BuddyPress - Version 2.9.5.1

Version Description

= 2.9.4 = See: https://codex.buddypress.org/releases/version-2-9-4/

Download this release

Release Info

Developer imath
Plugin Icon 128x128 BuddyPress
Version 2.9.5.1
Comparing to
See all releases

Code changes from version 9.0.0 to 2.9.5.1

Files changed (142) hide show
  1. bp-activity/actions/delete.php +0 -72
  2. bp-activity/actions/favorite.php +0 -36
  3. bp-activity/actions/feeds.php +0 -222
  4. bp-activity/actions/post.php +0 -100
  5. bp-activity/actions/reply.php +0 -66
  6. bp-activity/actions/spam.php +0 -77
  7. bp-activity/actions/unfavorite.php +0 -31
  8. bp-activity/admin/css/admin-rtl.css +0 -5
  9. bp-activity/admin/css/admin-rtl.min.css +1 -1
  10. bp-activity/admin/css/admin.css +0 -5
  11. bp-activity/admin/css/admin.min.css +1 -1
  12. bp-activity/admin/js/admin.js +20 -20
  13. bp-activity/admin/js/admin.min.js +1 -1
  14. bp-activity/bp-activity-actions.php +854 -0
  15. bp-activity/bp-activity-admin.php +58 -215
  16. bp-activity/bp-activity-adminbar.php +2 -2
  17. bp-activity/bp-activity-akismet.php +1 -1
  18. bp-activity/bp-activity-blocks.php +0 -167
  19. bp-activity/bp-activity-cssjs.php +4 -10
  20. bp-activity/bp-activity-embeds.php +12 -9
  21. bp-activity/bp-activity-filters.php +51 -53
  22. bp-activity/bp-activity-functions.php +64 -547
  23. bp-activity/bp-activity-notifications.php +10 -123
  24. bp-activity/bp-activity-screens.php +379 -0
  25. bp-activity/bp-activity-template.php +9 -41
  26. bp-activity/classes/class-bp-activity-activity.php +10 -71
  27. bp-activity/classes/class-bp-activity-component.php +6 -171
  28. bp-activity/classes/class-bp-activity-feed.php +77 -80
  29. bp-activity/classes/class-bp-activity-list-table.php +55 -113
  30. bp-activity/classes/class-bp-activity-query.php +2 -2
  31. bp-activity/classes/class-bp-activity-template.php +3 -5
  32. bp-activity/classes/class-bp-akismet.php +11 -54
  33. bp-activity/classes/class-bp-rest-activity-endpoint.php +0 -1589
  34. bp-activity/css/blocks/latest-activities-rtl.css +0 -81
  35. bp-activity/css/blocks/latest-activities-rtl.min.css +0 -1
  36. bp-activity/css/blocks/latest-activities.css +0 -81
  37. bp-activity/css/blocks/latest-activities.min.css +0 -1
  38. bp-activity/css/mentions-rtl.css +1 -0
  39. bp-activity/css/mentions-rtl.min.css +1 -1
  40. bp-activity/css/mentions.css +1 -0
  41. bp-activity/css/mentions.min.css +1 -1
  42. bp-activity/js/blocks/embed-activity.js +0 -20
  43. bp-activity/js/blocks/embed-activity.js.map +0 -1
  44. bp-activity/js/blocks/latest-activities.js +0 -8
  45. bp-activity/js/blocks/latest-activities.js.map +0 -1
  46. bp-activity/js/mentions.js +20 -22
  47. bp-activity/js/mentions.min.js +1 -1
  48. bp-activity/sass/blocks/latest-activities.scss +0 -100
  49. bp-activity/screens/directory.php +0 -37
  50. bp-activity/screens/favorites.php +0 -33
  51. bp-activity/screens/friends.php +0 -36
  52. bp-activity/screens/groups.php +0 -36
  53. bp-activity/screens/just-me.php +0 -32
  54. bp-activity/screens/mentions.php +0 -45
  55. bp-activity/screens/permalink.php +0 -166
  56. bp-blogs/{actions/random.php → bp-blogs-actions.php} +6 -3
  57. bp-blogs/bp-blogs-activity.php +46 -97
  58. bp-blogs/bp-blogs-blocks.php +0 -137
  59. bp-blogs/bp-blogs-cache.php +2 -2
  60. bp-blogs/bp-blogs-filters.php +0 -51
  61. bp-blogs/bp-blogs-functions.php +59 -241
  62. bp-blogs/bp-blogs-screens.php +73 -0
  63. bp-blogs/bp-blogs-template.php +184 -276
  64. bp-blogs/classes/class-bp-blogs-blog.php +1 -1
  65. bp-blogs/classes/class-bp-blogs-component.php +9 -127
  66. bp-blogs/classes/class-bp-blogs-recent-posts-widget.php +6 -18
  67. bp-blogs/classes/class-bp-rest-attachments-blog-avatar-endpoint.php +0 -325
  68. bp-blogs/classes/class-bp-rest-blogs-endpoint.php +0 -810
  69. bp-blogs/css/blocks/recent-posts-rtl.css +0 -42
  70. bp-blogs/css/blocks/recent-posts-rtl.min.css +0 -1
  71. bp-blogs/css/blocks/recent-posts.css +0 -42
  72. bp-blogs/css/blocks/recent-posts.min.css +0 -1
  73. bp-blogs/js/blocks/recent-posts.js +0 -8
  74. bp-blogs/js/blocks/recent-posts.js.map +0 -1
  75. bp-blogs/sass/blocks/recent-posts.scss +0 -46
  76. bp-blogs/screens/create.php +0 -30
  77. bp-blogs/screens/directory.php +0 -29
  78. bp-blogs/screens/my-blogs.php +0 -27
  79. bp-core/admin/bp-core-admin-actions.php +1 -1
  80. bp-core/admin/bp-core-admin-components.php +26 -66
  81. bp-core/admin/bp-core-admin-functions.php +173 -365
  82. bp-core/admin/bp-core-admin-optouts.php +0 -471
  83. bp-core/admin/bp-core-admin-schema.php +0 -99
  84. bp-core/admin/bp-core-admin-settings.php +63 -59
  85. bp-core/admin/bp-core-admin-slugs.php +22 -48
  86. bp-core/admin/bp-core-admin-tools.php +16 -270
  87. bp-core/admin/bp-core-admin-types.php +0 -298
  88. bp-core/admin/css/common-rtl.css +391 -255
  89. bp-core/admin/css/common-rtl.min.css +1 -1
  90. bp-core/admin/css/common.css +391 -255
  91. bp-core/admin/css/common.min.css +1 -1
  92. bp-core/admin/css/hello-rtl.css +0 -292
  93. bp-core/admin/css/hello-rtl.min.css +0 -1
  94. bp-core/admin/css/hello.css +0 -292
  95. bp-core/admin/css/hello.min.css +0 -1
  96. bp-core/admin/js/customizer-controls.min.js +1 -1
  97. bp-core/admin/js/customizer-receiver-emails.js +1 -1
  98. bp-core/admin/js/customizer-receiver-emails.min.js +1 -1
  99. bp-core/admin/js/dismissible-admin-notices.min.js +1 -1
  100. bp-core/admin/js/hello.js +0 -125
  101. bp-core/admin/js/hello.min.js +0 -1
  102. bp-core/admin/js/types-admin.js +0 -41
  103. bp-core/admin/js/types-admin.min.js +0 -1
  104. bp-core/admin/sass/hello.scss +0 -327
  105. bp-core/bp-core-actions.php +3 -14
  106. bp-core/bp-core-admin.php +0 -1
  107. bp-core/bp-core-adminbar.php +24 -3
  108. bp-core/bp-core-attachments.php +111 -216
  109. bp-core/bp-core-avatars.php +58 -131
  110. bp-core/bp-core-blocks.php +0 -399
  111. bp-core/bp-core-buddybar.php +7 -36
  112. bp-core/bp-core-cache.php +3 -67
  113. bp-core/bp-core-caps.php +3 -45
  114. bp-core/bp-core-catchuri.php +3 -3
  115. bp-core/bp-core-cssjs.php +31 -28
  116. bp-core/bp-core-customizer-email.php +6 -0
  117. bp-core/bp-core-dependency.php +1 -47
  118. bp-core/bp-core-filters.php +20 -103
  119. bp-core/bp-core-functions.php +331 -1101
  120. bp-core/bp-core-moderation.php +15 -34
  121. bp-core/bp-core-options.php +85 -3
  122. bp-core/bp-core-rest-api.php +0 -398
  123. bp-core/bp-core-taxonomy.php +21 -244
  124. bp-core/bp-core-template-loader.php +15 -84
  125. bp-core/bp-core-template.php +143 -210
  126. bp-core/bp-core-theme-compatibility.php +6 -29
  127. bp-core/bp-core-update.php +0 -162
  128. bp-core/bp-core-wpabstraction.php +0 -186
  129. bp-core/classes/class-bp-admin-types.php +0 -618
  130. bp-core/classes/class-bp-admin.php +361 -447
  131. bp-core/classes/class-bp-attachment-avatar.php +4 -7
  132. bp-core/classes/class-bp-attachment-cover-image.php +38 -8
  133. bp-core/classes/class-bp-attachment.php +2 -12
  134. bp-core/classes/class-bp-block.php +0 -219
  135. bp-core/classes/class-bp-button.php +0 -11
  136. bp-core/classes/class-bp-component.php +69 -213
  137. bp-core/classes/class-bp-core-login-widget.php +0 -2
  138. bp-core/classes/class-bp-core-nav.php +11 -11
  139. bp-core/classes/class-bp-core-notification.php +43 -78
  140. bp-core/classes/class-bp-core-oembed-extension.php +5 -6
  141. bp-core/classes/class-bp-core-user.php +21 -52
  142. bp-core/classes/class-bp-core.php +5 -33
bp-activity/actions/delete.php DELETED
@@ -1,72 +0,0 @@
1
- <?php
2
- /**
3
- * Activity: Delete action
4
- *
5
- * @package BuddyPress
6
- * @subpackage ActivityActions
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Delete specific activity item and redirect to previous page.
12
- *
13
- * @since 1.1.0
14
- *
15
- * @param int $activity_id Activity id to be deleted. Defaults to 0.
16
- * @return bool False on failure.
17
- */
18
- function bp_activity_action_delete_activity( $activity_id = 0 ) {
19
- // Not viewing activity or action is not delete.
20
- if ( !bp_is_activity_component() || !bp_is_current_action( 'delete' ) )
21
- return false;
22
-
23
- if ( empty( $activity_id ) && bp_action_variable( 0 ) )
24
- $activity_id = (int) bp_action_variable( 0 );
25
-
26
- // Not viewing a specific activity item.
27
- if ( empty( $activity_id ) )
28
- return false;
29
-
30
- // Check the nonce.
31
- check_admin_referer( 'bp_activity_delete_link' );
32
-
33
- // Load up the activity item.
34
- $activity = new BP_Activity_Activity( $activity_id );
35
-
36
- // Check access.
37
- if ( ! bp_activity_user_can_delete( $activity ) )
38
- return false;
39
-
40
- /**
41
- * Fires before the deletion so plugins can still fetch information about it.
42
- *
43
- * @since 1.5.0
44
- *
45
- * @param int $activity_id The activity ID.
46
- * @param int $user_id The user associated with the activity.
47
- */
48
- do_action( 'bp_activity_before_action_delete_activity', $activity_id, $activity->user_id );
49
-
50
- // Delete the activity item and provide user feedback.
51
- if ( bp_activity_delete( array( 'id' => $activity_id, 'user_id' => $activity->user_id ) ) )
52
- bp_core_add_message( __( 'Activity deleted successfully', 'buddypress' ) );
53
- else
54
- bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
55
-
56
- /**
57
- * Fires after the deletion so plugins can act afterwards based on the activity.
58
- *
59
- * @since 1.1.0
60
- *
61
- * @param int $activity_id The activity ID.
62
- * @param int $user_id The user associated with the activity.
63
- */
64
- do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id );
65
-
66
- // Check for the redirect query arg, otherwise let WP handle things.
67
- if ( !empty( $_GET['redirect_to'] ) )
68
- bp_core_redirect( esc_url( $_GET['redirect_to'] ) );
69
- else
70
- bp_core_redirect( wp_get_referer() );
71
- }
72
- add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/actions/favorite.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
- /**
3
- * Activity: Favorite action
4
- *
5
- * @package BuddyPress
6
- * @subpackage ActivityActions
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Mark activity as favorite.
12
- *
13
- * @since 1.2.0
14
- *
15
- * @return bool False on failure.
16
- */
17
- function bp_activity_action_mark_favorite() {
18
- if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'favorite' ) )
19
- return false;
20
-
21
- // Check the nonce.
22
- check_admin_referer( 'mark_favorite' );
23
-
24
- $activity_item = new BP_Activity_Activity( bp_action_variable( 0 ) );
25
- if ( ! bp_activity_user_can_read( $activity_item, bp_loggedin_user_id() ) ) {
26
- return false;
27
- }
28
-
29
- if ( bp_activity_add_user_favorite( bp_action_variable( 0 ) ) )
30
- bp_core_add_message( __( 'Activity marked as favorite.', 'buddypress' ) );
31
- else
32
- bp_core_add_message( __( 'There was an error marking that activity as a favorite. Please try again.', 'buddypress' ), 'error' );
33
-
34
- bp_core_redirect( wp_get_referer() . '#activity-' . bp_action_variable( 0 ) );
35
- }
36
- add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/actions/feeds.php DELETED
@@ -1,222 +0,0 @@
1
- <?php
2
- /**
3
- * Activity: RSS feed actions
4
- *
5
- * @package BuddyPress
6
- * @subpackage ActivityActions
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Load the sitewide activity feed.
12
- *
13
- * @since 1.0.0
14
- *
15
- * @return bool False on failure.
16
- */
17
- function bp_activity_action_sitewide_feed() {
18
- $bp = buddypress();
19
-
20
- if ( ! bp_is_activity_component() || ! bp_is_current_action( 'feed' ) || bp_is_user() || ! empty( $bp->groups->current_group ) ) {
21
- return false;
22
- }
23
-
24
- $link = bp_get_activity_directory_permalink();
25
-
26
- // Setup the feed.
27
- buddypress()->activity->feed = new BP_Activity_Feed( array(
28
- 'id' => 'sitewide',
29
-
30
- /* translators: %s Site Name */
31
- 'title' => sprintf( __( '%s | Site-Wide Activity', 'buddypress' ), bp_get_site_name() ),
32
- 'link' => $link,
33
- 'description' => __( 'Activity feed for the entire site.', 'buddypress' ),
34
- 'activity_args' => 'display_comments=threaded'
35
- ) );
36
-
37
- if ( ! buddypress()->activity->feed->enabled ) {
38
- bp_core_redirect( $link );
39
- }
40
- }
41
- add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
42
-
43
- /**
44
- * Load a user's personal activity feed.
45
- *
46
- * @since 1.0.0
47
- *
48
- * @return bool False on failure.
49
- */
50
- function bp_activity_action_personal_feed() {
51
- if ( ! bp_is_user_activity() || ! bp_is_current_action( 'feed' ) ) {
52
- return false;
53
- }
54
-
55
- $link = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() );
56
-
57
- // Setup the feed.
58
- buddypress()->activity->feed = new BP_Activity_Feed( array(
59
- 'id' => 'personal',
60
-
61
- /* translators: 1: Site Name. 2: User Display Name. */
62
- 'title' => sprintf( _x( '%1$s | %2$s | Activity', 'Personal activity feed title', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
63
- 'link' => $link,
64
-
65
- /* translators: %s: User Display Name */
66
- 'description' => sprintf( __( 'Activity feed for %s.', 'buddypress' ), bp_get_displayed_user_fullname() ),
67
- 'activity_args' => 'user_id=' . bp_displayed_user_id()
68
- ) );
69
-
70
- if ( ! buddypress()->activity->feed->enabled ) {
71
- bp_core_redirect( $link );
72
- }
73
- }
74
- add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
75
-
76
- /**
77
- * Load a user's friends' activity feed.
78
- *
79
- * @since 1.0.0
80
- *
81
- * @return bool False on failure.
82
- */
83
- function bp_activity_action_friends_feed() {
84
- if ( ! bp_is_active( 'friends' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_friends_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
85
- return false;
86
- }
87
-
88
- $link = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() );
89
-
90
- // Setup the feed.
91
- buddypress()->activity->feed = new BP_Activity_Feed( array(
92
- 'id' => 'friends',
93
-
94
- /* translators: 1: Site Name 2: User Display Name */
95
- 'title' => sprintf( __( '%1$s | %2$s | Friends Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
96
- 'link' => $link,
97
-
98
- /* translators: %s: User Display Name */
99
- 'description' => sprintf( __( "Activity feed for %s's friends.", 'buddypress' ), bp_get_displayed_user_fullname() ),
100
- 'activity_args' => 'scope=friends'
101
- ) );
102
-
103
- if ( ! buddypress()->activity->feed->enabled ) {
104
- bp_core_redirect( $link );
105
- }
106
- }
107
- add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
108
-
109
- /**
110
- * Load the activity feed for a user's groups.
111
- *
112
- * @since 1.2.0
113
- *
114
- * @return bool False on failure.
115
- */
116
- function bp_activity_action_my_groups_feed() {
117
- if ( ! bp_is_active( 'groups' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_groups_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
118
- return false;
119
- }
120
-
121
- // Get displayed user's group IDs.
122
- $groups = groups_get_user_groups();
123
- $group_ids = implode( ',', $groups['groups'] );
124
- $link = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() );
125
-
126
- // Setup the feed.
127
- buddypress()->activity->feed = new BP_Activity_Feed( array(
128
- 'id' => 'mygroups',
129
-
130
- /* translators: 1: Site Name 2: User Display Name */
131
- 'title' => sprintf( __( '%1$s | %2$s | Group Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
132
- 'link' => $link,
133
-
134
- /* translators: %s: User Display Name */
135
- 'description' => sprintf( __( "Public group activity feed of which %s is a member.", 'buddypress' ), bp_get_displayed_user_fullname() ),
136
- 'activity_args' => array(
137
- 'object' => buddypress()->groups->id,
138
- 'primary_id' => $group_ids,
139
- 'display_comments' => 'threaded'
140
- )
141
- ) );
142
-
143
- if ( ! buddypress()->activity->feed->enabled ) {
144
- bp_core_redirect( $link );
145
- }
146
- }
147
- add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
148
-
149
- /**
150
- * Load a user's @mentions feed.
151
- *
152
- * @since 1.2.0
153
- *
154
- * @return bool False on failure.
155
- */
156
- function bp_activity_action_mentions_feed() {
157
- if ( ! bp_activity_do_mentions() ) {
158
- return false;
159
- }
160
-
161
- if ( ! bp_is_user_activity() || ! bp_is_current_action( 'mentions' ) || ! bp_is_action_variable( 'feed', 0 ) ) {
162
- return false;
163
- }
164
-
165
- $link = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions' );
166
-
167
- // Setup the feed.
168
- buddypress()->activity->feed = new BP_Activity_Feed( array(
169
- 'id' => 'mentions',
170
-
171
- /* translators: 1: Site Name 2: User Display Name */
172
- 'title' => sprintf( __( '%1$s | %2$s | Mentions', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
173
- 'link' => $link,
174
-
175
- /* translators: %s: User Display Name */
176
- 'description' => sprintf( __( "Activity feed mentioning %s.", 'buddypress' ), bp_get_displayed_user_fullname() ),
177
- 'activity_args' => array(
178
- 'search_terms' => '@' . bp_core_get_username( bp_displayed_user_id() )
179
- )
180
- ) );
181
-
182
- if ( ! buddypress()->activity->feed->enabled ) {
183
- bp_core_redirect( $link );
184
- }
185
- }
186
- add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
187
-
188
- /**
189
- * Load a user's favorites feed.
190
- *
191
- * @since 1.2.0
192
- *
193
- * @return bool False on failure.
194
- */
195
- function bp_activity_action_favorites_feed() {
196
- if ( ! bp_is_user_activity() || ! bp_is_current_action( 'favorites' ) || ! bp_is_action_variable( 'feed', 0 ) ) {
197
- return false;
198
- }
199
-
200
- // Get displayed user's favorite activity IDs.
201
- $favs = bp_activity_get_user_favorites( bp_displayed_user_id() );
202
- $fav_ids = implode( ',', (array) $favs );
203
- $link = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites' );
204
-
205
- // Setup the feed.
206
- buddypress()->activity->feed = new BP_Activity_Feed( array(
207
- 'id' => 'favorites',
208
-
209
- /* translators: 1: Site Name 2: User Display Name */
210
- 'title' => sprintf( __( '%1$s | %2$s | Favorites', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
211
- 'link' => $link,
212
-
213
- /* translators: %s: User Display Name */
214
- 'description' => sprintf( __( "Activity feed of %s's favorites.", 'buddypress' ), bp_get_displayed_user_fullname() ),
215
- 'activity_args' => 'include=' . $fav_ids
216
- ) );
217
-
218
- if ( ! buddypress()->activity->feed->enabled ) {
219
- bp_core_redirect( $link );
220
- }
221
- }
222
- add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/actions/post.php DELETED
@@ -1,100 +0,0 @@
1
- <?php
2
- /**
3
- * Activity: Post action
4
- *
5
- * @package BuddyPress
6
- * @subpackage ActivityActions
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Post user/group activity update.
12
- *
13
- * @since 1.2.0
14
- *
15
- * @return bool False on failure.
16
- */
17
- function bp_activity_action_post_update() {
18
- // Do not proceed if user is not logged in, not viewing activity, or not posting.
19
- if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'post' ) )
20
- return false;
21
-
22
- // Check the nonce.
23
- check_admin_referer( 'post_update', '_wpnonce_post_update' );
24
-
25
- /**
26
- * Filters the content provided in the activity input field.
27
- *
28
- * @since 1.2.0
29
- *
30
- * @param string $value Activity message being posted.
31
- */
32
- $content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
33
-
34
- if ( ! empty( $_POST['whats-new-post-object'] ) ) {
35
-
36
- /**
37
- * Filters the item type that the activity update should be associated with.
38
- *
39
- * @since 1.2.0
40
- *
41
- * @param string $value Item type to associate with.
42
- */
43
- $object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
44
- }
45
-
46
- if ( ! empty( $_POST['whats-new-post-in'] ) ) {
47
-
48
- /**
49
- * Filters what component the activity is being to.
50
- *
51
- * @since 1.2.0
52
- *
53
- * @param string $value Chosen component to post activity to.
54
- */
55
- $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
56
- }
57
-
58
- // No activity content so provide feedback and redirect.
59
- if ( empty( $content ) ) {
60
- bp_core_add_message( __( 'Please enter some content to post.', 'buddypress' ), 'error' );
61
- bp_core_redirect( wp_get_referer() );
62
- }
63
-
64
- // No existing item_id.
65
- if ( empty( $item_id ) ) {
66
- $activity_id = bp_activity_post_update( array( 'content' => $content ) );
67
-
68
- // Post to groups object.
69
- } elseif ( 'groups' == $object && bp_is_active( 'groups' ) ) {
70
- if ( (int) $item_id ) {
71
- $activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) );
72
- }
73
-
74
- } else {
75
-
76
- /**
77
- * Filters activity object for BuddyPress core and plugin authors before posting activity update.
78
- *
79
- * @since 1.2.0
80
- * @since 5.0.0 Fixed filter signature to match other instances of filter,
81
- * with $activity_id as the first param.
82
- *
83
- * @param int $activity_id ID of the activity item.
84
- * @param string $object Activity item being associated to.
85
- * @param string $item_id Component ID being posted to.
86
- * @param string $content Activity content being posted.
87
- */
88
- $activity_id = apply_filters( 'bp_activity_custom_update', 0, $object, $item_id, $content );
89
- }
90
-
91
- // Provide user feedback.
92
- if ( !empty( $activity_id ) )
93
- bp_core_add_message( __( 'Update Posted!', 'buddypress' ) );
94
- else
95
- bp_core_add_message( __( 'There was an error when posting your update. Please try again.', 'buddypress' ), 'error' );
96
-
97
- // Redirect.
98
- bp_core_redirect( wp_get_referer() );
99
- }
100
- add_action( 'bp_actions', 'bp_activity_action_post_update' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/actions/reply.php DELETED
@@ -1,66 +0,0 @@
1
- <?php
2
- /**
3
- * Activity: Reply action
4
- *
5
- * @package BuddyPress
6
- * @subpackage ActivityActions
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Post new activity comment.
12
- *
13
- * @since 1.2.0
14
- *
15
- * @return bool False on failure.
16
- */
17
- function bp_activity_action_post_comment() {
18
- if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'reply' ) )
19
- return false;
20
-
21
- // Check the nonce.
22
- check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' );
23
-
24
- /**
25
- * Filters the activity ID a comment will be in reply to.
26
- *
27
- * @since 1.2.0
28
- *
29
- * @param string $value ID of the activity being replied to.
30
- */
31
- $activity_id = apply_filters( 'bp_activity_post_comment_activity_id', $_POST['comment_form_id'] );
32
-
33
- /**
34
- * Filters the comment content for a comment reply.
35
- *
36
- * @since 1.2.0
37
- *
38
- * @param string $value Comment content being posted.
39
- */
40
- $content = apply_filters( 'bp_activity_post_comment_content', $_POST['ac_input_' . $activity_id] );
41
-
42
- if ( empty( $content ) ) {
43
- bp_core_add_message( __( 'Please do not leave the comment area blank.', 'buddypress' ), 'error' );
44
- bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id );
45
- }
46
-
47
- $activity_item = new BP_Activity_Activity( $activity_id );
48
- if ( ! bp_activity_user_can_read( $activity_item ) ) {
49
- bp_core_add_message( __( 'There was an error posting that reply. Please try again.', 'buddypress' ), 'error' );
50
- bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id );
51
- }
52
-
53
- $comment_id = bp_activity_new_comment( array(
54
- 'content' => $content,
55
- 'activity_id' => $activity_id,
56
- 'parent_id' => false
57
- ));
58
-
59
- if ( !empty( $comment_id ) )
60
- bp_core_add_message( __( 'Reply Posted!', 'buddypress' ) );
61
- else
62
- bp_core_add_message( __( 'There was an error posting that reply. Please try again.', 'buddypress' ), 'error' );
63
-
64
- bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id );
65
- }
66
- add_action( 'bp_actions', 'bp_activity_action_post_comment' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/actions/spam.php DELETED
@@ -1,77 +0,0 @@
1
- <?php
2
- /**
3
- * Activity: Spam action
4
- *
5
- * @package BuddyPress
6
- * @subpackage ActivityActions
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Mark specific activity item as spam and redirect to previous page.
12
- *
13
- * @since 1.6.0
14
- *
15
- * @param int $activity_id Activity id to be deleted. Defaults to 0.
16
- * @return bool False on failure.
17
- */
18
- function bp_activity_action_spam_activity( $activity_id = 0 ) {
19
- $bp = buddypress();
20
-
21
- // Not viewing activity, or action is not spam, or Akismet isn't present.
22
- if ( !bp_is_activity_component() || !bp_is_current_action( 'spam' ) || empty( $bp->activity->akismet ) )
23
- return false;
24
-
25
- if ( empty( $activity_id ) && bp_action_variable( 0 ) )
26
- $activity_id = (int) bp_action_variable( 0 );
27
-
28
- // Not viewing a specific activity item.
29
- if ( empty( $activity_id ) )
30
- return false;
31
-
32
- // Is the current user allowed to spam items?
33
- if ( !bp_activity_user_can_mark_spam() )
34
- return false;
35
-
36
- // Load up the activity item.
37
- $activity = new BP_Activity_Activity( $activity_id );
38
- if ( empty( $activity->id ) )
39
- return false;
40
-
41
- // Check nonce.
42
- check_admin_referer( 'bp_activity_akismet_spam_' . $activity->id );
43
-
44
- /**
45
- * Fires before the marking activity as spam so plugins can modify things if they want to.
46
- *
47
- * @since 1.6.0
48
- *
49
- * @param int $activity_id Activity ID to be marked as spam.
50
- * @param object $activity Activity object for the ID to be marked as spam.
51
- */
52
- do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity );
53
-
54
- // Mark as spam.
55
- bp_activity_mark_as_spam( $activity );
56
- $activity->save();
57
-
58
- // Tell the user the spamming has been successful.
59
- bp_core_add_message( __( 'The activity item has been marked as spam and is no longer visible.', 'buddypress' ) );
60
-
61
- /**
62
- * Fires after the marking activity as spam so plugins can act afterwards based on the activity.
63
- *
64
- * @since 1.6.0
65
- *
66
- * @param int $activity_id Activity ID that was marked as spam.
67
- * @param int $user_id User ID associated with activity.
68
- */
69
- do_action( 'bp_activity_action_spam_activity', $activity_id, $activity->user_id );
70
-
71
- // Check for the redirect query arg, otherwise let WP handle things.
72
- if ( !empty( $_GET['redirect_to'] ) )
73
- bp_core_redirect( esc_url( $_GET['redirect_to'] ) );
74
- else
75
- bp_core_redirect( wp_get_referer() );
76
- }
77
- add_action( 'bp_actions', 'bp_activity_action_spam_activity' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/actions/unfavorite.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
- /**
3
- * Activity: Unfavorite action
4
- *
5
- * @package BuddyPress
6
- * @subpackage ActivityActions
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Remove activity from favorites.
12
- *
13
- * @since 1.2.0
14
- *
15
- * @return bool False on failure.
16
- */
17
- function bp_activity_action_remove_favorite() {
18
- if ( ! is_user_logged_in() || ! bp_is_activity_component() || ! bp_is_current_action( 'unfavorite' ) )
19
- return false;
20
-
21
- // Check the nonce.
22
- check_admin_referer( 'unmark_favorite' );
23
-
24
- if ( bp_activity_remove_user_favorite( bp_action_variable( 0 ) ) )
25
- bp_core_add_message( __( 'Activity removed as favorite.', 'buddypress' ) );
26
- else
27
- bp_core_add_message( __( 'There was an error removing that activity as a favorite. Please try again.', 'buddypress' ), 'error' );
28
-
29
- bp_core_redirect( wp_get_referer() . '#activity-' . bp_action_variable( 0 ) );
30
- }
31
- add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/admin/css/admin-rtl.css CHANGED
@@ -97,11 +97,6 @@
97
  width: 12%;
98
  }
99
 
100
- ul.bp-activity-delete-list {
101
- list-style-type: disc;
102
- margin: 4px 26px;
103
- }
104
-
105
  @media screen and (max-width: 782px) {
106
 
107
  body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column) {
97
  width: 12%;
98
  }
99
 
 
 
 
 
 
100
  @media screen and (max-width: 782px) {
101
 
102
  body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column) {
bp-activity/admin/css/admin-rtl.min.css CHANGED
@@ -1 +1 @@
1
- .akismet-status{float:left}.akismet-status a{color:#aaa;font-style:italic}.akismet-history{margin:13px}.akismet-history div{margin-bottom:13px}.akismet-history span{color:#999}#wp-bp-activities-wrap{padding:5px 0}#bp-activities{height:120px}#bp-replyhead{font-size:1em;line-height:1.4;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:left;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:right;margin-bottom:5px;margin-left:10px;margin-top:1px}.activity-errors{list-style-type:disc;margin-right:2em}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0}#bp_activity_action h3,#bp_activity_content h3{cursor:auto}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:#fff}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px}#bp_activity_link input{width:99%}#bp-activities-primaryid{margin-bottom:1em}.column-action{width:12%}ul.bp-activity-delete-list{list-style-type:disc;margin:4px 26px}@media screen and (max-width:782px){body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column){display:table-cell}}
1
+ .akismet-status{float:left}.akismet-status a{color:#aaa;font-style:italic}.akismet-history{margin:13px}.akismet-history div{margin-bottom:13px}.akismet-history span{color:#999}#wp-bp-activities-wrap{padding:5px 0}#bp-activities{height:120px}#bp-replyhead{font-size:1em;line-height:1.4;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:left;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:right;margin-bottom:5px;margin-left:10px;margin-top:1px}.activity-errors{list-style-type:disc;margin-right:2em}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0}#bp_activity_action h3,#bp_activity_content h3{cursor:auto}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:#fff}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px}#bp_activity_link input{width:99%}#bp-activities-primaryid{margin-bottom:1em}.column-action{width:12%}@media screen and (max-width:782px){body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column){display:table-cell}}
bp-activity/admin/css/admin.css CHANGED
@@ -97,11 +97,6 @@
97
  width: 12%;
98
  }
99
 
100
- ul.bp-activity-delete-list {
101
- list-style-type: disc;
102
- margin: 4px 26px;
103
- }
104
-
105
  @media screen and (max-width: 782px) {
106
 
107
  body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column) {
97
  width: 12%;
98
  }
99
 
 
 
 
 
 
100
  @media screen and (max-width: 782px) {
101
 
102
  body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column) {
bp-activity/admin/css/admin.min.css CHANGED
@@ -1 +1 @@
1
- .akismet-status{float:right}.akismet-status a{color:#aaa;font-style:italic}.akismet-history{margin:13px}.akismet-history div{margin-bottom:13px}.akismet-history span{color:#999}#wp-bp-activities-wrap{padding:5px 0}#bp-activities{height:120px}#bp-replyhead{font-size:1em;line-height:1.4;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:left;margin-bottom:5px;margin-right:10px;margin-top:1px}.activity-errors{list-style-type:disc;margin-left:2em}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0}#bp_activity_action h3,#bp_activity_content h3{cursor:auto}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:#fff}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px}#bp_activity_link input{width:99%}#bp-activities-primaryid{margin-bottom:1em}.column-action{width:12%}ul.bp-activity-delete-list{list-style-type:disc;margin:4px 26px}@media screen and (max-width:782px){body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column){display:table-cell}}
1
+ .akismet-status{float:right}.akismet-status a{color:#aaa;font-style:italic}.akismet-history{margin:13px}.akismet-history div{margin-bottom:13px}.akismet-history span{color:#999}#wp-bp-activities-wrap{padding:5px 0}#bp-activities{height:120px}#bp-replyhead{font-size:1em;line-height:1.4;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:left;margin-bottom:5px;margin-right:10px;margin-top:1px}.activity-errors{list-style-type:disc;margin-left:2em}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0}#bp_activity_action h3,#bp_activity_content h3{cursor:auto}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:#fff}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px}#bp_activity_link input{width:99%}#bp-activities-primaryid{margin-bottom:1em}.column-action{width:12%}@media screen and (max-width:782px){body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column){display:table-cell}}
bp-activity/admin/js/admin.js CHANGED
@@ -2,7 +2,7 @@
2
  (function( $ ) {
3
 
4
  /**
5
- * Activity reply object for the activity index screen.
6
  *
7
  * @since 1.6.0
8
  */
@@ -18,7 +18,7 @@ var activityReply = {
18
  $(document).on( 'click', '#bp-activities-container a.cancel', activityReply.close );
19
  $(document).on( 'click', '#bp-activities-container a.save', activityReply.send );
20
 
21
- // Close textarea on escape.
22
  $(document).on( 'keyup', '#bp-activities:visible', function( e ) {
23
  if ( 27 === e.which ) {
24
  activityReply.close();
@@ -32,7 +32,7 @@ var activityReply = {
32
  * @since 1.6.0
33
  */
34
  open : function() {
35
- // Hide the container row, and move it to the new location.
36
  var box = $( '#bp-activities-container' ).hide();
37
  $( this ).parents( 'tr' ).after( box );
38
 
@@ -49,13 +49,13 @@ var activityReply = {
49
  * @since 1.6.0
50
  */
51
  close : function() {
52
- // Hide the container row.
53
  $('#bp-activities-container').fadeOut( '200', function () {
54
 
55
- // Empty and unfocus the text area.
56
  $( '#bp-activities' ).val( '' ).blur();
57
 
58
- // Remove any error message and disable the spinner.
59
  $( '#bp-replysubmit .error' ).html( '' ).hide();
60
  $( '#bp-replysubmit .waiting' ).hide();
61
  });
@@ -69,27 +69,27 @@ var activityReply = {
69
  * @since 1.6.0
70
  */
71
  send : function() {
72
- // Hide any existing error message, and show the loading spinner.
73
  $( '#bp-replysubmit .error' ).hide();
74
  $( '#bp-replysubmit .waiting' ).show();
75
 
76
- // Grab the nonce.
77
  var reply = {};
78
  reply['_ajax_nonce-bp-activity-admin-reply'] = $( '#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]' ).val();
79
 
80
- // Get the rest of the data.
81
  reply.action = 'bp-activity-admin-reply';
82
  reply.content = $( '#bp-activities' ).val();
83
  reply.parent_id = $( '#bp-activities-container' ).prev().data( 'parent_id' );
84
  reply.root_id = $( '#bp-activities-container' ).prev().data( 'root_id' );
85
 
86
- // Make the AJAX call.
87
  $.ajax({
88
  data : reply,
89
  type : 'POST',
90
  url : ajaxurl,
91
 
92
- // Callbacks.
93
  error : function( r ) { activityReply.error( r ); },
94
  success : function( r ) { activityReply.show( r ); }
95
  });
@@ -98,7 +98,7 @@ var activityReply = {
98
  },
99
 
100
  /**
101
- * send() error message handler.
102
  *
103
  * @since 1.6.0
104
  */
@@ -116,14 +116,14 @@ var activityReply = {
116
  },
117
 
118
  /**
119
- * send() success handler.
120
  *
121
  * @since 1.6.0
122
  */
123
  show : function ( xml ) {
124
  var bg, id, response;
125
 
126
- // Handle any errors in the response.
127
  if ( typeof( xml ) === 'string' ) {
128
  activityReply.error( { 'responseText': xml } );
129
  return false;
@@ -139,17 +139,17 @@ var activityReply = {
139
  // Close and reset the reply row, and add the new Activity item into the list.
140
  $('#bp-activities-container').fadeOut( '200', function () {
141
 
142
- // Empty and unfocus the text area.
143
  $( '#bp-activities' ).val( '' ).blur();
144
 
145
- // Remove any error message and disable the spinner.
146
  $( '#bp-replysubmit .error' ).html( '' ).hide();
147
  $( '#bp-replysubmit .waiting' ).hide();
148
 
149
- // Insert new activity item.
150
  $( '#bp-activities-container' ).before( response.data );
151
 
152
- // Get background colour and animate the flash.
153
  id = $( '#activity-' + response.id );
154
  bg = id.closest( '.widefat' ).css( 'backgroundColor' );
155
  id.animate( { 'backgroundColor': '#CEB' }, 300 ).animate( { 'backgroundColor': bg }, 300 );
@@ -158,10 +158,10 @@ var activityReply = {
158
  };
159
 
160
  $(document).ready( function () {
161
- // Create the Activity reply object after domready event.
162
  activityReply.init();
163
 
164
- // On the edit screen, unload the close/open toggle js for the action & content metaboxes.
165
  $( '#bp_activity_action h3, #bp_activity_content h3' ).unbind( 'click' );
166
 
167
  // redo the post box toggles to reset the one made by comment.js in favor
2
  (function( $ ) {
3
 
4
  /**
5
+ * Activity reply object for the activity index screen
6
  *
7
  * @since 1.6.0
8
  */
18
  $(document).on( 'click', '#bp-activities-container a.cancel', activityReply.close );
19
  $(document).on( 'click', '#bp-activities-container a.save', activityReply.send );
20
 
21
+ // Close textarea on escape
22
  $(document).on( 'keyup', '#bp-activities:visible', function( e ) {
23
  if ( 27 === e.which ) {
24
  activityReply.close();
32
  * @since 1.6.0
33
  */
34
  open : function() {
35
+ // Hide the container row, and move it to the new location
36
  var box = $( '#bp-activities-container' ).hide();
37
  $( this ).parents( 'tr' ).after( box );
38
 
49
  * @since 1.6.0
50
  */
51
  close : function() {
52
+ // Hide the container row
53
  $('#bp-activities-container').fadeOut( '200', function () {
54
 
55
+ // Empty and unfocus the text area
56
  $( '#bp-activities' ).val( '' ).blur();
57
 
58
+ // Remove any error message and disable the spinner
59
  $( '#bp-replysubmit .error' ).html( '' ).hide();
60
  $( '#bp-replysubmit .waiting' ).hide();
61
  });
69
  * @since 1.6.0
70
  */
71
  send : function() {
72
+ // Hide any existing error message, and show the loading spinner
73
  $( '#bp-replysubmit .error' ).hide();
74
  $( '#bp-replysubmit .waiting' ).show();
75
 
76
+ // Grab the nonce
77
  var reply = {};
78
  reply['_ajax_nonce-bp-activity-admin-reply'] = $( '#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]' ).val();
79
 
80
+ // Get the rest of the data
81
  reply.action = 'bp-activity-admin-reply';
82
  reply.content = $( '#bp-activities' ).val();
83
  reply.parent_id = $( '#bp-activities-container' ).prev().data( 'parent_id' );
84
  reply.root_id = $( '#bp-activities-container' ).prev().data( 'root_id' );
85
 
86
+ // Make the AJAX call
87
  $.ajax({
88
  data : reply,
89
  type : 'POST',
90
  url : ajaxurl,
91
 
92
+ // Callbacks
93
  error : function( r ) { activityReply.error( r ); },
94
  success : function( r ) { activityReply.show( r ); }
95
  });
98
  },
99
 
100
  /**
101
+ * send() error message handler
102
  *
103
  * @since 1.6.0
104
  */
116
  },
117
 
118
  /**
119
+ * send() success handler
120
  *
121
  * @since 1.6.0
122
  */
123
  show : function ( xml ) {
124
  var bg, id, response;
125
 
126
+ // Handle any errors in the response
127
  if ( typeof( xml ) === 'string' ) {
128
  activityReply.error( { 'responseText': xml } );
129
  return false;
139
  // Close and reset the reply row, and add the new Activity item into the list.
140
  $('#bp-activities-container').fadeOut( '200', function () {
141
 
142
+ // Empty and unfocus the text area
143
  $( '#bp-activities' ).val( '' ).blur();
144
 
145
+ // Remove any error message and disable the spinner
146
  $( '#bp-replysubmit .error' ).html( '' ).hide();
147
  $( '#bp-replysubmit .waiting' ).hide();
148
 
149
+ // Insert new activity item
150
  $( '#bp-activities-container' ).before( response.data );
151
 
152
+ // Get background colour and animate the flash
153
  id = $( '#activity-' + response.id );
154
  bg = id.closest( '.widefat' ).css( 'backgroundColor' );
155
  id.animate( { 'backgroundColor': '#CEB' }, 300 ).animate( { 'backgroundColor': bg }, 300 );
158
  };
159
 
160
  $(document).ready( function () {
161
+ // Create the Activity reply object after domready event
162
  activityReply.init();
163
 
164
+ // On the edit screen, unload the close/open toggle js for the action & content metaboxes
165
  $( '#bp_activity_action h3, #bp_activity_content h3' ).unbind( 'click' );
166
 
167
  // redo the post box toggles to reset the one made by comment.js in favor
bp-activity/admin/js/admin.min.js CHANGED
@@ -1 +1 @@
1
- !function(a){var r={init:function(){a(document).on("click",".row-actions a.reply",r.open),a(document).on("click","#bp-activities-container a.cancel",r.close),a(document).on("click","#bp-activities-container a.save",r.send),a(document).on("keyup","#bp-activities:visible",function(i){27===i.which&&r.close()})},open:function(){var i=a("#bp-activities-container").hide();return a(this).parents("tr").after(i),i.fadeIn("300"),a("#bp-activities").focus(),!1},close:function(){return a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide()}),!1},send:function(){a("#bp-replysubmit .error").hide(),a("#bp-replysubmit .waiting").show();var i={};return i["_ajax_nonce-bp-activity-admin-reply"]=a('#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]').val(),i.action="bp-activity-admin-reply",i.content=a("#bp-activities").val(),i.parent_id=a("#bp-activities-container").prev().data("parent_id"),i.root_id=a("#bp-activities-container").prev().data("root_id"),a.ajax({data:i,type:"POST",url:ajaxurl,error:function(i){r.error(i)},success:function(i){r.show(i)}}),!1},error:function(i){var t=i.statusText;a("#bp-replysubmit .waiting").hide(),(t=i.responseText?i.responseText.replace(/<.[^<>]*?>/g,""):t)&&a("#bp-replysubmit .error").html(t).show()},show:function(i){var t,e,n;return"string"==typeof i?(r.error({responseText:i}),!1):(n=wpAjax.parseAjaxResponse(i)).errors?(r.error({responseText:wpAjax.broken}),!1):(n=n.responses[0],void a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide(),a("#bp-activities-container").before(n.data),e=a("#activity-"+n.id),t=e.closest(".widefat").css("backgroundColor"),e.animate({backgroundColor:"#CEB"},300).animate({backgroundColor:t},300)}))}};a(document).ready(function(){r.init(),a("#bp_activity_action h3, #bp_activity_content h3").unbind("click"),"undefined"!=typeof postboxes&&postboxes.add_postbox_toggles(bp_activity_admin_vars.page)})}(jQuery);
1
+ !function(i){var t={init:function(){i(document).on("click",".row-actions a.reply",t.open),i(document).on("click","#bp-activities-container a.cancel",t.close),i(document).on("click","#bp-activities-container a.save",t.send),i(document).on("keyup","#bp-activities:visible",function(i){27===i.which&&t.close()})},open:function(){var t=i("#bp-activities-container").hide();return i(this).parents("tr").after(t),t.fadeIn("300"),i("#bp-activities").focus(),!1},close:function(){return i("#bp-activities-container").fadeOut("200",function(){i("#bp-activities").val("").blur(),i("#bp-replysubmit .error").html("").hide(),i("#bp-replysubmit .waiting").hide()}),!1},send:function(){i("#bp-replysubmit .error").hide(),i("#bp-replysubmit .waiting").show();var e={};return e["_ajax_nonce-bp-activity-admin-reply"]=i('#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]').val(),e.action="bp-activity-admin-reply",e.content=i("#bp-activities").val(),e.parent_id=i("#bp-activities-container").prev().data("parent_id"),e.root_id=i("#bp-activities-container").prev().data("root_id"),i.ajax({data:e,type:"POST",url:ajaxurl,error:function(i){t.error(i)},success:function(i){t.show(i)}}),!1},error:function(t){var e=t.statusText;i("#bp-replysubmit .waiting").hide(),t.responseText&&(e=t.responseText.replace(/<.[^<>]*?>/g,"")),e&&i("#bp-replysubmit .error").html(e).show()},show:function(e){var n,a,r;return"string"==typeof e?(t.error({responseText:e}),!1):(r=wpAjax.parseAjaxResponse(e)).errors?(t.error({responseText:wpAjax.broken}),!1):(r=r.responses[0],void i("#bp-activities-container").fadeOut("200",function(){i("#bp-activities").val("").blur(),i("#bp-replysubmit .error").html("").hide(),i("#bp-replysubmit .waiting").hide(),i("#bp-activities-container").before(r.data),a=i("#activity-"+r.id),n=a.closest(".widefat").css("backgroundColor"),a.animate({backgroundColor:"#CEB"},300).animate({backgroundColor:n},300)}))}};i(document).ready(function(){t.init(),i("#bp_activity_action h3, #bp_activity_content h3").unbind("click"),"undefined"!=typeof postboxes&&postboxes.add_postbox_toggles(bp_activity_admin_vars.page)})}(jQuery);
bp-activity/bp-activity-actions.php ADDED
@@ -0,0 +1,854 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Action functions are exactly the same as screen functions, however they do
4
+ * not have a template screen associated with them. Usually they will send the
5
+ * user back to the default screen after execution.
6
+ *
7
+ * @package BuddyPress
8
+ * @subpackage ActivityActions
9
+ * @since 1.5.0
10
+ */
11
+
12
+ // Exit if accessed directly.
13
+ defined( 'ABSPATH' ) || exit;
14
+
15
+ /**
16
+ * Allow core components and dependent plugins to register activity actions.
17
+ *
18
+ * @since 1.2.0
19
+ *
20
+ */
21
+ function bp_register_activity_actions() {
22
+
23
+ /**
24
+ * Fires on bp_init to allow core components and dependent plugins to register activity actions.
25
+ *
26
+ * @since 1.2.0
27
+ */
28
+ do_action( 'bp_register_activity_actions' );
29
+ }
30
+ add_action( 'bp_init', 'bp_register_activity_actions', 8 );
31
+
32
+ /**
33
+ * Catch and route requests for single activity item permalinks.
34
+ *
35
+ * @since 1.2.0
36
+ *
37
+ * @return bool False on failure.
38
+ */
39
+ function bp_activity_action_permalink_router() {
40
+
41
+ // Not viewing activity.
42
+ if ( ! bp_is_activity_component() || ! bp_is_current_action( 'p' ) )
43
+ return false;
44
+
45
+ // No activity to display.
46
+ if ( ! bp_action_variable( 0 ) || ! is_numeric( bp_action_variable( 0 ) ) )
47
+ return false;
48
+
49
+ // Get the activity details.
50
+ $activity = bp_activity_get_specific( array( 'activity_ids' => bp_action_variable( 0 ), 'show_hidden' => true ) );
51
+
52
+ // 404 if activity does not exist
53
+ if ( empty( $activity['activities'][0] ) ) {
54
+ bp_do_404();
55
+ return;
56
+ } else {
57
+ $activity = $activity['activities'][0];
58
+ }
59
+
60
+ // Do not redirect at default.
61
+ $redirect = false;
62
+
63
+ // Redirect based on the type of activity.
64
+ if ( bp_is_active( 'groups' ) && $activity->component == buddypress()->groups->id ) {
65
+
66
+ // Activity is a user update.
67
+ if ( ! empty( $activity->user_id ) ) {
68
+ $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
69
+
70
+ // Activity is something else.
71
+ } else {
72
+
73
+ // Set redirect to group activity stream.
74
+ if ( $group = groups_get_group( $activity->item_id ) ) {
75
+ $redirect = bp_get_group_permalink( $group ) . bp_get_activity_slug() . '/' . $activity->id . '/';
76
+ }
77
+ }
78
+
79
+ // Set redirect to users' activity stream.
80
+ } elseif ( ! empty( $activity->user_id ) ) {
81
+ $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
82
+ }
83
+
84
+ // If set, add the original query string back onto the redirect URL.
85
+ if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
86
+ $query_frags = array();
87
+ wp_parse_str( $_SERVER['QUERY_STRING'], $query_frags );
88
+ $redirect = add_query_arg( urlencode_deep( $query_frags ), $redirect );
89
+ }
90
+
91
+ /**
92
+ * Filter the intended redirect url before the redirect occurs for the single activity item.
93
+ *
94
+ * @since 1.2.2
95
+ *
96
+ * @param array $value Array with url to redirect to and activity related to the redirect.
97
+ */
98
+ if ( ! $redirect = apply_filters_ref_array( 'bp_activity_permalink_redirect_url', array( $redirect, &$activity ) ) ) {
99
+ bp_core_redirect( bp_get_root_domain() );
100
+ }
101
+
102
+ // Redirect to the actual activity permalink page.
103
+ bp_core_redirect( $redirect );
104
+ }
105
+ add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
106
+
107
+ /**
108
+ * Delete specific activity item and redirect to previous page.
109
+ *
110
+ * @since 1.1.0
111
+ *
112
+ * @param int $activity_id Activity id to be deleted. Defaults to 0.
113
+ * @return bool False on failure.
114
+ */
115
+ function bp_activity_action_delete_activity( $activity_id = 0 ) {
116
+
117
+ // Not viewing activity or action is not delete.
118
+ if ( !bp_is_activity_component() || !bp_is_current_action( 'delete' ) )
119
+ return false;
120
+
121
+ if ( empty( $activity_id ) && bp_action_variable( 0 ) )
122
+ $activity_id = (int) bp_action_variable( 0 );
123
+
124
+ // Not viewing a specific activity item.
125
+ if ( empty( $activity_id ) )
126
+ return false;
127
+
128
+ // Check the nonce.
129
+ check_admin_referer( 'bp_activity_delete_link' );
130
+
131
+ // Load up the activity item.
132
+ $activity = new BP_Activity_Activity( $activity_id );
133
+
134
+ // Check access.
135
+ if ( ! bp_activity_user_can_delete( $activity ) )
136
+ return false;
137
+
138
+ /**
139
+ * Fires before the deletion so plugins can still fetch information about it.
140
+ *
141
+ * @since 1.5.0
142
+ *
143
+ * @param int $activity_id The activity ID.
144
+ * @param int $user_id The user associated with the activity.
145
+ */
146
+ do_action( 'bp_activity_before_action_delete_activity', $activity_id, $activity->user_id );
147
+
148
+ // Delete the activity item and provide user feedback.
149
+ if ( bp_activity_delete( array( 'id' => $activity_id, 'user_id' => $activity->user_id ) ) )
150
+ bp_core_add_message( __( 'Activity deleted successfully', 'buddypress' ) );
151
+ else
152
+ bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
153
+
154
+ /**
155
+ * Fires after the deletion so plugins can act afterwards based on the activity.
156
+ *
157
+ * @since 1.1.0
158
+ *
159
+ * @param int $activity_id The activity ID.
160
+ * @param int $user_id The user associated with the activity.
161
+ */
162
+ do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id );
163
+
164
+ // Check for the redirect query arg, otherwise let WP handle things.
165
+ if ( !empty( $_GET['redirect_to'] ) )
166
+ bp_core_redirect( esc_url( $_GET['redirect_to'] ) );
167
+ else
168
+ bp_core_redirect( wp_get_referer() );
169
+ }
170
+ add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
171
+
172
+ /**
173
+ * Mark specific activity item as spam and redirect to previous page.
174
+ *
175
+ * @since 1.6.0
176
+ *
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
+ $bp = buddypress();
182
+
183
+ // Not viewing activity, or action is not spam, or Akismet isn't present.
184
+ if ( !bp_is_activity_component() || !bp_is_current_action( 'spam' ) || empty( $bp->activity->akismet ) )
185
+ return false;
186
+
187
+ if ( empty( $activity_id ) && bp_action_variable( 0 ) )
188
+ $activity_id = (int) bp_action_variable( 0 );
189
+
190
+ // Not viewing a specific activity item.
191
+ if ( empty( $activity_id ) )
192
+ return false;
193
+
194
+ // Is the current user allowed to spam items?
195
+ if ( !bp_activity_user_can_mark_spam() )
196
+ return false;
197
+
198
+ // Load up the activity item.
199
+ $activity = new BP_Activity_Activity( $activity_id );
200
+ if ( empty( $activity->id ) )
201
+ return false;
202
+
203
+ // Check nonce.
204
+ check_admin_referer( 'bp_activity_akismet_spam_' . $activity->id );
205
+
206
+ /**
207
+ * Fires before the marking activity as spam so plugins can modify things if they want to.
208
+ *
209
+ * @since 1.6.0
210
+ *
211
+ * @param int $activity_id Activity ID to be marked as spam.
212
+ * @param object $activity Activity object for the ID to be marked as spam.
213
+ */
214
+ do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity );
215
+
216
+ // Mark as spam.
217
+ bp_activity_mark_as_spam( $activity );
218
+ $activity->save();
219
+
220
+ // Tell the user the spamming has been successful.
221
+ bp_core_add_message( __( 'The activity item has been marked as spam and is no longer visible.', 'buddypress' ) );
222
+
223
+ /**
224
+ * Fires after the marking activity as spam so plugins can act afterwards based on the activity.
225
+ *
226
+ * @since 1.6.0
227
+ *
228
+ * @param int $activity_id Activity ID that was marked as spam.
229
+ * @param int $user_id User ID associated with activity.
230
+ */
231
+ do_action( 'bp_activity_action_spam_activity', $activity_id, $activity->user_id );
232
+
233
+ // Check for the redirect query arg, otherwise let WP handle things.
234
+ if ( !empty( $_GET['redirect_to'] ) )
235
+ bp_core_redirect( esc_url( $_GET['redirect_to'] ) );
236
+ else
237
+ bp_core_redirect( wp_get_referer() );
238
+ }
239
+ add_action( 'bp_actions', 'bp_activity_action_spam_activity' );
240
+
241
+ /**
242
+ * Post user/group activity update.
243
+ *
244
+ * @since 1.2.0
245
+ *
246
+ * @return bool False on failure.
247
+ */
248
+ function bp_activity_action_post_update() {
249
+
250
+ // Do not proceed if user is not logged in, not viewing activity, or not posting.
251
+ if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'post' ) )
252
+ return false;
253
+
254
+ // Check the nonce.
255
+ check_admin_referer( 'post_update', '_wpnonce_post_update' );
256
+
257
+ /**
258
+ * Filters the content provided in the activity input field.
259
+ *
260
+ * @since 1.2.0
261
+ *
262
+ * @param string $value Activity message being posted.
263
+ */
264
+ $content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
265
+
266
+ if ( ! empty( $_POST['whats-new-post-object'] ) ) {
267
+
268
+ /**
269
+ * Filters the item type that the activity update should be associated with.
270
+ *
271
+ * @since 1.2.0
272
+ *
273
+ * @param string $value Item type to associate with.
274
+ */
275
+ $object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
276
+ }
277
+
278
+ if ( ! empty( $_POST['whats-new-post-in'] ) ) {
279
+
280
+ /**
281
+ * Filters what component the activity is being to.
282
+ *
283
+ * @since 1.2.0
284
+ *
285
+ * @param string $value Chosen component to post activity to.
286
+ */
287
+ $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
288
+ }
289
+
290
+ // No activity content so provide feedback and redirect.
291
+ if ( empty( $content ) ) {
292
+ bp_core_add_message( __( 'Please enter some content to post.', 'buddypress' ), 'error' );
293
+ bp_core_redirect( wp_get_referer() );
294
+ }
295
+
296
+ // No existing item_id.
297
+ if ( empty( $item_id ) ) {
298
+ $activity_id = bp_activity_post_update( array( 'content' => $content ) );
299
+
300
+ // Post to groups object.
301
+ } elseif ( 'groups' == $object && bp_is_active( 'groups' ) ) {
302
+ if ( (int) $item_id ) {
303
+ $activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) );
304
+ }
305
+
306
+ } else {
307
+
308
+ /**
309
+ * Filters activity object for BuddyPress core and plugin authors before posting activity update.
310
+ *
311
+ * @since 1.2.0
312
+ *
313
+ * @param string $object Activity item being associated to.
314
+ * @param string $item_id Component ID being posted to.
315
+ * @param string $content Activity content being posted.
316
+ */
317
+ $activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content );
318
+ }
319
+
320
+ // Provide user feedback.
321
+ if ( !empty( $activity_id ) )
322
+ bp_core_add_message( __( 'Update Posted!', 'buddypress' ) );
323
+ else
324
+ bp_core_add_message( __( 'There was an error when posting your update. Please try again.', 'buddypress' ), 'error' );
325
+
326
+ // Redirect.
327
+ bp_core_redirect( wp_get_referer() );
328
+ }
329
+ add_action( 'bp_actions', 'bp_activity_action_post_update' );
330
+
331
+ /**
332
+ * Post new activity comment.
333
+ *
334
+ * @since 1.2.0
335
+ *
336
+ * @return bool False on failure.
337
+ */
338
+ function bp_activity_action_post_comment() {
339
+
340
+ if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'reply' ) )
341
+ return false;
342
+
343
+ // Check the nonce.
344
+ check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' );
345
+
346
+ /**
347
+ * Filters the activity ID a comment will be in reply to.
348
+ *
349
+ * @since 1.2.0
350
+ *
351
+ * @param string $value ID of the activity being replied to.
352
+ */
353
+ $activity_id = apply_filters( 'bp_activity_post_comment_activity_id', $_POST['comment_form_id'] );
354
+
355
+ /**
356
+ * Filters the comment content for a comment reply.
357
+ *
358
+ * @since 1.2.0
359
+ *
360
+ * @param string $value Comment content being posted.
361
+ */
362
+ $content = apply_filters( 'bp_activity_post_comment_content', $_POST['ac_input_' . $activity_id] );
363
+
364
+ if ( empty( $content ) ) {
365
+ bp_core_add_message( __( 'Please do not leave the comment area blank.', 'buddypress' ), 'error' );
366
+ bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id );
367
+ }
368
+
369
+ $comment_id = bp_activity_new_comment( array(
370
+ 'content' => $content,
371
+ 'activity_id' => $activity_id,
372
+ 'parent_id' => false
373
+ ));
374
+
375
+ if ( !empty( $comment_id ) )
376
+ bp_core_add_message( __( 'Reply Posted!', 'buddypress' ) );
377
+ else
378
+ bp_core_add_message( __( 'There was an error posting that reply. Please try again.', 'buddypress' ), 'error' );
379
+
380
+ bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id );
381
+ }
382
+ add_action( 'bp_actions', 'bp_activity_action_post_comment' );
383
+
384
+ /**
385
+ * Mark activity as favorite.
386
+ *
387
+ * @since 1.2.0
388
+ *
389
+ * @return bool False on failure.
390
+ */
391
+ function bp_activity_action_mark_favorite() {
392
+
393
+ if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'favorite' ) )
394
+ return false;
395
+
396
+ // Check the nonce.
397
+ check_admin_referer( 'mark_favorite' );
398
+
399
+ if ( bp_activity_add_user_favorite( bp_action_variable( 0 ) ) )
400
+ bp_core_add_message( __( 'Activity marked as favorite.', 'buddypress' ) );
401
+ else
402
+ bp_core_add_message( __( 'There was an error marking that activity as a favorite. Please try again.', 'buddypress' ), 'error' );
403
+
404
+ bp_core_redirect( wp_get_referer() . '#activity-' . bp_action_variable( 0 ) );
405
+ }
406
+ add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
407
+
408
+ /**
409
+ * Remove activity from favorites.
410
+ *
411
+ * @since 1.2.0
412
+ *
413
+ * @return bool False on failure.
414
+ */
415
+ function bp_activity_action_remove_favorite() {
416
+
417
+ if ( ! is_user_logged_in() || ! bp_is_activity_component() || ! bp_is_current_action( 'unfavorite' ) )
418
+ return false;
419
+
420
+ // Check the nonce.
421
+ check_admin_referer( 'unmark_favorite' );
422
+
423
+ if ( bp_activity_remove_user_favorite( bp_action_variable( 0 ) ) )
424
+ bp_core_add_message( __( 'Activity removed as favorite.', 'buddypress' ) );
425
+ else
426
+ bp_core_add_message( __( 'There was an error removing that activity as a favorite. Please try again.', 'buddypress' ), 'error' );
427
+
428
+ bp_core_redirect( wp_get_referer() . '#activity-' . bp_action_variable( 0 ) );
429
+ }
430
+ add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
431
+
432
+ /**
433
+ * Load the sitewide activity feed.
434
+ *
435
+ * @since 1.0.0
436
+ *
437
+ * @return bool False on failure.
438
+ */
439
+ function bp_activity_action_sitewide_feed() {
440
+ $bp = buddypress();
441
+
442
+ if ( ! bp_is_activity_component() || ! bp_is_current_action( 'feed' ) || bp_is_user() || ! empty( $bp->groups->current_group ) )
443
+ return false;
444
+
445
+ // Setup the feed.
446
+ buddypress()->activity->feed = new BP_Activity_Feed( array(
447
+ 'id' => 'sitewide',
448
+
449
+ /* translators: Sitewide activity RSS title - "[Site Name] | Site Wide Activity" */
450
+ 'title' => sprintf( __( '%s | Site-Wide Activity', 'buddypress' ), bp_get_site_name() ),
451
+
452
+ 'link' => bp_get_activity_directory_permalink(),
453
+ 'description' => __( 'Activity feed for the entire site.', 'buddypress' ),
454
+ 'activity_args' => 'display_comments=threaded'
455
+ ) );
456
+ }
457
+ add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
458
+
459
+ /**
460
+ * Load a user's personal activity feed.
461
+ *
462
+ * @since 1.0.0
463
+ *
464
+ * @return bool False on failure.
465
+ */
466
+ function bp_activity_action_personal_feed() {
467
+ if ( ! bp_is_user_activity() || ! bp_is_current_action( 'feed' ) ) {
468
+ return false;
469
+ }
470
+
471
+ // Setup the feed.
472
+ buddypress()->activity->feed = new BP_Activity_Feed( array(
473
+ 'id' => 'personal',
474
+
475
+ /* translators: Personal activity RSS title - "[Site Name] | [User Display Name] | Activity" */
476
+ 'title' => sprintf( __( '%1$s | %2$s | Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
477
+
478
+ 'link' => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() ),
479
+ 'description' => sprintf( __( 'Activity feed for %s.', 'buddypress' ), bp_get_displayed_user_fullname() ),
480
+ 'activity_args' => 'user_id=' . bp_displayed_user_id()
481
+ ) );
482
+ }
483
+ add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
484
+
485
+ /**
486
+ * Load a user's friends' activity feed.
487
+ *
488
+ * @since 1.0.0
489
+ *
490
+ * @return bool False on failure.
491
+ */
492
+ function bp_activity_action_friends_feed() {
493
+ if ( ! bp_is_active( 'friends' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_friends_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
494
+ return false;
495
+ }
496
+
497
+ // Setup the feed.
498
+ buddypress()->activity->feed = new BP_Activity_Feed( array(
499
+ 'id' => 'friends',
500
+
501
+ /* translators: Friends activity RSS title - "[Site Name] | [User Display Name] | Friends Activity" */
502
+ 'title' => sprintf( __( '%1$s | %2$s | Friends Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
503
+
504
+ 'link' => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() ),
505
+ 'description' => sprintf( __( "Activity feed for %s's friends.", 'buddypress' ), bp_get_displayed_user_fullname() ),
506
+ 'activity_args' => 'scope=friends'
507
+ ) );
508
+ }
509
+ add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
510
+
511
+ /**
512
+ * Load the activity feed for a user's groups.
513
+ *
514
+ * @since 1.2.0
515
+ *
516
+ * @return bool False on failure.
517
+ */
518
+ function bp_activity_action_my_groups_feed() {
519
+ if ( ! bp_is_active( 'groups' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_groups_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
520
+ return false;
521
+ }
522
+
523
+ // Get displayed user's group IDs.
524
+ $groups = groups_get_user_groups();
525
+ $group_ids = implode( ',', $groups['groups'] );
526
+
527
+ // Setup the feed.
528
+ buddypress()->activity->feed = new BP_Activity_Feed( array(
529
+ 'id' => 'mygroups',
530
+
531
+ /* translators: Member groups activity RSS title - "[Site Name] | [User Display Name] | Groups Activity" */
532
+ 'title' => sprintf( __( '%1$s | %2$s | Group Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
533
+
534
+ 'link' => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() ),
535
+ 'description' => sprintf( __( "Public group activity feed of which %s is a member.", 'buddypress' ), bp_get_displayed_user_fullname() ),
536
+ 'activity_args' => array(
537
+ 'object' => buddypress()->groups->id,
538
+ 'primary_id' => $group_ids,
539
+ 'display_comments' => 'threaded'
540
+ )
541
+ ) );
542
+ }
543
+ add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
544
+
545
+ /**
546
+ * Load a user's @mentions feed.
547
+ *
548
+ * @since 1.2.0
549
+ *
550
+ * @return bool False on failure.
551
+ */
552
+ function bp_activity_action_mentions_feed() {
553
+ if ( ! bp_activity_do_mentions() ) {
554
+ return false;
555
+ }
556
+
557
+ if ( !bp_is_user_activity() || ! bp_is_current_action( 'mentions' ) || ! bp_is_action_variable( 'feed', 0 ) ) {
558
+ return false;
559
+ }
560
+
561
+ // Setup the feed.
562
+ buddypress()->activity->feed = new BP_Activity_Feed( array(
563
+ 'id' => 'mentions',
564
+
565
+ /* translators: User mentions activity RSS title - "[Site Name] | [User Display Name] | Mentions" */
566
+ 'title' => sprintf( __( '%1$s | %2$s | Mentions', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
567
+
568
+ 'link' => bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/',
569
+ 'description' => sprintf( __( "Activity feed mentioning %s.", 'buddypress' ), bp_get_displayed_user_fullname() ),
570
+ 'activity_args' => array(
571
+ 'search_terms' => '@' . bp_core_get_username( bp_displayed_user_id() )
572
+ )
573
+ ) );
574
+ }
575
+ add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
576
+
577
+ /**
578
+ * Load a user's favorites feed.
579
+ *
580
+ * @since 1.2.0
581
+ *
582
+ * @return bool False on failure.
583
+ */
584
+ function bp_activity_action_favorites_feed() {
585
+ if ( ! bp_is_user_activity() || ! bp_is_current_action( 'favorites' ) || ! bp_is_action_variable( 'feed', 0 ) ) {
586
+ return false;
587
+ }
588
+
589
+ // Get displayed user's favorite activity IDs.
590
+ $favs = bp_activity_get_user_favorites( bp_displayed_user_id() );
591
+ $fav_ids = implode( ',', (array) $favs );
592
+
593
+ // Setup the feed.
594
+ buddypress()->activity->feed = new BP_Activity_Feed( array(
595
+ 'id' => 'favorites',
596
+
597
+ /* translators: User activity favorites RSS title - "[Site Name] | [User Display Name] | Favorites" */
598
+ 'title' => sprintf( __( '%1$s | %2$s | Favorites', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
599
+
600
+ 'link' => bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/',
601
+ 'description' => sprintf( __( "Activity feed of %s's favorites.", 'buddypress' ), bp_get_displayed_user_fullname() ),
602
+ 'activity_args' => 'include=' . $fav_ids
603
+ ) );
604
+ }
605
+ add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
606
+
607
+ /**
608
+ * AJAX endpoint for Suggestions API lookups.
609
+ *
610
+ * @since 2.1.0
611
+ */
612
+ function bp_ajax_get_suggestions() {
613
+ if ( ! bp_is_user_active() || empty( $_GET['term'] ) || empty( $_GET['type'] ) ) {
614
+ wp_send_json_error( 'missing_parameter' );
615
+ exit;
616
+ }
617
+
618
+ $args = array(
619
+ 'term' => sanitize_text_field( $_GET['term'] ),
620
+ 'type' => sanitize_text_field( $_GET['type'] ),
621
+ );
622
+
623
+ // Support per-Group suggestions.
624
+ if ( ! empty( $_GET['group-id'] ) ) {
625
+ $args['group_id'] = absint( $_GET['group-id'] );
626
+ }
627
+
628
+ $results = bp_core_get_suggestions( $args );
629
+
630
+ if ( is_wp_error( $results ) ) {
631
+ wp_send_json_error( $results->get_error_message() );
632
+ exit;
633
+ }
634
+
635
+ wp_send_json_success( $results );
636
+ }
637
+ add_action( 'wp_ajax_bp_get_suggestions', 'bp_ajax_get_suggestions' );
638
+
639
+ /**
640
+ * Detect a change in post type status, and initiate an activity update if necessary.
641
+ *
642
+ * @since 2.2.0
643
+ *
644
+ * @todo Support untrashing better.
645
+ *
646
+ * @param string $new_status New status for the post.
647
+ * @param string $old_status Old status for the post.
648
+ * @param object $post Post data.
649
+ */
650
+ function bp_activity_catch_transition_post_type_status( $new_status, $old_status, $post ) {
651
+ if ( ! post_type_supports( $post->post_type, 'buddypress-activity' ) ) {
652
+ return;
653
+ }
654
+
655
+ // This is an edit.
656
+ if ( $new_status === $old_status ) {
657
+ // An edit of an existing post should update the existing activity item.
658
+ if ( $new_status == 'publish' ) {
659
+ $edit = bp_activity_post_type_update( $post );
660
+
661
+ // Post was never recorded into activity stream, so record it now!
662
+ if ( null === $edit ) {
663
+ bp_activity_post_type_publish( $post->ID, $post );
664
+ }
665
+
666
+ // Allow plugins to eventually deal with other post statuses.
667
+ } else {
668
+ /**
669
+ * Fires when editing the post and the new status is not 'publish'.
670
+ *
671
+ * This is a variable filter that is dependent on the post type
672
+ * being untrashed.
673
+ *
674
+ * @since 2.5.0
675
+ *
676
+ * @param WP_Post $post Post data.
677
+ * @param string $new_status New status for the post.
678
+ * @param string $old_status Old status for the post.
679
+ */
680
+ do_action( 'bp_activity_post_type_edit_' . $post->post_type, $post, $new_status, $old_status );
681
+ }
682
+
683
+ return;
684
+ }
685
+
686
+ // Publishing a previously unpublished post.
687
+ if ( 'publish' === $new_status ) {
688
+ // Untrashing the post type - nothing here yet.
689
+ if ( 'trash' == $old_status ) {
690
+
691
+ /**
692
+ * Fires if untrashing post in a post type.
693
+ *
694
+ * This is a variable filter that is dependent on the post type
695
+ * being untrashed.
696
+ *
697
+ * @since 2.2.0
698
+ *
699
+ * @param WP_Post $post Post data.
700
+ */
701
+ do_action( 'bp_activity_post_type_untrash_' . $post->post_type, $post );
702
+ } else {
703
+ // Record the post.
704
+ bp_activity_post_type_publish( $post->ID, $post );
705
+ }
706
+
707
+ // Unpublishing a previously published post.
708
+ } elseif ( 'publish' === $old_status ) {
709
+ // Some form of pending status - only remove the activity entry.
710
+ bp_activity_post_type_unpublish( $post->ID, $post );
711
+
712
+ // For any other cases, allow plugins to eventually deal with it.
713
+ } else {
714
+ /**
715
+ * Fires when the old and the new post status are not 'publish'.
716
+ *
717
+ * This is a variable filter that is dependent on the post type
718
+ * being untrashed.
719
+ *
720
+ * @since 2.5.0
721
+ *
722
+ * @param WP_Post $post Post data.
723
+ * @param string $new_status New status for the post.
724
+ * @param string $old_status Old status for the post.
725
+ */
726
+ do_action( 'bp_activity_post_type_transition_status_' . $post->post_type, $post, $new_status, $old_status );
727
+ }
728
+ }
729
+ add_action( 'transition_post_status', 'bp_activity_catch_transition_post_type_status', 10, 3 );
730
+
731
+ /**
732
+ * When a post type comment status transition occurs, update the relevant activity's status.
733
+ *
734
+ * @since 2.5.0
735
+ *
736
+ * @param string $new_status New comment status.
737
+ * @param string $old_status Previous comment status.
738
+ * @param WP_Comment $comment Comment data.
739
+ */
740
+ function bp_activity_transition_post_type_comment_status( $new_status, $old_status, $comment ) {
741
+ $post_type = get_post_type( $comment->comment_post_ID );
742
+ if ( ! $post_type ) {
743
+ return;
744
+ }
745
+
746
+ // Get the post type tracking args.
747
+ $activity_post_object = bp_activity_get_post_type_tracking_args( $post_type );
748
+
749
+ // Bail if the activity type does not exist
750
+ if ( empty( $activity_post_object->comments_tracking->action_id ) ) {
751
+ return false;
752
+
753
+ // Set the $activity_comment_object
754
+ } else {
755
+ $activity_comment_object = $activity_post_object->comments_tracking;
756
+ }
757
+
758
+ // Init an empty activity ID
759
+ $activity_id = 0;
760
+
761
+ /**
762
+ * Activity currently doesn't have any concept of a trash, or an unapproved/approved state.
763
+ *
764
+ * If a blog comment transitions to a "delete" or "hold" status, delete the activity item.
765
+ * If a blog comment transitions to trashed, or spammed, mark the activity as spam.
766
+ * If a blog comment transitions to approved (and the activity exists), mark the activity as ham.
767
+ * If a blog comment transitions to unapproved (and the activity exists), mark the activity as spam.
768
+ * Otherwise, record the comment into the activity stream.
769
+ */
770
+
771
+ // This clause handles delete/hold.
772
+ if ( in_array( $new_status, array( 'delete', 'hold' ) ) ) {
773
+ return bp_activity_post_type_remove_comment( $comment->comment_ID, $activity_post_object );
774
+
775
+ // These clauses handle trash, spam, and un-spams.
776
+ } elseif ( in_array( $new_status, array( 'trash', 'spam', 'unapproved' ) ) ) {
777
+ $action = 'spam_activity';
778
+ } elseif ( 'approved' == $new_status ) {
779
+ $action = 'ham_activity';
780
+ }
781
+
782
+ // Get the activity
783
+ if ( bp_disable_blogforum_comments() ) {
784
+ $activity_id = bp_activity_get_activity_id( array(
785
+ 'component' => $activity_comment_object->component_id,
786
+ 'item_id' => get_current_blog_id(),
787
+ 'secondary_item_id' => $comment->comment_ID,
788
+ 'type' => $activity_comment_object->action_id,
789
+ ) );
790
+ } else {
791
+ $activity_id = get_comment_meta( $comment->comment_ID, 'bp_activity_comment_id', true );
792
+ }
793
+
794
+ /**
795
+ * Leave a chance to plugins to manage activity comments differently.
796
+ *
797
+ * @since 2.5.0
798
+ *
799
+ * @param bool $value True to override BuddyPress management.
800
+ * @param string $post_type The post type name.
801
+ * @param int $activity_id The post type activity (0 if not found).
802
+ * @param string $new_status The new status of the post type comment.
803
+ * @param string $old_status The old status of the post type comment.
804
+ * @param WP_Comment $comment Comment data.
805
+ */
806
+ if ( true === apply_filters( 'bp_activity_pre_transition_post_type_comment_status', false, $post_type, $activity_id, $new_status, $old_status, $comment ) ) {
807
+ return false;
808
+ }
809
+
810
+ // Check activity item exists
811
+ if ( empty( $activity_id ) ) {
812
+ // If no activity exists, but the comment has been approved, record it into the activity table.
813
+ if ( 'approved' == $new_status ) {
814
+ return bp_activity_post_type_comment( $comment->comment_ID, true, $activity_post_object );
815
+ }
816
+
817
+ return;
818
+ }
819
+
820
+ // Create an activity object
821
+ $activity = new BP_Activity_Activity( $activity_id );
822
+ if ( empty( $activity->component ) ) {
823
+ return;
824
+ }
825
+
826
+ // Spam/ham the activity if it's not already in that state
827
+ if ( 'spam_activity' === $action && ! $activity->is_spam ) {
828
+ bp_activity_mark_as_spam( $activity );
829
+ } elseif ( 'ham_activity' == $action) {
830
+ bp_activity_mark_as_ham( $activity );
831
+ }
832
+
833
+ // Add "new_post_type_comment" to the whitelisted activity types, so that the activity's Akismet history is generated
834
+ $post_type_comment_action = $activity_comment_object->action_id;
835
+ $comment_akismet_history = function ( $activity_types ) use ( $post_type_comment_action ) {
836
+ $activity_types[] = $post_type_comment_action;
837
+
838
+ return $activity_types;
839
+ };
840
+ add_filter( 'bp_akismet_get_activity_types', $comment_akismet_history );
841
+
842
+ // Make sure the activity change won't edit the comment if sync is on
843
+ remove_action( 'bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20 );
844
+
845
+ // Save the updated activity
846
+ $activity->save();
847
+
848
+ // Restore the action
849
+ add_action( 'bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20 );
850
+
851
+ // Remove the "new_blog_comment" activity type whitelist so we don't break anything
852
+ remove_filter( 'bp_akismet_get_activity_types', $comment_akismet_history );
853
+ }
854
+ add_action( 'transition_comment_status', 'bp_activity_transition_post_type_comment_status', 10, 3 );
bp-activity/bp-activity-admin.php CHANGED
@@ -29,8 +29,8 @@ function bp_activity_add_admin_menu() {
29
 
30
  // Add our screen.
31
  $hook = add_menu_page(
32
- _x( 'Activity', 'Admin Dashboard SWA page title', 'buddypress' ),
33
- _x( 'Activity', 'Admin Dashboard SWA menu', 'buddypress' ),
34
  'bp_moderate',
35
  'bp-activity',
36
  'bp_activity_admin',
@@ -75,7 +75,7 @@ function bp_activity_admin_reply() {
75
  $parent_id = ! empty( $_REQUEST['parent_id'] ) ? (int) $_REQUEST['parent_id'] : 0;
76
  $root_id = ! empty( $_REQUEST['root_id'] ) ? (int) $_REQUEST['root_id'] : 0;
77
 
78
- // $parent_id is required.
79
  if ( empty( $parent_id ) )
80
  die( '-1' );
81
 
@@ -85,16 +85,16 @@ function bp_activity_admin_reply() {
85
 
86
  // Check that a reply has been entered.
87
  if ( empty( $_REQUEST['content'] ) )
88
- die( __( 'Error: Please type a reply.', 'buddypress' ) );
89
 
90
  // Check parent activity exists.
91
  $parent_activity = new BP_Activity_Activity( $parent_id );
92
  if ( empty( $parent_activity->component ) )
93
- die( __( 'Error: The item you are trying to reply to cannot be found, or it has been deleted.', 'buddypress' ) );
94
 
95
  // @todo: Check if user is allowed to create new activity items
96
  // if ( ! current_user_can( 'bp_new_activity' ) )
97
- if ( ! bp_current_user_can( 'bp_moderate' ) )
98
  die( '-1' );
99
 
100
  // Add new activity comment.
@@ -232,7 +232,7 @@ function bp_activity_admin_load() {
232
  'title' => __( 'Item, Link, Type', 'buddypress' ),
233
  'content' =>
234
  '<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>' .
235
- '<p>' . __( '<strong>Link</strong> - Used by some types of activity (blog posts and comments) to store a link back to the original content.', 'buddypress' ) . '</p>' .
236
  '<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>' .
237
  '<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>'
238
  ) );
@@ -296,11 +296,12 @@ function bp_activity_admin_load() {
296
  );
297
 
298
  // Add accessible hidden heading and text for Activity screen pagination.
299
- get_current_screen()->set_screen_reader_content( array(
300
- /* translators: accessibility text */
301
- 'heading_pagination' => __( 'Activity list navigation', 'buddypress' ),
302
- ) );
303
-
 
304
  }
305
 
306
  // Enqueue CSS and JavaScript.
@@ -310,7 +311,7 @@ function bp_activity_admin_load() {
310
  ) );
311
  wp_enqueue_style( 'bp_activity_admin_css', $bp->plugin_url . "bp-activity/admin/css/admin{$min}.css", array(), bp_get_version() );
312
 
313
- wp_style_add_data( 'bp_activity_admin_css', 'rtl', 'replace' );
314
  if ( $min ) {
315
  wp_style_add_data( 'bp_activity_admin_css', 'suffix', $min );
316
  }
@@ -323,14 +324,14 @@ function bp_activity_admin_load() {
323
  do_action( 'bp_activity_admin_enqueue_scripts' );
324
 
325
  // Handle spam/un-spam/delete of activities.
326
- if ( ! empty( $doaction ) && ! in_array( $doaction, array( '-1', 'edit', 'save', 'delete', 'bulk_delete' ) ) ) {
327
 
328
  // Build redirection URL.
329
  $redirect_to = remove_query_arg( array( 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), wp_get_referer() );
330
  $redirect_to = add_query_arg( 'paged', $bp_activity_list_table->get_pagenum(), $redirect_to );
331
 
332
  // Get activity IDs.
333
- $activity_ids = wp_parse_id_list( $_REQUEST['aid'] );
334
 
335
  /**
336
  * Filters list of IDs being spammed/un-spammed/deleted.
@@ -349,18 +350,14 @@ function bp_activity_admin_load() {
349
  // Trim 'bulk_' off the action name to avoid duplicating a ton of code.
350
  $doaction = substr( $doaction, 5 );
351
 
352
- // This is a request to delete single or multiple item.
353
- } elseif ( 'do_delete' === $doaction && ! empty( $_REQUEST['aid'] ) ) {
354
- check_admin_referer( 'bp-activities-delete' );
355
-
356
- // This is a request to spam, or un-spam, a single item.
357
  } elseif ( !empty( $_REQUEST['aid'] ) ) {
358
 
359
  // Check this is a valid form submission.
360
  check_admin_referer( 'spam-activity_' . $activity_ids[0] );
361
  }
362
 
363
- // Initialize counters for how many of each type of item we perform an action on.
364
  $deleted = $spammed = $unspammed = 0;
365
 
366
  // Store any errors that occurs when updating the database items.
@@ -379,37 +376,31 @@ function bp_activity_admin_load() {
379
  }
380
 
381
  switch ( $doaction ) {
382
- case 'do_delete' :
383
- if ( 'activity_comment' === $activity->type ) {
384
- $delete_result = bp_activity_delete_comment( $activity->item_id, $activity->id );
385
- } else {
386
- $delete_result = bp_activity_delete( array( 'id' => $activity->id ) );
387
- }
388
-
389
- if ( ! $delete_result ) {
390
- $errors[] = $activity->id;
391
- } else {
392
- $deleted++;
393
- }
394
  break;
395
 
396
  case 'ham' :
397
  /**
398
- * Remove moderation and disallowed keyword checks in case we want to ham an activity
399
  * which contains one of these listed keys.
400
  */
401
  remove_action( 'bp_activity_before_save', 'bp_activity_check_moderation_keys', 2 );
402
- remove_action( 'bp_activity_before_save', 'bp_activity_check_disallowed_keys', 2 );
403
 
404
  bp_activity_mark_as_ham( $activity );
405
  $result = $activity->save();
406
 
407
  // Check for any error during activity save.
408
- if ( ! $result ) {
409
  $errors[] = $activity->id;
410
- } else {
411
  $unspammed++;
412
- }
413
  break;
414
 
415
  case 'spam' :
@@ -417,11 +408,10 @@ function bp_activity_admin_load() {
417
  $result = $activity->save();
418
 
419
  // Check for any error during activity save.
420
- if ( ! $result ) {
421
  $errors[] = $activity->id;
422
- } else {
423
  $spammed++;
424
- }
425
  break;
426
 
427
  default:
@@ -446,22 +436,18 @@ function bp_activity_admin_load() {
446
  do_action( 'bp_activity_admin_action_after', array( $spammed, $unspammed, $deleted, $errors ), $redirect_to, $activity_ids );
447
 
448
  // Add arguments to the redirect URL so that on page reload, we can easily display what we've just done.
449
- if ( $spammed ) {
450
  $redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to );
451
- }
452
 
453
- if ( $unspammed ) {
454
  $redirect_to = add_query_arg( 'unspammed', $unspammed, $redirect_to );
455
- }
456
 
457
- if ( $deleted ) {
458
  $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to );
459
- }
460
 
461
  // If an error occurred, pass back the activity ID that failed.
462
- if ( ! empty( $errors ) ) {
463
  $redirect_to = add_query_arg( 'error', implode ( ',', array_map( 'absint', $errors ) ), $redirect_to );
464
- }
465
 
466
  /**
467
  * Filters redirect URL after activity spamming/un-spamming/deletion occurs.
@@ -619,100 +605,17 @@ function bp_activity_admin_load() {
619
  */
620
  function bp_activity_admin() {
621
  // Decide whether to load the index or edit screen.
622
- $doaction = bp_admin_list_table_current_bulk_action();
623
 
624
  // Display the single activity edit screen.
625
- if ( 'edit' === $doaction && ! empty( $_GET['aid'] ) ) {
626
  bp_activity_admin_edit();
627
 
628
- // Display the activty delete confirmation screen.
629
- } elseif ( in_array( $doaction, array( 'bulk_delete', 'delete' ) ) && ! empty( $_GET['aid'] ) ) {
630
- bp_activity_admin_delete();
631
-
632
  // Otherwise, display the Activity index screen.
633
- } else {
634
  bp_activity_admin_index();
635
- }
636
  }
637
 
638
- /**
639
- * Display the Activity delete confirmation screen.
640
- *
641
- * @since 7.0.0
642
- */
643
- function bp_activity_admin_delete() {
644
-
645
- if ( ! bp_current_user_can( 'bp_moderate' ) ) {
646
- die( '-1' );
647
- }
648
-
649
- $activity_ids = isset( $_REQUEST['aid'] ) ? $_REQUEST['aid'] : 0;
650
-
651
- if ( ! is_array( $activity_ids ) ) {
652
- $activity_ids = explode( ',', $activity_ids );
653
- }
654
-
655
- $activities = bp_activity_get( array(
656
- 'in' => $activity_ids,
657
- 'show_hidden' => true,
658
- 'spam' => 'all',
659
- 'display_comments' => 0,
660
- 'per_page' => null
661
- ) );
662
-
663
- // Create a new list of activity ids, based on those that actually exist.
664
- $aids = array();
665
- foreach ( $activities['activities'] as $activity ) {
666
- $aids[] = $activity->id;
667
- }
668
-
669
- $base_url = remove_query_arg( array( 'action', 'action2', 'paged', 's', '_wpnonce', 'aid' ), $_SERVER['REQUEST_URI'] ); ?>
670
-
671
- <div class="wrap">
672
- <h1 class="wp-heading-inline"><?php esc_html_e( 'Delete Activities', 'buddypress' ) ?></h1>
673
- <hr class="wp-header-end">
674
-
675
- <p><?php esc_html_e( 'You are about to delete the following activities:', 'buddypress' ) ?></p>
676
-
677
- <ul class="bp-activity-delete-list">
678
- <?php foreach ( $activities['activities'] as $activity ) : ?>
679
- <li>
680
- <?php
681
- $actions = bp_activity_admin_get_activity_actions();
682
-
683
- if ( isset( $actions[ $activity->type ] ) ) {
684
- $activity_type = $actions[ $activity->type ];
685
- } else {
686
- /* translators: %s: the name of the activity type */
687
- $activity_type = sprintf( __( 'Unregistered action - %s', 'buddypress' ), $activity->type );
688
- }
689
-
690
- printf(
691
- /* translators: 1: activity type. 2: activity author. 3: activity date and time. */
692
- __( '"%1$s" activity submitted by %2$s on %3$s', 'buddypress' ),
693
- esc_html( $activity_type ),
694
- bp_core_get_userlink( $activity->user_id ),
695
- sprintf(
696
- '<a href="%1$s">%2$s</a>',
697
- esc_url( bp_activity_get_permalink( $activity->id, $activity ) ),
698
- date_i18n( bp_get_option( 'date_format' ), strtotime( $activity->date_recorded ) )
699
- )
700
- );
701
- ?>
702
- </li>
703
- <?php endforeach; ?>
704
- </ul>
705
-
706
- <p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ) ?></strong></p>
707
-
708
- <a class="button-primary" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'do_delete', 'aid' => implode( ',', $aids ) ), $base_url ), 'bp-activities-delete' ) ); ?>"><?php esc_html_e( 'Delete Permanently', 'buddypress' ) ?></a>
709
- <a class="button" href="<?php echo esc_attr( $base_url ); ?>"><?php esc_html_e( 'Cancel', 'buddypress' ) ?></a>
710
- </div>
711
-
712
- <?php
713
- }
714
-
715
-
716
  /**
717
  * Display the single activity edit screen.
718
  *
@@ -758,14 +661,7 @@ function bp_activity_admin_edit() {
758
  do_action_ref_array( 'bp_activity_admin_edit', array( &$activity ) ); ?>
759
 
760
  <div class="wrap">
761
- <h1 class="wp-heading-inline">
762
- <?php
763
- /* translators: %s: the activity ID */
764
- printf( __( 'Editing Activity (ID #%s)', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) );
765
- ?>
766
- </h1>
767
-
768
- <hr class="wp-header-end">
769
 
770
  <?php if ( ! empty( $activity ) ) : ?>
771
 
@@ -841,10 +737,6 @@ function bp_activity_admin_edit() {
841
  * @param object $item Activity item.
842
  */
843
  function bp_activity_admin_edit_metabox_status( $item ) {
844
- $base_url = add_query_arg( array(
845
- 'page' => 'bp-activity',
846
- 'aid' => $item->id
847
- ), bp_get_admin_url( 'admin.php' ) );
848
  ?>
849
 
850
  <div class="submitbox" id="submitcomment">
@@ -870,12 +762,7 @@ function bp_activity_admin_edit_metabox_status( $item ) {
870
  $datef = __( 'M j, Y @ G:i', 'buddypress' );
871
  $date = date_i18n( $datef, strtotime( $item->date_recorded ) );
872
  ?>
873
- <span id="timestamp">
874
- <?php
875
- /* translators: %s: the date the activity was submitted on */
876
- printf( __( 'Submitted on: %s', 'buddypress' ), '<strong>' . $date . '</strong>' );
877
- ?>
878
- </span>&nbsp;<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e( 'Edit', 'buddypress' ); ?></a>
879
 
880
  <div id='timestampdiv' class='hide-if-js'>
881
  <?php touch_time( 1, 0, 5 ); ?>
@@ -887,10 +774,6 @@ function bp_activity_admin_edit_metabox_status( $item ) {
887
  </div><!-- #minor-publishing -->
888
 
889
  <div id="major-publishing-actions">
890
- <div id="delete-action">
891
- <a class="submitdelete deletion" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'action', 'delete', $base_url ), 'bp-activities-delete' ) ); ?>"><?php esc_html_e( 'Delete Permanently', 'buddypress' ) ?></a>
892
- </div>
893
-
894
  <div id="publishing-action">
895
  <?php submit_button( __( 'Update', 'buddypress' ), 'primary', 'save', false ); ?>
896
  </div>
@@ -917,7 +800,7 @@ function bp_activity_admin_edit_metabox_link( $item ) {
917
  _e( 'Link', 'buddypress' );
918
  ?></label>
919
  <input type="url" name="bp-activities-link" id="bp-activities-link" value="<?php echo esc_url( $item->primary_link ); ?>" aria-describedby="bp-activities-link-description" />
920
- <p id="bp-activities-link-description"><?php _e( 'Activity generated by posts and comments uses the link field for a permalink back to the content item.', 'buddypress' ); ?></p>
921
 
922
  <?php
923
  }
@@ -958,19 +841,13 @@ function bp_activity_admin_get_activity_actions() {
958
  $action = array_values( (array) $action );
959
 
960
  for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) {
961
- /**
962
- * Don't take in account:
963
- * - a mis-named Friends activity type from before BP 1.6,
964
- * - The Group's component 'activity_update' one as the Activity component is using it.
965
- */
966
- if ( 'friends_register_activity_action' === $action[$i]['key'] || 'bp_groups_format_activity_action_group_activity_update' === $action[$i]['format_callback'] ) {
967
- continue;
968
- }
969
-
970
  $actions[ $action[$i]['key'] ] = $action[$i]['value'];
971
  }
972
  }
973
 
 
 
 
974
  // Sort array by the human-readable value.
975
  natsort( $actions );
976
 
@@ -994,20 +871,13 @@ function bp_activity_admin_edit_metabox_type( $item ) {
994
  foreach ( bp_activity_get_actions() as $action ) {
995
  $action = array_values( (array) $action );
996
 
997
- for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) {
998
- /**
999
- * Don't take in account:
1000
- * - a mis-named Friends activity type from before BP 1.6,
1001
- * - The Group's component 'activity_update' one as the Activity component is using it.
1002
- */
1003
- if ( 'friends_register_activity_action' === $action[$i]['key'] || 'bp_groups_format_activity_action_group_activity_update' === $action[$i]['format_callback'] ) {
1004
- continue;
1005
- }
1006
-
1007
  $actions[ $action[$i]['key'] ] = $action[$i]['value'];
1008
- }
1009
  }
1010
 
 
 
 
1011
  // Sort array by the human-readable value.
1012
  natsort( $actions );
1013
 
@@ -1017,16 +887,7 @@ function bp_activity_admin_edit_metabox_type( $item ) {
1017
  * of the list.
1018
  */
1019
  if ( ! isset( $actions[ $selected ] ) ) {
1020
- _doing_it_wrong(
1021
- __FUNCTION__,
1022
- sprintf(
1023
- /* translators: %s: the name of the activity type */
1024
- __( 'This activity item has a type (%s) that is not registered using bp_activity_set_action(), so no label is available.', 'buddypress' ),
1025
- $selected
1026
- ),
1027
- '2.0.0'
1028
- );
1029
-
1030
  $actions[ $selected ] = $selected;
1031
  }
1032
 
@@ -1100,14 +961,11 @@ function bp_activity_admin_index() {
1100
  // Reindex array.
1101
  $errors = array_values( $errors );
1102
 
1103
- if ( $deleted > 0 ) {
1104
- /* translators: %s: the number of permanently deleted activities */
1105
  $messages[] = sprintf( _n( '%s activity item has been permanently deleted.', '%s activity items have been permanently deleted.', $deleted, 'buddypress' ), number_format_i18n( $deleted ) );
1106
- }
1107
 
1108
  if ( ! empty( $errors ) ) {
1109
  if ( 1 == count( $errors ) ) {
1110
- /* translators: %s: the ID of the activity which errored during an update */
1111
  $messages[] = sprintf( __( 'An error occurred when trying to update activity ID #%s.', 'buddypress' ), number_format_i18n( $errors[0] ) );
1112
 
1113
  } else {
@@ -1116,7 +974,7 @@ function bp_activity_admin_index() {
1116
 
1117
  // Display each error as a list item.
1118
  foreach ( $errors as $error ) {
1119
- /* Translators: %s: the activity ID */
1120
  $error_msg .= '<li>' . sprintf( __( '#%s', 'buddypress' ), number_format_i18n( $error ) ) . '</li>';
1121
  }
1122
 
@@ -1125,19 +983,14 @@ function bp_activity_admin_index() {
1125
  }
1126
  }
1127
 
1128
- if ( $spammed > 0 ) {
1129
- /* translators: %s: the number of activities successfully marked as spam */
1130
  $messages[] = sprintf( _n( '%s activity item has been successfully spammed.', '%s activity items have been successfully spammed.', $spammed, 'buddypress' ), number_format_i18n( $spammed ) );
1131
- }
1132
 
1133
- if ( $unspammed > 0 ) {
1134
- /* translators: %s: the number of activities successfully marked as ham */
1135
  $messages[] = sprintf( _n( '%s activity item has been successfully unspammed.', '%s activity items have been successfully unspammed.', $unspammed, 'buddypress' ), number_format_i18n( $unspammed ) );
1136
- }
1137
 
1138
- if ( $updated > 0 ) {
1139
  $messages[] = __( 'The activity item has been updated successfully.', 'buddypress' );
1140
- }
1141
  }
1142
 
1143
  // Prepare the activity items for display.
@@ -1153,31 +1006,21 @@ function bp_activity_admin_index() {
1153
  do_action( 'bp_activity_admin_index', $messages ); ?>
1154
 
1155
  <div class="wrap">
1156
- <h1 class="wp-heading-inline">
1157
  <?php if ( !empty( $_REQUEST['aid'] ) ) : ?>
1158
- <?php
1159
- /* translators: %s: the activity ID */
1160
- printf( __( 'Activity related to ID #%s', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) );
1161
- ?>
1162
  <?php else : ?>
1163
  <?php _ex( 'Activity', 'Admin SWA page', 'buddypress' ); ?>
1164
  <?php endif; ?>
1165
 
1166
  <?php if ( !empty( $_REQUEST['s'] ) ) : ?>
1167
- <span class="subtitle">
1168
- <?php
1169
- /* translators: %s: the activity search terms */
1170
- printf( __( 'Search results for &#8220;%s&#8221;', 'buddypress' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) );
1171
- ?>
1172
- </span>
1173
  <?php endif; ?>
1174
  </h1>
1175
 
1176
- <hr class="wp-header-end">
1177
-
1178
  <?php // If the user has just made a change to an activity item, display the status messages. ?>
1179
  <?php if ( !empty( $messages ) ) : ?>
1180
- <div id="moderated" class="<?php echo ( ! empty( $_REQUEST['error'] ) ) ? 'error' : 'updated'; ?> notice is-dismissible"><p><?php echo implode( "<br/>\n", $messages ); ?></p></div>
1181
  <?php endif; ?>
1182
 
1183
  <?php // Display each activity on its own row. ?>
29
 
30
  // Add our screen.
31
  $hook = add_menu_page(
32
+ _x( 'Activity', 'Admin Dashbord SWA page title', 'buddypress' ),
33
+ _x( 'Activity', 'Admin Dashbord SWA menu', 'buddypress' ),
34
  'bp_moderate',
35
  'bp-activity',
36
  'bp_activity_admin',
75
  $parent_id = ! empty( $_REQUEST['parent_id'] ) ? (int) $_REQUEST['parent_id'] : 0;
76
  $root_id = ! empty( $_REQUEST['root_id'] ) ? (int) $_REQUEST['root_id'] : 0;
77
 
78
+ // $parent_id is required
79
  if ( empty( $parent_id ) )
80
  die( '-1' );
81
 
85
 
86
  // Check that a reply has been entered.
87
  if ( empty( $_REQUEST['content'] ) )
88
+ die( __( 'ERROR: Please type a reply.', 'buddypress' ) );
89
 
90
  // Check parent activity exists.
91
  $parent_activity = new BP_Activity_Activity( $parent_id );
92
  if ( empty( $parent_activity->component ) )
93
+ die( __( 'ERROR: The item you are trying to reply to cannot be found, or it has been deleted.', 'buddypress' ) );
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.
232
  'title' => __( 'Item, Link, Type', 'buddypress' ),
233
  'content' =>
234
  '<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>' .
235
+ '<p>' . __( '<strong>Link</strong> - Used by some types of activity (e.g blog posts and comments, and forum topics and replies) to store a link back to the original content.', 'buddypress' ) . '</p>' .
236
  '<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>' .
237
  '<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>'
238
  ) );
296
  );
297
 
298
  // Add accessible hidden heading and text for Activity screen pagination.
299
+ if ( bp_get_major_wp_version() >= 4.4 ) {
300
+ get_current_screen()->set_screen_reader_content( array(
301
+ /* translators: accessibility text */
302
+ 'heading_pagination' => __( 'Activity list navigation', 'buddypress' ),
303
+ ) );
304
+ }
305
  }
306
 
307
  // Enqueue CSS and JavaScript.
311
  ) );
312
  wp_enqueue_style( 'bp_activity_admin_css', $bp->plugin_url . "bp-activity/admin/css/admin{$min}.css", array(), bp_get_version() );
313
 
314
+ wp_style_add_data( 'bp_activity_admin_css', 'rtl', true );
315
  if ( $min ) {
316
  wp_style_add_data( 'bp_activity_admin_css', 'suffix', $min );
317
  }
324
  do_action( 'bp_activity_admin_enqueue_scripts' );
325
 
326
  // Handle spam/un-spam/delete of activities.
327
+ if ( !empty( $doaction ) && ! in_array( $doaction, array( '-1', 'edit', 'save', ) ) ) {
328
 
329
  // Build redirection URL.
330
  $redirect_to = remove_query_arg( array( 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), wp_get_referer() );
331
  $redirect_to = add_query_arg( 'paged', $bp_activity_list_table->get_pagenum(), $redirect_to );
332
 
333
  // Get activity IDs.
334
+ $activity_ids = array_map( 'absint', (array) $_REQUEST['aid'] );
335
 
336
  /**
337
  * Filters list of IDs being spammed/un-spammed/deleted.
350
  // Trim 'bulk_' off the action name to avoid duplicating a ton of code.
351
  $doaction = substr( $doaction, 5 );
352
 
353
+ // This is a request to delete, spam, or un-spam, a single item.
 
 
 
 
354
  } elseif ( !empty( $_REQUEST['aid'] ) ) {
355
 
356
  // Check this is a valid form submission.
357
  check_admin_referer( 'spam-activity_' . $activity_ids[0] );
358
  }
359
 
360
+ // Initialise counters for how many of each type of item we perform an action on.
361
  $deleted = $spammed = $unspammed = 0;
362
 
363
  // Store any errors that occurs when updating the database items.
376
  }
377
 
378
  switch ( $doaction ) {
379
+ case 'delete' :
380
+ if ( 'activity_comment' == $activity->type )
381
+ bp_activity_delete_comment( $activity->item_id, $activity->id );
382
+ else
383
+ bp_activity_delete( array( 'id' => $activity->id ) );
384
+
385
+ $deleted++;
 
 
 
 
 
386
  break;
387
 
388
  case 'ham' :
389
  /**
390
+ * Remove moderation and blacklist checks in case we want to ham an activity
391
  * which contains one of these listed keys.
392
  */
393
  remove_action( 'bp_activity_before_save', 'bp_activity_check_moderation_keys', 2 );
394
+ remove_action( 'bp_activity_before_save', 'bp_activity_check_blacklist_keys', 2 );
395
 
396
  bp_activity_mark_as_ham( $activity );
397
  $result = $activity->save();
398
 
399
  // Check for any error during activity save.
400
+ if ( ! $result )
401
  $errors[] = $activity->id;
402
+ else
403
  $unspammed++;
 
404
  break;
405
 
406
  case 'spam' :
408
  $result = $activity->save();
409
 
410
  // Check for any error during activity save.
411
+ if ( ! $result )
412
  $errors[] = $activity->id;
413
+ else
414
  $spammed++;
 
415
  break;
416
 
417
  default:
436
  do_action( 'bp_activity_admin_action_after', array( $spammed, $unspammed, $deleted, $errors ), $redirect_to, $activity_ids );
437
 
438
  // Add arguments to the redirect URL so that on page reload, we can easily display what we've just done.
439
+ if ( $spammed )
440
  $redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to );
 
441
 
442
+ if ( $unspammed )
443
  $redirect_to = add_query_arg( 'unspammed', $unspammed, $redirect_to );
 
444
 
445
+ if ( $deleted )
446
  $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to );
 
447
 
448
  // If an error occurred, pass back the activity ID that failed.
449
+ if ( ! empty( $errors ) )
450
  $redirect_to = add_query_arg( 'error', implode ( ',', array_map( 'absint', $errors ) ), $redirect_to );
 
451
 
452
  /**
453
  * Filters redirect URL after activity spamming/un-spamming/deletion occurs.
605
  */
606
  function bp_activity_admin() {
607
  // Decide whether to load the index or edit screen.
608
+ $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
609
 
610
  // Display the single activity edit screen.
611
+ if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) )
612
  bp_activity_admin_edit();
613
 
 
 
 
 
614
  // Otherwise, display the Activity index screen.
615
+ else
616
  bp_activity_admin_index();
 
617
  }
618
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
619
  /**
620
  * Display the single activity edit screen.
621
  *
661
  do_action_ref_array( 'bp_activity_admin_edit', array( &$activity ) ); ?>
662
 
663
  <div class="wrap">
664
+ <h1><?php printf( __( 'Editing Activity (ID #%s)', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?></h1>
 
 
 
 
 
 
 
665
 
666
  <?php if ( ! empty( $activity ) ) : ?>
667
 
737
  * @param object $item Activity item.
738
  */
739
  function bp_activity_admin_edit_metabox_status( $item ) {
 
 
 
 
740
  ?>
741
 
742
  <div class="submitbox" id="submitcomment">
762
  $datef = __( 'M j, Y @ G:i', 'buddypress' );
763
  $date = date_i18n( $datef, strtotime( $item->date_recorded ) );
764
  ?>
765
+ <span id="timestamp"><?php printf( __( 'Submitted on: %s', 'buddypress' ), '<strong>' . $date . '</strong>' ); ?></span>&nbsp;<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e( 'Edit', 'buddypress' ); ?></a>
 
 
 
 
 
766
 
767
  <div id='timestampdiv' class='hide-if-js'>
768
  <?php touch_time( 1, 0, 5 ); ?>
774
  </div><!-- #minor-publishing -->
775
 
776
  <div id="major-publishing-actions">
 
 
 
 
777
  <div id="publishing-action">
778
  <?php submit_button( __( 'Update', 'buddypress' ), 'primary', 'save', false ); ?>
779
  </div>
800
  _e( 'Link', 'buddypress' );
801
  ?></label>
802
  <input type="url" name="bp-activities-link" id="bp-activities-link" value="<?php echo esc_url( $item->primary_link ); ?>" aria-describedby="bp-activities-link-description" />
803
+ <p id="bp-activities-link-description"><?php _e( 'Activity generated by posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item.', 'buddypress' ); ?></p>
804
 
805
  <?php
806
  }
841
  $action = array_values( (array) $action );
842
 
843
  for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) {
 
 
 
 
 
 
 
 
 
844
  $actions[ $action[$i]['key'] ] = $action[$i]['value'];
845
  }
846
  }
847
 
848
+ // This was a mis-named activity type from before BP 1.6.
849
+ unset( $actions['friends_register_activity_action'] );
850
+
851
  // Sort array by the human-readable value.
852
  natsort( $actions );
853
 
871
  foreach ( bp_activity_get_actions() as $action ) {
872
  $action = array_values( (array) $action );
873
 
874
+ for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ )
 
 
 
 
 
 
 
 
 
875
  $actions[ $action[$i]['key'] ] = $action[$i]['value'];
 
876
  }
877
 
878
+ // This was a mis-named activity type from before BP 1.6.
879
+ unset( $actions['friends_register_activity_action'] );
880
+
881
  // Sort array by the human-readable value.
882
  natsort( $actions );
883
 
887
  * of the list.
888
  */
889
  if ( ! isset( $actions[ $selected ] ) ) {
890
+ _doing_it_wrong( __FUNCTION__, sprintf( __( 'This activity item has a type (%s) that is not registered using bp_activity_set_action(), so no label is available.', 'buddypress' ), $selected ), '2.0.0' );
 
 
 
 
 
 
 
 
 
891
  $actions[ $selected ] = $selected;
892
  }
893
 
961
  // Reindex array.
962
  $errors = array_values( $errors );
963
 
964
+ if ( $deleted > 0 )
 
965
  $messages[] = sprintf( _n( '%s activity item has been permanently deleted.', '%s activity items have been permanently deleted.', $deleted, 'buddypress' ), number_format_i18n( $deleted ) );
 
966
 
967
  if ( ! empty( $errors ) ) {
968
  if ( 1 == count( $errors ) ) {
 
969
  $messages[] = sprintf( __( 'An error occurred when trying to update activity ID #%s.', 'buddypress' ), number_format_i18n( $errors[0] ) );
970
 
971
  } else {
974
 
975
  // Display each error as a list item.
976
  foreach ( $errors as $error ) {
977
+ // Translators: This is a bulleted list of item IDs.
978
  $error_msg .= '<li>' . sprintf( __( '#%s', 'buddypress' ), number_format_i18n( $error ) ) . '</li>';
979
  }
980
 
983
  }
984
  }
985
 
986
+ if ( $spammed > 0 )
 
987
  $messages[] = sprintf( _n( '%s activity item has been successfully spammed.', '%s activity items have been successfully spammed.', $spammed, 'buddypress' ), number_format_i18n( $spammed ) );
 
988
 
989
+ if ( $unspammed > 0 )
 
990
  $messages[] = sprintf( _n( '%s activity item has been successfully unspammed.', '%s activity items have been successfully unspammed.', $unspammed, 'buddypress' ), number_format_i18n( $unspammed ) );
 
991
 
992
+ if ( $updated > 0 )
993
  $messages[] = __( 'The activity item has been updated successfully.', 'buddypress' );
 
994
  }
995
 
996
  // Prepare the activity items for display.
1006
  do_action( 'bp_activity_admin_index', $messages ); ?>
1007
 
1008
  <div class="wrap">
1009
+ <h1>
1010
  <?php if ( !empty( $_REQUEST['aid'] ) ) : ?>
1011
+ <?php printf( __( 'Activity related to ID #%s', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?>
 
 
 
1012
  <?php else : ?>
1013
  <?php _ex( 'Activity', 'Admin SWA page', 'buddypress' ); ?>
1014
  <?php endif; ?>
1015
 
1016
  <?php if ( !empty( $_REQUEST['s'] ) ) : ?>
1017
+ <span class="subtitle"><?php printf( __( 'Search results for &#8220;%s&#8221;', 'buddypress' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) ); ?></span>
 
 
 
 
 
1018
  <?php endif; ?>
1019
  </h1>
1020
 
 
 
1021
  <?php // If the user has just made a change to an activity item, display the status messages. ?>
1022
  <?php if ( !empty( $messages ) ) : ?>
1023
+ <div id="moderated" class="<?php echo ( ! empty( $_REQUEST['error'] ) ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "<br/>\n", $messages ); ?></p></div>
1024
  <?php endif; ?>
1025
 
1026
  <?php // Display each activity on its own row. ?>
bp-activity/bp-activity-adminbar.php CHANGED
@@ -26,7 +26,7 @@ function bp_activity_admin_menu() {
26
  return;
27
  }
28
 
29
- // Only show this menu to super admins.
30
  if ( ! bp_current_user_can( 'bp_moderate' ) ) {
31
  return;
32
  }
@@ -38,7 +38,7 @@ function bp_activity_admin_menu() {
38
  ), bp_get_admin_url( 'admin.php' ) );
39
 
40
  // Add the top-level Edit Activity button.
41
- $wp_admin_bar->add_node( array(
42
  'id' => 'activity-admin',
43
  'title' => __( 'Edit Activity', 'buddypress' ),
44
  'href' => esc_url( $activity_edit_link ),
26
  return;
27
  }
28
 
29
+ // Only show this menu to super admins
30
  if ( ! bp_current_user_can( 'bp_moderate' ) ) {
31
  return;
32
  }
38
  ), bp_get_admin_url( 'admin.php' ) );
39
 
40
  // Add the top-level Edit Activity button.
41
+ $wp_admin_bar->add_menu( array(
42
  'id' => 'activity-admin',
43
  'title' => __( 'Edit Activity', 'buddypress' ),
44
  'href' => esc_url( $activity_edit_link ),
bp-activity/bp-activity-akismet.php CHANGED
@@ -60,7 +60,7 @@ function bp_activity_akismet_delete_old_metadata() {
60
  // Enforce a minimum of 1 day.
61
  $interval = max( 1, absint( $interval ) );
62
 
63
- // _bp_akismet_submission meta values are large, so expire them after $interval days regardless of the activity status.
64
  $sql = $wpdb->prepare( "SELECT a.id FROM {$bp->activity->table_name} a LEFT JOIN {$bp->activity->table_name_meta} m ON a.id = m.activity_id WHERE m.meta_key = %s AND DATE_SUB(%s, INTERVAL {$interval} DAY) > a.date_recorded LIMIT 10000", '_bp_akismet_submission', current_time( 'mysql', 1 ) );
65
  $activity_ids = $wpdb->get_col( $sql );
66
 
60
  // Enforce a minimum of 1 day.
61
  $interval = max( 1, absint( $interval ) );
62
 
63
+ // _bp_akismet_submission meta values are large, so expire them after $interval days regardless of the activity status
64
  $sql = $wpdb->prepare( "SELECT a.id FROM {$bp->activity->table_name} a LEFT JOIN {$bp->activity->table_name_meta} m ON a.id = m.activity_id WHERE m.meta_key = %s AND DATE_SUB(%s, INTERVAL {$interval} DAY) > a.date_recorded LIMIT 10000", '_bp_akismet_submission', current_time( 'mysql', 1 ) );
65
  $activity_ids = $wpdb->get_col( $sql );
66
 
bp-activity/bp-activity-blocks.php DELETED
@@ -1,167 +0,0 @@
1
- <?php
2
- /**
3
- * BP Activity Blocks Functions.
4
- *
5
- * @package BuddyPress
6
- * @subpackage ActvityBlocks
7
- * @since 7.0.0
8
- */
9
-
10
- // Exit if accessed directly.
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- }
14
-
15
- /**
16
- * Callback function to render the Latest Activities Block.
17
- *
18
- * @since 9.0.0
19
- *
20
- * @param array $attributes The block attributes.
21
- * @return string HTML output.
22
- */
23
- function bp_activity_render_latest_activities_block( $attributes = array() ) {
24
- $block_args = wp_parse_args(
25
- $attributes,
26
- array(
27
- 'title' => __( 'Latest updates', 'buddypress' ),
28
- 'maxActivities' => 5,
29
- 'type' => array( 'activity_update' ),
30
- 'postId' => 0,
31
- )
32
- );
33
-
34
- $max_activities = (int) $block_args['maxActivities'];
35
-
36
- // Should we get a specific member's activities?
37
- $member_id = 0;
38
- if ( $block_args['postId'] ) {
39
- $member_id = (int) get_post_field( 'post_author', $block_args['postId'] );
40
- } else {
41
- $member_id = bp_displayed_user_id();
42
- }
43
-
44
- // Set the widget's wrapper attributes.
45
- $types = (array) $block_args['type'];
46
- $classnames = array_map( 'sanitize_html_class', array_merge( $types, array( 'bp-latest-activities', 'buddypress', 'widget' ) ) );
47
- $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classnames ) ) );
48
-
49
- // Set the Block's title.
50
- $widget_content = sprintf( '<h2 class="widget-title">%s</h2>', esc_html( $block_args['title'] ) );
51
-
52
- // Avoid conflicts with other activity loops.
53
- $reset_activities_template = null;
54
- if ( ! empty( $GLOBALS['activities_template'] ) ) {
55
- $reset_activities_template = $GLOBALS['activities_template'];
56
- }
57
-
58
- /**
59
- * Filter here to edit the arguments used by the Latest Activities block.
60
- *
61
- * @since 9.0.0
62
- *
63
- * @param array $widget_args The list of arguments for the Activity query.
64
- * @param array $block_args The list of Block attributes.
65
- */
66
- $widget_args = apply_filters(
67
- 'bp_activity_block_latest_updates_args',
68
- array(
69
- 'max' => $max_activities,
70
- 'scope' => 'all',
71
- 'user_id' => $member_id,
72
- 'object' => false,
73
- 'action' => implode( ',', $types ),
74
- 'primary_id' => 0,
75
- 'secondary_id' => 0,
76
- ),
77
- $block_args
78
- );
79
-
80
- // Build the activity loop.
81
- if ( 'nouveau' === bp_get_theme_compat_id() ) {
82
- $bp_nouveau = bp_nouveau();
83
-
84
- // Globalize the activity widget arguments.
85
- $bp_nouveau->activity->widget_args = $widget_args;
86
-
87
- ob_start();
88
- bp_get_template_part( 'activity/widget' );
89
- $widget_content .= ob_get_clean();
90
-
91
- // Reset the global.
92
- $bp_nouveau->activity->widget_args = array();
93
- } else {
94
- $activity_loop = sprintf( '<div class="widget-error"><p>%s</p></div>', esc_html__( 'Sorry, there was no activity found. Please try a different filter.', 'buddypress' ) );
95
-
96
- if ( bp_has_activities( $widget_args ) ) {
97
- $activity_loop = '';
98
-
99
- while ( bp_activities() ) {
100
- bp_the_activity();
101
-
102
- $activity_footer = '';
103
- $activity_classes = 'activity-item';
104
- if ( bp_activity_has_content() ) {
105
- $activity_content = bp_get_activity_content_body();
106
- $activity_footer = sprintf(
107
- '<footer>
108
- <cite>
109
- <a href="%1$s" class="bp-tooltip" data-bp-tooltip="%2$s">
110
- %3$s
111
- </a>
112
- </cite>
113
- %4$s
114
- </footer>',
115
- bp_get_activity_user_link(),
116
- bp_get_activity_member_display_name(),
117
- bp_get_activity_avatar(
118
- array(
119
- 'type' => 'thumb',
120
- 'width' => '40',
121
- 'height' => '40',
122
- )
123
- ),
124
- bp_insert_activity_meta()
125
- );
126
- } else {
127
- $activity_classes .= ' mini';
128
- $activity_content = bp_get_activity_action();
129
- }
130
-
131
- $activity_loop .= sprintf(
132
- '<blockquote>
133
- <div class="%1$s">%2$s</div>
134
- %3$s
135
- </blockquote>',
136
- $activity_classes,
137
- $activity_content,
138
- $activity_footer
139
- );
140
- }
141
- }
142
-
143
- $widget_content .= sprintf(
144
- '<div class="activity-list item-list">
145
- %1$s
146
- </div>',
147
- $activity_loop
148
- );
149
- }
150
-
151
- // Adds a container to make sure the block is styled even when used into the Columns parent block.
152
- $widget_content = sprintf( '<div class="bp-latest-activities-block">%s</div>', "\n" . $widget_content . "\n" );
153
-
154
- // Reset the global template loop.
155
- $GLOBALS['activities_template'] = $reset_activities_template;
156
-
157
- // Only add a block wrapper if not loaded into a Widgets sidebar.
158
- if ( ! did_action( 'dynamic_sidebar_before' ) ) {
159
- return sprintf(
160
- '<div %1$s>%2$s</div>',
161
- $wrapper_attributes,
162
- $widget_content
163
- );
164
- }
165
-
166
- return $widget_content;
167
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/bp-activity-cssjs.php CHANGED
@@ -22,16 +22,10 @@ function bp_activity_mentions_script() {
22
 
23
  // Special handling for New/Edit screens in wp-admin.
24
  if ( is_admin() ) {
25
- $current_screen = null;
26
- if ( function_exists( 'get_current_screen' ) ) {
27
- $current_screen = get_current_screen();
28
- }
29
-
30
  if (
31
- ! $current_screen ||
32
- ( isset( $current_screen->is_block_editor ) && $current_screen->is_block_editor ) ||
33
- ! in_array( $current_screen->base, array( 'page', 'post' ) ) ||
34
- ! post_type_supports( $current_screen->post_type, 'editor' ) ) {
35
  return;
36
  }
37
  }
@@ -42,7 +36,7 @@ function bp_activity_mentions_script() {
42
  wp_enqueue_script( 'bp-mentions', buddypress()->plugin_url . "bp-activity/js/mentions{$min}.js", array( 'jquery', 'jquery-atwho' ), bp_get_version(), true );
43
  wp_enqueue_style( 'bp-mentions-css', buddypress()->plugin_url . "bp-activity/css/mentions{$min}.css", array(), bp_get_version() );
44
 
45
- wp_style_add_data( 'bp-mentions-css', 'rtl', 'replace' );
46
  if ( $min ) {
47
  wp_style_add_data( 'bp-mentions-css', 'suffix', $min );
48
  }
22
 
23
  // Special handling for New/Edit screens in wp-admin.
24
  if ( is_admin() ) {
 
 
 
 
 
25
  if (
26
+ ! get_current_screen() ||
27
+ ! in_array( get_current_screen()->base, array( 'page', 'post' ) ) ||
28
+ ! post_type_supports( get_current_screen()->post_type, 'editor' ) ) {
 
29
  return;
30
  }
31
  }
36
  wp_enqueue_script( 'bp-mentions', buddypress()->plugin_url . "bp-activity/js/mentions{$min}.js", array( 'jquery', 'jquery-atwho' ), bp_get_version(), true );
37
  wp_enqueue_style( 'bp-mentions-css', buddypress()->plugin_url . "bp-activity/css/mentions{$min}.css", array(), bp_get_version() );
38
 
39
+ wp_style_add_data( 'bp-mentions-css', 'rtl', true );
40
  if ( $min ) {
41
  wp_style_add_data( 'bp-mentions-css', 'suffix', $min );
42
  }
bp-activity/bp-activity-embeds.php CHANGED
@@ -2,6 +2,8 @@
2
  /**
3
  * Functions related to embedding single activity items externally.
4
  *
 
 
5
  * @since 2.6.0
6
  *
7
  * @package BuddyPress
@@ -17,7 +19,9 @@ defined( 'ABSPATH' ) || exit;
17
  * @since 2.6.0
18
  */
19
  function bp_activity_setup_oembed() {
20
- buddypress()->activity->oembed = new BP_Activity_oEmbed_Extension;
 
 
21
  }
22
  add_action( 'bp_loaded', 'bp_activity_setup_oembed' );
23
 
@@ -100,7 +104,7 @@ function bp_activity_embed_has_activity( $activity_id = 0 ) {
100
  $activity = (array) $activities_template->activities;
101
  $activity = reset( $activity );
102
 
103
- // No need to requery if we already got the embed activity.
104
  if ( (int) $activity_id === $activity->id ) {
105
  return $activities_template->has_activities();
106
  }
@@ -234,10 +238,10 @@ function bp_activity_embed_media() {
234
  $thumbnail = $oembed->thumbnail_url;
235
 
236
  /* Non-oEmbed standard attributes */
237
- // Mixcloud.
238
  } elseif ( isset( $oembed->image ) ) {
239
  $thumbnail = $oembed->image;
240
- // ReverbNation.
241
  } elseif ( isset( $oembed->{'thumbnail-url'} ) ) {
242
  $thumbnail = $oembed->{'thumbnail-url'};
243
  }
@@ -261,31 +265,30 @@ EOD;
261
  $play_icon = sprintf( '<a rel="nofollow" class="play-btn" href="%1$s" onclick="top.location.href=\'%1$s\'">%2$s</a>', esc_url( $url ), $play_icon );
262
  }
263
 
264
- // Thumb width.
265
  $thumb_width = isset( $oembed->thumbnail_width ) && 'photo' !== $oembed->type && (int) $oembed->thumbnail_width < 550 ? (int) $oembed->thumbnail_width : $width;
266
 
267
  $float_width = 350;
268
 
269
  // Set up thumb.
270
- $content = sprintf( '<div class="thumb" style="max-width:%1$spx">%2$s<a href="%3$s" rel="nofollow" onclick="top.location.href=\'%3$s\'"><img loading="lazy" src="%4$s" alt="" /></a></div>', $thumb_width, $play_icon, esc_url( $url ), esc_url( $thumbnail ) );
271
 
272
  // Show title.
273
  if ( isset( $oembed->title ) ) {
274
  $caption .= sprintf( '<p class="caption-title"><strong>%s</strong></p>', apply_filters( 'single_post_title', $oembed->title ) );
275
  }
276
 
277
- // Show description (non-oEmbed standard).
278
  if ( isset( $oembed->description ) ) {
279
  $caption .= sprintf( '<div class="caption-description">%s</div>', apply_filters( 'bp_activity_get_embed_excerpt', $oembed->description ) );
280
  }
281
 
282
  // Show author info.
283
  if ( isset( $oembed->provider_name ) && isset( $oembed->author_name ) ) {
284
- /* translators: 1: oEmbed author. 2: oEmbed provider. eg. By BuddyPress on YouTube. */
285
  $anchor_text = sprintf( __( 'By %1$s on %2$s', 'buddypress' ), $oembed->author_name, $oembed->provider_name );
286
 
287
  } elseif ( isset( $oembed->provider_name ) ) {
288
- /* translators: %s: oEmbed provider. */
289
  $anchor_text = sprintf( __( 'View on %s', 'buddypress' ), $oembed->provider_name );
290
  }
291
 
2
  /**
3
  * Functions related to embedding single activity items externally.
4
  *
5
+ * Relies on WordPress 4.5.
6
+ *
7
  * @since 2.6.0
8
  *
9
  * @package BuddyPress
19
  * @since 2.6.0
20
  */
21
  function bp_activity_setup_oembed() {
22
+ if ( version_compare( $GLOBALS['wp_version'], '4.5', '>=' ) && bp_is_active( 'activity', 'embeds' ) ) {
23
+ buddypress()->activity->oembed = new BP_Activity_oEmbed_Extension;
24
+ }
25
  }
26
  add_action( 'bp_loaded', 'bp_activity_setup_oembed' );
27
 
104
  $activity = (array) $activities_template->activities;
105
  $activity = reset( $activity );
106
 
107
+ // No need to requery if we already got the embed activity
108
  if ( (int) $activity_id === $activity->id ) {
109
  return $activities_template->has_activities();
110
  }
238
  $thumbnail = $oembed->thumbnail_url;
239
 
240
  /* Non-oEmbed standard attributes */
241
+ // Mixcloud
242
  } elseif ( isset( $oembed->image ) ) {
243
  $thumbnail = $oembed->image;
244
+ // ReverbNation
245
  } elseif ( isset( $oembed->{'thumbnail-url'} ) ) {
246
  $thumbnail = $oembed->{'thumbnail-url'};
247
  }
265
  $play_icon = sprintf( '<a rel="nofollow" class="play-btn" href="%1$s" onclick="top.location.href=\'%1$s\'">%2$s</a>', esc_url( $url ), $play_icon );
266
  }
267
 
268
+ // Thumb width
269
  $thumb_width = isset( $oembed->thumbnail_width ) && 'photo' !== $oembed->type && (int) $oembed->thumbnail_width < 550 ? (int) $oembed->thumbnail_width : $width;
270
 
271
  $float_width = 350;
272
 
273
  // Set up thumb.
274
+ $content = sprintf( '<div class="thumb" style="max-width:%1$spx">%2$s<a href="%3$s" rel="nofollow" onclick="top.location.href=\'%3$s\'"><img src="%4$s" /></a></div>', $thumb_width, $play_icon, esc_url( $url ), esc_url( $thumbnail ) );
275
 
276
  // Show title.
277
  if ( isset( $oembed->title ) ) {
278
  $caption .= sprintf( '<p class="caption-title"><strong>%s</strong></p>', apply_filters( 'single_post_title', $oembed->title ) );
279
  }
280
 
281
+ // Show description (non-oEmbed standard)
282
  if ( isset( $oembed->description ) ) {
283
  $caption .= sprintf( '<div class="caption-description">%s</div>', apply_filters( 'bp_activity_get_embed_excerpt', $oembed->description ) );
284
  }
285
 
286
  // Show author info.
287
  if ( isset( $oembed->provider_name ) && isset( $oembed->author_name ) ) {
288
+ /* translators: By [oEmbed author] on [oEmbed provider]. eg. By BuddyPress on YouTube. */
289
  $anchor_text = sprintf( __( 'By %1$s on %2$s', 'buddypress' ), $oembed->author_name, $oembed->provider_name );
290
 
291
  } elseif ( isset( $oembed->provider_name ) ) {
 
292
  $anchor_text = sprintf( __( 'View on %s', 'buddypress' ), $oembed->provider_name );
293
  }
294
 
bp-activity/bp-activity-filters.php CHANGED
@@ -13,7 +13,9 @@ defined( 'ABSPATH' ) || exit;
13
  /* Filters *******************************************************************/
14
 
15
  // Apply WordPress defined filters.
 
16
  add_filter( 'bp_get_activity_content_body', 'bp_activity_filter_kses', 1 );
 
17
  add_filter( 'bp_get_activity_parent_content', 'bp_activity_filter_kses', 1 );
18
  add_filter( 'bp_get_activity_latest_update', 'bp_activity_filter_kses', 1 );
19
  add_filter( 'bp_get_activity_latest_update_excerpt', 'bp_activity_filter_kses', 1 );
@@ -31,7 +33,9 @@ add_filter( 'bp_get_activity_feed_item_description', 'force_balance_tags' );
31
  add_filter( 'bp_activity_content_before_save', 'force_balance_tags' );
32
  add_filter( 'bp_activity_action_before_save', 'force_balance_tags' );
33
 
34
- add_filter( 'bp_activity_content_before_save', 'wp_encode_emoji' );
 
 
35
 
36
  add_filter( 'bp_get_activity_action', 'wptexturize' );
37
  add_filter( 'bp_get_activity_content_body', 'wptexturize' );
@@ -91,10 +95,9 @@ add_filter( 'bp_get_activity_latest_update', 'bp_activity_make_nofollow_
91
  add_filter( 'bp_get_activity_latest_update_excerpt', 'bp_activity_make_nofollow_filter' );
92
  add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_make_nofollow_filter' );
93
 
94
- add_filter( 'bp_get_activity_content_body', 'bp_core_add_loading_lazy_attribute' );
95
- add_filter( 'bp_activity_comment_content', 'bp_core_add_loading_lazy_attribute' );
96
-
97
  add_filter( 'pre_comment_content', 'bp_activity_at_name_filter' );
 
 
98
  add_filter( 'the_content', 'bp_activity_at_name_filter' );
99
  add_filter( 'bp_activity_get_embed_excerpt', 'bp_activity_at_name_filter' );
100
 
@@ -108,9 +111,6 @@ add_filter( 'bp_get_total_mention_count_for_user', 'bp_core_number_format' );
108
 
109
  add_filter( 'bp_activity_get_embed_excerpt', 'bp_activity_embed_excerpt_onclick_location_filter', 9 );
110
 
111
- // Personal data export.
112
- add_filter( 'wp_privacy_personal_data_exporters', 'bp_activity_register_personal_data_exporter' );
113
-
114
  /* Actions *******************************************************************/
115
 
116
  // At-name filter.
@@ -118,7 +118,7 @@ add_action( 'bp_activity_before_save', 'bp_activity_at_name_filter_updates' );
118
 
119
  // Activity stream moderation.
120
  add_action( 'bp_activity_before_save', 'bp_activity_check_moderation_keys', 2, 1 );
121
- add_action( 'bp_activity_before_save', 'bp_activity_check_disallowed_keys', 2, 1 );
122
 
123
  /** Functions *****************************************************************/
124
 
@@ -171,13 +171,13 @@ function bp_activity_check_moderation_keys( $activity ) {
171
  }
172
 
173
  /**
174
- * Mark the posted activity as spam, if it contains disallowed keywords.
175
  *
176
- * @since 7.0.0
177
  *
178
  * @param BP_Activity_Activity $activity The activity object to check.
179
  */
180
- function bp_activity_check_disallowed_keys( $activity ) {
181
 
182
  // Only check specific types of activity updates.
183
  if ( ! in_array( $activity->type, bp_activity_get_moderated_activity_types() ) ) {
@@ -186,9 +186,9 @@ function bp_activity_check_disallowed_keys( $activity ) {
186
 
187
  // Send back the error so activity update fails.
188
  // @todo This is temporary until some kind of trash status is built.
189
- $disallowed = bp_core_check_for_disallowed_keys( $activity->user_id, '', $activity->content, 'wp_error' );
190
- if ( is_wp_error( $disallowed ) ) {
191
- $activity->errors = $disallowed;
192
 
193
  // Backpat.
194
  $activity->component = false;
@@ -204,13 +204,35 @@ function bp_activity_check_disallowed_keys( $activity ) {
204
  * @return string $content Filtered activity content.
205
  */
206
  function bp_activity_filter_kses( $content ) {
207
- $activity_allowedtags = bp_get_allowedtags();
208
-
209
- // Don't allow 'class' or 'id'.
210
- foreach ( $activity_allowedtags as $el => &$atts ) {
211
- unset( $atts['class'] );
212
- unset( $atts['id'] );
213
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
 
215
  /**
216
  * Filters the allowed HTML tags for BuddyPress Activity content.
@@ -329,17 +351,15 @@ function bp_activity_at_name_send_emails( $activity ) {
329
  return;
330
  }
331
 
332
- $bp = buddypress();
333
-
334
  // If our temporary variable doesn't exist, stop now.
335
- if ( empty( $bp->activity->mentioned_users ) )
336
  return;
337
 
338
  // Grab our temporary variable from bp_activity_at_name_filter_updates().
339
- $usernames = $bp->activity->mentioned_users;
340
 
341
  // Get rid of temporary variable.
342
- unset( $bp->activity->mentioned_users );
343
 
344
  // Send @mentions and setup BP notifications.
345
  foreach( (array) $usernames as $user_id => $username ) {
@@ -377,20 +397,17 @@ function bp_activity_make_nofollow_filter( $text ) {
377
  }
378
 
379
  /**
380
- * Adds `rel="nofollow ugc"` to a link.
381
  *
382
- * @since 1.2.0 Adds the nofollow rel attribute.
383
- * @since 7.0.0 Adds the ugc rel attribute.
384
  *
385
  * @param array $matches Items matched by preg_replace_callback() in bp_activity_make_nofollow_filter().
386
  * @return string $text Link with rel=nofollow added.
387
  */
388
  function bp_activity_make_nofollow_filter_callback( $matches ) {
389
  $text = $matches[1];
390
-
391
- // The WP `make_clickable()` formatting function is adding the rel="nofollow" attribute.
392
- $text = str_replace( array( ' rel="nofollow"', " rel='nofollow'" ), '', $text );
393
- return "<a $text rel=\"nofollow ugc\">";
394
  }
395
 
396
  /**
@@ -619,7 +636,7 @@ function bp_activity_heartbeat_strings( $strings = array() ) {
619
  */
620
  $heartbeat_settings = apply_filters( 'heartbeat_settings', array() );
621
  if ( ! empty( $heartbeat_settings['interval'] ) ) {
622
- // 'Fast' is 5.
623
  $global_pulse = is_numeric( $heartbeat_settings['interval'] ) ? absint( $heartbeat_settings['interval'] ) : 5;
624
  }
625
 
@@ -817,22 +834,3 @@ function bp_activity_filter_mentions_scope( $retval = array(), $filter = array()
817
  return $retval;
818
  }
819
  add_filter( 'bp_activity_set_mentions_scope_args', 'bp_activity_filter_mentions_scope', 10, 2 );
820
-
821
- /**
822
- * Registers Activity personal data exporter.
823
- *
824
- * @since 4.0.0
825
- * @since 5.0.0 adds an `exporter_bp_friendly_name` param to exporters.
826
- *
827
- * @param array $exporters An array of personal data exporters.
828
- * @return array An array of personal data exporters.
829
- */
830
- function bp_activity_register_personal_data_exporter( $exporters ) {
831
- $exporters['buddypress-activity'] = array(
832
- 'exporter_friendly_name' => __( 'BuddyPress Activity Data', 'buddypress' ),
833
- 'callback' => 'bp_activity_personal_data_exporter',
834
- 'exporter_bp_friendly_name' => _x( 'Activity Data', 'BuddyPress Activity data exporter friendly name', 'buddypress' ),
835
- );
836
-
837
- return $exporters;
838
- }
13
  /* Filters *******************************************************************/
14
 
15
  // Apply WordPress defined filters.
16
+ add_filter( 'bp_get_activity_action', 'bp_activity_filter_kses', 1 );
17
  add_filter( 'bp_get_activity_content_body', 'bp_activity_filter_kses', 1 );
18
+ add_filter( 'bp_get_activity_content', 'bp_activity_filter_kses', 1 );
19
  add_filter( 'bp_get_activity_parent_content', 'bp_activity_filter_kses', 1 );
20
  add_filter( 'bp_get_activity_latest_update', 'bp_activity_filter_kses', 1 );
21
  add_filter( 'bp_get_activity_latest_update_excerpt', 'bp_activity_filter_kses', 1 );
33
  add_filter( 'bp_activity_content_before_save', 'force_balance_tags' );
34
  add_filter( 'bp_activity_action_before_save', 'force_balance_tags' );
35
 
36
+ if ( function_exists( 'wp_encode_emoji' ) ) {
37
+ add_filter( 'bp_activity_content_before_save', 'wp_encode_emoji' );
38
+ }
39
 
40
  add_filter( 'bp_get_activity_action', 'wptexturize' );
41
  add_filter( 'bp_get_activity_content_body', 'wptexturize' );
95
  add_filter( 'bp_get_activity_latest_update_excerpt', 'bp_activity_make_nofollow_filter' );
96
  add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_make_nofollow_filter' );
97
 
 
 
 
98
  add_filter( 'pre_comment_content', 'bp_activity_at_name_filter' );
99
+ add_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_name_filter' );
100
+ add_filter( 'group_forum_post_text_before_save', 'bp_activity_at_name_filter' );
101
  add_filter( 'the_content', 'bp_activity_at_name_filter' );
102
  add_filter( 'bp_activity_get_embed_excerpt', 'bp_activity_at_name_filter' );
103
 
111
 
112
  add_filter( 'bp_activity_get_embed_excerpt', 'bp_activity_embed_excerpt_onclick_location_filter', 9 );
113
 
 
 
 
114
  /* Actions *******************************************************************/
115
 
116
  // At-name filter.
118
 
119
  // Activity stream moderation.
120
  add_action( 'bp_activity_before_save', 'bp_activity_check_moderation_keys', 2, 1 );
121
+ add_action( 'bp_activity_before_save', 'bp_activity_check_blacklist_keys', 2, 1 );
122
 
123
  /** Functions *****************************************************************/
124
 
171
  }
172
 
173
  /**
174
+ * Mark the posted activity as spam, if it contains blacklist keywords.
175
  *
176
+ * @since 1.6.0
177
  *
178
  * @param BP_Activity_Activity $activity The activity object to check.
179
  */
180
+ function bp_activity_check_blacklist_keys( $activity ) {
181
 
182
  // Only check specific types of activity updates.
183
  if ( ! in_array( $activity->type, bp_activity_get_moderated_activity_types() ) ) {
186
 
187
  // Send back the error so activity update fails.
188
  // @todo This is temporary until some kind of trash status is built.
189
+ $blacklist = bp_core_check_for_blacklist( $activity->user_id, '', $activity->content, 'wp_error' );
190
+ if ( is_wp_error( $blacklist ) ) {
191
+ $activity->errors = $blacklist;
192
 
193
  // Backpat.
194
  $activity->component = false;
204
  * @return string $content Filtered activity content.
205
  */
206
  function bp_activity_filter_kses( $content ) {
207
+ global $allowedtags;
208
+
209
+ $activity_allowedtags = $allowedtags;
210
+ $activity_allowedtags['a']['aria-label'] = array();
211
+ $activity_allowedtags['a']['class'] = array();
212
+ $activity_allowedtags['a']['data-bp-tooltip'] = array();
213
+ $activity_allowedtags['a']['id'] = array();
214
+ $activity_allowedtags['a']['rel'] = array();
215
+ $activity_allowedtags['a']['title'] = array();
216
+
217
+ $activity_allowedtags['b'] = array();
218
+ $activity_allowedtags['code'] = array();
219
+ $activity_allowedtags['i'] = array();
220
+
221
+ $activity_allowedtags['img'] = array();
222
+ $activity_allowedtags['img']['src'] = array();
223
+ $activity_allowedtags['img']['alt'] = array();
224
+ $activity_allowedtags['img']['width'] = array();
225
+ $activity_allowedtags['img']['height'] = array();
226
+ $activity_allowedtags['img']['class'] = array();
227
+ $activity_allowedtags['img']['id'] = array();
228
+
229
+ $activity_allowedtags['span'] = array();
230
+ $activity_allowedtags['span']['class'] = array();
231
+ $activity_allowedtags['span']['data-livestamp'] = array();
232
+
233
+ $activity_allowedtags['ul'] = array();
234
+ $activity_allowedtags['ol'] = array();
235
+ $activity_allowedtags['li'] = array();
236
 
237
  /**
238
  * Filters the allowed HTML tags for BuddyPress Activity content.
351
  return;
352
  }
353
 
 
 
354
  // If our temporary variable doesn't exist, stop now.
355
+ if ( empty( buddypress()->activity->mentioned_users ) )
356
  return;
357
 
358
  // Grab our temporary variable from bp_activity_at_name_filter_updates().
359
+ $usernames = buddypress()->activity->mentioned_users;
360
 
361
  // Get rid of temporary variable.
362
+ unset( buddypress()->activity->mentioned_users );
363
 
364
  // Send @mentions and setup BP notifications.
365
  foreach( (array) $usernames as $user_id => $username ) {
397
  }
398
 
399
  /**
400
+ * Add rel=nofollow to a link.
401
  *
402
+ * @since 1.2.0
 
403
  *
404
  * @param array $matches Items matched by preg_replace_callback() in bp_activity_make_nofollow_filter().
405
  * @return string $text Link with rel=nofollow added.
406
  */
407
  function bp_activity_make_nofollow_filter_callback( $matches ) {
408
  $text = $matches[1];
409
+ $text = str_replace( array( ' rel="nofollow"', " rel='nofollow'"), '', $text );
410
+ return "<a $text rel=\"nofollow\">";
 
 
411
  }
412
 
413
  /**
636
  */
637
  $heartbeat_settings = apply_filters( 'heartbeat_settings', array() );
638
  if ( ! empty( $heartbeat_settings['interval'] ) ) {
639
+ // 'Fast' is 5
640
  $global_pulse = is_numeric( $heartbeat_settings['interval'] ) ? absint( $heartbeat_settings['interval'] ) : 5;
641
  }
642
 
834
  return $retval;
835
  }
836
  add_filter( 'bp_activity_set_mentions_scope_args', 'bp_activity_filter_mentions_scope', 10, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/bp-activity-functions.php CHANGED
@@ -20,7 +20,7 @@ defined( 'ABSPATH' ) || exit;
20
  * @return bool True if activity directory page is found, otherwise false.
21
  */
22
  function bp_activity_has_directory() {
23
- return isset( buddypress()->pages->activity->id ) && buddypress()->pages->activity->id;
24
  }
25
 
26
  /**
@@ -522,12 +522,12 @@ function bp_activity_get_post_type_tracking_args( $post_type ) {
522
  $post_type_activity->new_post_type_action_ms = $post_type_object->labels->bp_activity_new_post_ms;
523
  }
524
 
525
- // If the post type supports comments and has a comment action id, build the comments tracking args.
526
  if ( $post_type_support_comments && ! empty( $post_type_activity->comment_action_id ) ) {
527
- // Init a new container for the activity type for comments.
528
  $post_type_activity->comments_tracking = new stdClass();
529
 
530
- // Build the activity type for comments.
531
  $post_type_activity->comments_tracking->component_id = $post_type_activity->component_id;
532
  $post_type_activity->comments_tracking->action_id = $post_type_activity->comment_action_id;
533
 
@@ -597,9 +597,9 @@ function bp_activity_get_post_types_tracking_args() {
597
  $track_post_type = bp_activity_get_post_type_tracking_args( $post_type );
598
 
599
  if ( ! empty( $track_post_type ) ) {
600
- // Set the post type comments tracking args.
601
  if ( ! empty( $track_post_type->comments_tracking->action_id ) ) {
602
- // Used to check support for comment tracking by activity type (new_post_type_comment).
603
  $track_post_type->comments_tracking->comments_tracking = true;
604
 
605
  // Used to be able to find the post type this activity type is associated to.
@@ -607,7 +607,7 @@ function bp_activity_get_post_types_tracking_args() {
607
 
608
  $post_types_tracking_args[ $track_post_type->comments_tracking->action_id ] = $track_post_type->comments_tracking;
609
 
610
- // Used to check support for comment tracking by activity type (new_post_type).
611
  $track_post_type->comments_tracking = true;
612
  }
613
 
@@ -650,7 +650,7 @@ function bp_activity_type_supports( $activity_type = '', $feature = '' ) {
650
  * eg. 'new_blog_post' and 'new_blog_comment' will both return true.
651
  */
652
  case 'post-type-comment-tracking' :
653
- // Set the activity track global if not set yet.
654
  if ( empty( $bp->activity->track ) ) {
655
  $bp->activity->track = bp_activity_get_post_types_tracking_args();
656
  }
@@ -726,7 +726,7 @@ function bp_activity_post_type_get_tracking_arg( $activity_type, $arg = '' ) {
726
 
727
  $bp = buddypress();
728
 
729
- // Set the activity track global if not set yet.
730
  if ( empty( $bp->activity->track ) ) {
731
  $bp->activity->track = bp_activity_get_post_types_tracking_args();
732
  }
@@ -748,14 +748,11 @@ function bp_activity_post_type_get_tracking_arg( $activity_type, $arg = '' ) {
748
  function bp_activity_get_actions() {
749
  $bp = buddypress();
750
 
751
- // Set the activity track global if not set yet.
752
- if ( empty( $bp->activity->track ) ) {
753
- $bp->activity->track = bp_activity_get_post_types_tracking_args();
754
- }
755
 
756
  // Create the actions for the post types, if they haven't already been created.
757
- if ( ! empty( $bp->activity->track ) ) {
758
- foreach ( $bp->activity->track as $post_type ) {
759
  if ( isset( $bp->activity->actions->{$post_type->component_id}->{$post_type->action_id} ) ) {
760
  continue;
761
  }
@@ -842,58 +839,12 @@ function bp_activity_get_types() {
842
  return apply_filters( 'bp_activity_get_types', $actions );
843
  }
844
 
845
- /**
846
- * Returns the list of available BuddyPress activity types.
847
- *
848
- * @since 9.0.0
849
- *
850
- * @return array An array of activity type labels keyed by type names.
851
- */
852
- function bp_activity_get_types_list() {
853
- $actions_object = bp_activity_get_actions();
854
- $actions_array = get_object_vars( $actions_object );
855
-
856
- $types = array();
857
- foreach ( $actions_array as $component => $actions ) {
858
- $new_types = wp_list_pluck( $actions, 'label', 'key' );
859
-
860
- if ( $types ) {
861
- // Makes sure activity types are unique.
862
- $new_types = array_diff_key( $new_types, $types );
863
-
864
- if ( 'friends' === $component ) {
865
- $new_types = array_diff_key(
866
- array(
867
- 'friendship_accepted' => false,
868
- 'friendship_created' => false,
869
- 'friends_register_activity_action' => false,
870
- ),
871
- $new_types
872
- );
873
-
874
- $new_types['friendship_accepted,friendship_created'] = __( 'Friendships', 'buddypress' );
875
- }
876
- }
877
-
878
- $types = array_merge( $types, $new_types );
879
- }
880
-
881
- /**
882
- * Filter here to edit the activity types list.
883
- *
884
- * @since 9.0.0
885
- *
886
- * @param array $types An array of activity type labels keyed by type names.
887
- */
888
- return apply_filters( 'bp_activity_get_types_list', $types );
889
- }
890
-
891
  /**
892
  * Gets the current activity context.
893
  *
894
  * The "context" is the current view type, corresponding roughly to the
895
  * current component. Use this context to determine which activity actions
896
- * should be permitted in the filter dropdown.
897
  *
898
  * @since 2.8.0
899
  *
@@ -986,6 +937,11 @@ function bp_activity_get_user_favorites( $user_id = 0 ) {
986
  */
987
  function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
988
 
 
 
 
 
 
989
  // Fallback to logged in user if no user_id is passed.
990
  if ( empty( $user_id ) ) {
991
  $user_id = bp_loggedin_user_id();
@@ -1055,6 +1011,11 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
1055
  */
1056
  function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
1057
 
 
 
 
 
 
1058
  // Fallback to logged in user if no user_id is passed.
1059
  if ( empty( $user_id ) ) {
1060
  $user_id = bp_loggedin_user_id();
@@ -1299,7 +1260,9 @@ function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = f
1299
  * @return bool
1300
  */
1301
  function bp_activity_remove_all_user_data( $user_id = 0 ) {
1302
- if ( empty( $user_id ) ) {
 
 
1303
  return false;
1304
  }
1305
 
@@ -1323,22 +1286,7 @@ function bp_activity_remove_all_user_data( $user_id = 0 ) {
1323
  do_action( 'bp_activity_remove_all_user_data', $user_id );
1324
  }
1325
  add_action( 'wpmu_delete_user', 'bp_activity_remove_all_user_data' );
1326
-
1327
- /**
1328
- * Deletes user activity data on the 'delete_user' hook.
1329
- *
1330
- * @since 6.0.0
1331
- *
1332
- * @param int $user_id The ID of the deleted user.
1333
- */
1334
- function bp_activity_remove_all_user_data_on_delete_user( $user_id ) {
1335
- if ( ! bp_remove_user_data_on_delete_user_hook( 'activity', $user_id ) ) {
1336
- return;
1337
- }
1338
-
1339
- bp_activity_remove_all_user_data( $user_id );
1340
- }
1341
- add_action( 'delete_user', 'bp_activity_remove_all_user_data_on_delete_user' );
1342
 
1343
  /**
1344
  * Mark all of the user's activity as spam.
@@ -1479,21 +1427,6 @@ function bp_activity_ham_all_user_data( $user_id = 0 ) {
1479
  }
1480
  add_action( 'bp_make_ham_user', 'bp_activity_ham_all_user_data' );
1481
 
1482
- /**
1483
- * Allow core components and dependent plugins to register activity actions.
1484
- *
1485
- * @since 1.2.0
1486
- */
1487
- function bp_register_activity_actions() {
1488
- /**
1489
- * Fires on bp_init to allow core components and dependent plugins to register activity actions.
1490
- *
1491
- * @since 1.2.0
1492
- */
1493
- do_action( 'bp_register_activity_actions' );
1494
- }
1495
- add_action( 'bp_init', 'bp_register_activity_actions', 8 );
1496
-
1497
  /**
1498
  * Register the activity stream actions for updates.
1499
  *
@@ -1584,11 +1517,7 @@ function bp_activity_generate_action_string( $activity ) {
1584
  * @return string $action
1585
  */
1586
  function bp_activity_format_activity_action_activity_update( $action, $activity ) {
1587
- $action = sprintf(
1588
- /* translators: %s: the activity author user link */
1589
- esc_html__( '%s posted an update', 'buddypress' ),
1590
- bp_core_get_userlink( $activity->user_id )
1591
- );
1592
 
1593
  /**
1594
  * Filters the formatted activity action update string.
@@ -1611,11 +1540,7 @@ function bp_activity_format_activity_action_activity_update( $action, $activity
1611
  * @return string $action
1612
  */
1613
  function bp_activity_format_activity_action_activity_comment( $action, $activity ) {
1614
- $action = sprintf(
1615
- /* translators: %s: the activity author user link */
1616
- esc_html__( '%s posted a new activity comment', 'buddypress' ),
1617
- bp_core_get_userlink( $activity->user_id )
1618
- );
1619
 
1620
  /**
1621
  * Filters the formatted activity action comment string.
@@ -1658,23 +1583,19 @@ function bp_activity_format_activity_action_custom_post_type_post( $action, $act
1658
  $post_url = $activity->post_url;
1659
  }
1660
 
1661
- $post_link = '<a href="' . esc_url( $post_url ) . '">' . esc_html_x( 'item', 'Default text for the post type name', 'buddypress' ) . '</a>';
1662
-
1663
  if ( is_multisite() ) {
1664
- $blog_link = '<a href="' . esc_url( $blog_url ) . '">' . esc_html( get_blog_option( $activity->item_id, 'blogname' ) ) . '</a>';
1665
 
1666
  if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_action_ms ) ) {
1667
- $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_action_ms, $user_link, esc_url( $post_url ), $blog_link );
1668
  } else {
1669
- /* translators: 1: the activity author user link. 2: the post link. 3: the blog link. */
1670
- $action = sprintf( esc_html_x( '%1$s wrote a new %2$s, on the site %3$s', 'Activity Custom Post Type post action', 'buddypress' ), $user_link, $post_link, $blog_link );
1671
  }
1672
  } else {
1673
  if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_action ) ) {
1674
  $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_action, $user_link, $post_url );
1675
  } else {
1676
- /* translators: 1: the activity author user link. 2: the post link. */
1677
- $action = sprintf( esc_html_x( '%1$s wrote a new %2$s', 'Activity Custom Post Type post action', 'buddypress' ), $user_link, $post_link );
1678
  }
1679
  }
1680
 
@@ -1712,7 +1633,6 @@ function bp_activity_format_activity_action_custom_post_type_comment( $action, $
1712
  }
1713
 
1714
  $user_link = bp_core_get_userlink( $activity->user_id );
1715
- $post_link = '<a href="' . esc_url( $activity->primary_link ) . '">' . esc_html_x( 'item', 'Default text for the post type name', 'buddypress' ) . '</a>';
1716
 
1717
  if ( is_multisite() ) {
1718
  $blog_link = '<a href="' . esc_url( get_home_url( $activity->item_id ) ) . '">' . get_blog_option( $activity->item_id, 'blogname' ) . '</a>';
@@ -1720,15 +1640,13 @@ function bp_activity_format_activity_action_custom_post_type_comment( $action, $
1720
  if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_comment_action_ms ) ) {
1721
  $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_comment_action_ms, $user_link, $activity->primary_link, $blog_link );
1722
  } else {
1723
- /* translators: 1: the activity author user link. 2: the post link. 3: the blog link. */
1724
- $action = sprintf( esc_html_x( '%1$s commented on the %2$s, on the site %3$s', 'Activity Custom Post Type comment action', 'buddypress' ), $user_link, $post_link, $blog_link );
1725
  }
1726
  } else {
1727
  if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_comment_action ) ) {
1728
  $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_comment_action, $user_link, $activity->primary_link );
1729
  } else {
1730
- /* translators: 1: the activity author user link. 2: the post link. */
1731
- $action = sprintf( esc_html_x( '%1$s commented on the %2$s', 'Activity Custom Post Type post comment action', 'buddypress' ), $user_link, $post_link );
1732
  }
1733
  }
1734
 
@@ -1774,17 +1692,17 @@ function bp_activity_get( $args = '' ) {
1774
  'max' => false, // Maximum number of results to return.
1775
  'fields' => 'all',
1776
  'page' => 1, // Page 1 without a per_page will result in no pagination.
1777
- 'per_page' => false, // results per page.
1778
- 'sort' => 'DESC', // sort ASC or DESC.
1779
  'display_comments' => false, // False for no comments. 'stream' for within stream display, 'threaded' for below each activity item.
1780
 
1781
- 'search_terms' => false, // Pass search terms as a string.
1782
- 'meta_query' => false, // Filter by activity meta. See WP_Meta_Query for format.
1783
  'date_query' => false, // Filter by date. See first parameter of WP_Date_Query for format.
1784
  'filter_query' => false,
1785
  'show_hidden' => false, // Show activity items that are hidden site-wide?
1786
  'exclude' => false, // Comma-separated list of activity IDs to exclude.
1787
- 'in' => false, // Comma-separated list or array of activity IDs to which you.
1788
  // want to limit the query.
1789
  'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'.
1790
  'update_meta_cache' => true,
@@ -1797,7 +1715,7 @@ function bp_activity_get( $args = '' ) {
1797
  * 'user_id' => false, // User ID to filter on.
1798
  * 'object' => false, // Object to filter on e.g. groups, profile, status, friends.
1799
  * 'action' => false, // Action to filter on e.g. activity_update, profile_updated.
1800
- * 'primary_id' => false, // Object ID to filter on e.g. a group_id or blog_id etc.
1801
  * 'secondary_id' => false, // Secondary object ID to filter on e.g. a post_id.
1802
  * );
1803
  */
@@ -1860,7 +1778,7 @@ function bp_activity_get_specific( $args = '' ) {
1860
  'page' => 1, // Page 1 without a per_page will result in no pagination.
1861
  'per_page' => false, // Results per page.
1862
  'show_hidden' => true, // When fetching specific items, show all.
1863
- 'sort' => 'DESC', // Sort ASC or DESC.
1864
  'spam' => 'ham_only', // Retrieve items marked as spam.
1865
  'update_meta_cache' => true,
1866
  ), 'activity_get_specific' );
@@ -1933,8 +1851,8 @@ function bp_activity_add( $args = '' ) {
1933
 
1934
  $r = bp_parse_args( $args, array(
1935
  'id' => false, // Pass an existing activity ID to update an existing entry.
1936
- 'action' => '', // The activity action - e.g. "Jon Doe posted an update".
1937
- 'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!".
1938
  'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent.
1939
  'type' => false, // The activity type e.g. activity_update, profile_updated.
1940
  'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink).
@@ -1995,12 +1913,10 @@ function bp_activity_add( $args = '' ) {
1995
  * Fires at the end of the execution of adding a new activity item, before returning the new activity item ID.
1996
  *
1997
  * @since 1.1.0
1998
- * @since 4.0.0 Added the `$activity_id` parameter.
1999
  *
2000
- * @param array $r Array of parsed arguments for the activity item being added.
2001
- * @param int $activity_id The id of the activity item being added.
2002
  */
2003
- do_action( 'bp_activity_add', $r, $activity->id );
2004
 
2005
  return $activity->id;
2006
  }
@@ -2370,20 +2286,20 @@ function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
2370
  * @return null|WP_Error|bool|int The ID of the activity on success. False on error.
2371
  */
2372
  function bp_activity_post_type_comment( $comment_id = 0, $is_approved = true, $activity_post_object = null ) {
2373
- // Get the users comment.
2374
  $post_type_comment = get_comment( $comment_id );
2375
 
2376
- // Don't record activity if the comment hasn't been approved.
2377
  if ( empty( $is_approved ) ) {
2378
  return false;
2379
  }
2380
 
2381
- // Don't record activity if no email address has been included.
2382
  if ( empty( $post_type_comment->comment_author_email ) ) {
2383
  return false;
2384
  }
2385
 
2386
- // Don't record activity if the comment has already been marked as spam.
2387
  if ( 'spam' === $is_approved ) {
2388
  return false;
2389
  }
@@ -2391,18 +2307,18 @@ function bp_activity_post_type_comment( $comment_id = 0, $is_approved = true, $a
2391
  // Get the user by the comment author email.
2392
  $user = get_user_by( 'email', $post_type_comment->comment_author_email );
2393
 
2394
- // If user isn't registered, don't record activity.
2395
  if ( empty( $user ) ) {
2396
  return false;
2397
  }
2398
 
2399
- // Get the user_id.
2400
  $user_id = (int) $user->ID;
2401
 
2402
- // Get blog and post data.
2403
  $blog_id = get_current_blog_id();
2404
 
2405
- // Get the post.
2406
  $post_type_comment->post = get_post( $post_type_comment->comment_post_ID );
2407
 
2408
  if ( ! is_a( $post_type_comment->post, 'WP_Post' ) ) {
@@ -2418,25 +2334,25 @@ function bp_activity_post_type_comment( $comment_id = 0, $is_approved = true, $a
2418
  */
2419
  $is_post_status_not_allowed = (bool) apply_filters( 'bp_activity_post_type_is_post_status_allowed', 'publish' !== $post_type_comment->post->post_status || ! empty( $post_type_comment->post->post_password ) );
2420
 
2421
- // If this is a password protected post, or not a public post don't record the comment.
2422
  if ( $is_post_status_not_allowed ) {
2423
  return false;
2424
  }
2425
 
2426
- // Set post type.
2427
  $post_type = $post_type_comment->post->post_type;
2428
 
2429
  if ( empty( $activity_post_object ) ) {
2430
  // Get the post type tracking args.
2431
  $activity_post_object = bp_activity_get_post_type_tracking_args( $post_type );
2432
 
2433
- // Bail if the activity type does not exist.
2434
  if ( empty( $activity_post_object->comments_tracking->action_id ) ) {
2435
  return false;
2436
  }
2437
  }
2438
 
2439
- // Set the $activity_comment_object.
2440
  $activity_comment_object = $activity_post_object->comments_tracking;
2441
 
2442
  /**
@@ -2575,13 +2491,13 @@ function bp_activity_post_type_remove_comment( $comment_id = 0, $activity_post_o
2575
  // Get the post type tracking args.
2576
  $activity_post_object = bp_activity_get_post_type_tracking_args( $post_type );
2577
 
2578
- // Bail if the activity type does not exist.
2579
  if ( empty( $activity_post_object->comments_tracking->action_id ) ) {
2580
  return false;
2581
  }
2582
  }
2583
 
2584
- // Set the $activity_comment_object.
2585
  $activity_comment_object = $activity_post_object->comments_tracking;
2586
 
2587
  if ( empty( $activity_comment_object->action_id ) ) {
@@ -2713,12 +2629,10 @@ function bp_activity_new_comment( $args = '' ) {
2713
  * Filters the content of a new comment.
2714
  *
2715
  * @since 1.2.0
2716
- * @since 3.0.0 Added $context parameter to disambiguate from bp_get_activity_comment_content().
2717
  *
2718
- * @param string $r Content for the newly posted comment.
2719
- * @param string $context This filter's context ("new").
2720
  */
2721
- $comment_content = apply_filters( 'bp_activity_comment_content', $r['content'], 'new' );
2722
 
2723
  // Insert the activity comment.
2724
  $comment_id = bp_activity_add( array(
@@ -3175,64 +3089,6 @@ function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
3175
  return apply_filters_ref_array( 'bp_activity_get_permalink', array( $link, &$activity_obj ) );
3176
  }
3177
 
3178
- /**
3179
- * Can a user see a particular activity item?
3180
- *
3181
- * @since 3.0.0
3182
- *
3183
- * @param BP_Activity_Activity $activity Activity object.
3184
- * @param integer $user_id User ID.
3185
- * @return boolean True on success, false on failure.
3186
- */
3187
- function bp_activity_user_can_read( $activity, $user_id = 0 ) {
3188
- $retval = true;
3189
-
3190
- // Fallback.
3191
- if ( empty( $user_id ) ) {
3192
- $user_id = bp_loggedin_user_id();
3193
- }
3194
-
3195
- // If activity is from a group, do extra cap checks.
3196
- if ( bp_is_active( 'groups' ) && buddypress()->groups->id === $activity->component ) {
3197
- // Check to see if the user has access to the activity's parent group.
3198
- $group = groups_get_group( $activity->item_id );
3199
- if ( $group ) {
3200
- // For logged-in user, we can check against the 'user_has_access' prop.
3201
- if ( bp_loggedin_user_id() === $user_id ) {
3202
- $retval = $group->user_has_access;
3203
-
3204
- // Manually check status.
3205
- } elseif ( 'private' === $group->status || 'hidden' === $group->status ) {
3206
- // Only group members that are not banned can view.
3207
- if ( ! groups_is_user_member( $user_id, $activity->item_id ) || groups_is_user_banned( $user_id, $activity->item_id ) ) {
3208
- $retval = false;
3209
- }
3210
- }
3211
- }
3212
- }
3213
-
3214
- // Spammed items are not visible to the public.
3215
- if ( $activity->is_spam ) {
3216
- $retval = false;
3217
- }
3218
-
3219
- // Site moderators can view anything.
3220
- if ( bp_current_user_can( 'bp_moderate' ) ) {
3221
- $retval = true;
3222
- }
3223
-
3224
- /**
3225
- * Filters whether the current user has access to an activity item.
3226
- *
3227
- * @since 3.0.0
3228
- *
3229
- * @param bool $retval Return value.
3230
- * @param int $user_id Current user ID.
3231
- * @param BP_Activity_Activity $activity Activity object.
3232
- */
3233
- return apply_filters( 'bp_activity_user_can_read', $retval, $user_id, $activity );
3234
- }
3235
-
3236
  /**
3237
  * Hide a user's activity.
3238
  *
@@ -3412,7 +3268,7 @@ function bp_activity_create_summary( $content, $activity ) {
3412
  // Embeds must be subtracted from the paragraph count.
3413
  if ( ! empty( $media['has']['embeds'] ) ) {
3414
  $has_embeds = $media['has']['embeds'] > 0;
3415
- $para_count -= $media['has']['embeds'];
3416
  }
3417
 
3418
  $extracted_media = array();
@@ -3489,8 +3345,7 @@ function bp_activity_create_summary( $content, $activity ) {
3489
  if ( $use_media_type === 'embeds' ) {
3490
  $summary .= PHP_EOL . PHP_EOL . $extracted_media['url'];
3491
  } elseif ( $use_media_type === 'images' ) {
3492
- $extracted_media_url = isset( $extracted_media['url'] ) ? $extracted_media['url'] : '';
3493
- $summary .= sprintf( ' <img src="%s">', esc_url( $extracted_media_url ) );
3494
  } elseif ( in_array( $use_media_type, array( 'audio', 'videos' ), true ) ) {
3495
  $summary .= PHP_EOL . PHP_EOL . $extracted_media['original']; // Full shortcode.
3496
  }
@@ -3994,341 +3849,3 @@ function bp_activity_do_heartbeat() {
3994
  */
3995
  return (bool) apply_filters( 'bp_activity_do_heartbeat', $retval );
3996
  }
3997
-
3998
- /**
3999
- * Detect a change in post type status, and initiate an activity update if necessary.
4000
- *
4001
- * @since 2.2.0
4002
- *
4003
- * @todo Support untrashing better.
4004
- *
4005
- * @param string $new_status New status for the post.
4006
- * @param string $old_status Old status for the post.
4007
- * @param object $post Post data.
4008
- */
4009
- function bp_activity_catch_transition_post_type_status( $new_status, $old_status, $post ) {
4010
- if ( ! post_type_supports( $post->post_type, 'buddypress-activity' ) ) {
4011
- return;
4012
- }
4013
-
4014
- // This is an edit.
4015
- if ( $new_status === $old_status ) {
4016
- // An edit of an existing post should update the existing activity item.
4017
- if ( $new_status == 'publish' ) {
4018
- $edit = bp_activity_post_type_update( $post );
4019
-
4020
- // Post was never recorded into activity stream, so record it now!
4021
- if ( null === $edit ) {
4022
- bp_activity_post_type_publish( $post->ID, $post );
4023
- }
4024
-
4025
- // Allow plugins to eventually deal with other post statuses.
4026
- } else {
4027
- /**
4028
- * Fires when editing the post and the new status is not 'publish'.
4029
- *
4030
- * This is a variable filter that is dependent on the post type
4031
- * being untrashed.
4032
- *
4033
- * @since 2.5.0
4034
- *
4035
- * @param WP_Post $post Post data.
4036
- * @param string $new_status New status for the post.
4037
- * @param string $old_status Old status for the post.
4038
- */
4039
- do_action( 'bp_activity_post_type_edit_' . $post->post_type, $post, $new_status, $old_status );
4040
- }
4041
-
4042
- return;
4043
- }
4044
-
4045
- // Publishing a previously unpublished post.
4046
- if ( 'publish' === $new_status ) {
4047
- // Untrashing the post type - nothing here yet.
4048
- if ( 'trash' == $old_status ) {
4049
-
4050
- /**
4051
- * Fires if untrashing post in a post type.
4052
- *
4053
- * This is a variable filter that is dependent on the post type
4054
- * being untrashed.
4055
- *
4056
- * @since 2.2.0
4057
- *
4058
- * @param WP_Post $post Post data.
4059
- */
4060
- do_action( 'bp_activity_post_type_untrash_' . $post->post_type, $post );
4061
- } else {
4062
- // Record the post.
4063
- bp_activity_post_type_publish( $post->ID, $post );
4064
- }
4065
-
4066
- // Unpublishing a previously published post.
4067
- } elseif ( 'publish' === $old_status ) {
4068
- // Some form of pending status - only remove the activity entry.
4069
- bp_activity_post_type_unpublish( $post->ID, $post );
4070
-
4071
- // For any other cases, allow plugins to eventually deal with it.
4072
- } else {
4073
- /**
4074
- * Fires when the old and the new post status are not 'publish'.
4075
- *
4076
- * This is a variable filter that is dependent on the post type
4077
- * being untrashed.
4078
- *
4079
- * @since 2.5.0
4080
- *
4081
- * @param WP_Post $post Post data.
4082
- * @param string $new_status New status for the post.
4083
- * @param string $old_status Old status for the post.
4084
- */
4085
- do_action( 'bp_activity_post_type_transition_status_' . $post->post_type, $post, $new_status, $old_status );
4086
- }
4087
- }
4088
- add_action( 'transition_post_status', 'bp_activity_catch_transition_post_type_status', 10, 3 );
4089
-
4090
- /**
4091
- * When a post type comment status transition occurs, update the relevant activity's status.
4092
- *
4093
- * @since 2.5.0
4094
- *
4095
- * @param string $new_status New comment status.
4096
- * @param string $old_status Previous comment status.
4097
- * @param WP_Comment $comment Comment data.
4098
- */
4099
- function bp_activity_transition_post_type_comment_status( $new_status, $old_status, $comment ) {
4100
- $post_type = get_post_type( $comment->comment_post_ID );
4101
- if ( ! $post_type ) {
4102
- return;
4103
- }
4104
-
4105
- // Get the post type tracking args.
4106
- $activity_post_object = bp_activity_get_post_type_tracking_args( $post_type );
4107
-
4108
- // Bail if the activity type does not exist.
4109
- if ( empty( $activity_post_object->comments_tracking->action_id ) ) {
4110
- return false;
4111
-
4112
- // Set the $activity_comment_object.
4113
- } else {
4114
- $activity_comment_object = $activity_post_object->comments_tracking;
4115
- }
4116
-
4117
- // Init an empty activity ID.
4118
- $activity_id = 0;
4119
-
4120
- /**
4121
- * Activity currently doesn't have any concept of a trash, or an unapproved/approved state.
4122
- *
4123
- * If a blog comment transitions to a "delete" or "hold" status, delete the activity item.
4124
- * If a blog comment transitions to trashed, or spammed, mark the activity as spam.
4125
- * If a blog comment transitions to approved (and the activity exists), mark the activity as ham.
4126
- * If a blog comment transitions to unapproved (and the activity exists), mark the activity as spam.
4127
- * Otherwise, record the comment into the activity stream.
4128
- */
4129
-
4130
- // This clause handles delete/hold.
4131
- if ( in_array( $new_status, array( 'delete', 'hold' ) ) ) {
4132
- return bp_activity_post_type_remove_comment( $comment->comment_ID, $activity_post_object );
4133
-
4134
- // These clauses handle trash, spam, and un-spams.
4135
- } elseif ( in_array( $new_status, array( 'trash', 'spam', 'unapproved' ) ) ) {
4136
- $action = 'spam_activity';
4137
- } elseif ( 'approved' == $new_status ) {
4138
- $action = 'ham_activity';
4139
- }
4140
-
4141
- // Get the activity.
4142
- if ( bp_disable_blogforum_comments() ) {
4143
- $activity_id = bp_activity_get_activity_id( array(
4144
- 'component' => $activity_comment_object->component_id,
4145
- 'item_id' => get_current_blog_id(),
4146
- 'secondary_item_id' => $comment->comment_ID,
4147
- 'type' => $activity_comment_object->action_id,
4148
- ) );
4149
- } else {
4150
- $activity_id = get_comment_meta( $comment->comment_ID, 'bp_activity_comment_id', true );
4151
- }
4152
-
4153
- /**
4154
- * Leave a chance to plugins to manage activity comments differently.
4155
- *
4156
- * @since 2.5.0
4157
- *
4158
- * @param bool $value True to override BuddyPress management.
4159
- * @param string $post_type The post type name.
4160
- * @param int $activity_id The post type activity (0 if not found).
4161
- * @param string $new_status The new status of the post type comment.
4162
- * @param string $old_status The old status of the post type comment.
4163
- * @param WP_Comment $comment Comment data.
4164
- */
4165
- if ( true === apply_filters( 'bp_activity_pre_transition_post_type_comment_status', false, $post_type, $activity_id, $new_status, $old_status, $comment ) ) {
4166
- return false;
4167
- }
4168
-
4169
- // Check activity item exists.
4170
- if ( empty( $activity_id ) ) {
4171
- // If no activity exists, but the comment has been approved, record it into the activity table.
4172
- if ( 'approved' == $new_status ) {
4173
- return bp_activity_post_type_comment( $comment->comment_ID, true, $activity_post_object );
4174
- }
4175
-
4176
- return;
4177
- }
4178
-
4179
- // Create an activity object.
4180
- $activity = new BP_Activity_Activity( $activity_id );
4181
- if ( empty( $activity->component ) ) {
4182
- return;
4183
- }
4184
-
4185
- // Spam/ham the activity if it's not already in that state.
4186
- if ( 'spam_activity' === $action && ! $activity->is_spam ) {
4187
- bp_activity_mark_as_spam( $activity );
4188
- } elseif ( 'ham_activity' == $action) {
4189
- bp_activity_mark_as_ham( $activity );
4190
- }
4191
-
4192
- // Add "new_post_type_comment" to the allowed activity types, so that the activity's Akismet history is generated.
4193
- $post_type_comment_action = $activity_comment_object->action_id;
4194
- $comment_akismet_history = function ( $activity_types ) use ( $post_type_comment_action ) {
4195
- $activity_types[] = $post_type_comment_action;
4196
-
4197
- return $activity_types;
4198
- };
4199
- add_filter( 'bp_akismet_get_activity_types', $comment_akismet_history );
4200
-
4201
- // Make sure the activity change won't edit the comment if sync is on.
4202
- remove_action( 'bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20 );
4203
-
4204
- // Save the updated activity.
4205
- $activity->save();
4206
-
4207
- // Restore the action.
4208
- add_action( 'bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20 );
4209
-
4210
- // Remove the dynamic permitting of the "new_blog_comment" activity type so we don't break anything.
4211
- remove_filter( 'bp_akismet_get_activity_types', $comment_akismet_history );
4212
- }
4213
- add_action( 'transition_comment_status', 'bp_activity_transition_post_type_comment_status', 10, 3 );
4214
-
4215
- /**
4216
- * Finds and exports personal data associated with an email address from the Activity tables.
4217
- *
4218
- * @since 4.0.0
4219
- *
4220
- * @param string $email_address The user's email address.
4221
- * @param int $page Batch number.
4222
- * @return array An array of personal data.
4223
- */
4224
- function bp_activity_personal_data_exporter( $email_address, $page ) {
4225
- $number = 50;
4226
-
4227
- $email_address = trim( $email_address );
4228
-
4229
- $data_to_export = array();
4230
-
4231
- $user = get_user_by( 'email', $email_address );
4232
-
4233
- if ( ! $user ) {
4234
- return array(
4235
- 'data' => array(),
4236
- 'done' => true,
4237
- );
4238
- }
4239
-
4240
- $activities = bp_activity_get( array(
4241
- 'display_comments' => 'stream',
4242
- 'per_page' => $number,
4243
- 'page' => $page,
4244
- 'show_hidden' => true,
4245
- 'filter' => array(
4246
- 'user_id' => $user->ID,
4247
- ),
4248
- ) );
4249
-
4250
- $user_data_to_export = array();
4251
- $activity_actions = bp_activity_get_actions();
4252
-
4253
- foreach ( $activities['activities'] as $activity ) {
4254
- if ( ! empty( $activity_actions->{$activity->component}->{$activity->type}['format_callback'] ) ) {
4255
- $description = call_user_func( $activity_actions->{$activity->component}->{$activity->type}['format_callback'], '', $activity );
4256
- } elseif ( ! empty( $activity->action ) ) {
4257
- $description = $activity->action;
4258
- } else {
4259
- $description = $activity->type;
4260
- }
4261
-
4262
- $item_data = array(
4263
- array(
4264
- 'name' => __( 'Activity Date', 'buddypress' ),
4265
- 'value' => $activity->date_recorded,
4266
- ),
4267
- array(
4268
- 'name' => __( 'Activity Description', 'buddypress' ),
4269
- 'value' => $description,
4270
- ),
4271
- array(
4272
- 'name' => __( 'Activity URL', 'buddypress' ),
4273
- 'value' => bp_activity_get_permalink( $activity->id, $activity ),
4274
- ),
4275
- );
4276
-
4277
- if ( ! empty( $activity->content ) ) {
4278
- $item_data[] = array(
4279
- 'name' => __( 'Activity Content', 'buddypress' ),
4280
- 'value' => $activity->content,
4281
- );
4282
- }
4283
-
4284
- /**
4285
- * Filters the data associated with an activity item when assembled for a WP personal data export.
4286
- *
4287
- * Plugins that register activity types whose `action` string doesn't adequately
4288
- * describe the activity item for the purposes of data export may filter the activity
4289
- * item data here.
4290
- *
4291
- * @since 4.0.0
4292
- *
4293
- * @param array $item_data Array of data describing the activity item.
4294
- * @param BP_Activity_Activity $activity Activity item.
4295
- */
4296
- $item_data = apply_filters( 'bp_activity_personal_data_export_item_data', $item_data, $activity );
4297
-
4298
- $data_to_export[] = array(
4299
- 'group_id' => 'bp_activity',
4300
- 'group_label' => __( 'Activity', 'buddypress' ),
4301
- 'item_id' => "bp-activity-{$activity->id}",
4302
- 'data' => $item_data,
4303
- );
4304
- }
4305
-
4306
- // Tell core if we have more items to process.
4307
- $done = count( $activities['activities'] ) < $number;
4308
-
4309
- return array(
4310
- 'data' => $data_to_export,
4311
- 'done' => $done,
4312
- );
4313
- }
4314
-
4315
- /**
4316
- * Checks whether an activity feed is enabled.
4317
- *
4318
- * @since 8.0.0
4319
- *
4320
- * @param string $feed_id The feed identifier. Possible values are:
4321
- * 'sitewide', 'personal', 'friends', 'mygroups', 'mentions', 'favorites'.
4322
- */
4323
- function bp_activity_is_feed_enable( $feed_id = '' ) {
4324
- /**
4325
- * Filters if BuddyPress should consider feeds enabled. If disabled, it will return early.
4326
- *
4327
- * @since 1.8.0
4328
- * @since 8.0.0 Adds the `$feed_id` parameter.
4329
- *
4330
- * @param bool $value Defaults to true aka feeds are enabled.
4331
- * @param string $feed_id The feed identifier.
4332
- */
4333
- return (bool) apply_filters( 'bp_activity_enable_feeds', true, $feed_id );
4334
- }
20
  * @return bool True if activity directory page is found, otherwise false.
21
  */
22
  function bp_activity_has_directory() {
23
+ return (bool) !empty( buddypress()->pages->activity->id );
24
  }
25
 
26
  /**
522
  $post_type_activity->new_post_type_action_ms = $post_type_object->labels->bp_activity_new_post_ms;
523
  }
524
 
525
+ // If the post type supports comments and has a comment action id, build the comments tracking args
526
  if ( $post_type_support_comments && ! empty( $post_type_activity->comment_action_id ) ) {
527
+ // Init a new container for the activity type for comments
528
  $post_type_activity->comments_tracking = new stdClass();
529
 
530
+ // Build the activity type for comments
531
  $post_type_activity->comments_tracking->component_id = $post_type_activity->component_id;
532
  $post_type_activity->comments_tracking->action_id = $post_type_activity->comment_action_id;
533
 
597
  $track_post_type = bp_activity_get_post_type_tracking_args( $post_type );
598
 
599
  if ( ! empty( $track_post_type ) ) {
600
+ // Set the post type comments tracking args
601
  if ( ! empty( $track_post_type->comments_tracking->action_id ) ) {
602
+ // Used to check support for comment tracking by activity type (new_post_type_comment)
603
  $track_post_type->comments_tracking->comments_tracking = true;
604
 
605
  // Used to be able to find the post type this activity type is associated to.
607
 
608
  $post_types_tracking_args[ $track_post_type->comments_tracking->action_id ] = $track_post_type->comments_tracking;
609
 
610
+ // Used to check support for comment tracking by activity type (new_post_type)
611
  $track_post_type->comments_tracking = true;
612
  }
613
 
650
  * eg. 'new_blog_post' and 'new_blog_comment' will both return true.
651
  */
652
  case 'post-type-comment-tracking' :
653
+ // Set the activity track global if not set yet
654
  if ( empty( $bp->activity->track ) ) {
655
  $bp->activity->track = bp_activity_get_post_types_tracking_args();
656
  }
726
 
727
  $bp = buddypress();
728
 
729
+ // Set the activity track global if not set yet
730
  if ( empty( $bp->activity->track ) ) {
731
  $bp->activity->track = bp_activity_get_post_types_tracking_args();
732
  }
748
  function bp_activity_get_actions() {
749
  $bp = buddypress();
750
 
751
+ $post_types = bp_activity_get_post_types_tracking_args();
 
 
 
752
 
753
  // Create the actions for the post types, if they haven't already been created.
754
+ if ( ! empty( $post_types ) ) {
755
+ foreach ( $post_types as $post_type ) {
756
  if ( isset( $bp->activity->actions->{$post_type->component_id}->{$post_type->action_id} ) ) {
757
  continue;
758
  }
839
  return apply_filters( 'bp_activity_get_types', $actions );
840
  }
841
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
842
  /**
843
  * Gets the current activity context.
844
  *
845
  * The "context" is the current view type, corresponding roughly to the
846
  * current component. Use this context to determine which activity actions
847
+ * should be whitelisted for the filter dropdown.
848
  *
849
  * @since 2.8.0
850
  *
937
  */
938
  function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
939
 
940
+ // Favorite activity stream items are for logged in users only.
941
+ if ( ! is_user_logged_in() ) {
942
+ return false;
943
+ }
944
+
945
  // Fallback to logged in user if no user_id is passed.
946
  if ( empty( $user_id ) ) {
947
  $user_id = bp_loggedin_user_id();
1011
  */
1012
  function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
1013
 
1014
+ // Favorite activity stream items are for logged in users only.
1015
+ if ( ! is_user_logged_in() ) {
1016
+ return false;
1017
+ }
1018
+
1019
  // Fallback to logged in user if no user_id is passed.
1020
  if ( empty( $user_id ) ) {
1021
  $user_id = bp_loggedin_user_id();
1260
  * @return bool
1261
  */
1262
  function bp_activity_remove_all_user_data( $user_id = 0 ) {
1263
+
1264
+ // Do not delete user data unless a logged in user says so.
1265
+ if ( empty( $user_id ) || ! is_user_logged_in() ) {
1266
  return false;
1267
  }
1268
 
1286
  do_action( 'bp_activity_remove_all_user_data', $user_id );
1287
  }
1288
  add_action( 'wpmu_delete_user', 'bp_activity_remove_all_user_data' );
1289
+ add_action( 'delete_user', 'bp_activity_remove_all_user_data' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1290
 
1291
  /**
1292
  * Mark all of the user's activity as spam.
1427
  }
1428
  add_action( 'bp_make_ham_user', 'bp_activity_ham_all_user_data' );
1429
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1430
  /**
1431
  * Register the activity stream actions for updates.
1432
  *
1517
  * @return string $action
1518
  */
1519
  function bp_activity_format_activity_action_activity_update( $action, $activity ) {
1520
+ $action = sprintf( __( '%s posted an update', 'buddypress' ), bp_core_get_userlink( $activity->user_id ) );
 
 
 
 
1521
 
1522
  /**
1523
  * Filters the formatted activity action update string.
1540
  * @return string $action
1541
  */
1542
  function bp_activity_format_activity_action_activity_comment( $action, $activity ) {
1543
+ $action = sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_core_get_userlink( $activity->user_id ) );
 
 
 
 
1544
 
1545
  /**
1546
  * Filters the formatted activity action comment string.
1583
  $post_url = $activity->post_url;
1584
  }
1585
 
 
 
1586
  if ( is_multisite() ) {
1587
+ $blog_link = '<a href="' . esc_url( $blog_url ) . '">' . get_blog_option( $activity->item_id, 'blogname' ) . '</a>';
1588
 
1589
  if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_action_ms ) ) {
1590
+ $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_action_ms, $user_link, $post_url, $blog_link );
1591
  } else {
1592
+ $action = sprintf( _x( '%1$s wrote a new <a href="%2$s">item</a>, on the site %3$s', 'Activity Custom Post Type post action', 'buddypress' ), $user_link, esc_url( $post_url ), $blog_link );
 
1593
  }
1594
  } else {
1595
  if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_action ) ) {
1596
  $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_action, $user_link, $post_url );
1597
  } else {
1598
+ $action = sprintf( _x( '%1$s wrote a new <a href="%2$s">item</a>', 'Activity Custom Post Type post action', 'buddypress' ), $user_link, esc_url( $post_url ) );
 
1599
  }
1600
  }
1601
 
1633
  }
1634
 
1635
  $user_link = bp_core_get_userlink( $activity->user_id );
 
1636
 
1637
  if ( is_multisite() ) {
1638
  $blog_link = '<a href="' . esc_url( get_home_url( $activity->item_id ) ) . '">' . get_blog_option( $activity->item_id, 'blogname' ) . '</a>';
1640
  if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_comment_action_ms ) ) {
1641
  $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_comment_action_ms, $user_link, $activity->primary_link, $blog_link );
1642
  } else {
1643
+ $action = sprintf( _x( '%1$s commented on the <a href="%2$s">item</a>, on the site %3$s', 'Activity Custom Post Type comment action', 'buddypress' ), $user_link, $activity->primary_link, $blog_link );
 
1644
  }
1645
  } else {
1646
  if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_comment_action ) ) {
1647
  $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_comment_action, $user_link, $activity->primary_link );
1648
  } else {
1649
+ $action = sprintf( _x( '%1$s commented on the <a href="%2$s">item</a>', 'Activity Custom Post Type post comment action', 'buddypress' ), $user_link, $activity->primary_link );
 
1650
  }
1651
  }
1652
 
1692
  'max' => false, // Maximum number of results to return.
1693
  'fields' => 'all',
1694
  'page' => 1, // Page 1 without a per_page will result in no pagination.
1695
+ 'per_page' => false, // results per page
1696
+ 'sort' => 'DESC', // sort ASC or DESC
1697
  'display_comments' => false, // False for no comments. 'stream' for within stream display, 'threaded' for below each activity item.
1698
 
1699
+ 'search_terms' => false, // Pass search terms as a string
1700
+ 'meta_query' => false, // Filter by activity meta. See WP_Meta_Query for format
1701
  'date_query' => false, // Filter by date. See first parameter of WP_Date_Query for format.
1702
  'filter_query' => false,
1703
  'show_hidden' => false, // Show activity items that are hidden site-wide?
1704
  'exclude' => false, // Comma-separated list of activity IDs to exclude.
1705
+ 'in' => false, // Comma-separated list or array of activity IDs to which you
1706
  // want to limit the query.
1707
  'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'.
1708
  'update_meta_cache' => true,
1715
  * 'user_id' => false, // User ID to filter on.
1716
  * 'object' => false, // Object to filter on e.g. groups, profile, status, friends.
1717
  * 'action' => false, // Action to filter on e.g. activity_update, profile_updated.
1718
+ * 'primary_id' => false, // Object ID to filter on e.g. a group_id or forum_id or blog_id etc.
1719
  * 'secondary_id' => false, // Secondary object ID to filter on e.g. a post_id.
1720
  * );
1721
  */
1778
  'page' => 1, // Page 1 without a per_page will result in no pagination.
1779
  'per_page' => false, // Results per page.
1780
  'show_hidden' => true, // When fetching specific items, show all.
1781
+ 'sort' => 'DESC', // Sort ASC or DESC
1782
  'spam' => 'ham_only', // Retrieve items marked as spam.
1783
  'update_meta_cache' => true,
1784
  ), 'activity_get_specific' );
1851
 
1852
  $r = bp_parse_args( $args, array(
1853
  'id' => false, // Pass an existing activity ID to update an existing entry.
1854
+ 'action' => '', // The activity action - e.g. "Jon Doe posted an update"
1855
+ 'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
1856
  'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent.
1857
  'type' => false, // The activity type e.g. activity_update, profile_updated.
1858
  'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink).
1913
  * Fires at the end of the execution of adding a new activity item, before returning the new activity item ID.
1914
  *
1915
  * @since 1.1.0
 
1916
  *
1917
+ * @param array $r Array of parsed arguments for the activity item being added.
 
1918
  */
1919
+ do_action( 'bp_activity_add', $r );
1920
 
1921
  return $activity->id;
1922
  }
2286
  * @return null|WP_Error|bool|int The ID of the activity on success. False on error.
2287
  */
2288
  function bp_activity_post_type_comment( $comment_id = 0, $is_approved = true, $activity_post_object = null ) {
2289
+ // Get the users comment
2290
  $post_type_comment = get_comment( $comment_id );
2291
 
2292
+ // Don't record activity if the comment hasn't been approved
2293
  if ( empty( $is_approved ) ) {
2294
  return false;
2295
  }
2296
 
2297
+ // Don't record activity if no email address has been included
2298
  if ( empty( $post_type_comment->comment_author_email ) ) {
2299
  return false;
2300
  }
2301
 
2302
+ // Don't record activity if the comment has already been marked as spam
2303
  if ( 'spam' === $is_approved ) {
2304
  return false;
2305
  }
2307
  // Get the user by the comment author email.
2308
  $user = get_user_by( 'email', $post_type_comment->comment_author_email );
2309
 
2310
+ // If user isn't registered, don't record activity
2311
  if ( empty( $user ) ) {
2312
  return false;
2313
  }
2314
 
2315
+ // Get the user_id
2316
  $user_id = (int) $user->ID;
2317
 
2318
+ // Get blog and post data
2319
  $blog_id = get_current_blog_id();
2320
 
2321
+ // Get the post
2322
  $post_type_comment->post = get_post( $post_type_comment->comment_post_ID );
2323
 
2324
  if ( ! is_a( $post_type_comment->post, 'WP_Post' ) ) {
2334
  */
2335
  $is_post_status_not_allowed = (bool) apply_filters( 'bp_activity_post_type_is_post_status_allowed', 'publish' !== $post_type_comment->post->post_status || ! empty( $post_type_comment->post->post_password ) );
2336
 
2337
+ // If this is a password protected post, or not a public post don't record the comment
2338
  if ( $is_post_status_not_allowed ) {
2339
  return false;
2340
  }
2341
 
2342
+ // Set post type
2343
  $post_type = $post_type_comment->post->post_type;
2344
 
2345
  if ( empty( $activity_post_object ) ) {
2346
  // Get the post type tracking args.
2347
  $activity_post_object = bp_activity_get_post_type_tracking_args( $post_type );
2348
 
2349
+ // Bail if the activity type does not exist
2350
  if ( empty( $activity_post_object->comments_tracking->action_id ) ) {
2351
  return false;
2352
  }
2353
  }
2354
 
2355
+ // Set the $activity_comment_object
2356
  $activity_comment_object = $activity_post_object->comments_tracking;
2357
 
2358
  /**
2491
  // Get the post type tracking args.
2492
  $activity_post_object = bp_activity_get_post_type_tracking_args( $post_type );
2493
 
2494
+ // Bail if the activity type does not exist
2495
  if ( empty( $activity_post_object->comments_tracking->action_id ) ) {
2496
  return false;
2497
  }
2498
  }
2499
 
2500
+ // Set the $activity_comment_object
2501
  $activity_comment_object = $activity_post_object->comments_tracking;
2502
 
2503
  if ( empty( $activity_comment_object->action_id ) ) {
2629
  * Filters the content of a new comment.
2630
  *
2631
  * @since 1.2.0
 
2632
  *
2633
+ * @param string $r Content for the newly posted comment.
 
2634
  */
2635
+ $comment_content = apply_filters( 'bp_activity_comment_content', $r['content'] );
2636
 
2637
  // Insert the activity comment.
2638
  $comment_id = bp_activity_add( array(
3089
  return apply_filters_ref_array( 'bp_activity_get_permalink', array( $link, &$activity_obj ) );
3090
  }
3091
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3092
  /**
3093
  * Hide a user's activity.
3094
  *
3268
  // Embeds must be subtracted from the paragraph count.
3269
  if ( ! empty( $media['has']['embeds'] ) ) {
3270
  $has_embeds = $media['has']['embeds'] > 0;
3271
+ $para_count -= count( $media['has']['embeds'] );
3272
  }
3273
 
3274
  $extracted_media = array();
3345
  if ( $use_media_type === 'embeds' ) {
3346
  $summary .= PHP_EOL . PHP_EOL . $extracted_media['url'];
3347
  } elseif ( $use_media_type === 'images' ) {
3348
+ $summary .= sprintf( ' <img src="%s">', esc_url( $extracted_media['url'] ) );
 
3349
  } elseif ( in_array( $use_media_type, array( 'audio', 'videos' ), true ) ) {
3350
  $summary .= PHP_EOL . PHP_EOL . $extracted_media['original']; // Full shortcode.
3351
  }
3849
  */
3850
  return (bool) apply_filters( 'bp_activity_do_heartbeat', $retval );
3851
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/bp-activity-notifications.php CHANGED
@@ -19,7 +19,7 @@ defined( 'ABSPATH' ) || exit;
19
  * @param int $item_id The activity ID.
20
  * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's ID.
21
  * @param int $total_items The total number of notifications to format.
22
- * @param string $format 'string' for notification HTML link or 'array' for separate link and text.
23
  * @param int $id Optional. The notification ID.
24
  * @return string $return Formatted @mention notification.
25
  */
@@ -34,17 +34,13 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
34
  case 'new_at_mention':
35
  $action_filter = 'at_mentions';
36
  $link = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/';
37
-
38
- /* translators: %s: the current user display name */
39
- $title = sprintf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() );
40
- $amount = 'single';
41
 
42
  if ( (int) $total_items > 1 ) {
43
- /* translators: 1: the number of activity mentions */
44
  $text = sprintf( __( 'You have %1$d new mentions', 'buddypress' ), (int) $total_items );
45
  $amount = 'multiple';
46
  } else {
47
- /* translators: 1: the user display name */
48
  $text = sprintf( __( '%1$s mentioned you', 'buddypress' ), $user_fullname );
49
  }
50
  break;
@@ -55,15 +51,11 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
55
  $amount = 'single';
56
 
57
  if ( (int) $total_items > 1 ) {
58
- $link = add_query_arg( 'type', $action, $link );
59
-
60
- /* translators: 1: the number of activity replies */
61
  $text = sprintf( __( 'You have %1$d new replies', 'buddypress' ), (int) $total_items );
62
  $amount = 'multiple';
63
  } else {
64
- $link = add_query_arg( 'rid', (int) $id, bp_activity_get_permalink( $activity_id ) );
65
-
66
- /* translators: 1: the user display name */
67
  $text = sprintf( __( '%1$s commented on one of your updates', 'buddypress' ), $user_fullname );
68
  }
69
  break;
@@ -74,16 +66,12 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
74
  $amount = 'single';
75
 
76
  if ( (int) $total_items > 1 ) {
77
- $link = add_query_arg( 'type', $action, $link );
78
-
79
- /* translators: 1: the number of activity comment replies */
80
  $text = sprintf( __( 'You have %1$d new comment replies', 'buddypress' ), (int) $total_items );
81
  $amount = 'multiple';
82
  } else {
83
- $link = add_query_arg( 'crid', (int) $id, bp_activity_get_permalink( $activity_id ) );
84
-
85
- /* translators: 1: the user display name */
86
- $text = sprintf( __( '%1$s replied to one of your activity comments', 'buddypress' ), $user_fullname );
87
  }
88
  break;
89
  }
@@ -238,10 +226,9 @@ function bp_activity_remove_screen_notifications( $user_id = 0 ) {
238
  add_action( 'bp_activity_clear_new_mentions', 'bp_activity_remove_screen_notifications', 10, 1 );
239
 
240
  /**
241
- * Mark notifications as read when a user visits an activity permalink.
242
  *
243
  * @since 2.0.0
244
- * @since 3.2.0 Marks replies to parent update and replies to an activity comment as read.
245
  *
246
  * @param BP_Activity_Activity $activity Activity object.
247
  */
@@ -252,29 +239,6 @@ function bp_activity_remove_screen_notifications_single_activity_permalink( $act
252
 
253
  // Mark as read any notifications for the current user related to this activity item.
254
  bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $activity->id, buddypress()->activity->id, 'new_at_mention' );
255
-
256
- $comment_id = 0;
257
- // For replies to a parent update.
258
- if ( ! empty( $_GET['rid'] ) ) {
259
- $comment_id = (int) $_GET['rid'];
260
-
261
- // For replies to an activity comment.
262
- } elseif ( ! empty( $_GET['crid'] ) ) {
263
- $comment_id = (int) $_GET['crid'];
264
- }
265
-
266
- // Mark individual activity reply notification as read.
267
- if ( ! empty( $comment_id ) ) {
268
- BP_Notifications_Notification::update(
269
- array(
270
- 'is_new' => false
271
- ),
272
- array(
273
- 'user_id' => bp_loggedin_user_id(),
274
- 'id' => $comment_id
275
- )
276
- );
277
- }
278
  }
279
  add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications_single_activity_permalink' );
280
 
@@ -325,7 +289,7 @@ add_action( 'bp_activity_deleted_activities', 'bp_activity_at_mention_delete_not
325
  /**
326
  * Add a notification for post comments to the post author or post commenter.
327
  *
328
- * Requires "activity stream commenting on posts and comments" to be enabled.
329
  *
330
  * @since 2.6.0
331
  *
@@ -375,80 +339,3 @@ function bp_activity_add_notification_for_synced_blog_comment( $activity_id, $po
375
  }
376
  }
377
  add_action( 'bp_blogs_comment_sync_activity_comment', 'bp_activity_add_notification_for_synced_blog_comment', 10, 4 );
378
-
379
- /**
380
- * Add activity notifications settings to the notifications settings page.
381
- *
382
- * @since 1.2.0
383
- */
384
- function bp_activity_screen_notification_settings() {
385
- if ( bp_activity_do_mentions() ) {
386
- if ( ! $mention = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_mention', true ) ) {
387
- $mention = 'yes';
388
- }
389
- }
390
-
391
- if ( ! $reply = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_reply', true ) ) {
392
- $reply = 'yes';
393
- }
394
-
395
- ?>
396
-
397
- <table class="notification-settings" id="activity-notification-settings">
398
- <thead>
399
- <tr>
400
- <th class="icon">&nbsp;</th>
401
- <th class="title"><?php _e( 'Activity', 'buddypress' ) ?></th>
402
- <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
403
- <th class="no"><?php _e( 'No', 'buddypress' )?></th>
404
- </tr>
405
- </thead>
406
-
407
- <tbody>
408
- <?php if ( bp_activity_do_mentions() ) : ?>
409
- <tr id="activity-notification-settings-mentions">
410
- <td>&nbsp;</td>
411
- <td>
412
- <?php
413
- /* translators: %s: the displayed user username */
414
- printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( bp_displayed_user_id() ) );
415
- ?>
416
- </td>
417
- <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" id="notification-activity-new-mention-yes" value="yes" <?php checked( $mention, 'yes', true ) ?>/><label for="notification-activity-new-mention-yes" class="bp-screen-reader-text"><?php
418
- /* translators: accessibility text */
419
- esc_html_e( 'Yes, send email', 'buddypress' );
420
- ?></label></td>
421
- <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" id="notification-activity-new-mention-no" value="no" <?php checked( $mention, 'no', true ) ?>/><label for="notification-activity-new-mention-no" class="bp-screen-reader-text"><?php
422
- /* translators: accessibility text */
423
- esc_html_e( 'No, do not send email', 'buddypress' );
424
- ?></label></td>
425
- </tr>
426
- <?php endif; ?>
427
-
428
- <tr id="activity-notification-settings-replies">
429
- <td>&nbsp;</td>
430
- <td><?php _e( "A member replies to an update or comment you've posted", 'buddypress' ) ?></td>
431
- <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" id="notification-activity-new-reply-yes" value="yes" <?php checked( $reply, 'yes', true ) ?>/><label for="notification-activity-new-reply-yes" class="bp-screen-reader-text"><?php
432
- /* translators: accessibility text */
433
- esc_html_e( 'Yes, send email', 'buddypress' );
434
- ?></label></td>
435
- <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" id="notification-activity-new-reply-no" value="no" <?php checked( $reply, 'no', true ) ?>/><label for="notification-activity-new-reply-no" class="bp-screen-reader-text"><?php
436
- /* translators: accessibility text */
437
- esc_html_e( 'No, do not send email', 'buddypress' );
438
- ?></label></td>
439
- </tr>
440
-
441
- <?php
442
-
443
- /**
444
- * Fires inside the closing </tbody> tag for activity screen notification settings.
445
- *
446
- * @since 1.2.0
447
- */
448
- do_action( 'bp_activity_screen_notification_settings' ) ?>
449
- </tbody>
450
- </table>
451
-
452
- <?php
453
- }
454
- add_action( 'bp_notification_settings', 'bp_activity_screen_notification_settings', 1 );
19
  * @param int $item_id The activity ID.
20
  * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's ID.
21
  * @param int $total_items The total number of notifications to format.
22
+ * @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise.
23
  * @param int $id Optional. The notification ID.
24
  * @return string $return Formatted @mention notification.
25
  */
34
  case 'new_at_mention':
35
  $action_filter = 'at_mentions';
36
  $link = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/';
37
+ $title = sprintf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() );
38
+ $amount = 'single';
 
 
39
 
40
  if ( (int) $total_items > 1 ) {
 
41
  $text = sprintf( __( 'You have %1$d new mentions', 'buddypress' ), (int) $total_items );
42
  $amount = 'multiple';
43
  } else {
 
44
  $text = sprintf( __( '%1$s mentioned you', 'buddypress' ), $user_fullname );
45
  }
46
  break;
51
  $amount = 'single';
52
 
53
  if ( (int) $total_items > 1 ) {
54
+ $link = add_query_arg( 'type', $action, $link );
 
 
55
  $text = sprintf( __( 'You have %1$d new replies', 'buddypress' ), (int) $total_items );
56
  $amount = 'multiple';
57
  } else {
58
+ $link = add_query_arg( 'nid', (int) $id, bp_activity_get_permalink( $activity_id ) );
 
 
59
  $text = sprintf( __( '%1$s commented on one of your updates', 'buddypress' ), $user_fullname );
60
  }
61
  break;
66
  $amount = 'single';
67
 
68
  if ( (int) $total_items > 1 ) {
69
+ $link = add_query_arg( 'type', $action, $link );
 
 
70
  $text = sprintf( __( 'You have %1$d new comment replies', 'buddypress' ), (int) $total_items );
71
  $amount = 'multiple';
72
  } else {
73
+ $link = add_query_arg( 'nid', (int) $id, bp_activity_get_permalink( $activity_id ) );
74
+ $text = sprintf( __( '%1$s replied to one your activity comments', 'buddypress' ), $user_fullname );
 
 
75
  }
76
  break;
77
  }
226
  add_action( 'bp_activity_clear_new_mentions', 'bp_activity_remove_screen_notifications', 10, 1 );
227
 
228
  /**
229
+ * Mark at-mention notification as read when user visits the activity with the mention.
230
  *
231
  * @since 2.0.0
 
232
  *
233
  * @param BP_Activity_Activity $activity Activity object.
234
  */
239
 
240
  // Mark as read any notifications for the current user related to this activity item.
241
  bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $activity->id, buddypress()->activity->id, 'new_at_mention' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  }
243
  add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications_single_activity_permalink' );
244
 
289
  /**
290
  * Add a notification for post comments to the post author or post commenter.
291
  *
292
+ * Requires "activity stream commenting on blog and forum posts" to be enabled.
293
  *
294
  * @since 2.6.0
295
  *
339
  }
340
  }
341
  add_action( 'bp_blogs_comment_sync_activity_comment', 'bp_activity_add_notification_for_synced_blog_comment', 10, 4 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/bp-activity-screens.php ADDED
@@ -0,0 +1,379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BuddyPress Activity Screens.
4
+ *
5
+ * The functions in this file detect, with each page load, whether an Activity
6
+ * component page is being requested. If so, it parses any necessary data from
7
+ * the URL, and tells BuddyPress to load the appropriate template.
8
+ *
9
+ * @package BuddyPress
10
+ * @subpackage ActivityScreens
11
+ * @since 1.5.0
12
+ */
13
+
14
+ // Exit if accessed directly.
15
+ defined( 'ABSPATH' ) || exit;
16
+
17
+ /**
18
+ * Load the Activity directory.
19
+ *
20
+ * @since 1.5.0
21
+ *
22
+ */
23
+ function bp_activity_screen_index() {
24
+ if ( bp_is_activity_directory() ) {
25
+ bp_update_is_directory( true, 'activity' );
26
+
27
+ /**
28
+ * Fires right before the loading of the Activity directory screen template file.
29
+ *
30
+ * @since 1.5.0
31
+ */
32
+ do_action( 'bp_activity_screen_index' );
33
+
34
+ /**
35
+ * Filters the template to load for the Activity directory screen.
36
+ *
37
+ * @since 1.5.0
38
+ *
39
+ * @param string $template Path to the activity template to load.
40
+ */
41
+ bp_core_load_template( apply_filters( 'bp_activity_screen_index', 'activity/index' ) );
42
+ }
43
+ }
44
+ add_action( 'bp_screens', 'bp_activity_screen_index' );
45
+
46
+ /**
47
+ * Load the 'My Activity' page.
48
+ *
49
+ * @since 1.0.0
50
+ *
51
+ */
52
+ function bp_activity_screen_my_activity() {
53
+
54
+ /**
55
+ * Fires right before the loading of the "My Activity" screen template file.
56
+ *
57
+ * @since 1.0.0
58
+ */
59
+ do_action( 'bp_activity_screen_my_activity' );
60
+
61
+ /**
62
+ * Filters the template to load for the "My Activity" screen.
63
+ *
64
+ * @since 1.0.0
65
+ *
66
+ * @param string $template Path to the activity template to load.
67
+ */
68
+ bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'members/single/home' ) );
69
+ }
70
+
71
+ /**
72
+ * Load the 'My Friends' activity page.
73
+ *
74
+ * @since 1.0.0
75
+ *
76
+ */
77
+ function bp_activity_screen_friends() {
78
+ if ( !bp_is_active( 'friends' ) )
79
+ return false;
80
+
81
+ bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
82
+
83
+ /**
84
+ * Fires right before the loading of the "My Friends" screen template file.
85
+ *
86
+ * @since 1.2.0
87
+ */
88
+ do_action( 'bp_activity_screen_friends' );
89
+
90
+ /**
91
+ * Filters the template to load for the "My Friends" screen.
92
+ *
93
+ * @since 1.0.0
94
+ *
95
+ * @param string $template Path to the activity template to load.
96
+ */
97
+ bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'members/single/home' ) );
98
+ }
99
+
100
+ /**
101
+ * Load the 'My Groups' activity page.
102
+ *
103
+ * @since 1.2.0
104
+ *
105
+ */
106
+ function bp_activity_screen_groups() {
107
+ if ( !bp_is_active( 'groups' ) )
108
+ return false;
109
+
110
+ bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
111
+
112
+ /**
113
+ * Fires right before the loading of the "My Groups" screen template file.
114
+ *
115
+ * @since 1.2.0
116
+ */
117
+ do_action( 'bp_activity_screen_groups' );
118
+
119
+ /**
120
+ * Filters the template to load for the "My Groups" screen.
121
+ *
122
+ * @since 1.2.0
123
+ *
124
+ * @param string $template Path to the activity template to load.
125
+ */
126
+ bp_core_load_template( apply_filters( 'bp_activity_template_groups_activity', 'members/single/home' ) );
127
+ }
128
+
129
+ /**
130
+ * Load the 'Favorites' activity page.
131
+ *
132
+ * @since 1.2.0
133
+ *
134
+ */
135
+ function bp_activity_screen_favorites() {
136
+ bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
137
+
138
+ /**
139
+ * Fires right before the loading of the "Favorites" screen template file.
140
+ *
141
+ * @since 1.2.0
142
+ */
143
+ do_action( 'bp_activity_screen_favorites' );
144
+
145
+ /**
146
+ * Filters the template to load for the "Favorites" screen.
147
+ *
148
+ * @since 1.2.0
149
+ *
150
+ * @param string $template Path to the activity template to load.
151
+ */
152
+ bp_core_load_template( apply_filters( 'bp_activity_template_favorite_activity', 'members/single/home' ) );
153
+ }
154
+
155
+ /**
156
+ * Load the 'Mentions' activity page.
157
+ *
158
+ * @since 1.2.0
159
+ *
160
+ */
161
+ function bp_activity_screen_mentions() {
162
+ bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
163
+
164
+ /**
165
+ * Fires right before the loading of the "Mentions" screen template file.
166
+ *
167
+ * @since 1.2.0
168
+ */
169
+ do_action( 'bp_activity_screen_mentions' );
170
+
171
+ /**
172
+ * Filters the template to load for the "Mentions" screen.
173
+ *
174
+ * @since 1.2.0
175
+ *
176
+ * @param string $template Path to the activity template to load.
177
+ */
178
+ bp_core_load_template( apply_filters( 'bp_activity_template_mention_activity', 'members/single/home' ) );
179
+ }
180
+
181
+ /**
182
+ * Reset the logged-in user's new mentions data when he visits his mentions screen.
183
+ *
184
+ * @since 1.5.0
185
+ *
186
+ */
187
+ function bp_activity_reset_my_new_mentions() {
188
+ if ( bp_is_my_profile() )
189
+ bp_activity_clear_new_mentions( bp_loggedin_user_id() );
190
+ }
191
+ add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' );
192
+
193
+ /**
194
+ * Load the page for a single activity item.
195
+ *
196
+ * @since 1.2.0
197
+ *
198
+ */
199
+ function bp_activity_screen_single_activity_permalink() {
200
+ $bp = buddypress();
201
+
202
+ // No displayed user or not viewing activity component.
203
+ if ( !bp_is_activity_component() )
204
+ return false;
205
+
206
+ if ( ! bp_current_action() || !is_numeric( bp_current_action() ) )
207
+ return false;
208
+
209
+ // Get the activity details.
210
+ $activity = bp_activity_get_specific( array( 'activity_ids' => bp_current_action(), 'show_hidden' => true, 'spam' => 'ham_only', ) );
211
+
212
+ // 404 if activity does not exist
213
+ if ( empty( $activity['activities'][0] ) || bp_action_variables() ) {
214
+ bp_do_404();
215
+ return;
216
+
217
+ } else {
218
+ $activity = $activity['activities'][0];
219
+ }
220
+
221
+ // Default access is true.
222
+ $has_access = true;
223
+
224
+ // If activity is from a group, do an extra cap check.
225
+ if ( isset( $bp->groups->id ) && $activity->component == $bp->groups->id ) {
226
+
227
+ // Activity is from a group, but groups is currently disabled.
228
+ if ( !bp_is_active( 'groups') ) {
229
+ bp_do_404();
230
+ return;
231
+ }
232
+
233
+ // Check to see if the group is not public, if so, check the
234
+ // user has access to see this activity.
235
+ if ( $group = groups_get_group( $activity->item_id ) ) {
236
+
237
+ // Group is not public.
238
+ if ( 'public' != $group->status ) {
239
+
240
+ // User is not a member of group.
241
+ if ( !groups_is_user_member( bp_loggedin_user_id(), $group->id ) ) {
242
+ $has_access = false;
243
+ }
244
+ }
245
+ }
246
+ }
247
+
248
+ // If activity author does not match displayed user, block access.
249
+ if ( true === $has_access && bp_displayed_user_id() !== $activity->user_id ) {
250
+ $has_access = false;
251
+ }
252
+
253
+ /**
254
+ * Filters the access permission for a single activity view.
255
+ *
256
+ * @since 1.2.0
257
+ *
258
+ * @param array $access Array holding the current $has_access value and current activity item instance.
259
+ */
260
+ $has_access = apply_filters_ref_array( 'bp_activity_permalink_access', array( $has_access, &$activity ) );
261
+
262
+ /**
263
+ * Fires before the loading of a single activity template file.
264
+ *
265
+ * @since 1.2.0
266
+ *
267
+ * @param BP_Activity_Activity $activity Object representing the current activity item being displayed.
268
+ * @param bool $has_access Whether or not the current user has access to view activity.
269
+ */
270
+ do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access );
271
+
272
+ // Access is specifically disallowed.
273
+ if ( false === $has_access ) {
274
+
275
+ // User feedback.
276
+ bp_core_add_message( __( 'You do not have access to this activity.', 'buddypress' ), 'error' );
277
+
278
+ // Redirect based on logged in status.
279
+ if ( is_user_logged_in() ) {
280
+ $url = bp_loggedin_user_domain();
281
+
282
+ } else {
283
+ $url = sprintf(
284
+ site_url( 'wp-login.php?redirect_to=%s' ),
285
+ urlencode( esc_url_raw( bp_activity_get_permalink( bp_current_action() ) ) )
286
+ );
287
+ }
288
+
289
+ bp_core_redirect( $url );
290
+ }
291
+
292
+ /**
293
+ * Filters the template to load for a single activity screen.
294
+ *
295
+ * @since 1.0.0
296
+ *
297
+ * @param string $template Path to the activity template to load.
298
+ */
299
+ bp_core_load_template( apply_filters( 'bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink' ) );
300
+ }
301
+ add_action( 'bp_screens', 'bp_activity_screen_single_activity_permalink' );
302
+
303
+ /**
304
+ * Add activity notifications settings to the notifications settings page.
305
+ *
306
+ * @since 1.2.0
307
+ *
308
+ */
309
+ function bp_activity_screen_notification_settings() {
310
+
311
+ if ( bp_activity_do_mentions() ) {
312
+ if ( ! $mention = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_mention', true ) ) {
313
+ $mention = 'yes';
314
+ }
315
+ }
316
+
317
+ if ( ! $reply = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_reply', true ) ) {
318
+ $reply = 'yes';
319
+ }
320
+
321
+ ?>
322
+
323
+ <table class="notification-settings" id="activity-notification-settings">
324
+ <thead>
325
+ <tr>
326
+ <th class="icon">&nbsp;</th>
327
+ <th class="title"><?php _e( 'Activity', 'buddypress' ) ?></th>
328
+ <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
329
+ <th class="no"><?php _e( 'No', 'buddypress' )?></th>
330
+ </tr>
331
+ </thead>
332
+
333
+ <tbody>
334
+ <?php if ( bp_activity_do_mentions() ) : ?>
335
+ <tr id="activity-notification-settings-mentions">
336
+ <td>&nbsp;</td>
337
+ <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( bp_displayed_user_id() ) ) ?></td>
338
+ <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" id="notification-activity-new-mention-yes" value="yes" <?php checked( $mention, 'yes', true ) ?>/><label for="notification-activity-new-mention-yes" class="bp-screen-reader-text"><?php
339
+ /* translators: accessibility text */
340
+ _e( 'Yes, send email', 'buddypress' );
341
+ ?></label></td>
342
+ <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" id="notification-activity-new-mention-no" value="no" <?php checked( $mention, 'no', true ) ?>/><label for="notification-activity-new-mention-no" class="bp-screen-reader-text"><?php
343
+ /* translators: accessibility text */
344
+ _e( 'No, do not send email', 'buddypress' );
345
+ ?></label></td>
346
+ </tr>
347
+ <?php endif; ?>
348
+
349
+ <tr id="activity-notification-settings-replies">
350
+ <td>&nbsp;</td>
351
+ <td><?php _e( "A member replies to an update or comment you've posted", 'buddypress' ) ?></td>
352
+ <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" id="notification-activity-new-reply-yes" value="yes" <?php checked( $reply, 'yes', true ) ?>/><label for="notification-activity-new-reply-yes" class="bp-screen-reader-text"><?php
353
+ /* translators: accessibility text */
354
+ _e( 'Yes, send email', 'buddypress' );
355
+ ?></label></td>
356
+ <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" id="notification-activity-new-reply-no" value="no" <?php checked( $reply, 'no', true ) ?>/><label for="notification-activity-new-reply-no" class="bp-screen-reader-text"><?php
357
+ /* translators: accessibility text */
358
+ _e( 'No, do not send email', 'buddypress' );
359
+ ?></label></td>
360
+ </tr>
361
+
362
+ <?php
363
+
364
+ /**
365
+ * Fires inside the closing </tbody> tag for activity screen notification settings.
366
+ *
367
+ * @since 1.2.0
368
+ */
369
+ do_action( 'bp_activity_screen_notification_settings' ) ?>
370
+ </tbody>
371
+ </table>
372
+
373
+ <?php
374
+ }
375
+ add_action( 'bp_notification_settings', 'bp_activity_screen_notification_settings', 1 );
376
+
377
+ /** Theme Compatibility *******************************************************/
378
+
379
+ new BP_Activity_Theme_Compat();
bp-activity/bp-activity-template.php CHANGED
@@ -266,8 +266,8 @@ function bp_has_activities( $args = '' ) {
266
  // Filtering
267
  'user_id' => $user_id, // user_id to filter on.
268
  'object' => $object, // Object to filter on e.g. groups, profile, status, friends.
269
- 'action' => false, // Action to filter on e.g. activity_update, profile_updated.
270
- 'primary_id' => $primary_id, // Object ID to filter on e.g. a group_id or blog_id etc.
271
  'secondary_id' => false, // Secondary object ID to filter on e.g. a post_id.
272
  'offset' => false, // Return only items >= this ID.
273
  'since' => false, // Return only items recorded since this Y-m-d H:i:s date.
@@ -452,7 +452,6 @@ function bp_activity_pagination_count() {
452
  if ( 1 == $activities_template->total_activity_count ) {
453
  $message = __( 'Viewing 1 item', 'buddypress' );
454
  } else {
455
- /* translators: 1: the from number item. 2: the to number item. 3: the total number of items. */
456
  $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s item', 'Viewing %1$s - %2$s of %3$s items', $activities_template->total_activity_count, 'buddypress' ), $from_num, $to_num, $total );
457
  }
458
 
@@ -1035,11 +1034,7 @@ function bp_activity_avatar( $args = '' ) {
1035
  $dn_default = isset( $current_activity_item->display_name ) ? $current_activity_item->display_name : '';
1036
 
1037
  // Prepend some descriptive text to alt.
1038
- $alt_default = __( 'Profile picture', 'buddypress' );
1039
- if ( ! empty( $dn_default ) ) {
1040
- /* translators: %s: member name */
1041
- $alt_default = sprintf( __( 'Profile picture of %s', 'buddypress' ), $dn_default );
1042
- }
1043
 
1044
  $defaults = array(
1045
  'alt' => $alt_default,
@@ -1187,7 +1182,6 @@ function bp_activity_secondary_avatar( $args = '' ) {
1187
  $alt = __( 'Group logo', 'buddypress' );
1188
 
1189
  if ( ! empty( $name ) ) {
1190
- /* translators: %s: the Group name */
1191
  $alt = sprintf( __( 'Group logo of %s', 'buddypress' ), $name );
1192
  }
1193
  }
@@ -1199,7 +1193,6 @@ function bp_activity_secondary_avatar( $args = '' ) {
1199
  $link = home_url();
1200
 
1201
  if ( empty( $alt ) ) {
1202
- /* translators: %s: the blog name */
1203
  $alt = sprintf( __( 'Profile picture of the author of the site %s', 'buddypress' ), get_blog_option( $item_id, 'blogname' ) );
1204
  }
1205
 
@@ -1210,7 +1203,6 @@ function bp_activity_secondary_avatar( $args = '' ) {
1210
  $link = bp_core_get_userlink( $item_id, false, true );
1211
 
1212
  if ( empty( $alt ) ) {
1213
- /* translators: %s: member name */
1214
  $alt = sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_core_get_user_displayname( $activities_template->activity->secondary_item_id ) );
1215
  }
1216
 
@@ -1222,7 +1214,6 @@ function bp_activity_secondary_avatar( $args = '' ) {
1222
  $link = bp_core_get_userlink( $item_id, false, true );
1223
 
1224
  if ( empty( $alt ) ) {
1225
- /* translators: %s: member name */
1226
  $alt = sprintf( __( 'Profile picture of %s', 'buddypress' ), $activities_template->activity->display_name );
1227
  }
1228
 
@@ -1315,7 +1306,6 @@ function bp_activity_action( $args = array() ) {
1315
  * Return the activity action.
1316
  *
1317
  * @since 1.2.0
1318
- * @since 1.7.0 Introduce function parameter, $args.
1319
  *
1320
  * @global object $activities_template {@link BP_Activity_Template}
1321
  *
@@ -1354,9 +1344,8 @@ function bp_activity_action( $args = array() ) {
1354
  * Filters the activity action after the action has been inserted as meta.
1355
  *
1356
  * @since 1.2.0
1357
- * @since 1.7.0 Now passes a 3rd parameter, $r, an array of arguments from the function.
1358
  *
1359
- * @param array $value Array containing the current action, the current activity, and the $r array passed into the function.
1360
  */
1361
  return apply_filters_ref_array( 'bp_get_activity_action', array(
1362
  $action,
@@ -1578,13 +1567,8 @@ function bp_activity_user_can_delete( $activity = false ) {
1578
  $can_delete = true;
1579
  }
1580
 
1581
- /*
1582
- * Viewing a single item, and this user is an admin of that item.
1583
- *
1584
- * Group activity items are handled separately.
1585
- * See bp_groups_filter_activity_user_can_delete().
1586
- */
1587
- if ( 'groups' !== $activity->component && bp_is_single_item() && bp_is_item_admin() ) {
1588
  $can_delete = true;
1589
  }
1590
  }
@@ -2152,12 +2136,10 @@ function bp_activity_comment_content() {
2152
  * Filters the content of the current activity comment.
2153
  *
2154
  * @since 1.2.0
2155
- * @since 3.0.0 Added $context parameter to disambiguate from bp_get_activity_comment_content().
2156
  *
2157
  * @param string $content The content of the current activity comment.
2158
- * @param string $context This filter's context ("get").
2159
  */
2160
- return apply_filters( 'bp_activity_comment_content', $content, 'get' );
2161
  }
2162
 
2163
  /**
@@ -2185,16 +2167,7 @@ function bp_activity_comment_count() {
2185
 
2186
  // Deprecated notice about $args.
2187
  if ( ! empty( $deprecated ) ) {
2188
- _deprecated_argument(
2189
- __FUNCTION__,
2190
- '1.2',
2191
- sprintf(
2192
- /* translators: 1: the name of the function. 2: the name of the file. */
2193
- __( '%1$s no longer accepts arguments. See the inline documentation at %2$s for more details.', 'buddypress' ),
2194
- __FUNCTION__,
2195
- __FILE__
2196
- )
2197
- );
2198
  }
2199
 
2200
  // Get the count using the purpose-built recursive function.
@@ -2971,7 +2944,7 @@ function bp_activity_can_comment_reply( $comment = false ) {
2971
  * @since 1.5.0
2972
  *
2973
  * @param bool $can_comment Status on if activity reply can be commented on.
2974
- * @param object $comment Current comment object being checked on.
2975
  */
2976
  return (bool) apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
2977
  }
@@ -3873,11 +3846,6 @@ function bp_activity_show_filters( $context = '' ) {
3873
  $action['key'] = 'friendship_accepted,friendship_created';
3874
  }
3875
 
3876
- // The 'activity_update' filter is already used by the Activity component.
3877
- if ( 'bp_groups_format_activity_action_group_activity_update' === $action['format_callback'] ) {
3878
- continue;
3879
- }
3880
-
3881
  $filters[ $action['key'] ] = $action['label'];
3882
  }
3883
 
266
  // Filtering
267
  'user_id' => $user_id, // user_id to filter on.
268
  'object' => $object, // Object to filter on e.g. groups, profile, status, friends.
269
+ 'action' => false, // Action to filter on e.g. activity_update, new_forum_post, profile_updated.
270
+ 'primary_id' => $primary_id, // Object ID to filter on e.g. a group_id or forum_id or blog_id etc.
271
  'secondary_id' => false, // Secondary object ID to filter on e.g. a post_id.
272
  'offset' => false, // Return only items >= this ID.
273
  'since' => false, // Return only items recorded since this Y-m-d H:i:s date.
452
  if ( 1 == $activities_template->total_activity_count ) {
453
  $message = __( 'Viewing 1 item', 'buddypress' );
454
  } else {
 
455
  $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s item', 'Viewing %1$s - %2$s of %3$s items', $activities_template->total_activity_count, 'buddypress' ), $from_num, $to_num, $total );
456
  }
457
 
1034
  $dn_default = isset( $current_activity_item->display_name ) ? $current_activity_item->display_name : '';
1035
 
1036
  // Prepend some descriptive text to alt.
1037
+ $alt_default = !empty( $dn_default ) ? sprintf( __( 'Profile picture of %s', 'buddypress' ), $dn_default ) : __( 'Profile picture', 'buddypress' );
 
 
 
 
1038
 
1039
  $defaults = array(
1040
  'alt' => $alt_default,
1182
  $alt = __( 'Group logo', 'buddypress' );
1183
 
1184
  if ( ! empty( $name ) ) {
 
1185
  $alt = sprintf( __( 'Group logo of %s', 'buddypress' ), $name );
1186
  }
1187
  }
1193
  $link = home_url();
1194
 
1195
  if ( empty( $alt ) ) {
 
1196
  $alt = sprintf( __( 'Profile picture of the author of the site %s', 'buddypress' ), get_blog_option( $item_id, 'blogname' ) );
1197
  }
1198
 
1203
  $link = bp_core_get_userlink( $item_id, false, true );
1204
 
1205
  if ( empty( $alt ) ) {
 
1206
  $alt = sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_core_get_user_displayname( $activities_template->activity->secondary_item_id ) );
1207
  }
1208
 
1214
  $link = bp_core_get_userlink( $item_id, false, true );
1215
 
1216
  if ( empty( $alt ) ) {
 
1217
  $alt = sprintf( __( 'Profile picture of %s', 'buddypress' ), $activities_template->activity->display_name );
1218
  }
1219
 
1306
  * Return the activity action.
1307
  *
1308
  * @since 1.2.0
 
1309
  *
1310
  * @global object $activities_template {@link BP_Activity_Template}
1311
  *
1344
  * Filters the activity action after the action has been inserted as meta.
1345
  *
1346
  * @since 1.2.0
 
1347
  *
1348
+ * @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
1349
  */
1350
  return apply_filters_ref_array( 'bp_get_activity_action', array(
1351
  $action,
1567
  $can_delete = true;
1568
  }
1569
 
1570
+ // Viewing a single item, and this user is an admin of that item.
1571
+ if ( bp_is_single_item() && bp_is_item_admin() ) {
 
 
 
 
 
1572
  $can_delete = true;
1573
  }
1574
  }
2136
  * Filters the content of the current activity comment.
2137
  *
2138
  * @since 1.2.0
 
2139
  *
2140
  * @param string $content The content of the current activity comment.
 
2141
  */
2142
+ return apply_filters( 'bp_activity_comment_content', $content );
2143
  }
2144
 
2145
  /**
2167
 
2168
  // Deprecated notice about $args.
2169
  if ( ! empty( $deprecated ) ) {
2170
+ _deprecated_argument( __FUNCTION__, '1.2', sprintf( __( '%1$s no longer accepts arguments. See the inline documentation at %2$s for more details.', 'buddypress' ), __FUNCTION__, __FILE__ ) );
 
 
 
 
 
 
 
 
 
2171
  }
2172
 
2173
  // Get the count using the purpose-built recursive function.
2944
  * @since 1.5.0
2945
  *
2946
  * @param bool $can_comment Status on if activity reply can be commented on.
2947
+ * @param string $comment Current comment being checked on.
2948
  */
2949
  return (bool) apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
2950
  }
3846
  $action['key'] = 'friendship_accepted,friendship_created';
3847
  }
3848
 
 
 
 
 
 
3849
  $filters[ $action['key'] ] = $action['label'];
3850
  }
3851
 
bp-activity/classes/class-bp-activity-activity.php CHANGED
@@ -268,35 +268,15 @@ class BP_Activity_Activity {
268
  return false;
269
  } else {
270
  if ( empty( $this->component ) ) {
271
- $this->errors->add( 'bp_activity_missing_component', __( 'You need to define a component parameter to insert activity.', 'buddypress' ) );
272
  } else {
273
- $this->errors->add( 'bp_activity_missing_type', __( 'You need to define a type parameter to insert activity.', 'buddypress' ) );
274
  }
275
 
276
  return $this->errors;
277
  }
278
  }
279
 
280
- /**
281
- * Use this filter to make the content of your activity required.
282
- *
283
- * @since 6.0.0
284
- *
285
- * @param bool $value True if the content of the activity type is required.
286
- * False otherwise.
287
- * @param string $type The type of the activity we are about to insert.
288
- */
289
- $type_requires_content = (bool) apply_filters( 'bp_activity_type_requires_content', $this->type === 'activity_update', $this->type );
290
- if ( $type_requires_content && ! $this->content ) {
291
- if ( 'bool' === $this->error_type ) {
292
- return false;
293
- } else {
294
- $this->errors->add( 'bp_activity_missing_content', __( 'Please enter some content to post.', 'buddypress' ) );
295
-
296
- return $this->errors;
297
- }
298
- }
299
-
300
  if ( empty( $this->primary_link ) ) {
301
  $this->primary_link = bp_loggedin_user_domain();
302
  }
@@ -380,20 +360,9 @@ class BP_Activity_Activity {
380
  public static function get( $args = array() ) {
381
  global $wpdb;
382
 
383
- $function_args = func_get_args();
384
-
385
  // Backward compatibility with old method of passing arguments.
386
- if ( !is_array( $args ) || count( $function_args ) > 1 ) {
387
- _deprecated_argument(
388
- __METHOD__,
389
- '1.6',
390
- sprintf(
391
- /* translators: 1: the name of the method. 2: the name of the file. */
392
- __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ),
393
- __METHOD__,
394
- __FILE__
395
- )
396
- );
397
 
398
  $old_args_keys = array(
399
  0 => 'max',
@@ -409,7 +378,7 @@ class BP_Activity_Activity {
409
  10 => 'spam'
410
  );
411
 
412
- $args = bp_core_parse_args_array( $old_args_keys, $function_args );
413
  }
414
 
415
  $bp = buddypress();
@@ -487,21 +456,6 @@ class BP_Activity_Activity {
487
  if ( $r['search_terms'] ) {
488
  $search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
489
  $where_conditions['search_sql'] = $wpdb->prepare( 'a.content LIKE %s', $search_terms_like );
490
-
491
- /**
492
- * Filters whether or not to include users for search parameters.
493
- *
494
- * @since 3.0.0
495
- *
496
- * @param bool $value Whether or not to include user search. Default false.
497
- */
498
- if ( apply_filters( 'bp_activity_get_include_user_search', false ) ) {
499
- $user_search = get_user_by( 'slug', $r['search_terms'] );
500
- if ( false !== $user_search ) {
501
- $user_id = $user_search->ID;
502
- $where_conditions['search_sql'] .= $wpdb->prepare( ' OR a.user_id = %d', $user_id );
503
- }
504
- }
505
  }
506
 
507
  // Sorting.
@@ -644,12 +598,12 @@ class BP_Activity_Activity {
644
  $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
645
 
646
  if ( ! empty( $page ) && ! empty( $per_page ) ) {
647
- $pag_sql = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
648
 
649
  /** This filter is documented in bp-activity/bp-activity-classes.php */
650
- $activity_sql = apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}, a.id {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql );
651
  } else {
652
- $pag_sql = '';
653
 
654
  /**
655
  * Filters the legacy MySQL query statement so plugins can alter before results are fetched.
@@ -662,21 +616,9 @@ class BP_Activity_Activity {
662
  * @param string $where_sql Final WHERE MySQL statement portion for legacy query.
663
  * @param string $sort Final sort direction for legacy query.
664
  */
665
- $activity_sql = apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}, a.id {$sort}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql );
666
- }
667
-
668
- /*
669
- * Queries that include 'last_activity' are cached separately,
670
- * since they are generally much less long-lived.
671
- */
672
- if ( preg_match( '/a\.type NOT IN \([^\)]*\'last_activity\'[^\)]*\)/', $activity_sql ) ) {
673
- $cache_group = 'bp_activity';
674
- } else {
675
- $cache_group = 'bp_activity_with_last_activity';
676
  }
677
 
678
- $activities = $wpdb->get_results( $activity_sql );
679
-
680
  // Integer casting for legacy activity query.
681
  foreach ( (array) $activities as $i => $ac ) {
682
  $activities[ $i ]->id = (int) $ac->id;
@@ -1498,8 +1440,6 @@ class BP_Activity_Activity {
1498
  public static function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
1499
  global $wpdb;
1500
 
1501
- $function_args = func_get_args();
1502
-
1503
  if ( empty( $top_level_parent_id ) ) {
1504
  $top_level_parent_id = $activity_id;
1505
  }
@@ -1547,7 +1487,7 @@ class BP_Activity_Activity {
1547
  * @param BP_Activity_Activity $value Magic method referring to currently called method.
1548
  * @param array $func_args Array of the method's argument list.
1549
  */
1550
- if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $function_args ) ) {
1551
 
1552
  /**
1553
  * Filters the MySQL prepared statement for the legacy activity query.
@@ -1572,7 +1512,6 @@ class BP_Activity_Activity {
1572
  $descendant_ids = $wpdb->get_col( $sql );
1573
  $descendants = self::get_activity_data( $descendant_ids );
1574
  $descendants = self::append_user_fullnames( $descendants );
1575
- $descendants = self::generate_action_strings( $descendants );
1576
  }
1577
 
1578
  $ref = array();
268
  return false;
269
  } else {
270
  if ( empty( $this->component ) ) {
271
+ $this->errors->add( 'bp_activity_missing_component' );
272
  } else {
273
+ $this->errors->add( 'bp_activity_missing_type' );
274
  }
275
 
276
  return $this->errors;
277
  }
278
  }
279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  if ( empty( $this->primary_link ) ) {
281
  $this->primary_link = bp_loggedin_user_domain();
282
  }
360
  public static function get( $args = array() ) {
361
  global $wpdb;
362
 
 
 
363
  // Backward compatibility with old method of passing arguments.
364
+ if ( !is_array( $args ) || func_num_args() > 1 ) {
365
+ _deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
 
 
 
 
 
 
 
 
 
366
 
367
  $old_args_keys = array(
368
  0 => 'max',
378
  10 => 'spam'
379
  );
380
 
381
+ $args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
382
  }
383
 
384
  $bp = buddypress();
456
  if ( $r['search_terms'] ) {
457
  $search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
458
  $where_conditions['search_sql'] = $wpdb->prepare( 'a.content LIKE %s', $search_terms_like );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
459
  }
460
 
461
  // Sorting.
598
  $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
599
 
600
  if ( ! empty( $page ) && ! empty( $per_page ) ) {
601
+ $pag_sql = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
602
 
603
  /** This filter is documented in bp-activity/bp-activity-classes.php */
604
+ $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}, a.id {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
605
  } else {
606
+ $pag_sql = '';
607
 
608
  /**
609
  * Filters the legacy MySQL query statement so plugins can alter before results are fetched.
616
  * @param string $where_sql Final WHERE MySQL statement portion for legacy query.
617
  * @param string $sort Final sort direction for legacy query.
618
  */
619
+ $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}, a.id {$sort}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
 
 
 
 
 
 
 
 
 
 
620
  }
621
 
 
 
622
  // Integer casting for legacy activity query.
623
  foreach ( (array) $activities as $i => $ac ) {
624
  $activities[ $i ]->id = (int) $ac->id;
1440
  public static function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
1441
  global $wpdb;
1442
 
 
 
1443
  if ( empty( $top_level_parent_id ) ) {
1444
  $top_level_parent_id = $activity_id;
1445
  }
1487
  * @param BP_Activity_Activity $value Magic method referring to currently called method.
1488
  * @param array $func_args Array of the method's argument list.
1489
  */
1490
+ if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, func_get_args() ) ) {
1491
 
1492
  /**
1493
  * Filters the MySQL prepared statement for the legacy activity query.
1512
  $descendant_ids = $wpdb->get_col( $sql );
1513
  $descendants = self::get_activity_data( $descendant_ids );
1514
  $descendants = self::append_user_fullnames( $descendants );
 
1515
  }
1516
 
1517
  $ref = array();
bp-activity/classes/class-bp-activity-component.php CHANGED
@@ -51,12 +51,13 @@ class BP_Activity_Component extends BP_Component {
51
  // Files to include.
52
  $includes = array(
53
  'cssjs',
 
 
54
  'filters',
55
  'adminbar',
56
  'template',
57
  'functions',
58
- 'cache',
59
- 'blocks',
60
  );
61
 
62
  // Notifications support.
@@ -72,8 +73,8 @@ class BP_Activity_Component extends BP_Component {
72
  $includes[] = 'akismet';
73
  }
74
 
75
- // Embeds.
76
- if ( bp_is_active( $this->id, 'embeds' ) ) {
77
  $includes[] = 'embeds';
78
  }
79
 
@@ -84,83 +85,6 @@ class BP_Activity_Component extends BP_Component {
84
  parent::includes( $includes );
85
  }
86
 
87
- /**
88
- * Late includes method.
89
- *
90
- * Only load up certain code when on specific pages.
91
- *
92
- * @since 3.0.0
93
- */
94
- public function late_includes() {
95
- // Bail if PHPUnit is running.
96
- if ( defined( 'BP_TESTS_DIR' ) ) {
97
- return;
98
- }
99
-
100
- /*
101
- * Load activity action and screen code if PHPUnit isn't running.
102
- *
103
- * For PHPUnit, we load these files in tests/phpunit/includes/install.php.
104
- */
105
- if ( bp_is_current_component( 'activity' ) ) {
106
- // Authenticated actions - Only fires when JS is disabled.
107
- if ( is_user_logged_in() &&
108
- in_array( bp_current_action(), array( 'delete', 'spam', 'post', 'reply', 'favorite', 'unfavorite' ), true )
109
- ) {
110
- require $this->path . 'bp-activity/actions/' . bp_current_action() . '.php';
111
- }
112
-
113
- // RSS feeds.
114
- if ( bp_is_current_action( 'feed' ) || bp_is_action_variable( 'feed', 0 ) ) {
115
- require $this->path . 'bp-activity/actions/feeds.php';
116
- }
117
-
118
- // Screens - Directory.
119
- if ( bp_is_activity_directory() ) {
120
- require $this->path . 'bp-activity/screens/directory.php';
121
- }
122
-
123
- // Screens - User main nav.
124
- if ( bp_is_user() ) {
125
- require $this->path . 'bp-activity/screens/just-me.php';
126
- }
127
-
128
- /**
129
- * Screens - User secondary nav.
130
- *
131
- * For these specific actions, slugs can be customized using `BP_{COMPONENT}_SLUGS`.
132
- * As a result, we need to map filenames with slugs.
133
- */
134
- $filenames = array(
135
- 'favorites' => 'favorites',
136
- 'mentions' => 'mentions',
137
- );
138
-
139
- if ( bp_is_active( 'friends' ) ) {
140
- $filenames[bp_get_friends_slug()] = 'friends';
141
- }
142
-
143
- if ( bp_is_active( 'groups' ) ) {
144
- $filenames[bp_get_groups_slug()] = 'groups';
145
- }
146
-
147
- // The slug is the current action requested.
148
- $slug = bp_current_action();
149
-
150
- if ( bp_is_user() && isset( $filenames[ $slug ] ) ) {
151
- require $this->path . 'bp-activity/screens/' . $filenames[ $slug ] . '.php';
152
- }
153
-
154
- // Screens - Single permalink.
155
- if ( bp_is_current_action( 'p' ) || is_numeric( bp_current_action() ) ) {
156
- require $this->path . 'bp-activity/screens/permalink.php';
157
- }
158
-
159
- // Theme compatibility.
160
- new BP_Activity_Theme_Compat();
161
- }
162
- }
163
-
164
  /**
165
  * Set up component global variables.
166
  *
@@ -207,11 +131,6 @@ class BP_Activity_Component extends BP_Component {
207
  'search_string' => __( 'Search Activity...', 'buddypress' ),
208
  'global_tables' => $global_tables,
209
  'meta_tables' => $meta_tables,
210
- 'block_globals' => array(
211
- 'bp/latest-activities' => array(
212
- 'widget_classnames' => array( 'wp-block-bp-latest-activities', 'buddypress' ),
213
- )
214
- ),
215
  );
216
 
217
  parent::setup_globals( $args );
@@ -437,11 +356,7 @@ class BP_Activity_Component extends BP_Component {
437
  $bp->bp_options_avatar = bp_core_fetch_avatar( array(
438
  'item_id' => bp_displayed_user_id(),
439
  'type' => 'thumb',
440
- 'alt' => sprintf(
441
- /* translators: %s: member name */
442
- __( 'Profile picture of %s', 'buddypress' ),
443
- bp_get_displayed_user_fullname()
444
- ),
445
  ) );
446
  $bp->bp_options_title = bp_get_displayed_user_fullname();
447
  }
@@ -466,84 +381,4 @@ class BP_Activity_Component extends BP_Component {
466
 
467
  parent::setup_cache_groups();
468
  }
469
-
470
- /**
471
- * Init the BP REST API.
472
- *
473
- * @since 5.0.0
474
- *
475
- * @param array $controllers Optional. See BP_Component::rest_api_init() for
476
- * description.
477
- */
478
- public function rest_api_init( $controllers = array() ) {
479
- parent::rest_api_init( array( 'BP_REST_Activity_Endpoint' ) );
480
- }
481
-
482
- /**
483
- * Register the BP Activity Blocks.
484
- *
485
- * @since 7.0.0
486
- *
487
- * @param array $blocks Optional. See BP_Component::blocks_init() for
488
- * description.
489
- */
490
- public function blocks_init( $blocks = array() ) {
491
- $blocks = array(
492
- 'bp/latest-activities' => array(
493
- 'name' => 'bp/latest-activities',
494
- 'editor_script' => 'bp-latest-activities-block',
495
- 'editor_script_url' => plugins_url( 'js/blocks/latest-activities.js', dirname( __FILE__ ) ),
496
- 'editor_script_deps' => array(
497
- 'wp-blocks',
498
- 'wp-element',
499
- 'wp-components',
500
- 'wp-i18n',
501
- 'wp-block-editor',
502
- 'bp-block-data',
503
- 'bp-block-components',
504
- ),
505
- 'style' => 'bp-latest-activities-block',
506
- 'style_url' => plugins_url( 'css/blocks/latest-activities.css', dirname( __FILE__ ) ),
507
- 'attributes' => array(
508
- 'title' => array(
509
- 'type' => 'string',
510
- 'default' => __( 'Latest updates', 'buddypress' ),
511
- ),
512
- 'maxActivities' => array(
513
- 'type' => 'number',
514
- 'default' => 5,
515
- ),
516
- 'type' => array(
517
- 'type' => 'array',
518
- 'default' => array( 'activity_update' ),
519
- ),
520
- 'postId' => array(
521
- 'type' => 'number',
522
- 'default' => 0,
523
- ),
524
- ),
525
- 'render_callback' => 'bp_activity_render_latest_activities_block',
526
- ),
527
- );
528
-
529
- if ( bp_is_active( $this->id, 'embeds' ) ) {
530
- $blocks['bp/embed-activity'] = array(
531
- 'name' => 'bp/embed-activity',
532
- 'editor_script' => 'bp-embed-activity-block',
533
- 'editor_script_url' => plugins_url( 'js/blocks/embed-activity.js', dirname( __FILE__ ) ),
534
- 'editor_script_deps' => array(
535
- 'wp-blocks',
536
- 'wp-element',
537
- 'wp-i18n',
538
- 'wp-components',
539
- 'wp-block-editor',
540
- 'wp-data',
541
- 'wp-compose',
542
- 'bp-block-data',
543
- ),
544
- );
545
- }
546
-
547
- parent::blocks_init( $blocks );
548
- }
549
  }
51
  // Files to include.
52
  $includes = array(
53
  'cssjs',
54
+ 'actions',
55
+ 'screens',
56
  'filters',
57
  'adminbar',
58
  'template',
59
  'functions',
60
+ 'cache'
 
61
  );
62
 
63
  // Notifications support.
73
  $includes[] = 'akismet';
74
  }
75
 
76
+ // Embeds - only applicable for WP 4.5+
77
+ if ( version_compare( $GLOBALS['wp_version'], '4.5', '>=' ) && bp_is_active( $this->id, 'embeds' ) ) {
78
  $includes[] = 'embeds';
79
  }
80
 
85
  parent::includes( $includes );
86
  }
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  /**
89
  * Set up component global variables.
90
  *
131
  'search_string' => __( 'Search Activity...', 'buddypress' ),
132
  'global_tables' => $global_tables,
133
  'meta_tables' => $meta_tables,
 
 
 
 
 
134
  );
135
 
136
  parent::setup_globals( $args );
356
  $bp->bp_options_avatar = bp_core_fetch_avatar( array(
357
  'item_id' => bp_displayed_user_id(),
358
  'type' => 'thumb',
359
+ 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() )
 
 
 
 
360
  ) );
361
  $bp->bp_options_title = bp_get_displayed_user_fullname();
362
  }
381
 
382
  parent::setup_cache_groups();
383
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  }
bp-activity/classes/class-bp-activity-feed.php CHANGED
@@ -87,97 +87,94 @@ class BP_Activity_Feed {
87
  * @param array $args Optional.
88
  */
89
  public function __construct( $args = array() ) {
90
- $feed_id = '';
91
 
92
- if ( isset( $args['id'] ) ) {
93
- $feed_id = sanitize_key( $args['id'] );
94
- }
95
-
96
- if ( false === bp_activity_is_feed_enable( $feed_id ) ) {
 
 
 
97
  global $wp_query;
98
 
99
  // Set feed flag to false.
100
  $wp_query->is_feed = false;
101
 
102
- $this->data = array(
103
- 'enabled' => false,
104
- );
105
- } else {
106
- // Setup data.
107
- $this->data = wp_parse_args( $args, array(
108
- // Internal identifier for the RSS feed - should be alphanumeric only.
109
- 'id' => '',
110
-
111
- // RSS title - should be plain-text.
112
- 'title' => '',
113
-
114
- // Relevant link for the RSS feed.
115
- 'link' => '',
116
-
117
- // RSS description - should be plain-text.
118
- 'description' => '',
119
-
120
- // Time-to-live - number of minutes to cache the data before an aggregator
121
- // requests it again. This is only acknowledged if the RSS client supports it
122
- //
123
- // See: http://www.rssboard.org/rss-profile#element-channel-ttl.
124
- // See: http://www.kbcafe.com/rss/rssfeedstate.html#ttl.
125
- 'ttl' => '30',
126
-
127
- // Syndication module - similar to ttl, but not really supported by RSS
128
- // clients
129
- //
130
- // See: http://web.resource.org/rss/1.0/modules/syndication/#description.
131
- // See: http://www.kbcafe.com/rss/rssfeedstate.html#syndicationmodule.
132
- 'update_period' => 'hourly',
133
- 'update_frequency' => 2,
134
-
135
- // Number of items to display.
136
- 'max' => 50,
137
-
138
- // Activity arguments passed to bp_has_activities().
139
- 'activity_args' => array(),
140
-
141
- // The activity feed is enabled.
142
- 'enabled' => false,
143
- ) );
144
-
145
- /**
146
- * Fires before the feed is setup so plugins can modify.
147
- *
148
- * @since 1.8.0
149
- *
150
- * @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
151
- */
152
- do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) );
153
-
154
- // Setup class properties.
155
- $this->setup_properties();
156
-
157
- // Check if id is valid.
158
- if ( empty( $this->id ) ) {
159
- _doing_it_wrong( 'BP_Activity_Feed', __( "RSS feed 'id' must be defined", 'buddypress' ), 'BP 1.8' );
160
- return false;
161
- }
162
 
163
- /**
164
- * Fires after the feed is setup so plugins can modify.
165
- *
166
- * @since 1.8.0
167
- *
168
- * @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
169
- */
170
- do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) );
171
 
172
- // Setup feed hooks.
173
- $this->setup_hooks();
 
 
 
 
174
 
175
- // Output the feed.
176
- $this->output();
 
 
 
 
 
 
 
 
 
 
 
 
177
 
178
- // Kill the rest of the output.
179
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  }
182
 
183
  /** SETUP ****************************************************************/
87
  * @param array $args Optional.
88
  */
89
  public function __construct( $args = array() ) {
 
90
 
91
+ /**
92
+ * Filters if BuddyPress should consider feeds enabled. If disabled, it will return early.
93
+ *
94
+ * @since 1.8.0
95
+ *
96
+ * @param bool true Default true aka feeds are enabled.
97
+ */
98
+ if ( false === (bool) apply_filters( 'bp_activity_enable_feeds', true ) ) {
99
  global $wp_query;
100
 
101
  // Set feed flag to false.
102
  $wp_query->is_feed = false;
103
 
104
+ return false;
105
+ }
106
+
107
+ // Setup data.
108
+ $this->data = wp_parse_args( $args, array(
109
+ // Internal identifier for the RSS feed - should be alphanumeric only.
110
+ 'id' => '',
111
+
112
+ // RSS title - should be plain-text.
113
+ 'title' => '',
114
+
115
+ // Relevant link for the RSS feed.
116
+ 'link' => '',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
+ // RSS description - should be plain-text.
119
+ 'description' => '',
 
 
 
 
 
 
120
 
121
+ // Time-to-live - number of minutes to cache the data before an aggregator
122
+ // requests it again. This is only acknowledged if the RSS client supports it
123
+ //
124
+ // See: http://www.rssboard.org/rss-profile#element-channel-ttl.
125
+ // See: http://www.kbcafe.com/rss/rssfeedstate.html#ttl.
126
+ 'ttl' => '30',
127
 
128
+ // Syndication module - similar to ttl, but not really supported by RSS
129
+ // clients
130
+ //
131
+ // See: http://web.resource.org/rss/1.0/modules/syndication/#description.
132
+ // See: http://www.kbcafe.com/rss/rssfeedstate.html#syndicationmodule.
133
+ 'update_period' => 'hourly',
134
+ 'update_frequency' => 2,
135
+
136
+ // Number of items to display.
137
+ 'max' => 50,
138
+
139
+ // Activity arguments passed to bp_has_activities().
140
+ 'activity_args' => array()
141
+ ) );
142
 
143
+ /**
144
+ * Fires before the feed is setup so plugins can modify.
145
+ *
146
+ * @since 1.8.0
147
+ *
148
+ * @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
149
+ */
150
+ do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) );
151
+
152
+ // Setup class properties.
153
+ $this->setup_properties();
154
+
155
+ // Check if id is valid.
156
+ if ( empty( $this->id ) ) {
157
+ _doing_it_wrong( 'BP_Activity_Feed', __( "RSS feed 'id' must be defined", 'buddypress' ), 'BP 1.8' );
158
+ return false;
159
  }
160
+
161
+ /**
162
+ * Fires after the feed is setup so plugins can modify.
163
+ *
164
+ * @since 1.8.0
165
+ *
166
+ * @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
167
+ */
168
+ do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) );
169
+
170
+ // Setup feed hooks.
171
+ $this->setup_hooks();
172
+
173
+ // Output the feed.
174
+ $this->output();
175
+
176
+ // Kill the rest of the output.
177
+ die();
178
  }
179
 
180
  /** SETUP ****************************************************************/
bp-activity/classes/class-bp-activity-list-table.php CHANGED
@@ -38,14 +38,6 @@ class BP_Activity_List_Table extends WP_List_Table {
38
  */
39
  public $spam_count = 0;
40
 
41
- /**
42
- * Total number of activities.
43
- *
44
- * @since 6.0.0
45
- * @var int $all_count
46
- */
47
- public $all_count = 0;
48
-
49
  /**
50
  * Store activity-to-user-ID mappings for use in the In Response To column.
51
  *
@@ -55,7 +47,7 @@ class BP_Activity_List_Table extends WP_List_Table {
55
  protected $activity_user_id = array();
56
 
57
  /**
58
- * If users can comment on post and comment activity items.
59
  *
60
  * @link https://buddypress.trac.wordpress.org/ticket/6277
61
  *
@@ -71,7 +63,7 @@ class BP_Activity_List_Table extends WP_List_Table {
71
  */
72
  public function __construct() {
73
 
74
- // See if activity commenting is enabled for post/comment activity items.
75
  $this->disable_blogforum_comments = bp_disable_blogforum_comments();
76
 
77
  // Define singular and plural labels, as well as whether we support AJAX.
@@ -105,18 +97,23 @@ class BP_Activity_List_Table extends WP_List_Table {
105
  $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) );
106
 
107
  // Check if we're on the "Spam" view.
108
- if ( ! empty( $_REQUEST['activity_status'] ) && 'spam' === $_REQUEST['activity_status'] ) {
109
  $spam = 'spam_only';
110
  $this->view = 'spam';
111
  }
112
 
 
 
 
 
 
 
 
 
113
  // Filter.
114
  if ( ! empty( $_REQUEST['activity_type'] ) ) {
115
  $filter = array( 'action' => $_REQUEST['activity_type'] );
116
 
117
- // Set the view as a filtered one.
118
- $this->view = 'filtered';
119
-
120
  /**
121
  * Filter here to override the filter with a filter query
122
  *
@@ -127,30 +124,22 @@ class BP_Activity_List_Table extends WP_List_Table {
127
  $has_filter_query = apply_filters( 'bp_activity_list_table_filter_activity_type_items', $filter );
128
 
129
  if ( ! empty( $has_filter_query['filter_query'] ) ) {
130
- // Reset the filter.
131
  $filter = array();
132
 
133
- // And use the filter query instead.
134
  $filter_query = $has_filter_query['filter_query'];
135
  }
136
  }
137
 
138
  // Are we doing a search?
139
- if ( ! empty( $_REQUEST['s'] ) ) {
140
  $search_terms = $_REQUEST['s'];
141
 
142
- // Set the view as a search request.
143
- $this->view = 'search';
144
- }
145
-
146
  // Check if user has clicked on a specific activity (if so, fetch only that, and any related, activity).
147
- if ( ! empty( $_REQUEST['aid'] ) ) {
148
  $include_id = (int) $_REQUEST['aid'];
149
 
150
- // Set the view as a single activity.
151
- $this->view = 'single';
152
- }
153
-
154
  // Get the spam total (ignoring any search query or filter).
155
  $spams = bp_activity_get( array(
156
  'display_comments' => 'stream',
@@ -171,6 +160,7 @@ class BP_Activity_List_Table extends WP_List_Table {
171
  'search_terms' => $search_terms,
172
  'filter_query' => $filter_query,
173
  'show_hidden' => true,
 
174
  'spam' => $spam,
175
  'count_total' => 'count_query',
176
  ) );
@@ -194,7 +184,7 @@ class BP_Activity_List_Table extends WP_List_Table {
194
  }
195
 
196
  // Set raw data to display.
197
- $this->items = $new_activities;
198
 
199
  // Store information needed for handling table pagination.
200
  $this->set_pagination_args( array(
@@ -205,25 +195,6 @@ class BP_Activity_List_Table extends WP_List_Table {
205
 
206
  // Don't truncate activity items; bp_activity_truncate_entry() needs to be used inside a BP_Activity_Template loop.
207
  remove_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
208
-
209
- // Set the Total number of activities.
210
- if ( 'all' === $this->view ) {
211
- $this->all_count = (int) $activities['total'];
212
-
213
- // Only perform a query if not on the main list view.
214
- } elseif ( 'single' !== $this->view ) {
215
- $count_activities = bp_activity_get(
216
- array(
217
- 'fields' => 'ids',
218
- 'show_hidden' => true,
219
- 'count_total' => 'count_query',
220
- )
221
- );
222
-
223
- if ( $count_activities['total'] ) {
224
- $this->all_count = (int) $count_activities['total'];
225
- }
226
- }
227
  }
228
 
229
  /**
@@ -338,34 +309,12 @@ class BP_Activity_List_Table extends WP_List_Table {
338
 
339
  <h2 class="screen-reader-text"><?php
340
  /* translators: accessibility text */
341
- esc_html_e( 'Filter activities list', 'buddypress' );
342
  ?></h2>
343
 
344
  <ul class="subsubsub">
345
- <li class="all">
346
- <a href="<?php echo esc_url( $url_base ); ?>" class="<?php if ( 'all' === $this->view ) echo 'current'; ?>">
347
- <?php printf(
348
- /* translators: %s is the placeholder for the count html tag `<span class="count"/>` */
349
- esc_html__( 'All %s', 'buddypress' ),
350
- sprintf(
351
- '<span class="count">(%s)</span>',
352
- number_format_i18n( $this->all_count )
353
- )
354
- ); ?>
355
- </a> |
356
- </li>
357
- <li class="spam">
358
- <a href="<?php echo esc_url( add_query_arg( array( 'activity_status' => 'spam' ), $url_base ) ); ?>" class="<?php if ( 'spam' === $this->view ) echo 'current'; ?>">
359
- <?php printf(
360
- /* translators: %s is the placeholder for the count html tag `<span class="count"/>` */
361
- esc_html__( 'Spam %s', 'buddypress' ),
362
- sprintf(
363
- '<span class="count">(%s)</span>',
364
- number_format_i18n( $this->spam_count )
365
- )
366
- ); ?>
367
- </a>
368
- </li>
369
 
370
  <?php
371
 
@@ -389,7 +338,11 @@ class BP_Activity_List_Table extends WP_List_Table {
389
  *
390
  * @return array Key/value pairs for the bulk actions dropdown.
391
  */
392
- public function get_bulk_actions() {
 
 
 
 
393
 
394
  /**
395
  * Filters the default bulk actions so plugins can add custom actions.
@@ -398,11 +351,7 @@ class BP_Activity_List_Table extends WP_List_Table {
398
  *
399
  * @param array $actions Default available actions for bulk operations.
400
  */
401
- return apply_filters( 'bp_activity_list_table_get_bulk_actions', array(
402
- 'bulk_spam' => __( 'Mark as Spam', 'buddypress' ),
403
- 'bulk_ham' => __( 'Not Spam', 'buddypress' ),
404
- 'bulk_delete' => __( 'Delete Permanently', 'buddypress' ),
405
- ) );
406
  }
407
 
408
  /**
@@ -415,7 +364,6 @@ class BP_Activity_List_Table extends WP_List_Table {
415
  * @return array The columns to appear in the Activity list table.
416
  */
417
  function get_columns() {
418
-
419
  /**
420
  * Filters the titles for the columns for the activity list table.
421
  *
@@ -425,7 +373,7 @@ class BP_Activity_List_Table extends WP_List_Table {
425
  */
426
  return apply_filters( 'bp_activity_list_table_get_columns', array(
427
  'cb' => '<input name type="checkbox" />',
428
- 'author' => _x( 'Author', 'Admin SWA column header', 'buddypress' ),
429
  'comment' => _x( 'Activity', 'Admin SWA column header', 'buddypress' ),
430
  'action' => _x( 'Action', 'Admin SWA column header', 'buddypress' ),
431
  'response' => _x( 'In Response To', 'Admin SWA column header', 'buddypress' ),
@@ -435,20 +383,20 @@ class BP_Activity_List_Table extends WP_List_Table {
435
  /**
436
  * Get the column names for sortable columns.
437
  *
 
 
438
  * @since 1.6.0
 
 
439
  *
440
  * @return array The columns that can be sorted on the Activity screen.
441
  */
442
- public function get_sortable_columns() {
 
443
 
444
- /**
445
- * Filters the column names for the sortable columns.
446
- *
447
- * @since 5.0.0
448
- *
449
- * @param array $value Array of column names.
450
- */
451
- return apply_filters( 'bp_activity_list_table_get_sortable_columns', array() );
452
  }
453
 
454
  /**
@@ -486,11 +434,6 @@ class BP_Activity_List_Table extends WP_List_Table {
486
  $component = 'xprofile';
487
  }
488
 
489
- // The 'activity_update' filter is already used by the Activity component.
490
- if ( isset( $actions->activity_update ) && 'bp_groups_format_activity_action_group_activity_update' === $actions->activity_update['format_callback'] ) {
491
- unset( $actions->activity_update );
492
- }
493
-
494
  if ( bp_is_active( $component ) ) {
495
  if ( $component === 'xprofile' ) {
496
  $component_name = buddypress()->profile->name;
@@ -511,7 +454,7 @@ class BP_Activity_List_Table extends WP_List_Table {
511
  <?php
512
 
513
  // Skip the incorrectly named pre-1.6 action.
514
- if ( 'friends_register_activity_action' !== $action_key ) : ?>
515
 
516
  <option value="<?php echo esc_attr( $action_key ); ?>" <?php selected( $action_key, $selected ); ?>><?php echo esc_html( $action_values[ 'value' ] ); ?></option>
517
 
@@ -604,7 +547,6 @@ class BP_Activity_List_Table extends WP_List_Table {
604
  if ( isset( $actions[ $item['type'] ] ) ) {
605
  echo $actions[ $item['type'] ];
606
  } else {
607
- /* translators: %s: the name of the activity type */
608
  printf( __( 'Unregistered action - %s', 'buddypress' ), $item['type'] );
609
  }
610
  }
@@ -648,24 +590,23 @@ class BP_Activity_List_Table extends WP_List_Table {
648
  // Reply - JavaScript only; implemented by AJAX.
649
  if ( 'spam' != $item_status ) {
650
  if ( $this->can_comment( $item ) ) {
651
- $actions['reply'] = sprintf( '<a href="#" class="reply hide-if-no-js">%s</a>', esc_html__( 'Reply', 'buddypress' ) );
652
  } else {
653
- $actions['reply'] = sprintf( '<span class="form-input-tip">%s</span>', esc_html__( 'Replies disabled', 'buddypress' ) );
654
  }
655
 
656
  // Edit.
657
- $actions['edit'] = sprintf( '<a href="%s">%s</a>', esc_url( $edit_url ), esc_html__( 'Edit', 'buddypress' ) );
658
  }
659
 
660
  // Spam/unspam.
661
- if ( 'spam' == $item_status ) {
662
- $actions['unspam'] = sprintf( '<a href="%s">%s</a>', esc_url( $ham_url ), esc_html__( 'Not Spam', 'buddypress' ) );
663
- } else {
664
- $actions['spam'] = sprintf( '<a href="%s">%s</a>', esc_url( $spam_url ), esc_html__( 'Spam', 'buddypress' ) );
665
- }
666
 
667
  // Delete.
668
- $actions['delete'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $delete_url ), esc_html__( 'Delete Permanently', 'buddypress' ) );
669
 
670
  // Start timestamp.
671
  echo '<div class="submitted-on">';
@@ -698,20 +639,21 @@ class BP_Activity_List_Table extends WP_List_Table {
698
  // End timestamp.
699
  echo '</div>';
700
 
701
- $activity = new BP_Activity_Activity( $item['id'] );
702
-
703
  // Get activity content - if not set, use the action.
704
  if ( ! empty( $item['content'] ) ) {
 
 
705
  /** This filter is documented in bp-activity/bp-activity-template.php */
706
  $content = apply_filters_ref_array( 'bp_get_activity_content_body', array( $item['content'], &$activity ) );
707
  } else {
708
- // Emulate bp_get_activity_action().
709
- $r = array(
710
- 'no_timestamp' => false,
711
- );
712
-
713
- /** This filter is documented in bp-activity/bp-activity-template.php */
714
- $content = apply_filters_ref_array( 'bp_get_activity_action', array( $item['action'], &$activity, $r ) );
 
715
  }
716
 
717
  /**
38
  */
39
  public $spam_count = 0;
40
 
 
 
 
 
 
 
 
 
41
  /**
42
  * Store activity-to-user-ID mappings for use in the In Response To column.
43
  *
47
  protected $activity_user_id = array();
48
 
49
  /**
50
+ * If users can comment on blog & forum activity items.
51
  *
52
  * @link https://buddypress.trac.wordpress.org/ticket/6277
53
  *
63
  */
64
  public function __construct() {
65
 
66
+ // See if activity commenting is enabled for blog / forum activity items.
67
  $this->disable_blogforum_comments = bp_disable_blogforum_comments();
68
 
69
  // Define singular and plural labels, as well as whether we support AJAX.
97
  $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) );
98
 
99
  // Check if we're on the "Spam" view.
100
+ if ( !empty( $_REQUEST['activity_status'] ) && 'spam' == $_REQUEST['activity_status'] ) {
101
  $spam = 'spam_only';
102
  $this->view = 'spam';
103
  }
104
 
105
+ // Sort order.
106
+ if ( !empty( $_REQUEST['order'] ) && 'desc' != $_REQUEST['order'] )
107
+ $sort = 'ASC';
108
+
109
+ // Order by.
110
+ /*if ( !empty( $_REQUEST['orderby'] ) ) {
111
+ }*/
112
+
113
  // Filter.
114
  if ( ! empty( $_REQUEST['activity_type'] ) ) {
115
  $filter = array( 'action' => $_REQUEST['activity_type'] );
116
 
 
 
 
117
  /**
118
  * Filter here to override the filter with a filter query
119
  *
124
  $has_filter_query = apply_filters( 'bp_activity_list_table_filter_activity_type_items', $filter );
125
 
126
  if ( ! empty( $has_filter_query['filter_query'] ) ) {
127
+ // Reset the filter
128
  $filter = array();
129
 
130
+ // And use the filter query instead
131
  $filter_query = $has_filter_query['filter_query'];
132
  }
133
  }
134
 
135
  // Are we doing a search?
136
+ if ( !empty( $_REQUEST['s'] ) )
137
  $search_terms = $_REQUEST['s'];
138
 
 
 
 
 
139
  // Check if user has clicked on a specific activity (if so, fetch only that, and any related, activity).
140
+ if ( !empty( $_REQUEST['aid'] ) )
141
  $include_id = (int) $_REQUEST['aid'];
142
 
 
 
 
 
143
  // Get the spam total (ignoring any search query or filter).
144
  $spams = bp_activity_get( array(
145
  'display_comments' => 'stream',
160
  'search_terms' => $search_terms,
161
  'filter_query' => $filter_query,
162
  'show_hidden' => true,
163
+ // 'sort' => $sort,
164
  'spam' => $spam,
165
  'count_total' => 'count_query',
166
  ) );
184
  }
185
 
186
  // Set raw data to display.
187
+ $this->items = $new_activities;
188
 
189
  // Store information needed for handling table pagination.
190
  $this->set_pagination_args( array(
195
 
196
  // Don't truncate activity items; bp_activity_truncate_entry() needs to be used inside a BP_Activity_Template loop.
197
  remove_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  }
199
 
200
  /**
309
 
310
  <h2 class="screen-reader-text"><?php
311
  /* translators: accessibility text */
312
+ _e( 'Filter activities list', 'buddypress' );
313
  ?></h2>
314
 
315
  <ul class="subsubsub">
316
+ <li class="all"><a href="<?php echo esc_url( $url_base ); ?>" class="<?php if ( 'spam' != $this->view ) echo 'current'; ?>"><?php _e( 'All', 'buddypress' ); ?></a> |</li>
317
+ <li class="spam"><a href="<?php echo esc_url( add_query_arg( array( 'activity_status' => 'spam' ), $url_base ) ); ?>" class="<?php if ( 'spam' == $this->view ) echo 'current'; ?>"><?php printf( __( 'Spam <span class="count">(%s)</span>', 'buddypress' ), number_format_i18n( $this->spam_count ) ); ?></a></li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
 
319
  <?php
320
 
338
  *
339
  * @return array Key/value pairs for the bulk actions dropdown.
340
  */
341
+ function get_bulk_actions() {
342
+ $actions = array();
343
+ $actions['bulk_spam'] = __( 'Mark as Spam', 'buddypress' );
344
+ $actions['bulk_ham'] = __( 'Not Spam', 'buddypress' );
345
+ $actions['bulk_delete'] = __( 'Delete Permanently', 'buddypress' );
346
 
347
  /**
348
  * Filters the default bulk actions so plugins can add custom actions.
351
  *
352
  * @param array $actions Default available actions for bulk operations.
353
  */
354
+ return apply_filters( 'bp_activity_list_table_get_bulk_actions', $actions );
 
 
 
 
355
  }
356
 
357
  /**
364
  * @return array The columns to appear in the Activity list table.
365
  */
366
  function get_columns() {
 
367
  /**
368
  * Filters the titles for the columns for the activity list table.
369
  *
373
  */
374
  return apply_filters( 'bp_activity_list_table_get_columns', array(
375
  'cb' => '<input name type="checkbox" />',
376
+ 'author' => _x('Author', 'Admin SWA column header', 'buddypress' ),
377
  'comment' => _x( 'Activity', 'Admin SWA column header', 'buddypress' ),
378
  'action' => _x( 'Action', 'Admin SWA column header', 'buddypress' ),
379
  'response' => _x( 'In Response To', 'Admin SWA column header', 'buddypress' ),
383
  /**
384
  * Get the column names for sortable columns.
385
  *
386
+ * Currently, returns an empty array (no columns are sortable).
387
+ *
388
  * @since 1.6.0
389
+ * @todo For this to work, BP_Activity_Activity::get() needs updating
390
+ * to support ordering by specific fields.
391
  *
392
  * @return array The columns that can be sorted on the Activity screen.
393
  */
394
+ function get_sortable_columns() {
395
+ return array();
396
 
397
+ /*return array(
398
+ 'author' => array( 'activity_author', false ), // Intentionally not using "=>"
399
+ );*/
 
 
 
 
 
400
  }
401
 
402
  /**
434
  $component = 'xprofile';
435
  }
436
 
 
 
 
 
 
437
  if ( bp_is_active( $component ) ) {
438
  if ( $component === 'xprofile' ) {
439
  $component_name = buddypress()->profile->name;
454
  <?php
455
 
456
  // Skip the incorrectly named pre-1.6 action.
457
+ if ( 'friends_register_activity_action' !== $action_key ) : ?>
458
 
459
  <option value="<?php echo esc_attr( $action_key ); ?>" <?php selected( $action_key, $selected ); ?>><?php echo esc_html( $action_values[ 'value' ] ); ?></option>
460
 
547
  if ( isset( $actions[ $item['type'] ] ) ) {
548
  echo $actions[ $item['type'] ];
549
  } else {
 
550
  printf( __( 'Unregistered action - %s', 'buddypress' ), $item['type'] );
551
  }
552
  }
590
  // Reply - JavaScript only; implemented by AJAX.
591
  if ( 'spam' != $item_status ) {
592
  if ( $this->can_comment( $item ) ) {
593
+ $actions['reply'] = sprintf( '<a href="#" class="reply hide-if-no-js">%s</a>', __( 'Reply', 'buddypress' ) );
594
  } else {
595
+ $actions['reply'] = sprintf( '<span class="form-input-tip">%s</span>', __( 'Replies disabled', 'buddypress' ) );
596
  }
597
 
598
  // Edit.
599
+ $actions['edit'] = sprintf( '<a href="%s">%s</a>', $edit_url, __( 'Edit', 'buddypress' ) );
600
  }
601
 
602
  // Spam/unspam.
603
+ if ( 'spam' == $item_status )
604
+ $actions['unspam'] = sprintf( '<a href="%s">%s</a>', $ham_url, __( 'Not Spam', 'buddypress' ) );
605
+ else
606
+ $actions['spam'] = sprintf( '<a href="%s">%s</a>', $spam_url, __( 'Spam', 'buddypress' ) );
 
607
 
608
  // Delete.
609
+ $actions['delete'] = sprintf( '<a href="%s" onclick="%s">%s</a>', $delete_url, "javascript:return confirm('" . esc_js( __( 'Are you sure?', 'buddypress' ) ) . "'); ", __( 'Delete Permanently', 'buddypress' ) );
610
 
611
  // Start timestamp.
612
  echo '<div class="submitted-on">';
639
  // End timestamp.
640
  echo '</div>';
641
 
 
 
642
  // Get activity content - if not set, use the action.
643
  if ( ! empty( $item['content'] ) ) {
644
+ $activity = new BP_Activity_Activity( $item['id'] );
645
+
646
  /** This filter is documented in bp-activity/bp-activity-template.php */
647
  $content = apply_filters_ref_array( 'bp_get_activity_content_body', array( $item['content'], &$activity ) );
648
  } else {
649
+ /**
650
+ * Filters current activity item action.
651
+ *
652
+ * @since 1.2.0
653
+ *
654
+ * @var array $item Array index holding current activity item action.
655
+ */
656
+ $content = apply_filters_ref_array( 'bp_get_activity_action', array( $item['action'] ) );
657
  }
658
 
659
  /**
bp-activity/classes/class-bp-activity-query.php CHANGED
@@ -46,7 +46,7 @@ class BP_Activity_Query extends BP_Recursive_Query {
46
  * @var array
47
  */
48
  public $db_columns = array(
49
- 'id', 'user_id', 'component', 'type', 'action', 'content', 'primary_link',
50
  'item_id', 'secondary_item_id', 'hide_sitewide', 'is_spam',
51
  );
52
 
@@ -229,7 +229,7 @@ class BP_Activity_Query extends BP_Recursive_Query {
229
  /**
230
  * Validates a column name parameter.
231
  *
232
- * Column names are checked against a list of known tables.
233
  * See {@link BP_Activity_Query::db_tables}.
234
  *
235
  * @since 2.2.0
46
  * @var array
47
  */
48
  public $db_columns = array(
49
+ 'id', 'user_id', 'component', 'type', 'action', 'content',
50
  'item_id', 'secondary_item_id', 'hide_sitewide', 'is_spam',
51
  );
52
 
229
  /**
230
  * Validates a column name parameter.
231
  *
232
+ * Column names are checked against a whitelist of known tables.
233
  * See {@link BP_Activity_Query::db_tables}.
234
  *
235
  * @since 2.2.0
bp-activity/classes/class-bp-activity-template.php CHANGED
@@ -139,10 +139,8 @@ class BP_Activity_Template {
139
  public function __construct( $args ) {
140
  $bp = buddypress();
141
 
142
- $function_args = func_get_args();
143
-
144
  // Backward compatibility with old method of passing arguments.
145
- if ( !is_array( $args ) || count( $function_args ) > 1 ) {
146
  _deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
147
 
148
  $old_args_keys = array(
@@ -161,7 +159,7 @@ class BP_Activity_Template {
161
  12 => 'page_arg'
162
  );
163
 
164
- $args = bp_core_parse_args_array( $old_args_keys, $function_args );
165
  }
166
 
167
  $defaults = array(
@@ -193,7 +191,7 @@ class BP_Activity_Template {
193
  $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] );
194
  $this->pag_num = bp_sanitize_pagination_arg( 'num', $r['per_page'] );
195
 
196
- // Check if post/comment replies are disabled.
197
  $this->disable_blogforum_replies = (bool) bp_core_get_root_option( 'bp-disable-blogforum-comments' );
198
 
199
  // Get an array of the logged in user's favorite activities.
139
  public function __construct( $args ) {
140
  $bp = buddypress();
141
 
 
 
142
  // Backward compatibility with old method of passing arguments.
143
+ if ( !is_array( $args ) || func_num_args() > 1 ) {
144
  _deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
145
 
146
  $old_args_keys = array(
159
  12 => 'page_arg'
160
  );
161
 
162
+ $args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
163
  }
164
 
165
  $defaults = array(
191
  $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] );
192
  $this->pag_num = bp_sanitize_pagination_arg( 'num', $r['per_page'] );
193
 
194
+ // Check if blog/forum replies are disabled.
195
  $this->disable_blogforum_replies = (bool) bp_core_get_root_option( 'bp-disable-blogforum-comments' );
196
 
197
  // Get an array of the logged in user's favorite activities.
bp-activity/classes/class-bp-akismet.php CHANGED
@@ -92,13 +92,10 @@ class BP_Akismet {
92
  } else {
93
  $who = bp_activity_get_meta( $activity['id'], '_bp_akismet_user' );
94
 
95
- if ( 'true' == $user_result ) {
96
- /* translators: %s: the name of the user */
97
  $desc = sprintf( __( 'Flagged as spam by %s', 'buddypress' ), $who );
98
- } else {
99
- /* translators: %s: the name of the user */
100
  $desc = sprintf( __( 'Un-spammed by %s', 'buddypress' ), $who );
101
- }
102
  }
103
 
104
  // Add a History item to the hover links, just after Edit.
@@ -414,19 +411,6 @@ class BP_Akismet {
414
 
415
  // Mark as spam.
416
  bp_activity_mark_as_spam( $activity, 'by_akismet' );
417
-
418
- if (
419
- Akismet::allow_discard() &&
420
- ! empty( $activity_data['akismet_pro_tip'] ) &&
421
- 'discard' === $activity_data['akismet_pro_tip']
422
- ) {
423
- // If this is so spammy it's not worth your time, let's just delete it.
424
- if ( $activity->type === 'activity_comment' ) {
425
- bp_activity_delete_comment( $activity->item_id, $activity->id );
426
- } else {
427
- bp_activity_delete( array( 'id' => $activity->id ) );
428
- }
429
- }
430
  }
431
 
432
  // Update activity meta after a spam check.
@@ -445,16 +429,7 @@ class BP_Akismet {
445
  if ( !in_array( $activity->type, BP_Akismet::get_activity_types() ) )
446
  return;
447
 
448
- $this->update_activity_history(
449
- $activity->id,
450
- sprintf(
451
- /* translators: %s: the current user username */
452
- __( '%s reported this activity as spam', 'buddypress' ),
453
- bp_get_loggedin_user_username()
454
- ),
455
- 'report-spam'
456
- );
457
-
458
  bp_activity_update_meta( $activity->id, '_bp_akismet_user_result', 'true' );
459
  bp_activity_update_meta( $activity->id, '_bp_akismet_user', bp_get_loggedin_user_username() );
460
  }
@@ -471,16 +446,7 @@ class BP_Akismet {
471
  if ( !in_array( $activity->type, BP_Akismet::get_activity_types() ) )
472
  return;
473
 
474
- $this->update_activity_history(
475
- $activity->id,
476
- sprintf(
477
- /* translators: %s: the current user username */
478
- __( '%s reported this activity as not spam', 'buddypress' ),
479
- bp_get_loggedin_user_username()
480
- ),
481
- 'report-ham'
482
- );
483
-
484
  bp_activity_update_meta( $activity->id, '_bp_akismet_user_result', 'false' );
485
  bp_activity_update_meta( $activity->id, '_bp_akismet_user', bp_get_loggedin_user_username() );
486
  }
@@ -514,15 +480,7 @@ class BP_Akismet {
514
  // Uh oh, something's gone horribly wrong. Unexpected result.
515
  } else {
516
  bp_activity_update_meta( $activity->id, '_bp_akismet_error', bp_core_current_time() );
517
- $this->update_activity_history(
518
- $activity->id,
519
- sprintf(
520
- /* translators: %s the akismet result */
521
- __( 'Akismet was unable to check this item (response: %s), will automatically retry again later.', 'buddypress' ),
522
- $this->last_activity->akismet_submission['bp_as_result']
523
- ),
524
- 'check-error'
525
- );
526
  }
527
 
528
  // Record the original data which was submitted to Akismet for checking.
@@ -562,7 +520,7 @@ class BP_Akismet {
562
  // Keys to ignore.
563
  $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
564
 
565
- // Loop through _SERVER args and remove specified keys.
566
  foreach ( $_SERVER as $key => $value ) {
567
 
568
  // Key should not be ignored.
@@ -588,11 +546,11 @@ class BP_Akismet {
588
  $response = Akismet::http_post( $query_string, $path );
589
  remove_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
590
 
591
- // Save response data.
592
- $activity_data['bp_as_result'] = $response[1];
593
- if ( isset( $response[0]['x-akismet-pro-tip'] ) ) {
594
- $activity_data['akismet_pro_tip'] = $response[0]['x-akismet-pro-tip'];
595
- }
596
 
597
  // Perform a daily tidy up.
598
  if ( ! wp_next_scheduled( 'bp_activity_akismet_delete_old_metadata' ) )
@@ -647,7 +605,6 @@ class BP_Akismet {
647
  return;
648
 
649
  echo '<div class="akismet-history"><div>';
650
- /* translators: 1: the human diff time. 2: the akismet history data. */
651
  printf( _x( '%1$s &mdash; %2$s', 'x hours ago - akismet cleared this item', 'buddypress' ), '<span>' . bp_core_time_since( $history[2] ) . '</span>', esc_html( $history[1] ) );
652
  echo '</div></div>';
653
  }
92
  } else {
93
  $who = bp_activity_get_meta( $activity['id'], '_bp_akismet_user' );
94
 
95
+ if ( 'true' == $user_result )
 
96
  $desc = sprintf( __( 'Flagged as spam by %s', 'buddypress' ), $who );
97
+ else
 
98
  $desc = sprintf( __( 'Un-spammed by %s', 'buddypress' ), $who );
 
99
  }
100
 
101
  // Add a History item to the hover links, just after Edit.
411
 
412
  // Mark as spam.
413
  bp_activity_mark_as_spam( $activity, 'by_akismet' );
 
 
 
 
 
 
 
 
 
 
 
 
 
414
  }
415
 
416
  // Update activity meta after a spam check.
429
  if ( !in_array( $activity->type, BP_Akismet::get_activity_types() ) )
430
  return;
431
 
432
+ $this->update_activity_history( $activity->id, sprintf( __( '%s reported this activity as spam', 'buddypress' ), bp_get_loggedin_user_username() ), 'report-spam' );
 
 
 
 
 
 
 
 
 
433
  bp_activity_update_meta( $activity->id, '_bp_akismet_user_result', 'true' );
434
  bp_activity_update_meta( $activity->id, '_bp_akismet_user', bp_get_loggedin_user_username() );
435
  }
446
  if ( !in_array( $activity->type, BP_Akismet::get_activity_types() ) )
447
  return;
448
 
449
+ $this->update_activity_history( $activity->id, sprintf( __( '%s reported this activity as not spam', 'buddypress' ), bp_get_loggedin_user_username() ), 'report-ham' );
 
 
 
 
 
 
 
 
 
450
  bp_activity_update_meta( $activity->id, '_bp_akismet_user_result', 'false' );
451
  bp_activity_update_meta( $activity->id, '_bp_akismet_user', bp_get_loggedin_user_username() );
452
  }
480
  // Uh oh, something's gone horribly wrong. Unexpected result.
481
  } else {
482
  bp_activity_update_meta( $activity->id, '_bp_akismet_error', bp_core_current_time() );
483
+ $this->update_activity_history( $activity->id, sprintf( __( 'Akismet was unable to check this item (response: %s), will automatically retry again later.', 'buddypress' ), $this->last_activity->akismet_submission['bp_as_result'] ), 'check-error' );
 
 
 
 
 
 
 
 
484
  }
485
 
486
  // Record the original data which was submitted to Akismet for checking.
520
  // Keys to ignore.
521
  $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
522
 
523
+ // Loop through _SERVER args and remove whitelisted keys.
524
  foreach ( $_SERVER as $key => $value ) {
525
 
526
  // Key should not be ignored.
546
  $response = Akismet::http_post( $query_string, $path );
547
  remove_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
548
 
549
+ // Get the response.
550
+ if ( ! empty( $response[1] ) && ! is_wp_error( $response[1] ) )
551
+ $activity_data['bp_as_result'] = $response[1];
552
+ else
553
+ $activity_data['bp_as_result'] = false;
554
 
555
  // Perform a daily tidy up.
556
  if ( ! wp_next_scheduled( 'bp_activity_akismet_delete_old_metadata' ) )
605
  return;
606
 
607
  echo '<div class="akismet-history"><div>';
 
608
  printf( _x( '%1$s &mdash; %2$s', 'x hours ago - akismet cleared this item', 'buddypress' ), '<span>' . bp_core_time_since( $history[2] ) . '</span>', esc_html( $history[1] ) );
609
  echo '</div></div>';
610
  }
bp-activity/classes/class-bp-rest-activity-endpoint.php DELETED
@@ -1,1589 +0,0 @@
1
- <?php
2
- /**
3
- * BP REST: BP_REST_Activity_Endpoint class
4
- *
5
- * @package BuddyPress
6
- * @since 5.0.0
7
- */
8
-
9
- defined( 'ABSPATH' ) || exit;
10
-
11
- /**
12
- * Activity endpoints.
13
- *
14
- * @since 5.0.0
15
- */
16
- class BP_REST_Activity_Endpoint extends WP_REST_Controller {
17
-
18
- /**
19
- * User favorites.
20
- *
21
- * @since 5.0.0
22
- *
23
- * @var array|null
24
- */
25
- protected $user_favorites = null;
26
-
27
- /**
28
- * Constructor.
29
- *
30
- * @since 5.0.0
31
- */
32
- public function __construct() {
33
- $this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
34
- $this->rest_base = buddypress()->activity->id;
35
- }
36
-
37
- /**
38
- * Register the component routes.
39
- *
40
- * @since 5.0.0
41
- */
42
- public function register_routes() {
43
- register_rest_route(
44
- $this->namespace,
45
- '/' . $this->rest_base,
46
- array(
47
- array(
48
- 'methods' => WP_REST_Server::READABLE,
49
- 'callback' => array( $this, 'get_items' ),
50
- 'permission_callback' => array( $this, 'get_items_permissions_check' ),
51
- 'args' => $this->get_collection_params(),
52
- ),
53
- array(
54
- 'methods' => WP_REST_Server::CREATABLE,
55
- 'callback' => array( $this, 'create_item' ),
56
- 'permission_callback' => array( $this, 'create_item_permissions_check' ),
57
- 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
58
- ),
59
- 'schema' => array( $this, 'get_item_schema' ),
60
- )
61
- );
62
-
63
- $activity_endpoint = '/' . $this->rest_base . '/(?P<id>[\d]+)';
64
-
65
- register_rest_route(
66
- $this->namespace,
67
- $activity_endpoint,
68
- array(
69
- 'args' => array(
70
- 'id' => array(
71
- 'description' => __( 'A unique numeric ID for the activity.', 'buddypress' ),
72
- 'type' => 'integer',
73
- ),
74
- ),
75
- array(
76
- 'methods' => WP_REST_Server::READABLE,
77
- 'callback' => array( $this, 'get_item' ),
78
- 'permission_callback' => array( $this, 'get_item_permissions_check' ),
79
- 'args' => array(
80
- 'context' => $this->get_context_param(
81
- array(
82
- 'default' => 'view',
83
- )
84
- ),
85
- ),
86
- ),
87
- array(
88
- 'methods' => WP_REST_Server::EDITABLE,
89
- 'callback' => array( $this, 'update_item' ),
90
- 'permission_callback' => array( $this, 'update_item_permissions_check' ),
91
- 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
92
- ),
93
- array(
94
- 'methods' => WP_REST_Server::DELETABLE,
95
- 'callback' => array( $this, 'delete_item' ),
96
- 'permission_callback' => array( $this, 'delete_item_permissions_check' ),
97
- ),
98
- 'schema' => array( $this, 'get_item_schema' ),
99
- )
100
- );
101
-
102
- // Register the favorite route.
103
- register_rest_route(
104
- $this->namespace,
105
- $activity_endpoint . '/favorite',
106
- array(
107
- 'args' => array(
108
- 'id' => array(
109
- 'description' => __( 'A unique numeric ID for the activity.', 'buddypress' ),
110
- 'type' => 'integer',
111
- ),
112
- ),
113
- array(
114
- 'methods' => WP_REST_Server::EDITABLE,
115
- 'callback' => array( $this, 'update_favorite' ),
116
- 'permission_callback' => array( $this, 'update_favorite_permissions_check' ),
117
- ),
118
- 'schema' => array( $this, 'get_item_schema' ),
119
- )
120
- );
121
- }
122
-
123
- /**
124
- * Retrieve activities.
125
- *
126
- * @since 5.0.0
127
- *
128
- * @param WP_REST_Request $request Full details about the request.
129
- * @return WP_REST_Response List of activities response data.
130
- */
131
- public function get_items( $request ) {
132
- $args = array(
133
- 'exclude' => $request->get_param( 'exclude' ),
134
- 'in' => $request->get_param( 'include' ),
135
- 'page' => $request->get_param( 'page' ),
136
- 'per_page' => $request->get_param( 'per_page' ),
137
- 'search_terms' => $request->get_param( 'search' ),
138
- 'sort' => $request->get_param( 'order' ),
139
- 'spam' => $request->get_param( 'status' ),
140
- 'display_comments' => $request->get_param( 'display_comments' ),
141
- 'site_id' => $request->get_param( 'site_id' ),
142
- 'group_id' => $request->get_param( 'group_id' ),
143
- 'scope' => $request->get_param( 'scope' ),
144
- 'count_total' => true,
145
- 'fields' => 'all',
146
- 'show_hidden' => false,
147
- 'update_meta_cache' => true,
148
- 'filter' => false,
149
- );
150
-
151
- if ( empty( $args['display_comments'] ) || 'false' === $args['display_comments'] ) {
152
- $args['display_comments'] = false;
153
- }
154
-
155
- if ( empty( $request->get_param( 'exclude' ) ) ) {
156
- $args['exclude'] = false;
157
- }
158
-
159
- if ( empty( $request->get_param( 'include' ) ) ) {
160
- $args['in'] = false;
161
- }
162
-
163
- if ( ! empty( $request->get_param( 'after' ) ) ) {
164
- $args['since'] = $request->get_param( 'after' );
165
- }
166
-
167
- if ( ! empty( $request->get_param( 'user_id' ) ) ) {
168
- $args['filter']['user_id'] = $request->get_param( 'user_id' );
169
- }
170
-
171
- $item_id = 0;
172
- if ( ! empty( $args['group_id'] ) ) {
173
- $args['filter']['object'] = 'groups';
174
- $args['filter']['primary_id'] = $args['group_id'];
175
-
176
- if ( empty( $request->get_param( 'component' ) ) ) {
177
- $request->set_param( 'component', 'groups' );
178
- }
179
-
180
- $item_id = $args['group_id'];
181
- }
182
-
183
- if ( ! empty( $args['site_id'] ) ) {
184
- $args['filter']['object'] = 'blogs';
185
- $args['filter']['primary_id'] = $args['site_id'];
186
-
187
- $item_id = $args['site_id'];
188
- }
189
-
190
- if ( empty( $args['group_id'] ) && empty( $args['site_id'] ) ) {
191
- if ( ! empty( $request->get_param( 'component' ) ) ) {
192
- $args['filter']['object'] = $request->get_param( 'component' );
193
- }
194
-
195
- if ( ! empty( $request->get_param( 'primary_id' ) ) ) {
196
- $item_id = $request->get_param( 'primary_id' );
197
- $args['filter']['primary_id'] = $item_id;
198
- }
199
- }
200
-
201
- if ( empty( $request->get_param( 'scope' ) ) ) {
202
- $args['scope'] = false;
203
- }
204
-
205
- if ( ! empty( $request->get_param( 'type' ) ) ) {
206
- $args['filter']['action'] = $request->get_param( 'type' );
207
- }
208
-
209
- if ( ! empty( $request->get_param( 'secondary_id' ) ) ) {
210
- $args['filter']['secondary_id'] = $request->get_param( 'secondary_id' );
211
- }
212
-
213
- if ( $args['in'] ) {
214
- $args['count_total'] = false;
215
- }
216
-
217
- if ( $this->show_hidden( $request->get_param( 'component' ), $item_id ) ) {
218
- $args['show_hidden'] = true;
219
- }
220
-
221
- /**
222
- * Filter the query arguments for the request.
223
- *
224
- * @since 5.0.0
225
- *
226
- * @param array $args Key value array of query var to query value.
227
- * @param WP_REST_Request $request Full data about the request.
228
- */
229
- $args = apply_filters( 'bp_rest_activity_get_items_query_args', $args, $request );
230
-
231
- // Actually, query it.
232
- $activities = bp_activity_get( $args );
233
-
234
- $retval = array();
235
- foreach ( $activities['activities'] as $activity ) {
236
- $retval[] = $this->prepare_response_for_collection(
237
- $this->prepare_item_for_response( $activity, $request )
238
- );
239
- }
240
-
241
- $response = rest_ensure_response( $retval );
242
- $response = bp_rest_response_add_total_headers( $response, $activities['total'], $args['per_page'] );
243
-
244
- /**
245
- * Fires after a list of activities is fetched via the REST API.
246
- *
247
- * @since 5.0.0
248
- *
249
- * @param array $activities Fetched activities.
250
- * @param WP_REST_Response $response The response data.
251
- * @param WP_REST_Request $request Full data about the request.
252
- */
253
- do_action( 'bp_rest_activity_get_items', $activities, $response, $request );
254
-
255
- return $response;
256
- }
257
-
258
- /**
259
- * Check if a given request has access to activity items.
260
- *
261
- * @since 5.0.0
262
- *
263
- * @param WP_REST_Request $request Full data about the request.
264
- * @return true|WP_Error
265
- */
266
- public function get_items_permissions_check( $request ) {
267
-
268
- /**
269
- * Filter the activity `get_items` permissions check.
270
- *
271
- * @since 5.0.0
272
- *
273
- * @param true|WP_Error $retval Returned value.
274
- * @param WP_REST_Request $request Full data about the request.
275
- */
276
- return apply_filters( 'bp_rest_activity_get_items_permissions_check', true, $request );
277
- }
278
-
279
- /**
280
- * Retrieve an activity.
281
- *
282
- * @since 5.0.0
283
- *
284
- * @param WP_REST_Request $request Full details about the request.
285
- * @return WP_REST_Response|WP_Error
286
- */
287
- public function get_item( $request ) {
288
- $activity = $this->get_activity_object( $request );
289
-
290
- if ( empty( $activity->id ) ) {
291
- return new WP_Error(
292
- 'bp_rest_invalid_id',
293
- __( 'Invalid activity ID.', 'buddypress' ),
294
- array(
295
- 'status' => 404,
296
- )
297
- );
298
- }
299
-
300
- $retval = array(
301
- $this->prepare_response_for_collection(
302
- $this->prepare_item_for_response( $activity, $request )
303
- ),
304
- );
305
-
306
- $response = rest_ensure_response( $retval );
307
-
308
- /**
309
- * Fires after an activity is fetched via the REST API.
310
- *
311
- * @since 5.0.0
312
- *
313
- * @param BP_Activity_Activity $activity Fetched activity.
314
- * @param WP_REST_Response $response The response data.
315
- * @param WP_REST_Request $request The request sent to the API.
316
- */
317
- do_action( 'bp_rest_activity_get_item', $activity, $response, $request );
318
-
319
- return $response;
320
- }
321
-
322
- /**
323
- * Check if a given request has access to get information about a specific activity.
324
- *
325
- * @since 5.0.0
326
- *
327
- * @param WP_REST_Request $request Full data about the request.
328
- * @return true|WP_Error
329
- */
330
- public function get_item_permissions_check( $request ) {
331
- $retval = new WP_Error(
332
- 'bp_rest_authorization_required',
333
- __( 'Sorry, you cannot view the activities.', 'buddypress' ),
334
- array(
335
- 'status' => rest_authorization_required_code(),
336
- )
337
- );
338
-
339
- if ( $this->can_see( $request ) ) {
340
- $retval = true;
341
- }
342
-
343
- /**
344
- * Filter the activity `get_item` permissions check.
345
- *
346
- * @since 5.0.0
347
- *
348
- * @param true|WP_Error $retval Returned value.
349
- * @param WP_REST_Request $request The request sent to the API.
350
- */
351
- return apply_filters( 'bp_rest_activity_get_item_permissions_check', $retval, $request );
352
- }
353
-
354
- /**
355
- * Create an activity.
356
- *
357
- * @since 5.0.0
358
- *
359
- * @param WP_REST_Request $request Full data about the request.
360
- * @return WP_REST_Response|WP_Error
361
- */
362
- public function create_item( $request ) {
363
- $request->set_param( 'context', 'edit' );
364
-
365
- if ( empty( $request->get_param( 'content' ) ) ) {
366
- return new WP_Error(
367
- 'bp_rest_create_activity_empty_content',
368
- __( 'Please, enter some content.', 'buddypress' ),
369
- array(
370
- 'status' => 400,
371
- )
372
- );
373
- }
374
-
375
- $prepared_activity = $this->prepare_item_for_database( $request );
376
-
377
- // Fallback for the activity_update type.
378
- $type = 'activity_update';
379
- if ( ! empty( $request->get_param( 'type' ) ) ) {
380
- $type = $request->get_param( 'type' );
381
- }
382
-
383
- $prime = $request->get_param( 'primary_item_id' );
384
- $activity_id = 0;
385
-
386
- // Post a regular activity update.
387
- if ( 'activity_update' === $type ) {
388
- if ( bp_is_active( 'groups' ) && ! is_null( $prime ) ) {
389
- $activity_id = groups_post_update( $prepared_activity );
390
- } else {
391
- $activity_id = bp_activity_post_update( $prepared_activity );
392
- }
393
-
394
- // Post an activity comment.
395
- } elseif ( 'activity_comment' === $type ) {
396
-
397
- // ID of the root activity item.
398
- if ( isset( $prime ) ) {
399
- $prepared_activity->activity_id = (int) $prime;
400
- }
401
-
402
- // ID of a parent comment.
403
- if ( ! empty( $request->get_param( 'secondary_item_id' ) ) ) {
404
- $prepared_activity->parent_id = $request->get_param( 'secondary_item_id' );
405
- }
406
-
407
- $activity_id = bp_activity_new_comment( $prepared_activity );
408
-
409
- // Otherwise add an activity.
410
- } else {
411
- $activity_id = bp_activity_add( $prepared_activity );
412
- }
413
-
414
- if ( ! is_numeric( $activity_id ) ) {
415
- return new WP_Error(
416
- 'bp_rest_user_cannot_create_activity',
417
- __( 'Cannot create new activity.', 'buddypress' ),
418
- array(
419
- 'status' => 500,
420
- )
421
- );
422
- }
423
-
424
- $activity = bp_activity_get(
425
- array(
426
- 'in' => $activity_id,
427
- 'display_comments' => 'stream',
428
- 'show_hidden' => true,
429
- )
430
- );
431
-
432
- $activity = current( $activity['activities'] );
433
- $fields_update = $this->update_additional_fields_for_object( $activity, $request );
434
-
435
- if ( is_wp_error( $fields_update ) ) {
436
- return $fields_update;
437
- }
438
-
439
- // Update current user's last activity.
440
- bp_update_user_last_activity();
441
-
442
- $retval = array(
443
- $this->prepare_response_for_collection(
444
- $this->prepare_item_for_response( $activity, $request )
445
- ),
446
- );
447
-
448
- $response = rest_ensure_response( $retval );
449
-
450
- /**
451
- * Fires after an activity item is created via the REST API.
452
- *
453
- * @since 5.0.0
454
- *
455
- * @param BP_Activity_Activity $activity The created activity.
456
- * @param WP_REST_Response $response The response data.
457
- * @param WP_REST_Request $request The request sent to the API.
458
- */
459
- do_action( 'bp_rest_activity_create_item', $activity, $response, $request );
460
-
461
- return $response;
462
- }
463
-
464
- /**
465
- * Checks if a given request has access to create an activity.
466
- *
467
- * @since 5.0.0
468
- *
469
- * @param WP_REST_Request $request Full details about the request.
470
- * @return true|WP_Error
471
- */
472
- public function create_item_permissions_check( $request ) {
473
- $error = new WP_Error(
474
- 'bp_rest_authorization_required',
475
- __( 'Sorry, you are not allowed to create activities.', 'buddypress' ),
476
- array(
477
- 'status' => rest_authorization_required_code(),
478
- )
479
- );
480
-
481
- $retval = $error;
482
-
483
- if ( is_user_logged_in() ) {
484
- $user_id = $request->get_param( 'user_id' );
485
-
486
- if ( empty( $user_id ) || (int) bp_loggedin_user_id() === (int) $user_id ) {
487
- $item_id = $request->get_param( 'primary_item_id' );
488
- $component = $request->get_param( 'component' );
489
-
490
- // The current user can create an activity.
491
- $retval = true;
492
-
493
- if ( bp_is_active( 'groups' ) && buddypress()->groups->id === $component && ! is_null( $item_id ) ) {
494
- if ( ! $this->show_hidden( $component, $item_id ) ) {
495
- $retval = $error;
496
- }
497
- }
498
- }
499
- }
500
-
501
- /**
502
- * Filter the activity `create_item` permissions check.
503
- *
504
- * @since 5.0.0
505
- *
506
- * @param true|WP_Error $retval Returned value.
507
- * @param WP_REST_Request $request The request sent to the API.
508
- */
509
- return apply_filters( 'bp_rest_activity_create_item_permissions_check', $retval, $request );
510
- }
511
-
512
- /**
513
- * Update an activity.
514
- *
515
- * @since 5.0.0
516
- *
517
- * @param WP_REST_Request $request Full details about the request.
518
- * @return WP_REST_Response|WP_Error
519
- */
520
- public function update_item( $request ) {
521
- $request->set_param( 'context', 'edit' );
522
-
523
- if ( empty( $request->get_param( 'content' ) ) ) {
524
- return new WP_Error(
525
- 'bp_rest_update_activity_empty_content',
526
- __( 'Please, enter some content.', 'buddypress' ),
527
- array(
528
- 'status' => 400,
529
- )
530
- );
531
- }
532
-
533
- $activity_id = bp_activity_add( $this->prepare_item_for_database( $request ) );
534
-
535
- if ( ! is_numeric( $activity_id ) ) {
536
- return new WP_Error(
537
- 'bp_rest_user_cannot_update_activity',
538
- __( 'Cannot update existing activity.', 'buddypress' ),
539
- array(
540
- 'status' => 500,
541
- )
542
- );
543
- }
544
-
545
- $activity = $this->get_activity_object( $activity_id );
546
- $fields_update = $this->update_additional_fields_for_object( $activity, $request );
547
-
548
- if ( is_wp_error( $fields_update ) ) {
549
- return $fields_update;
550
- }
551
-
552
- $retval = array(
553
- $this->prepare_response_for_collection(
554
- $this->prepare_item_for_response( $activity, $request )
555
- ),
556
- );
557
-
558
- $response = rest_ensure_response( $retval );
559
-
560
- /**
561
- * Fires after an activity is updated via the REST API.
562
- *
563
- * @since 5.0.0
564
- *
565
- * @param BP_Activity_Activity $activity The updated activity.
566
- * @param WP_REST_Response $response The response data.
567
- * @param WP_REST_Request $request The request sent to the API.
568
- */
569
- do_action( 'bp_rest_activity_update_item', $activity, $response, $request );
570
-
571
- return $response;
572
- }
573
-
574
- /**
575
- * Check if a given request has access to update an activity.
576
- *
577
- * @since 5.0.0
578
- *
579
- * @param WP_REST_Request $request Full details about the request.
580
- * @return true|WP_Error
581
- */
582
- public function update_item_permissions_check( $request ) {
583
- $retval = new WP_Error(
584
- 'bp_rest_authorization_required',
585
- __( 'Sorry, you are not allowed to update this activity.', 'buddypress' ),
586
- array(
587
- 'status' => rest_authorization_required_code(),
588
- )
589
- );
590
-
591
- if ( is_user_logged_in() ) {
592
- $activity = $this->get_activity_object( $request );
593
-
594
- if ( empty( $activity->id ) ) {
595
- $retval = new WP_Error(
596
- 'bp_rest_invalid_id',
597
- __( 'Invalid activity ID.', 'buddypress' ),
598
- array(
599
- 'status' => 404,
600
- )
601
- );
602
- } elseif ( bp_activity_user_can_delete( $activity ) ) {
603
- $retval = true;
604
- }
605
- }
606
-
607
- /**
608
- * Filter the activity `update_item` permissions check.
609
- *
610
- * @since 5.0.0
611
- *
612
- * @param true|WP_Error $retval Returned value.
613
- * @param WP_REST_Request $request The request sent to the API.
614
- */
615
- return apply_filters( 'bp_rest_activity_update_item_permissions_check', $retval, $request );
616
- }
617
-
618
- /**
619
- * Delete activity.
620
- *
621
- * @since 5.0.0
622
- *
623
- * @param WP_REST_Request $request Full details about the request.
624
- * @return WP_REST_Response|WP_Error
625
- */
626
- public function delete_item( $request ) {
627
- // Setting context.
628
- $request->set_param( 'context', 'edit' );
629
-
630
- // Get the activity before it's deleted.
631
- $activity = $this->get_activity_object( $request );
632
- $previous = $this->prepare_item_for_response( $activity, $request );
633
-
634
- if ( 'activity_comment' === $activity->type ) {
635
- $retval = bp_activity_delete_comment( $activity->item_id, $activity->id );
636
- } else {
637
- $retval = bp_activity_delete(
638
- array(
639
- 'id' => $activity->id,
640
- )
641
- );
642
- }
643
-
644
- if ( ! $retval ) {
645
- return new WP_Error(
646
- 'bp_rest_activity_cannot_delete',
647
- __( 'Could not delete the activity.', 'buddypress' ),
648
- array(
649
- 'status' => 500,
650
- )
651
- );
652
- }
653
-
654
- // Build the response.
655
- $response = new WP_REST_Response();
656
- $response->set_data(
657
- array(
658
- 'deleted' => true,
659
- 'previous' => $previous->get_data(),
660
- )
661
- );
662
-
663
- /**
664
- * Fires after an activity is deleted via the REST API.
665
- *
666
- * @since 5.0.0
667
- *
668
- * @param BP_Activity_Activity $activity The deleted activity.
669
- * @param WP_REST_Response $response The response data.
670
- * @param WP_REST_Request $request The request sent to the API.
671
- */
672
- do_action( 'bp_rest_activity_delete_item', $activity, $response, $request );
673
-
674
- return $response;
675
- }
676
-
677
- /**
678
- * Check if a given request has access to delete an activity.
679
- *
680
- * @since 5.0.0
681
- *
682
- * @param WP_REST_Request $request Full details about the request.
683
- * @return true|WP_Error
684
- */
685
- public function delete_item_permissions_check( $request ) {
686
- $retval = new WP_Error(
687
- 'bp_rest_authorization_required',
688
- __( 'Sorry, you are not allowed to delete this activity.', 'buddypress' ),
689
- array(
690
- 'status' => rest_authorization_required_code(),
691
- )
692
- );
693
-
694
- if ( is_user_logged_in() ) {
695
- $activity = $this->get_activity_object( $request );
696
-
697
- if ( empty( $activity->id ) ) {
698
- $retval = new WP_Error(
699
- 'bp_rest_invalid_id',
700
- __( 'Invalid activity ID.', 'buddypress' ),
701
- array(
702
- 'status' => 404,
703
- )
704
- );
705
- } elseif ( bp_activity_user_can_delete( $activity ) ) {
706
- $retval = true;
707
- }
708
- }
709
-
710
- /**
711
- * Filter the activity `delete_item` permissions check.
712
- *
713
- * @since 5.0.0
714
- *
715
- * @param true|WP_Error $retval Returned value.
716
- * @param WP_REST_Request $request The request sent to the API.
717
- */
718
- return apply_filters( 'bp_rest_activity_delete_item_permissions_check', $retval, $request );
719
- }
720
-
721
- /**
722
- * Gets the current user's favorites.
723
- *
724
- * @since 5.0.0
725
- *
726
- * @return array Array of activity IDs.
727
- */
728
- public function get_user_favorites() {
729
- if ( null === $this->user_favorites ) {
730
- if ( is_user_logged_in() ) {
731
- $user_favorites = bp_activity_get_user_favorites( get_current_user_id() );
732
- $this->user_favorites = array_filter( wp_parse_id_list( $user_favorites ) );
733
- } else {
734
- $this->user_favorites = array();
735
- }
736
- }
737
-
738
- return $this->user_favorites;
739
- }
740
-
741
- /**
742
- * Adds or removes the activity from the current user's favorites.
743
- *
744
- * @since 5.0.0
745
- *
746
- * @param WP_REST_Request $request Full details about the request.
747
- * @return WP_REST_Response|WP_Error
748
- */
749
- public function update_favorite( $request ) {
750
- $activity = $this->get_activity_object( $request );
751
-
752
- if ( empty( $activity->id ) ) {
753
- return new WP_Error(
754
- 'bp_rest_invalid_id',
755
- __( 'Invalid activity ID.', 'buddypress' ),
756
- array(
757
- 'status' => 404,
758
- )
759
- );
760
- }
761
-
762
- $user_id = get_current_user_id();
763
-
764
- $result = false;
765
- if ( in_array( $activity->id, $this->get_user_favorites(), true ) ) {
766
- $result = bp_activity_remove_user_favorite( $activity->id, $user_id );
767
- $message = __( 'Sorry, you cannot remove the activity from your favorites.', 'buddypress' );
768
-
769
- // Update the user favorites, removing the activity ID.
770
- $this->user_favorites = array_diff( $this->get_user_favorites(), array( $activity->id ) );
771
- } else {
772
- $result = bp_activity_add_user_favorite( $activity->id, $user_id );
773
- $message = __( 'Sorry, you cannot add the activity to your favorites.', 'buddypress' );
774
-
775
- // Update the user favorites, adding the activity ID.
776
- $this->user_favorites[] = (int) $activity->id;
777
- }
778
-
779
- if ( ! $result ) {
780
- return new WP_Error(
781
- 'bp_rest_user_cannot_update_activity_favorite',
782
- $message,
783
- array(
784
- 'status' => 500,
785
- )
786
- );
787
- }
788
-
789
- // Prepare the response now the user favorites has been updated.
790
- $retval = array(
791
- $this->prepare_response_for_collection(
792
- $this->prepare_item_for_response( $activity, $request )
793
- ),
794
- );
795
-
796
- $response = rest_ensure_response( $retval );
797
-
798
- /**
799
- * Fires after user favorited activities has been updated via the REST API.
800
- *
801
- * @since 5.0.0
802
- *
803
- * @param BP_Activity_Activity $activity The updated activity.
804
- * @param array $user_favorites The updated user favorites.
805
- * @param WP_REST_Response $response The response data.
806
- * @param WP_REST_Request $request The request sent to the API.
807
- */
808
- do_action( 'bp_rest_activity_update_favorite', $activity, $this->get_user_favorites(), $response, $request );
809
-
810
- return $response;
811
- }
812
-
813
- /**
814
- * Check if a given request has access to update user favorites.
815
- *
816
- * @since 5.0.0
817
- *
818
- * @param WP_REST_Request $request Full details about the request.
819
- * @return true|WP_Error
820
- */
821
- public function update_favorite_permissions_check( $request ) {
822
- $retval = new WP_Error(
823
- 'bp_rest_authorization_required',
824
- __( 'Sorry, you are not allowed to update favorites.', 'buddypress' ),
825
- array(
826
- 'status' => rest_authorization_required_code(),
827
- )
828
- );
829
-
830
- if ( is_user_logged_in() && bp_activity_can_favorite() && $this->can_see( $request ) ) {
831
- $retval = true;
832
- }
833
-
834
- /**
835
- * Filter the activity `update_favorite` permissions check.
836
- *
837
- * @since 5.0.0
838
- *
839
- * @param true|WP_Error $retval Returned value.
840
- * @param WP_REST_Request $request The request sent to the API.
841
- */
842
- return apply_filters( 'bp_rest_activity_update_favorite_permissions_check', $retval, $request );
843
- }
844
-
845
- /**
846
- * Renders the content of an activity.
847
- *
848
- * @since 5.0.0
849
- *
850
- * @param BP_Activity_Activity $activity Activity data.
851
- * @return string The rendered activity content.
852
- */
853
- public function render_item( $activity ) {
854
- $rendered = '';
855
-
856
- if ( empty( $activity->content ) ) {
857
- return $rendered;
858
- }
859
-
860
- // Do not truncate activities.
861
- add_filter( 'bp_activity_maybe_truncate_entry', '__return_false' );
862
-
863
- if ( 'activity_comment' === $activity->type ) {
864
- $rendered = apply_filters( 'bp_get_activity_content', $activity->content );
865
- } else {
866
- $activities_template = null;
867
-
868
- if ( isset( $GLOBALS['activities_template'] ) ) {
869
- $activities_template = $GLOBALS['activities_template'];
870
- }
871
-
872
- // Set the `activities_template` global for the current activity.
873
- $GLOBALS['activities_template'] = new stdClass();
874
- $GLOBALS['activities_template']->activity = $activity;
875
-
876
- // Set up activity oEmbed cache.
877
- bp_activity_embed();
878
-
879
- $rendered = apply_filters( 'bp_get_activity_content_body', $activity->content, $activity );
880
-
881
- // Restore the `activities_template` global.
882
- $GLOBALS['activities_template'] = $activities_template;
883
- }
884
-
885
- // Restore the filter to truncate activities.
886
- remove_filter( 'bp_activity_maybe_truncate_entry', '__return_false' );
887
-
888
- return $rendered;
889
- }
890
-
891
- /**
892
- * Prepares activity data for return as an object.
893
- *
894
- * @since 5.0.0
895
- *
896
- * @param BP_Activity_Activity $activity Activity object.
897
- * @param WP_REST_Request $request Full details about the request.
898
- * @return WP_REST_Response
899
- */
900
- public function prepare_item_for_response( $activity, $request ) {
901
- $data = array(
902
- 'user_id' => $activity->user_id,
903
- 'component' => $activity->component,
904
- 'content' => array(
905
- 'raw' => $activity->content,
906
- 'rendered' => $this->render_item( $activity ),
907
- ),
908
- 'date' => bp_rest_prepare_date_response( $activity->date_recorded ),
909
- 'id' => $activity->id,
910
- 'link' => bp_activity_get_permalink( $activity->id ),
911
- 'primary_item_id' => $activity->item_id,
912
- 'secondary_item_id' => $activity->secondary_item_id,
913
- 'status' => $activity->is_spam ? 'spam' : 'published',
914
- 'title' => $activity->action,
915
- 'type' => $activity->type,
916
- 'favorited' => in_array( $activity->id, $this->get_user_favorites(), true ),
917
- );
918
-
919
- // Get item schema.
920
- $schema = $this->get_item_schema();
921
-
922
- // Get comments (count).
923
- if ( ! empty( $activity->children ) ) {
924
- $comment_count = wp_filter_object_list( $activity->children, array( 'type' => 'activity_comment' ), 'AND', 'id' );
925
- $data['comment_count'] = ! empty( $comment_count ) ? count( $comment_count ) : 0;
926
-
927
- if ( ! empty( $schema['properties']['comments'] ) && 'threaded' === $request->get_param( 'display_comments' ) ) {
928
- $data['comments'] = $this->prepare_activity_comments( $activity->children, $request );
929
- }
930
- }
931
-
932
- if ( true === buddypress()->avatar->show_avatars ) {
933
- $data['user_avatar'] = array(
934
- 'full' => bp_core_fetch_avatar(
935
- array(
936
- 'item_id' => $activity->user_id,
937
- 'html' => false,
938
- 'type' => 'full',
939
- )
940
- ),
941
- 'thumb' => bp_core_fetch_avatar(
942
- array(
943
- 'item_id' => $activity->user_id,
944
- 'html' => false,
945
- )
946
- ),
947
- );
948
- }
949
-
950
- $context = ! empty( $request->get_param( 'context' ) ) ? $request->get_param( 'context' ) : 'view';
951
- $data = $this->add_additional_fields_to_object( $data, $request );
952
- $data = $this->filter_response_by_context( $data, $context );
953
- $response = rest_ensure_response( $data );
954
-
955
- $response->add_links( $this->prepare_links( $activity ) );
956
-
957
- /**
958
- * Filter an activity value returned from the API.
959
- *
960
- * @since 5.0.0
961
- *
962
- * @param WP_REST_Response $response The response data.
963
- * @param WP_REST_Request $request Request used to generate the response.
964
- * @param BP_Activity_Activity $activity The activity object.
965
- */
966
- return apply_filters( 'bp_rest_activity_prepare_value', $response, $request, $activity );
967
- }
968
-
969
- /**
970
- * Prepare activity comments.
971
- *
972
- * @since 5.0.0
973
- *
974
- * @param array $comments Array of comments.
975
- * @param WP_REST_Request $request Full details about the request.
976
- * @return array An array of activity comments.
977
- */
978
- protected function prepare_activity_comments( $comments, $request ) {
979
- $data = array();
980
-
981
- if ( empty( $comments ) ) {
982
- return $data;
983
- }
984
-
985
- foreach ( $comments as $comment ) {
986
- $data[] = $this->prepare_response_for_collection(
987
- $this->prepare_item_for_response( $comment, $request )
988
- );
989
- }
990
-
991
- /**
992
- * Filter activity comments returned from the API.
993
- *
994
- * @since 5.0.0
995
- *
996
- * @param array $data An array of activity comments with proper API response.
997
- * @param array $comments An array of activity comments.
998
- * @param WP_REST_Request $request Full details about the request.
999
- */
1000
- return apply_filters( 'bp_rest_activity_prepare_comments', $data, $comments, $request );
1001
- }
1002
-
1003
- /**
1004
- * Prepare an activity for create or update.
1005
- *
1006
- * @since 5.0.0
1007
- *
1008
- * @param WP_REST_Request $request Full details about the request.
1009
- * @return stdClass|WP_Error Object or WP_Error.
1010
- */
1011
- protected function prepare_item_for_database( $request ) {
1012
- $prepared_activity = new stdClass();
1013
- $schema = $this->get_item_schema();
1014
- $activity = $this->get_activity_object( $request );
1015
-
1016
- if ( ! empty( $schema['properties']['id'] ) && ! empty( $activity->id ) ) {
1017
- $prepared_activity->id = $activity->id;
1018
-
1019
- if ( 'activity_comment' !== $request->get_param( 'type' ) ) {
1020
- $prepared_activity->error_type = 'wp_error';
1021
- }
1022
- }
1023
-
1024
- // Activity author ID.
1025
- if ( ! empty( $activity->user_id ) ) {
1026
- $prepared_activity->user_id = (int) $activity->user_id;
1027
- } else {
1028
- $prepared_activity->user_id = get_current_user_id();
1029
- }
1030
-
1031
- // Activity component.
1032
- if ( ! empty( $schema['properties']['component'] ) && ! empty( $request->get_param( 'component' ) ) ) {
1033
- $prepared_activity->component = $request->get_param( 'component' );
1034
- } else {
1035
- $prepared_activity->component = buddypress()->activity->id;
1036
- }
1037
-
1038
- // Activity Item ID.
1039
- if ( ! empty( $schema['properties']['primary_item_id'] ) && ! empty( $request->get_param( 'primary_item_id' ) ) ) {
1040
- $item_id = (int) $request->get_param( 'primary_item_id' );
1041
-
1042
- // Set the group ID of the activity.
1043
- if ( bp_is_active( 'groups' ) && isset( $prepared_activity->component ) && buddypress()->groups->id === $prepared_activity->component ) {
1044
- $prepared_activity->group_id = $item_id;
1045
-
1046
- // Use a generic item ID for other components.
1047
- } else {
1048
- $prepared_activity->item_id = $item_id;
1049
- }
1050
- }
1051
-
1052
- // Secondary Item ID.
1053
- if ( ! empty( $schema['properties']['secondary_item_id'] ) && ! empty( $request->get_param( 'secondary_item_id' ) ) ) {
1054
- $prepared_activity->secondary_item_id = (int) $request->get_param( 'secondary_item_id' );
1055
- }
1056
-
1057
- // Activity type.
1058
- if ( ! empty( $schema['properties']['type'] ) && ! empty( $request->get_param( 'type' ) ) ) {
1059
- $prepared_activity->type = $request->get_param( 'type' );
1060
- }
1061
-
1062
- // Activity content.
1063
- if ( ! empty( $schema['properties']['content'] ) && ! empty( $request->get_param( 'content' ) ) ) {
1064
- if ( is_string( $request->get_param( 'content' ) ) ) {
1065
- $prepared_activity->content = $request->get_param( 'content' );
1066
- } elseif ( isset( $request['content']['raw'] ) ) {
1067
- $prepared_activity->content = $request['content']['raw'];
1068
- }
1069
- }
1070
-
1071
- // Activity Sitewide visibility.
1072
- if ( ! empty( $schema['properties']['hidden'] ) && ! empty( $request->get_param( 'hidden' ) ) ) {
1073
- $prepared_activity->hide_sitewide = (bool) $request->get_param( 'hidden' );
1074
- }
1075
-
1076
- /**
1077
- * Filters an activity before it is inserted or updated via the REST API.
1078
- *
1079
- * @since 5.0.0
1080
- *
1081
- * @param stdClass $prepared_activity An object prepared for inserting or updating the database.
1082
- * @param WP_REST_Request $request Request object.
1083
- */
1084
- return apply_filters( 'bp_rest_activity_pre_insert_value', $prepared_activity, $request );
1085
- }
1086
-
1087
- /**
1088
- * Prepare links for the request.
1089
- *
1090
- * @since 5.0.0
1091
- *
1092
- * @param BP_Activity_Activity $activity Activity object.
1093
- * @return array
1094
- */
1095
- protected function prepare_links( $activity ) {
1096
- $base = sprintf( '/%1$s/%2$s/', $this->namespace, $this->rest_base );
1097
- $url = $base . $activity->id;
1098
-
1099
- // Entity meta.
1100
- $links = array(
1101
- 'self' => array(
1102
- 'href' => rest_url( $url ),
1103
- ),
1104
- 'collection' => array(
1105
- 'href' => rest_url( $base ),
1106
- ),
1107
- );
1108
-
1109
- if ( ! empty( $activity->user_id ) ) {
1110
- $links['user'] = array(
1111
- 'href' => bp_rest_get_object_url( absint( $activity->user_id ), 'members' ),
1112
- 'embeddable' => true,
1113
- );
1114
- }
1115
-
1116
- if ( 'activity_comment' === $activity->type ) {
1117
- $links['up'] = array(
1118
- 'href' => rest_url( $url ),
1119
- );
1120
- }
1121
-
1122
- if ( bp_activity_can_favorite() ) {
1123
- $links['favorite'] = array(
1124
- 'href' => rest_url( $url . '/favorite' ),
1125
- );
1126
- }
1127
-
1128
- // Embed Group.
1129
- if ( bp_is_active( 'groups' ) && buddypress()->groups->id === $activity->component && ! empty( $activity->item_id ) ) {
1130
- $links['group'] = array(
1131
- 'embeddable' => true,
1132
- 'href' => rest_url(
1133
- sprintf(
1134
- '/%1$s/%2$s/%3$d',
1135
- $this->namespace,
1136
- buddypress()->groups->id,
1137
- absint( $activity->item_id )
1138
- )
1139
- ),
1140
- );
1141
- }
1142
-
1143
- // Embed Blog.
1144
- if ( bp_is_active( 'blogs' ) && buddypress()->blogs->id === $activity->component && ! empty( $activity->item_id ) ) {
1145
- $links['blog'] = array(
1146
- 'embeddable' => true,
1147
- 'href' => rest_url(
1148
- sprintf(
1149
- '/%1$s/%2$s/%3$d',
1150
- $this->namespace,
1151
- buddypress()->blogs->id,
1152
- absint( $activity->item_id )
1153
- )
1154
- ),
1155
- );
1156
- }
1157
-
1158
- /**
1159
- * Filter links prepared for the REST response.
1160
- *
1161
- * @since 5.0.0
1162
- *
1163
- * @param array $links The prepared links of the REST response.
1164
- * @param BP_Activity_Activity $activity Activity object.
1165
- */
1166
- return apply_filters( 'bp_rest_activity_prepare_links', $links, $activity );
1167
- }
1168
-
1169
- /**
1170
- * Can this user see the activity?
1171
- *
1172
- * @since 5.0.0
1173
- *
1174
- * @param WP_REST_Request $request Full details about the request.
1175
- * @return boolean
1176
- */
1177
- protected function can_see( $request ) {
1178
- return bp_activity_user_can_read(
1179
- $this->get_activity_object( $request ),
1180
- bp_loggedin_user_id()
1181
- );
1182
- }
1183
-
1184
- /**
1185
- * Show hidden activity?
1186
- *
1187
- * @since 5.0.0
1188
- *
1189
- * @param string $component The component the activity is from.
1190
- * @param int $item_id The activity item ID.
1191
- * @return boolean
1192
- */
1193
- protected function show_hidden( $component, $item_id ) {
1194
- $user_id = get_current_user_id();
1195
- $retval = false;
1196
-
1197
- if ( ! is_null( $component ) ) {
1198
- // If activity is from a group, do an extra cap check.
1199
- if ( ! $retval && ! empty( $item_id ) && bp_is_active( $component ) && buddypress()->groups->id === $component ) {
1200
- // Group admins and mods have access as well.
1201
- if ( groups_is_user_admin( $user_id, $item_id ) || groups_is_user_mod( $user_id, $item_id ) ) {
1202
- $retval = true;
1203
-
1204
- // User is a member of the group.
1205
- } elseif ( (bool) groups_is_user_member( $user_id, $item_id ) ) {
1206
- $retval = true;
1207
- }
1208
- }
1209
- }
1210
-
1211
- // Moderators as well.
1212
- if ( bp_current_user_can( 'bp_moderate' ) ) {
1213
- $retval = true;
1214
- }
1215
-
1216
- return (bool) $retval;
1217
- }
1218
-
1219
- /**
1220
- * Get activity object.
1221
- *
1222
- * @since 5.0.0
1223
- *
1224
- * @param WP_REST_Request $request Full details about the request.
1225
- * @return BP_Activity_Activity|string An activity object.
1226
- */
1227
- public function get_activity_object( $request ) {
1228
- $activity_id = is_numeric( $request ) ? $request : (int) $request->get_param( 'id' );
1229
-
1230
- $activity = bp_activity_get_specific(
1231
- array(
1232
- 'activity_ids' => array( $activity_id ),
1233
- 'display_comments' => true,
1234
- )
1235
- );
1236
-
1237
- if ( is_array( $activity ) && ! empty( $activity['activities'][0] ) ) {
1238
- return $activity['activities'][0];
1239
- }
1240
-
1241
- return '';
1242
- }
1243
-
1244
- /**
1245
- * Edit the type of the some properties for the CREATABLE & EDITABLE methods.
1246
- *
1247
- * @since 5.0.0
1248
- *
1249
- * @param string $method Optional. HTTP method of the request.
1250
- * @return array Endpoint arguments.
1251
- */
1252
- public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) {
1253
- $args = parent::get_endpoint_args_for_item_schema( $method );
1254
- $key = 'get_item';
1255
-
1256
- if ( WP_REST_Server::CREATABLE === $method || WP_REST_Server::EDITABLE === $method ) {
1257
- $key = 'create_item';
1258
- $args['content']['type'] = 'string';
1259
- unset( $args['content']['properties'] );
1260
-
1261
- if ( WP_REST_Server::EDITABLE === $method ) {
1262
- $key = 'update_item';
1263
- $args['type']['required'] = true;
1264
- }
1265
- } elseif ( WP_REST_Server::DELETABLE === $method ) {
1266
- $key = 'delete_item';
1267
- }
1268
-
1269
- /**
1270
- * Filters the method query arguments.
1271
- *
1272
- * @since 5.0.0
1273
- *
1274
- * @param array $args Query arguments.
1275
- * @param string $method HTTP method of the request.
1276
- */
1277
- return apply_filters( "bp_rest_activity_{$key}_query_arguments", $args, $method );
1278
- }
1279
-
1280
- /**
1281
- * Get the plugin schema, conforming to JSON Schema.
1282
- *
1283
- * @since 5.0.0
1284
- *
1285
- * @return array
1286
- */
1287
- public function get_item_schema() {
1288
- if ( is_null( $this->schema ) ) {
1289
- $schema = array(
1290
- '$schema' => 'http://json-schema.org/draft-04/schema#',
1291
- 'title' => 'bp_activity',
1292
- 'type' => 'object',
1293
- 'properties' => array(
1294
- 'id' => array(
1295
- 'context' => array( 'view', 'edit', 'embed' ),
1296
- 'description' => __( 'A unique numeric ID for the activity.', 'buddypress' ),
1297
- 'readonly' => true,
1298
- 'type' => 'integer',
1299
- ),
1300
- 'primary_item_id' => array(
1301
- 'context' => array( 'view', 'edit', 'embed' ),
1302
- 'description' => __( 'The ID of some other object primarily associated with this one.', 'buddypress' ),
1303
- 'type' => 'integer',
1304
- ),
1305
- 'secondary_item_id' => array(
1306
- 'context' => array( 'view', 'edit', 'embed' ),
1307
- 'description' => __( 'The ID of some other object also associated with this one.', 'buddypress' ),
1308
- 'type' => 'integer',
1309
- ),
1310
- 'user_id' => array(
1311
- 'context' => array( 'view', 'edit', 'embed' ),
1312
- 'description' => __( 'The ID for the author of the activity.', 'buddypress' ),
1313
- 'readonly' => true,
1314
- 'type' => 'integer',
1315
- ),
1316
- 'link' => array(
1317
- 'context' => array( 'view', 'edit', 'embed' ),
1318
- 'description' => __( 'The permalink to this activity on the site.', 'buddypress' ),
1319
- 'format' => 'uri',
1320
- 'type' => 'string',
1321
- ),
1322
- 'component' => array(
1323
- 'context' => array( 'view', 'edit', 'embed' ),
1324
- 'description' => __( 'The active BuddyPress component the activity relates to.', 'buddypress' ),
1325
- 'type' => 'string',
1326
- 'enum' => array_keys( buddypress()->active_components ),
1327
- 'arg_options' => array(
1328
- 'sanitize_callback' => 'sanitize_key',
1329
- ),
1330
- ),
1331
- 'type' => array(
1332
- 'context' => array( 'view', 'edit', 'embed' ),
1333
- 'description' => __( 'The activity type of the activity.', 'buddypress' ),
1334
- 'type' => 'string',
1335
- 'enum' => array_keys( bp_activity_get_types() ),
1336
- 'arg_options' => array(
1337
- 'sanitize_callback' => 'sanitize_key',
1338
- ),
1339
- ),
1340
- 'title' => array(
1341
- 'context' => array( 'view', 'edit', 'embed' ),
1342
- 'description' => __( 'The description of the activity\'s type (eg: Username posted an update)', 'buddypress' ),
1343
- 'type' => 'string',
1344
- 'readonly' => true,
1345
- 'arg_options' => array(
1346
- 'sanitize_callback' => 'sanitize_text_field',
1347
- ),
1348
- ),
1349
- 'content' => array(
1350
- 'context' => array( 'view', 'edit', 'embed' ),
1351
- 'description' => __( 'Allowed HTML content for the activity.', 'buddypress' ),
1352
- 'type' => 'object',
1353
- 'arg_options' => array(
1354
- 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database().
1355
- 'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database().
1356
- ),
1357
- 'properties' => array(
1358
- 'raw' => array(
1359
- 'description' => __( 'Content for the activity, as it exists in the database.', 'buddypress' ),
1360
- 'type' => 'string',
1361
- 'context' => array( 'edit' ),
1362
- ),
1363
- 'rendered' => array(
1364
- 'description' => __( 'HTML content for the activity, transformed for display.', 'buddypress' ),
1365
- 'type' => 'string',
1366
- 'context' => array( 'view', 'edit', 'embed' ),
1367
- 'readonly' => true,
1368
- ),
1369
- ),
1370
- ),
1371
- 'date' => array(
1372
- 'context' => array( 'view', 'edit', 'embed' ),
1373
- 'description' => __( "The date the activity was published, in the site's timezone.", 'buddypress' ),
1374
- 'type' => 'string',
1375
- 'format' => 'date-time',
1376
- ),
1377
- 'status' => array(
1378
- 'context' => array( 'view', 'edit', 'embed' ),
1379
- 'description' => __( 'Whether the activity has been marked as spam or not.', 'buddypress' ),
1380
- 'type' => 'string',
1381
- 'enum' => array( 'published', 'spam' ),
1382
- 'readonly' => true,
1383
- 'arg_options' => array(
1384
- 'sanitize_callback' => 'sanitize_key',
1385
- ),
1386
- ),
1387
- 'comments' => array(
1388
- 'context' => array( 'view', 'edit', 'embed' ),
1389
- 'description' => __( 'A list of objects children of the activity object.', 'buddypress' ),
1390
- 'type' => 'array',
1391
- 'readonly' => true,
1392
- ),
1393
- 'comment_count' => array(
1394
- 'context' => array( 'view', 'edit', 'embed' ),
1395
- 'description' => __( 'Total number of comments of the activity object.', 'buddypress' ),
1396
- 'type' => 'integer',
1397
- 'readonly' => true,
1398
- ),
1399
- 'hidden' => array(
1400
- 'context' => array( 'edit', 'embed' ),
1401
- 'description' => __( 'Whether the activity object should be sitewide hidden or not.', 'buddypress' ),
1402
- 'type' => 'boolean',
1403
- ),
1404
- 'favorited' => array(
1405
- 'context' => array( 'view', 'edit', 'embed' ),
1406
- 'description' => __( 'Whether the activity object has been favorited by the current user.', 'buddypress' ),
1407
- 'type' => 'boolean',
1408
- 'readonly' => true,
1409
- ),
1410
- ),
1411
- );
1412
-
1413
- if ( true === buddypress()->avatar->show_avatars ) {
1414
- $avatar_properties = array();
1415
-
1416
- $avatar_properties['full'] = array(
1417
- 'context' => array( 'view', 'edit', 'embed' ),
1418
- /* translators: 1: Full avatar width in pixels. 2: Full avatar height in pixels */
1419
- 'description' => sprintf( __( 'Avatar URL with full image size (%1$d x %2$d pixels).', 'buddypress' ), number_format_i18n( bp_core_avatar_full_width() ), number_format_i18n( bp_core_avatar_full_height() ) ),
1420
- 'type' => 'string',
1421
- 'format' => 'uri',
1422
- );
1423
-
1424
- $avatar_properties['thumb'] = array(
1425
- 'context' => array( 'view', 'edit', 'embed' ),
1426
- /* translators: 1: Thumb avatar width in pixels. 2: Thumb avatar height in pixels */
1427
- 'description' => sprintf( __( 'Avatar URL with thumb image size (%1$d x %2$d pixels).', 'buddypress' ), number_format_i18n( bp_core_avatar_thumb_width() ), number_format_i18n( bp_core_avatar_thumb_height() ) ),
1428
- 'type' => 'string',
1429
- 'format' => 'uri',
1430
- );
1431
-
1432
- $schema['properties']['user_avatar'] = array(
1433
- 'context' => array( 'view', 'edit', 'embed' ),
1434
- 'description' => __( 'Avatar URLs for the author of the activity.', 'buddypress' ),
1435
- 'type' => 'object',
1436
- 'readonly' => true,
1437
- 'properties' => $avatar_properties,
1438
- );
1439
- }
1440
-
1441
- // Cache current schema here.
1442
- $this->schema = $schema;
1443
- }
1444
-
1445
- /**
1446
- * Filters the activity schema.
1447
- *
1448
- * @param array $schema The endpoint schema.
1449
- */
1450
- return apply_filters( 'bp_rest_activity_schema', $this->add_additional_fields_schema( $this->schema ) );
1451
- }
1452
-
1453
- /**
1454
- * Get the query params for collections of plugins.
1455
- *
1456
- * @since 5.0.0
1457
- *
1458
- * @return array
1459
- */
1460
- public function get_collection_params() {
1461
- $params = parent::get_collection_params();
1462
- $params['context']['default'] = 'view';
1463
-
1464
- $params['exclude'] = array(
1465
- 'description' => __( 'Ensure result set excludes specific IDs.', 'buddypress' ),
1466
- 'default' => array(),
1467
- 'type' => 'array',
1468
- 'items' => array( 'type' => 'integer' ),
1469
- 'sanitize_callback' => 'wp_parse_id_list',
1470
- 'validate_callback' => 'rest_validate_request_arg',
1471
- );
1472
-
1473
- $params['include'] = array(
1474
- 'description' => __( 'Ensure result set includes specific IDs.', 'buddypress' ),
1475
- 'default' => array(),
1476
- 'type' => 'array',
1477
- 'items' => array( 'type' => 'integer' ),
1478
- 'sanitize_callback' => 'wp_parse_id_list',
1479
- 'validate_callback' => 'rest_validate_request_arg',
1480
- );
1481
-
1482
- $params['order'] = array(
1483
- 'description' => __( 'Order sort attribute ascending or descending.', 'buddypress' ),
1484
- 'default' => 'desc',
1485
- 'type' => 'string',
1486
- 'enum' => array( 'asc', 'desc' ),
1487
- 'sanitize_callback' => 'sanitize_key',
1488
- 'validate_callback' => 'rest_validate_request_arg',
1489
- );
1490
-
1491
- $params['after'] = array(
1492
- 'description' => __( 'Limit result set to items published after a given ISO8601 compliant date.', 'buddypress' ),
1493
- 'type' => 'string',
1494
- 'format' => 'date-time',
1495
- 'validate_callback' => 'rest_validate_request_arg',
1496
- );
1497
-
1498
- $params['user_id'] = array(
1499
- 'description' => __( 'Limit result set to items created by a specific user (ID).', 'buddypress' ),
1500
- 'default' => 0,
1501
- 'type' => 'integer',
1502
- 'sanitize_callback' => 'absint',
1503
- 'validate_callback' => 'rest_validate_request_arg',
1504
- );
1505
-
1506
- $params['status'] = array(
1507
- 'description' => __( 'Limit result set to items with a specific status.', 'buddypress' ),
1508
- 'default' => 'ham_only',
1509
- 'type' => 'string',
1510
- 'enum' => array( 'ham_only', 'spam_only', 'all' ),
1511
- 'sanitize_callback' => 'sanitize_key',
1512
- 'validate_callback' => 'rest_validate_request_arg',
1513
- );
1514
-
1515
- $params['scope'] = array(
1516
- 'description' => __( 'Limit result set to items with a specific scope.', 'buddypress' ),
1517
- 'type' => 'string',
1518
- 'enum' => array( 'just-me', 'friends', 'groups', 'favorites', 'mentions' ),
1519
- 'sanitize_callback' => 'sanitize_text_field',
1520
- 'validate_callback' => 'rest_validate_request_arg',
1521
- );
1522
-
1523
- $params['group_id'] = array(
1524
- 'description' => __( 'Limit result set to items created by a specific group.', 'buddypress' ),
1525
- 'default' => 0,
1526
- 'type' => 'integer',
1527
- 'sanitize_callback' => 'absint',
1528
- 'validate_callback' => 'rest_validate_request_arg',
1529
- );
1530
-
1531
- $params['site_id'] = array(
1532
- 'description' => __( 'Limit result set to items created by a specific site.', 'buddypress' ),
1533
- 'default' => 0,
1534
- 'type' => 'integer',
1535
- 'sanitize_callback' => 'absint',
1536
- 'validate_callback' => 'rest_validate_request_arg',
1537
- );
1538
-
1539
- $params['primary_id'] = array(
1540
- 'description' => __( 'Limit result set to items with a specific prime association ID.', 'buddypress' ),
1541
- 'default' => 0,
1542
- 'type' => 'integer',
1543
- 'sanitize_callback' => 'absint',
1544
- 'validate_callback' => 'rest_validate_request_arg',
1545
- );
1546
-
1547
- $params['secondary_id'] = array(
1548
- 'description' => __( 'Limit result set to items with a specific secondary association ID.', 'buddypress' ),
1549
- 'default' => 0,
1550
- 'type' => 'integer',
1551
- 'sanitize_callback' => 'absint',
1552
- 'validate_callback' => 'rest_validate_request_arg',
1553
- );
1554
-
1555
- $params['component'] = array(
1556
- 'description' => __( 'Limit result set to items with a specific active BuddyPress component.', 'buddypress' ),
1557
- 'type' => 'string',
1558
- 'enum' => array_keys( buddypress()->active_components ),
1559
- 'sanitize_callback' => 'sanitize_key',
1560
- 'validate_callback' => 'rest_validate_request_arg',
1561
- );
1562
-
1563
- $params['type'] = array(
1564
- 'description' => __( 'Limit result set to items with a specific activity type.', 'buddypress' ),
1565
- 'type' => 'array',
1566
- 'items' => array(
1567
- 'enum' => array_keys( bp_activity_get_types() ),
1568
- 'type' => 'string',
1569
- ),
1570
- 'sanitize_callback' => 'wp_parse_list',
1571
- 'validate_callback' => 'rest_validate_request_arg',
1572
- );
1573
-
1574
- $params['display_comments'] = array(
1575
- 'description' => __( 'No comments by default, stream for within stream display, threaded for below each activity item.', 'buddypress' ),
1576
- 'default' => '',
1577
- 'type' => 'string',
1578
- 'sanitize_callback' => 'sanitize_key',
1579
- 'validate_callback' => 'rest_validate_request_arg',
1580
- );
1581
-
1582
- /**
1583
- * Filters the collection query params.
1584
- *
1585
- * @param array $params Query params.
1586
- */
1587
- return apply_filters( 'bp_rest_activity_collection_params', $params );
1588
- }
1589
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/css/blocks/latest-activities-rtl.css DELETED
@@ -1,81 +0,0 @@
1
- .bp-latest-activities .components-flex.components-select-control select[multiple] {
2
- height: auto;
3
- padding: 0 8px;
4
- }
5
-
6
- .bp-latest-activities .components-flex.components-select-control select[multiple] + .components-input-control__suffix svg {
7
- display: none;
8
- }
9
-
10
- .bp-latest-activities-block a,
11
- .entry .entry-content .bp-latest-activities-block a {
12
- border: none;
13
- text-decoration: none;
14
- }
15
-
16
- .bp-latest-activities-block .activity-list.item-list blockquote {
17
- padding: 0;
18
- border: none;
19
- }
20
-
21
- .bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini) {
22
- position: relative;
23
- box-shadow: -1px 0 4px rgba(0, 0, 0, 0.15);
24
- padding: 0 1em;
25
- }
26
-
27
- .bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):after, .bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):before {
28
- position: absolute;
29
- right: 15px;
30
- display: block;
31
- width: 0;
32
- height: 0;
33
- border-style: solid;
34
- border-color: transparent;
35
- content: "";
36
- }
37
-
38
- .bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):before {
39
- bottom: -18px;
40
- border-top-color: rgba(0, 0, 0, 0.15);
41
- border-width: 9px;
42
- right: 14px;
43
- }
44
-
45
- .bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):after {
46
- bottom: -16px;
47
- border-top-color: #fff;
48
- border-width: 8px;
49
- }
50
-
51
- .bp-latest-activities-block .activity-list.item-list blockquote .activity-item.mini .avatar {
52
- display: inline-block;
53
- width: 20px;
54
- height: 20px;
55
- vertical-align: middle;
56
- margin-left: 2px;
57
- }
58
-
59
- .bp-latest-activities-block .activity-list.item-list footer {
60
- display: flex;
61
- align-items: center;
62
- }
63
-
64
- .bp-latest-activities-block .activity-list.item-list footer img.avatar {
65
- display: inline-block;
66
- border: none;
67
- margin-left: 0.5em;
68
- }
69
-
70
- .bp-latest-activities-block .activity-list.item-list footer .activity-time-since {
71
- font-size: 90%;
72
- }
73
-
74
- .bp-latest-activities-block .widget-error {
75
- border-right: solid 4px #0b80a4;
76
- box-shadow: -1px 0 4px rgba(0, 0, 0, 0.15);
77
- }
78
-
79
- .bp-latest-activities-block .widget-error p {
80
- padding: 0 1em;
81
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/css/blocks/latest-activities-rtl.min.css DELETED
@@ -1 +0,0 @@
1
- .bp-latest-activities .components-flex.components-select-control select[multiple]{height:auto;padding:0 8px}.bp-latest-activities .components-flex.components-select-control select[multiple]+.components-input-control__suffix svg{display:none}.bp-latest-activities-block a,.entry .entry-content .bp-latest-activities-block a{border:none;text-decoration:none}.bp-latest-activities-block .activity-list.item-list blockquote{padding:0;border:none}.bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini){position:relative;box-shadow:-1px 0 4px rgba(0,0,0,.15);padding:0 1em}.bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):after,.bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):before{position:absolute;right:15px;display:block;width:0;height:0;border-style:solid;border-color:transparent;content:""}.bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):before{bottom:-18px;border-top-color:rgba(0,0,0,.15);border-width:9px;right:14px}.bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):after{bottom:-16px;border-top-color:#fff;border-width:8px}.bp-latest-activities-block .activity-list.item-list blockquote .activity-item.mini .avatar{display:inline-block;width:20px;height:20px;vertical-align:middle;margin-left:2px}.bp-latest-activities-block .activity-list.item-list footer{display:flex;align-items:center}.bp-latest-activities-block .activity-list.item-list footer img.avatar{display:inline-block;border:none;margin-left:.5em}.bp-latest-activities-block .activity-list.item-list footer .activity-time-since{font-size:90%}.bp-latest-activities-block .widget-error{border-right:solid 4px #0b80a4;box-shadow:-1px 0 4px rgba(0,0,0,.15)}.bp-latest-activities-block .widget-error p{padding:0 1em}
 
bp-activity/css/blocks/latest-activities.css DELETED
@@ -1,81 +0,0 @@
1
- .bp-latest-activities .components-flex.components-select-control select[multiple] {
2
- height: auto;
3
- padding: 0 8px;
4
- }
5
-
6
- .bp-latest-activities .components-flex.components-select-control select[multiple] + .components-input-control__suffix svg {
7
- display: none;
8
- }
9
-
10
- .bp-latest-activities-block a,
11
- .entry .entry-content .bp-latest-activities-block a {
12
- border: none;
13
- text-decoration: none;
14
- }
15
-
16
- .bp-latest-activities-block .activity-list.item-list blockquote {
17
- padding: 0;
18
- border: none;
19
- }
20
-
21
- .bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini) {
22
- position: relative;
23
- box-shadow: 1px 0 4px rgba(0, 0, 0, 0.15);
24
- padding: 0 1em;
25
- }
26
-
27
- .bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):after, .bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):before {
28
- position: absolute;
29
- left: 15px;
30
- display: block;
31
- width: 0;
32
- height: 0;
33
- border-style: solid;
34
- border-color: transparent;
35
- content: "";
36
- }
37
-
38
- .bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):before {
39
- bottom: -18px;
40
- border-top-color: rgba(0, 0, 0, 0.15);
41
- border-width: 9px;
42
- left: 14px;
43
- }
44
-
45
- .bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):after {
46
- bottom: -16px;
47
- border-top-color: #fff;
48
- border-width: 8px;
49
- }
50
-
51
- .bp-latest-activities-block .activity-list.item-list blockquote .activity-item.mini .avatar {
52
- display: inline-block;
53
- width: 20px;
54
- height: 20px;
55
- vertical-align: middle;
56
- margin-right: 2px;
57
- }
58
-
59
- .bp-latest-activities-block .activity-list.item-list footer {
60
- display: flex;
61
- align-items: center;
62
- }
63
-
64
- .bp-latest-activities-block .activity-list.item-list footer img.avatar {
65
- display: inline-block;
66
- border: none;
67
- margin-right: 0.5em;
68
- }
69
-
70
- .bp-latest-activities-block .activity-list.item-list footer .activity-time-since {
71
- font-size: 90%;
72
- }
73
-
74
- .bp-latest-activities-block .widget-error {
75
- border-left: solid 4px #0b80a4;
76
- box-shadow: 1px 0 4px rgba(0, 0, 0, 0.15);
77
- }
78
-
79
- .bp-latest-activities-block .widget-error p {
80
- padding: 0 1em;
81
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/css/blocks/latest-activities.min.css DELETED
@@ -1 +0,0 @@
1
- .bp-latest-activities .components-flex.components-select-control select[multiple]{height:auto;padding:0 8px}.bp-latest-activities .components-flex.components-select-control select[multiple]+.components-input-control__suffix svg{display:none}.bp-latest-activities-block a,.entry .entry-content .bp-latest-activities-block a{border:none;text-decoration:none}.bp-latest-activities-block .activity-list.item-list blockquote{padding:0;border:none}.bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini){position:relative;box-shadow:1px 0 4px rgba(0,0,0,.15);padding:0 1em}.bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):after,.bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):before{position:absolute;left:15px;display:block;width:0;height:0;border-style:solid;border-color:transparent;content:""}.bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):before{bottom:-18px;border-top-color:rgba(0,0,0,.15);border-width:9px;left:14px}.bp-latest-activities-block .activity-list.item-list blockquote .activity-item:not(.mini):after{bottom:-16px;border-top-color:#fff;border-width:8px}.bp-latest-activities-block .activity-list.item-list blockquote .activity-item.mini .avatar{display:inline-block;width:20px;height:20px;vertical-align:middle;margin-right:2px}.bp-latest-activities-block .activity-list.item-list footer{display:flex;align-items:center}.bp-latest-activities-block .activity-list.item-list footer img.avatar{display:inline-block;border:none;margin-right:.5em}.bp-latest-activities-block .activity-list.item-list footer .activity-time-since{font-size:90%}.bp-latest-activities-block .widget-error{border-left:solid 4px #0b80a4;box-shadow:1px 0 4px rgba(0,0,0,.15)}.bp-latest-activities-block .widget-error p{padding:0 1em}
 
bp-activity/css/mentions-rtl.css CHANGED
@@ -88,6 +88,7 @@
88
 
89
  .atwho-view {
90
  border-radius: 0;
 
91
  right: 0 !important;
92
  width: 100%;
93
  }
88
 
89
  .atwho-view {
90
  border-radius: 0;
91
+ height: 100%;
92
  right: 0 !important;
93
  width: 100%;
94
  }
bp-activity/css/mentions-rtl.min.css CHANGED
@@ -1 +1 @@
1
- .atwho-view{background:rgba(204,204,204,.8);border-radius:2px;border:1px solid #ccc;box-shadow:0 0 5px rgba(204,204,204,.25),0 0 1px #fff;color:#d84800;display:none;font-family:sans-serif;margin-top:18px;position:absolute;top:0;z-index:1000}.atwho-view{left:0}.atwho-view ul{background:#fff;list-style:none;margin:auto;padding:0}.atwho-view ul li{border-bottom:1px solid #efefef;box-sizing:content-box;cursor:pointer;display:block;font-size:14px;height:20px;line-height:20px;margin:0;overflow:hidden;padding:5px 10px}.atwho-view img{border-radius:2px;float:left;height:20px;margin-top:0;width:20px}.atwho-view strong{background:#efefef;font-weight:700}.atwho-view .username strong{color:#d54e21}.atwho-view small{color:#aaa;float:left;font-size:smaller;font-weight:400;margin:0 40px 0 10px}.atwho-view .cur{background:rgba(239,239,239,.5)}@media (max-width:900px){.atwho-view img{float:right;margin:0 0 0 10px}}@media (max-width:400px){.atwho-view ul li{font-size:16px;line-height:23px;padding:13px}.atwho-view ul li img{height:30px;margin-top:-5px;width:30px}.atwho-view{border-radius:0;right:0!important;width:100%}.atwho-view ul li .username{display:inline-block;margin:-10px 0 0 0;padding:10px 0}.atwho-view ul li small{display:inline-block;margin-right:20px}}
1
+ .atwho-view{background:rgba(204,204,204,.8);border-radius:2px;border:1px solid #ccc;box-shadow:0 0 5px rgba(204,204,204,.25),0 0 1px #fff;color:#d84800;display:none;font-family:sans-serif;margin-top:18px;position:absolute;top:0;z-index:1000}.atwho-view{left:0}.atwho-view ul{background:#fff;list-style:none;margin:auto;padding:0}.atwho-view ul li{border-bottom:1px solid #efefef;box-sizing:content-box;cursor:pointer;display:block;font-size:14px;height:20px;line-height:20px;margin:0;overflow:hidden;padding:5px 10px}.atwho-view img{border-radius:2px;float:left;height:20px;margin-top:0;width:20px}.atwho-view strong{background:#efefef;font-weight:700}.atwho-view .username strong{color:#d54e21}.atwho-view small{color:#aaa;float:left;font-size:smaller;font-weight:400;margin:0 40px 0 10px}.atwho-view .cur{background:rgba(239,239,239,.5)}@media (max-width:900px){.atwho-view img{float:right;margin:0 0 0 10px}}@media (max-width:400px){.atwho-view ul li{font-size:16px;line-height:23px;padding:13px}.atwho-view ul li img{height:30px;margin-top:-5px;width:30px}.atwho-view{border-radius:0;height:100%;right:0!important;width:100%}.atwho-view ul li .username{display:inline-block;margin:-10px 0 0 0;padding:10px 0}.atwho-view ul li small{display:inline-block;margin-right:20px}}
bp-activity/css/mentions.css CHANGED
@@ -90,6 +90,7 @@
90
 
91
  .atwho-view {
92
  border-radius: 0;
 
93
  left: 0 !important;
94
  width: 100%;
95
  }
90
 
91
  .atwho-view {
92
  border-radius: 0;
93
+ height: 100%;
94
  left: 0 !important;
95
  width: 100%;
96
  }
bp-activity/css/mentions.min.css CHANGED
@@ -1 +1 @@
1
- .atwho-view{background:rgba(204,204,204,.8);border-radius:2px;border:1px solid #ccc;box-shadow:0 0 5px rgba(204,204,204,.25),0 0 1px #fff;color:#d84800;display:none;font-family:sans-serif;margin-top:18px;position:absolute;top:0;z-index:1000}.atwho-view{left:0}.atwho-view ul{background:#fff;list-style:none;margin:auto;padding:0}.atwho-view ul li{border-bottom:1px solid #efefef;box-sizing:content-box;cursor:pointer;display:block;font-size:14px;height:20px;line-height:20px;margin:0;overflow:hidden;padding:5px 10px}.atwho-view img{border-radius:2px;float:right;height:20px;margin-top:0;width:20px}.atwho-view strong{background:#efefef;font-weight:700}.atwho-view .username strong{color:#d54e21}.atwho-view small{color:#aaa;float:right;font-size:smaller;font-weight:400;margin:0 10px 0 40px}.atwho-view .cur{background:rgba(239,239,239,.5)}@media (max-width:900px){.atwho-view img{float:left;margin:0 10px 0 0}}@media (max-width:400px){.atwho-view ul li{font-size:16px;line-height:23px;padding:13px}.atwho-view ul li img{height:30px;margin-top:-5px;width:30px}.atwho-view{border-radius:0;left:0!important;width:100%}.atwho-view ul li .username{display:inline-block;margin:-10px 0 0 0;padding:10px 0}.atwho-view ul li small{display:inline-block;margin-left:20px}}
1
+ .atwho-view{background:rgba(204,204,204,.8);border-radius:2px;border:1px solid #ccc;box-shadow:0 0 5px rgba(204,204,204,.25),0 0 1px #fff;color:#d84800;display:none;font-family:sans-serif;margin-top:18px;position:absolute;top:0;z-index:1000}.atwho-view{left:0}.atwho-view ul{background:#fff;list-style:none;margin:auto;padding:0}.atwho-view ul li{border-bottom:1px solid #efefef;box-sizing:content-box;cursor:pointer;display:block;font-size:14px;height:20px;line-height:20px;margin:0;overflow:hidden;padding:5px 10px}.atwho-view img{border-radius:2px;float:right;height:20px;margin-top:0;width:20px}.atwho-view strong{background:#efefef;font-weight:700}.atwho-view .username strong{color:#d54e21}.atwho-view small{color:#aaa;float:right;font-size:smaller;font-weight:400;margin:0 10px 0 40px}.atwho-view .cur{background:rgba(239,239,239,.5)}@media (max-width:900px){.atwho-view img{float:left;margin:0 10px 0 0}}@media (max-width:400px){.atwho-view ul li{font-size:16px;line-height:23px;padding:13px}.atwho-view ul li img{height:30px;margin-top:-5px;width:30px}.atwho-view{border-radius:0;height:100%;left:0!important;width:100%}.atwho-view ul li .username{display:inline-block;margin:-10px 0 0 0;padding:10px 0}.atwho-view ul li small{display:inline-block;margin-left:20px}}
bp-activity/js/blocks/embed-activity.js DELETED
@@ -1,20 +0,0 @@
1
- parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"DCTP":[function(require,module,exports) {
2
- function r(r){if(Array.isArray(r))return r}module.exports=r;
3
- },{}],"LoeL":[function(require,module,exports) {
4
- function r(r,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(r)){var e=[],n=!0,o=!1,l=void 0;try{for(var i,u=r[Symbol.iterator]();!(n=(i=u.next()).done)&&(e.push(i.value),!t||e.length!==t);n=!0);}catch(a){o=!0,l=a}finally{try{n||null==u.return||u.return()}finally{if(o)throw l}}return e}}module.exports=r;
5
- },{}],"jEQo":[function(require,module,exports) {
6
- function n(n,r){(null==r||r>n.length)&&(r=n.length);for(var e=0,l=new Array(r);e<r;e++)l[e]=n[e];return l}module.exports=n;
7
- },{}],"Dbv9":[function(require,module,exports) {
8
- var r=require("./arrayLikeToArray");function t(t,e){if(t){if("string"==typeof t)return r(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(o):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?r(t,e):void 0}}module.exports=t;
9
- },{"./arrayLikeToArray":"jEQo"}],"MWEO":[function(require,module,exports) {
10
- function e(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}module.exports=e;
11
- },{}],"DERy":[function(require,module,exports) {
12
- var r=require("./arrayWithHoles"),e=require("./iterableToArrayLimit"),t=require("./unsupportedIterableToArray"),i=require("./nonIterableRest");function u(u,a){return r(u)||e(u,a)||t(u,a)||i()}module.exports=u;
13
- },{"./arrayWithHoles":"DCTP","./iterableToArrayLimit":"LoeL","./unsupportedIterableToArray":"Dbv9","./nonIterableRest":"MWEO"}],"Sjre":[function(require,module,exports) {
14
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=t(require("@babel/runtime/helpers/slicedToArray"));function t(e){return e&&e.__esModule?e:{default:e}}var r=wp,i=r.element,l=i.createElement,o=i.Fragment,a=i.useState,n=r.i18n.__,s=r.components,d=s.Placeholder,u=s.Disabled,c=s.SandBox,p=s.Button,b=s.ExternalLink,m=s.Spinner,y=s.ToolbarGroup,v=s.ToolbarButton,h=r.compose.compose,f=r.data.withSelect,_=r.blockEditor,g=_.RichText,w=_.BlockControls,k=bp,E=k.blockData.embedScriptURL,x=function(t){var r=t.attributes,i=t.setAttributes,s=t.isSelected,h=t.preview,f=t.fetching,_=r.url,k=r.caption,x=n("BuddyPress Activity URL","buddypress"),P=a(_),L=(0,e.default)(P,2),N=L[0],R=L[1],S=a(!_),B=(0,e.default)(S,2),T=B[0],U=B[1],A=l(w,null,l(y,null,l(v,{icon:"edit",title:n("Edit URL","buddypress"),onClick:function(e){e&&e.preventDefault(),U(!0)}})));return T?l(d,{icon:"buddicons-activity",label:x,className:"wp-block-embed",instructions:n("Paste the link to the activity content you want to display on your site.","buddypress")},l("form",{onSubmit:function(e){e&&e.preventDefault(),U(!1),i({url:N})}},l("input",{type:"url",value:N||"",className:"components-placeholder__input","aria-label":x,placeholder:n("Enter URL to embed here…","buddypress"),onChange:function(e){return R(e.target.value)}}),l(p,{isPrimary:!0,type:"submit"},n("Embed","buddypress"))),l("div",{className:"components-placeholder__learn-more"},l(b,{href:n("https://codex.buddypress.org/activity-embeds/")},n("Learn more about activity embeds","buddypress")))):f?l("div",{className:"wp-block-embed is-loading"},l(m,null),l("p",null,n("Embedding…","buddypress"))):h&&h.x_buddypress&&"activity"===h.x_buddypress?l(o,null,!T&&A,l("figure",{className:"wp-block-embed is-type-bp-activity"},l("div",{className:"wp-block-embed__wrapper"},l(u,null,l(c,{html:h&&h.html?h.html:"",scripts:[E]}))),(!g.isEmpty(k)||s)&&l(g,{tagName:"figcaption",placeholder:n("Write caption…","buddypress"),value:k,onChange:function(e){return i({caption:e})},inlineToolbar:!0}))):l(o,null,A,l(d,{icon:"buddicons-activity",label:x},l("p",{className:"components-placeholder__error"},n("The URL you provided is not a permalink to a public BuddyPress Activity. Please use another URL.","buddypress"))))},P=h([f(function(e,t){var r=t.attributes.url,i=e("core"),l=i.getEmbedPreview,o=i.isRequestingEmbedPreview;return{preview:!!r&&l(r),fetching:!!r&&o(r)}})])(x),L=P;exports.default=L;
15
- },{"@babel/runtime/helpers/slicedToArray":"DERy"}],"zmBI":[function(require,module,exports) {
16
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=wp,t=e.blockEditor.RichText,a=e.element.createElement,r=function(e){var r=e.attributes,i=r.url,c=r.caption;return i?a("figure",{className:"wp-block-embed is-type-bp-activity"},a("div",{className:"wp-block-embed__wrapper"},"\n".concat(i,"\n")),!t.isEmpty(c)&&a(t.Content,{tagName:"figcaption",value:c})):null},i=r;exports.default=i;
17
- },{}],"hBDw":[function(require,module,exports) {
18
- "use strict";var t=i(require("./embed-activity/edit")),e=i(require("./embed-activity/save"));function i(t){return t&&t.__esModule?t:{default:t}}var r=wp,s=r.i18n.__,d=r.blocks.registerBlockType;d("bp/embed-activity",{title:s("Embed an activity","buddypress"),description:s("Add a block that displays the activity content pulled from this or other community sites.","buddypress"),icon:{background:"#fff",foreground:"#d84800",src:"buddicons-activity"},category:"buddypress",attributes:{url:{type:"string"},caption:{type:"string",source:"html",selector:"figcaption"}},supports:{align:!0},edit:t.default,save:e.default});
19
- },{"./embed-activity/edit":"Sjre","./embed-activity/save":"zmBI"}]},{},["hBDw"], null)
20
- //# sourceMappingURL=/bp-activity/js/blocks/embed-activity.js.map
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/js/blocks/embed-activity.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../node_modules/@babel/runtime/helpers/arrayWithHoles.js","../../../../../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js","../../../../../node_modules/@babel/runtime/helpers/arrayLikeToArray.js","../../../../../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js","../../../../../node_modules/@babel/runtime/helpers/nonIterableRest.js","../../../../../node_modules/@babel/runtime/helpers/slicedToArray.js","bp-activity/js/blocks/embed-activity/edit.js","bp-activity/js/blocks/embed-activity/save.js","bp-activity/js/blocks/embed-activity.js"],"names":["editEmbedActivityBlock","wp","element","createElement","Fragment","useState","__","i18n","components","Placeholder","Disabled","SandBox","Button","ExternalLink","Spinner","ToolbarGroup","ToolbarButton","compose","withSelect","data","blockEditor","RichText","BlockControls","bp","embedScriptURL","blockData","EditEmbedActivity","attributes","setAttributes","isSelected","preview","fetching","url","caption","label","value","setURL","isEditingURL","setIsEditingURL","editToolbar","event","preventDefault","target","html","isEmpty","select","ownProps","getEmbedPreview","isRequestingEmbedPreview","saveEmbedActivityBlock","registerBlockType","blocks","title","description","icon","background","foreground","src","category","type","source","selector","supports","align","edit","save"],"mappings":";AAAA,SAAA,EAAA,GACA,GAAA,MAAA,QAAA,GAAA,OAAA,EAGA,OAAA,QAAA;;ACJA,SAAA,EAAA,EAAA,GACA,GAAA,oBAAA,QAAA,OAAA,YAAA,OAAA,GAAA,CACA,IAAA,EAAA,GACA,GAAA,EACA,GAAA,EACA,OAAA,EAEA,IACA,IAAA,IAAA,EAAA,EAAA,EAAA,OAAA,cAAA,GAAA,EAAA,EAAA,QAAA,QACA,EAAA,KAAA,EAAA,QAEA,GAAA,EAAA,SAAA,GAHA,GAAA,IAKA,MAAA,GACA,GAAA,EACA,EAAA,EACA,QACA,IACA,GAAA,MAAA,EAAA,QAAA,EAAA,SACA,QACA,GAAA,EAAA,MAAA,GAIA,OAAA,GAGA,OAAA,QAAA;;AC3BA,SAAA,EAAA,EAAA,IACA,MAAA,GAAA,EAAA,EAAA,UAAA,EAAA,EAAA,QAEA,IAAA,IAAA,EAAA,EAAA,EAAA,IAAA,MAAA,GAAA,EAAA,EAAA,IACA,EAAA,GAAA,EAAA,GAGA,OAAA,EAGA,OAAA,QAAA;;ACVA,IAAA,EAAA,QAAA,sBAEA,SAAA,EAAA,EAAA,GACA,GAAA,EAAA,CACA,GAAA,iBAAA,EAAA,OAAA,EAAA,EAAA,GACA,IAAA,EAAA,OAAA,UAAA,SAAA,KAAA,GAAA,MAAA,GAAA,GAEA,MADA,WAAA,GAAA,EAAA,cAAA,EAAA,EAAA,YAAA,MACA,QAAA,GAAA,QAAA,EAAA,MAAA,KAAA,GACA,cAAA,GAAA,2CAAA,KAAA,GAAA,EAAA,EAAA,QAAA,GAGA,OAAA,QAAA;;ACXA,SAAA,IACA,MAAA,IAAA,UAAA,6IAGA,OAAA,QAAA;;ACJA,IAAA,EAAA,QAAA,oBAEA,EAAA,QAAA,0BAEA,EAAA,QAAA,gCAEA,EAAA,QAAA,qBAEA,SAAA,EAAA,EAAA,GACA,OAAA,EAAA,IAAA,EAAA,EAAA,IAAA,EAAA,EAAA,IAAA,IAGA,OAAA,QAAA;;AC+KeA,aAAAA,OAAAA,eAAAA,QAAAA,aAAAA,CAAAA,OAAAA,IAAAA,QAAAA,aAAAA,EAAAA,IAAAA,EAAAA,EAAAA,QAAAA,yCAAAA,SAAAA,EAAAA,GAAAA,OAAAA,GAAAA,EAAAA,WAAAA,EAAAA,CAAAA,QAAAA,GAxLf,IA6BIC,EAAAA,GA5BHC,EAAAA,EAAAA,QACCC,EAAAA,EAAAA,cACAC,EAAAA,EAAAA,SACAC,EAAAA,EAAAA,SAGAC,EADDC,EAAAA,KACCD,GAEDE,EAAAA,EAAAA,WACCC,EAAAA,EAAAA,YACAC,EAAAA,EAAAA,SACAC,EAAAA,EAAAA,QACAC,EAAAA,EAAAA,OACAC,EAAAA,EAAAA,aACAC,EAAAA,EAAAA,QACAC,EAAAA,EAAAA,aACAC,EAAAA,EAAAA,cAGAC,EADDA,EAAAA,QACCA,QAGAC,EADDC,EAAAA,KACCD,WAEDE,EAAAA,EAAAA,YACCC,EAAAA,EAAAA,SACAC,EAAAA,EAAAA,cAWEC,EAAAA,GAFFC,EADDC,EAAAA,UACCD,eAIIE,EAAoB,SAMnB,GALNC,IAAAA,EAAAA,EAAAA,WACAC,EAAAA,EAAAA,cACAC,EAAAA,EAAAA,WACAC,EAAAA,EAAAA,QACAC,EAAAA,EAAAA,SAEQC,EAAiBL,EAAjBK,IAAKC,EAAYN,EAAZM,QACPC,EAAQ5B,EAAI,0BAA2B,cACnBD,EAAAA,EAAU2B,GAApC,GAAA,EAAA,EAAA,SAAA,EAAA,GAAQG,EAAR,EAAA,GAAeC,EAAf,EAAA,GAC0C/B,EAAAA,GAAY2B,GAAtD,GAAA,EAAA,EAAA,SAAA,EAAA,GAAQK,EAAR,EAAA,GAAsBC,EAAtB,EAAA,GAmBMC,EACL,EAAC,EACA,KAAA,EAAC,EACA,KAAA,EAAC,EAAD,CACC,KAAK,OACL,MAAQjC,EAAI,WAAY,cACxB,QAdyB,SAAEkC,GACzBA,GACJA,EAAMC,iBAGPH,GAAiB,QAebD,OAAAA,EAEH,EAAC,EAAD,CACC,KAAK,qBACL,MAAQH,EACR,UAAU,iBACV,aAAe5B,EAAI,2EAA4E,eAE/F,EAAA,OAAA,CAAM,SArCQ,SAAEkC,GACbA,GACJA,EAAMC,iBAGPH,GAAiB,GACjBV,EAAe,CAAEI,IAAKG,MAgCnB,EAAA,QAAA,CACC,KAAK,MACL,MAAQA,GAAS,GACjB,UAAU,gCACGD,aAAAA,EACb,YAAc5B,EAAI,2BAA4B,cAC9C,SAAW,SAAEkC,GAAWJ,OAAAA,EAAQI,EAAME,OAAOP,UAE9C,EAAC,EAAD,CAAQ,WAAR,EAAkB,KAAK,UACpB7B,EAAI,QAAS,gBAGjB,EAAA,MAAA,CAAK,UAAU,sCACd,EAAC,EAAD,CACC,KAAOA,EACN,kDAGCA,EAAI,mCAAoC,iBAO1CyB,EAEH,EAAA,MAAA,CAAK,UAAU,6BACd,EAAC,EADF,MAEC,EAAKzB,IAAAA,KAAAA,EAAI,aAAc,gBAKnBwB,GAAaA,EAAO,cAAoB,aAAeA,EAAO,aAiBpE,EAAC,EACE,MAAEO,GAAgBE,EACpB,EAAA,SAAA,CAAQ,UAAU,sCACjB,EAAA,MAAA,CAAK,UAAU,2BACd,EAAC,EACA,KAAA,EAAC,EAAD,CACC,KAAOT,GAAWA,EAAQa,KAAOb,EAAQa,KAAO,GAChD,QAAU,CAAEnB,SAITH,EAASuB,QAASX,IAAaJ,IACpC,EAAC,EAAD,CACC,QAAQ,aACR,YAAcvB,EAAI,iBAAkB,cACpC,MAAQ2B,EACR,SAAW,SAAEE,GAAWP,OAAAA,EAAe,CAAEK,QAASE,KAClD,eAAa,MAhChB,EAAC,EACEI,KAAAA,EACF,EAAC,EAAD,CACC,KAAK,qBACL,MAAQL,GAER,EAAA,IAAA,CAAG,UAAU,iCACV5B,EAAI,mGAAoG,kBAiC1GN,EAAyBiB,EAAS,CACvCC,EAAY,SAAE2B,EAAQC,GACbd,IAAAA,EAAQc,EAASnB,WAAjBK,IAIJa,EAAAA,EAAQ,QAFXE,EAAAA,EAAAA,gBACAC,EAAAA,EAAAA,yBAMM,MAAA,CACNlB,UAJkBE,GAAOe,EAAiBf,GAK1CD,WAJmBC,GAAOgB,EAA0BhB,OATxBf,CAgB1BS,GAEU1B,EAAAA,EAAAA,QAAAA,QAAAA;;ACvJAiD,aAAAA,OAAAA,eAAAA,QAAAA,aAAAA,CAAAA,OAAAA,IAAAA,QAAAA,aAAAA,EAjCf,IAOIhD,EAAAA,GALFoB,EADDD,EAAAA,YACCC,SAGAlB,EADDD,EAAAA,QACCC,cAII8C,EAAyB,SAAsB,GAAlBtB,IAAAA,EAAAA,EAAAA,WAC1BK,EAAiBL,EAAjBK,IAAKC,EAAYN,EAAZM,QAER,OAAED,EAKP,EAAA,SAAA,CAAQ,UAAU,sCACjB,EAAA,MAAA,CAAK,UAAU,2BAERA,KAAAA,OAAAA,EAFP,QAKIX,EAASuB,QAASX,IACrB,EAAC,EAAS,QAAV,CACC,QAAQ,aACR,MAAQA,KAbH,MAoBMgB,EAAAA,EAAAA,QAAAA,QAAAA;;AClBf,aAHA,IAAA,EAAA,EAAA,QAAA,0BACA,EAAA,EAAA,QAAA,0BAEA,SAAA,EAAA,GAAA,OAAA,GAAA,EAAA,WAAA,EAAA,CAAA,QAAA,GAfA,IAOIhD,EAAAA,GALFK,EADDC,EAAAA,KACCD,GAGA4C,EADDC,EAAAA,OACCD,kBAUFA,EAAmB,oBAAqB,CACvCE,MAAO9C,EAAI,oBAAqB,cAChC+C,YAAa/C,EAAI,4FAA6F,cAC9GgD,KAAM,CACLC,WAAY,OACZC,WAAY,UACZC,IAAK,sBAENC,SAAU,aACV/B,WAAY,CACXK,IAAK,CACJ2B,KAAM,UAEP1B,QAAS,CACR0B,KAAM,SACNC,OAAQ,OACRC,SAAU,eAGZC,SAAU,CACTC,OAAO,GAERC,KAAMhE,EAtBiC,QAuBvCiE,KAAMhB,EAAAA","file":"embed-activity.js","sourceRoot":"../src/js","sourcesContent":["function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}\n\nmodule.exports = _arrayWithHoles;","function _iterableToArrayLimit(arr, i) {\n if (typeof Symbol === \"undefined\" || !(Symbol.iterator in Object(arr))) return;\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"] != null) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n}\n\nmodule.exports = _iterableToArrayLimit;","function _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n\n for (var i = 0, arr2 = new Array(len); i < len; i++) {\n arr2[i] = arr[i];\n }\n\n return arr2;\n}\n\nmodule.exports = _arrayLikeToArray;","var arrayLikeToArray = require(\"./arrayLikeToArray\");\n\nfunction _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(n);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);\n}\n\nmodule.exports = _unsupportedIterableToArray;","function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n\nmodule.exports = _nonIterableRest;","var arrayWithHoles = require(\"./arrayWithHoles\");\n\nvar iterableToArrayLimit = require(\"./iterableToArrayLimit\");\n\nvar unsupportedIterableToArray = require(\"./unsupportedIterableToArray\");\n\nvar nonIterableRest = require(\"./nonIterableRest\");\n\nfunction _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();\n}\n\nmodule.exports = _slicedToArray;","/**\n * WordPress dependencies.\n */\nconst {\n\telement: {\n\t\tcreateElement,\n\t\tFragment,\n\t\tuseState,\n\t},\n\ti18n: {\n\t\t__,\n\t},\n\tcomponents: {\n\t\tPlaceholder,\n\t\tDisabled,\n\t\tSandBox,\n\t\tButton,\n\t\tExternalLink,\n\t\tSpinner,\n\t\tToolbarGroup,\n\t\tToolbarButton,\n\t},\n\tcompose: {\n\t\tcompose,\n\t},\n\tdata: {\n\t\twithSelect,\n\t},\n\tblockEditor: {\n\t\tRichText,\n\t\tBlockControls,\n\t}\n} = wp;\n\n/**\n * BuddyPress dependencies.\n */\n const {\n\tblockData: {\n\t\tembedScriptURL,\n\t}\n} = bp;\n\nconst EditEmbedActivity = ( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tpreview,\n\tfetching\n} ) => {\n\tconst { url, caption } = attributes;\n\tconst label = __( 'BuddyPress Activity URL', 'buddypress' );\n\tconst [ value, setURL ] = useState( url );\n\tconst [ isEditingURL, setIsEditingURL ] = useState( ! url );\n\n\tconst onSubmit = ( event ) => {\n\t\tif ( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: value } );\n\t};\n\n\tconst switchBackToURLInput = ( event ) => {\n\t\tif ( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\tsetIsEditingURL( true );\n\t};\n\n\tconst editToolbar = (\n\t\t<BlockControls>\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\ticon=\"edit\"\n\t\t\t\t\ttitle={ __( 'Edit URL', 'buddypress' ) }\n\t\t\t\t\tonClick={ switchBackToURLInput }\n\t\t\t\t/>\n\t\t\t</ToolbarGroup>\n\t\t</BlockControls>\n\t);\n\n\tif ( isEditingURL ) {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\ticon=\"buddicons-activity\"\n\t\t\t\tlabel={ label }\n\t\t\t\tclassName=\"wp-block-embed\"\n\t\t\t\tinstructions={ __( 'Paste the link to the activity content you want to display on your site.', 'buddypress' ) }\n\t\t\t>\n\t\t\t\t<form onSubmit={ onSubmit }>\n\t\t\t\t\t<input\n\t\t\t\t\t\ttype=\"url\"\n\t\t\t\t\t\tvalue={ value || '' }\n\t\t\t\t\t\tclassName=\"components-placeholder__input\"\n\t\t\t\t\t\taria-label={ label }\n\t\t\t\t\t\tplaceholder={ __( 'Enter URL to embed here…', 'buddypress' ) }\n\t\t\t\t\t\tonChange={ ( event ) => setURL( event.target.value ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<Button isPrimary type=\"submit\">\n\t\t\t\t\t\t{ __( 'Embed', 'buddypress' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</form>\n\t\t\t\t<div className=\"components-placeholder__learn-more\">\n\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t'https://codex.buddypress.org/activity-embeds/'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Learn more about activity embeds', 'buddypress' ) }\n\t\t\t\t\t</ExternalLink>\n\t\t\t\t</div>\n\t\t\t</Placeholder>\n\t\t);\n\t}\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<div className=\"wp-block-embed is-loading\">\n\t\t\t\t<Spinner />\n\t\t\t\t<p>{ __( 'Embedding…', 'buddypress' ) }</p>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( ! preview || ! preview['x_buddypress'] || 'activity' !== preview['x_buddypress'] ) {\n\t\treturn (\n\t\t\t<Fragment>\n\t\t\t\t{ editToolbar }\n\t\t\t\t<Placeholder\n\t\t\t\t\ticon=\"buddicons-activity\"\n\t\t\t\t\tlabel={ label }\n\t\t\t\t>\n\t\t\t\t\t<p className=\"components-placeholder__error\">\n\t\t\t\t\t\t{ __( 'The URL you provided is not a permalink to a public BuddyPress Activity. Please use another URL.', 'buddypress' ) }\n\t\t\t\t\t</p>\n\t\t\t\t</Placeholder>\n\t\t\t</Fragment>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Fragment>\n\t\t\t{ ! isEditingURL && editToolbar }\n\t\t\t<figure className=\"wp-block-embed is-type-bp-activity\">\n\t\t\t\t<div className=\"wp-block-embed__wrapper\">\n\t\t\t\t\t<Disabled>\n\t\t\t\t\t\t<SandBox\n\t\t\t\t\t\t\thtml={ preview && preview.html ? preview.html : '' }\n\t\t\t\t\t\t\tscripts={ [ embedScriptURL ] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Disabled>\n\t\t\t\t</div>\n\t\t\t\t{ ( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\tplaceholder={ __( 'Write caption…', 'buddypress' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) => setAttributes( { caption: value } ) }\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</figure>\n\t\t</Fragment>\n\t);\n}\n\nconst editEmbedActivityBlock = compose( [\n\twithSelect( ( select, ownProps ) => {\n\t\tconst { url } = ownProps.attributes;\n\t\tconst {\n\t\t\tgetEmbedPreview,\n\t\t\tisRequestingEmbedPreview,\n\t\t} = select( 'core' );\n\n\t\tconst preview = !! url && getEmbedPreview( url );\n\t\tconst fetching = !! url && isRequestingEmbedPreview( url );\n\n\t\treturn {\n\t\t\tpreview: preview,\n\t\t\tfetching: fetching,\n\t\t};\n\t} ),\n] )( EditEmbedActivity );\n\nexport default editEmbedActivityBlock;\n","/**\n * WordPress dependencies.\n */\nconst {\n\tblockEditor: {\n\t\tRichText,\n\t},\n\telement: {\n\t\tcreateElement,\n\t},\n} = wp;\n\nconst saveEmbedActivityBlock = ( { attributes } ) => {\n\tconst { url, caption } = attributes;\n\n\tif ( ! url ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t<figure className=\"wp-block-embed is-type-bp-activity\">\n\t\t<div className=\"wp-block-embed__wrapper\">\n\t\t{\n\t\t\t`\\n${ url }\\n` /* URL needs to be on its own line. */\n\t\t}\n\t\t</div>\n\t\t{ ! RichText.isEmpty( caption ) && (\n\t\t\t<RichText.Content\n\t\t\t\ttagName=\"figcaption\"\n\t\t\t\tvalue={ caption }\n\t\t\t/>\n\t\t) }\n\t</figure>\n\t);\n};\n\nexport default saveEmbedActivityBlock;\n","/**\n * WordPress dependencies.\n */\nconst {\n\ti18n: {\n\t\t__,\n\t},\n\tblocks: {\n\t\tregisterBlockType,\n\t},\n} = wp;\n\n/**\n * Internal dependencies.\n */\nimport editEmbedActivityBlock from './embed-activity/edit';\nimport saveEmbedActivityBlock from './embed-activity/save';\n\nregisterBlockType( 'bp/embed-activity', {\n\ttitle: __( 'Embed an activity', 'buddypress' ),\n\tdescription: __( 'Add a block that displays the activity content pulled from this or other community sites.', 'buddypress' ),\n\ticon: {\n\t\tbackground: '#fff',\n\t\tforeground: '#d84800',\n\t\tsrc: 'buddicons-activity',\n\t},\n\tcategory: 'buddypress',\n\tattributes: {\n\t\turl: {\n\t\t\ttype: 'string',\n\t\t},\n\t\tcaption: {\n\t\t\ttype: 'string',\n\t\t\tsource: 'html',\n\t\t\tselector: 'figcaption',\n\t\t},\n\t},\n\tsupports: {\n\t\talign: true,\n\t},\n\tedit: editEmbedActivityBlock,\n\tsave: saveEmbedActivityBlock,\n} );\n"]}
 
bp-activity/js/blocks/latest-activities.js DELETED
@@ -1,8 +0,0 @@
1
- parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"DIzr":[function(require,module,exports) {
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=wp,t=e.blockEditor.InspectorControls,l=e.components,n=l.Disabled,i=l.PanelBody,o=l.RangeControl,s=l.SelectControl,a=l.TextControl,r=e.element,u=r.Fragment,p=r.createElement,d=e.i18n.__,c=bp,b=c.blockComponents.ServerSideRender,m=c.blockData,v=m.currentPostId,y=m.activityTypes,x=function(e){var l=e.attributes,r=e.setAttributes,c=l.postId,m=l.maxActivities,x=l.type,C=l.title,f=v(),g=y();return!c&&f&&r({postId:f}),p(u,null,p(t,null,p(i,{title:d("Settings","buddypress"),initialOpen:!0,className:"bp-latest-activities"},p(a,{label:d("Title","buddypress"),value:C,onChange:function(e){r({title:e})}}),p(o,{label:d("Maximum amount to display","buddypress"),value:m,onChange:function(e){return r({maxActivities:e})},min:1,max:10,required:!0}),p(s,{multiple:!0,label:d("Type","buddypress"),value:x,options:g,onChange:function(e){r({type:e})}}))),p(n,null,p(b,{block:"bp/latest-activities",attributes:l})))},C=x;exports.default=C;
3
- },{}],"yqpU":[function(require,module,exports) {
4
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=wp,e=t.blocks.createBlock,a={from:[{type:"block",blocks:["core/legacy-widget"],isMatch:function(t){var e=t.idBase,a=t.instance;return!(null==a||!a.raw)&&"bp_latest_activities"===e},transform:function(t){for(var a,i=t.instance,r=/i:\d*;s:\d*:"(.*?)";/gim,s=[];null!==(a=r.exec(i.raw.type));)a.index===r.lastIndex&&r.lastIndex++,a.forEach(function(t,e){1===e&&s.push(t)});return e("bp/latest-activities",{title:i.raw.title,maxActivities:parseInt(i.raw.max,10),type:s})}}]},i=a;exports.default=i;
5
- },{}],"q3eE":[function(require,module,exports) {
6
- "use strict";var t=i(require("./latest-activities/edit")),e=i(require("./latest-activities/transforms"));function i(t){return t&&t.__esModule?t:{default:t}}var s=wp,r=s.blocks.registerBlockType,a=s.i18n.__;r("bp/latest-activities",{title:a("Latest Activities","buddypress"),description:a("Display the latest updates of the post author (when used into a page or post), of the displayed user (when viewing their profile) or of your community.","buddypress"),icon:{background:"#fff",foreground:"#d84800",src:"buddicons-activity"},category:"buddypress",attributes:{title:{type:"string",default:a("Latest updates","buddypress")},maxActivities:{type:"number",default:5},type:{type:"array",default:["activity_update"]},postId:{type:"number",default:0}},edit:t.default,transforms:e.default});
7
- },{"./latest-activities/edit":"DIzr","./latest-activities/transforms":"yqpU"}]},{},["q3eE"], null)
8
- //# sourceMappingURL=/bp-activity/js/blocks/latest-activities.js.map
 
 
 
 
 
 
 
 
bp-activity/js/blocks/latest-activities.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["bp-activity/js/blocks/latest-activities/edit.js","bp-activity/js/blocks/latest-activities/transforms.js","bp-activity/js/blocks/latest-activities.js"],"names":["editDynamicActivitiesBlock","wp","InspectorControls","blockEditor","components","Disabled","PanelBody","RangeControl","SelectControl","TextControl","element","Fragment","createElement","__","i18n","bp","ServerSideRender","blockComponents","blockData","currentPostId","activityTypes","attributes","setAttributes","postId","maxActivities","type","title","post","types","text","value","option","transforms","createBlock","blocks","from","isMatch","idBase","instance","raw","transform","matches","regex","exec","index","lastIndex","forEach","match","groupIndex","push","parseInt","max","registerBlockType","description","icon","background","foreground","src","category","default","edit"],"mappings":";AAoFeA,aAAAA,OAAAA,eAAAA,QAAAA,aAAAA,CAAAA,OAAAA,IAAAA,QAAAA,aAAAA,EAjFf,IAkBIC,EAAAA,GAhBFC,EADDC,EAAAA,YACCD,kBAEDE,EAAAA,EAAAA,WACCC,EAAAA,EAAAA,SACAC,EAAAA,EAAAA,UACAC,EAAAA,EAAAA,aACAC,EAAAA,EAAAA,cACAC,EAAAA,EAAAA,YAEDC,EAAAA,EAAAA,QACCC,EAAAA,EAAAA,SACAC,EAAAA,EAAAA,cAGAC,EADDC,EAAAA,KACCD,GAeEE,EAAAA,GANFC,EADDC,EAAAA,gBACCD,iBAEDE,EAAAA,EAAAA,UACCC,EAAAA,EAAAA,cACAC,EAAAA,EAAAA,cAIIpB,EAA6B,SAAqC,GAAjCqB,IAAAA,EAAAA,EAAAA,WAAYC,EAAAA,EAAAA,cAC1CC,EAAuCF,EAAvCE,OAAQC,EAA+BH,EAA/BG,cAAeC,EAAgBJ,EAAhBI,KAAMC,EAAUL,EAAVK,MAC/BC,EAAOR,IACPS,EAAQR,IAOb,OALMG,GAAUI,GAChBL,EAAe,CAAEC,OAAQI,IAIzB,EAAC,EACA,KAAA,EAAC,EACA,KAAA,EAAC,EAAD,CAAW,MAAQd,EAAI,WAAY,cAAiB,aAAc,EAAO,UAAU,wBAClF,EAAC,EAAD,CACC,MAAQA,EAAI,QAAS,cACrB,MAAQa,EACR,SAAW,SAAEG,GACZP,EAAe,CAAEI,MAAOG,OAG1B,EAAC,EAAD,CACC,MAAQhB,EAAI,4BAA6B,cACzC,MAAQW,EACR,SAAW,SAAEM,GACZR,OAAAA,EAAe,CAAEE,cAAeM,KAEjC,IAAM,EACN,IAAM,GACN,UAAQ,IAET,EAAC,EAAD,CACC,UADD,EAEC,MAAQjB,EAAI,OAAQ,cACpB,MAAQY,EACR,QAAUG,EACV,SAAW,SAAEG,GACZT,EAAe,CAAEG,KAAMM,SAK3B,EAAC,EACA,KAAA,EAAC,EAAD,CAAkB,MAAM,uBAAuB,WAAaV,OAMjDrB,EAAAA,EAAAA,QAAAA,QAAAA;;AC/BAgC,aAAAA,OAAAA,eAAAA,QAAAA,aAAAA,CAAAA,OAAAA,IAAAA,QAAAA,aAAAA,EAlDf,IAII/B,EAAAA,GAFFgC,EADDC,EAAAA,OACCD,YASID,EAAa,CAClBG,KAAM,CACL,CACCV,KAAM,QACNS,OAAQ,CAAE,sBACVE,QAAS,SAA4B,GAAxBC,IAAAA,EAAAA,EAAAA,OAAQC,EAAAA,EAAAA,SACf,QAAEA,MAAAA,IAAAA,EAAUC,MAIC,yBAAXF,GAERG,UAAW,SAAoB,GAKtB,IALMF,IAGVG,EAHUH,EAAAA,EAAAA,SACRI,EAAQ,0BACVd,EAAQ,GAG8C,QAAhDa,EAAUC,EAAMC,KAAML,EAASC,IAAId,QACvCgB,EAAQG,QAAUF,EAAMG,WAC5BH,EAAMG,YAGPJ,EAAQK,QAAS,SAAEC,EAAOC,GACpB,IAAMA,GACVpB,EAAMqB,KAAMF,KAKRd,OAAAA,EAAa,uBAAwB,CAC3CP,MAAOY,EAASC,IAAIb,MACpBF,cAAe0B,SAAUZ,EAASC,IAAIY,IAAK,IAC3C1B,KAAMG,QAOII,EAAAA,EAAAA,QAAAA,QAAAA;;ACnCf,aAHA,IAAA,EAAA,EAAA,QAAA,6BACA,EAAA,EAAA,QAAA,mCAEA,SAAA,EAAA,GAAA,OAAA,GAAA,EAAA,WAAA,EAAA,CAAA,QAAA,GAfA,IAOI/B,EAAAA,GALFmD,EADDlB,EAAAA,OACCkB,kBAGAvC,EADDC,EAAAA,KACCD,GAUFuC,EAAmB,uBAAwB,CAC1C1B,MAAOb,EAAI,oBAAqB,cAChCwC,YAAaxC,EAAI,0JAA2J,cAC5KyC,KAAM,CACLC,WAAY,OACZC,WAAY,UACZC,IAAK,sBAENC,SAAU,aACVrC,WAAY,CACXK,MAAO,CACND,KAAM,SACNkC,QAAS9C,EAAI,iBAAkB,eAEhCW,cAAe,CACdC,KAAM,SACNkC,QAAS,GAEVlC,KAAM,CACLA,KAAM,QACNkC,QAAS,CAAC,oBAEXpC,OAAQ,CACPE,KAAM,SACNkC,QAAS,IAGXC,KAAM5D,EA3BoC,QA4B1CgC,WAAYA,EAAAA","file":"latest-activities.js","sourceRoot":"../src/js","sourcesContent":["/**\n * WordPress dependencies.\n */\nconst {\n\tblockEditor: {\n\t\tInspectorControls,\n\t},\n\tcomponents: {\n\t\tDisabled,\n\t\tPanelBody,\n\t\tRangeControl,\n\t\tSelectControl,\n\t\tTextControl,\n\t},\n\telement: {\n\t\tFragment,\n\t\tcreateElement,\n\t},\n\ti18n: {\n\t\t__,\n\t},\n} = wp;\n\n/**\n * BuddyPress dependencies.\n */\nconst {\n\tblockComponents: {\n\t\tServerSideRender,\n\t},\n\tblockData: {\n\t\tcurrentPostId,\n\t\tactivityTypes,\n\t}\n} = bp;\n\nconst editDynamicActivitiesBlock = ( { attributes, setAttributes } ) => {\n\tconst { postId, maxActivities, type, title } = attributes;\n\tconst post = currentPostId();\n\tconst types = activityTypes();\n\n\tif ( ! postId && post ) {\n\t\tsetAttributes( { postId: post } );\n\t}\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings', 'buddypress' ) } initialOpen={ true } className=\"bp-latest-activities\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Title', 'buddypress' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ ( text ) => {\n\t\t\t\t\t\t\tsetAttributes( { title: text } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tlabel={ __( 'Maximum amount to display', 'buddypress' ) }\n\t\t\t\t\t\tvalue={ maxActivities }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { maxActivities: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\tmax={ 10 }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\tmultiple\n\t\t\t\t\t\tlabel={ __( 'Type', 'buddypress' ) }\n\t\t\t\t\t\tvalue={ type }\n\t\t\t\t\t\toptions={ types }\n\t\t\t\t\t\tonChange={ ( option ) => {\n\t\t\t\t\t\t\tsetAttributes( { type: option } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<Disabled>\n\t\t\t\t<ServerSideRender block=\"bp/latest-activities\" attributes={ attributes } />\n\t\t\t</Disabled>\n\t\t</Fragment>\n\t);\n};\n\nexport default editDynamicActivitiesBlock;\n","/**\n * WordPress dependencies.\n */\nconst {\n\tblocks: {\n\t\tcreateBlock,\n\t},\n} = wp;\n\n/**\n * Transforms Nouveau Activity Widget to Activity Block.\n *\n * @type {Object}\n */\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/legacy-widget' ],\n\t\t\tisMatch: ( { idBase, instance } ) => {\n\t\t\t\tif ( ! instance?.raw ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn idBase === 'bp_latest_activities';\n\t\t\t},\n\t\t\ttransform: ( { instance } ) => {\n\t\t\t\tconst regex = /i:\\d*;s:\\d*:\"(.*?)\";/gmi;\n\t\t\t\tlet types = [];\n\t\t\t\tlet matches;\n\n\t\t\t\twhile ( ( matches = regex.exec( instance.raw.type ) ) !== null ) {\n\t\t\t\t\tif ( matches.index === regex.lastIndex ) {\n\t\t\t\t\t\tregex.lastIndex++;\n\t\t\t\t\t}\n\n\t\t\t\t\tmatches.forEach( ( match, groupIndex ) => {\n\t\t\t\t\t\tif ( 1 === groupIndex ) {\n\t\t\t\t\t\t\ttypes.push( match );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\treturn createBlock( 'bp/latest-activities', {\n\t\t\t\t\ttitle: instance.raw.title,\n\t\t\t\t\tmaxActivities: parseInt( instance.raw.max, 10 ),\n\t\t\t\t\ttype: types,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n","/**\n * WordPress dependencies.\n */\nconst {\n\tblocks: {\n\t\tregisterBlockType,\n\t},\n\ti18n: {\n\t\t__,\n\t},\n} = wp;\n\n/**\n * Internal dependencies.\n */\nimport editDynamicActivitiesBlock from './latest-activities/edit';\nimport transforms from './latest-activities/transforms';\n\nregisterBlockType( 'bp/latest-activities', {\n\ttitle: __( 'Latest Activities', 'buddypress' ),\n\tdescription: __( 'Display the latest updates of the post author (when used into a page or post), of the displayed user (when viewing their profile) or of your community.', 'buddypress' ),\n\ticon: {\n\t\tbackground: '#fff',\n\t\tforeground: '#d84800',\n\t\tsrc: 'buddicons-activity',\n\t},\n\tcategory: 'buddypress',\n\tattributes: {\n\t\ttitle: {\n\t\t\ttype: 'string',\n\t\t\tdefault: __( 'Latest updates', 'buddypress' ),\n\t\t},\n\t\tmaxActivities: {\n\t\t\ttype: 'number',\n\t\t\tdefault: 5\n\t\t},\n\t\ttype: {\n\t\t\ttype: 'array',\n\t\t\tdefault: ['activity_update'],\n\t\t},\n\t\tpostId: {\n\t\t\ttype: 'number',\n\t\t\tdefault: 0,\n\t\t},\n\t},\n\tedit: editDynamicActivitiesBlock,\n\ttransforms: transforms,\n} );\n"]}
 
bp-activity/js/mentions.js CHANGED
@@ -20,7 +20,7 @@ window.bp = window.bp || {};
20
  * @since 2.1.0
21
  */
22
  $.fn.bp_mentions = function( options ) {
23
- if ( Array.isArray( options ) ) {
24
  options = { data: options };
25
  }
26
 
@@ -28,12 +28,12 @@ window.bp = window.bp || {};
28
  * Default options for at.js; see https://github.com/ichord/At.js/.
29
  */
30
  var suggestionsDefaults = {
31
- delay: 200,
32
- hideWithoutSuffix: true,
33
- insertTpl: '@${ID}',
34
- limit: 10,
35
- startWithSpace: false,
36
- suffix: '',
37
 
38
  callbacks: {
39
  /**
@@ -87,7 +87,7 @@ window.bp = window.bp || {};
87
  * @since 2.1.0
88
  */
89
  before_reposition: function( offset ) {
90
- // get the iframe, if any, already applied with atwho.js library.
91
  var caret,
92
  line,
93
  iframeOffset,
@@ -109,7 +109,7 @@ window.bp = window.bp || {};
109
  caret = this.$inputor.caret( 'offset' );
110
  }
111
 
112
- // If the caret is past horizontal half, then flip it, yo.
113
  if ( caret.left > ( $body.width() / 2 ) ) {
114
  $view.addClass( 'right' );
115
  move = caret.left - offset.left - this.view.$el.width();
@@ -118,15 +118,15 @@ window.bp = window.bp || {};
118
  move = caret.left - offset.left + 1;
119
  }
120
 
121
- // If we're on a small screen, scroll to caret.
122
  if ( $body.width() <= 400 ) {
123
  $( document ).scrollTop( caret.top - 6 );
124
  }
125
 
126
- // New position is under the caret (never above) and positioned to follow.
127
- // Dynamic sizing based on the input area (remove 'px' from end).
128
  line = parseInt( this.$inputor.css( 'line-height' ).substr( 0, this.$inputor.css( 'line-height' ).length - 2 ), 10 );
129
- if ( !line || line < 5 ) { // Sanity check, and catch no line-height.
130
  line = 19;
131
  }
132
 
@@ -135,11 +135,11 @@ window.bp = window.bp || {};
135
  },
136
 
137
  /**
138
- * Override default behavior which inserts junk tags in the WordPress Visual editor.
139
  *
140
  * @param {unknown} $inputor Element which we're inserting content into.
141
- * @param {string} content The content that will be inserted.
142
- * @param {string} suffix Applied to the end of the content string.
143
  * @return {string}
144
  * @since 2.1.0
145
  */
@@ -160,9 +160,8 @@ window.bp = window.bp || {};
160
  * @param {string} query Partial @mention to search for.
161
  * @param {function} render_view Render page callback function.
162
  * @since 2.1.0
163
- * @since 3.0.0. Renamed from "remote_filter" for at.js v1.5.4 support.
164
  */
165
- remoteFilter: function( query, render_view ) {
166
  var self = $( this ),
167
  params = {};
168
 
@@ -178,8 +177,7 @@ window.bp = window.bp || {};
178
 
179
  params = { 'action': 'bp_get_suggestions', 'term': query, 'type': 'members' };
180
 
181
- var groupId = this.$inputor.data( 'suggestions-group-id' );
182
- if ( ( 'number' === typeof groupId || 'string' === typeof groupId ) && ! isNaN( groupId - parseFloat( groupId ) ) ) {
183
  params['group-id'] = parseInt( this.$inputor.data( 'suggestions-group-id' ), 10 );
184
  }
185
 
@@ -232,8 +230,8 @@ window.bp = window.bp || {};
232
  ),
233
 
234
  at: '@',
235
- searchKey: 'search',
236
- displayTpl: '<li data-value="@${ID}"><img src="${image}" alt="" /><span class="username">@${ID}</span><small>${name}</small></li>'
237
  },
238
 
239
  opts = $.extend( true, {}, suggestionsDefaults, mentionsDefaults, options );
20
  * @since 2.1.0
21
  */
22
  $.fn.bp_mentions = function( options ) {
23
+ if ( $.isArray( options ) ) {
24
  options = { data: options };
25
  }
26
 
28
  * Default options for at.js; see https://github.com/ichord/At.js/.
29
  */
30
  var suggestionsDefaults = {
31
+ delay: 200,
32
+ hide_without_suffix: true,
33
+ insert_tpl: '</>${atwho-data-value}</>', // For contentEditable, the fake tags make jQuery insert a textNode.
34
+ limit: 10,
35
+ start_with_space: false,
36
+ suffix: '',
37
 
38
  callbacks: {
39
  /**
87
  * @since 2.1.0
88
  */
89
  before_reposition: function( offset ) {
90
+ // get the iframe, if any, already applied with atwho
91
  var caret,
92
  line,
93
  iframeOffset,
109
  caret = this.$inputor.caret( 'offset' );
110
  }
111
 
112
+ // If the caret is past horizontal half, then flip it, yo
113
  if ( caret.left > ( $body.width() / 2 ) ) {
114
  $view.addClass( 'right' );
115
  move = caret.left - offset.left - this.view.$el.width();
118
  move = caret.left - offset.left + 1;
119
  }
120
 
121
+ // If we're on a small screen, scroll to caret
122
  if ( $body.width() <= 400 ) {
123
  $( document ).scrollTop( caret.top - 6 );
124
  }
125
 
126
+ // New position is under the caret (never above) and positioned to follow
127
+ // Dynamic sizing based on the input area (remove 'px' from end)
128
  line = parseInt( this.$inputor.css( 'line-height' ).substr( 0, this.$inputor.css( 'line-height' ).length - 2 ), 10 );
129
+ if ( !line || line < 5 ) { // sanity check, and catch no line-height
130
  line = 19;
131
  }
132
 
135
  },
136
 
137
  /**
138
+ * Override default behaviour which inserts junk tags in the WordPress Visual editor.
139
  *
140
  * @param {unknown} $inputor Element which we're inserting content into.
141
+ * @param {string) content The content that will be inserted.
142
+ * @param {string) suffix Applied to the end of the content string.
143
  * @return {string}
144
  * @since 2.1.0
145
  */
160
  * @param {string} query Partial @mention to search for.
161
  * @param {function} render_view Render page callback function.
162
  * @since 2.1.0
 
163
  */
164
+ remote_filter: function( query, render_view ) {
165
  var self = $( this ),
166
  params = {};
167
 
177
 
178
  params = { 'action': 'bp_get_suggestions', 'term': query, 'type': 'members' };
179
 
180
+ if ( $.isNumeric( this.$inputor.data( 'suggestions-group-id' ) ) ) {
 
181
  params['group-id'] = parseInt( this.$inputor.data( 'suggestions-group-id' ), 10 );
182
  }
183
 
230
  ),
231
 
232
  at: '@',
233
+ search_key: 'search',
234
+ tpl: '<li data-value="@${ID}"><img src="${image}" /><span class="username">@${ID}</span><small>${name}</small></li>'
235
  },
236
 
237
  opts = $.extend( true, {}, suggestionsDefaults, mentionsDefaults, options );
bp-activity/js/mentions.min.js CHANGED
@@ -1 +1 @@
1
- window.bp=window.bp||{},function(t,r){var o,a=[];t.mentions=t.mentions||{},t.mentions.users=window.bp.mentions.users||[],"object"==typeof window.BP_Suggestions&&(t.mentions.users=window.BP_Suggestions.friends||t.mentions.users),r.fn.bp_mentions=function(t){Array.isArray(t)&&(t={data:t});var e={delay:200,hideWithoutSuffix:!0,insertTpl:"@${ID}",limit:10,startWithSpace:!1,suffix:"",callbacks:{filter:function(t,e,i){for(var n,s=[],r=new RegExp("^"+t+"| "+t,"ig"),o=0,a=e.length;o<a;o++)(n=e[o])[i].toLowerCase().match(r)&&s.push(n);return s},highlighter:function(t,e){if(!e)return t;e=new RegExp(">(\\s*|[\\w\\s]*)("+this.at.replace("+","\\+")+"?"+e.replace("+","\\+")+")([\\w ]*)\\s*<","ig");return t.replace(e,function(t,e,i,n){return">"+e+"<strong>"+i+"</strong>"+n+"<"})},before_reposition:function(t){var e,i=r("#atwho-ground-"+this.id+" .atwho-view"),n=r("body"),s=this.$inputor.data("atwho");"undefined"!==s&&"undefined"!==s.iframe&&null!==s.iframe?(e=this.$inputor.caret("offset",{iframe:s.iframe}),"undefined"!==(s=r(s.iframe).offset())&&(e.left+=s.left,e.top+=s.top)):e=this.$inputor.caret("offset"),i=e.left>n.width()/2?(i.addClass("right"),e.left-t.left-this.view.$el.width()):(i.removeClass("right"),e.left-t.left+1),n.width()<=400&&r(document).scrollTop(e.top-6),n=parseInt(this.$inputor.css("line-height").substr(0,this.$inputor.css("line-height").length-2),10),t.top=e.top+(n=!n||n<5?19:n),t.left+=i},inserting_wrapper:function(t,e,i){return""+e+i}}},i={callbacks:{remoteFilter:function(e,i){var t,n=r(this),s={};"object"!=typeof(o=a[e])?(n.xhr&&n.xhr.abort(),s={action:"bp_get_suggestions",term:e,type:"members"},"number"!=typeof(t=this.$inputor.data("suggestions-group-id"))&&"string"!=typeof t||isNaN(t-parseFloat(t))||(s["group-id"]=parseInt(this.$inputor.data("suggestions-group-id"),10)),n.xhr=r.getJSON(ajaxurl,s).done(function(t){t.success&&(t=r.map(t.data,function(t){return t.search=t.search||t.ID+" "+t.name,t}),a[e]=t,i(t))})):i(o)}},data:r.map(t.data,function(t){return t.search=t.search||t.ID+" "+t.name,t}),at:"@",searchKey:"search",displayTpl:'<li data-value="@${ID}"><img src="${image}" alt="" /><span class="username">@${ID}</span><small>${name}</small></li>'},t=r.extend(!0,{},e,i,t);return r.fn.atwho.call(this,t)},r(document).ready(function(){r(".bp-suggestions, #comments form textarea, .wp-editor-area").bp_mentions(t.mentions.users)}),t.mentions.tinyMCEinit=function(){void 0===window.tinyMCE||null===window.tinyMCE.activeEditor||void 0===window.tinyMCE.activeEditor||r(window.tinyMCE.activeEditor.contentDocument.activeElement).atwho("setIframe",r(".wp-editor-wrap iframe")[0]).bp_mentions(t.mentions.users)}}(bp,jQuery);
1
+ window.bp=window.bp||{},function(t,e,i){var n,s=[];t.mentions=t.mentions||{},t.mentions.users=window.bp.mentions.users||[],"object"==typeof window.BP_Suggestions&&(t.mentions.users=window.BP_Suggestions.friends||t.mentions.users),e.fn.bp_mentions=function(t){e.isArray(t)&&(t={data:t});var i={delay:200,hide_without_suffix:!0,insert_tpl:"</>${atwho-data-value}</>",limit:10,start_with_space:!1,suffix:"",callbacks:{filter:function(t,e,i){var n,s,r,o=[],a=new RegExp("^"+t+"| "+t,"ig");for(s=0,r=e.length;s<r;s++)(n=e[s])[i].toLowerCase().match(a)&&o.push(n);return o},highlighter:function(t,e){if(!e)return t;var i=new RegExp(">(\\s*|[\\w\\s]*)("+this.at.replace("+","\\+")+"?"+e.replace("+","\\+")+")([\\w ]*)\\s*<","ig");return t.replace(i,function(t,e,i,n){return">"+e+"<strong>"+i+"</strong>"+n+"<"})},before_reposition:function(t){var i,n,s,r,o=e("#atwho-ground-"+this.id+" .atwho-view"),a=e("body"),u=this.$inputor.data("atwho");"undefined"!==u&&"undefined"!==u.iframe&&null!==u.iframe?(i=this.$inputor.caret("offset",{iframe:u.iframe}),"undefined"!==(s=e(u.iframe).offset())&&(i.left+=s.left,i.top+=s.top)):i=this.$inputor.caret("offset"),i.left>a.width()/2?(o.addClass("right"),r=i.left-t.left-this.view.$el.width()):(o.removeClass("right"),r=i.left-t.left+1),a.width()<=400&&e(document).scrollTop(i.top-6),(!(n=parseInt(this.$inputor.css("line-height").substr(0,this.$inputor.css("line-height").length-2),10))||n<5)&&(n=19),t.top=i.top+n,t.left+=r},inserting_wrapper:function(t,e,i){return""+e+i}}},r={callbacks:{remote_filter:function(t,i){var r=e(this),o={};"object"!=typeof(n=s[t])?(r.xhr&&r.xhr.abort(),o={action:"bp_get_suggestions",term:t,type:"members"},e.isNumeric(this.$inputor.data("suggestions-group-id"))&&(o["group-id"]=parseInt(this.$inputor.data("suggestions-group-id"),10)),r.xhr=e.getJSON(ajaxurl,o).done(function(n){if(n.success){var r=e.map(n.data,function(t){return t.search=t.search||t.ID+" "+t.name,t});s[t]=r,i(r)}})):i(n)}},data:e.map(t.data,function(t){return t.search=t.search||t.ID+" "+t.name,t}),at:"@",search_key:"search",tpl:'<li data-value="@${ID}"><img src="${image}" /><span class="username">@${ID}</span><small>${name}</small></li>'},o=e.extend(!0,{},i,r,t);return e.fn.atwho.call(this,o)},e(document).ready(function(){e(".bp-suggestions, #comments form textarea, .wp-editor-area").bp_mentions(t.mentions.users)}),t.mentions.tinyMCEinit=function(){void 0!==window.tinyMCE&&null!==window.tinyMCE.activeEditor&&void 0!==window.tinyMCE.activeEditor&&e(window.tinyMCE.activeEditor.contentDocument.activeElement).atwho("setIframe",e(".wp-editor-wrap iframe")[0]).bp_mentions(t.mentions.users)}}(bp,jQuery);
bp-activity/sass/blocks/latest-activities.scss DELETED
@@ -1,100 +0,0 @@
1
- .bp-latest-activities {
2
-
3
- .components-flex.components-select-control {
4
-
5
- select[multiple] {
6
- height: auto;
7
- padding: 0 8px;
8
-
9
- + .components-input-control__suffix svg {
10
- display: none;
11
- }
12
- }
13
- }
14
- }
15
-
16
- .bp-latest-activities-block {
17
-
18
- a,
19
- .entry .entry-content & a {
20
- border: none;
21
- text-decoration: none;
22
- }
23
-
24
- .activity-list.item-list {
25
-
26
- blockquote {
27
- padding: 0;
28
- border: none;
29
-
30
- .activity-item {
31
-
32
- &:not(.mini) {
33
- position: relative;
34
- box-shadow: 1px 0 4px rgba(0, 0, 0, 0.15);
35
- padding: 0 1em;
36
-
37
- &:after,
38
- &:before {
39
- position: absolute;
40
- left: 15px;
41
- display: block;
42
- width: 0;
43
- height: 0;
44
- border-style: solid;
45
- border-color: transparent;
46
- content: "";
47
- }
48
-
49
- &:before {
50
- bottom: -18px;
51
- border-top-color: rgba(0, 0, 0, 0.15);
52
- border-width: 9px;
53
- left: 14px;
54
- }
55
-
56
- &:after {
57
- bottom: -16px;
58
- border-top-color: #fff;
59
- border-width: 8px;
60
- }
61
- }
62
-
63
- &.mini {
64
-
65
- .avatar {
66
- display: inline-block;
67
- width: 20px;
68
- height: 20px;
69
- vertical-align: middle;
70
- margin-right: 2px;
71
- }
72
- }
73
- }
74
- }
75
-
76
- footer {
77
- display: flex;
78
- align-items: center;
79
-
80
- img.avatar {
81
- display: inline-block;
82
- border: none;
83
- margin-right: 0.5em;
84
- }
85
-
86
- .activity-time-since {
87
- font-size: 90%;
88
- }
89
- }
90
- }
91
-
92
- .widget-error {
93
- border-left: solid 4px #0b80a4;
94
- box-shadow: 1px 0 4px rgba(0, 0, 0, 0.15);
95
-
96
- p {
97
- padding: 0 1em;
98
- }
99
- }
100
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/screens/directory.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- * Activity: Directory screen handler
4
- *
5
- * @package BuddyPress
6
- * @subpackage ActivityScreens
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Load the Activity directory.
12
- *
13
- * @since 1.5.0
14
- *
15
- */
16
- function bp_activity_screen_index() {
17
- if ( bp_is_activity_directory() ) {
18
- bp_update_is_directory( true, 'activity' );
19
-
20
- /**
21
- * Fires right before the loading of the Activity directory screen template file.
22
- *
23
- * @since 1.5.0
24
- */
25
- do_action( 'bp_activity_screen_index' );
26
-
27
- /**
28
- * Filters the template to load for the Activity directory screen.
29
- *
30
- * @since 1.5.0
31
- *
32
- * @param string $template Path to the activity template to load.
33
- */
34
- bp_core_load_template( apply_filters( 'bp_activity_screen_index', 'activity/index' ) );
35
- }
36
- }
37
- add_action( 'bp_screens', 'bp_activity_screen_index' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/screens/favorites.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
- /**
3
- * Activity: User's "Activity > Favorites" screen handler
4
- *
5
- * @package BuddyPress
6
- * @subpackage ActivityScreens
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Load the 'Favorites' activity page.
12
- *
13
- * @since 1.2.0
14
- */
15
- function bp_activity_screen_favorites() {
16
- bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
17
-
18
- /**
19
- * Fires right before the loading of the "Favorites" screen template file.
20
- *
21
- * @since 1.2.0
22
- */
23
- do_action( 'bp_activity_screen_favorites' );
24
-
25
- /**
26
- * Filters the template to load for the "Favorites" screen.
27
- *
28
- * @since 1.2.0
29
- *
30
- * @param string $template Path to the activity template to load.
31
- */
32
- bp_core_load_template( apply_filters( 'bp_activity_template_favorite_activity', 'members/single/home' ) );
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/screens/friends.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
- /**
3
- * Activity: User's "Activity > Friends" screen handler
4
- *
5
- * @package BuddyPress
6
- * @subpackage ActivityScreens
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Load the 'My Friends' activity page.
12
- *
13
- * @since 1.0.0
14
- */
15
- function bp_activity_screen_friends() {
16
- if ( !bp_is_active( 'friends' ) )
17
- return false;
18
-
19
- bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
20
-
21
- /**
22
- * Fires right before the loading of the "My Friends" screen template file.
23
- *
24
- * @since 1.2.0
25
- */
26
- do_action( 'bp_activity_screen_friends' );
27
-
28
- /**
29
- * Filters the template to load for the "My Friends" screen.
30
- *
31
- * @since 1.0.0
32
- *
33
- * @param string $template Path to the activity template to load.
34
- */
35
- bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'members/single/home' ) );
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/screens/groups.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
- /**
3
- * Activity: User's "Activity > Groups" screen handler
4
- *
5
- * @package BuddyPress
6
- * @subpackage ActivityScreens
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Load the 'My Groups' activity page.
12
- *
13
- * @since 1.2.0
14
- */
15
- function bp_activity_screen_groups() {
16
- if ( !bp_is_active( 'groups' ) )
17
- return false;
18
-
19
- bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
20
-
21
- /**
22
- * Fires right before the loading of the "My Groups" screen template file.
23
- *
24
- * @since 1.2.0
25
- */
26
- do_action( 'bp_activity_screen_groups' );
27
-
28
- /**
29
- * Filters the template to load for the "My Groups" screen.
30
- *
31
- * @since 1.2.0
32
- *
33
- * @param string $template Path to the activity template to load.
34
- */
35
- bp_core_load_template( apply_filters( 'bp_activity_template_groups_activity', 'members/single/home' ) );
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/screens/just-me.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- /**
3
- * Activity: User's "Activity" screen handler
4
- *
5
- * @package BuddyPress
6
- * @subpackage ActivityScreens
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Load the 'My Activity' page.
12
- *
13
- * @since 1.0.0
14
- */
15
- function bp_activity_screen_my_activity() {
16
-
17
- /**
18
- * Fires right before the loading of the "My Activity" screen template file.
19
- *
20
- * @since 1.0.0
21
- */
22
- do_action( 'bp_activity_screen_my_activity' );
23
-
24
- /**
25
- * Filters the template to load for the "My Activity" screen.
26
- *
27
- * @since 1.0.0
28
- *
29
- * @param string $template Path to the activity template to load.
30
- */
31
- bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'members/single/home' ) );
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/screens/mentions.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
- /**
3
- * Activity: User's "Activity > Mentions" screen handler
4
- *
5
- * @package BuddyPress
6
- * @subpackage ActivityScreens
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Load the 'Mentions' activity page.
12
- *
13
- * @since 1.2.0
14
- */
15
- function bp_activity_screen_mentions() {
16
- bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
17
-
18
- /**
19
- * Fires right before the loading of the "Mentions" screen template file.
20
- *
21
- * @since 1.2.0
22
- */
23
- do_action( 'bp_activity_screen_mentions' );
24
-
25
- /**
26
- * Filters the template to load for the "Mentions" screen.
27
- *
28
- * @since 1.2.0
29
- *
30
- * @param string $template Path to the activity template to load.
31
- */
32
- bp_core_load_template( apply_filters( 'bp_activity_template_mention_activity', 'members/single/home' ) );
33
- }
34
-
35
- /**
36
- * Reset the logged-in user's new mentions data when he visits his mentions screen.
37
- *
38
- * @since 1.5.0
39
- *
40
- */
41
- function bp_activity_reset_my_new_mentions() {
42
- if ( bp_is_my_profile() )
43
- bp_activity_clear_new_mentions( bp_loggedin_user_id() );
44
- }
45
- add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-activity/screens/permalink.php DELETED
@@ -1,166 +0,0 @@
1
- <?php
2
- /**
3
- * Activity: Single permalink screen handler
4
- *
5
- * @package BuddyPress
6
- * @subpackage ActivityScreens
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Catch and route requests for single activity item permalinks.
12
- *
13
- * @since 1.2.0
14
- *
15
- * @return bool False on failure.
16
- */
17
- function bp_activity_action_permalink_router() {
18
- // Not viewing activity.
19
- if ( ! bp_is_activity_component() || ! bp_is_current_action( 'p' ) )
20
- return false;
21
-
22
- // No activity to display.
23
- if ( ! bp_action_variable( 0 ) || ! is_numeric( bp_action_variable( 0 ) ) )
24
- return false;
25
-
26
- // Get the activity details.
27
- $activity = bp_activity_get_specific( array( 'activity_ids' => bp_action_variable( 0 ), 'show_hidden' => true ) );
28
-
29
- // 404 if activity does not exist.
30
- if ( empty( $activity['activities'][0] ) ) {
31
- bp_do_404();
32
- return;
33
- } else {
34
- $activity = $activity['activities'][0];
35
- }
36
-
37
- // Do not redirect at default.
38
- $redirect = false;
39
-
40
- // Redirect based on the type of activity.
41
- if ( bp_is_active( 'groups' ) && $activity->component == buddypress()->groups->id ) {
42
-
43
- // Activity is a user update.
44
- if ( ! empty( $activity->user_id ) ) {
45
- $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
46
-
47
- // Activity is something else.
48
- } else {
49
-
50
- // Set redirect to group activity stream.
51
- if ( $group = groups_get_group( $activity->item_id ) ) {
52
- $redirect = bp_get_group_permalink( $group ) . bp_get_activity_slug() . '/' . $activity->id . '/';
53
- }
54
- }
55
-
56
- // Set redirect to users' activity stream.
57
- } elseif ( ! empty( $activity->user_id ) ) {
58
- $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
59
- }
60
-
61
- // If set, add the original query string back onto the redirect URL.
62
- if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
63
- $query_frags = array();
64
- wp_parse_str( $_SERVER['QUERY_STRING'], $query_frags );
65
- $redirect = add_query_arg( urlencode_deep( $query_frags ), $redirect );
66
- }
67
-
68
- /**
69
- * Filter the intended redirect url before the redirect occurs for the single activity item.
70
- *
71
- * @since 1.2.2
72
- *
73
- * @param array $value Array with url to redirect to and activity related to the redirect.
74
- */
75
- if ( ! $redirect = apply_filters_ref_array( 'bp_activity_permalink_redirect_url', array( $redirect, &$activity ) ) ) {
76
- bp_core_redirect( bp_get_root_domain() );
77
- }
78
-
79
- // Redirect to the actual activity permalink page.
80
- bp_core_redirect( $redirect );
81
- }
82
- add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
83
-
84
- /**
85
- * Load the page for a single activity item.
86
- *
87
- * @since 1.2.0
88
- *
89
- * @return bool|string Boolean on false or the template for a single activity item on success.
90
- */
91
- function bp_activity_screen_single_activity_permalink() {
92
- // No displayed user or not viewing activity component.
93
- if ( ! bp_is_activity_component() ) {
94
- return false;
95
- }
96
-
97
- $action = bp_current_action();
98
- if ( ! $action || ! is_numeric( $action ) ) {
99
- return false;
100
- }
101
-
102
- // Get the activity details.
103
- $activity = bp_activity_get_specific( array(
104
- 'activity_ids' => $action,
105
- 'show_hidden' => true,
106
- 'spam' => 'ham_only',
107
- ) );
108
-
109
- // 404 if activity does not exist.
110
- if ( empty( $activity['activities'][0] ) || bp_action_variables() ) {
111
- bp_do_404();
112
- return;
113
-
114
- } else {
115
- $activity = $activity['activities'][0];
116
- }
117
-
118
- /**
119
- * Check user access to the activity item.
120
- *
121
- * @since 3.0.0
122
- */
123
- $has_access = bp_activity_user_can_read( $activity );
124
-
125
- // If activity author does not match displayed user, block access.
126
- // More info:https://buddypress.trac.wordpress.org/ticket/7048#comment:28
127
- if ( true === $has_access && bp_displayed_user_id() !== $activity->user_id ) {
128
- $has_access = false;
129
- }
130
-
131
- /**
132
- * Fires before the loading of a single activity template file.
133
- *
134
- * @since 1.2.0
135
- *
136
- * @param BP_Activity_Activity $activity Object representing the current activity item being displayed.
137
- * @param bool $has_access Whether or not the current user has access to view activity.
138
- */
139
- do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access );
140
-
141
- // Access is specifically disallowed.
142
- if ( false === $has_access ) {
143
- // If not logged in, prompt for login.
144
- if ( ! is_user_logged_in() ) {
145
- bp_core_no_access();
146
-
147
- // Redirect away.
148
- } else {
149
- bp_core_add_message( __( 'You do not have access to this activity.', 'buddypress' ), 'error' );
150
- bp_core_redirect( bp_loggedin_user_domain() );
151
- }
152
- }
153
-
154
- /**
155
- * Filters the template to load for a single activity screen.
156
- *
157
- * @since 1.0.0
158
- *
159
- * @param string $template Path to the activity template to load.
160
- */
161
- $template = apply_filters( 'bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink' );
162
-
163
- // Load the template.
164
- bp_core_load_template( $template );
165
- }
166
- add_action( 'bp_screens', 'bp_activity_screen_single_activity_permalink' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-blogs/{actions/random.php → bp-blogs-actions.php} RENAMED
@@ -1,12 +1,15 @@
1
  <?php
2
  /**
3
- * Blogs: Random blog action handler
4
  *
5
  * @package BuddyPress
6
  * @subpackage BlogsActions
7
- * @since 3.0.0
8
  */
9
 
 
 
 
10
  /**
11
  * Redirect to a random blog in the multisite network.
12
  *
@@ -28,4 +31,4 @@ function bp_blogs_redirect_to_random_blog() {
28
  bp_core_redirect( bp_core_get_root_domain() );
29
  }
30
  }
31
- add_action( 'bp_actions', 'bp_blogs_redirect_to_random_blog' );
1
  <?php
2
  /**
3
+ * BuddyPress Blogs Actions.
4
  *
5
  * @package BuddyPress
6
  * @subpackage BlogsActions
7
+ * @since 1.5.0
8
  */
9
 
10
+ // Exit if accessed directly.
11
+ defined( 'ABSPATH' ) || exit;
12
+
13
  /**
14
  * Redirect to a random blog in the multisite network.
15
  *
31
  bp_core_redirect( bp_core_get_root_domain() );
32
  }
33
  }
34
+ add_action( 'bp_actions', 'bp_blogs_redirect_to_random_blog' );
bp-blogs/bp-blogs-activity.php CHANGED
@@ -127,12 +127,7 @@ function bp_blogs_format_activity_action_new_blog( $action, $activity ) {
127
  $blog_url = bp_blogs_get_blogmeta( $activity->item_id, 'url' );
128
  $blog_name = bp_blogs_get_blogmeta( $activity->item_id, 'name' );
129
 
130
- $action = sprintf(
131
- /* translators: 1: the activity user link. 2: the blog link. */
132
- esc_html__( '%1$s created the site %2$s', 'buddypress' ),
133
- bp_core_get_userlink( $activity->user_id ),
134
- '<a href="' . esc_url( $blog_url ) . '">' . esc_html( $blog_name ) . '</a>'
135
- );
136
 
137
  // Legacy filter - requires the BP_Blogs_Blog object.
138
  if ( has_filter( 'bp_blogs_activity_created_blog_action' ) ) {
@@ -214,7 +209,7 @@ function bp_blogs_format_activity_action_new_blog_post( $action, $activity ) {
214
  */
215
  if ( empty( $post_title ) ) {
216
  // Defaults to no title.
217
- $post_title = __( '(no title)', 'buddypress' );
218
 
219
  switch_to_blog( $activity->item_id );
220
 
@@ -235,26 +230,15 @@ function bp_blogs_format_activity_action_new_blog_post( $action, $activity ) {
235
  }
236
 
237
  // Build the 'post link' part of the activity action string.
238
- $post_link = '<a href="' . esc_url( $post_url ) . '">' . esc_html( $post_title ) . '</a>';
239
 
240
  $user_link = bp_core_get_userlink( $activity->user_id );
241
 
242
  // Build the complete activity action string.
243
  if ( is_multisite() ) {
244
- $action = sprintf(
245
- /* translators: 1: the activity user link. 2: the post link. 3: the blog link. */
246
- esc_html_x( '%1$s wrote a new post, %2$s, on the site %3$s', '`new_blog_post` activity action', 'buddypress' ),
247
- $user_link,
248
- $post_link,
249
- '<a href="' . esc_url( $blog_url ) . '">' . esc_html( $blog_name ) . '</a>'
250
- );
251
  } else {
252
- $action = sprintf(
253
- /* translators: 1: the activity user link. 2: the post link. */
254
- esc_html_x( '%1$s wrote a new post, %2$s', '`new_blog_post` activity action', 'buddypress' ),
255
- $user_link,
256
- $post_link
257
- );
258
  }
259
 
260
  // Legacy filter - requires the post object.
@@ -303,7 +287,7 @@ function bp_blogs_format_activity_action_new_blog_comment( $action, $activity )
303
 
304
  $blog_url = false;
305
 
306
- // Try to get the blog url from the activity object.
307
  if ( isset( $activity->blog_url ) ) {
308
  $blog_url = $activity->blog_url;
309
  } else {
@@ -312,7 +296,7 @@ function bp_blogs_format_activity_action_new_blog_comment( $action, $activity )
312
 
313
  $blog_name = false;
314
 
315
- // Try to get the blog name from the activity object.
316
  if ( isset( $activity->blog_name ) ) {
317
  $blog_name = $activity->blog_name;
318
  } else {
@@ -329,7 +313,7 @@ function bp_blogs_format_activity_action_new_blog_comment( $action, $activity )
329
 
330
  $post_url = false;
331
 
332
- // Try to get the post url from the activity object.
333
  if ( isset( $activity->post_url ) ) {
334
  $post_url = $activity->post_url;
335
 
@@ -344,11 +328,11 @@ function bp_blogs_format_activity_action_new_blog_comment( $action, $activity )
344
 
345
  $post_title = false;
346
 
347
- // Should be the case when the comment has just been published.
348
  if ( isset( $activity->post_title ) ) {
349
  $post_title = $activity->post_title;
350
 
351
- // If activity already exists try to get the post title from activity meta.
352
  } elseif ( ! empty( $activity->id ) ) {
353
  $post_title = bp_activity_get_meta( $activity->id, 'post_title' );
354
  }
@@ -374,24 +358,13 @@ function bp_blogs_format_activity_action_new_blog_comment( $action, $activity )
374
  restore_current_blog();
375
  }
376
 
377
- $post_link = '<a href="' . esc_url( $post_url ) . '">' . esc_html( $post_title ) . '</a>';
378
  $user_link = bp_core_get_userlink( $activity->user_id );
379
 
380
  if ( is_multisite() ) {
381
- $action = sprintf(
382
- /* translators: 1: the activity user link. 2: the post link. 3: the blog link. */
383
- esc_html_x( '%1$s commented on the post, %2$s, on the site %3$s', '`new_blog_comment` activity action', 'buddypress' ),
384
- $user_link,
385
- $post_link,
386
- '<a href="' . esc_url( $blog_url ) . '">' . esc_html( $blog_name ) . '</a>'
387
- );
388
  } else {
389
- $action = sprintf(
390
- /* translators: 1: the activity user link. 2: the post link. */
391
- esc_html_x( '%1$s commented on the post, %2$s', '`new_blog_comment` activity action', 'buddypress' ),
392
- $user_link,
393
- $post_link
394
- );
395
  }
396
 
397
  // Legacy filter - requires the comment object.
@@ -803,12 +776,6 @@ function bp_blogs_sync_add_from_activity_comment( $comment_id, $params, $parent_
803
  return;
804
  }
805
 
806
- // Check if comments are still open for parent item.
807
- $comments_open = bp_blogs_comments_open( $parent_activity );
808
- if ( ! $comments_open ) {
809
- return;
810
- }
811
-
812
  // Get userdata.
813
  if ( $params['user_id'] == bp_loggedin_user_id() ) {
814
  $user = buddypress()->loggedin_user->userdata;
@@ -816,7 +783,7 @@ function bp_blogs_sync_add_from_activity_comment( $comment_id, $params, $parent_
816
  $user = bp_core_get_core_userdata( $params['user_id'] );
817
  }
818
 
819
- // Get associated post type and set default comment parent.
820
  $post_type = bp_activity_post_type_get_tracking_arg( $parent_activity->type, 'post_type' );
821
  $comment_parent = 0;
822
 
@@ -832,7 +799,7 @@ function bp_blogs_sync_add_from_activity_comment( $comment_id, $params, $parent_
832
  'comment_author_email' => $user->user_email,
833
  'comment_author_url' => bp_core_get_user_domain( $params['user_id'], $user->user_nicename, $user->user_login ),
834
  'comment_content' => $params['content'],
835
- 'comment_type' => '', // Could be interesting to add 'BuddyPress' here...
836
  'comment_parent' => (int) $comment_parent,
837
  'user_id' => $params['user_id'],
838
  'comment_approved' => 1
@@ -936,7 +903,7 @@ function bp_blogs_sync_delete_from_activity_comment( $retval, $parent_activity_i
936
  $activity_ids = bp_activity_recurse_comments_activity_ids( $activity );
937
  $activity_ids[] = $activity_id;
938
 
939
- // Handle multisite.
940
  // switch to the blog where the comment was made.
941
  switch_to_blog( $parent_activity->item_id );
942
 
@@ -950,7 +917,7 @@ function bp_blogs_sync_delete_from_activity_comment( $retval, $parent_activity_i
950
  // emulate bp_activity_delete_comment().
951
  BP_Activity_Activity::rebuild_activity_comment_tree( $parent_activity_id );
952
 
953
- // Avoid the error message although the comments were successfully deleted.
954
  $deleted = true;
955
 
956
  // We're overriding the default bp_activity_delete_comment() functionality
@@ -973,10 +940,10 @@ function bp_blogs_sync_activity_edit_to_post_comment( BP_Activity_Activity $acti
973
  return;
974
  }
975
 
976
- // Fetch parent activity item.
977
  $parent_activity = new BP_Activity_Activity( $activity->item_id );
978
 
979
- // If parent activity isn't a post type having the buddypress-activity support for comments, stop now!
980
  if ( ! bp_activity_type_supports( $parent_activity->type, 'post-type-comment-tracking' ) ) {
981
  return;
982
  }
@@ -998,11 +965,11 @@ function bp_blogs_sync_activity_edit_to_post_comment( BP_Activity_Activity $acti
998
  // Handle multisite.
999
  switch_to_blog( $parent_activity->item_id );
1000
 
1001
- // Get the comment status.
1002
  $post_comment_status = wp_get_comment_status( $post_comment_id );
1003
  $old_comment_status = $post_comment_status;
1004
 
1005
- // No need to edit the activity, as it's the activity who's updating the comment.
1006
  remove_action( 'transition_comment_status', 'bp_activity_transition_post_type_comment_status', 10 );
1007
  remove_action( 'bp_activity_post_type_comment', 'bp_blogs_comment_sync_activity_comment', 10 );
1008
 
@@ -1022,7 +989,7 @@ function bp_blogs_sync_activity_edit_to_post_comment( BP_Activity_Activity $acti
1022
  }
1023
  }
1024
 
1025
- // Restore actions.
1026
  add_action( 'transition_comment_status', 'bp_activity_transition_post_type_comment_status', 10, 3 );
1027
  add_action( 'bp_activity_post_type_comment', 'bp_blogs_comment_sync_activity_comment', 10, 4 );
1028
 
@@ -1081,15 +1048,15 @@ function bp_blogs_new_blog_comment_query_backpat( $args ) {
1081
  return $args;
1082
  }
1083
 
1084
- // Get the associated post type.
1085
  $post_type = bp_activity_post_type_get_tracking_arg( $args['action'], 'post_type' );
1086
 
1087
- // Bail if this is not an activity associated with a post type.
1088
  if ( empty( $post_type ) ) {
1089
  return $args;
1090
  }
1091
 
1092
- // Bail if this is an activity about posts and not comments.
1093
  if ( bp_activity_post_type_get_tracking_arg( $args['action'], 'comment_action_id' ) ) {
1094
  return $args;
1095
  }
@@ -1181,33 +1148,25 @@ function bp_blogs_setup_activity_loop_globals( $activity ) {
1181
 
1182
  $allow_comments = bp_blogs_comments_open( $activity );
1183
  $thread_depth = bp_blogs_get_blogmeta( $activity->item_id, 'thread_comments_depth' );
1184
- $moderation = bp_blogs_get_blogmeta( $activity->item_id, 'comment_moderation' );
1185
 
1186
  // Initialize a local object so we won't have to query this again in the
1187
  // comment loop.
1188
- if ( ! isset( buddypress()->blogs->allow_comments ) ) {
1189
  buddypress()->blogs->allow_comments = array();
1190
  }
1191
- if ( ! isset( buddypress()->blogs->thread_depth ) ) {
1192
  buddypress()->blogs->thread_depth = array();
1193
  }
1194
- if ( ! isset( buddypress()->blogs->comment_moderation ) ) {
1195
- buddypress()->blogs->comment_moderation = array();
1196
- }
1197
 
1198
- /*
1199
- * Cache comment settings in the buddypress() singleton for later reference.
1200
- *
1201
- * See bp_blogs_disable_activity_commenting() / bp_blogs_can_comment_reply().
1202
- *
1203
- * thread_depth is keyed by activity ID instead of blog ID because when we're
1204
- * in an actvity comment loop, we don't have access to the blog ID...
1205
- *
1206
- * Should probably object cache these values instead...
1207
- */
1208
- buddypress()->blogs->allow_comments[ $activity->id ] = $allow_comments;
1209
- buddypress()->blogs->thread_depth[ $activity->id ] = $thread_depth;
1210
- buddypress()->blogs->comment_moderation[ $activity->id ] = $moderation;
1211
  }
1212
 
1213
  /**
@@ -1262,22 +1221,17 @@ function bp_blogs_disable_activity_commenting( $retval ) {
1262
 
1263
  // It's a post type supporting comment tracking.
1264
  if ( bp_activity_type_supports( $type, 'post-type-comment-tracking' ) ) {
1265
- // The activity type is supporting comments or replies.
1266
  if ( bp_activity_type_supports( $type, 'post-type-comment-reply' ) ) {
1267
  // Setup some globals we'll need to reference later.
1268
  bp_blogs_setup_activity_loop_globals( $activities_template->activity );
1269
 
1270
  // If comments are closed for the WP blog post, we should disable
1271
  // activity comments for this activity entry.
1272
- if ( ! isset( buddypress()->blogs->allow_comments[ bp_get_activity_id() ] ) || ! buddypress()->blogs->allow_comments[ bp_get_activity_id() ] ) {
1273
  $retval = false;
1274
  }
1275
-
1276
- // If comments need moderation, disable activity commenting.
1277
- if ( isset( buddypress()->blogs->comment_moderation[ bp_get_activity_id() ] ) && buddypress()->blogs->comment_moderation[ bp_get_activity_id() ] ) {
1278
- $retval = false;
1279
- }
1280
- // The activity type does not support comments or replies.
1281
  } else {
1282
  $retval = false;
1283
  }
@@ -1312,7 +1266,7 @@ function bp_blogs_post_type_comments_avoid_duplicates( $retval ) {
1312
  return $retval;
1313
  }
1314
 
1315
- // Check the parent activity.
1316
  $parent_activity = new BP_Activity_Activity( bp_get_activity_item_id() );
1317
 
1318
  if ( isset( $parent_activity->type ) && bp_activity_post_type_get_tracking_arg( $parent_activity->type, 'post_type' ) ) {
@@ -1355,16 +1309,11 @@ function bp_blogs_can_comment_reply( $retval, $comment ) {
1355
  if ( isset( buddypress()->blogs->allow_comments[$comment->item_id] ) ){
1356
  // The blog post has closed off commenting, so we should disable all activity
1357
  // comments under the parent 'new_blog_post' activity entry.
1358
- if ( ! buddypress()->blogs->allow_comments[ $comment->item_id ] ) {
1359
  $retval = false;
1360
  }
1361
  }
1362
 
1363
- // If comments need moderation, disable activity commenting.
1364
- if ( isset( buddypress()->blogs->comment_moderation[ $comment->item_id ] ) && buddypress()->blogs->comment_moderation[ $comment->item_id ] ) {
1365
- $retval = false;
1366
- }
1367
-
1368
  return $retval;
1369
  }
1370
  add_filter( 'bp_activity_can_comment_reply', 'bp_blogs_can_comment_reply', 10, 2 );
@@ -1465,15 +1414,15 @@ function bp_blogs_activity_comment_single_action( $retval, $activity ) {
1465
  if ( ! empty( $blog_comment_id ) ) {
1466
  $bp = buddypress();
1467
 
1468
- // Check if a comment action id is set for the parent activity.
1469
  $comment_action_id = bp_activity_post_type_get_tracking_arg( $parent_activity->type, 'comment_action_id' );
1470
 
1471
- // Use the action string callback for the activity type.
1472
  if ( ! empty( $comment_action_id ) ) {
1473
  // Fake a 'new_{post_type}_comment' by cloning the activity object.
1474
  $object = clone $activity;
1475
 
1476
- // Set the type of the activity to be a comment about a post type.
1477
  $object->type = $comment_action_id;
1478
 
1479
  // Use the blog ID as the item_id.
@@ -1482,10 +1431,10 @@ function bp_blogs_activity_comment_single_action( $retval, $activity ) {
1482
  // Use comment ID as the secondary_item_id.
1483
  $object->secondary_item_id = $blog_comment_id;
1484
 
1485
- // Get the format callback for this activity comment.
1486
  $format_callback = bp_activity_post_type_get_tracking_arg( $comment_action_id, 'format_callback' );
1487
 
1488
- // Now format the activity action using the 'new_{post_type}_comment' action callback.
1489
  if ( is_callable( $format_callback ) ) {
1490
  $retval = call_user_func_array( $format_callback, array( '', $object ) );
1491
  }
127
  $blog_url = bp_blogs_get_blogmeta( $activity->item_id, 'url' );
128
  $blog_name = bp_blogs_get_blogmeta( $activity->item_id, 'name' );
129
 
130
+ $action = sprintf( __( '%s created the site %s', 'buddypress' ), bp_core_get_userlink( $activity->user_id ), '<a href="' . esc_url( $blog_url ) . '">' . esc_html( $blog_name ) . '</a>' );
 
 
 
 
 
131
 
132
  // Legacy filter - requires the BP_Blogs_Blog object.
133
  if ( has_filter( 'bp_blogs_activity_created_blog_action' ) ) {
209
  */
210
  if ( empty( $post_title ) ) {
211
  // Defaults to no title.
212
+ $post_title = esc_html__( '(no title)', 'buddypress' );
213
 
214
  switch_to_blog( $activity->item_id );
215
 
230
  }
231
 
232
  // Build the 'post link' part of the activity action string.
233
+ $post_link = '<a href="' . esc_url( $post_url ) . '">' . $post_title . '</a>';
234
 
235
  $user_link = bp_core_get_userlink( $activity->user_id );
236
 
237
  // Build the complete activity action string.
238
  if ( is_multisite() ) {
239
+ $action = sprintf( __( '%1$s wrote a new post, %2$s, on the site %3$s', 'buddypress' ), $user_link, $post_link, '<a href="' . esc_url( $blog_url ) . '">' . esc_html( $blog_name ) . '</a>' );
 
 
 
 
 
 
240
  } else {
241
+ $action = sprintf( __( '%1$s wrote a new post, %2$s', 'buddypress' ), $user_link, $post_link );
 
 
 
 
 
242
  }
243
 
244
  // Legacy filter - requires the post object.
287
 
288
  $blog_url = false;
289
 
290
+ // Try to get the blog url from the activity object
291
  if ( isset( $activity->blog_url ) ) {
292
  $blog_url = $activity->blog_url;
293
  } else {
296
 
297
  $blog_name = false;
298
 
299
+ // Try to get the blog name from the activity object
300
  if ( isset( $activity->blog_name ) ) {
301
  $blog_name = $activity->blog_name;
302
  } else {
313
 
314
  $post_url = false;
315
 
316
+ // Try to get the post url from the activity object
317
  if ( isset( $activity->post_url ) ) {
318
  $post_url = $activity->post_url;
319
 
328
 
329
  $post_title = false;
330
 
331
+ // Should be the case when the comment has just been published
332
  if ( isset( $activity->post_title ) ) {
333
  $post_title = $activity->post_title;
334
 
335
+ // If activity already exists try to get the post title from activity meta
336
  } elseif ( ! empty( $activity->id ) ) {
337
  $post_title = bp_activity_get_meta( $activity->id, 'post_title' );
338
  }
358
  restore_current_blog();
359
  }
360
 
361
+ $post_link = '<a href="' . esc_url( $post_url ) . '">' . $post_title . '</a>';
362
  $user_link = bp_core_get_userlink( $activity->user_id );
363
 
364
  if ( is_multisite() ) {
365
+ $action = sprintf( __( '%1$s commented on the post, %2$s, on the site %3$s', 'buddypress' ), $user_link, $post_link, '<a href="' . esc_url( $blog_url ) . '">' . esc_html( $blog_name ) . '</a>' );
 
 
 
 
 
 
366
  } else {
367
+ $action = sprintf( __( '%1$s commented on the post, %2$s', 'buddypress' ), $user_link, $post_link );
 
 
 
 
 
368
  }
369
 
370
  // Legacy filter - requires the comment object.
776
  return;
777
  }
778
 
 
 
 
 
 
 
779
  // Get userdata.
780
  if ( $params['user_id'] == bp_loggedin_user_id() ) {
781
  $user = buddypress()->loggedin_user->userdata;
783
  $user = bp_core_get_core_userdata( $params['user_id'] );
784
  }
785
 
786
+ // Get associated post type and set default comment parent
787
  $post_type = bp_activity_post_type_get_tracking_arg( $parent_activity->type, 'post_type' );
788
  $comment_parent = 0;
789
 
799
  'comment_author_email' => $user->user_email,
800
  'comment_author_url' => bp_core_get_user_domain( $params['user_id'], $user->user_nicename, $user->user_login ),
801
  'comment_content' => $params['content'],
802
+ 'comment_type' => '', // Could be interesting to add 'buddypress' here...
803
  'comment_parent' => (int) $comment_parent,
804
  'user_id' => $params['user_id'],
805
  'comment_approved' => 1
903
  $activity_ids = bp_activity_recurse_comments_activity_ids( $activity );
904
  $activity_ids[] = $activity_id;
905
 
906
+ // Handle multisite
907
  // switch to the blog where the comment was made.
908
  switch_to_blog( $parent_activity->item_id );
909
 
917
  // emulate bp_activity_delete_comment().
918
  BP_Activity_Activity::rebuild_activity_comment_tree( $parent_activity_id );
919
 
920
+ // Avoid the error message although the comments were successfully deleted
921
  $deleted = true;
922
 
923
  // We're overriding the default bp_activity_delete_comment() functionality
940
  return;
941
  }
942
 
943
+ // fetch parent activity item
944
  $parent_activity = new BP_Activity_Activity( $activity->item_id );
945
 
946
+ // if parent activity isn't a post type having the buddypress-activity support for comments, stop now!
947
  if ( ! bp_activity_type_supports( $parent_activity->type, 'post-type-comment-tracking' ) ) {
948
  return;
949
  }
965
  // Handle multisite.
966
  switch_to_blog( $parent_activity->item_id );
967
 
968
+ // Get the comment status
969
  $post_comment_status = wp_get_comment_status( $post_comment_id );
970
  $old_comment_status = $post_comment_status;
971
 
972
+ // No need to edit the activity, as it's the activity who's updating the comment
973
  remove_action( 'transition_comment_status', 'bp_activity_transition_post_type_comment_status', 10 );
974
  remove_action( 'bp_activity_post_type_comment', 'bp_blogs_comment_sync_activity_comment', 10 );
975
 
989
  }
990
  }
991
 
992
+ // Restore actions
993
  add_action( 'transition_comment_status', 'bp_activity_transition_post_type_comment_status', 10, 3 );
994
  add_action( 'bp_activity_post_type_comment', 'bp_blogs_comment_sync_activity_comment', 10, 4 );
995
 
1048
  return $args;
1049
  }
1050
 
1051
+ // Get the associated post type
1052
  $post_type = bp_activity_post_type_get_tracking_arg( $args['action'], 'post_type' );
1053
 
1054
+ // Bail if this is not an activity associated with a post type
1055
  if ( empty( $post_type ) ) {
1056
  return $args;
1057
  }
1058
 
1059
+ // Bail if this is an activity about posts and not comments
1060
  if ( bp_activity_post_type_get_tracking_arg( $args['action'], 'comment_action_id' ) ) {
1061
  return $args;
1062
  }
1148
 
1149
  $allow_comments = bp_blogs_comments_open( $activity );
1150
  $thread_depth = bp_blogs_get_blogmeta( $activity->item_id, 'thread_comments_depth' );
 
1151
 
1152
  // Initialize a local object so we won't have to query this again in the
1153
  // comment loop.
1154
+ if ( empty( buddypress()->blogs->allow_comments ) ) {
1155
  buddypress()->blogs->allow_comments = array();
1156
  }
1157
+ if ( empty( buddypress()->blogs->thread_depth ) ) {
1158
  buddypress()->blogs->thread_depth = array();
1159
  }
 
 
 
1160
 
1161
+ // Cache comment settings in the buddypress() singleton to reference later in
1162
+ // the activity comment loop
1163
+ // @see bp_blogs_disable_activity_replies()
1164
+ //
1165
+ // thread_depth is keyed by activity ID instead of blog ID because when we're
1166
+ // in a comment loop, we don't have access to the blog ID...
1167
+ // should probably object cache these values instead...
1168
+ buddypress()->blogs->allow_comments[ $activity->id ] = $allow_comments;
1169
+ buddypress()->blogs->thread_depth[ $activity->id ] = $thread_depth;
 
 
 
 
1170
  }
1171
 
1172
  /**
1221
 
1222
  // It's a post type supporting comment tracking.
1223
  if ( bp_activity_type_supports( $type, 'post-type-comment-tracking' ) ) {
1224
+ // The activity type is supporting comments or replies
1225
  if ( bp_activity_type_supports( $type, 'post-type-comment-reply' ) ) {
1226
  // Setup some globals we'll need to reference later.
1227
  bp_blogs_setup_activity_loop_globals( $activities_template->activity );
1228
 
1229
  // If comments are closed for the WP blog post, we should disable
1230
  // activity comments for this activity entry.
1231
+ if ( empty( buddypress()->blogs->allow_comments[ bp_get_activity_id() ] ) ) {
1232
  $retval = false;
1233
  }
1234
+ // The activity type does not support comments or replies
 
 
 
 
 
1235
  } else {
1236
  $retval = false;
1237
  }
1266
  return $retval;
1267
  }
1268
 
1269
+ // Check the parent activity
1270
  $parent_activity = new BP_Activity_Activity( bp_get_activity_item_id() );
1271
 
1272
  if ( isset( $parent_activity->type ) && bp_activity_post_type_get_tracking_arg( $parent_activity->type, 'post_type' ) ) {
1309
  if ( isset( buddypress()->blogs->allow_comments[$comment->item_id] ) ){
1310
  // The blog post has closed off commenting, so we should disable all activity
1311
  // comments under the parent 'new_blog_post' activity entry.
1312
+ if ( empty( buddypress()->blogs->allow_comments[$comment->item_id] ) ) {
1313
  $retval = false;
1314
  }
1315
  }
1316
 
 
 
 
 
 
1317
  return $retval;
1318
  }
1319
  add_filter( 'bp_activity_can_comment_reply', 'bp_blogs_can_comment_reply', 10, 2 );
1414
  if ( ! empty( $blog_comment_id ) ) {
1415
  $bp = buddypress();
1416
 
1417
+ // Check if a comment action id is set for the parent activity
1418
  $comment_action_id = bp_activity_post_type_get_tracking_arg( $parent_activity->type, 'comment_action_id' );
1419
 
1420
+ // Use the action string callback for the activity type
1421
  if ( ! empty( $comment_action_id ) ) {
1422
  // Fake a 'new_{post_type}_comment' by cloning the activity object.
1423
  $object = clone $activity;
1424
 
1425
+ // Set the type of the activity to be a comment about a post type
1426
  $object->type = $comment_action_id;
1427
 
1428
  // Use the blog ID as the item_id.
1431
  // Use comment ID as the secondary_item_id.
1432
  $object->secondary_item_id = $blog_comment_id;
1433
 
1434
+ // Get the format callback for this activity comment
1435
  $format_callback = bp_activity_post_type_get_tracking_arg( $comment_action_id, 'format_callback' );
1436
 
1437
+ // now format the activity action using the 'new_{post_type}_comment' action callback
1438
  if ( is_callable( $format_callback ) ) {
1439
  $retval = call_user_func_array( $format_callback, array( '', $object ) );
1440
  }
bp-blogs/bp-blogs-blocks.php DELETED
@@ -1,137 +0,0 @@
1
- <?php
2
- /**
3
- * BP Blogs Blocks Functions.
4
- *
5
- * @package BuddyPress
6
- * @subpackage BlogsBlocks
7
- * @since 9.0.0
8
- */
9
-
10
- // Exit if accessed directly.
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- }
14
-
15
- /**
16
- * Callback function to render the Recent Posts Block.
17
- *
18
- * @since 9.0.0
19
- *
20
- * @param array $attributes The block attributes.
21
- * @return string HTML output.
22
- */
23
- function bp_blogs_render_recent_posts_block( $attributes = array() ) {
24
- $block_args = wp_parse_args(
25
- $attributes,
26
- array(
27
- 'title' => __( 'Recent Networkwide Posts', 'buddypress' ),
28
- 'maxPosts' => 10,
29
- 'linkTitle' => false,
30
- )
31
- );
32
-
33
- $classnames = 'widget_bp_blogs_widget buddypress widget';
34
- $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) );
35
- $blogs_directory_link = bp_get_blogs_directory_permalink();
36
- $max_posts = (int) $block_args['maxPosts'];
37
- $no_posts = __( 'Sorry, there were no posts found.', 'buddypress' );
38
-
39
- // Set the Block's title.
40
- if ( true === $block_args['linkTitle'] ) {
41
- $widget_content = sprintf(
42
- '<h2 class="widget-title"><a href="%1$s">%2$s</a></h2>',
43
- esc_url( $blogs_directory_link ),
44
- esc_html( $block_args['title'] )
45
- );
46
- } else {
47
- $widget_content = sprintf( '<h2 class="widget-title">%s</h2>', esc_html( $block_args['title'] ) );
48
- }
49
-
50
- $blog_activities = bp_activity_get(
51
- array(
52
- 'max' => $max_posts,
53
- 'per_page' => $max_posts,
54
- 'user_id' => 0,
55
- 'scope' => false,
56
- 'filter' => array(
57
- 'object' => false,
58
- 'primary_id' => false,
59
- 'action' => 'new_blog_post',
60
- ),
61
- )
62
- );
63
-
64
- $blog_activities = reset( $blog_activities );
65
-
66
- if ( ! $blog_activities ) {
67
- $widget_content .= sprintf( '<div class="widget-error">%s</div>', $no_posts );
68
- } else {
69
- // Avoid conflicts with other activity loops.
70
- $reset_activities_template = null;
71
- if ( ! empty( $GLOBALS['activities_template'] ) ) {
72
- $reset_activities_template = $GLOBALS['activities_template'];
73
- }
74
-
75
- $GLOBALS['activities_template'] = new \stdClass();
76
- $activities = array();
77
-
78
- foreach ( $blog_activities as $blog_activity ) {
79
- $activity_content = '';
80
- $GLOBALS['activities_template']->activity = $blog_activity;
81
-
82
- if ( $blog_activity->content ) {
83
- /** This filter is documented in bp-activity/bp-activity-template.php. */
84
- $activity_content = apply_filters_ref_array( 'bp_get_activity_content_body', array( $blog_activity->content, &$blog_activity ) );
85
- $activity_content = sprintf(
86
- '<div class="activity-inner">%s</div>',
87
- $activity_content
88
- );
89
- }
90
-
91
- /** This filter is documented in bp-activity/bp-activity-template.php. */
92
- $actity_action = apply_filters_ref_array(
93
- 'bp_get_activity_action',
94
- array(
95
- bp_insert_activity_meta( $blog_activity->action ),
96
- &$blog_activity,
97
- array( 'no_timestamp' => false ),
98
- )
99
- );
100
-
101
- $activities[] = sprintf(
102
- '<li>
103
- <div class="activity-content">
104
- <div class="activity-header">%1$s</div>
105
- %2$s
106
- </div>
107
- </li>',
108
- $actity_action,
109
- $activity_content
110
- );
111
- }
112
-
113
- // Reset the global template loop.
114
- $GLOBALS['activities_template'] = $reset_activities_template;
115
-
116
- $widget_content .= sprintf(
117
- '<ul class="activity-list item-list">
118
- %s
119
- </ul>',
120
- implode( "\n", $activities )
121
- );
122
- }
123
-
124
- // Adds a container to make sure the block is styled even when used into the Columns parent block.
125
- $widget_content = sprintf( '<div class="bp-recent-posts-block-container">%s</div>', "\n" . $widget_content . "\n" );
126
-
127
- // Only add a block wrapper if not loaded into a Widgets sidebar.
128
- if ( ! did_action( 'dynamic_sidebar_before' ) ) {
129
- return sprintf(
130
- '<div %1$s>%2$s</div>',
131
- $wrapper_attributes,
132
- $widget_content
133
- );
134
- }
135
-
136
- return $widget_content;
137
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-blogs/bp-blogs-cache.php CHANGED
@@ -28,7 +28,7 @@ function bp_blogs_update_meta_cache( $blog_ids = false ) {
28
  'object_ids' => $blog_ids,
29
  'object_type' => buddypress()->blogs->id,
30
  'object_column' => 'blog_id',
31
- 'cache_group' => 'bp_blog_meta',
32
  'meta_table' => buddypress()->blogs->table_name_blogmeta,
33
  );
34
 
@@ -53,7 +53,7 @@ function bp_blogs_clear_blog_object_cache( $blog_id = 0, $user_id = 0 ) {
53
 
54
  // List actions to clear object caches on.
55
  add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
56
- add_action( 'bp_insert_site', 'bp_blogs_clear_blog_object_cache', 10, 2 );
57
  add_action( 'bp_blogs_remove_blog', 'bp_blogs_clear_blog_object_cache' );
58
 
59
  // List actions to clear super cached pages on, if super cache is installed.
28
  'object_ids' => $blog_ids,
29
  'object_type' => buddypress()->blogs->id,
30
  'object_column' => 'blog_id',
31
+ 'cache_group' => 'blog_meta',
32
  'meta_table' => buddypress()->blogs->table_name_blogmeta,
33
  );
34
 
53
 
54
  // List actions to clear object caches on.
55
  add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
56
+ add_action( 'wpmu_new_blog', 'bp_blogs_clear_blog_object_cache', 10, 2 );
57
  add_action( 'bp_blogs_remove_blog', 'bp_blogs_clear_blog_object_cache' );
58
 
59
  // List actions to clear super cached pages on, if super cache is installed.
bp-blogs/bp-blogs-filters.php CHANGED
@@ -135,54 +135,3 @@ function bp_blogs_register_custom_site_icon_size( $sizes ) {
135
  return $sizes;
136
  }
137
  add_filter( 'site_icon_image_sizes', 'bp_blogs_register_custom_site_icon_size' );
138
-
139
- /**
140
- * Use the mystery blog avatar for blogs.
141
- *
142
- * @since 7.0.0
143
- *
144
- * @param string $avatar Current avatar src.
145
- * @param array $params Avatar params.
146
- * @return string
147
- */
148
- function bp_blogs_default_avatar( $avatar, $params ) {
149
- if ( isset( $params['object'] ) && 'blog' === $params['object'] ) {
150
- if ( isset( $params['type'] ) && 'thumb' === $params['type'] ) {
151
- $file = 'mystery-blog-50.png';
152
- } else {
153
- $file = 'mystery-blog.png';
154
- }
155
-
156
- $avatar = buddypress()->plugin_url . "bp-core/images/$file";
157
- }
158
-
159
- return $avatar;
160
- }
161
- add_filter( 'bp_core_default_avatar', 'bp_blogs_default_avatar', 10, 2 );
162
- add_filter( 'bp_core_avatar_default_thumb', 'bp_blogs_default_avatar', 10, 2 );
163
-
164
- /**
165
- * Filters the column name during blog metadata queries.
166
- *
167
- * This filters 'sanitize_key', which is used during various core metadata
168
- * API functions: {@link https://core.trac.wordpress.org/browser/branches/4.9/src/wp-includes/meta.php?lines=47,160,324}.
169
- * Due to how we are passing our meta type, we need to ensure that the correct
170
- * DB column is referenced during blogmeta queries.
171
- *
172
- * @since 4.0.0
173
- *
174
- * @see bp_blogs_delete_blogmeta()
175
- * @see bp_blogs_get_blogmeta()
176
- * @see bp_blogs_update_blogmeta()
177
- * @see bp_blogs_add_blogmeta()
178
- *
179
- * @param string $retval
180
- *
181
- * @return string
182
- */
183
- function bp_blogs_filter_meta_column_name( $retval ) {
184
- if ( 'bp_blog_id' === $retval ) {
185
- $retval = 'blog_id';
186
- }
187
- return $retval;
188
- }
135
  return $sizes;
136
  }
137
  add_filter( 'site_icon_image_sizes', 'bp_blogs_register_custom_site_icon_size' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-blogs/bp-blogs-functions.php CHANGED
@@ -45,13 +45,13 @@ function bp_blogs_get_blogs( $args = '' ) {
45
 
46
  // Parse query arguments.
47
  $r = bp_parse_args( $args, array(
48
- 'type' => 'active', // 'active', 'alphabetical', 'newest', or 'random'.
49
- 'include_blog_ids' => false, // Array of blog IDs to include.
50
- 'user_id' => false, // Limit to blogs this user can post to.
51
- 'search_terms' => false, // Limit to blogs matching these search terms.
52
- 'per_page' => 20, // The number of results to return per page.
53
- 'page' => 1, // The page to return if limiting per page.
54
- 'update_meta_cache' => true // Whether to pre-fetch blogmeta.
55
  ), 'blogs_get_blogs' );
56
 
57
  // Get the blogs.
@@ -100,40 +100,40 @@ function bp_blogs_record_existing_blogs( $args = array() ) {
100
 
101
  // Query for all sites in network.
102
  $r = bp_parse_args( $args, array(
103
- 'offset' => (int) bp_get_option( '_bp_record_blogs_offset' ),
104
  'limit' => 50,
105
  'blog_ids' => array(),
106
  'site_id' => $wpdb->siteid
107
  ), 'record_existing_blogs' );
108
 
109
- // Truncate all BP blogs tables if starting fresh.
110
  if ( empty( $r['offset'] ) && empty( $r['blog_ids'] ) ) {
111
  $bp = buddypress();
112
 
113
- // Truncate user blogs table.
114
  $truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name}" );
115
  if ( is_wp_error( $truncate ) ) {
116
  return false;
117
  }
118
 
119
- // Truncate user blogmeta table.
120
  $truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name_blogmeta}" );
121
  if ( is_wp_error( $truncate ) ) {
122
  return false;
123
  }
124
  }
125
 
126
- // Multisite.
127
  if ( is_multisite() ) {
128
  $sql = array();
129
  $sql['select'] = $wpdb->prepare( "SELECT blog_id, last_updated FROM {$wpdb->base_prefix}blogs WHERE mature = 0 AND spam = 0 AND deleted = 0 AND site_id = %d", $r['site_id'] );
130
 
131
- // Omit root blog if large network.
132
- if ( bp_is_large_install() ) {
133
  $sql['omit_root_blog'] = $wpdb->prepare( "AND blog_id != %d", bp_get_root_blog_id() );
134
  }
135
 
136
- // Filter by selected blog IDs.
137
  if ( ! empty( $r['blog_ids'] ) ) {
138
  $in = implode( ',', wp_parse_id_list( $r['blog_ids'] ) );
139
  $sql['in'] = "AND blog_id IN ({$in})";
@@ -161,9 +161,9 @@ function bp_blogs_record_existing_blogs( $args = array() ) {
161
  }
162
  }
163
 
164
- // Bail if there are no blogs.
165
  if ( empty( $blogs ) ) {
166
- // Make sure we remove our offset marker.
167
  if ( is_multisite() ) {
168
  bp_delete_option( '_bp_record_blogs_offset' );
169
  }
@@ -175,7 +175,7 @@ function bp_blogs_record_existing_blogs( $args = array() ) {
175
  foreach ( (array) $blogs as $blog ) {
176
 
177
  // Ensure that the cache is clear after the table TRUNCATE above.
178
- wp_cache_delete( $blog->blog_id, 'bp_blog_meta' );
179
 
180
  // Get all users.
181
  $users = get_users( array(
@@ -192,24 +192,24 @@ function bp_blogs_record_existing_blogs( $args = array() ) {
192
  foreach ( (array) $users as $user_id ) {
193
  bp_blogs_add_user_to_blog( $user_id, false, $blog->blog_id );
194
 
195
- // Clear cache.
196
  bp_blogs_clear_blog_object_cache( $blog->blog_id, $user_id );
197
  }
198
 
199
- // Update blog last activity timestamp.
200
  if ( ! empty( $blog->last_updated ) && false !== strtotime( $blog->last_updated ) ) {
201
  bp_blogs_update_blogmeta( $blog->blog_id, 'last_activity', $blog->last_updated );
202
  }
203
  }
204
 
205
- // See if we need to do this again.
206
  if ( is_multisite() && empty( $r['blog_ids'] ) ) {
207
  $sql['offset'] = $wpdb->prepare( " OFFSET %d", $r['limit'] + $r['offset'] );
208
 
209
- // Check if there are more blogs to record.
210
  $blog_ids = $wpdb->get_results( implode( ' ', $sql ) );
211
 
212
- // We have more blogs; record offset and re-run function.
213
  if ( ! empty( $blog_ids ) ) {
214
  bp_update_option( '_bp_record_blogs_offset', $r['limit'] + $r['offset'] );
215
  bp_blogs_record_existing_blogs( array(
@@ -222,7 +222,7 @@ function bp_blogs_record_existing_blogs( $args = array() ) {
222
  // Bail since we have more blogs to record.
223
  return;
224
 
225
- // No more blogs; delete offset marker.
226
  } else {
227
  bp_delete_option( '_bp_record_blogs_offset' );
228
  }
@@ -362,7 +362,6 @@ function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
362
  $description = get_blog_option( $blog_id, 'blogdescription' );
363
  $close_old_posts = get_blog_option( $blog_id, 'close_comments_for_old_posts' );
364
  $close_days_old = get_blog_option( $blog_id, 'close_comments_days_old' );
365
- $moderation = get_blog_option( $blog_id, 'comment_moderation' );
366
 
367
  $thread_depth = get_blog_option( $blog_id, 'thread_comments' );
368
  if ( ! empty( $thread_depth ) ) {
@@ -385,7 +384,6 @@ function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
385
  bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'close_comments_for_old_posts', $close_old_posts );
386
  bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'close_comments_days_old', $close_days_old );
387
  bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'thread_comments_depth', $thread_depth );
388
- bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'comment_moderation', $moderation );
389
 
390
  $is_private = !empty( $_POST['blog_public'] ) && (int) $_POST['blog_public'] ? false : true;
391
 
@@ -411,7 +409,7 @@ function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
411
  */
412
  do_action_ref_array( 'bp_blogs_new_blog', array( &$recorded_blog, $is_private, $is_recorded, $no_activity ) );
413
  }
414
- add_action( 'bp_insert_site', 'bp_blogs_record_blog', 10, 2 );
415
 
416
  /**
417
  * Update blog name in BuddyPress blogmeta table.
@@ -527,19 +525,6 @@ function bp_blogs_update_option_thread_comments_depth( $oldvalue, $newvalue ) {
527
  }
528
  add_action( 'update_option_thread_comments_depth', 'bp_blogs_update_option_thread_comments_depth', 10, 2 );
529
 
530
- /**
531
- * When updating comment moderation, mirror value in blogmeta table.
532
- *
533
- * @since 3.0.0
534
- *
535
- * @param string $oldvalue Value before save. Passed by do_action() but unused here.
536
- * @param string $newvalue Value to change meta to.
537
- */
538
- function bp_blogs_update_option_comment_moderation( $oldvalue, $newvalue ) {
539
- bp_blogs_update_blogmeta( $GLOBALS['wpdb']->blogid, 'comment_moderation', $newvalue );
540
- }
541
- add_action( 'update_option_comment_moderation', 'bp_blogs_update_option_comment_moderation', 10, 2 );
542
-
543
  /**
544
  * Syncs site icon URLs to blogmeta.
545
  *
@@ -549,15 +534,13 @@ add_action( 'update_option_comment_moderation', 'bp_blogs_update_option_comment_
549
  * @param int|string $new_value New value
550
  */
551
  function bp_blogs_update_option_site_icon( $old_value, $new_value ) {
552
- $blog_id = get_current_blog_id();
553
-
554
  if ( 0 === $new_value ) {
555
- bp_blogs_update_blogmeta( $blog_id, 'site_icon_url_thumb', 0 );
556
- bp_blogs_update_blogmeta( $blog_id, 'site_icon_url_full', 0 );
557
  } else {
558
  // Save site icon URL as blogmeta.
559
- bp_blogs_update_blogmeta( $blog_id, 'site_icon_url_thumb', bp_blogs_get_site_icon_url( $blog_id, bp_core_avatar_thumb_width() ) );
560
- bp_blogs_update_blogmeta( $blog_id, 'site_icon_url_full', bp_blogs_get_site_icon_url( $blog_id, bp_core_avatar_full_width() ) );
561
  }
562
  }
563
  add_action( 'update_option_site_icon', 'bp_blogs_update_option_site_icon', 10, 2 );
@@ -577,7 +560,7 @@ function bp_blogs_delete_url_blogmeta( $site_id = 0 ) {
577
  bp_blogs_delete_blogmeta( (int) $site_id, 'url' );
578
  }
579
 
580
- if ( bp_is_running_wp( '4.9.0' ) ) {
581
  add_action( 'clean_site_cache', 'bp_blogs_delete_url_blogmeta' );
582
  } else {
583
  add_action( 'refresh_blog_details', 'bp_blogs_delete_url_blogmeta' );
@@ -664,7 +647,6 @@ function bp_blogs_update_post_activity_meta( $post, $activity, $activity_post_ob
664
  $args['filter'] = array(
665
  'object' => $activity_post_object->comments_tracking->component_id,
666
  'action' => $activity_post_object->comments_tracking->action_id,
667
- 'primary_id' => get_current_blog_id(),
668
  'secondary_id' => implode( ',', $comment_ids ),
669
  );
670
 
@@ -728,14 +710,14 @@ function bp_blogs_comment_sync_activity_comment( &$activity_id, $comment = null,
728
  // Set the current blog id.
729
  $blog_id = get_current_blog_id();
730
 
731
- // These activity metadatas are used to build the new_blog_comment action string.
732
  if ( ! empty( $activity_id ) && ! empty( $activity_args['item_id'] ) && 'new_blog_comment' === $activity_post_object->comment_action_id ) {
733
- // Add some post info in activity meta.
734
  bp_activity_update_meta( $activity_id, 'post_title', $comment->post->post_title );
735
  bp_activity_update_meta( $activity_id, 'post_url', esc_url_raw( add_query_arg( 'p', $comment->post->ID, home_url( '/' ) ) ) );
736
  }
737
 
738
- // Sync comment - activity comment.
739
  if ( ! bp_disable_blogforum_comments() ) {
740
 
741
  if ( ! empty( $_REQUEST['action'] ) ) {
@@ -751,7 +733,7 @@ function bp_blogs_comment_sync_activity_comment( &$activity_id, $comment = null,
751
  }
752
 
753
  if ( isset( $activity_post_object->action_id ) && isset( $activity_post_object->component_id ) ) {
754
- // Find the parent 'new_post_type' activity entry.
755
  $parent_activity_id = bp_activity_get_activity_id( array(
756
  'component' => $activity_post_object->component_id,
757
  'type' => $activity_post_object->action_id,
@@ -765,20 +747,20 @@ function bp_blogs_comment_sync_activity_comment( &$activity_id, $comment = null,
765
  }
766
  }
767
 
768
- // We found the parent activity entry
769
- // so let's go ahead and reconfigure some activity args.
770
  if ( ! empty( $parent_activity_id ) ) {
771
- // Set the parent activity entry ID.
772
  $activity_args['activity_id'] = $parent_activity_id;
773
 
774
- // Now see if the WP parent comment has a BP activity ID.
775
  $comment_parent = 0;
776
  if ( ! empty( $comment->comment_parent ) ) {
777
  $comment_parent = get_comment_meta( $comment->comment_parent, 'bp_activity_comment_id', true );
778
  }
779
 
780
  // WP parent comment does not have a BP activity ID
781
- // so set to 'new_' . post_type activity ID.
782
  if ( empty( $comment_parent ) ) {
783
  $comment_parent = $parent_activity_id;
784
  }
@@ -786,24 +768,24 @@ function bp_blogs_comment_sync_activity_comment( &$activity_id, $comment = null,
786
  $activity_args['parent_id'] = $comment_parent;
787
  $activity_args['skip_notification'] = true;
788
 
789
- // Could not find corresponding parent activity entry
790
- // so wipe out $args array.
791
  } else {
792
  $activity_args = array();
793
  }
794
 
795
- // Record in activity streams.
796
  if ( ! empty( $activity_args ) ) {
797
  $activity_id = bp_activity_new_comment( $activity_args );
798
 
799
  if ( empty( $activity_args['id'] ) ) {
800
- // The activity metadata to inform about the corresponding comment ID.
801
  bp_activity_update_meta( $activity_id, "bp_blogs_{$comment->post->post_type}_comment_id", $comment->comment_ID );
802
 
803
- // The comment metadata to inform about the corresponding activity ID.
804
  add_comment_meta( $comment->comment_ID, 'bp_activity_comment_id', $activity_id );
805
 
806
- // These activity metadatas are used to build the new_blog_comment action string.
807
  if ( 'new_blog_comment' === $activity_post_object->comment_action_id ) {
808
  bp_activity_update_meta( $activity_id, 'post_title', $comment->post->post_title );
809
  bp_activity_update_meta( $activity_id, 'post_url', esc_url_raw( add_query_arg( 'p', $comment->post->ID, home_url( '/' ) ) ) );
@@ -996,7 +978,7 @@ function bp_blogs_remove_blog( $blog_id ) {
996
  */
997
  do_action( 'bp_blogs_remove_blog', $blog_id );
998
  }
999
- add_action( 'bp_delete_site', 'bp_blogs_remove_blog' );
1000
 
1001
  /**
1002
  * Remove a blog from the tracker for a specific user.
@@ -1056,32 +1038,32 @@ function bp_blogs_post_type_remove_comment( $deleted, $comment_id, $activity_pos
1056
  * child post comments and associated activity comments.
1057
  */
1058
  if ( ! empty( $activity_id ) ) {
1059
- // Fetch the activity comments for the activity item.
1060
  $activity = bp_activity_get( array(
1061
  'in' => $activity_id,
1062
  'display_comments' => 'stream',
1063
  'spam' => 'all',
1064
  ) );
1065
 
1066
- // Get all activity comment IDs for the pending deleted item.
1067
  if ( ! empty( $activity['activities'] ) ) {
1068
  $activity_ids = bp_activity_recurse_comments_activity_ids( $activity );
1069
  $activity_ids[] = $activity_id;
1070
 
1071
- // Delete activity items.
1072
  foreach ( $activity_ids as $activity_id ) {
1073
  bp_activity_delete( array(
1074
  'id' => $activity_id
1075
  ) );
1076
  }
1077
 
1078
- // Remove associated blog comments.
1079
  bp_blogs_remove_associated_blog_comments( $activity_ids );
1080
 
1081
- // Rebuild activity comment tree.
1082
  BP_Activity_Activity::rebuild_activity_comment_tree( $activity['activities'][0]->item_id );
1083
 
1084
- // Set the result.
1085
  $deleted = true;
1086
  }
1087
  }
@@ -1220,7 +1202,7 @@ function bp_blogs_remove_data_for_blog( $blog_id ) {
1220
  */
1221
  do_action( 'bp_blogs_remove_data_for_blog', $blog_id );
1222
  }
1223
- add_action( 'bp_delete_site', 'bp_blogs_remove_data_for_blog', 1 );
1224
 
1225
  /**
1226
  * Get all of a user's blogs, as tracked by BuddyPress.
@@ -1305,27 +1287,20 @@ function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = fa
1305
 
1306
  // Legacy - if no meta_key is passed, delete all for the blog_id.
1307
  if ( empty( $meta_key ) ) {
1308
- $table_name = buddypress()->blogs->table_name_blogmeta;
1309
- $sql = "SELECT meta_key FROM {$table_name} WHERE blog_id = %d";
1310
- $query = $wpdb->prepare( $sql, $blog_id );
1311
- $keys = $wpdb->get_col( $query );
1312
-
1313
- // With no meta_key, ignore $delete_all.
1314
  $delete_all = false;
1315
  } else {
1316
  $keys = array( $meta_key );
1317
  }
1318
 
1319
  add_filter( 'query', 'bp_filter_metaid_column_name' );
1320
- add_filter( 'sanitize_key', 'bp_blogs_filter_meta_column_name' );
1321
 
1322
  $retval = false;
1323
  foreach ( $keys as $key ) {
1324
- $retval = delete_metadata( 'bp_blog', $blog_id, $key, $meta_value, $delete_all );
1325
  }
1326
 
1327
  remove_filter( 'query', 'bp_filter_metaid_column_name' );
1328
- remove_filter( 'sanitize_key', 'bp_blogs_filter_meta_column_name' );
1329
 
1330
  return $retval;
1331
  }
@@ -1348,9 +1323,7 @@ function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = fa
1348
  */
1349
  function bp_blogs_get_blogmeta( $blog_id, $meta_key = '', $single = true ) {
1350
  add_filter( 'query', 'bp_filter_metaid_column_name' );
1351
- add_filter( 'sanitize_key', 'bp_blogs_filter_meta_column_name' );
1352
- $retval = get_metadata( 'bp_blog', $blog_id, $meta_key, $single );
1353
- remove_filter( 'sanitize_key', 'bp_blogs_filter_meta_column_name' );
1354
  remove_filter( 'query', 'bp_filter_metaid_column_name' );
1355
 
1356
  return $retval;
@@ -1373,9 +1346,7 @@ function bp_blogs_get_blogmeta( $blog_id, $meta_key = '', $single = true ) {
1373
  */
1374
  function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value, $prev_value = '' ) {
1375
  add_filter( 'query', 'bp_filter_metaid_column_name' );
1376
- add_filter( 'sanitize_key', 'bp_blogs_filter_meta_column_name' );
1377
- $retval = update_metadata( 'bp_blog', $blog_id, $meta_key, $meta_value, $prev_value );
1378
- remove_filter( 'sanitize_key', 'bp_blogs_filter_meta_column_name' );
1379
  remove_filter( 'query', 'bp_filter_metaid_column_name' );
1380
 
1381
  return $retval;
@@ -1396,9 +1367,7 @@ function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value, $prev_value
1396
  */
1397
  function bp_blogs_add_blogmeta( $blog_id, $meta_key, $meta_value, $unique = false ) {
1398
  add_filter( 'query', 'bp_filter_metaid_column_name' );
1399
- add_filter( 'sanitize_key', 'bp_blogs_filter_meta_column_name' );
1400
- $retval = add_metadata( 'bp_blog', $blog_id, $meta_key, $meta_value, $unique );
1401
- remove_filter( 'sanitize_key', 'bp_blogs_filter_meta_column_name' );
1402
  remove_filter( 'query', 'bp_filter_metaid_column_name' );
1403
 
1404
  return $retval;
@@ -1435,24 +1404,9 @@ function bp_blogs_remove_data( $user_id ) {
1435
  do_action( 'bp_blogs_remove_data', $user_id );
1436
  }
1437
  add_action( 'wpmu_delete_user', 'bp_blogs_remove_data' );
 
1438
  add_action( 'bp_make_spam_user', 'bp_blogs_remove_data' );
1439
 
1440
- /**
1441
- * Deletes user XProfile data on the 'delete_user' hook.
1442
- *
1443
- * @since 6.0.0
1444
- *
1445
- * @param int $user_id The ID of the deleted user.
1446
- */
1447
- function bp_blogs_remove_data_on_delete_user( $user_id ) {
1448
- if ( ! bp_remove_user_data_on_delete_user_hook( 'blogs', $user_id ) ) {
1449
- return;
1450
- }
1451
-
1452
- bp_blogs_remove_data( $user_id );
1453
- }
1454
- add_action( 'delete_user', 'bp_blogs_remove_data_on_delete_user' );
1455
-
1456
  /**
1457
  * Restore all blog associations for a given user.
1458
  *
@@ -1478,139 +1432,3 @@ function bp_blogs_restore_data( $user_id = 0 ) {
1478
  }
1479
  }
1480
  add_action( 'bp_make_ham_user', 'bp_blogs_restore_data', 10, 1 );
1481
-
1482
- /**
1483
- * Checks whether blog creation is enabled.
1484
- *
1485
- * Returns true when blog creation is enabled for logged-in users only, or
1486
- * when it's enabled for new registrations.
1487
- *
1488
- * @since 1.0.0
1489
- * @since 7.0.0 The function has been moved into `bp-blogs/bp-blogs-functions.php`.
1490
- *
1491
- * @return bool True if blog registration is enabled.
1492
- */
1493
- function bp_blog_signup_enabled() {
1494
- $bp = buddypress();
1495
- $retval = true;
1496
- $active_signup = 'all';
1497
-
1498
- if ( isset( $bp->site_options['registration'] ) ) {
1499
- $active_signup = $bp->site_options['registration'];
1500
- }
1501
-
1502
- /**
1503
- * Filters whether or not blog creation is enabled.
1504
- *
1505
- * Return "all", "none", "blog" or "user".
1506
- *
1507
- * @since 1.0.0
1508
- *
1509
- * @param string $active_signup Value of the registration site option creation status.
1510
- */
1511
- $active_signup = apply_filters( 'wpmu_active_signup', $active_signup );
1512
-
1513
- if ( 'none' === $active_signup || 'user' === $active_signup ) {
1514
- $retval = false;
1515
- }
1516
-
1517
- return $retval;
1518
- }
1519
-
1520
- /**
1521
- * Returns the Blog signup's submitted vars.
1522
- *
1523
- * @since 7.0.0
1524
- *
1525
- * @return array An associative array containing the Blog signup's submitted vars.
1526
- */
1527
- function bp_blogs_get_signup_form_submitted_vars() {
1528
- $exprected_vars = array(
1529
- 'blogname' => '',
1530
- 'blog_title' => '',
1531
- 'blog_public' => 0,
1532
- );
1533
-
1534
- $submitted_vars = wp_parse_args( $_POST, $exprected_vars );
1535
-
1536
- return array_map( 'wp_unslash', array_intersect_key( $submitted_vars, $exprected_vars ) );
1537
- }
1538
-
1539
- /**
1540
- * Validate a blog creation submission.
1541
- *
1542
- * Essentially, a wrapper for {@link wpmu_validate_blog_signup()}.
1543
- *
1544
- * @since 1.0.0
1545
- * @since 7.0.0 Add the blog_name and blog_title parameters.
1546
- * The function has been moved into `bp-blogs/bp-blogs-functions.php`.
1547
- *
1548
- * @return array Contains the new site data and error messages.
1549
- */
1550
- function bp_blogs_validate_blog_form( $blog_name = '', $blog_title = '' ) {
1551
- $user = '';
1552
-
1553
- if ( is_user_logged_in() ) {
1554
- $user = wp_get_current_user();
1555
- }
1556
-
1557
- if ( ! $blog_name && ! $blog_title ) {
1558
- $submitted_vars = bp_blogs_get_signup_form_submitted_vars();
1559
-
1560
- if ( array_filter( $submitted_vars ) ) {
1561
- $blog_name = $submitted_vars['blogname'];
1562
- $blog_title = $submitted_vars['blog_title'];
1563
- }
1564
- }
1565
-
1566
- return wpmu_validate_blog_signup( $blog_name, $blog_title, $user );
1567
- }
1568
-
1569
- /**
1570
- * Gets the site icon URL even when BuddyPress is not network activated.
1571
- *
1572
- * @since 7.0.0
1573
- *
1574
- * @param integer $blog_id The ID of the blog to get the site icon URL for.
1575
- * @param integer $size The size of the site icon.
1576
- * @return string The site icon URL
1577
- */
1578
- function bp_blogs_get_site_icon_url( $blog_id = 0, $size = 512 ) {
1579
- if ( is_multisite() && ! bp_is_network_activated() && ! bp_is_root_blog( $blog_id ) ) {
1580
- $switched_blog = false;
1581
- $url = '';
1582
-
1583
- if ( $blog_id && get_current_blog_id() !== (int) $blog_id ) {
1584
- switch_to_blog( $blog_id );
1585
- $switched_blog = true;
1586
- }
1587
-
1588
- $site_icon_id = get_option( 'site_icon' );
1589
-
1590
- if ( $site_icon_id ) {
1591
- $site_icon_data = wp_get_attachment_metadata( $site_icon_id );
1592
- $sizes = wp_list_pluck( $site_icon_data['sizes'], 'width' );
1593
-
1594
- sort( $sizes );
1595
- $closest = 'full';
1596
-
1597
- foreach ( $sizes as $width ) {
1598
- $closest = array( $width, $width );
1599
-
1600
- if ( (int) $size < (int) $width ) {
1601
- break;
1602
- }
1603
- }
1604
-
1605
- $url = wp_get_attachment_image_url( $site_icon_id, $closest );
1606
- }
1607
-
1608
- if ( $switched_blog ) {
1609
- restore_current_blog();
1610
- }
1611
-
1612
- return $url;
1613
- }
1614
-
1615
- return get_site_icon_url( $size, '', $blog_id );
1616
- }
45
 
46
  // Parse query arguments.
47
  $r = bp_parse_args( $args, array(
48
+ 'type' => 'active', // 'active', 'alphabetical', 'newest', or 'random'
49
+ 'include_blog_ids' => false, // Array of blog IDs to include
50
+ 'user_id' => false, // Limit to blogs this user can post to
51
+ 'search_terms' => false, // Limit to blogs matching these search terms
52
+ 'per_page' => 20, // The number of results to return per page
53
+ 'page' => 1, // The page to return if limiting per page
54
+ 'update_meta_cache' => true // Whether to pre-fetch blogmeta
55
  ), 'blogs_get_blogs' );
56
 
57
  // Get the blogs.
100
 
101
  // Query for all sites in network.
102
  $r = bp_parse_args( $args, array(
103
+ 'offset' => false === bp_get_option( '_bp_record_blogs_offset' ) ? 0 : bp_get_option( '_bp_record_blogs_offset' ),
104
  'limit' => 50,
105
  'blog_ids' => array(),
106
  'site_id' => $wpdb->siteid
107
  ), 'record_existing_blogs' );
108
 
109
+ // Truncate all BP blogs tables if starting fresh
110
  if ( empty( $r['offset'] ) && empty( $r['blog_ids'] ) ) {
111
  $bp = buddypress();
112
 
113
+ // Truncate user blogs table
114
  $truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name}" );
115
  if ( is_wp_error( $truncate ) ) {
116
  return false;
117
  }
118
 
119
+ // Truncate user blogmeta table
120
  $truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name_blogmeta}" );
121
  if ( is_wp_error( $truncate ) ) {
122
  return false;
123
  }
124
  }
125
 
126
+ // Multisite
127
  if ( is_multisite() ) {
128
  $sql = array();
129
  $sql['select'] = $wpdb->prepare( "SELECT blog_id, last_updated FROM {$wpdb->base_prefix}blogs WHERE mature = 0 AND spam = 0 AND deleted = 0 AND site_id = %d", $r['site_id'] );
130
 
131
+ // Omit root blog if large network
132
+ if ( wp_is_large_network( 'users' ) ) {
133
  $sql['omit_root_blog'] = $wpdb->prepare( "AND blog_id != %d", bp_get_root_blog_id() );
134
  }
135
 
136
+ // Filter by selected blog IDs
137
  if ( ! empty( $r['blog_ids'] ) ) {
138
  $in = implode( ',', wp_parse_id_list( $r['blog_ids'] ) );
139
  $sql['in'] = "AND blog_id IN ({$in})";
161
  }
162
  }
163
 
164
+ // Bail if there are no blogs
165
  if ( empty( $blogs ) ) {
166
+ // Make sure we remove our offset marker
167
  if ( is_multisite() ) {
168
  bp_delete_option( '_bp_record_blogs_offset' );
169
  }
175
  foreach ( (array) $blogs as $blog ) {
176
 
177
  // Ensure that the cache is clear after the table TRUNCATE above.
178
+ wp_cache_delete( $blog->blog_id, 'blog_meta' );
179
 
180
  // Get all users.
181
  $users = get_users( array(
192
  foreach ( (array) $users as $user_id ) {
193
  bp_blogs_add_user_to_blog( $user_id, false, $blog->blog_id );
194
 
195
+ // Clear cache
196
  bp_blogs_clear_blog_object_cache( $blog->blog_id, $user_id );
197
  }
198
 
199
+ // Update blog last activity timestamp
200
  if ( ! empty( $blog->last_updated ) && false !== strtotime( $blog->last_updated ) ) {
201
  bp_blogs_update_blogmeta( $blog->blog_id, 'last_activity', $blog->last_updated );
202
  }
203
  }
204
 
205
+ // See if we need to do this again
206
  if ( is_multisite() && empty( $r['blog_ids'] ) ) {
207
  $sql['offset'] = $wpdb->prepare( " OFFSET %d", $r['limit'] + $r['offset'] );
208
 
209
+ // Check if there are more blogs to record
210
  $blog_ids = $wpdb->get_results( implode( ' ', $sql ) );
211
 
212
+ // We have more blogs; record offset and re-run function
213
  if ( ! empty( $blog_ids ) ) {
214
  bp_update_option( '_bp_record_blogs_offset', $r['limit'] + $r['offset'] );
215
  bp_blogs_record_existing_blogs( array(
222
  // Bail since we have more blogs to record.
223
  return;
224
 
225
+ // No more blogs; delete offset marker
226
  } else {
227
  bp_delete_option( '_bp_record_blogs_offset' );
228
  }
362
  $description = get_blog_option( $blog_id, 'blogdescription' );
363
  $close_old_posts = get_blog_option( $blog_id, 'close_comments_for_old_posts' );
364
  $close_days_old = get_blog_option( $blog_id, 'close_comments_days_old' );
 
365
 
366
  $thread_depth = get_blog_option( $blog_id, 'thread_comments' );
367
  if ( ! empty( $thread_depth ) ) {
384
  bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'close_comments_for_old_posts', $close_old_posts );
385
  bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'close_comments_days_old', $close_days_old );
386
  bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'thread_comments_depth', $thread_depth );
 
387
 
388
  $is_private = !empty( $_POST['blog_public'] ) && (int) $_POST['blog_public'] ? false : true;
389
 
409
  */
410
  do_action_ref_array( 'bp_blogs_new_blog', array( &$recorded_blog, $is_private, $is_recorded, $no_activity ) );
411
  }
412
+ add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 );
413
 
414
  /**
415
  * Update blog name in BuddyPress blogmeta table.
525
  }
526
  add_action( 'update_option_thread_comments_depth', 'bp_blogs_update_option_thread_comments_depth', 10, 2 );
527
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528
  /**
529
  * Syncs site icon URLs to blogmeta.
530
  *
534
  * @param int|string $new_value New value
535
  */
536
  function bp_blogs_update_option_site_icon( $old_value, $new_value ) {
 
 
537
  if ( 0 === $new_value ) {
538
+ bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_thumb', 0 );
539
+ bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_full', 0 );
540
  } else {
541
  // Save site icon URL as blogmeta.
542
+ bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_thumb', get_site_icon_url( bp_core_avatar_thumb_width() ) );
543
+ bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_full', get_site_icon_url( bp_core_avatar_full_width() ) );
544
  }
545
  }
546
  add_action( 'update_option_site_icon', 'bp_blogs_update_option_site_icon', 10, 2 );
560
  bp_blogs_delete_blogmeta( (int) $site_id, 'url' );
561
  }
562
 
563
+ if ( function_exists( 'wp_switch_roles_and_user' ) ) {
564
  add_action( 'clean_site_cache', 'bp_blogs_delete_url_blogmeta' );
565
  } else {
566
  add_action( 'refresh_blog_details', 'bp_blogs_delete_url_blogmeta' );
647
  $args['filter'] = array(
648
  'object' => $activity_post_object->comments_tracking->component_id,
649
  'action' => $activity_post_object->comments_tracking->action_id,
 
650
  'secondary_id' => implode( ',', $comment_ids ),
651
  );
652
 
710
  // Set the current blog id.
711
  $blog_id = get_current_blog_id();
712
 
713
+ // These activity metadatas are used to build the new_blog_comment action string
714
  if ( ! empty( $activity_id ) && ! empty( $activity_args['item_id'] ) && 'new_blog_comment' === $activity_post_object->comment_action_id ) {
715
+ // add some post info in activity meta
716
  bp_activity_update_meta( $activity_id, 'post_title', $comment->post->post_title );
717
  bp_activity_update_meta( $activity_id, 'post_url', esc_url_raw( add_query_arg( 'p', $comment->post->ID, home_url( '/' ) ) ) );
718
  }
719
 
720
+ // Sync comment - activity comment
721
  if ( ! bp_disable_blogforum_comments() ) {
722
 
723
  if ( ! empty( $_REQUEST['action'] ) ) {
733
  }
734
 
735
  if ( isset( $activity_post_object->action_id ) && isset( $activity_post_object->component_id ) ) {
736
+ // find the parent 'new_post_type' activity entry
737
  $parent_activity_id = bp_activity_get_activity_id( array(
738
  'component' => $activity_post_object->component_id,
739
  'type' => $activity_post_object->action_id,
747
  }
748
  }
749
 
750
+ // we found the parent activity entry
751
+ // so let's go ahead and reconfigure some activity args
752
  if ( ! empty( $parent_activity_id ) ) {
753
+ // set the parent activity entry ID
754
  $activity_args['activity_id'] = $parent_activity_id;
755
 
756
+ // now see if the WP parent comment has a BP activity ID
757
  $comment_parent = 0;
758
  if ( ! empty( $comment->comment_parent ) ) {
759
  $comment_parent = get_comment_meta( $comment->comment_parent, 'bp_activity_comment_id', true );
760
  }
761
 
762
  // WP parent comment does not have a BP activity ID
763
+ // so set to 'new_' . post_type activity ID
764
  if ( empty( $comment_parent ) ) {
765
  $comment_parent = $parent_activity_id;
766
  }
768
  $activity_args['parent_id'] = $comment_parent;
769
  $activity_args['skip_notification'] = true;
770
 
771
+ // could not find corresponding parent activity entry
772
+ // so wipe out $args array
773
  } else {
774
  $activity_args = array();
775
  }
776
 
777
+ // Record in activity streams
778
  if ( ! empty( $activity_args ) ) {
779
  $activity_id = bp_activity_new_comment( $activity_args );
780
 
781
  if ( empty( $activity_args['id'] ) ) {
782
+ // The activity metadata to inform about the corresponding comment ID
783
  bp_activity_update_meta( $activity_id, "bp_blogs_{$comment->post->post_type}_comment_id", $comment->comment_ID );
784
 
785
+ // The comment metadata to inform about the corresponding activity ID
786
  add_comment_meta( $comment->comment_ID, 'bp_activity_comment_id', $activity_id );
787
 
788
+ // These activity metadatas are used to build the new_blog_comment action string
789
  if ( 'new_blog_comment' === $activity_post_object->comment_action_id ) {
790
  bp_activity_update_meta( $activity_id, 'post_title', $comment->post->post_title );
791
  bp_activity_update_meta( $activity_id, 'post_url', esc_url_raw( add_query_arg( 'p', $comment->post->ID, home_url( '/' ) ) ) );
978
  */
979
  do_action( 'bp_blogs_remove_blog', $blog_id );
980
  }
981
+ add_action( 'delete_blog', 'bp_blogs_remove_blog' );
982
 
983
  /**
984
  * Remove a blog from the tracker for a specific user.
1038
  * child post comments and associated activity comments.
1039
  */
1040
  if ( ! empty( $activity_id ) ) {
1041
+ // fetch the activity comments for the activity item
1042
  $activity = bp_activity_get( array(
1043
  'in' => $activity_id,
1044
  'display_comments' => 'stream',
1045
  'spam' => 'all',
1046
  ) );
1047
 
1048
+ // get all activity comment IDs for the pending deleted item
1049
  if ( ! empty( $activity['activities'] ) ) {
1050
  $activity_ids = bp_activity_recurse_comments_activity_ids( $activity );
1051
  $activity_ids[] = $activity_id;
1052
 
1053
+ // delete activity items
1054
  foreach ( $activity_ids as $activity_id ) {
1055
  bp_activity_delete( array(
1056
  'id' => $activity_id
1057
  ) );
1058
  }
1059
 
1060
+ // remove associated blog comments
1061
  bp_blogs_remove_associated_blog_comments( $activity_ids );
1062
 
1063
+ // rebuild activity comment tree
1064
  BP_Activity_Activity::rebuild_activity_comment_tree( $activity['activities'][0]->item_id );
1065
 
1066
+ // Set the result
1067
  $deleted = true;
1068
  }
1069
  }
1202
  */
1203
  do_action( 'bp_blogs_remove_data_for_blog', $blog_id );
1204
  }
1205
+ add_action( 'delete_blog', 'bp_blogs_remove_data_for_blog', 1 );
1206
 
1207
  /**
1208
  * Get all of a user's blogs, as tracked by BuddyPress.
1287
 
1288
  // Legacy - if no meta_key is passed, delete all for the blog_id.
1289
  if ( empty( $meta_key ) ) {
1290
+ $keys = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM {$wpdb->blogmeta} WHERE blog_id = %d", $blog_id ) );
 
 
 
 
 
1291
  $delete_all = false;
1292
  } else {
1293
  $keys = array( $meta_key );
1294
  }
1295
 
1296
  add_filter( 'query', 'bp_filter_metaid_column_name' );
 
1297
 
1298
  $retval = false;
1299
  foreach ( $keys as $key ) {
1300
+ $retval = delete_metadata( 'blog', $blog_id, $key, $meta_value, $delete_all );
1301
  }
1302
 
1303
  remove_filter( 'query', 'bp_filter_metaid_column_name' );
 
1304
 
1305
  return $retval;
1306
  }
1323
  */
1324
  function bp_blogs_get_blogmeta( $blog_id, $meta_key = '', $single = true ) {
1325
  add_filter( 'query', 'bp_filter_metaid_column_name' );
1326
+ $retval = get_metadata( 'blog', $blog_id, $meta_key, $single );
 
 
1327
  remove_filter( 'query', 'bp_filter_metaid_column_name' );
1328
 
1329
  return $retval;
1346
  */
1347
  function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value, $prev_value = '' ) {
1348
  add_filter( 'query', 'bp_filter_metaid_column_name' );
1349
+ $retval = update_metadata( 'blog', $blog_id, $meta_key, $meta_value, $prev_value );
 
 
1350
  remove_filter( 'query', 'bp_filter_metaid_column_name' );
1351
 
1352
  return $retval;
1367
  */
1368
  function bp_blogs_add_blogmeta( $blog_id, $meta_key, $meta_value, $unique = false ) {
1369
  add_filter( 'query', 'bp_filter_metaid_column_name' );
1370
+ $retval = add_metadata( 'blog', $blog_id, $meta_key, $meta_value, $unique );
 
 
1371
  remove_filter( 'query', 'bp_filter_metaid_column_name' );
1372
 
1373
  return $retval;
1404
  do_action( 'bp_blogs_remove_data', $user_id );
1405
  }
1406
  add_action( 'wpmu_delete_user', 'bp_blogs_remove_data' );
1407
+ add_action( 'delete_user', 'bp_blogs_remove_data' );
1408
  add_action( 'bp_make_spam_user', 'bp_blogs_remove_data' );
1409
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1410
  /**
1411
  * Restore all blog associations for a given user.
1412
  *
1432
  }
1433
  }
1434
  add_action( 'bp_make_ham_user', 'bp_blogs_restore_data', 10, 1 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-blogs/bp-blogs-screens.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BuddyPress Blogs Screens.
4
+ *
5
+ * @package BuddyPress
6
+ * @subpackage BlogsScreens
7
+ * @since 1.5.0
8
+ */
9
+
10
+ // Exit if accessed directly.
11
+ 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;
19
+
20
+ /**
21
+ * Fires right before the loading of the My Blogs screen template file.
22
+ *
23
+ * @since 1.0.0
24
+ */
25
+ do_action( 'bp_blogs_screen_my_blogs' );
26
+
27
+ bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'members/single/home' ) );
28
+ }
29
+
30
+ /**
31
+ * Load the "Create a Blog" screen.
32
+ */
33
+ function bp_blogs_screen_create_a_blog() {
34
+
35
+ if ( !is_multisite() || !bp_is_blogs_component() || !bp_is_current_action( 'create' ) )
36
+ return false;
37
+
38
+ if ( !is_user_logged_in() || !bp_blog_signup_enabled() )
39
+ return false;
40
+
41
+ /**
42
+ * Fires right before the loading of the Create A Blog screen template file.
43
+ *
44
+ * @since 1.0.0
45
+ */
46
+ do_action( 'bp_blogs_screen_create_a_blog' );
47
+
48
+ bp_core_load_template( apply_filters( 'bp_blogs_template_create_a_blog', 'blogs/create' ) );
49
+ }
50
+ add_action( 'bp_screens', 'bp_blogs_screen_create_a_blog', 3 );
51
+
52
+ /**
53
+ * Load the top-level Blogs directory.
54
+ */
55
+ function bp_blogs_screen_index() {
56
+ if ( bp_is_blogs_directory() ) {
57
+ bp_update_is_directory( true, 'blogs' );
58
+
59
+ /**
60
+ * Fires right before the loading of the top-level Blogs screen template file.
61
+ *
62
+ * @since 1.0.0
63
+ */
64
+ do_action( 'bp_blogs_screen_index' );
65
+
66
+ bp_core_load_template( apply_filters( 'bp_blogs_screen_index', 'blogs/index' ) );
67
+ }
68
+ }
69
+ add_action( 'bp_screens', 'bp_blogs_screen_index', 2 );
70
+
71
+ /** Theme Compatibility *******************************************************/
72
+
73
+ new BP_Blogs_Theme_Compat();
bp-blogs/bp-blogs-template.php CHANGED
@@ -242,7 +242,6 @@ function bp_get_blogs_pagination_count() {
242
  if ( 1 == $blogs_template->total_blog_count ) {
243
  $message = __( 'Viewing 1 site', 'buddypress' );
244
  } else {
245
- /* translators: 1: the site from number. 2: the site to number. 3: the total number of sites. */
246
  $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s site', 'Viewing %1$s - %2$s of %3$s sites', $blogs_template->total_blog_count, 'buddypress' ), $from_num, $to_num, $total );
247
  }
248
 
@@ -298,14 +297,10 @@ function bp_blog_avatar( $args = '' ) {
298
  /**
299
  * Get a blog's avatar.
300
  *
301
- * At the moment, unless the blog has a site icon, the blog's avatar defaults
302
- * to the /bp-core/images/mystery-blog.png image or the Blog's Admin user avatar
303
- * if the `admin_user_id` argument contains the Blog's Admin user ID.
304
  *
305
  * @since 2.4.0 Introduced `$title` argument.
306
- * @since 6.0.0 Introduced the `$blog_id`, `$admin_user_id` and `html` arguments.
307
- * @since 7.0.0 Introduced the Blog's default avatar {@see bp_blogs_default_avatar()}.
308
- * Removed the `'bp_get_blog_avatar_' . $blog_id` filter (it was deprecated since 1.5).
309
  *
310
  * @see bp_core_fetch_avatar() For a description of arguments and
311
  * return values.
@@ -314,16 +309,13 @@ function bp_blog_avatar( $args = '' ) {
314
  * Arguments are listed here with an explanation of their defaults.
315
  * For more information about the arguments, see
316
  * {@link bp_core_fetch_avatar()}.
317
- * @type string $alt Default: 'Profile picture of site author [user name]'.
318
- * @type string $class Default: 'avatar'.
319
- * @type string $type Default: 'full'.
320
- * @type int|bool $width Default: false.
321
- * @type int|bool $height Default: false.
322
- * @type bool $id Currently unused.
323
- * @type bool $no_grav Default: false.
324
- * @type int $blog_id The blog ID. Default: O.
325
- * @type int $admin_user_id The Blog Admin user ID. Default: 0.
326
- * @type bool $html Default: true.
327
  * }
328
  * @return string User avatar string.
329
  */
@@ -336,52 +328,28 @@ function bp_blog_avatar( $args = '' ) {
336
  return false;
337
  }
338
 
339
- // Set default value for the `alt` attribute.
340
- $alt_attribute = __( 'Site icon for the blog', 'buddypress' );
341
-
342
- if ( ! $blogs_template && isset( $args['blog_id'] ) && $args['blog_id'] ) {
343
- $blog_id = (int) $args['blog_id'];
344
- } else {
345
- $blog_id = bp_get_blog_id();
346
-
347
- /* translators: %s is the blog name */
348
- $alt_attribute = sprintf( __( 'Site icon for %s', 'buddypress' ), bp_get_blog_name() );
349
- }
350
 
351
  // Parse the arguments.
352
  $r = bp_parse_args( $args, array(
353
- 'item_id' => $blog_id,
354
- 'avatar_dir' => 'blog-avatars',
355
- 'object' => 'blog',
356
- 'type' => 'full',
357
- 'width' => false,
358
- 'height' => false,
359
- 'class' => 'avatar',
360
- 'id' => false,
361
- 'alt' => $alt_attribute,
362
- 'no_grav' => false,
363
- 'html' => true,
364
- ), 'blog_avatar' );
365
-
366
- /**
367
- * If the `admin_user_id` was provided, make the Blog avatar
368
- * defaults to the Blog's Admin user one.
369
- */
370
- if ( isset( $r['admin_user_id'] ) && $r['admin_user_id'] ) {
371
- $r['item_id'] = (int) $r['admin_user_id'];
372
- $r['avatar_dir'] = 'avatars';
373
- $r['object'] = 'user';
374
- } elseif ( ! $r['no_grav'] ) {
375
- $r['no_grav'] = true;
376
- }
377
 
378
  // Use site icon if available.
379
  $avatar = '';
380
- if ( bp_is_active( 'blogs', 'site-icon' ) ) {
381
- $site_icon = bp_blogs_get_blogmeta( $blog_id, "site_icon_url_{$r['type']}" );
382
 
383
  // Never attempted to fetch site icon before; do it now!
384
  if ( '' === $site_icon ) {
 
 
385
  // Fetch the other size first.
386
  if ( 'full' === $r['type'] ) {
387
  $size = bp_core_avatar_thumb_width();
@@ -391,33 +359,29 @@ function bp_blog_avatar( $args = '' ) {
391
  $save_size = 'full';
392
  }
393
 
394
- $site_icon = bp_blogs_get_site_icon_url( $blog_id, $size );
395
-
396
  // Empty site icons get saved as integer 0.
397
  if ( empty( $site_icon ) ) {
398
  $site_icon = 0;
399
  }
400
 
401
  // Sync site icon for other size to blogmeta.
402
- bp_blogs_update_blogmeta( $blog_id, "site_icon_url_{$save_size}", $site_icon );
403
 
404
  // Now, fetch the size we want.
405
  if ( 0 !== $site_icon ) {
406
  $size = 'full' === $r['type'] ? bp_core_avatar_full_width() : bp_core_avatar_thumb_width();
407
- $site_icon = bp_blogs_get_site_icon_url( $blog_id, $size );
408
  }
409
 
410
  // Sync site icon to blogmeta.
411
- bp_blogs_update_blogmeta( $blog_id, "site_icon_url_{$r['type']}", $site_icon );
 
 
412
  }
413
 
414
  // We have a site icon.
415
  if ( ! is_numeric( $site_icon ) ) {
416
- // Just return the raw url of the Site Icon.
417
- if ( ! $r['html'] ) {
418
- return esc_url_raw( $site_icon );
419
- }
420
-
421
  if ( empty( $r['width'] ) && ! isset( $size ) ) {
422
  $size = 'full' === $r['type'] ? bp_core_avatar_full_width() : bp_core_avatar_thumb_width();
423
  } else {
@@ -428,16 +392,36 @@ function bp_blog_avatar( $args = '' ) {
428
  esc_url( $site_icon ),
429
  esc_attr( "{$r['class']} avatar-{$size}" ),
430
  esc_attr( $size ),
431
- esc_attr( $alt_attribute )
432
  );
433
  }
434
  }
435
 
436
- // Fallback to Default blog avatar.
437
  if ( '' === $avatar ) {
438
- $avatar = bp_core_fetch_avatar( $r );
 
 
 
 
 
 
 
 
 
 
439
  }
440
 
 
 
 
 
 
 
 
 
 
 
441
  /**
442
  * Filters a blog's avatar.
443
  *
@@ -448,7 +432,7 @@ function bp_blog_avatar( $args = '' ) {
448
  * @param int $blog_id ID of the blog whose avatar is being displayed.
449
  * @param array $r Array of arguments used when fetching avatar.
450
  */
451
- return apply_filters( 'bp_get_blog_avatar', $avatar, $blog_id, $r );
452
  }
453
 
454
  function bp_blog_permalink() {
@@ -637,8 +621,7 @@ function bp_blog_last_active( $args = array() ) {
637
 
638
  // Backwards compatibility for anyone forcing a 'true' active_format.
639
  if ( true === $r['active_format'] ) {
640
- /* translators: %s: human time diff of the last time the site was active. */
641
- $r['active_format'] = _x( 'Active %s', 'last time the site was active', 'buddypress' );
642
  }
643
 
644
  // Blog has been posted to at least once.
@@ -703,11 +686,7 @@ function bp_blog_latest_post( $args = array() ) {
703
  *
704
  * @param string $retval Title of the latest post.
705
  */
706
- $retval = sprintf(
707
- /* translators: %s: the title of the latest post */
708
- __( 'Latest Post: %s', 'buddypress' ),
709
- '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>'
710
- );
711
  } else {
712
 
713
  /** This filter is documented in bp-blogs/bp-blogs-template.php */
@@ -978,23 +957,52 @@ function bp_total_blog_count_for_user( $user_id = 0 ) {
978
  /** Blog Registration ********************************************************/
979
 
980
  /**
981
- * Output the wrapper markup for the blog signup form.
982
  *
983
- * @since 1.0.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
984
  *
985
  * @param string $blogname Optional. The default blog name (path or domain).
986
  * @param string $blog_title Optional. The default blog title.
987
  * @param string|WP_Error $errors Optional. The WP_Error object returned by a previous
988
  * submission attempt.
989
  */
990
- function bp_show_blog_signup_form( $blogname = '', $blog_title = '', $errors = '' ) {
991
- $blog_id = bp_blogs_validate_blog_signup();
992
 
993
- // Display the signup form.
994
- if ( false === $blog_id || is_wp_error( $blog_id ) ) {
995
- if ( is_wp_error( $blog_id ) ) {
996
- $errors = $blog_id;
997
- } else {
998
  $errors = new WP_Error();
999
  }
1000
 
@@ -1010,35 +1018,17 @@ function bp_show_blog_signup_form( $blogname = '', $blog_title = '', $errors = '
1010
  * }
1011
  */
1012
  $filtered_results = apply_filters('signup_another_blog_init', array('blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors ));
1013
- $blogname = $filtered_results['blogname'];
1014
- $blog_title = $filtered_results['blog_title'];
1015
- $errors = $filtered_results['errors'];
1016
 
1017
  if ( $errors->get_error_code() ) {
1018
- if ( in_array( $errors->get_error_code(), array( 'blogname', 'blog_title' ), true ) ) {
1019
- printf(
1020
- '<p class="error">%s</p>',
1021
- esc_html__( 'There was a problem; please correct the form below and try again.', 'buddypress' )
1022
- );
1023
- } else {
1024
- printf(
1025
- '<p class="error">%s</p>',
1026
- $errors->get_error_message()
1027
- );
1028
- }
1029
  }
1030
-
1031
- printf(
1032
- '<p>%1$s <strong>%2$s</strong>. %3$s</p>',
1033
- esc_html__( 'By filling out the form below, you can', 'buddypress' ),
1034
- esc_html__( 'add a site to your account', 'buddypress' ),
1035
- esc_html__( 'There is no limit to the number of sites that you can have, so create to your heart’s content, but blog responsibly!', 'buddypress' )
1036
- );
1037
  ?>
 
1038
 
1039
- <p>
1040
- <?php esc_html_e( 'If you’re not going to use a great domain, leave it for a new user. Now have at it!', 'buddypress' ); ?>
1041
- </p>
1042
 
1043
  <form class="standard-form" id="setupform" method="post" action="">
1044
 
@@ -1052,145 +1042,81 @@ function bp_show_blog_signup_form( $blogname = '', $blog_title = '', $errors = '
1052
  */
1053
  do_action( 'signup_hidden_fields' ); ?>
1054
 
1055
- <?php bp_blogs_signup_blog( $blogname, $blog_title, $errors ); ?>
1056
  <p>
1057
- <input id="submit" type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site', 'buddypress' ); ?>" />
1058
  </p>
1059
 
1060
  <?php wp_nonce_field( 'bp_blog_signup_form' ) ?>
1061
  </form>
1062
  <?php
1063
-
1064
- // Display the confirmation form.
1065
- } elseif ( is_numeric( $blog_id ) ) {
1066
- // Validate the site.
1067
- $site = get_site( $blog_id );
1068
-
1069
- if ( isset( $site->id ) && $site->id ) {
1070
- $current_user = wp_get_current_user();
1071
-
1072
- bp_blogs_confirm_blog_signup(
1073
- $site->domain,
1074
- $site->path,
1075
- $site->blogname,
1076
- $current_user->user_login,
1077
- $current_user->user_email,
1078
- '',
1079
- $site->id
1080
- );
1081
- }
1082
  }
1083
  }
1084
 
1085
  /**
1086
  * Output the input fields for the blog creation form.
1087
  *
1088
- * @since 1.0.0
1089
- *
1090
  * @param string $blogname Optional. The default blog name (path or domain).
1091
  * @param string $blog_title Optional. The default blog title.
1092
  * @param string|WP_Error $errors Optional. The WP_Error object returned by a previous
1093
  * submission attempt.
1094
  */
1095
  function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' ) {
1096
- $current_site = get_current_site();
1097
 
1098
- if ( ! $blogname && ! $blog_title ) {
1099
- $submitted_vars = bp_blogs_get_signup_form_submitted_vars();
 
 
 
1100
 
1101
- if ( array_filter( $submitted_vars ) ) {
1102
- $blogname = $submitted_vars['blogname'];
1103
- $blog_title = $submitted_vars['blog_title'];
1104
- }
1105
- }
1106
- ?>
1107
 
1108
- <p>
1109
- <?php
1110
- // Blog name.
1111
- if ( ! is_subdomain_install() ) {
1112
- printf( '<label for="blogname">%s</label>', esc_html__( 'Site Name:', 'buddypress' ) );
1113
- } else {
1114
- printf( '<label for="blogname">%s</label>', esc_html__( 'Site Domain:', 'buddypress' ) );
1115
- }
1116
 
1117
- if ( ! is_subdomain_install() ) {
1118
- printf(
1119
- '<span class="prefix_address">%1$s</span> <input name="blogname" type="text" id="blogname" value="%2$s" maxlength="63" style="width: auto!important" /><br />',
1120
- esc_html( $current_site->domain . $current_site->path ),
1121
- esc_attr( $blogname )
1122
- );
1123
- } else {
1124
- printf(
1125
- '<input name="blogname" type="text" id="blogname" value="%1$s" maxlength="63" style="width: auto!important" %2$s/> <span class="suffix_address">.%3$s</span><br />',
1126
- esc_attr( $blogname ),
1127
- bp_get_form_field_attributes( 'blogname' ),
1128
- bp_signup_get_subdomain_base()
1129
- );
1130
- }
1131
- if ( is_wp_error( $errors ) && $errors->get_error_message( 'blogname' ) ) {
1132
- printf( '<div class="error">%s</div>', $errors->get_error_message( 'blogname' ) );
1133
- }
1134
- ?>
1135
- </p>
1136
 
1137
- <?php
1138
- if ( ! is_user_logged_in() ) {
1139
- $url = sprintf(
1140
- /* translators: %s is the site domain and path. */
1141
- __( 'domain.%s' , 'buddypress' ),
1142
- $current_site->domain . $current_site->path
1143
- );
1144
 
1145
- if ( ! is_subdomain_install() ) {
1146
- $url = sprintf(
1147
- /* translators: %s is the site domain and path. */
1148
- __( '%sblogname' , 'buddypress'),
1149
- $current_site->domain . $current_site->path
1150
- );
1151
  }
1152
 
1153
- printf(
1154
- '<p>(<strong>%1$s.</strong> %2$s)</p>',
1155
- sprintf(
1156
- /* translators: %s is the site url. */
1157
- esc_html__( 'Your address will be %s' , 'buddypress' ), $url
1158
- ),
1159
- esc_html__( 'Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!' , 'buddypress' )
1160
- );
1161
  }
1162
 
1163
  // Blog Title.
1164
  ?>
1165
- <p>
1166
- <label for="blog_title"><?php esc_html_e('Site Title:', 'buddypress') ?></label>
1167
- <input name="blog_title" type="text" id="blog_title" value="<?php echo esc_html( $blog_title ); ?>" />
1168
-
1169
- <?php
1170
- if ( is_wp_error( $errors ) && $errors->get_error_message( 'blog_title' ) ) {
1171
- printf( '<div class="error">%s</div>', $errors->get_error_message( 'blog_title' ) );
1172
- }
1173
- ?>
1174
- </p>
1175
 
1176
- <fieldset class="create-site">
1177
 
1178
- <legend class="label"><?php esc_html_e( 'Privacy: I would like my site to appear in search engines, and in public listings around this network', 'buddypress' ) ?></legend>
1179
 
1180
- <p>
1181
- <label class="checkbox" for="blog_public_on">
1182
- <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php checked( ! isset( $_POST['blog_public'] ) || 1 === (int) $_POST['blog_public'] ); ?> />
1183
- <strong><?php esc_html_e( 'Yes' , 'buddypress'); ?></strong>
1184
- </label>
1185
- </p>
1186
 
1187
- <p>
1188
- <label class="checkbox" for="blog_public_off">
1189
- <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php checked( isset( $_POST['blog_public'] ) && 0 === (int) $_POST['blog_public'] ); ?> />
1190
- <strong><?php esc_html_e( 'No' , 'buddypress'); ?></strong>
1191
- </label>
1192
- </p>
1193
 
 
 
 
 
 
 
 
 
 
 
 
1194
  </fieldset>
1195
 
1196
  <?php
@@ -1202,7 +1128,7 @@ function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' )
1202
  *
1203
  * @param WP_Error $errors WP_Error object if any present.
1204
  */
1205
- do_action( 'signup_blogform', $errors );
1206
  }
1207
 
1208
  /**
@@ -1210,38 +1136,32 @@ function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' )
1210
  *
1211
  * Passes submitted values to {@link wpmu_create_blog()}.
1212
  *
1213
- * @since 1.0.0
1214
- *
1215
- * @return bool|int|WP_Error False if not a form submission, the Blog ID on success, a WP_Error object on failure.
1216
  */
1217
  function bp_blogs_validate_blog_signup() {
1218
- if ( ! isset( $_POST['submit'] ) ) {
 
 
1219
  return false;
1220
- }
1221
 
1222
- $current_site = get_current_site();
1223
  $current_user = wp_get_current_user();
1224
- $blog_name = '';
1225
- $blog_title = '';
1226
- $public = 1;
1227
 
1228
- if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['_wpnonce'] ), 'bp_blog_signup_form' ) || ! $current_user->ID ) {
1229
- return new WP_Error( 'bp_blogs_doing_it_wrong', __( 'Sorry, we cannot create the site. Please try again later.', 'buddypress' ) );
1230
- }
1231
 
1232
- $submitted_vars = bp_blogs_get_signup_form_submitted_vars();
 
1233
 
1234
- if ( array_filter( $submitted_vars ) ) {
1235
- $blog_name = $submitted_vars['blogname'];
1236
- $blog_title = $submitted_vars['blog_title'];
1237
- $public = (int) $submitted_vars['blog_public'];
1238
  }
1239
 
1240
- $blog = bp_blogs_validate_blog_form( $blog_name, $blog_title );
1241
 
1242
- if ( is_wp_error( $blog['errors'] ) && $blog['errors']->get_error_code() ) {
1243
- return $blog['errors'];
1244
- }
1245
 
1246
  /**
1247
  * Filters the default values for Blog meta.
@@ -1253,21 +1173,35 @@ function bp_blogs_validate_blog_signup() {
1253
  * string $public Default public status.
1254
  * }
1255
  */
1256
- $meta = apply_filters( 'add_signup_meta', array( 'lang_id' => 1, 'public' => $public ) );
1257
-
1258
- return wpmu_create_blog(
1259
- $blog['domain'],
1260
- $blog['path'],
1261
- $blog['blog_title'],
1262
- $current_user->ID, $meta,
1263
- $current_site->id
1264
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1265
  }
1266
 
1267
  /**
1268
  * Display a message after successful blog registration.
1269
  *
1270
- * @since 1.0.0
1271
  * @since 2.6.0 Introduced `$blog_id` parameter.
1272
  *
1273
  * @param string $domain The new blog's domain.
@@ -1285,12 +1219,11 @@ function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name,
1285
  restore_current_blog();
1286
 
1287
  ?>
1288
- <p class="success"><?php esc_html_e( 'Congratulations! You have successfully registered a new site.', 'buddypress' ) ?></p>
1289
  <p>
1290
  <?php printf(
1291
  '%s %s',
1292
  sprintf(
1293
- /* translators: %s: the link of the new site */
1294
  __( '%s is your new site.', 'buddypress' ),
1295
  sprintf( '<a href="%s">%s</a>', esc_url( $blog_url ), esc_url( $blog_url ) )
1296
  ),
@@ -1310,7 +1243,7 @@ function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name,
1310
  *
1311
  * @since 1.0.0
1312
  */
1313
- do_action( 'signup_finished' );
1314
  }
1315
 
1316
  /**
@@ -1349,30 +1282,9 @@ function bp_blogs_blog_tabs() {
1349
  } ?>
1350
 
1351
  <ul class="content-header-nav">
1352
- <li<?php if ( bp_is_current_action( 'my-blogs' ) || !bp_current_action() ) : ?> class="current"<?php endif; ?>>
1353
- <a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_blogs_slug() . '/my-blogs' ); ?>">
1354
- <?php
1355
- /* translators: %s: the User Display Name */
1356
- printf( __( "%s's Sites", 'buddypress' ), bp_get_displayed_user_fullname() );
1357
- ?>
1358
- </a>
1359
- </li>
1360
- <li<?php if ( bp_is_current_action( 'recent-posts' ) ) : ?> class="current"<?php endif; ?>>
1361
- <a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_blogs_slug() . '/recent-posts' ); ?>">
1362
- <?php
1363
- /* translators: %s: the User Display Name */
1364
- printf( __( "%s's Recent Posts", 'buddypress' ), bp_get_displayed_user_fullname() );
1365
- ?>
1366
- </a>
1367
- </li>
1368
- <li<?php if ( bp_is_current_action( 'recent-comments' ) ) : ?> class="current"<?php endif; ?>>
1369
- <a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_blogs_slug() . '/recent-comments' ); ?>">
1370
- <?php
1371
- /* translators: %s: the User Display Name */
1372
- printf( __( "%s's Recent Comments", 'buddypress' ), bp_get_displayed_user_fullname() );
1373
- ?>
1374
- </a>
1375
- </li>
1376
  </ul>
1377
 
1378
  <?php
@@ -1616,11 +1528,7 @@ function bp_blogs_get_profile_stats( $args = '' ) {
1616
  }
1617
 
1618
  // If blogs exist, show some formatted output.
1619
- $r['output'] = $r['before'];
1620
-
1621
- /* translators: %s: the number of blogs */
1622
- $r['output'] .= sprintf( _n( '%s site', '%s sites', $r['blogs'], 'buddypress' ), '<strong>' . $r['blogs'] . '</strong>' );
1623
- $r['output'] .= $r['after'];
1624
  }
1625
  }
1626
 
242
  if ( 1 == $blogs_template->total_blog_count ) {
243
  $message = __( 'Viewing 1 site', 'buddypress' );
244
  } else {
 
245
  $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s site', 'Viewing %1$s - %2$s of %3$s sites', $blogs_template->total_blog_count, 'buddypress' ), $from_num, $to_num, $total );
246
  }
247
 
297
  /**
298
  * Get a blog's avatar.
299
  *
300
+ * At the moment, blog avatars are simply the user avatars of the blog
301
+ * admin. Filter 'bp_get_blog_avatar_' . $blog_id to customize.
 
302
  *
303
  * @since 2.4.0 Introduced `$title` argument.
 
 
 
304
  *
305
  * @see bp_core_fetch_avatar() For a description of arguments and
306
  * return values.
309
  * Arguments are listed here with an explanation of their defaults.
310
  * For more information about the arguments, see
311
  * {@link bp_core_fetch_avatar()}.
312
+ * @type string $alt Default: 'Profile picture of site author [user name]'.
313
+ * @type string $class Default: 'avatar'.
314
+ * @type string $type Default: 'full'.
315
+ * @type int|bool $width Default: false.
316
+ * @type int|bool $height Default: false.
317
+ * @type bool $id Currently unused.
318
+ * @type bool $no_grav Default: true.
 
 
 
319
  * }
320
  * @return string User avatar string.
321
  */
328
  return false;
329
  }
330
 
331
+ $author_displayname = bp_core_get_user_displayname( $blogs_template->blog->admin_user_id );
 
 
 
 
 
 
 
 
 
 
332
 
333
  // Parse the arguments.
334
  $r = bp_parse_args( $args, array(
335
+ 'type' => 'full',
336
+ 'width' => false,
337
+ 'height' => false,
338
+ 'class' => 'avatar',
339
+ 'id' => false,
340
+ 'alt' => sprintf( __( 'Profile picture of site author %s', 'buddypress' ), esc_attr( $author_displayname ) ),
341
+ 'no_grav' => true,
342
+ ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
343
 
344
  // Use site icon if available.
345
  $avatar = '';
346
+ if ( bp_is_active( 'blogs', 'site-icon' ) && function_exists( 'has_site_icon' ) ) {
347
+ $site_icon = bp_blogs_get_blogmeta( bp_get_blog_id(), "site_icon_url_{$r['type']}" );
348
 
349
  // Never attempted to fetch site icon before; do it now!
350
  if ( '' === $site_icon ) {
351
+ switch_to_blog( bp_get_blog_id() );
352
+
353
  // Fetch the other size first.
354
  if ( 'full' === $r['type'] ) {
355
  $size = bp_core_avatar_thumb_width();
359
  $save_size = 'full';
360
  }
361
 
362
+ $site_icon = get_site_icon_url( $size );
 
363
  // Empty site icons get saved as integer 0.
364
  if ( empty( $site_icon ) ) {
365
  $site_icon = 0;
366
  }
367
 
368
  // Sync site icon for other size to blogmeta.
369
+ bp_blogs_update_blogmeta( bp_get_blog_id(), "site_icon_url_{$save_size}", $site_icon );
370
 
371
  // Now, fetch the size we want.
372
  if ( 0 !== $site_icon ) {
373
  $size = 'full' === $r['type'] ? bp_core_avatar_full_width() : bp_core_avatar_thumb_width();
374
+ $site_icon = get_site_icon_url( $size );
375
  }
376
 
377
  // Sync site icon to blogmeta.
378
+ bp_blogs_update_blogmeta( bp_get_blog_id(), "site_icon_url_{$r['type']}", $site_icon );
379
+
380
+ restore_current_blog();
381
  }
382
 
383
  // We have a site icon.
384
  if ( ! is_numeric( $site_icon ) ) {
 
 
 
 
 
385
  if ( empty( $r['width'] ) && ! isset( $size ) ) {
386
  $size = 'full' === $r['type'] ? bp_core_avatar_full_width() : bp_core_avatar_thumb_width();
387
  } else {
392
  esc_url( $site_icon ),
393
  esc_attr( "{$r['class']} avatar-{$size}" ),
394
  esc_attr( $size ),
395
+ sprintf( esc_attr__( 'Site icon for %s', 'buddypress' ), bp_get_blog_name() )
396
  );
397
  }
398
  }
399
 
400
+ // Fallback to user ID avatar.
401
  if ( '' === $avatar ) {
402
+ $avatar = bp_core_fetch_avatar( array(
403
+ 'item_id' => $blogs_template->blog->admin_user_id,
404
+ // 'avatar_dir' => 'blog-avatars',
405
+ // 'object' => 'blog',
406
+ 'type' => $r['type'],
407
+ 'alt' => $r['alt'],
408
+ 'css_id' => $r['id'],
409
+ 'class' => $r['class'],
410
+ 'width' => $r['width'],
411
+ 'height' => $r['height']
412
+ ) );
413
  }
414
 
415
+ /**
416
+ * In future BuddyPress versions you will be able to set the avatar for a blog.
417
+ * Right now you can use a filter with the ID of the blog to change it if you wish.
418
+ * By default it will return the avatar for the primary blog admin.
419
+ *
420
+ * This filter is deprecated as of BuddyPress 1.5 and may be removed in a future version.
421
+ * Use the 'bp_get_blog_avatar' filter instead.
422
+ */
423
+ $avatar = apply_filters( 'bp_get_blog_avatar_' . $blogs_template->blog->blog_id, $avatar );
424
+
425
  /**
426
  * Filters a blog's avatar.
427
  *
432
  * @param int $blog_id ID of the blog whose avatar is being displayed.
433
  * @param array $r Array of arguments used when fetching avatar.
434
  */
435
+ return apply_filters( 'bp_get_blog_avatar', $avatar, $blogs_template->blog->blog_id, $r );
436
  }
437
 
438
  function bp_blog_permalink() {
621
 
622
  // Backwards compatibility for anyone forcing a 'true' active_format.
623
  if ( true === $r['active_format'] ) {
624
+ $r['active_format'] = __( 'active %s', 'buddypress' );
 
625
  }
626
 
627
  // Blog has been posted to at least once.
686
  *
687
  * @param string $retval Title of the latest post.
688
  */
689
+ $retval = sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>' );
 
 
 
 
690
  } else {
691
 
692
  /** This filter is documented in bp-blogs/bp-blogs-template.php */
957
  /** Blog Registration ********************************************************/
958
 
959
  /**
960
+ * Checks whether blog creation is enabled.
961
  *
962
+ * Returns true when blog creation is enabled for logged-in users only, or
963
+ * when it's enabled for new registrations.
964
+ *
965
+ * @return bool True if blog registration is enabled.
966
+ */
967
+ function bp_blog_signup_enabled() {
968
+ $bp = buddypress();
969
+
970
+ $active_signup = isset( $bp->site_options['registration'] )
971
+ ? $bp->site_options['registration']
972
+ : 'all';
973
+
974
+ /**
975
+ * Filters whether or not blog creation is enabled.
976
+ *
977
+ * Return "all", "none", "blog" or "user".
978
+ *
979
+ * @since 1.0.0
980
+ *
981
+ * @param string $active_signup Value of the registration site option creation status.
982
+ */
983
+ $active_signup = apply_filters( 'wpmu_active_signup', $active_signup );
984
+
985
+ if ( 'none' == $active_signup || 'user' == $active_signup )
986
+ return false;
987
+
988
+ return true;
989
+ }
990
+
991
+ /**
992
+ * Output the wrapper markup for the blog signup form.
993
  *
994
  * @param string $blogname Optional. The default blog name (path or domain).
995
  * @param string $blog_title Optional. The default blog title.
996
  * @param string|WP_Error $errors Optional. The WP_Error object returned by a previous
997
  * submission attempt.
998
  */
999
+ function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = '') {
1000
+ global $current_user;
1001
 
1002
+ if ( isset($_POST['submit']) ) {
1003
+ bp_blogs_validate_blog_signup();
1004
+ } else {
1005
+ if ( ! is_wp_error($errors) ) {
 
1006
  $errors = new WP_Error();
1007
  }
1008
 
1018
  * }
1019
  */
1020
  $filtered_results = apply_filters('signup_another_blog_init', array('blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors ));
1021
+ $blogname = $filtered_results['blogname'];
1022
+ $blog_title = $filtered_results['blog_title'];
1023
+ $errors = $filtered_results['errors'];
1024
 
1025
  if ( $errors->get_error_code() ) {
1026
+ echo "<p>" . __('There was a problem; please correct the form below and try again.', 'buddypress') . "</p>";
 
 
 
 
 
 
 
 
 
 
1027
  }
 
 
 
 
 
 
 
1028
  ?>
1029
+ <p><?php printf(__("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!", 'buddypress'), $current_user->display_name) ?></p>
1030
 
1031
+ <p><?php _e("If you&#8217;re not going to use a great domain, leave it for a new user. Now have at it!", 'buddypress') ?></p>
 
 
1032
 
1033
  <form class="standard-form" id="setupform" method="post" action="">
1034
 
1042
  */
1043
  do_action( 'signup_hidden_fields' ); ?>
1044
 
1045
+ <?php bp_blogs_signup_blog($blogname, $blog_title, $errors); ?>
1046
  <p>
1047
+ <input id="submit" type="submit" name="submit" class="submit" value="<?php esc_attr_e('Create Site', 'buddypress') ?>" />
1048
  </p>
1049
 
1050
  <?php wp_nonce_field( 'bp_blog_signup_form' ) ?>
1051
  </form>
1052
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1053
  }
1054
  }
1055
 
1056
  /**
1057
  * Output the input fields for the blog creation form.
1058
  *
 
 
1059
  * @param string $blogname Optional. The default blog name (path or domain).
1060
  * @param string $blog_title Optional. The default blog title.
1061
  * @param string|WP_Error $errors Optional. The WP_Error object returned by a previous
1062
  * submission attempt.
1063
  */
1064
  function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' ) {
1065
+ global $current_site;
1066
 
1067
+ // Blog name.
1068
+ if( !is_subdomain_install() )
1069
+ echo '<label for="blogname">' . __('Site Name:', 'buddypress') . '</label>';
1070
+ else
1071
+ echo '<label for="blogname">' . __('Site Domain:', 'buddypress') . '</label>';
1072
 
1073
+ if ( $errmsg = $errors->get_error_message('blogname') ) { ?>
 
 
 
 
 
1074
 
1075
+ <p class="error"><?php echo $errmsg ?></p>
 
 
 
 
 
 
 
1076
 
1077
+ <?php }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1078
 
1079
+ if ( !is_subdomain_install() )
1080
+ echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span> <input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="63" /><br />';
1081
+ else
1082
+ echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="63" ' . bp_get_form_field_attributes( 'blogname' ) . '/> <span class="suffix_address">.' . bp_signup_get_subdomain_base() . '</span><br />';
1083
+
1084
+ if ( !is_user_logged_in() ) {
1085
+ print '(<strong>' . __( 'Your address will be ' , 'buddypress');
1086
 
1087
+ if ( !is_subdomain_install() ) {
1088
+ print $current_site->domain . $current_site->path . __( 'blogname' , 'buddypress');
1089
+ } else {
1090
+ print __( 'domain.' , 'buddypress') . $current_site->domain . $current_site->path;
 
 
1091
  }
1092
 
1093
+ echo '.</strong> ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)' , 'buddypress') . '</p>';
 
 
 
 
 
 
 
1094
  }
1095
 
1096
  // Blog Title.
1097
  ?>
 
 
 
 
 
 
 
 
 
 
1098
 
1099
+ <label for="blog_title"><?php _e('Site Title:', 'buddypress') ?></label>
1100
 
1101
+ <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
1102
 
1103
+ <p class="error"><?php echo $errmsg ?></p>
 
 
 
 
 
1104
 
1105
+ <?php }
1106
+ echo '<input name="blog_title" type="text" id="blog_title" value="'.esc_html($blog_title, 1).'" /></p>';
1107
+ ?>
 
 
 
1108
 
1109
+ <fieldset class="create-site">
1110
+ <legend class="label"><?php _e('Privacy: I would like my site to appear in search engines, and in public listings around this network', 'buddypress') ?></legend>
1111
+
1112
+ <label class="checkbox" for="blog_public_on">
1113
+ <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if( !isset( $_POST['blog_public'] ) || '1' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> />
1114
+ <strong><?php _e( 'Yes' , 'buddypress'); ?></strong>
1115
+ </label>
1116
+ <label class="checkbox" for="blog_public_off">
1117
+ <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if( isset( $_POST['blog_public'] ) && '0' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> />
1118
+ <strong><?php _e( 'No' , 'buddypress'); ?></strong>
1119
+ </label>
1120
  </fieldset>
1121
 
1122
  <?php
1128
  *
1129
  * @param WP_Error $errors WP_Error object if any present.
1130
  */
1131
+ do_action('signup_blogform', $errors);
1132
  }
1133
 
1134
  /**
1136
  *
1137
  * Passes submitted values to {@link wpmu_create_blog()}.
1138
  *
1139
+ * @return bool True on success, false on failure.
 
 
1140
  */
1141
  function bp_blogs_validate_blog_signup() {
1142
+ global $wpdb, $current_user, $blogname, $blog_title, $errors, $domain, $path, $current_site;
1143
+
1144
+ if ( !check_admin_referer( 'bp_blog_signup_form' ) )
1145
  return false;
 
1146
 
 
1147
  $current_user = wp_get_current_user();
 
 
 
1148
 
1149
+ if( !is_user_logged_in() )
1150
+ die();
 
1151
 
1152
+ $result = bp_blogs_validate_blog_form();
1153
+ extract($result);
1154
 
1155
+ if ( $errors->get_error_code() ) {
1156
+ unset($_POST['submit']);
1157
+ bp_show_blog_signup_form( $blogname, $blog_title, $errors );
1158
+ return false;
1159
  }
1160
 
1161
+ $public = (int) $_POST['blog_public'];
1162
 
1163
+ // Depreciated.
1164
+ $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) );
 
1165
 
1166
  /**
1167
  * Filters the default values for Blog meta.
1173
  * string $public Default public status.
1174
  * }
1175
  */
1176
+ $meta = apply_filters( 'add_signup_meta', $meta );
1177
+
1178
+ // If this is a subdomain install, set up the site inside the root domain.
1179
+ if ( is_subdomain_install() )
1180
+ $domain = $blogname . '.' . preg_replace( '|^www\.|', '', $current_site->domain );
1181
+
1182
+ $blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid );
1183
+ bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta, $blog_id );
1184
+ return true;
1185
+ }
1186
+
1187
+ /**
1188
+ * Validate a blog creation submission.
1189
+ *
1190
+ * Essentially, a wrapper for {@link wpmu_validate_blog_signup()}.
1191
+ *
1192
+ * @return array Contains the new site data and error messages.
1193
+ */
1194
+ function bp_blogs_validate_blog_form() {
1195
+ $user = '';
1196
+ if ( is_user_logged_in() )
1197
+ $user = wp_get_current_user();
1198
+
1199
+ return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);
1200
  }
1201
 
1202
  /**
1203
  * Display a message after successful blog registration.
1204
  *
 
1205
  * @since 2.6.0 Introduced `$blog_id` parameter.
1206
  *
1207
  * @param string $domain The new blog's domain.
1219
  restore_current_blog();
1220
 
1221
  ?>
1222
+ <p><?php _e( 'Congratulations! You have successfully registered a new site.', 'buddypress' ) ?></p>
1223
  <p>
1224
  <?php printf(
1225
  '%s %s',
1226
  sprintf(
 
1227
  __( '%s is your new site.', 'buddypress' ),
1228
  sprintf( '<a href="%s">%s</a>', esc_url( $blog_url ), esc_url( $blog_url ) )
1229
  ),
1243
  *
1244
  * @since 1.0.0
1245
  */
1246
+ do_action('signup_finished');
1247
  }
1248
 
1249
  /**
1282
  } ?>
1283
 
1284
  <ul class="content-header-nav">
1285
+ <li<?php if ( bp_is_current_action( 'my-blogs' ) || !bp_current_action() ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_blogs_slug() . '/my-blogs' ); ?>"><?php printf( __( "%s's Sites", 'buddypress' ), bp_get_displayed_user_fullname() ); ?></a></li>
1286
+ <li<?php if ( bp_is_current_action( 'recent-posts' ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_blogs_slug() . '/recent-posts' ); ?>"><?php printf( __( "%s's Recent Posts", 'buddypress' ), bp_get_displayed_user_fullname() ); ?></a></li>
1287
+ <li<?php if ( bp_is_current_action( 'recent-comments' ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_blogs_slug() . '/recent-comments' ); ?>"><?php printf( __( "%s's Recent Comments", 'buddypress' ), bp_get_displayed_user_fullname() ); ?></a></li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1288
  </ul>
1289
 
1290
  <?php
1528
  }
1529
 
1530
  // If blogs exist, show some formatted output.
1531
+ $r['output'] = $r['before'] . sprintf( _n( '%s site', '%s sites', $r['blogs'], 'buddypress' ), '<strong>' . $r['blogs'] . '</strong>' ) . $r['after'];
 
 
 
 
1532
  }
1533
  }
1534
 
bp-blogs/classes/class-bp-blogs-blog.php CHANGED
@@ -86,7 +86,7 @@ class BP_Blogs_Blog {
86
  $this->user_id = apply_filters( 'bp_blogs_blog_user_id_before_save', $this->user_id, $this->id );
87
 
88
  /**
89
- * Filters the blog ID before save.
90
  *
91
  * @since 1.0.0
92
  *
86
  $this->user_id = apply_filters( 'bp_blogs_blog_user_id_before_save', $this->user_id, $this->id );
87
 
88
  /**
89
+ * Filters the blog blog ID before save.
90
  *
91
  * @since 1.0.0
92
  *
bp-blogs/classes/class-bp-blogs-component.php CHANGED
@@ -63,7 +63,7 @@ class BP_Blogs_Component extends BP_Component {
63
  );
64
 
65
  $meta_tables = array(
66
- 'bp_blog' => $bp->table_prefix . 'bp_user_blogs_blogmeta',
67
  );
68
 
69
  // Fetch the default directory title.
@@ -81,11 +81,6 @@ class BP_Blogs_Component extends BP_Component {
81
  'autocomplete_all' => defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ),
82
  'global_tables' => $global_tables,
83
  'meta_tables' => $meta_tables,
84
- 'block_globals' => array(
85
- 'bp/recent-posts' => array(
86
- 'widget_classnames' => array( 'widget_bp_blogs_widget', 'buddypress' ),
87
- ),
88
- ),
89
  );
90
 
91
  // Setup the globals.
@@ -130,6 +125,8 @@ class BP_Blogs_Component extends BP_Component {
130
  // Files to include.
131
  $includes = array(
132
  'cache',
 
 
133
  'template',
134
  'filters',
135
  'functions',
@@ -137,57 +134,16 @@ class BP_Blogs_Component extends BP_Component {
137
 
138
  if ( bp_is_active( 'activity' ) ) {
139
  $includes[] = 'activity';
 
140
 
141
- if ( is_multisite() ) {
142
- $includes[] = 'widgets';
143
- $includes[] = 'blocks';
144
- }
145
  }
146
 
147
  // Include the files.
148
  parent::includes( $includes );
149
  }
150
 
151
- /**
152
- * Late includes method.
153
- *
154
- * Only load up certain code when on specific pages.
155
- *
156
- * @since 3.0.0
157
- */
158
- public function late_includes() {
159
- // Bail if PHPUnit is running.
160
- if ( defined( 'BP_TESTS_DIR' ) ) {
161
- return;
162
- }
163
-
164
- // Bail if not on a blogs page or not multisite.
165
- if ( ! bp_is_blogs_component() || ! is_multisite() ) {
166
- return;
167
- }
168
-
169
- // Actions.
170
- if ( isset( $_GET['random-blog'] ) ) {
171
- require $this->path . 'bp-blogs/actions/random.php';
172
- }
173
-
174
- // Screens.
175
- if ( bp_is_user() ) {
176
- require $this->path . 'bp-blogs/screens/my-blogs.php';
177
- } else {
178
- if ( bp_is_blogs_directory() ) {
179
- require $this->path . 'bp-blogs/screens/directory.php';
180
- }
181
-
182
- if ( is_user_logged_in() && bp_is_current_action( 'create' ) ) {
183
- require $this->path . 'bp-blogs/screens/create.php';
184
- }
185
-
186
- // Theme compatibility.
187
- new BP_Blogs_Theme_Compat();
188
- }
189
- }
190
-
191
  /**
192
  * Set up component navigation for bp-blogs.
193
  *
@@ -230,7 +186,7 @@ class BP_Blogs_Component extends BP_Component {
230
  sprintf(
231
  '<span class="%s">%s</span>',
232
  esc_attr( $class ),
233
- esc_html( $count )
234
  )
235
  );
236
  $main_nav = array(
@@ -335,11 +291,7 @@ class BP_Blogs_Component extends BP_Component {
335
  $bp->bp_options_avatar = bp_core_fetch_avatar( array(
336
  'item_id' => bp_displayed_user_id(),
337
  'type' => 'thumb',
338
- 'alt' => sprintf(
339
- /* translators: %s: member name */
340
- __( 'Profile picture of %s', 'buddypress' ),
341
- bp_get_displayed_user_fullname()
342
- ),
343
  ) );
344
  $bp->bp_options_title = bp_get_displayed_user_fullname();
345
  }
@@ -357,79 +309,9 @@ class BP_Blogs_Component extends BP_Component {
357
 
358
  // Global groups.
359
  wp_cache_add_global_groups( array(
360
- 'bp_blog_meta'
361
  ) );
362
 
363
  parent::setup_cache_groups();
364
  }
365
-
366
- /**
367
- * Init the BP REST API.
368
- *
369
- * @since 6.0.0
370
- *
371
- * @param array $controllers Optional. See BP_Component::rest_api_init() for
372
- * description.
373
- */
374
- public function rest_api_init( $controllers = array() ) {
375
- if ( is_multisite() ) {
376
- $controllers = array(
377
- 'BP_REST_Blogs_Endpoint',
378
- );
379
-
380
- // Support to Blog Avatar.
381
- if ( bp_is_active( 'blogs', 'site-icon' ) ) {
382
- $controllers[] = 'BP_REST_Attachments_Blog_Avatar_Endpoint';
383
- }
384
- }
385
-
386
- parent::rest_api_init( $controllers );
387
- }
388
-
389
- /**
390
- * Register the BP Blogs Blocks.
391
- *
392
- * @since 9.0.0
393
- *
394
- * @param array $blocks Optional. See BP_Component::blocks_init() for
395
- * description.
396
- */
397
- public function blocks_init( $blocks = array() ) {
398
- $blocks = array();
399
-
400
- if ( is_multisite() && bp_is_active( 'activity' ) ) {
401
- $blocks['bp/recent-posts'] = array(
402
- 'name' => 'bp/recent-posts',
403
- 'editor_script' => 'bp-recent-posts-block',
404
- 'editor_script_url' => plugins_url( 'js/blocks/recent-posts.js', dirname( __FILE__ ) ),
405
- 'editor_script_deps' => array(
406
- 'wp-blocks',
407
- 'wp-element',
408
- 'wp-components',
409
- 'wp-i18n',
410
- 'wp-block-editor',
411
- 'bp-block-components',
412
- ),
413
- 'style' => 'bp-recent-posts-block',
414
- 'style_url' => plugins_url( 'css/blocks/recent-posts.css', dirname( __FILE__ ) ),
415
- 'attributes' => array(
416
- 'title' => array(
417
- 'type' => 'string',
418
- 'default' => __( 'Recent Networkwide Posts', 'buddypress' ),
419
- ),
420
- 'maxPosts' => array(
421
- 'type' => 'number',
422
- 'default' => 10,
423
- ),
424
- 'linkTitle' => array(
425
- 'type' => 'boolean',
426
- 'default' => false,
427
- ),
428
- ),
429
- 'render_callback' => 'bp_blogs_render_recent_posts_block',
430
- );
431
- }
432
-
433
- parent::blocks_init( $blocks );
434
- }
435
  }
63
  );
64
 
65
  $meta_tables = array(
66
+ 'blog' => $bp->table_prefix . 'bp_user_blogs_blogmeta',
67
  );
68
 
69
  // Fetch the default directory title.
81
  'autocomplete_all' => defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ),
82
  'global_tables' => $global_tables,
83
  'meta_tables' => $meta_tables,
 
 
 
 
 
84
  );
85
 
86
  // Setup the globals.
125
  // Files to include.
126
  $includes = array(
127
  'cache',
128
+ 'actions',
129
+ 'screens',
130
  'template',
131
  'filters',
132
  'functions',
134
 
135
  if ( bp_is_active( 'activity' ) ) {
136
  $includes[] = 'activity';
137
+ }
138
 
139
+ if ( is_multisite() ) {
140
+ $includes[] = 'widgets';
 
 
141
  }
142
 
143
  // Include the files.
144
  parent::includes( $includes );
145
  }
146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  /**
148
  * Set up component navigation for bp-blogs.
149
  *
186
  sprintf(
187
  '<span class="%s">%s</span>',
188
  esc_attr( $class ),
189
+ bp_core_number_format( $count )
190
  )
191
  );
192
  $main_nav = array(
291
  $bp->bp_options_avatar = bp_core_fetch_avatar( array(
292
  'item_id' => bp_displayed_user_id(),
293
  'type' => 'thumb',
294
+ 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() )
 
 
 
 
295
  ) );
296
  $bp->bp_options_title = bp_get_displayed_user_fullname();
297
  }
309
 
310
  // Global groups.
311
  wp_cache_add_global_groups( array(
312
+ 'blog_meta'
313
  ) );
314
 
315
  parent::setup_cache_groups();
316
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  }
bp-blogs/classes/class-bp-blogs-recent-posts-widget.php CHANGED
@@ -12,23 +12,17 @@ defined( 'ABSPATH' ) || exit;
12
 
13
  /**
14
  * The Recent Networkwide Posts widget.
15
- *
16
- * @since 1.0.0
17
  */
18
  class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
19
 
20
  /**
21
  * Constructor method.
22
- *
23
- * @since 1.5.0
24
- * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
25
  */
26
  public function __construct() {
27
  $widget_ops = array(
28
  'description' => __( 'A list of recently published posts from across your network.', 'buddypress' ),
29
  'classname' => 'widget_bp_blogs_widget buddypress widget',
30
  'customize_selective_refresh' => true,
31
- 'show_instance_in_rest' => true,
32
  );
33
  parent::__construct( false, $name = _x( '(BuddyPress) Recent Networkwide Posts', 'widget name', 'buddypress' ), $widget_ops );
34
  }
@@ -67,8 +61,7 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
67
  echo $args['before_widget'];
68
  echo $args['before_title'] . $title . $args['after_title'];
69
 
70
- $max_limit = bp_get_widget_max_count_limit( __CLASS__ );
71
- if ( empty( $instance['max_posts'] ) || $instance['max_posts'] > $max_limit ) {
72
  $instance['max_posts'] = 10;
73
  }
74
 
@@ -135,13 +128,10 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
135
  * @return array $instance The parsed options to be saved.
136
  */
137
  public function update( $new_instance, $old_instance ) {
138
- $instance = $old_instance;
139
-
140
- $max_limit = bp_get_widget_max_count_limit( __CLASS__ );
141
-
142
  $instance['title'] = strip_tags( $new_instance['title'] );
143
- $instance['max_posts'] = $new_instance['max_posts'] > $max_limit ? $max_limit : intval( $new_instance['max_posts'] );
144
- $instance['link_title'] = ! empty( $new_instance['link_title'] );
145
 
146
  return $instance;
147
  }
@@ -160,17 +150,15 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
160
  'link_title' => false,
161
  ) );
162
 
163
- $max_limit = bp_get_widget_max_count_limit( __CLASS__ );
164
-
165
  $title = strip_tags( $instance['title'] );
166
- $max_posts = $instance['max_posts'] > $max_limit ? $max_limit : intval( $instance['max_posts'] );
167
  $link_title = (bool) $instance['link_title'];
168
 
169
  ?>
170
 
171
  <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _ex( 'Title:', 'Label for the Title field of the Recent Networkwide Posts widget', 'buddypress' ); ?> <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( $title ); ?>" style="width: 100%;" /></label></p>
172
  <p><label for="<?php echo $this->get_field_id( '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 Blogs directory', 'buddypress' ); ?></label></p>
173
- <p><label for="<?php echo $this->get_field_id( 'max_posts' ); ?>"><?php _e( 'Max posts to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="number" min="1" max="<?php echo esc_attr( $max_limit ); ?>" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p>
174
  <?php
175
  }
176
  }
12
 
13
  /**
14
  * The Recent Networkwide Posts widget.
 
 
15
  */
16
  class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
17
 
18
  /**
19
  * Constructor method.
 
 
 
20
  */
21
  public function __construct() {
22
  $widget_ops = array(
23
  'description' => __( 'A list of recently published posts from across your network.', 'buddypress' ),
24
  'classname' => 'widget_bp_blogs_widget buddypress widget',
25
  'customize_selective_refresh' => true,
 
26
  );
27
  parent::__construct( false, $name = _x( '(BuddyPress) Recent Networkwide Posts', 'widget name', 'buddypress' ), $widget_ops );
28
  }
61
  echo $args['before_widget'];
62
  echo $args['before_title'] . $title . $args['after_title'];
63
 
64
+ if ( empty( $instance['max_posts'] ) || empty( $instance['max_posts'] ) ) {
 
65
  $instance['max_posts'] = 10;
66
  }
67
 
128
  * @return array $instance The parsed options to be saved.
129
  */
130
  public function update( $new_instance, $old_instance ) {
131
+ $instance = $old_instance;
 
 
 
132
  $instance['title'] = strip_tags( $new_instance['title'] );
133
+ $instance['max_posts'] = strip_tags( $new_instance['max_posts'] );
134
+ $instance['link_title'] = (bool) $new_instance['link_title'];
135
 
136
  return $instance;
137
  }
150
  'link_title' => false,
151
  ) );
152
 
 
 
153
  $title = strip_tags( $instance['title'] );
154
+ $max_posts = strip_tags( $instance['max_posts'] );
155
  $link_title = (bool) $instance['link_title'];
156
 
157
  ?>
158
 
159
  <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _ex( 'Title:', 'Label for the Title field of the Recent Networkwide Posts widget', 'buddypress' ); ?> <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( $title ); ?>" style="width: 100%;" /></label></p>
160
  <p><label for="<?php echo $this->get_field_id( '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 Blogs directory', 'buddypress' ); ?></label></p>
161
+ <p><label for="<?php echo $this->get_field_id( 'max_posts' ); ?>"><?php _e( 'Max posts to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="text" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p>
162
  <?php
163
  }
164
  }
bp-blogs/classes/class-bp-rest-attachments-blog-avatar-endpoint.php DELETED
@@ -1,325 +0,0 @@
1
- <?php
2
- /**
3
- * BP REST: BP_REST_Attachments_Blog_Avatar_Endpoint class
4
- *
5
- * @package BuddyPress
6
- * @since 6.0.0
7
- */
8
-
9
- defined( 'ABSPATH' ) || exit;
10
-
11
- /**
12
- * Blog avatar endpoints.
13
- *
14
- * @since 6.0.0
15
- */
16
- class BP_REST_Attachments_Blog_Avatar_Endpoint extends WP_REST_Controller {
17
-
18
- use BP_REST_Attachments;
19
-
20
- /**
21
- * Reuse some parts of the BP_REST_Blogs_Endpoint class.
22
- *
23
- * @since 6.0.0
24
- *
25
- * @var BP_REST_Blogs_Endpoint
26
- */
27
- protected $blogs_endpoint;
28
-
29
- /**
30
- * This variable is used to query for the requested blog only once.
31
- * It is set during the permission check methods.
32
- *
33
- * @since 6.0.0
34
- *
35
- * @var BP_Blogs_Blog
36
- */
37
- protected $blog;
38
-
39
- /**
40
- * Constructor.
41
- *
42
- * @since 6.0.0
43
- */
44
- public function __construct() {
45
- $this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
46
- $this->rest_base = buddypress()->blogs->id;
47
- $this->blogs_endpoint = new BP_REST_Blogs_Endpoint();
48
- }
49
-
50
- /**
51
- * Register the component routes.
52
- *
53
- * @since 6.0.0
54
- */
55
- public function register_routes() {
56
- register_rest_route(
57
- $this->namespace,
58
- '/' . $this->rest_base . '/(?P<id>[\d]+)/avatar',
59
- array(
60
- 'args' => array(
61
- 'id' => array(
62
- 'description' => __( 'A unique numeric ID for the blog.', 'buddypress' ),
63
- 'type' => 'integer',
64
- ),
65
- ),
66
- array(
67
- 'methods' => WP_REST_Server::READABLE,
68
- 'callback' => array( $this, 'get_item' ),
69
- 'permission_callback' => array( $this, 'get_item_permissions_check' ),
70
- 'args' => $this->get_item_collection_params(),
71
- ),
72
- 'schema' => array( $this, 'get_item_schema' ),
73
- )
74
- );
75
- }
76
-
77
- /**
78
- * Fetch an existing blog avatar.
79
- *
80
- * @since 6.0.0
81
- *
82
- * @param WP_REST_Request $request Full details about the request.
83
- * @return WP_REST_Response|WP_Error
84
- */
85
- public function get_item( $request ) {
86
- $no_user_grav = (bool) $request->get_param( 'no_user_gravatar' );
87
-
88
- if ( empty( $this->blog->admin_user_id ) && ! $no_user_grav ) {
89
- return new WP_Error(
90
- 'bp_rest_blog_avatar_get_item_user_failed',
91
- __( 'There was a problem confirming the blog\'s user admin is valid.', 'buddypress' ),
92
- array(
93
- 'status' => 500,
94
- )
95
- );
96
- }
97
-
98
- // Set the requested args.
99
- $requested_args = array(
100
- 'blog_id' => $request->get_param( 'id' ),
101
- 'no_grav' => $no_user_grav,
102
- 'html' => (bool) $request->get_param( 'html' ),
103
- );
104
-
105
- if ( ! empty( $request->get_param( 'alt' ) ) ) {
106
- $requested_args['alt'] = $request->get_param( 'alt' );
107
- }
108
-
109
- if ( ! $no_user_grav ) {
110
- $requested_args['admin_user_id'] = (int) $this->blog->admin_user_id;
111
-
112
- if ( ! isset( $requested_args['alt'] ) ) {
113
- $requested_args['alt'] = '';
114
- }
115
- }
116
-
117
- $args = array();
118
- foreach ( array( 'full', 'thumb' ) as $type ) {
119
- $requested_args['type'] = $type;
120
- $args[ $type ] = bp_get_blog_avatar( $requested_args );
121
- }
122
-
123
- // Get the avatar object.
124
- $avatar = $this->get_avatar_object( $args );
125
-
126
- if ( ! $avatar->full && ! $avatar->thumb ) {
127
- return new WP_Error(
128
- 'bp_rest_attachments_blog_avatar_no_image',
129
- __( 'Sorry, there was a problem fetching the blog avatar.', 'buddypress' ),
130
- array(
131
- 'status' => 500,
132
- )
133
- );
134
- }
135
-
136
- $retval = array(
137
- $this->prepare_response_for_collection(
138
- $this->prepare_item_for_response( $avatar, $request )
139
- ),
140
- );
141
-
142
- $response = rest_ensure_response( $retval );
143
-
144
- /**
145
- * Fires after a blog avatar is fetched via the REST API.
146
- *
147
- * @since 6.0.0
148
- *
149
- * @param stdClass $avatar The avatar object.
150
- * @param WP_REST_Response $response The response data.
151
- * @param WP_REST_Request $request The request sent to the API.
152
- */
153
- do_action( 'bp_rest_attachments_blog_avatar_get_item', $avatar, $response, $request );
154
-
155
- return $response;
156
- }
157
-
158
- /**
159
- * Checks if a given request has access to get a blog avatar.
160
- *
161
- * @since 6.0.0
162
- *
163
- * @param WP_REST_Request $request Full details about the request.
164
- * @return true|WP_Error
165
- */
166
- public function get_item_permissions_check( $request ) {
167
- $retval = new WP_Error(
168
- 'bp_rest_authorization_required',
169
- __( 'Sorry, you are not allowed to perform this action.', 'buddypress' ),
170
- array(
171
- 'status' => rest_authorization_required_code(),
172
- )
173
- );
174
-
175
- $this->blog = $this->blogs_endpoint->get_blog_object( $request->get_param( 'id' ) );
176
-
177
- if ( ! is_object( $this->blog ) ) {
178
- $retval = new WP_Error(
179
- 'bp_rest_blog_invalid_id',
180
- __( 'Invalid group ID.', 'buddypress' ),
181
- array(
182
- 'status' => 404,
183
- )
184
- );
185
- } elseif ( buddypress()->avatar->show_avatars ) {
186
- $retval = true;
187
- } else {
188
- $retval = new WP_Error(
189
- 'bp_rest_attachments_blog_avatar_disabled',
190
- __( 'Sorry, blog avatar is disabled.', 'buddypress' ),
191
- array(
192
- 'status' => 500,
193
- )
194
- );
195
- }
196
-
197
- /**
198
- * Filter the blog avatar `get_item` permissions check.
199
- *
200
- * @since 6.0.0
201
- *
202
- * @param true|WP_Error $retval Returned value.
203
- * @param WP_REST_Request $request The request sent to the API.
204
- */
205
- return apply_filters( 'bp_rest_attachments_blog_avatar_get_item_permissions_check', $retval, $request );
206
- }
207
-
208
- /**
209
- * Prepares avatar data to return as an object.
210
- *
211
- * @since 6.0.0
212
- *
213
- * @param stdClass $avatar Avatar object.
214
- * @param WP_REST_Request $request Full details about the request.
215
- * @return WP_REST_Response
216
- */
217
- public function prepare_item_for_response( $avatar, $request ) {
218
- $data = array(
219
- 'full' => $avatar->full,
220
- 'thumb' => $avatar->thumb,
221
- );
222
-
223
- $context = ! empty( $request->get_param( 'context' ) ) ? $request->get_param( 'context' ) : 'view';
224
- $data = $this->add_additional_fields_to_object( $data, $request );
225
- $data = $this->filter_response_by_context( $data, $context );
226
- $response = rest_ensure_response( $data );
227
-
228
- /**
229
- * Filter a blog avatar value returned from the API.
230
- *
231
- * @since 6.0.0
232
- *
233
- * @param WP_REST_Response $response Response.
234
- * @param WP_REST_Request $request Request used to generate the response.
235
- * @param object $avatar Avatar object.
236
- */
237
- return apply_filters( 'bp_rest_attachments_blog_avatar_prepare_value', $response, $request, $avatar );
238
- }
239
-
240
- /**
241
- * Get the blog avatar schema, conforming to JSON Schema.
242
- *
243
- * @since 6.0.0
244
- *
245
- * @return array
246
- */
247
- public function get_item_schema() {
248
- if ( is_null( $this->schema ) ) {
249
- $this->schema = array(
250
- '$schema' => 'http://json-schema.org/draft-04/schema#',
251
- 'title' => 'bp_attachments_blog_avatar',
252
- 'type' => 'object',
253
- 'properties' => array(
254
- 'full' => array(
255
- 'context' => array( 'view', 'edit' ),
256
- 'description' => __( 'Full size of the image file.', 'buddypress' ),
257
- 'type' => 'string',
258
- 'format' => 'uri',
259
- 'readonly' => true,
260
- ),
261
- 'thumb' => array(
262
- 'context' => array( 'view', 'edit' ),
263
- 'description' => __( 'Thumb size of the image file.', 'buddypress' ),
264
- 'type' => 'string',
265
- 'format' => 'uri',
266
- 'readonly' => true,
267
- ),
268
- ),
269
- );
270
- }
271
-
272
- /**
273
- * Filters the blog avatar schema.
274
- *
275
- * @param array $schema The endpoint schema.
276
- */
277
- return apply_filters( 'bp_rest_attachments_blog_avatar_schema', $this->add_additional_fields_schema( $this->schema ) );
278
- }
279
-
280
- /**
281
- * Get the query params for the `get_item`.
282
- *
283
- * @since 6.0.0
284
- *
285
- * @return array
286
- */
287
- public function get_item_collection_params() {
288
- $params = parent::get_collection_params();
289
- $params['context']['default'] = 'view';
290
-
291
- // Removing unused params.
292
- unset( $params['search'], $params['page'], $params['per_page'] );
293
-
294
- $params['html'] = array(
295
- 'description' => __( 'Whether to return an <img> HTML element, vs a raw URL to an avatar.', 'buddypress' ),
296
- 'default' => false,
297
- 'type' => 'boolean',
298
- 'sanitize_callback' => 'rest_sanitize_boolean',
299
- 'validate_callback' => 'rest_validate_request_arg',
300
- );
301
-
302
- $params['alt'] = array(
303
- 'description' => __( 'The alt attribute for the <img> element.', 'buddypress' ),
304
- 'default' => '',
305
- 'type' => 'string',
306
- 'sanitize_callback' => 'sanitize_text_field',
307
- 'validate_callback' => 'rest_validate_request_arg',
308
- );
309
-
310
- $params['no_user_gravatar'] = array(
311
- 'description' => __( 'Whether to disable the default Gravatar Admin user fallback.', 'buddypress' ),
312
- 'default' => false,
313
- 'type' => 'boolean',
314
- 'sanitize_callback' => 'rest_sanitize_boolean',
315
- 'validate_callback' => 'rest_validate_request_arg',
316
- );
317
-
318
- /**
319
- * Filters the item collection query params.
320
- *
321
- * @param array $params Query params.
322
- */
323
- return apply_filters( 'bp_rest_attachments_blog_avatar_collection_params', $params );
324
- }
325
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-blogs/classes/class-bp-rest-blogs-endpoint.php DELETED
@@ -1,810 +0,0 @@
1
- <?php
2
- /**
3
- * BP REST: BP_REST_Blogs_Endpoint class
4
- *
5
- * @package BuddyPress
6
- * @since 6.0.0
7
- */
8
-
9
- defined( 'ABSPATH' ) || exit;
10
-
11
- /**
12
- * Blogs endpoints.
13
- *
14
- * Use /blogs/
15
- * Use /blogs/{id}
16
- *
17
- * @since 6.0.0
18
- */
19
- class BP_REST_Blogs_Endpoint extends WP_REST_Controller {
20
-
21
- /**
22
- * Constructor.
23
- *
24
- * @since 6.0.0
25
- */
26
- public function __construct() {
27
- $this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
28
- $this->rest_base = buddypress()->blogs->id;
29
- }
30
-
31
- /**
32
- * Register the component routes.
33
- *
34
- * @since 6.0.0
35
- */
36
- public function register_routes() {
37
- register_rest_route(
38
- $this->namespace,
39
- '/' . $this->rest_base,
40
- array(
41
- array(
42
- 'methods' => WP_REST_Server::READABLE,
43
- 'callback' => array( $this, 'get_items' ),
44
- 'permission_callback' => array( $this, 'get_items_permissions_check' ),
45
- 'args' => $this->get_collection_params(),
46
- ),
47
- array(
48
- 'methods' => WP_REST_Server::CREATABLE,
49
- 'callback' => array( $this, 'create_item' ),
50
- 'permission_callback' => array( $this, 'create_item_permissions_check' ),
51
- 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
52
- ),
53
- 'schema' => array( $this, 'get_item_schema' ),
54
- )
55
- );
56
-
57
- register_rest_route(
58
- $this->namespace,
59
- '/' . $this->rest_base . '/(?P<id>[\d]+)',
60
- array(
61
- 'args' => array(
62
- 'id' => array(
63
- 'description' => __( 'A unique numeric ID for the Blog.', 'buddypress' ),
64
- 'type' => 'integer',
65
- ),
66
- ),
67
- array(
68
- 'methods' => WP_REST_Server::READABLE,
69
- 'callback' => array( $this, 'get_item' ),
70
- 'permission_callback' => array( $this, 'get_item_permissions_check' ),
71
- 'args' => array(
72
- 'context' => $this->get_context_param(
73
- array(
74
- 'default' => 'view',
75
- )
76
- ),
77
- ),
78
- ),
79
- 'schema' => array( $this, 'get_item_schema' ),
80
- )
81
- );
82
- }
83
-
84
- /**
85
- * Retrieve Blogs.
86
- *
87
- * @since 6.0.0
88
- *
89
- * @param WP_REST_Request $request Full details about the request.
90
- * @return WP_REST_Response|WP_Error
91
- */
92
- public function get_items( $request ) {
93
- $args = array(
94
- 'type' => $request->get_param( 'type' ),
95
- 'include_blog_ids' => $request->get_param( 'include' ),
96
- 'user_id' => $request->get_param( 'user_id' ),
97
- 'search_terms' => $request->get_param( 'search' ),
98
- 'page' => $request->get_param( 'page' ),
99
- 'per_page' => $request->get_param( 'per_page' ),
100
- );
101
-
102
- /**
103
- * Filter the query arguments for the request.
104
- *
105
- * @since 6.0.0
106
- *
107
- * @param array $args Key value array of query var to query value.
108
- * @param WP_REST_Request $request The request sent to the API.
109
- */
110
- $args = apply_filters( 'bp_rest_blogs_get_items_query_args', $args, $request );
111
-
112
- // false is the default value for some args.
113
- foreach ( $args as $key => $value ) {
114
- if ( empty( $value ) ) {
115
- $args[ $key ] = false;
116
- }
117
- }
118
-
119
- // Check if user is valid.
120
- if ( 0 !== absint( $args['user_id'] ) ) {
121
- $user = get_user_by( 'id', absint( $args['user_id'] ) );
122
- if ( ! $user instanceof WP_User ) {
123
- return new WP_Error(
124
- 'bp_rest_blogs_get_items_user_failed',
125
- __( 'There was a problem confirming if user ID provided is a valid one.', 'buddypress' ),
126
- array(
127
- 'status' => 404,
128
- )
129
- );
130
- }
131
- }
132
-
133
- // Actually, query it.
134
- $blogs = bp_blogs_get_blogs( $args );
135
- $retval = array();
136
- foreach ( (array) $blogs['blogs'] as $blog ) {
137
- $retval[] = $this->prepare_response_for_collection(
138
- $this->prepare_item_for_response( $blog, $request )
139
- );
140
- }
141
-
142
- $response = rest_ensure_response( $retval );
143
- $response = bp_rest_response_add_total_headers( $response, $blogs['total'], $args['per_page'] );
144
-
145
- /**
146
- * Fires after blogs are fetched via the REST API.
147
- *
148
- * @since 6.0.0
149
- *
150
- * @param array $blogs Fetched blogs.
151
- * @param WP_REST_Response $response The response data.
152
- * @param WP_REST_Request $request The request sent to the API.
153
- */
154
- do_action( 'bp_rest_blogs_get_items', $blogs, $response, $request );
155
-
156
- return $response;
157
- }
158
-
159
- /**
160
- * Check if a given request has access to blog items.
161
- *
162
- * @since 6.0.0
163
- *
164
- * @param WP_REST_Request $request Full data about the request.
165
- * @return true|WP_Error
166
- */
167
- public function get_items_permissions_check( $request ) {
168
-
169
- /**
170
- * Filter the blogs `get_items` permissions check.
171
- *
172
- * @since 6.0.0
173
- *
174
- * @param true|WP_Error $retval Returned value.
175
- * @param WP_REST_Request $request The request sent to the API.
176
- */
177
- return apply_filters( 'bp_rest_blogs_get_items_permissions_check', true, $request );
178
- }
179
-
180
- /**
181
- * Retrieve a blog.
182
- *
183
- * @since 6.0.0
184
- *
185
- * @param WP_REST_Request $request Full details about the request.
186
- * @return WP_REST_Response|WP_Error
187
- */
188
- public function get_item( $request ) {
189
- $blog = $this->get_blog_object( $request->get_param( 'id' ) );
190
-
191
- if ( empty( $blog->blog_id ) || empty( $blog->admin_user_id ) ) {
192
- return new WP_Error(
193
- 'bp_rest_blog_invalid_id',
194
- __( 'Invalid blog ID.', 'buddypress' ),
195
- array(
196
- 'status' => 404,
197
- )
198
- );
199
- }
200
-
201
- $retval = array(
202
- $this->prepare_response_for_collection(
203
- $this->prepare_item_for_response( $blog, $request )
204
- ),
205
- );
206
-
207
- $response = rest_ensure_response( $retval );
208
-
209
- /**
210
- * Fires after a blog is fetched via the REST API.
211
- *
212
- * @since 6.0.0
213
- *
214
- * @param stdClass $blog Fetched blog.
215
- * @param WP_REST_Response $response The response data.
216
- * @param WP_REST_Request $request The request sent to the API.
217
- */
218
- do_action( 'bp_rest_blogs_get_item', $blog, $response, $request );
219
-
220
- return $response;
221
- }
222
-
223
- /**
224
- * Check if a given request has access to get information about a specific blog.
225
- *
226
- * @since 6.0.0
227
- *
228
- * @param WP_REST_Request $request Full details about the request.
229
- * @return true|WP_Error
230
- */
231
- public function get_item_permissions_check( $request ) {
232
-
233
- /**
234
- * Filter the blog `get_item` permissions check.
235
- *
236
- * @since 6.0.0
237
- *
238
- * @param true|WP_Error $retval Returned value.
239
- * @param WP_REST_Request $request The request sent to the API.
240
- */
241
- return apply_filters( 'bp_rest_blogs_get_item_permissions_check', true, $request );
242
- }
243
-
244
- /**
245
- * Create a new blog.
246
- *
247
- * @since 7.0.0
248
- *
249
- * @param WP_REST_Request $request Full details about the request.
250
- * @return WP_REST_Response|WP_Error
251
- */
252
- public function create_item( $request ) {
253
- $request->set_param( 'context', 'edit' );
254
-
255
- // Get WP_User object.
256
- $user = bp_rest_get_user( $request->get_param( 'user_id' ) );
257
-
258
- // Validate blog signup.
259
- $blog_meta = wpmu_validate_blog_signup(
260
- $request->get_param( 'name' ),
261
- $request->get_param( 'title' ),
262
- $user
263
- );
264
-
265
- // Check if validation failed.
266
- if ( is_wp_error( $blog_meta['errors'] ) && ! empty( $blog_meta['errors']->errors ) ) {
267
- return new WP_Error(
268
- 'bp_rest_blog_validation_failed',
269
- $blog_meta['errors']->get_error_message(),
270
- array(
271
- 'status' => 500,
272
- )
273
- );
274
- }
275
-
276
- $site_id = $request->get_param( 'site_id' );
277
- $meta = $request->get_param( 'meta' );
278
-
279
- // Assign blog meta.
280
- if ( empty( $meta['public'] ) ) {
281
- $meta['public'] = 1;
282
- }
283
-
284
- if ( empty( $meta['lang_id'] ) ) {
285
- $meta['lang_id'] = 1;
286
- }
287
-
288
- /**
289
- * Filter the meta arguments for the new Blog.
290
- *
291
- * @since 7.0.0
292
- *
293
- * @param array $args Key value array of query var to query value.
294
- * @param WP_REST_Request $request The request sent to the API.
295
- */
296
- $meta = apply_filters( 'bp_rest_blogs_create_item_meta', $meta, $request );
297
-
298
- // Create blog.
299
- $blog_id = wpmu_create_blog(
300
- $blog_meta['domain'],
301
- $blog_meta['path'],
302
- $blog_meta['blog_title'],
303
- $user->ID,
304
- $meta,
305
- $site_id
306
- );
307
-
308
- // If something went wrong, bail it.
309
- if ( is_wp_error( $blog_id ) ) {
310
- return new WP_Error(
311
- 'bp_rest_blogs_create_error',
312
- __( 'There was a problem creating blog.', 'buddypress' ),
313
- array(
314
- 'status' => 500,
315
- )
316
- );
317
- }
318
-
319
- $blog = $this->get_blog_object( $blog_id );
320
-
321
- if ( empty( $blog->blog_id ) || empty( $blog->admin_user_id ) ) {
322
- return new WP_Error(
323
- 'bp_rest_blog_invalid_id',
324
- __( 'Invalid blog ID.', 'buddypress' ),
325
- array(
326
- 'status' => 404,
327
- )
328
- );
329
- }
330
-
331
- $retval = array(
332
- $this->prepare_response_for_collection(
333
- $this->prepare_item_for_response( $blog, $request )
334
- ),
335
- );
336
-
337
- $response = rest_ensure_response( $retval );
338
-
339
- /**
340
- * Fires after a blog is created via the REST API.
341
- *
342
- * @since 7.0.0
343
- *
344
- * @param stdClass $blog Created blog.
345
- * @param WP_REST_Response $response The response data.
346
- * @param WP_REST_Request $request The request sent to the API.
347
- */
348
- do_action( 'bp_rest_blogs_create_item', $blog, $response, $request );
349
-
350
- return $response;
351
- }
352
-
353
- /**
354
- * Check if a given request has access to create a blog.
355
- *
356
- * @since 7.0.0
357
- *
358
- * @param WP_REST_Request $request Full details about the request.
359
- * @return true|WP_Error
360
- */
361
- public function create_item_permissions_check( $request ) {
362
- $retval = new WP_Error(
363
- 'bp_rest_authorization_required',
364
- __( 'Sorry, you are not allowed to perform this action.', 'buddypress' ),
365
- array(
366
- 'status' => rest_authorization_required_code(),
367
- )
368
- );
369
-
370
- if ( is_user_logged_in() ) {
371
- if ( true === bp_blog_signup_enabled() ) {
372
- $retval = true;
373
- } else {
374
- $retval = new WP_Error(
375
- 'bp_rest_blogs_signup_disabled',
376
- __( 'Sorry, blog creation is disabled.', 'buddypress' ),
377
- array(
378
- 'status' => 500,
379
- )
380
- );
381
- }
382
- }
383
-
384
- /**
385
- * Filter the blogs `create_item` permissions check.
386
- *
387
- * @since 7.0.0
388
- *
389
- * @param true|WP_Error $retval Returned value.
390
- * @param WP_REST_Request $request The request sent to the API.
391
- */
392
- return apply_filters( 'bp_rest_blogs_create_item_permissions_check', $retval, $request );
393
- }
394
-
395
- /**
396
- * Prepares blogs data for return as an object.
397
- *
398
- * @since 6.0.0
399
- *
400
- * @param stdClass $blog Blog object.
401
- * @param WP_REST_Request $request Full details about the request.
402
- * @return WP_REST_Response
403
- */
404
- public function prepare_item_for_response( $blog, $request ) {
405
- $data = array(
406
- 'id' => absint( $blog->blog_id ),
407
- 'user_id' => absint( $blog->admin_user_id ),
408
- 'name' => apply_filters( 'bp_get_blog_name', $blog->name ),
409
- 'domain' => (string) $blog->domain,
410
- 'path' => (string) $blog->path,
411
- 'permalink' => $this->get_blog_domain( $blog ),
412
- 'description' => array(
413
- 'raw' => $blog->description,
414
- 'rendered' => apply_filters( 'bp_get_blog_description', $blog->description ),
415
- ),
416
- 'last_activity' => bp_rest_prepare_date_response( $blog->last_activity ),
417
- 'lastest_post_id' => 0,
418
- );
419
-
420
- if ( ! empty( $blog->latest_post->ID ) ) {
421
- $data['lastest_post_id'] = absint( $blog->latest_post->ID );
422
- }
423
-
424
- // Blog Avatars.
425
- if ( true === buddypress()->avatar->show_avatars ) {
426
- $data['avatar_urls'] = array(
427
- 'thumb' => bp_get_blog_avatar(
428
- array(
429
- 'type' => 'thumb',
430
- 'blog_id' => $blog->blog_id,
431
- 'html' => false,
432
- )
433
- ),
434
- 'full' => bp_get_blog_avatar(
435
- array(
436
- 'type' => 'full',
437
- 'blog_id' => $blog->blog_id,
438
- 'html' => false,
439
- )
440
- ),
441
- );
442
- }
443
-
444
- $context = ! empty( $request->get_param( 'context' ) ) ? $request->get_param( 'context' ) : 'view';
445
- $data = $this->add_additional_fields_to_object( $data, $request );
446
- $data = $this->filter_response_by_context( $data, $context );
447
- $response = rest_ensure_response( $data );
448
-
449
- $response->add_links( $this->prepare_links( $blog ) );
450
-
451
- /**
452
- * Filter a blog returned from the API.
453
- *
454
- * @since 6.0.0
455
- *
456
- * @param WP_REST_Response $response Response generated by the request.
457
- * @param WP_REST_Request $request Request used to generate the response.
458
- * @param stdClass $blog The blog object.
459
- */
460
- return apply_filters( 'bp_rest_blogs_prepare_value', $response, $request, $blog );
461
- }
462
-
463
- /**
464
- * Prepare links for the request.
465
- *
466
- * @since 6.0.0
467
- *
468
- * @param stdClass $blog Blog object.
469
- * @return array
470
- */
471
- protected function prepare_links( $blog ) {
472
- $base = sprintf( '/%s/%s/', $this->namespace, $this->rest_base );
473
-
474
- // Entity meta.
475
- $links = array(
476
- 'self' => array(
477
- 'href' => rest_url( $base . $blog->blog_id ),
478
- ),
479
- 'collection' => array(
480
- 'href' => rest_url( $base ),
481
- ),
482
- );
483
-
484
- if ( ! empty( $blog->admin_user_id ) ) {
485
- $links['user'] = array(
486
- 'href' => bp_rest_get_object_url( absint( $blog->admin_user_id ), 'members' ),
487
- 'embeddable' => true,
488
- );
489
- }
490
-
491
- // Embed latest blog post.
492
- if ( ! empty( $blog->latest_post->ID ) ) {
493
- $links['post'] = array(
494
- 'embeddable' => true,
495
- 'href' => sprintf(
496
- '%s/%d',
497
- get_rest_url( absint( $blog->blog_id ), 'wp/v2/posts' ),
498
- absint( $blog->latest_post->ID )
499
- ),
500
- );
501
- }
502
-
503
- /**
504
- * Filter links prepared for the REST response.
505
- *
506
- * @since 5.0.0
507
- *
508
- * @param array $links The prepared links of the REST response.
509
- * @param stdClass $blog The blog object.
510
- */
511
- return apply_filters( 'bp_rest_blogs_prepare_links', $links, $blog );
512
- }
513
-
514
- /**
515
- * Get blog permalink.
516
- *
517
- * @param stdClass $blog Blog object.
518
- * @return string
519
- */
520
- protected function get_blog_domain( $blog ) {
521
-
522
- // Bail early.
523
- if ( empty( $blog->domain ) && empty( $blog->path ) ) {
524
- return '';
525
- }
526
-
527
- if ( empty( $blog->domain ) && ! empty( $blog->path ) ) {
528
- return bp_get_root_domain() . $blog->path;
529
- }
530
-
531
- $protocol = is_ssl() ? 'https://' : 'http://';
532
- $permalink = $protocol . $blog->domain . $blog->path;
533
-
534
- return apply_filters( 'bp_get_blog_permalink', $permalink );
535
- }
536
-
537
- /**
538
- * Get a blog object from a blog_id.
539
- *
540
- * @since 6.0.0
541
- *
542
- * @param int $blog_id Blog ID.
543
- * @return stdClass|int
544
- */
545
- public function get_blog_object( $blog_id ) {
546
- $blogs = current(
547
- bp_blogs_get_blogs(
548
- array(
549
- 'include_blog_ids' => array( $blog_id ),
550
- )
551
- )
552
- );
553
-
554
- if ( ! empty( $blogs[0] ) ) {
555
- return $blogs[0];
556
- }
557
-
558
- return 0;
559
- }
560
-
561
- /**
562
- * Edit the type of the some properties for the CREATABLE method.
563
- *
564
- * @since 7.0.0
565
- *
566
- * @param string $method Optional. HTTP method of the request.
567
- * @return array Endpoint arguments.
568
- */
569
- public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) {
570
- $args = parent::get_endpoint_args_for_item_schema( $method );
571
- $key = 'get_item';
572
-
573
- if ( WP_REST_Server::CREATABLE === $method ) {
574
- $key = 'create_item';
575
-
576
- unset( $args['last_activity'] );
577
-
578
- $args['name'] = array(
579
- 'required' => true,
580
- 'description' => __( 'The new site\'s name (used for the site URL).', 'buddypress' ),
581
- 'type' => 'string',
582
- 'sanitize_callback' => 'sanitize_key',
583
- 'validate_callback' => 'rest_validate_request_arg',
584
- );
585
-
586
- $args['title'] = array(
587
- 'required' => true,
588
- 'description' => __( 'The new site\'s title.', 'buddypress' ),
589
- 'type' => 'string',
590
- 'sanitize_callback' => 'sanitize_text_field',
591
- 'validate_callback' => 'rest_validate_request_arg',
592
- );
593
-
594
- $args['site_id'] = array(
595
- 'required' => false,
596
- 'default' => get_current_network_id(),
597
- 'description' => __( 'The new site\'s network ID. (Only relevant on multi-network installations)', 'buddypress' ),
598
- 'type' => 'integer',
599
- 'sanitize_callback' => 'absint',
600
- 'validate_callback' => 'rest_validate_request_arg',
601
- );
602
-
603
- $args['user_id'] = array(
604
- 'required' => false,
605
- 'default' => bp_loggedin_user_id(),
606
- 'description' => __( 'The user ID of the new site\'s admin.', 'buddypress' ),
607
- 'type' => 'integer',
608
- 'sanitize_callback' => 'absint',
609
- 'validate_callback' => 'rest_validate_request_arg',
610
- );
611
-
612
- $args['meta'] = array(
613
- 'required' => false,
614
- 'description' => __( 'Set initial Blog options.', 'buddypress' ),
615
- 'default' => array(),
616
- 'type' => 'array',
617
- 'items' => array( 'type' => 'string' ),
618
- 'validate_callback' => 'rest_validate_request_arg',
619
- );
620
- }
621
-
622
- /**
623
- * Filters the method query arguments.
624
- *
625
- * @since 7.0.0
626
- *
627
- * @param array $args Query arguments.
628
- * @param string $method HTTP method of the request.
629
- */
630
- return apply_filters( "bp_rest_blogs_{$key}_query_arguments", $args, $method );
631
- }
632
-
633
- /**
634
- * Get the blogs schema, conforming to JSON Schema.
635
- *
636
- * @since 6.0.0
637
- *
638
- * @return array
639
- */
640
- public function get_item_schema() {
641
- if ( is_null( $this->schema ) ) {
642
- $schema = array(
643
- '$schema' => 'http://json-schema.org/draft-04/schema#',
644
- 'title' => 'bp_blogs',
645
- 'type' => 'object',
646
- 'properties' => array(
647
- 'id' => array(
648
- 'context' => array( 'view', 'edit', 'embed' ),
649
- 'description' => __( 'A unique numeric ID for the blog.', 'buddypress' ),
650
- 'readonly' => true,
651
- 'type' => 'integer',
652
- ),
653
- 'user_id' => array(
654
- 'context' => array( 'view', 'edit', 'embed' ),
655
- 'description' => __( 'A unique numeric ID for the blog admin.', 'buddypress' ),
656
- 'readonly' => true,
657
- 'type' => 'integer',
658
- ),
659
- 'name' => array(
660
- 'context' => array( 'view', 'edit', 'embed' ),
661
- 'description' => __( 'The name of the blog.', 'buddypress' ),
662
- 'readonly' => true,
663
- 'type' => 'string',
664
- 'arg_options' => array(
665
- 'sanitize_callback' => 'sanitize_text_field',
666
- ),
667
- ),
668
- 'permalink' => array(
669
- 'context' => array( 'view', 'edit', 'embed' ),
670
- 'description' => __( 'The permalink of the blog.', 'buddypress' ),
671
- 'readonly' => true,
672
- 'type' => 'string',
673
- 'format' => 'uri',
674
- ),
675
- 'description' => array(
676
- 'context' => array( 'view', 'edit', 'embed' ),
677
- 'description' => __( 'The description of the blog.', 'buddypress' ),
678
- 'type' => 'object',
679
- 'arg_options' => array(
680
- 'sanitize_callback' => null,
681
- 'validate_callback' => null,
682
- ),
683
- 'properties' => array(
684
- 'raw' => array(
685
- 'description' => __( 'Content for the description of the blog, as it exists in the database.', 'buddypress' ),
686
- 'type' => 'string',
687
- 'context' => array( 'view', 'edit' ),
688
- ),
689
- 'rendered' => array(
690
- 'description' => __( 'HTML content for the description of the blog, transformed for display.', 'buddypress' ),
691
- 'type' => 'string',
692
- 'context' => array( 'view', 'edit', 'embed' ),
693
- 'readonly' => true,
694
- ),
695
- ),
696
- ),
697
- 'path' => array(
698
- 'context' => array( 'view', 'edit', 'embed' ),
699
- 'description' => __( 'The path of the blog.', 'buddypress' ),
700
- 'readonly' => true,
701
- 'type' => 'string',
702
- ),
703
- 'domain' => array(
704
- 'context' => array( 'view', 'edit', 'embed' ),
705
- 'description' => __( 'The domain of the blog.', 'buddypress' ),
706
- 'readonly' => true,
707
- 'type' => 'string',
708
- ),
709
- 'last_activity' => array(
710
- 'context' => array( 'view', 'edit', 'embed' ),
711
- 'description' => __( "The last activity date from the blog, in the site's timezone.", 'buddypress' ),
712
- 'type' => 'string',
713
- 'format' => 'date-time',
714
- ),
715
- 'lastest_post_id' => array(
716
- 'context' => array( 'view', 'edit', 'embed' ),
717
- 'description' => __( 'The latest post ID from the blog', 'buddypress' ),
718
- 'type' => 'integer',
719
- 'readonly' => true,
720
- ),
721
- ),
722
- );
723
-
724
- if ( true === buddypress()->avatar->show_avatars ) {
725
- $avatar_properties = array();
726
-
727
- $avatar_properties['full'] = array(
728
- /* translators: 1: Full avatar width in pixels. 2: Full avatar height in pixels */
729
- 'description' => sprintf( __( 'Avatar URL with full image size (%1$d x %2$d pixels).', 'buddypress' ), number_format_i18n( bp_core_avatar_full_width() ), number_format_i18n( bp_core_avatar_full_height() ) ),
730
- 'type' => 'string',
731
- 'format' => 'uri',
732
- 'context' => array( 'view', 'edit', 'embed' ),
733
- );
734
-
735
- $avatar_properties['thumb'] = array(
736
- /* translators: 1: Thumb avatar width in pixels. 2: Thumb avatar height in pixels */
737
- 'description' => sprintf( __( 'Avatar URL with thumb image size (%1$d x %2$d pixels).', 'buddypress' ), number_format_i18n( bp_core_avatar_thumb_width() ), number_format_i18n( bp_core_avatar_thumb_height() ) ),
738
- 'type' => 'string',
739
- 'format' => 'uri',
740
- 'context' => array( 'view', 'edit', 'embed' ),
741
- );
742
-
743
- $schema['properties']['avatar_urls'] = array(
744
- 'description' => __( 'Avatar URLs for the blog.', 'buddypress' ),
745
- 'type' => 'object',
746
- 'context' => array( 'view', 'edit', 'embed' ),
747
- 'readonly' => true,
748
- 'properties' => $avatar_properties,
749
- );
750
- }
751
-
752
- // Cache current schema here.
753
- $this->schema = $schema;
754
- }
755
-
756
- /**
757
- * Filter the blogs schema.
758
- *
759
- * @since 6.0.0
760
- *
761
- * @param array $schema The endpoint schema.
762
- */
763
- return apply_filters( 'bp_rest_blogs_schema', $this->add_additional_fields_schema( $this->schema ) );
764
- }
765
-
766
- /**
767
- * Get the query params for blogs collections.
768
- *
769
- * @since 6.0.0
770
- *
771
- * @return array
772
- */
773
- public function get_collection_params() {
774
- $params = parent::get_collection_params();
775
- $params['context']['default'] = 'view';
776
-
777
- $params['user_id'] = array(
778
- 'description' => __( 'ID of the user whose blogs user can post to.', 'buddypress' ),
779
- 'default' => 0,
780
- 'type' => 'integer',
781
- 'sanitize_callback' => 'absint',
782
- 'validate_callback' => 'rest_validate_request_arg',
783
- );
784
-
785
- $params['include'] = array(
786
- 'description' => __( 'Ensure result set includes specific IDs.', 'buddypress' ),
787
- 'default' => array(),
788
- 'type' => 'array',
789
- 'items' => array( 'type' => 'integer' ),
790
- 'sanitize_callback' => 'wp_parse_id_list',
791
- 'validate_callback' => 'rest_validate_request_arg',
792
- );
793
-
794
- $params['type'] = array(
795
- 'description' => __( 'Limit result set to items with a specific type.', 'buddypress' ),
796
- 'default' => 'active',
797
- 'type' => 'string',
798
- 'enum' => array( 'active', 'alphabetical', 'newest', 'random' ),
799
- 'sanitize_callback' => 'sanitize_key',
800
- 'validate_callback' => 'rest_validate_request_arg',
801
- );
802
-
803
- /**
804
- * Filters the collection query params.
805
- *
806
- * @param array $params Query params.
807
- */
808
- return apply_filters( 'bp_rest_blogs_collection_params', $params );
809
- }
810
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-blogs/css/blocks/recent-posts-rtl.css DELETED
@@ -1,42 +0,0 @@
1
- .bp-recent-posts-block-container a {
2
- box-shadow: none;
3
- text-decoration: none;
4
- }
5
-
6
- .bp-recent-posts-block-container ul.item-list {
7
- list-style: none;
8
- margin: 10px 0;
9
- }
10
-
11
- .bp-recent-posts-block-container ul.activity-list {
12
- padding: 0;
13
- }
14
-
15
- .bp-recent-posts-block-container ul.activity-list blockquote {
16
- margin: 0 0 1.5em;
17
- overflow: visible;
18
- padding: 0 0.75em 0.75em 0;
19
- }
20
-
21
- .bp-recent-posts-block-container ul.activity-list img {
22
- margin-bottom: 0.5em;
23
- }
24
-
25
- .bp-recent-posts-block-container ul.activity-list li {
26
- border-bottom: 1px solid #ccc;
27
- margin-bottom: 1em;
28
- }
29
-
30
- .bp-recent-posts-block-container ul.activity-list li .activity-header p {
31
- margin-bottom: 0.5em;
32
- }
33
-
34
- .bp-recent-posts-block-container ul.activity-list li .activity-header p .time-since {
35
- font-size: 80%;
36
- color: #767676;
37
- text-decoration: none;
38
- }
39
-
40
- .bp-recent-posts-block-container ul.activity-list li:last-child {
41
- border-bottom: 0;
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-blogs/css/blocks/recent-posts-rtl.min.css DELETED
@@ -1 +0,0 @@
1
- .bp-recent-posts-block-container a{box-shadow:none;text-decoration:none}.bp-recent-posts-block-container ul.item-list{list-style:none;margin:10px 0}.bp-recent-posts-block-container ul.activity-list{padding:0}.bp-recent-posts-block-container ul.activity-list blockquote{margin:0 0 1.5em;overflow:visible;padding:0 .75em .75em 0}.bp-recent-posts-block-container ul.activity-list img{margin-bottom:.5em}.bp-recent-posts-block-container ul.activity-list li{border-bottom:1px solid #ccc;margin-bottom:1em}.bp-recent-posts-block-container ul.activity-list li .activity-header p{margin-bottom:.5em}.bp-recent-posts-block-container ul.activity-list li .activity-header p .time-since{font-size:80%;color:#767676;text-decoration:none}.bp-recent-posts-block-container ul.activity-list li:last-child{border-bottom:0}
 
bp-blogs/css/blocks/recent-posts.css DELETED
@@ -1,42 +0,0 @@
1
- .bp-recent-posts-block-container a {
2
- box-shadow: none;
3
- text-decoration: none;
4
- }
5
-
6
- .bp-recent-posts-block-container ul.item-list {
7
- list-style: none;
8
- margin: 10px 0;
9
- }
10
-
11
- .bp-recent-posts-block-container ul.activity-list {
12
- padding: 0;
13
- }
14
-
15
- .bp-recent-posts-block-container ul.activity-list blockquote {
16
- margin: 0 0 1.5em;
17
- overflow: visible;
18
- padding: 0 0 0.75em 0.75em;
19
- }
20
-
21
- .bp-recent-posts-block-container ul.activity-list img {
22
- margin-bottom: 0.5em;
23
- }
24
-
25
- .bp-recent-posts-block-container ul.activity-list li {
26
- border-bottom: 1px solid #ccc;
27
- margin-bottom: 1em;
28
- }
29
-
30
- .bp-recent-posts-block-container ul.activity-list li .activity-header p {
31
- margin-bottom: 0.5em;
32
- }
33
-
34
- .bp-recent-posts-block-container ul.activity-list li .activity-header p .time-since {
35
- font-size: 80%;
36
- color: #767676;
37
- text-decoration: none;
38
- }
39
-
40
- .bp-recent-posts-block-container ul.activity-list li:last-child {
41
- border-bottom: 0;
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-blogs/css/blocks/recent-posts.min.css DELETED
@@ -1 +0,0 @@
1
- .bp-recent-posts-block-container a{box-shadow:none;text-decoration:none}.bp-recent-posts-block-container ul.item-list{list-style:none;margin:10px 0}.bp-recent-posts-block-container ul.activity-list{padding:0}.bp-recent-posts-block-container ul.activity-list blockquote{margin:0 0 1.5em;overflow:visible;padding:0 0 .75em .75em}.bp-recent-posts-block-container ul.activity-list img{margin-bottom:.5em}.bp-recent-posts-block-container ul.activity-list li{border-bottom:1px solid #ccc;margin-bottom:1em}.bp-recent-posts-block-container ul.activity-list li .activity-header p{margin-bottom:.5em}.bp-recent-posts-block-container ul.activity-list li .activity-header p .time-since{font-size:80%;color:#767676;text-decoration:none}.bp-recent-posts-block-container ul.activity-list li:last-child{border-bottom:0}
 
bp-blogs/js/blocks/recent-posts.js DELETED
@@ -1,8 +0,0 @@
1
- parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"Pfcj":[function(require,module,exports) {
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=wp,t=e.blockEditor.InspectorControls,n=e.components,l=n.Disabled,o=n.PanelBody,r=n.RangeControl,s=n.TextControl,i=n.ToggleControl,a=e.element,u=a.Fragment,d=a.createElement,b=e.i18n.__,c=bp,p=c.blockComponents.ServerSideRender,g=function(e){var n=e.attributes,a=e.setAttributes,c=n.title,g=n.maxPosts,m=n.linkTitle;return d(u,null,d(t,null,d(o,{title:b("Settings","buddypress"),initialOpen:!0},d(s,{label:b("Title","buddypress"),value:c,onChange:function(e){a({title:e})}}),d(r,{label:b("Max posts to show","buddypress"),value:g,onChange:function(e){return a({maxPosts:e})},min:1,max:10,required:!0}),d(i,{label:b("Link block title to Blogs directory","buddypress"),checked:!!m,onChange:function(){a({linkTitle:!m})}}))),d(l,null,d(p,{block:"bp/recent-posts",attributes:n})))},m=g;exports.default=m;
3
- },{}],"D8sC":[function(require,module,exports) {
4
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=wp,e=t.blocks.createBlock,r={from:[{type:"block",blocks:["core/legacy-widget"],isMatch:function(t){var e=t.idBase,r=t.instance;return!(null==r||!r.raw)&&"bp_blogs_recent_posts_widget"===e},transform:function(t){var r=t.instance;return e("bp/recent-posts",{title:r.raw.title,maxPosts:r.raw.max_posts,linkTitle:r.raw.link_title})}}]},s=r;exports.default=s;
5
- },{}],"PMBS":[function(require,module,exports) {
6
- "use strict";var e=s(require("./recent-posts/edit")),t=s(require("./recent-posts/transforms"));function s(e){return e&&e.__esModule?e:{default:e}}var r=wp,o=r.blocks.registerBlockType,d=r.i18n.__;o("bp/recent-posts",{title:d("Recent Networkwide Posts","buddypress"),description:d("A list of recently published posts from across your network.","buddypress"),icon:{background:"#fff",foreground:"#d84800",src:"wordpress"},category:"buddypress",attributes:{title:{type:"string",default:d("Recent Networkwide Posts","buddypress")},maxPosts:{type:"number",default:10},linkTitle:{type:"boolean",default:!1}},edit:e.default,transforms:t.default});
7
- },{"./recent-posts/edit":"Pfcj","./recent-posts/transforms":"D8sC"}]},{},["PMBS"], null)
8
- //# sourceMappingURL=/bp-blogs/js/blocks/recent-posts.js.map
 
 
 
 
 
 
 
 
bp-blogs/js/blocks/recent-posts.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["bp-blogs/js/blocks/recent-posts/edit.js","bp-blogs/js/blocks/recent-posts/transforms.js","bp-blogs/js/blocks/recent-posts.js"],"names":["editRecentPostsBlock","wp","InspectorControls","blockEditor","components","Disabled","PanelBody","RangeControl","TextControl","ToggleControl","element","Fragment","createElement","__","i18n","bp","ServerSideRender","blockComponents","attributes","setAttributes","title","maxPosts","linkTitle","text","value","transforms","createBlock","blocks","from","type","isMatch","idBase","instance","raw","transform","max_posts","link_title","registerBlockType","description","icon","background","foreground","src","category","default","edit"],"mappings":";AAwEeA,aAAAA,OAAAA,eAAAA,QAAAA,aAAAA,CAAAA,OAAAA,IAAAA,QAAAA,aAAAA,EArEf,IAkBIC,EAAAA,GAhBFC,EADDC,EAAAA,YACCD,kBAEDE,EAAAA,EAAAA,WACCC,EAAAA,EAAAA,SACAC,EAAAA,EAAAA,UACAC,EAAAA,EAAAA,aACAC,EAAAA,EAAAA,YACAC,EAAAA,EAAAA,cAEDC,EAAAA,EAAAA,QACCC,EAAAA,EAAAA,SACAC,EAAAA,EAAAA,cAGAC,EADDC,EAAAA,KACCD,GAWEE,EAAAA,GAFFC,EADDC,EAAAA,gBACCD,iBAIIhB,EAAuB,SAAqC,GAAjCkB,IAAAA,EAAAA,EAAAA,WAAYC,EAAAA,EAAAA,cACpCC,EAA+BF,EAA/BE,MAAOC,EAAwBH,EAAxBG,SAAUC,EAAcJ,EAAdI,UAGxB,OAAA,EAAC,EACA,KAAA,EAAC,EACA,KAAA,EAAC,EAAD,CAAW,MAAQT,EAAI,WAAY,cAAiB,aAAc,GACjE,EAAC,EAAD,CACC,MAAQA,EAAI,QAAS,cACrB,MAAQO,EACR,SAAW,SAAEG,GACZJ,EAAe,CAAEC,MAAOG,OAG1B,EAAC,EAAD,CACC,MAAQV,EAAI,oBAAqB,cACjC,MAAQQ,EACR,SAAW,SAAEG,GACZL,OAAAA,EAAe,CAAEE,SAAUG,KAE5B,IAAM,EACN,IAAM,GACN,UAAQ,IAET,EAAC,EAAD,CACC,MAAQX,EAAI,sCAAuC,cACnD,UAAaS,EACb,SAAW,WACVH,EAAe,CAAEG,WAAaA,SAKlC,EAAC,EACA,KAAA,EAAC,EAAD,CAAkB,MAAM,kBAAkB,WAAaJ,OAM5ClB,EAAAA,EAAAA,QAAAA,QAAAA;;ACnCAyB,aAAAA,OAAAA,eAAAA,QAAAA,aAAAA,CAAAA,OAAAA,IAAAA,QAAAA,aAAAA,EAlCf,IAIIxB,EAAAA,GAFFyB,EADDC,EAAAA,OACCD,YASID,EAAa,CAClBG,KAAM,CACL,CACCC,KAAM,QACNF,OAAQ,CAAE,sBACVG,QAAS,SAA4B,GAAxBC,IAAAA,EAAAA,EAAAA,OAAQC,EAAAA,EAAAA,SACf,QAAEA,MAAAA,IAAAA,EAAUC,MAIC,iCAAXF,GAERG,UAAW,SAAoB,GAAhBF,IAAAA,EAAAA,EAAAA,SACPN,OAAAA,EAAa,kBAAmB,CACtCN,MAAOY,EAASC,IAAIb,MACpBC,SAAUW,EAASC,IAAIE,UACvBb,UAAWU,EAASC,IAAIG,iBAOdX,EAAAA,EAAAA,QAAAA,QAAAA;;ACnBf,aAHA,IAAA,EAAA,EAAA,QAAA,wBACA,EAAA,EAAA,QAAA,8BAEA,SAAA,EAAA,GAAA,OAAA,GAAA,EAAA,WAAA,EAAA,CAAA,QAAA,GAfA,IAOIxB,EAAAA,GALFoC,EADDV,EAAAA,OACCU,kBAGAxB,EADDC,EAAAA,KACCD,GAUFwB,EAAmB,kBAAmB,CACrCjB,MAAOP,EAAI,2BAA4B,cACvCyB,YAAazB,EAAI,+DAAgE,cACjF0B,KAAM,CACLC,WAAY,OACZC,WAAY,UACZC,IAAK,aAENC,SAAU,aACVzB,WAAY,CACXE,MAAO,CACNS,KAAM,SACNe,QAAS/B,EAAI,2BAA4B,eAE1CQ,SAAU,CACTQ,KAAM,SACNe,QAAS,IAEVtB,UAAW,CACVO,KAAM,UACNe,SAAS,IAGXC,KAAM7C,EAvB+B,QAwBrCyB,WAAYA,EAAAA","file":"recent-posts.js","sourceRoot":"../src/js","sourcesContent":["/**\n * WordPress dependencies.\n */\nconst {\n\tblockEditor: {\n\t\tInspectorControls,\n\t},\n\tcomponents: {\n\t\tDisabled,\n\t\tPanelBody,\n\t\tRangeControl,\n\t\tTextControl,\n\t\tToggleControl,\n\t},\n\telement: {\n\t\tFragment,\n\t\tcreateElement,\n\t},\n\ti18n: {\n\t\t__,\n\t},\n} = wp;\n\n/**\n * BuddyPress dependencies.\n */\nconst {\n\tblockComponents: {\n\t\tServerSideRender,\n\t},\n} = bp;\n\nconst editRecentPostsBlock = ( { attributes, setAttributes } ) => {\n\tconst { title, maxPosts, linkTitle } = attributes;\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings', 'buddypress' ) } initialOpen={ true }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Title', 'buddypress' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ ( text ) => {\n\t\t\t\t\t\t\tsetAttributes( { title: text } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tlabel={ __( 'Max posts to show', 'buddypress' ) }\n\t\t\t\t\t\tvalue={ maxPosts }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { maxPosts: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\tmax={ 10 }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Link block title to Blogs directory', 'buddypress' ) }\n\t\t\t\t\t\tchecked={ !! linkTitle }\n\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\tsetAttributes( { linkTitle: ! linkTitle } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<Disabled>\n\t\t\t\t<ServerSideRender block=\"bp/recent-posts\" attributes={ attributes } />\n\t\t\t</Disabled>\n\t\t</Fragment>\n\t);\n};\n\nexport default editRecentPostsBlock;\n","/**\n * WordPress dependencies.\n */\nconst {\n\tblocks: {\n\t\tcreateBlock,\n\t},\n} = wp;\n\n/**\n * Transforms Legacy Widget to Recent Posts Block.\n *\n * @type {Object}\n */\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/legacy-widget' ],\n\t\t\tisMatch: ( { idBase, instance } ) => {\n\t\t\t\tif ( ! instance?.raw ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn idBase === 'bp_blogs_recent_posts_widget';\n\t\t\t},\n\t\t\ttransform: ( { instance } ) => {\n\t\t\t\treturn createBlock( 'bp/recent-posts', {\n\t\t\t\t\ttitle: instance.raw.title,\n\t\t\t\t\tmaxPosts: instance.raw.max_posts,\n\t\t\t\t\tlinkTitle: instance.raw.link_title,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n","/**\n * WordPress dependencies.\n */\nconst {\n\tblocks: {\n\t\tregisterBlockType,\n\t},\n\ti18n: {\n\t\t__,\n\t},\n} = wp;\n\n/**\n * Internal dependencies.\n */\nimport editRecentPostsBlock from './recent-posts/edit';\nimport transforms from './recent-posts/transforms';\n\nregisterBlockType( 'bp/recent-posts', {\n\ttitle: __( 'Recent Networkwide Posts', 'buddypress' ),\n\tdescription: __( 'A list of recently published posts from across your network.', 'buddypress' ),\n\ticon: {\n\t\tbackground: '#fff',\n\t\tforeground: '#d84800',\n\t\tsrc: 'wordpress',\n\t},\n\tcategory: 'buddypress',\n\tattributes: {\n\t\ttitle: {\n\t\t\ttype: 'string',\n\t\t\tdefault: __( 'Recent Networkwide Posts', 'buddypress' ),\n\t\t},\n\t\tmaxPosts: {\n\t\t\ttype: 'number',\n\t\t\tdefault: 10\n\t\t},\n\t\tlinkTitle: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tedit: editRecentPostsBlock,\n\ttransforms: transforms,\n} );\n"]}
 
bp-blogs/sass/blocks/recent-posts.scss DELETED
@@ -1,46 +0,0 @@
1
- .bp-recent-posts-block-container {
2
-
3
- a {
4
- box-shadow: none;
5
- text-decoration: none;
6
- }
7
-
8
- ul.item-list {
9
- list-style: none;
10
- margin: 10px 0;
11
- }
12
-
13
- ul.activity-list {
14
-
15
- padding: 0;
16
-
17
- blockquote {
18
- margin: 0 0 1.5em;
19
- overflow: visible;
20
- padding: 0 0 0.75em 0.75em;
21
- }
22
-
23
- img {
24
- margin-bottom: 0.5em;
25
- }
26
-
27
- li {
28
- border-bottom: 1px solid #ccc;
29
- margin-bottom: 1em;
30
-
31
- .activity-header p {
32
- margin-bottom: 0.5em;
33
-
34
- .time-since {
35
- font-size: 80%;
36
- color: #767676;
37
- text-decoration: none;
38
- }
39
- }
40
-
41
- &:last-child {
42
- border-bottom: 0;
43
- }
44
- }
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-blogs/screens/create.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
- /**
3
- * Blogs: Create screen handler
4
- *
5
- * @package BuddyPress
6
- * @subpackage BlogsScreens
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Load the "Create a Blog" screen.
12
- *
13
- * @since 1.0.0
14
- */
15
- function bp_blogs_screen_create_a_blog() {
16
-
17
- if ( ! is_multisite() || ! bp_is_blogs_component() || ! bp_is_current_action( 'create' ) || ! is_user_logged_in() || ! bp_blog_signup_enabled() ) {
18
- return false;
19
- }
20
-
21
- /**
22
- * Fires right before the loading of the Create A Blog screen template file.
23
- *
24
- * @since 1.0.0
25
- */
26
- do_action( 'bp_blogs_screen_create_a_blog' );
27
-
28
- bp_core_load_template( apply_filters( 'bp_blogs_template_create_a_blog', 'blogs/create' ) );
29
- }
30
- add_action( 'bp_screens', 'bp_blogs_screen_create_a_blog', 3 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-blogs/screens/directory.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
- /**
3
- * Blogs: Directory screen handler
4
- *
5
- * @package BuddyPress
6
- * @subpackage BlogsScreens
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Load the top-level Blogs directory.
12
- *
13
- * @since 1.5-beta-1
14
- */
15
- function bp_blogs_screen_index() {
16
- if ( bp_is_blogs_directory() ) {
17
- bp_update_is_directory( true, 'blogs' );
18
-
19
- /**
20
- * Fires right before the loading of the top-level Blogs screen template file.
21
- *
22
- * @since 1.0.0
23
- */
24
- do_action( 'bp_blogs_screen_index' );
25
-
26
- bp_core_load_template( apply_filters( 'bp_blogs_screen_index', 'blogs/index' ) );
27
- }
28
- }
29
- add_action( 'bp_screens', 'bp_blogs_screen_index', 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-blogs/screens/my-blogs.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
- /**
3
- * Blogs: User's "Sites" screen handler
4
- *
5
- * @package BuddyPress
6
- * @subpackage BlogsScreens
7
- * @since 3.0.0
8
- */
9
-
10
- /**
11
- * Load the "My Blogs" screen.
12
- *
13
- * @since 1.0.0
14
- */
15
- function bp_blogs_screen_my_blogs() {
16
- if ( !is_multisite() )
17
- return false;
18
-
19
- /**
20
- * Fires right before the loading of the My Blogs screen template file.
21
- *
22
- * @since 1.0.0
23
- */
24
- do_action( 'bp_blogs_screen_my_blogs' );
25
-
26
- bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'members/single/home' ) );
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/admin/bp-core-admin-actions.php CHANGED
@@ -46,7 +46,7 @@ add_action( 'customize_controls_enqueue_scripts', 'bp_admin_enqueue_scripts', 8
46
  add_action( 'network_admin_menu', 'bp_admin_menu' );
47
  add_action( 'custom_menu_order', 'bp_admin_custom_menu_order' );
48
  add_action( 'menu_order', 'bp_admin_menu_order' );
49
- add_action( 'bp_insert_site', 'bp_new_site', 10, 6 );
50
 
51
  // Hook on to admin_init.
52
  add_action( 'bp_admin_init', 'bp_setup_updater', 1000 );
46
  add_action( 'network_admin_menu', 'bp_admin_menu' );
47
  add_action( 'custom_menu_order', 'bp_admin_custom_menu_order' );
48
  add_action( 'menu_order', 'bp_admin_menu_order' );
49
+ add_action( 'wpmu_new_blog', 'bp_new_site', 10, 6 );
50
 
51
  // Hook on to admin_init.
52
  add_action( 'bp_admin_init', 'bp_setup_updater', 1000 );
bp-core/admin/bp-core-admin-components.php CHANGED
@@ -21,8 +21,7 @@ function bp_core_admin_components_settings() {
21
 
22
  <div class="wrap">
23
 
24
- <h1 class="wp-heading-inline"><?php _e( 'BuddyPress Settings', 'buddypress' ); ?> </h1>
25
- <hr class="wp-header-end">
26
 
27
  <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Components', 'buddypress' ) ); ?></h2>
28
  <form action="" method="post" id="bp-admin-component-form">
@@ -82,6 +81,11 @@ function bp_core_admin_components_options() {
82
  $required_components = bp_core_admin_get_components( 'required' );
83
  $retired_components = bp_core_admin_get_components( 'retired' );
84
 
 
 
 
 
 
85
  // Merge optional and required together.
86
  $all_components = $optional_components + $required_components;
87
 
@@ -143,79 +147,32 @@ function bp_core_admin_components_options() {
143
  case 'retired' :
144
  $current_components = $retired_components;
145
  break;
146
- }
147
-
148
- $component_views = array(
149
- array(
150
- 'action' => 'all',
151
- 'view' => sprintf(
152
- /* translators: %s: the number of installed components */
153
- _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $all_count, 'plugins', 'buddypress' ),
154
- number_format_i18n( $all_count )
155
- ),
156
- ),
157
- array(
158
- 'action' => 'active',
159
- 'view' => sprintf(
160
- /* translators: %s: the number of active components */
161
- _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', count( $active_components ), 'buddypress' ),
162
- number_format_i18n( count( $active_components ) )
163
- ),
164
- ),
165
- array(
166
- 'action' => 'inactive',
167
- 'view' => sprintf(
168
- /* translators: %s: the number of inactive components */
169
- _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', count( $inactive_components ), 'buddypress' ),
170
- number_format_i18n( count( $inactive_components ) )
171
- ),
172
- ),
173
- array(
174
- 'action' => 'mustuse',
175
- 'view' => sprintf(
176
- /* translators: %s: the number of must-Use components */
177
- _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', count( $required_components ), 'buddypress' ),
178
- number_format_i18n( count( $required_components ) )
179
- ),
180
- ),
181
- array(
182
- 'action' => 'retired',
183
- 'view' => sprintf(
184
- /* translators: %s: the number of retired components */
185
- _n( 'Retired <span class="count">(%s)</span>', 'Retired <span class="count">(%s)</span>', count( $retired_components ), 'buddypress' ),
186
- number_format_i18n( count( $retired_components ) )
187
- ),
188
- ),
189
- );
190
- ?>
191
 
192
  <h3 class="screen-reader-text"><?php
193
  /* translators: accessibility text */
194
- esc_html_e( 'Filter components list', 'buddypress' );
195
  ?></h3>
196
 
197
  <ul class="subsubsub">
198
- <?php foreach ( $component_views as $component_view ) : ?>
199
- <li>
200
- <a href="<?php echo esc_url( add_query_arg( array( 'page' => 'bp-components', 'action' => $component_view['action'] ), bp_get_admin_url( $page ) ) ); ?>" <?php if ( $action === $component_view['action'] ) : ?>class="current"<?php endif; ?>>
201
- <?php echo wp_kses( $component_view['view'], array( 'span' => array( 'class' => true ) ) ); ?>
202
- </a><?php echo 'retired' !== $component_view['action'] ? ' |' : ''; ?>
203
- </li>
204
- <?php endforeach ;?>
205
  </ul>
206
 
207
  <h3 class="screen-reader-text"><?php
208
  /* translators: accessibility text */
209
- esc_html_e( 'Components list', 'buddypress' );
210
  ?></h3>
211
 
212
  <table class="wp-list-table widefat plugins">
213
  <thead>
214
  <tr>
215
- <td id="cb" class="manage-column column-cb check-column"><input id="cb-select-all-1" type="checkbox" <?php checked( empty( $inactive_components ) ); ?>>
216
- <label class="screen-reader-text" for="cb-select-all-1"><?php
217
  /* translators: accessibility text */
218
- _e( 'Enable or disable all optional components in bulk', 'buddypress' );
219
  ?></label></td>
220
  <th scope="col" id="name" class="manage-column column-title column-primary"><?php _e( 'Component', 'buddypress' ); ?></th>
221
  <th scope="col" id="description" class="manage-column column-description"><?php _e( 'Description', 'buddypress' ); ?></th>
@@ -243,14 +200,18 @@ function bp_core_admin_components_options() {
243
  /* translators: accessibility text */
244
  printf( __( 'Select %s', 'buddypress' ), esc_html( $labels['title'] ) ); ?></label>
245
 
 
 
 
 
 
 
246
  <?php endif; ?>
247
 
248
  </th>
249
  <td class="plugin-title column-primary">
250
- <label for="<?php echo esc_attr( "bp_components[$name]" ); ?>">
251
- <span aria-hidden="true"></span>
252
- <strong><?php echo esc_html( $labels['title'] ); ?></strong>
253
- </label>
254
  </td>
255
 
256
  <td class="column-description desc">
@@ -275,10 +236,9 @@ function bp_core_admin_components_options() {
275
 
276
  <tfoot>
277
  <tr>
278
- <td class="manage-column column-cb check-column"><input id="cb-select-all-2" type="checkbox" <?php checked( empty( $inactive_components ) ); ?>>
279
- <label class="screen-reader-text" for="cb-select-all-2"><?php
280
  /* translators: accessibility text */
281
- _e( 'Enable or disable all optional components in bulk', 'buddypress' );
282
  ?></label></td>
283
  <th class="manage-column column-title column-primary"><?php _e( 'Component', 'buddypress' ); ?></th>
284
  <th class="manage-column column-description"><?php _e( 'Description', 'buddypress' ); ?></th>
21
 
22
  <div class="wrap">
23
 
24
+ <h1><?php _e( 'BuddyPress Settings', 'buddypress' ); ?> </h1>
 
25
 
26
  <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Components', 'buddypress' ) ); ?></h2>
27
  <form action="" method="post" id="bp-admin-component-form">
81
  $required_components = bp_core_admin_get_components( 'required' );
82
  $retired_components = bp_core_admin_get_components( 'retired' );
83
 
84
+ // Don't show Forums component in optional components if it's disabled.
85
+ if ( ! bp_is_active( 'forums' ) ) {
86
+ unset( $optional_components['forums'] );
87
+ }
88
+
89
  // Merge optional and required together.
90
  $all_components = $optional_components + $required_components;
91
 
147
  case 'retired' :
148
  $current_components = $retired_components;
149
  break;
150
+ } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
 
152
  <h3 class="screen-reader-text"><?php
153
  /* translators: accessibility text */
154
+ _e( 'Filter components list', 'buddypress' );
155
  ?></h3>
156
 
157
  <ul class="subsubsub">
158
+ <li><a href="<?php echo esc_url( add_query_arg( array( 'page' => 'bp-components', 'action' => 'all' ), bp_get_admin_url( $page ) ) ); ?>" <?php if ( $action === 'all' ) : ?>class="current"<?php endif; ?>><?php printf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $all_count, 'plugins', 'buddypress' ), number_format_i18n( $all_count ) ); ?></a> | </li>
159
+ <li><a href="<?php echo esc_url( add_query_arg( array( 'page' => 'bp-components', 'action' => 'active' ), bp_get_admin_url( $page ) ) ); ?>" <?php if ( $action === 'active' ) : ?>class="current"<?php endif; ?>><?php printf( _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', count( $active_components ), 'buddypress' ), number_format_i18n( count( $active_components ) ) ); ?></a> | </li>
160
+ <li><a href="<?php echo esc_url( add_query_arg( array( 'page' => 'bp-components', 'action' => 'inactive' ), bp_get_admin_url( $page ) ) ); ?>" <?php if ( $action === 'inactive' ) : ?>class="current"<?php endif; ?>><?php printf( _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', count( $inactive_components ), 'buddypress' ), number_format_i18n( count( $inactive_components ) ) ); ?></a> | </li>
161
+ <li><a href="<?php echo esc_url( add_query_arg( array( 'page' => 'bp-components', 'action' => 'mustuse' ), bp_get_admin_url( $page ) ) ); ?>" <?php if ( $action === 'mustuse' ) : ?>class="current"<?php endif; ?>><?php printf( _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', count( $required_components ), 'buddypress' ), number_format_i18n( count( $required_components ) ) ); ?></a> | </li>
162
+ <li><a href="<?php echo esc_url( add_query_arg( array( 'page' => 'bp-components', 'action' => 'retired' ), bp_get_admin_url( $page ) ) ); ?>" <?php if ( $action === 'retired' ) : ?>class="current"<?php endif; ?>><?php printf( _n( 'Retired <span class="count">(%s)</span>', 'Retired <span class="count">(%s)</span>', count( $retired_components ), 'buddypress' ), number_format_i18n( count( $retired_components ) ) ); ?></a></li>
 
 
163
  </ul>
164
 
165
  <h3 class="screen-reader-text"><?php
166
  /* translators: accessibility text */
167
+ _e( 'Components list', 'buddypress' );
168
  ?></h3>
169
 
170
  <table class="wp-list-table widefat plugins">
171
  <thead>
172
  <tr>
173
+ <td id="cb" class="manage-column column-cb check-column"><input id="cb-select-all-1" type="checkbox" disabled><label class="screen-reader-text" for="cb-select-all-1"><?php
 
174
  /* translators: accessibility text */
175
+ _e( 'Bulk selection is disabled', 'buddypress' );
176
  ?></label></td>
177
  <th scope="col" id="name" class="manage-column column-title column-primary"><?php _e( 'Component', 'buddypress' ); ?></th>
178
  <th scope="col" id="description" class="manage-column column-description"><?php _e( 'Description', 'buddypress' ); ?></th>
200
  /* translators: accessibility text */
201
  printf( __( 'Select %s', 'buddypress' ), esc_html( $labels['title'] ) ); ?></label>
202
 
203
+ <?php else : ?>
204
+
205
+ <input type="checkbox" id="<?php echo esc_attr( "bp_components[$name]" ); ?>" name="<?php echo esc_attr( "bp_components[$name]" ); ?>" value="1" checked="checked" disabled><label for="<?php echo esc_attr( "bp_components[$name]" ); ?>" class="screen-reader-text"><?php
206
+ /* translators: accessibility text */
207
+ printf( __( '%s is a required component', 'buddypress' ), esc_html( $labels['title'] ) ); ?></label>
208
+
209
  <?php endif; ?>
210
 
211
  </th>
212
  <td class="plugin-title column-primary">
213
+ <span aria-hidden="true"></span>
214
+ <strong><?php echo esc_html( $labels['title'] ); ?></strong>
 
 
215
  </td>
216
 
217
  <td class="column-description desc">
236
 
237
  <tfoot>
238
  <tr>
239
+ <td class="manage-column column-cb check-column"><input id="cb-select-all-2" type="checkbox" disabled><label class="screen-reader-text" for="cb-select-all-2"><?php
 
240
  /* translators: accessibility text */
241
+ _e( 'Bulk selection is disabled', 'buddypress' );
242
  ?></label></td>
243
  <th class="manage-column column-title column-primary"><?php _e( 'Component', 'buddypress' ); ?></th>
244
  <th class="manage-column column-description"><?php _e( 'Description', 'buddypress' ); ?></th>
bp-core/admin/bp-core-admin-functions.php CHANGED
@@ -14,6 +14,7 @@ defined( 'ABSPATH' ) || exit;
14
 
15
  /**
16
  * Initializes the wp-admin area "BuddyPress" menus and sub menus.
 
17
  */
18
  function bp_core_admin_menu_init() {
19
  add_action( bp_core_admin_hook(), 'bp_core_add_admin_menu', 9 );
@@ -64,7 +65,7 @@ add_action( bp_core_admin_hook(), 'bp_core_admin_backpat_menu', 999 );
64
  * This tells WP to highlight the Settings > BuddyPress menu item,
65
  * regardless of which actual BuddyPress admin screen we are on.
66
  *
67
- * The conditional prevents the behavior when the user is viewing the
68
  * backpat "Help" page, the Activity page, or any third-party plugins.
69
  *
70
  * @global string $plugin_page
@@ -76,7 +77,7 @@ function bp_core_modify_admin_menu_highlight() {
76
  global $plugin_page, $submenu_file;
77
 
78
  // This tweaks the Settings subnav menu to show only one BuddyPress menu item.
79
- if ( ! in_array( $plugin_page, array( 'bp-activity', 'bp-general-settings' ) ) ) {
80
  $submenu_file = 'bp-components';
81
  }
82
 
@@ -84,11 +85,6 @@ function bp_core_modify_admin_menu_highlight() {
84
  if ( in_array( $plugin_page, array( 'bp-tools', 'available-tools' ) ) ) {
85
  $submenu_file = $plugin_page;
86
  }
87
-
88
- // Keep the BuddyPress tools menu highlighted when using a tools tab.
89
- if ( 'bp-optouts' === $plugin_page || 'bp-members-invitations' === $plugin_page ) {
90
- $submenu_file = 'bp-tools';
91
- }
92
  }
93
 
94
  /**
@@ -100,27 +96,17 @@ function bp_core_modify_admin_menu_highlight() {
100
  *
101
  * @since 1.6.0
102
  *
103
- * @todo Add convenience links into the markup once new positions are finalized.
104
  */
105
  function bp_core_admin_backpat_page() {
106
  $url = bp_core_do_network_admin() ? network_admin_url( 'settings.php' ) : admin_url( 'options-general.php' );
107
  $settings_url = add_query_arg( 'page', 'bp-components', $url ); ?>
108
 
109
  <div class="wrap">
110
- <h1 class="wp-heading-inline"><?php esc_html_e( 'Why have all my BuddyPress menus disappeared?', 'buddypress' ); ?></h1>
111
- <hr class="wp-header-end">
112
 
113
- <p><?php esc_html_e( "Don't worry! We've moved the BuddyPress options into more convenient and easier to find locations. You're seeing this page because you are running a legacy BuddyPress plugin which has not been updated.", 'buddypress' ); ?></p>
114
- <p>
115
- <?php
116
- printf(
117
- // Translators: 1: is the url to the BP Components settings screen. 2: is the url to the xProfile administration screen.
118
- __( 'Components, Pages, Settings, and Forums, have been moved to <a href="%1$s">Settings &gt; BuddyPress</a>. Profile Fields has been moved into the <a href="%2$s">Users</a> menu.', 'buddypress' ),
119
- esc_url( $settings_url ),
120
- bp_get_admin_url( 'users.php?page=bp-profile-setup' )
121
- );
122
- ?>
123
- </p>
124
  </div>
125
 
126
  <?php
@@ -135,6 +121,7 @@ function bp_core_admin_backpat_page() {
135
  * boxes.
136
  *
137
  * @since 1.5.0
 
138
  */
139
  function bp_core_print_admin_notices() {
140
 
@@ -157,7 +144,7 @@ function bp_core_print_admin_notices() {
157
 
158
  foreach ( $notice_types as $type ) {
159
  $notices = wp_list_filter( buddypress()->admin->notices, array( 'type' => $type ) );
160
- printf( '<div id="message" class="fade %s notice is-dismissible">', sanitize_html_class( $type ) );
161
 
162
  foreach ( $notices as $notice ) {
163
  printf( '<p>%s</p>', $notice['message'] );
@@ -166,7 +153,7 @@ function bp_core_print_admin_notices() {
166
  printf( '</div>' );
167
  }
168
  }
169
- add_action( 'admin_notices', 'bp_core_print_admin_notices' );
170
  add_action( 'network_admin_notices', 'bp_core_print_admin_notices' );
171
 
172
  /**
@@ -253,14 +240,7 @@ function bp_core_activation_notice() {
253
 
254
  // Add notice if no rewrite rules are enabled.
255
  if ( empty( $wp_rewrite->permalink_structure ) ) {
256
- bp_core_add_admin_notice(
257
- sprintf(
258
- // Translators: %s is the url to the permalink settings.
259
- __( '<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' ),
260
- admin_url( 'options-permalink.php' )
261
- ),
262
- 'error'
263
- );
264
  }
265
 
266
  // Get BuddyPress instance.
@@ -273,26 +253,26 @@ function bp_core_activation_notice() {
273
  $wp_page_components = array();
274
 
275
  // Only components with 'has_directory' require a WP page to function.
276
- foreach ( array_keys( $bp->loaded_components ) as $component_id ) {
277
- if ( ! empty( $bp->{$component_id}->has_directory ) ) {
278
  $wp_page_components[] = array(
279
  'id' => $component_id,
280
- 'name' => isset( $bp->{$component_id}->name ) ? $bp->{$component_id}->name : ucwords( $bp->{$component_id}->id ),
281
  );
282
  }
283
  }
284
 
285
  // Activate and Register are special cases. They are not components but they need WP pages.
286
  // If user registration is disabled, we can skip this step.
287
- if ( bp_get_signup_allowed() || bp_get_members_invitations_allowed() ) {
288
  $wp_page_components[] = array(
289
  'id' => 'activate',
290
- 'name' => __( 'Activate', 'buddypress' ),
291
  );
292
 
293
  $wp_page_components[] = array(
294
  'id' => 'register',
295
- 'name' => __( 'Register', 'buddypress' ),
296
  );
297
  }
298
 
@@ -302,18 +282,26 @@ function bp_core_activation_notice() {
302
  $bp->pages = bp_core_get_directory_pages();
303
  }
304
 
305
- foreach ( $wp_page_components as $component ) {
306
- if ( ! isset( $bp->pages->{$component['id']} ) ) {
307
  $orphaned_components[] = $component['name'];
308
  }
309
  }
310
 
311
- if ( ! empty( $orphaned_components ) ) {
 
 
 
 
 
 
 
 
 
312
  $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) );
313
  $notice = sprintf(
314
  '%1$s <a href="%2$s">%3$s</a>',
315
  sprintf(
316
- // Translators: %s is the comma separated list of components needing a directory page.
317
  __( 'The following active BuddyPress Components do not have associated WordPress Pages: %s.', 'buddypress' ),
318
  '<strong>' . implode( '</strong>, <strong>', array_map( 'esc_html', $orphaned_components ) ) . '</strong>'
319
  ),
@@ -329,8 +317,8 @@ function bp_core_activation_notice() {
329
  $page_ids = bp_core_get_directory_page_ids();
330
  $dupes = array_diff_assoc( $page_ids, array_unique( $page_ids ) );
331
 
332
- if ( ! empty( $dupes ) ) {
333
- foreach ( array_keys( $dupes ) as $dupe_component ) {
334
  $dupe_names[] = $bp->pages->{$dupe_component}->title;
335
  }
336
 
@@ -339,12 +327,11 @@ function bp_core_activation_notice() {
339
  }
340
 
341
  // If there are duplicates, post a message about them.
342
- if ( ! empty( $dupe_names ) ) {
343
  $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) );
344
  $notice = sprintf(
345
  '%1$s <a href="%2$s">%3$s</a>',
346
  sprintf(
347
- // Translators: %s is the list of directory pages associated to more than one component.
348
  __( 'Each BuddyPress Component needs its own WordPress page. The following WordPress Pages have more than one component associated with them: %s.', 'buddypress' ),
349
  '<strong>' . implode( '</strong>, <strong>', array_map( 'esc_html', $dupe_names ) ) . '</strong>'
350
  ),
@@ -362,6 +349,7 @@ function bp_core_activation_notice() {
362
  * @since 1.7.0
363
  *
364
  * @internal Used internally to redirect BuddyPress to the about page on activation.
 
365
  */
366
  function bp_do_activation_redirect() {
367
 
@@ -378,14 +366,14 @@ function bp_do_activation_redirect() {
378
  return;
379
  }
380
 
381
- $query_args = array();
382
  if ( get_transient( '_bp_is_new_install' ) ) {
383
  $query_args['is_new_install'] = '1';
384
  delete_transient( '_bp_is_new_install' );
385
  }
386
 
387
- // Redirect to dashboard and trigger the Hello screen.
388
- wp_safe_redirect( add_query_arg( $query_args, bp_get_admin_url( '?hello=buddypress' ) ) );
389
  }
390
 
391
  /** UI/Styling ****************************************************************/
@@ -394,13 +382,10 @@ function bp_do_activation_redirect() {
394
  * Output the tabs in the admin area.
395
  *
396
  * @since 1.5.0
397
- * @since 8.0.0 Adds the `$context` parameter.
398
  *
399
  * @param string $active_tab Name of the tab that is active. Optional.
400
- * @param string $context The context of use for the tabs. Defaults to 'settings'.
401
- * Possible values are 'settings' & 'tools'.
402
  */
403
- function bp_core_admin_tabs( $active_tab = '', $context = 'settings' ) {
404
  $tabs_html = '';
405
  $idle_class = 'nav-tab';
406
  $active_class = 'nav-tab nav-tab-active';
@@ -412,7 +397,7 @@ function bp_core_admin_tabs( $active_tab = '', $context = 'settings' ) {
412
  *
413
  * @param array $value Array of tabs to output to the admin area.
414
  */
415
- $tabs = apply_filters( 'bp_core_admin_tabs', bp_core_get_admin_tabs( $active_tab, $context ) );
416
 
417
  // Loop through tabs and build navigation.
418
  foreach ( array_values( $tabs ) as $tab_data ) {
@@ -427,65 +412,44 @@ function bp_core_admin_tabs( $active_tab = '', $context = 'settings' ) {
427
  * Fires after the output of tabs for the admin area.
428
  *
429
  * @since 1.5.0
430
- * @since 8.0.0 Adds the `$context` parameter.
431
- *
432
- * @param string $context The context of use for the tabs.
433
  */
434
- do_action( 'bp_admin_tabs', $context );
435
  }
436
 
437
  /**
438
  * Get the data for the tabs in the admin area.
439
  *
440
  * @since 2.2.0
441
- * @since 8.0.0 Adds the `$context` parameter.
442
  *
443
  * @param string $active_tab Name of the tab that is active. Optional.
444
- * @param string $context The context of use for the tabs. Defaults to 'settings'.
445
- * Possible values are 'settings' & 'tools'.
446
  * @return string
447
  */
448
- function bp_core_get_admin_tabs( $active_tab = '', $context = 'settings' ) {
449
- $tabs = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
450
 
451
- if ( 'settings' === $context ) {
452
- $tabs = array(
453
- '0' => array(
454
- 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), 'admin.php' ) ),
455
- 'name' => __( 'Components', 'buddypress' ),
456
- ),
457
- '2' => array(
458
- 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), 'admin.php' ) ),
459
- 'name' => __( 'Options', 'buddypress' ),
460
- ),
461
- '1' => array(
462
- 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) ),
463
- 'name' => __( 'Pages', 'buddypress' ),
464
- ),
465
- '3' => array(
466
- 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-credits' ), 'admin.php' ) ),
467
- 'name' => __( 'Credits', 'buddypress' ),
468
- ),
469
- );
470
- } elseif ( 'tools' === $context ) {
471
- $tools_page = 'tools.php';
472
- if ( bp_core_do_network_admin() ) {
473
- $tools_page = 'admin.php';
474
- }
475
 
476
- $tabs = array(
477
- '0' => array(
478
- 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-tools' ), $tools_page ) ),
479
- 'name' => __( 'Repair', 'buddypress' ),
480
- ),
481
- '1' => array(
482
- 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-members-invitations' ), $tools_page ) ),
483
- 'name' => __( 'Manage Invitations', 'buddypress' ),
484
- ),
485
- '2' => array(
486
- 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-optouts' ), $tools_page ) ),
487
- 'name' => __( 'Manage Opt-outs', 'buddypress' ),
488
- ),
489
  );
490
  }
491
 
@@ -493,12 +457,10 @@ function bp_core_get_admin_tabs( $active_tab = '', $context = 'settings' ) {
493
  * Filters the tab data used in our wp-admin screens.
494
  *
495
  * @since 2.2.0
496
- * @since 8.0.0 Adds the `$context` parameter.
497
  *
498
- * @param array $tabs Tab data.
499
- * @param string $context The context of use for the tabs.
500
  */
501
- return apply_filters( 'bp_core_get_admin_tabs', $tabs, $context );
502
  }
503
 
504
  /** Help **********************************************************************/
@@ -518,15 +480,14 @@ function bp_core_add_contextual_help( $screen = '' ) {
518
  switch ( $screen->id ) {
519
 
520
  // Component page.
521
- case 'settings_page_bp-components':
 
522
  // Help tabs.
523
- $screen->add_help_tab(
524
- array(
525
- 'id' => 'bp-comp-overview',
526
- 'title' => __( 'Overview', 'buddypress' ),
527
- 'content' => bp_core_add_contextual_help_content( 'bp-comp-overview' ),
528
- )
529
- );
530
 
531
  // Help panel - sidebar links.
532
  $screen->set_help_sidebar(
@@ -537,15 +498,14 @@ function bp_core_add_contextual_help( $screen = '' ) {
537
  break;
538
 
539
  // Pages page.
540
- case 'settings_page_bp-page-settings':
 
541
  // Help tabs.
542
- $screen->add_help_tab(
543
- array(
544
- 'id' => 'bp-page-overview',
545
- 'title' => __( 'Overview', 'buddypress' ),
546
- 'content' => bp_core_add_contextual_help_content( 'bp-page-overview' ),
547
- )
548
- );
549
 
550
  // Help panel - sidebar links.
551
  $screen->set_help_sidebar(
@@ -557,15 +517,14 @@ function bp_core_add_contextual_help( $screen = '' ) {
557
  break;
558
 
559
  // Settings page.
560
- case 'settings_page_bp-settings':
 
561
  // Help tabs.
562
- $screen->add_help_tab(
563
- array(
564
- 'id' => 'bp-settings-overview',
565
- 'title' => __( 'Overview', 'buddypress' ),
566
- 'content' => bp_core_add_contextual_help_content( 'bp-settings-overview' ),
567
- )
568
- );
569
 
570
  // Help panel - sidebar links.
571
  $screen->set_help_sidebar(
@@ -577,15 +536,14 @@ function bp_core_add_contextual_help( $screen = '' ) {
577
  break;
578
 
579
  // Profile fields page.
580
- case 'users_page_bp-profile-setup':
 
581
  // Help tabs.
582
- $screen->add_help_tab(
583
- array(
584
- 'id' => 'bp-profile-overview',
585
- 'title' => __( 'Overview', 'buddypress' ),
586
- 'content' => bp_core_add_contextual_help_content( 'bp-profile-overview' ),
587
- )
588
- );
589
 
590
  // Help panel - sidebar links.
591
  $screen->set_help_sidebar(
@@ -613,20 +571,20 @@ add_action( 'load-users_page_bp-profile-setup', 'bp_core_add_contextual_help' );
613
  function bp_core_add_contextual_help_content( $tab = '' ) {
614
 
615
  switch ( $tab ) {
616
- case 'bp-comp-overview':
617
  $retval = __( 'By default, all but four of the BuddyPress components are enabled. You can selectively enable or disable any of the components by using the form below. Your BuddyPress installation will continue to function. However, the features of the disabled components will no longer be accessible to anyone using the site.', 'buddypress' );
618
  break;
619
 
620
- case 'bp-page-overview':
621
  $retval = __( 'BuddyPress Components use WordPress Pages for their root directory/archive pages. You can change the page associations for each active component by using the form below.', 'buddypress' );
622
  break;
623
 
624
- case 'bp-settings-overview':
625
  $retval = __( 'Extra configuration settings are provided and activated. You can selectively enable or disable any setting by using the form on this screen.', 'buddypress' );
626
  break;
627
 
628
- case 'bp-profile-overview':
629
- $retval = __( 'Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile.', 'buddypress' ) . '<br /><br />' . __( 'Note: Drag fields from other groups and drop them on the "Signup Fields" tab to include them into your registration form.', 'buddypress' );
630
  break;
631
 
632
  default:
@@ -635,7 +593,7 @@ function bp_core_add_contextual_help_content( $tab = '' ) {
635
  }
636
 
637
  // Wrap text in a paragraph tag.
638
- if ( ! empty( $retval ) ) {
639
  $retval = '<p>' . $retval . '</p>';
640
  }
641
 
@@ -648,6 +606,7 @@ function bp_core_add_contextual_help_content( $tab = '' ) {
648
  * Add a separator to the WordPress admin menus.
649
  *
650
  * @since 1.7.0
 
651
  */
652
  function bp_admin_separator() {
653
 
@@ -714,7 +673,7 @@ function bp_admin_menu_order( $menu_order = array() ) {
714
  $bp_menu_order = array();
715
 
716
  // Menu values.
717
- $last_sep = is_network_admin() ? 'separator1' : 'separator2';
718
 
719
  /**
720
  * Filters the custom admin menus.
@@ -740,7 +699,7 @@ function bp_admin_menu_order( $menu_order = array() ) {
740
  if ( $last_sep == $item ) {
741
 
742
  // Add our custom menus.
743
- foreach ( (array) $custom_menus as $custom_menu ) {
744
  if ( array_search( $custom_menu, $menu_order ) ) {
745
  $bp_menu_order[] = $custom_menu;
746
  }
@@ -749,7 +708,7 @@ function bp_admin_menu_order( $menu_order = array() ) {
749
  // Add the appearance separator.
750
  $bp_menu_order[] = $last_sep;
751
 
752
- // Skip our menu items.
753
  } elseif ( ! in_array( $item, $custom_menus ) ) {
754
  $bp_menu_order[] = $item;
755
  }
@@ -777,7 +736,7 @@ function bp_admin_list_table_current_bulk_action() {
777
  $action = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
778
 
779
  // If the bottom is set, let it override the action.
780
- if ( ! empty( $_REQUEST['action2'] ) && $_REQUEST['action2'] != '-1' ) {
781
  $action = $_REQUEST['action2'];
782
  }
783
 
@@ -796,167 +755,86 @@ function bp_admin_wp_nav_menu_meta_box() {
796
  return;
797
  }
798
 
799
- add_meta_box( 'add-buddypress-nav-menu', __( 'BuddyPress Member', 'buddypress' ), 'bp_admin_do_wp_nav_menu_meta_box', 'nav-menus', 'side', 'default' );
800
 
801
  add_action( 'admin_print_footer_scripts', 'bp_admin_wp_nav_menu_restrict_items' );
802
  }
803
 
804
- /**
805
- * BP Member nav menu filter to short-circuit WP's query.
806
- *
807
- * @since 7.0.0
808
- *
809
- * @param null $null A null value.
810
- * @param WP_Query $wp_query The WP_Query instance (passed by reference).
811
- * @return array The BP Member nav items to short-circuit WP's query,
812
- */
813
- function bp_admin_get_wp_nav_menu_items( $null, $wp_query ) {
814
- if ( isset( $wp_query->query['orderby'], $wp_query->query['order'] ) && 'post_date' === $wp_query->query['orderby'] && 'DESC' === $wp_query->query['order'] ) {
815
- return bp_nav_menu_get_loggedin_pages();
816
- } elseif ( isset( $wp_query->query['nopaging'] ) && true === $wp_query->query['nopaging'] ) {
817
- return array_merge( bp_nav_menu_get_loggedin_pages(), bp_nav_menu_get_loggedout_pages() );
818
- }
819
-
820
- return bp_nav_menu_get_loggedout_pages();
821
- }
822
-
823
  /**
824
  * Build and populate the BuddyPress accordion on Appearance > Menus.
825
  *
826
  * @since 1.9.0
827
- * @since 7.0.0 Uses wp_nav_menu_item_post_type_meta_box()
828
  *
829
  * @global $nav_menu_selected_id
830
  */
831
- function bp_admin_do_wp_nav_menu_meta_box( $object = '', $box = array() ) {
832
  global $nav_menu_selected_id;
833
 
834
- $box['args'] = (object) array(
835
- 'name' => 'bp_nav_menu_item',
836
- '_default_query' => array(),
837
- );
838
-
839
- // Temporarly register a post type.
840
- register_post_type(
841
- 'bp_nav_menu_item',
842
- array(
843
- 'label' => 'BuddyPress',
844
- 'labels' => array(
845
- 'search_items' => __( 'Search BuddyPress member menu items', 'buddypress' ),
846
- 'all_items' => __( 'All BuddyPress Member menu items', 'buddypress' ),
847
- ),
848
- 'public' => true,
849
- 'hierarchical' => false,
850
- 'has_archive' => false,
851
- 'rewrite' => false,
852
- )
853
- );
854
-
855
- // Temporarly override the posts query results.
856
- add_filter( 'posts_pre_query', 'bp_admin_get_wp_nav_menu_items', 10, 2 );
857
-
858
- ob_start();
859
- wp_nav_menu_item_post_type_meta_box( 'buddypress', $box );
860
- $output = ob_get_clean();
861
 
862
- $get_bp_items = new WP_Query;
863
- $all_bp_items = $get_bp_items->query( array( 'nopaging' => true ) );
864
- $walker = new Walker_Nav_Menu_Checklist();
865
- $all_bp_tabs = sprintf(
866
- '<div id="bp_nav_menu_item-all" class="tabs-panel tabs-panel-view-all tabs-panel-inactive" role="region" aria-label="%1$s" tabindex="0">
867
- <ul id="bp_nav_menu_itemchecklist" data-wp-lists="list:bp_nav_menu_item" class="categorychecklist form-no-clear">
868
- %2$s
869
- </ul>
870
- </div>',
871
- esc_html__( 'All BuddyPress Member menu items', 'buddypress' ),
872
- walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $all_bp_items ), 0, (object) array( 'walker' => $walker ) )
873
- );
874
 
875
- // Remove temporary post type and filter.
876
- unregister_post_type( 'bp_nav_menu_item' );
877
- remove_filter( 'posts_pre_query', 'bp_admin_get_wp_nav_menu_items', 10, 2 );
878
 
879
- $tab_name = 'bp_nav_menu_item-tab';
880
- $current_tab = 'logged-in';
881
- $tabs = array(
882
- 'logged-in' => __( 'Logged-In', 'buddypress' ),
883
- 'logged-out' => __( 'Logged-Out', 'buddypress' ),
884
- 'all' => __( 'All', 'buddypress' ),
885
- );
886
- $tab_urls = array(
887
- 'all' => '',
888
- 'logged-in' => '',
889
- 'logged-out' => '',
890
- );
891
 
892
- if ( isset( $_REQUEST[ $tab_name ] ) && in_array( $_REQUEST[ $tab_name ], array_keys( $tabs ), true ) ) {
893
- $current_tab = $_REQUEST[ $tab_name ];
894
- }
895
 
896
- $removed_args = array(
897
- 'action',
898
- 'customlink-tab',
899
- 'edit-menu-item',
900
- 'menu-item',
901
- 'page-tab',
902
- '_wpnonce',
903
- );
904
 
905
- if ( $nav_menu_selected_id ) {
906
- $tab_urls['all'] = esc_url( add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) ) );
907
- $tab_urls['logged-in'] = esc_url( add_query_arg( $tab_name, 'logged-in', remove_query_arg( $removed_args ) ) );
908
- $tab_urls['logged-out'] = esc_url( add_query_arg( $tab_name, 'logged-out', remove_query_arg( $removed_args ) ) );
909
- }
910
 
911
- $bp_tabs_nav = '';
912
- foreach ( $tabs as $tab => $tab_text ) {
913
- $class = '';
914
- $datatype = 'bp_nav_menu_item-' . $tab;
 
915
 
916
- if ( $current_tab === $tab ) {
917
- $class = ' class="tabs"';
918
- }
919
 
920
- if ( 'all' !== $tab ) {
921
- $datatype = 'tabs-panel-posttype-bp_nav_menu_item-' . $tab;
922
- }
 
 
923
 
924
- $bp_tabs_nav .= sprintf(
925
- '<li%1$s>
926
- <a class="nav-tab-link" data-type="%2$s" href="%3$s">
927
- %4$s
928
- </a>
929
- </li>',
930
- $class,
931
- $datatype,
932
- esc_url( $tab_urls[ $tab ] ) . '#' . $datatype,
933
- esc_html( $tab_text )
934
  );
935
- }
936
-
937
- $output = str_replace(
938
- array(
939
- 'tabs-panel-posttype-bp_nav_menu_item-most-recent',
940
- 'bp_nav_menu_itemchecklist-most-recent',
941
- 'bp_nav_menu_item-all',
942
- 'bp_nav_menu_itemchecklist',
943
- ),
944
- array(
945
- 'tabs-panel-posttype-bp_nav_menu_item-logged-in',
946
- 'bp_nav_menu_itemchecklist-logged-in',
947
- 'tabs-panel-posttype-bp_nav_menu_item-logged-out',
948
- 'bp_nav_menu_itemchecklist-logged-out',
949
- ),
950
- $output
951
- );
952
-
953
- preg_match( '/\<ul\sid=\"posttype-bp_nav_menu_item-tabs\"[^>]*>(.*?)\<\/ul\>\<!-- \.posttype-tabs --\>/s', $output, $tabs_nav );
954
 
955
- if ( isset( $tabs_nav[1] ) ) {
956
- $output = str_replace( $tabs_nav[1], $bp_tabs_nav, $output );
957
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
958
 
959
- echo preg_replace( '/\<div\sclass=\".*\"\sid=\"tabs-panel-posttype-bp_nav_menu_item-search\"[^>]*>(.*?)\<\/div\>/s', $all_bp_tabs, $output );
960
  }
961
 
962
  /**
@@ -985,8 +863,7 @@ function bp_admin_email_maybe_add_translation_notice() {
985
 
986
  bp_core_add_admin_notice(
987
  sprintf(
988
- // Translators: %s is the url to the BuddyPress tools administration screen.
989
- __( 'Are these emails not written in your site\'s language? Go to <a href="%s">BuddyPress Tools and try the "reinstall emails"</a> tool.', 'buddypress' ),
990
  esc_url( add_query_arg( 'page', 'bp-tools', bp_get_admin_url( $admin_page ) ) )
991
  ),
992
  'updated'
@@ -1006,7 +883,6 @@ function bp_admin_email_add_codex_notice() {
1006
 
1007
  bp_core_add_admin_notice(
1008
  sprintf(
1009
- // Translators: %s is the url to the BuddyPress codex page about BP Email tokens.
1010
  __( 'Phrases wrapped in braces <code>{{ }}</code> are email tokens. <a href="%s">Learn about tokens on the BuddyPress Codex</a>.', 'buddypress' ),
1011
  esc_url( 'https://codex.buddypress.org/emails/email-tokens/' )
1012
  ),
@@ -1033,7 +909,7 @@ add_action( 'admin_head-post.php', 'bp_admin_email_add_codex_notice' );
1033
  */
1034
  function bp_email_tax_type_metabox( $post, $box ) {
1035
  $r = array(
1036
- 'taxonomy' => bp_get_email_tax_type(),
1037
  );
1038
 
1039
  $tax_name = esc_attr( $r['taxonomy'] );
@@ -1046,15 +922,7 @@ function bp_email_tax_type_metabox( $post, $box ) {
1046
  echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.
1047
  ?>
1048
  <ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear">
1049
- <?php
1050
- wp_terms_checklist(
1051
- $post->ID,
1052
- array(
1053
- 'taxonomy' => $tax_name,
1054
- 'walker' => new BP_Walker_Category_Checklist(),
1055
- )
1056
- );
1057
- ?>
1058
  </ul>
1059
  </div>
1060
 
@@ -1085,18 +953,16 @@ add_action( 'add_meta_boxes_' . bp_get_email_post_type(), 'bp_email_custom_metab
1085
  * @param WP_Post $post
1086
  */
1087
  function bp_email_plaintext_metabox( $post ) {
1088
- ?>
1089
 
1090
- <label class="screen-reader-text" for="excerpt">
1091
- <?php
1092
  /* translators: accessibility text */
1093
  _e( 'Plain text email content', 'buddypress' );
1094
- ?>
1095
- </label><textarea rows="5" cols="40" name="excerpt" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea>
1096
 
1097
  <p><?php _e( 'Most email clients support HTML email. However, some people prefer to receive plain text email. Enter a plain text alternative version of your email here.', 'buddypress' ); ?></p>
1098
 
1099
- <?php
1100
  }
1101
 
1102
  /**
@@ -1116,7 +982,7 @@ function bp_email_plaintext_metabox( $post ) {
1116
  * @since 1.9.0
1117
  */
1118
  function bp_admin_wp_nav_menu_restrict_items() {
1119
- ?>
1120
  <script type="text/javascript">
1121
  jQuery( '#menu-to-edit').on( 'click', 'a.item-edit', function() {
1122
  var settings = jQuery(this).closest( '.menu-item-bar' ).next( '.menu-item-settings' );
@@ -1128,7 +994,7 @@ function bp_admin_wp_nav_menu_restrict_items() {
1128
  }
1129
  });
1130
  </script>
1131
- <?php
1132
  }
1133
 
1134
  /**
@@ -1144,7 +1010,7 @@ function bp_core_admin_user_row_actions( $actions, $user_object ) {
1144
 
1145
  // Setup the $user_id variable from the current user object.
1146
  $user_id = 0;
1147
- if ( ! empty( $user_object->ID ) ) {
1148
  $user_id = absint( $user_object->ID );
1149
  }
1150
 
@@ -1156,25 +1022,13 @@ function bp_core_admin_user_row_actions( $actions, $user_object ) {
1156
 
1157
  // If spammed, create unspam link.
1158
  if ( bp_is_user_spammer( $user_id ) ) {
1159
- $url = add_query_arg(
1160
- array(
1161
- 'action' => 'ham',
1162
- 'user' => $user_id,
1163
- ),
1164
- $url
1165
- );
1166
- $unspam_link = wp_nonce_url( $url, 'bp-spam-user' );
1167
- $actions['ham'] = sprintf('<a href="%1$s">%2$s</a>', esc_url( $unspam_link ), esc_html__( 'Not Spam', 'buddypress' ) );
1168
 
1169
- // If not already spammed, create spam link.
1170
  } else {
1171
- $url = add_query_arg(
1172
- array(
1173
- 'action' => 'spam',
1174
- 'user' => $user_id,
1175
- ),
1176
- $url
1177
- );
1178
  $spam_link = wp_nonce_url( $url, 'bp-spam-user' );
1179
  $actions['spam'] = sprintf( '<a class="submitdelete" href="%1$s">%2$s</a>', esc_url( $spam_link ), esc_html__( 'Spam', 'buddypress' ) );
1180
  }
@@ -1299,49 +1153,3 @@ function bp_core_admin_body_classes( $classes ) {
1299
  return $classes . ' buddypress';
1300
  }
1301
  add_filter( 'admin_body_class', 'bp_core_admin_body_classes' );
1302
-
1303
- /**
1304
- * Adds a BuddyPress category to house BuddyPress blocks.
1305
- *
1306
- * @since 5.0.0
1307
- * @since 8.0.0 The `bp_block_category_post_types` filter has been deprecated.
1308
- *
1309
- * @param array $categories Array of block categories.
1310
- * @param string|WP_Post $post Post being loaded.
1311
- */
1312
- function bp_block_category( $categories = array(), $editor_name_or_post = null ) {
1313
- if ( $editor_name_or_post instanceof WP_Post ) {
1314
- $post_types = array( 'post', 'page' );
1315
-
1316
- /*
1317
- * As blocks are always loaded even if the category is not available, there's no more interest
1318
- * in disabling the BuddyPress category.
1319
- */
1320
- apply_filters_deprecated( 'bp_block_category_post_types', array( $post_types ), '8.0.0' );
1321
- }
1322
-
1323
- return array_merge(
1324
- $categories,
1325
- array(
1326
- array(
1327
- 'slug' => 'buddypress',
1328
- 'title' => __( 'BuddyPress', 'buddypress' ),
1329
- 'icon' => 'buddicons-buddypress-logo',
1330
- ),
1331
- )
1332
- );
1333
- }
1334
-
1335
- /**
1336
- * Select the right `block_categories` filter according to WP version.
1337
- *
1338
- * @since 8.0.0
1339
- */
1340
- function bp_block_init_category_filter() {
1341
- if ( function_exists( 'get_default_block_categories' ) ) {
1342
- add_filter( 'block_categories_all', 'bp_block_category', 1, 2 );
1343
- } else {
1344
- add_filter( 'block_categories', 'bp_block_category', 1, 2 );
1345
- }
1346
- }
1347
- add_action( 'bp_init', 'bp_block_init_category_filter' );
14
 
15
  /**
16
  * Initializes the wp-admin area "BuddyPress" menus and sub menus.
17
+ *
18
  */
19
  function bp_core_admin_menu_init() {
20
  add_action( bp_core_admin_hook(), 'bp_core_add_admin_menu', 9 );
65
  * This tells WP to highlight the Settings > BuddyPress menu item,
66
  * regardless of which actual BuddyPress admin screen we are on.
67
  *
68
+ * The conditional prevents the behaviour when the user is viewing the
69
  * backpat "Help" page, the Activity page, or any third-party plugins.
70
  *
71
  * @global string $plugin_page
77
  global $plugin_page, $submenu_file;
78
 
79
  // This tweaks the Settings subnav menu to show only one BuddyPress menu item.
80
+ if ( ! in_array( $plugin_page, array( 'bp-activity', 'bp-general-settings', ) ) ) {
81
  $submenu_file = 'bp-components';
82
  }
83
 
85
  if ( in_array( $plugin_page, array( 'bp-tools', 'available-tools' ) ) ) {
86
  $submenu_file = $plugin_page;
87
  }
 
 
 
 
 
88
  }
89
 
90
  /**
96
  *
97
  * @since 1.6.0
98
  *
99
+ * @todo Add convenience links into the markup once new positions are finalised.
100
  */
101
  function bp_core_admin_backpat_page() {
102
  $url = bp_core_do_network_admin() ? network_admin_url( 'settings.php' ) : admin_url( 'options-general.php' );
103
  $settings_url = add_query_arg( 'page', 'bp-components', $url ); ?>
104
 
105
  <div class="wrap">
106
+ <h2><?php _e( 'Why have all my BuddyPress menus disappeared?', 'buddypress' ); ?></h2>
 
107
 
108
+ <p><?php _e( "Don't worry! We've moved the BuddyPress options into more convenient and easier to find locations. You're seeing this page because you are running a legacy BuddyPress plugin which has not been updated.", 'buddypress' ); ?></p>
109
+ <p><?php printf( __( '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.', 'buddypress' ), esc_url( $settings_url ), bp_get_admin_url( 'users.php?page=bp-profile-setup' ) ); ?></p>
 
 
 
 
 
 
 
 
 
110
  </div>
111
 
112
  <?php
121
  * boxes.
122
  *
123
  * @since 1.5.0
124
+ *
125
  */
126
  function bp_core_print_admin_notices() {
127
 
144
 
145
  foreach ( $notice_types as $type ) {
146
  $notices = wp_list_filter( buddypress()->admin->notices, array( 'type' => $type ) );
147
+ printf( '<div id="message" class="fade %s">', sanitize_html_class( $type ) );
148
 
149
  foreach ( $notices as $notice ) {
150
  printf( '<p>%s</p>', $notice['message'] );
153
  printf( '</div>' );
154
  }
155
  }
156
+ add_action( 'admin_notices', 'bp_core_print_admin_notices' );
157
  add_action( 'network_admin_notices', 'bp_core_print_admin_notices' );
158
 
159
  /**
240
 
241
  // Add notice if no rewrite rules are enabled.
242
  if ( empty( $wp_rewrite->permalink_structure ) ) {
243
+ 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' ) ), 'error' );
 
 
 
 
 
 
 
244
  }
245
 
246
  // Get BuddyPress instance.
253
  $wp_page_components = array();
254
 
255
  // Only components with 'has_directory' require a WP page to function.
256
+ foreach( array_keys( $bp->loaded_components ) as $component_id ) {
257
+ if ( !empty( $bp->{$component_id}->has_directory ) ) {
258
  $wp_page_components[] = array(
259
  'id' => $component_id,
260
+ 'name' => isset( $bp->{$component_id}->name ) ? $bp->{$component_id}->name : ucwords( $bp->{$component_id}->id )
261
  );
262
  }
263
  }
264
 
265
  // Activate and Register are special cases. They are not components but they need WP pages.
266
  // If user registration is disabled, we can skip this step.
267
+ if ( bp_get_signup_allowed() ) {
268
  $wp_page_components[] = array(
269
  'id' => 'activate',
270
+ 'name' => __( 'Activate', 'buddypress' )
271
  );
272
 
273
  $wp_page_components[] = array(
274
  'id' => 'register',
275
+ 'name' => __( 'Register', 'buddypress' )
276
  );
277
  }
278
 
282
  $bp->pages = bp_core_get_directory_pages();
283
  }
284
 
285
+ foreach( $wp_page_components as $component ) {
286
+ if ( !isset( $bp->pages->{$component['id']} ) ) {
287
  $orphaned_components[] = $component['name'];
288
  }
289
  }
290
 
291
+ // Special case: If the Forums component is orphaned, but the bbPress 1.x installation is
292
+ // not correctly set up, don't show a nag. (In these cases, it's probably the case that the
293
+ // user is using bbPress 2.x; see https://buddypress.trac.wordpress.org/ticket/4292.
294
+ if ( isset( $bp->forums->name ) && in_array( $bp->forums->name, $orphaned_components ) && !bp_forums_is_installed_correctly() ) {
295
+ $forum_key = array_search( $bp->forums->name, $orphaned_components );
296
+ unset( $orphaned_components[$forum_key] );
297
+ $orphaned_components = array_values( $orphaned_components );
298
+ }
299
+
300
+ if ( !empty( $orphaned_components ) ) {
301
  $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) );
302
  $notice = sprintf(
303
  '%1$s <a href="%2$s">%3$s</a>',
304
  sprintf(
 
305
  __( 'The following active BuddyPress Components do not have associated WordPress Pages: %s.', 'buddypress' ),
306
  '<strong>' . implode( '</strong>, <strong>', array_map( 'esc_html', $orphaned_components ) ) . '</strong>'
307
  ),
317
  $page_ids = bp_core_get_directory_page_ids();
318
  $dupes = array_diff_assoc( $page_ids, array_unique( $page_ids ) );
319
 
320
+ if ( !empty( $dupes ) ) {
321
+ foreach( array_keys( $dupes ) as $dupe_component ) {
322
  $dupe_names[] = $bp->pages->{$dupe_component}->title;
323
  }
324
 
327
  }
328
 
329
  // If there are duplicates, post a message about them.
330
+ if ( !empty( $dupe_names ) ) {
331
  $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) );
332
  $notice = sprintf(
333
  '%1$s <a href="%2$s">%3$s</a>',
334
  sprintf(
 
335
  __( 'Each BuddyPress Component needs its own WordPress page. The following WordPress Pages have more than one component associated with them: %s.', 'buddypress' ),
336
  '<strong>' . implode( '</strong>, <strong>', array_map( 'esc_html', $dupe_names ) ) . '</strong>'
337
  ),
349
  * @since 1.7.0
350
  *
351
  * @internal Used internally to redirect BuddyPress to the about page on activation.
352
+ *
353
  */
354
  function bp_do_activation_redirect() {
355
 
366
  return;
367
  }
368
 
369
+ $query_args = array( 'page' => 'bp-about' );
370
  if ( get_transient( '_bp_is_new_install' ) ) {
371
  $query_args['is_new_install'] = '1';
372
  delete_transient( '_bp_is_new_install' );
373
  }
374
 
375
+ // Redirect to BuddyPress about page.
376
+ wp_safe_redirect( add_query_arg( $query_args, bp_get_admin_url( 'index.php' ) ) );
377
  }
378
 
379
  /** UI/Styling ****************************************************************/
382
  * Output the tabs in the admin area.
383
  *
384
  * @since 1.5.0
 
385
  *
386
  * @param string $active_tab Name of the tab that is active. Optional.
 
 
387
  */
388
+ function bp_core_admin_tabs( $active_tab = '' ) {
389
  $tabs_html = '';
390
  $idle_class = 'nav-tab';
391
  $active_class = 'nav-tab nav-tab-active';
397
  *
398
  * @param array $value Array of tabs to output to the admin area.
399
  */
400
+ $tabs = apply_filters( 'bp_core_admin_tabs', bp_core_get_admin_tabs( $active_tab ) );
401
 
402
  // Loop through tabs and build navigation.
403
  foreach ( array_values( $tabs ) as $tab_data ) {
412
  * Fires after the output of tabs for the admin area.
413
  *
414
  * @since 1.5.0
 
 
 
415
  */
416
+ do_action( 'bp_admin_tabs' );
417
  }
418
 
419
  /**
420
  * Get the data for the tabs in the admin area.
421
  *
422
  * @since 2.2.0
 
423
  *
424
  * @param string $active_tab Name of the tab that is active. Optional.
 
 
425
  * @return string
426
  */
427
+ function bp_core_get_admin_tabs( $active_tab = '' ) {
428
+ $tabs = array(
429
+ '0' => array(
430
+ 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), 'admin.php' ) ),
431
+ 'name' => __( 'Components', 'buddypress' )
432
+ ),
433
+ '1' => array(
434
+ 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) ),
435
+ 'name' => __( 'Pages', 'buddypress' )
436
+ ),
437
+ '2' => array(
438
+ 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), 'admin.php' ) ),
439
+ 'name' => __( 'Options', 'buddypress' )
440
+ ),
441
+ );
442
 
443
+ // If forums component is active, add additional tab.
444
+ if ( bp_is_active( 'forums' ) && class_exists( 'BP_Forums_Component' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445
 
446
+ // Enqueue thickbox.
447
+ wp_enqueue_script( 'thickbox' );
448
+ wp_enqueue_style( 'thickbox' );
449
+
450
+ $tabs['3'] = array(
451
+ 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bb-forums-setup' ), 'admin.php' ) ),
452
+ 'name' => __( 'Forums', 'buddypress' )
 
 
 
 
 
 
453
  );
454
  }
455
 
457
  * Filters the tab data used in our wp-admin screens.
458
  *
459
  * @since 2.2.0
 
460
  *
461
+ * @param array $tabs Tab data.
 
462
  */
463
+ return apply_filters( 'bp_core_get_admin_tabs', $tabs );
464
  }
465
 
466
  /** Help **********************************************************************/
480
  switch ( $screen->id ) {
481
 
482
  // Component page.
483
+ case 'settings_page_bp-components' :
484
+
485
  // Help tabs.
486
+ $screen->add_help_tab( array(
487
+ 'id' => 'bp-comp-overview',
488
+ 'title' => __( 'Overview', 'buddypress' ),
489
+ 'content' => bp_core_add_contextual_help_content( 'bp-comp-overview' ),
490
+ ) );
 
 
491
 
492
  // Help panel - sidebar links.
493
  $screen->set_help_sidebar(
498
  break;
499
 
500
  // Pages page.
501
+ case 'settings_page_bp-page-settings' :
502
+
503
  // Help tabs.
504
+ $screen->add_help_tab( array(
505
+ 'id' => 'bp-page-overview',
506
+ 'title' => __( 'Overview', 'buddypress' ),
507
+ 'content' => bp_core_add_contextual_help_content( 'bp-page-overview' ),
508
+ ) );
 
 
509
 
510
  // Help panel - sidebar links.
511
  $screen->set_help_sidebar(
517
  break;
518
 
519
  // Settings page.
520
+ case 'settings_page_bp-settings' :
521
+
522
  // Help tabs.
523
+ $screen->add_help_tab( array(
524
+ 'id' => 'bp-settings-overview',
525
+ 'title' => __( 'Overview', 'buddypress' ),
526
+ 'content' => bp_core_add_contextual_help_content( 'bp-settings-overview' ),
527
+ ) );
 
 
528
 
529
  // Help panel - sidebar links.
530
  $screen->set_help_sidebar(
536
  break;
537
 
538
  // Profile fields page.
539
+ case 'users_page_bp-profile-setup' :
540
+
541
  // Help tabs.
542
+ $screen->add_help_tab( array(
543
+ 'id' => 'bp-profile-overview',
544
+ 'title' => __( 'Overview', 'buddypress' ),
545
+ 'content' => bp_core_add_contextual_help_content( 'bp-profile-overview' ),
546
+ ) );
 
 
547
 
548
  // Help panel - sidebar links.
549
  $screen->set_help_sidebar(
571
  function bp_core_add_contextual_help_content( $tab = '' ) {
572
 
573
  switch ( $tab ) {
574
+ case 'bp-comp-overview' :
575
  $retval = __( 'By default, all but four of the BuddyPress components are enabled. You can selectively enable or disable any of the components by using the form below. Your BuddyPress installation will continue to function. However, the features of the disabled components will no longer be accessible to anyone using the site.', 'buddypress' );
576
  break;
577
 
578
+ case 'bp-page-overview' :
579
  $retval = __( 'BuddyPress Components use WordPress Pages for their root directory/archive pages. You can change the page associations for each active component by using the form below.', 'buddypress' );
580
  break;
581
 
582
+ case 'bp-settings-overview' :
583
  $retval = __( 'Extra configuration settings are provided and activated. You can selectively enable or disable any setting by using the form on this screen.', 'buddypress' );
584
  break;
585
 
586
+ case 'bp-profile-overview' :
587
+ $retval = __( 'Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile.', 'buddypress' ) . '<br /><br />' . __( 'Note: Any fields in the first group will appear on the signup page.', 'buddypress' );
588
  break;
589
 
590
  default:
593
  }
594
 
595
  // Wrap text in a paragraph tag.
596
+ if ( !empty( $retval ) ) {
597
  $retval = '<p>' . $retval . '</p>';
598
  }
599
 
606
  * Add a separator to the WordPress admin menus.
607
  *
608
  * @since 1.7.0
609
+ *
610
  */
611
  function bp_admin_separator() {
612
 
673
  $bp_menu_order = array();
674
 
675
  // Menu values.
676
+ $last_sep = is_network_admin() ? 'separator1' : 'separator2';
677
 
678
  /**
679
  * Filters the custom admin menus.
699
  if ( $last_sep == $item ) {
700
 
701
  // Add our custom menus.
702
+ foreach( (array) $custom_menus as $custom_menu ) {
703
  if ( array_search( $custom_menu, $menu_order ) ) {
704
  $bp_menu_order[] = $custom_menu;
705
  }
708
  // Add the appearance separator.
709
  $bp_menu_order[] = $last_sep;
710
 
711
+ // Skip our menu items.
712
  } elseif ( ! in_array( $item, $custom_menus ) ) {
713
  $bp_menu_order[] = $item;
714
  }
736
  $action = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
737
 
738
  // If the bottom is set, let it override the action.
739
+ if ( ! empty( $_REQUEST['action2'] ) && $_REQUEST['action2'] != "-1" ) {
740
  $action = $_REQUEST['action2'];
741
  }
742
 
755
  return;
756
  }
757
 
758
+ add_meta_box( 'add-buddypress-nav-menu', __( 'BuddyPress', 'buddypress' ), 'bp_admin_do_wp_nav_menu_meta_box', 'nav-menus', 'side', 'default' );
759
 
760
  add_action( 'admin_print_footer_scripts', 'bp_admin_wp_nav_menu_restrict_items' );
761
  }
762
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
763
  /**
764
  * Build and populate the BuddyPress accordion on Appearance > Menus.
765
  *
766
  * @since 1.9.0
 
767
  *
768
  * @global $nav_menu_selected_id
769
  */
770
+ function bp_admin_do_wp_nav_menu_meta_box() {
771
  global $nav_menu_selected_id;
772
 
773
+ $walker = new BP_Walker_Nav_Menu_Checklist( false );
774
+ $args = array( 'walker' => $walker );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
775
 
776
+ $post_type_name = 'buddypress';
 
 
 
 
 
 
 
 
 
 
 
777
 
778
+ $tabs = array();
 
 
779
 
780
+ $tabs['loggedin']['label'] = __( 'Logged-In', 'buddypress' );
781
+ $tabs['loggedin']['pages'] = bp_nav_menu_get_loggedin_pages();
 
 
 
 
 
 
 
 
 
 
782
 
783
+ $tabs['loggedout']['label'] = __( 'Logged-Out', 'buddypress' );
784
+ $tabs['loggedout']['pages'] = bp_nav_menu_get_loggedout_pages();
 
785
 
786
+ ?>
 
 
 
 
 
 
 
787
 
788
+ <div id="buddypress-menu" class="posttypediv">
789
+ <h4><?php _e( 'Logged-In', 'buddypress' ) ?></h4>
790
+ <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>
 
 
791
 
792
+ <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-loggedin" class="tabs-panel tabs-panel-active">
793
+ <ul id="buddypress-menu-checklist-loggedin" class="categorychecklist form-no-clear">
794
+ <?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $tabs['loggedin']['pages'] ), 0, (object) $args );?>
795
+ </ul>
796
+ </div>
797
 
798
+ <h4><?php _e( 'Logged-Out', 'buddypress' ) ?></h4>
799
+ <p><?php _e( '<em>Logged-Out</em> links are not visible to users who are logged in.', 'buddypress' ) ?></p>
 
800
 
801
+ <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-loggedout" class="tabs-panel tabs-panel-active">
802
+ <ul id="buddypress-menu-checklist-loggedout" class="categorychecklist form-no-clear">
803
+ <?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $tabs['loggedout']['pages'] ), 0, (object) $args );?>
804
+ </ul>
805
+ </div>
806
 
807
+ <?php
808
+ $removed_args = array(
809
+ 'action',
810
+ 'customlink-tab',
811
+ 'edit-menu-item',
812
+ 'menu-item',
813
+ 'page-tab',
814
+ '_wpnonce',
 
 
815
  );
816
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
817
 
818
+ <p class="button-controls">
819
+ <span class="list-controls">
820
+ <a href="<?php
821
+ echo esc_url( add_query_arg(
822
+ array(
823
+ $post_type_name . '-tab' => 'all',
824
+ 'selectall' => 1,
825
+ ),
826
+ remove_query_arg( $removed_args )
827
+ ) );
828
+ ?>#buddypress-menu" class="select-all"><?php _e( 'Select All', 'buddypress' ); ?></a>
829
+ </span>
830
+ <span class="add-to-menu">
831
+ <input type="submit"<?php if ( function_exists( 'wp_nav_menu_disabled_check' ) ) : wp_nav_menu_disabled_check( $nav_menu_selected_id ); endif; ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu', 'buddypress' ); ?>" name="add-custom-menu-item" id="submit-buddypress-menu" />
832
+ <span class="spinner"></span>
833
+ </span>
834
+ </p>
835
+ </div><!-- /#buddypress-menu -->
836
 
837
+ <?php
838
  }
839
 
840
  /**
863
 
864
  bp_core_add_admin_notice(
865
  sprintf(
866
+ __( 'Are your emails in the wrong language? Go to <a href="%s">BuddyPress Tools and run the "reinstall emails"</a> tool.', 'buddypress' ),
 
867
  esc_url( add_query_arg( 'page', 'bp-tools', bp_get_admin_url( $admin_page ) ) )
868
  ),
869
  'updated'
883
 
884
  bp_core_add_admin_notice(
885
  sprintf(
 
886
  __( 'Phrases wrapped in braces <code>{{ }}</code> are email tokens. <a href="%s">Learn about tokens on the BuddyPress Codex</a>.', 'buddypress' ),
887
  esc_url( 'https://codex.buddypress.org/emails/email-tokens/' )
888
  ),
909
  */
910
  function bp_email_tax_type_metabox( $post, $box ) {
911
  $r = array(
912
+ 'taxonomy' => bp_get_email_tax_type()
913
  );
914
 
915
  $tax_name = esc_attr( $r['taxonomy'] );
922
  echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.
923
  ?>
924
  <ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear">
925
+ <?php wp_terms_checklist( $post->ID, array( 'taxonomy' => $tax_name, 'walker' => new BP_Walker_Category_Checklist ) ); ?>
 
 
 
 
 
 
 
 
926
  </ul>
927
  </div>
928
 
953
  * @param WP_Post $post
954
  */
955
  function bp_email_plaintext_metabox( $post ) {
956
+ ?>
957
 
958
+ <label class="screen-reader-text" for="excerpt"><?php
 
959
  /* translators: accessibility text */
960
  _e( 'Plain text email content', 'buddypress' );
961
+ ?></label><textarea rows="5" cols="40" name="excerpt" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea>
 
962
 
963
  <p><?php _e( 'Most email clients support HTML email. However, some people prefer to receive plain text email. Enter a plain text alternative version of your email here.', 'buddypress' ); ?></p>
964
 
965
+ <?php
966
  }
967
 
968
  /**
982
  * @since 1.9.0
983
  */
984
  function bp_admin_wp_nav_menu_restrict_items() {
985
+ ?>
986
  <script type="text/javascript">
987
  jQuery( '#menu-to-edit').on( 'click', 'a.item-edit', function() {
988
  var settings = jQuery(this).closest( '.menu-item-bar' ).next( '.menu-item-settings' );
994
  }
995
  });
996
  </script>
997
+ <?php
998
  }
999
 
1000
  /**
1010
 
1011
  // Setup the $user_id variable from the current user object.
1012
  $user_id = 0;
1013
+ if ( !empty( $user_object->ID ) ) {
1014
  $user_id = absint( $user_object->ID );
1015
  }
1016
 
1022
 
1023
  // If spammed, create unspam link.
1024
  if ( bp_is_user_spammer( $user_id ) ) {
1025
+ $url = add_query_arg( array( 'action' => 'ham', 'user' => $user_id ), $url );
1026
+ $unspam_link = wp_nonce_url( $url, 'bp-spam-user' );
1027
+ $actions['ham'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $unspam_link ), esc_html__( 'Not Spam', 'buddypress' ) );
 
 
 
 
 
 
1028
 
1029
+ // If not already spammed, create spam link.
1030
  } else {
1031
+ $url = add_query_arg( array( 'action' => 'spam', 'user' => $user_id ), $url );
 
 
 
 
 
 
1032
  $spam_link = wp_nonce_url( $url, 'bp-spam-user' );
1033
  $actions['spam'] = sprintf( '<a class="submitdelete" href="%1$s">%2$s</a>', esc_url( $spam_link ), esc_html__( 'Spam', 'buddypress' ) );
1034
  }
1153
  return $classes . ' buddypress';
1154
  }
1155
  add_filter( 'admin_body_class', 'bp_core_admin_body_classes' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/admin/bp-core-admin-optouts.php DELETED
@@ -1,471 +0,0 @@
1
- <?php
2
- /**
3
- * BuddyPress Opt-outs management.
4
- *
5
- * @package BuddyPress
6
- * @subpackage Core
7
- * @since 8.0.0
8
- */
9
-
10
- // Exit if accessed directly.
11
- defined( 'ABSPATH' ) || exit;
12
-
13
- /**
14
- * Set up the Opt-outs admin page.
15
- *
16
- * Loaded before the page is rendered, this function does all initial
17
- * setup, including: processing form requests, registering contextual
18
- * help, and setting up screen options.
19
- *
20
- * @since 8.0.0
21
- *
22
- * @global $bp_optouts_list_table
23
- */
24
- function bp_core_optouts_admin_load() {
25
- global $bp_optouts_list_table;
26
-
27
- // Build redirection URL.
28
- $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'activated', 'notactivated', 'deleted', 'notdeleted', 'resent', 'notresent', 'do_delete', 'do_resend', 'do_activate', '_wpnonce', 'signup_ids' ), $_SERVER['REQUEST_URI'] );
29
- $doaction = bp_admin_list_table_current_bulk_action();
30
-
31
- /**
32
- * Fires at the start of the nonmember opt-outs admin load.
33
- *
34
- * @since 8.0.0
35
- *
36
- * @param string $doaction Current bulk action being processed.
37
- * @param array $_REQUEST Current $_REQUEST global.
38
- */
39
- do_action( 'bp_optouts_admin_load', $doaction, $_REQUEST );
40
-
41
- /**
42
- * Filters the allowed actions for use in the nonmember opt-outs admin page.
43
- *
44
- * @since 8.0.0
45
- *
46
- * @param array $value Array of allowed actions to use.
47
- */
48
- $allowed_actions = apply_filters( 'bp_optouts_admin_allowed_actions', array( 'do_delete', 'do_resend' ) );
49
-
50
- if ( ! in_array( $doaction, $allowed_actions ) || ( -1 == $doaction ) ) {
51
-
52
- require_once( ABSPATH . 'wp-admin/includes/class-wp-users-list-table.php' );
53
- $bp_optouts_list_table = new BP_Optouts_List_Table();
54
-
55
- // The per_page screen option.
56
- add_screen_option( 'per_page', array( 'label' => _x( 'Nonmember opt-outs', 'Nonmember opt-outs per page (screen options)', 'buddypress' ) ) );
57
-
58
- // Current screen.
59
- $current_screen = get_current_screen();
60
-
61
- $current_screen->add_help_tab(
62
- array(
63
- 'id' => 'bp-optouts-overview',
64
- 'title' => __( 'Overview', 'buddypress' ),
65
- 'content' =>
66
- '<p>' . __( 'This is the administration screen for nonmember opt-outs on your site.', 'buddypress' ) . '</p>' .
67
- '<p>' . __( 'From the screen options, you can customize the displayed columns and the pagination of this screen.', 'buddypress' ) . '</p>' .
68
- '<p>' . __( 'You can reorder the list of opt-outs by clicking on the Email Sender, Email Type or Date Modified column headers.', 'buddypress' ) . '</p>' .
69
- '<p>' . __( 'Using the search form, you can search for an opt-out to a specific email address.', 'buddypress' ) . '</p>',
70
- )
71
- );
72
-
73
- $current_screen->add_help_tab(
74
- array(
75
- 'id' => 'bp-optouts-actions',
76
- 'title' => __( 'Actions', 'buddypress' ),
77
- 'content' =>
78
- '<p>' . __( 'Hovering over a row in the opt-outs list will display action links that allow you to manage the opt-out. You can perform the following actions:', 'buddypress' ) . '</p>' .
79
- '<ul><li>' . __( '"Delete" allows you to delete the record of an opt-out. You will be asked to confirm this deletion.', 'buddypress' ) . '</li></ul>' .
80
- '<p>' . __( 'Bulk actions allow you to perform these actions for the selected rows.', 'buddypress' ) . '</p>',
81
- )
82
- );
83
-
84
- // Help panel - sidebar links.
85
- $current_screen->set_help_sidebar(
86
- '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
87
- '<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
88
- );
89
-
90
- // Add accessible hidden headings and text for the Pending Users screen.
91
- $current_screen->set_screen_reader_content(
92
- array(
93
- /* translators: accessibility text */
94
- 'heading_views' => __( 'Filter opt-outs list', 'buddypress' ),
95
- /* translators: accessibility text */
96
- 'heading_pagination' => __( 'Opt-out list navigation', 'buddypress' ),
97
- /* translators: accessibility text */
98
- 'heading_list' => __( 'Opt-outs list', 'buddypress' ),
99
- )
100
- );
101
-
102
- } else {
103
- if ( empty( $_REQUEST['optout_ids' ] ) ) {
104
- return;
105
- }
106
- $optout_ids = wp_parse_id_list( $_REQUEST['optout_ids' ] );
107
-
108
- // Handle optout deletion.
109
- if ( 'do_delete' == $doaction ) {
110
-
111
- // Nonce check.
112
- check_admin_referer( 'optouts_delete' );
113
-
114
- $success = 0;
115
- foreach ( $optout_ids as $optout_id ) {
116
- if ( bp_delete_optout_by_id( $optout_id ) ) {
117
- $success++;
118
- }
119
- }
120
-
121
- $query_arg = array( 'updated' => 'deleted' );
122
-
123
- if ( ! empty( $success ) ) {
124
- $query_arg['deleted'] = $success;
125
- }
126
-
127
- $notdeleted = count( $optout_ids ) - $success;
128
- if ( $notdeleted > 0 ) {
129
- $query_arg['notdeleted'] = $notdeleted;
130
- }
131
-
132
- $redirect_to = add_query_arg( $query_arg, $redirect_to );
133
-
134
- bp_core_redirect( $redirect_to );
135
-
136
- // Plugins can update other stuff from here.
137
- } else {
138
-
139
- /**
140
- * Fires at end of opt-outs admin load
141
- * if doaction does not match any actions.
142
- *
143
- * @since 2.0.0
144
- *
145
- * @param string $doaction Current bulk action being processed.
146
- * @param array $_REQUEST Current $_REQUEST global.
147
- * @param string $redirect Determined redirect url to send user to.
148
- */
149
- do_action( 'bp_core_admin_update_optouts', $doaction, $_REQUEST, $redirect_to );
150
-
151
- bp_core_redirect( $redirect_to );
152
- }
153
- }
154
- }
155
- add_action( "load-tools_page_bp-optouts", 'bp_core_optouts_admin_load' );
156
-
157
- /**
158
- * Get admin notice when viewing the optouts management page.
159
- *
160
- * @since 8.0.0
161
- *
162
- * @return array
163
- */
164
- function bp_core_get_optouts_notice() {
165
-
166
- // Setup empty notice for return value.
167
- $notice = array();
168
-
169
- // Updates.
170
- if ( ! empty( $_REQUEST['updated'] ) && 'deleted' === $_REQUEST['updated'] ) {
171
- $notice = array(
172
- 'class' => 'updated',
173
- 'message' => ''
174
- );
175
-
176
- if ( ! empty( $_REQUEST['deleted'] ) ) {
177
- $deleted = absint( $_REQUEST['deleted'] );
178
- $notice['message'] .= sprintf(
179
- _nx(
180
- /* translators: %s: number of deleted optouts */
181
- '%s opt-out successfully deleted!', '%s opt-outs successfully deleted!',
182
- $deleted,
183
- 'nonmembers opt-out deleted',
184
- 'buddypress'
185
- ),
186
- number_format_i18n( absint( $_REQUEST['deleted'] ) )
187
- );
188
- }
189
-
190
- if ( ! empty( $_REQUEST['notdeleted'] ) ) {
191
- $notdeleted = absint( $_REQUEST['notdeleted'] );
192
- $notice['message'] .= sprintf(
193
- _nx(
194
- /* translators: %s: number of optouts that failed to be deleted */
195
- '%s opt-out was not deleted.', '%s opt-outs were not deleted.',
196
- $notdeleted,
197
- 'nonmembers opt-out not deleted',
198
- 'buddypress'
199
- ),
200
- number_format_i18n( $notdeleted )
201
- );
202
-
203
- if ( empty( $_REQUEST['deleted'] ) ) {
204
- $notice['class'] = 'error';
205
- }
206
- }
207
- }
208
-
209
- // Errors.
210
- if ( ! empty( $_REQUEST['error'] ) && 'do_delete' === $_REQUEST['error'] ) {
211
- $notice = array(
212
- 'class' => 'error',
213
- 'message' => esc_html__( 'There was a problem deleting opt-outs. Please try again.', 'buddypress' ),
214
- );
215
- }
216
-
217
- return $notice;
218
- }
219
-
220
- /**
221
- * Opt-outs admin page router.
222
- *
223
- * Depending on the context, display
224
- * - the list of optouts,
225
- * - or the delete confirmation screen,
226
- *
227
- * Also prepare the admin notices.
228
- *
229
- * @since 8.0.0
230
- */
231
- function bp_core_optouts_admin() {
232
- $doaction = bp_admin_list_table_current_bulk_action();
233
-
234
- // Prepare notices for admin.
235
- $notice = bp_core_get_optouts_notice();
236
-
237
- // Display notices.
238
- if ( ! empty( $notice ) ) :
239
- if ( 'updated' === $notice['class'] ) : ?>
240
-
241
- <div id="message" class="<?php echo esc_attr( $notice['class'] ); ?> notice is-dismissible">
242
-
243
- <?php else: ?>
244
-
245
- <div class="<?php echo esc_attr( $notice['class'] ); ?> notice is-dismissible">
246
-
247
- <?php endif; ?>
248
-
249
- <p><?php echo esc_html( $notice['message'] ); ?></p>
250
- </div>
251
-
252
- <?php endif;
253
-
254
- // Show the proper screen.
255
- switch ( $doaction ) {
256
- case 'delete' :
257
- bp_core_optouts_admin_manage( $doaction );
258
- break;
259
-
260
- default:
261
- bp_core_optouts_admin_index();
262
- break;
263
- }
264
- }
265
-
266
- /**
267
- * This is the list of optouts.
268
- *
269
- * @since 8.0.0
270
- *
271
- * @global $plugin_page
272
- * @global $bp_optouts_list_table
273
- */
274
- function bp_core_optouts_admin_index() {
275
- global $plugin_page, $bp_optouts_list_table;
276
-
277
- $usersearch = ! empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
278
-
279
- // Prepare the group items for display.
280
- $bp_optouts_list_table->prepare_items();
281
-
282
- if ( is_network_admin() ) {
283
- $form_url = network_admin_url( 'admin.php' );
284
- } else {
285
- $form_url = bp_get_admin_url( 'tools.php' );
286
- }
287
-
288
- $form_url = add_query_arg(
289
- array(
290
- 'page' => 'bp-optouts',
291
- ),
292
- $form_url
293
- );
294
-
295
- $search_form_url = remove_query_arg(
296
- array(
297
- 'action',
298
- 'deleted',
299
- 'notdeleted',
300
- 'error',
301
- 'updated',
302
- 'delete',
303
- 'activate',
304
- 'activated',
305
- 'notactivated',
306
- 'resend',
307
- 'resent',
308
- 'notresent',
309
- 'do_delete',
310
- 'do_activate',
311
- 'do_resend',
312
- 'action2',
313
- '_wpnonce',
314
- 'optout_ids'
315
- ),
316
- $_SERVER['REQUEST_URI']
317
- );
318
-
319
- ?>
320
-
321
- <div class="wrap">
322
- <h1 class="wp-heading-inline"><?php esc_html_e( 'BuddyPress tools', 'buddypress' ); ?></h1>
323
- <hr class="wp-header-end">
324
-
325
- <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Manage Opt-outs', 'buddypress' ), 'tools' ); ?></h2>
326
-
327
- <?php
328
- if ( $usersearch ) {
329
- $num_results = (int) $bp_optouts_list_table->total_items;
330
- printf(
331
- '<p><span class="subtitle">%s</span></p>',
332
- sprintf(
333
- esc_html(
334
- /* translators: %s: the searched email. */
335
- _n( 'Opt-out with an email address matching &#8220;%s&#8221;', 'Opt-outs with an email address matching &#8220;%s&#8221;', $num_results, 'buddypress' )
336
- ),
337
- esc_html( $usersearch )
338
- )
339
- );
340
- }
341
- ?>
342
- <p><?php esc_html_e( 'This table shows opt-out requests from people who are not members of this site, but have been contacted via communication from this site, and wish to receive no further communications.', 'buddypress' ); ?></p>
343
-
344
- <?php // Display each opt-out on its own row. ?>
345
- <?php $bp_optouts_list_table->views(); ?>
346
-
347
- <form id="bp-optouts-search-form" action="<?php echo esc_url( $search_form_url ) ;?>">
348
- <input type="hidden" name="page" value="<?php echo esc_attr( $plugin_page ); ?>" />
349
- <?php $bp_optouts_list_table->search_box( esc_html__( 'Search for a specific email address', 'buddypress' ), 'bp-optouts' ); ?>
350
- </form>
351
-
352
- <form id="bp-optouts-form" action="<?php echo esc_url( $form_url );?>" method="post">
353
- <?php $bp_optouts_list_table->display(); ?>
354
- </form>
355
- </div>
356
- <?php
357
- }
358
-
359
- /**
360
- * This is the confirmation screen for actions.
361
- *
362
- * @since 8.0.0
363
- *
364
- * @param string $action Delete or resend optout.
365
- *
366
- * @return null|false
367
- */
368
- function bp_core_optouts_admin_manage( $action = '' ) {
369
- $capability = bp_core_do_network_admin() ? 'manage_network_options' : 'manage_options';
370
- if ( ! current_user_can( $capability ) || empty( $action ) ) {
371
- die( '-1' );
372
- }
373
-
374
- // Get the IDs from the URL.
375
- $ids = false;
376
- if ( ! empty( $_POST['optout_ids'] ) ) {
377
- $ids = wp_parse_id_list( $_POST['optout_ids'] );
378
- } elseif ( ! empty( $_GET['optout_id'] ) ) {
379
- $ids = absint( $_GET['optout_id'] );
380
- }
381
-
382
- if ( empty( $ids ) ) {
383
- return false;
384
- }
385
-
386
- // Query for matching optouts, and filter out bad IDs.
387
- $args = array(
388
- 'id' => $ids,
389
- );
390
- $optouts = bp_get_optouts( $args );
391
- $optout_ids = wp_list_pluck( $optouts, 'id' );
392
-
393
- // Check optout IDs and set up strings.
394
- switch ( $action ) {
395
- case 'delete' :
396
- if ( 0 === count( $optouts ) ) {
397
- $helper_text = __( 'No opt-out requests were found.', 'buddypress' );
398
- } else {
399
- $helper_text = _n( 'You are about to delete the following opt-out request:', 'You are about to delete the following opt-out requests:', count( $optouts ), 'buddypress' );
400
- }
401
- break;
402
- }
403
-
404
- // These arguments are added to all URLs.
405
- $url_args = array( 'page' => 'bp-optouts' );
406
-
407
- // These arguments are only added when performing an action.
408
- $action_args = array(
409
- 'action' => 'do_' . $action,
410
- 'optout_ids' => implode( ',', $optout_ids )
411
- );
412
-
413
- if ( is_network_admin() ) {
414
- $base_url = network_admin_url( 'admin.php' );
415
- } else {
416
- $base_url = bp_get_admin_url( 'tools.php' );
417
- }
418
-
419
- $cancel_url = add_query_arg( $url_args, $base_url );
420
- $action_url = wp_nonce_url(
421
- add_query_arg(
422
- array_merge( $url_args, $action_args ),
423
- $base_url
424
- ),
425
- 'optouts_' . $action
426
- );
427
-
428
- ?>
429
-
430
- <div class="wrap">
431
- <h1 class="wp-heading-inline"><?php esc_html_e( 'BuddyPress tools', 'buddypress' ); ?></h1>
432
- <hr class="wp-header-end">
433
-
434
- <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Manage Opt-outs', 'buddypress' ), 'tools' ); ?></h2>
435
-
436
- <p><?php echo esc_html( $helper_text ); ?></p>
437
-
438
- <ol class="bp-optouts-list">
439
- <?php foreach ( $optouts as $optout ) : ?>
440
-
441
- <li>
442
- <strong><?php echo esc_html( $optout->email_address ) ?></strong>
443
- <p class="description">
444
- <?php
445
- $last_modified = mysql2date( 'Y/m/d g:i:s a', $optout->date_modified );
446
- /* translators: %s: modification date */
447
- printf( esc_html__( 'Date modified: %s', 'buddypress'), $last_modified );
448
- ?>
449
- </p>
450
- </li>
451
-
452
- <?php endforeach; ?>
453
- </ol>
454
-
455
- <?php if ( 'delete' === $action && count( $optouts ) ) : ?>
456
-
457
- <p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ) ?></strong></p>
458
-
459
- <?php endif ; ?>
460
-
461
- <?php if ( count( $optouts ) ) : ?>
462
-
463
- <a class="button-primary" href="<?php echo esc_url( $action_url ); ?>"><?php esc_html_e( 'Confirm', 'buddypress' ); ?></a>
464
-
465
- <?php endif; ?>
466
-
467
- <a class="button" href="<?php echo esc_url( $cancel_url ); ?>"><?php esc_html_e( 'Cancel', 'buddypress' ) ?></a>
468
- </div>
469
-
470
- <?php
471
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/admin/bp-core-admin-schema.php CHANGED
@@ -37,12 +37,6 @@ function bp_core_install( $active_components = false ) {
37
  // Install the signups table.
38
  bp_core_maybe_install_signups();
39
 
40
- // Install the invitations table.
41
- bp_core_install_invitations();
42
-
43
- // Install the nonmember opt-outs table.
44
- bp_core_install_nonmember_opt_outs();
45
-
46
  // Notifications.
47
  if ( !empty( $active_components['notifications'] ) ) {
48
  bp_core_install_notifications();
@@ -388,12 +382,6 @@ function bp_core_install_extended_profiles() {
388
 
389
  if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE id = 1" ) ) {
390
  $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-fullname-field-name' ) ) ) . ", '', 1, 0 );";
391
-
392
- // Make sure the custom visibility is disabled for the default field.
393
- if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_meta WHERE id = 1" ) ) {
394
- $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_meta ( object_id, object_type, meta_key, meta_value ) VALUES ( 1, 'field', 'allow_custom_visibility', 'disabled' );";
395
- $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_meta ( object_id, object_type, meta_key, meta_value ) VALUES ( 1, 'field', 'signup_position', 1 );";
396
- }
397
  }
398
 
399
  dbDelta( $insert_sql );
@@ -518,12 +506,6 @@ function bp_core_install_emails() {
518
 
519
  // Add these emails to the database.
520
  foreach ( $emails as $id => $email ) {
521
-
522
- // Some emails are multisite-only.
523
- if ( ! is_multisite() && isset( $email['args'] ) && ! empty( $email['args']['multisite'] ) ) {
524
- continue;
525
- }
526
-
527
  $post_id = wp_insert_post( bp_parse_args( $email, $defaults, 'install_email_' . $id ) );
528
  if ( ! $post_id ) {
529
  continue;
@@ -547,84 +529,3 @@ function bp_core_install_emails() {
547
  */
548
  do_action( 'bp_core_install_emails' );
549
  }
550
-
551
- /**
552
- * Install database tables for the Invitations API
553
- *
554
- * @since 5.0.0
555
- *
556
- * @uses bp_core_set_charset()
557
- * @uses bp_core_get_table_prefix()
558
- * @uses dbDelta()
559
- */
560
- function bp_core_install_invitations() {
561
- $sql = array();
562
- $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
563
- $bp_prefix = bp_core_get_table_prefix();
564
- $sql[] = "CREATE TABLE {$bp_prefix}bp_invitations (
565
- id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
566
- user_id bigint(20) NOT NULL,
567
- inviter_id bigint(20) NOT NULL,
568
- invitee_email varchar(100) DEFAULT NULL,
569
- class varchar(120) NOT NULL,
570
- item_id bigint(20) NOT NULL,
571
- secondary_item_id bigint(20) DEFAULT NULL,
572
- type varchar(12) NOT NULL DEFAULT 'invite',
573
- content longtext DEFAULT '',
574
- date_modified datetime NOT NULL,
575
- invite_sent tinyint(1) NOT NULL DEFAULT '0',
576
- accepted tinyint(1) NOT NULL DEFAULT '0',
577
- KEY user_id (user_id),
578
- KEY inviter_id (inviter_id),
579
- KEY invitee_email (invitee_email),
580
- KEY class (class),
581
- KEY item_id (item_id),
582
- KEY secondary_item_id (secondary_item_id),
583
- KEY type (type),
584
- KEY invite_sent (invite_sent),
585
- KEY accepted (accepted)
586
- ) {$charset_collate};";
587
- dbDelta( $sql );
588
-
589
- /**
590
- * Fires after BuddyPress adds the invitations table.
591
- *
592
- * @since 5.0.0
593
- */
594
- do_action( 'bp_core_install_invitations' );
595
- }
596
-
597
- /**
598
- * Install database tables to store opt-out requests from nonmembers.
599
- *
600
- * @since 8.0.0
601
- *
602
- * @uses bp_core_set_charset()
603
- * @uses bp_core_get_table_prefix()
604
- * @uses dbDelta()
605
- */
606
- function bp_core_install_nonmember_opt_outs() {
607
- $sql = array();
608
- $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
609
- $bp_prefix = bp_core_get_table_prefix();
610
- $optouts_class = new BP_Optout();
611
- $table_name = $optouts_class->get_table_name();
612
- $sql = "CREATE TABLE {$table_name} (
613
- id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
614
- email_address_hash varchar(255) NOT NULL,
615
- user_id bigint(20) NOT NULL,
616
- email_type varchar(255) NOT NULL,
617
- date_modified datetime NOT NULL,
618
- KEY user_id (user_id),
619
- KEY email_type (email_type),
620
- KEY date_modified (date_modified)
621
- ) {$charset_collate};";
622
- dbDelta( $sql );
623
-
624
- /**
625
- * Fires after BuddyPress adds the nonmember opt-outs table.
626
- *
627
- * @since 8.0.0
628
- */
629
- do_action( 'bp_core_install_nonmember_opt_outs' );
630
- }
37
  // Install the signups table.
38
  bp_core_maybe_install_signups();
39
 
 
 
 
 
 
 
40
  // Notifications.
41
  if ( !empty( $active_components['notifications'] ) ) {
42
  bp_core_install_notifications();
382
 
383
  if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE id = 1" ) ) {
384
  $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-fullname-field-name' ) ) ) . ", '', 1, 0 );";
 
 
 
 
 
 
385
  }
386
 
387
  dbDelta( $insert_sql );
506
 
507
  // Add these emails to the database.
508
  foreach ( $emails as $id => $email ) {
 
 
 
 
 
 
509
  $post_id = wp_insert_post( bp_parse_args( $email, $defaults, 'install_email_' . $id ) );
510
  if ( ! $post_id ) {
511
  continue;
529
  */
530
  do_action( 'bp_core_install_emails' );
531
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/admin/bp-core-admin-settings.php CHANGED
@@ -70,8 +70,8 @@ function bp_admin_setting_callback_theme_package_id() {
70
  }
71
 
72
  if ( $options ) : ?>
73
- <select name="_bp_theme_package_id" id="_bp_theme_package_id" aria-describedby="_bp_theme_package_description"><?php echo $options; ?></select>
74
- <p id="_bp_theme_package_description" class="description"><?php esc_html_e( 'The selected Template Pack will serve all BuddyPress templates.', 'buddypress' ); ?></p>
75
 
76
  <?php else : ?>
77
  <p><?php esc_html_e( 'No template packages available.', 'buddypress' ); ?></p>
@@ -104,7 +104,7 @@ function bp_admin_setting_callback_activity_akismet() {
104
  }
105
 
106
  /**
107
- * Allow activity comments on posts and comments.
108
  *
109
  * @since 1.6.0
110
  */
@@ -112,7 +112,7 @@ function bp_admin_setting_callback_blogforum_comments() {
112
  ?>
113
 
114
  <input id="bp-disable-blogforum-comments" name="bp-disable-blogforum-comments" type="checkbox" value="1" <?php checked( !bp_disable_blogforum_comments( false ) ); ?> />
115
- <label for="bp-disable-blogforum-comments"><?php _e( 'Allow activity stream commenting on posts and comments', 'buddypress' ); ?></label>
116
 
117
  <?php
118
  }
@@ -134,7 +134,7 @@ function bp_admin_setting_callback_heartbeat() {
134
  /**
135
  * Sanitization for bp-disable-blogforum-comments setting.
136
  *
137
- * In the UI, a checkbox asks whether you'd like to *enable* post/comment activity comments. For
138
  * legacy reasons, the option that we store is 1 if these comments are *disabled*. So we use this
139
  * function to flip the boolean before saving the intval.
140
  *
@@ -147,25 +147,42 @@ function bp_admin_sanitize_callback_blogforum_comments( $value = false ) {
147
  return $value ? 0 : 1;
148
  }
149
 
150
- /** Members *******************************************************************/
151
 
152
  /**
153
  * Profile settings section description for the settings page.
154
  *
155
  * @since 1.6.0
156
  */
157
- function bp_admin_setting_callback_members_section() { }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
 
159
  /**
160
  * Allow members to upload avatars field.
161
  *
162
  * @since 1.6.0
163
- * @since 6.0.0 Setting has been moved into the Members section.
164
  */
165
  function bp_admin_setting_callback_avatar_uploads() {
166
  ?>
 
167
  <input id="bp-disable-avatar-uploads" name="bp-disable-avatar-uploads" type="checkbox" value="1" <?php checked( !bp_disable_avatar_uploads( false ) ); ?> />
168
  <label for="bp-disable-avatar-uploads"><?php _e( 'Allow registered members to upload avatars', 'buddypress' ); ?></label>
 
169
  <?php
170
  }
171
 
@@ -173,7 +190,6 @@ function bp_admin_setting_callback_avatar_uploads() {
173
  * Allow members to upload cover images field.
174
  *
175
  * @since 2.4.0
176
- * @since 6.0.0 Setting has been moved into the Members section.
177
  */
178
  function bp_admin_setting_callback_cover_image_uploads() {
179
  ?>
@@ -182,51 +198,6 @@ function bp_admin_setting_callback_cover_image_uploads() {
182
  <?php
183
  }
184
 
185
- /**
186
- * Allow members to invite non-members to the network.
187
- *
188
- * @since 8.0.0
189
- */
190
- function bp_admin_setting_callback_members_invitations() {
191
- ?>
192
- <input id="bp-enable-members-invitations" name="bp-enable-members-invitations" type="checkbox" value="1" <?php checked( bp_get_members_invitations_allowed() ); ?> />
193
- <label for="bp-enable-members-invitations"><?php _e( 'Allow registered members to invite people to join this network', 'buddypress' ); ?></label>
194
- <?php if ( ! bp_get_signup_allowed() ) : ?>
195
- <p class="description"><?php _e( 'Public registration is currently disabled. However, invitees will still be able to register if network invitations are enabled.', 'buddypress' ); ?></p>
196
- <?php endif; ?>
197
- <?php
198
- /**
199
- * Fires after the output of the invitations settings section.
200
- *
201
- * @since 8.0.0
202
- */
203
- do_action( 'bp_admin_settings_after_members_invitations' );
204
- }
205
-
206
- /** XProfile ******************************************************************/
207
-
208
- /**
209
- * Profile settings section description for the settings page.
210
- *
211
- * @since 1.6.0
212
- */
213
- function bp_admin_setting_callback_xprofile_section() { }
214
-
215
- /**
216
- * Enable BP->WP profile syncing field.
217
- *
218
- * @since 1.6.0
219
- *
220
- */
221
- function bp_admin_setting_callback_profile_sync() {
222
- ?>
223
-
224
- <input id="bp-disable-profile-sync" name="bp-disable-profile-sync" type="checkbox" value="1" <?php checked( !bp_disable_profile_sync( false ) ); ?> />
225
- <label for="bp-disable-profile-sync"><?php _e( 'Enable BuddyPress to WordPress profile syncing', 'buddypress' ); ?></label>
226
-
227
- <?php
228
- }
229
-
230
  /** Groups Section ************************************************************/
231
 
232
  /**
@@ -245,9 +216,9 @@ function bp_admin_setting_callback_groups_section() { }
245
  function bp_admin_setting_callback_group_creation() {
246
  ?>
247
 
248
- <input id="bp_restrict_group_creation" name="bp_restrict_group_creation" type="checkbox" aria-describedby="bp_group_creation_description" value="1" <?php checked( !bp_restrict_group_creation( false ) ); ?> />
249
  <label for="bp_restrict_group_creation"><?php _e( 'Enable group creation for all users', 'buddypress' ); ?></label>
250
- <p class="description" id="bp_group_creation_description"><?php _e( 'Administrators can always create groups, regardless of this setting.', 'buddypress' ); ?></p>
251
 
252
  <?php
253
  }
@@ -276,6 +247,40 @@ function bp_admin_setting_callback_group_cover_image_uploads() {
276
  <?php
277
  }
278
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  /** Settings Page *************************************************************/
280
 
281
  /**
@@ -293,10 +298,9 @@ function bp_core_admin_settings() {
293
 
294
  <div class="wrap">
295
 
296
- <h1 class="wp-heading-inline"><?php esc_html_e( 'BuddyPress Settings', 'buddypress' ); ?></h1>
297
- <hr class="wp-header-end">
298
 
299
- <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( esc_html__( 'Options', 'buddypress' ) ); ?></h2>
300
 
301
  <form action="<?php echo esc_url( $form_action ) ?>" method="post">
302
 
70
  }
71
 
72
  if ( $options ) : ?>
73
+ <select name="_bp_theme_package_id" id="_bp_theme_package_id"><?php echo $options; ?></select>
74
+ <p class="description"><label for="_bp_theme_package_id"><?php esc_html_e( 'The selected Template Pack will serve all BuddyPress templates.', 'buddypress' ); ?></label></p>
75
 
76
  <?php else : ?>
77
  <p><?php esc_html_e( 'No template packages available.', 'buddypress' ); ?></p>
104
  }
105
 
106
  /**
107
+ * Allow activity comments on blog posts and forum posts.
108
  *
109
  * @since 1.6.0
110
  */
112
  ?>
113
 
114
  <input id="bp-disable-blogforum-comments" name="bp-disable-blogforum-comments" type="checkbox" value="1" <?php checked( !bp_disable_blogforum_comments( false ) ); ?> />
115
+ <label for="bp-disable-blogforum-comments"><?php _e( 'Allow activity stream commenting on blog and forum posts', 'buddypress' ); ?></label>
116
 
117
  <?php
118
  }
134
  /**
135
  * Sanitization for bp-disable-blogforum-comments setting.
136
  *
137
+ * In the UI, a checkbox asks whether you'd like to *enable* blog/forum activity comments. For
138
  * legacy reasons, the option that we store is 1 if these comments are *disabled*. So we use this
139
  * function to flip the boolean before saving the intval.
140
  *
147
  return $value ? 0 : 1;
148
  }
149
 
150
+ /** XProfile ******************************************************************/
151
 
152
  /**
153
  * Profile settings section description for the settings page.
154
  *
155
  * @since 1.6.0
156
  */
157
+ function bp_admin_setting_callback_xprofile_section() { }
158
+
159
+ /**
160
+ * Enable BP->WP profile syncing field.
161
+ *
162
+ * @since 1.6.0
163
+ *
164
+ */
165
+ function bp_admin_setting_callback_profile_sync() {
166
+ ?>
167
+
168
+ <input id="bp-disable-profile-sync" name="bp-disable-profile-sync" type="checkbox" value="1" <?php checked( !bp_disable_profile_sync( false ) ); ?> />
169
+ <label for="bp-disable-profile-sync"><?php _e( 'Enable BuddyPress to WordPress profile syncing', 'buddypress' ); ?></label>
170
+
171
+ <?php
172
+ }
173
 
174
  /**
175
  * Allow members to upload avatars field.
176
  *
177
  * @since 1.6.0
178
+ *
179
  */
180
  function bp_admin_setting_callback_avatar_uploads() {
181
  ?>
182
+
183
  <input id="bp-disable-avatar-uploads" name="bp-disable-avatar-uploads" type="checkbox" value="1" <?php checked( !bp_disable_avatar_uploads( false ) ); ?> />
184
  <label for="bp-disable-avatar-uploads"><?php _e( 'Allow registered members to upload avatars', 'buddypress' ); ?></label>
185
+
186
  <?php
187
  }
188
 
190
  * Allow members to upload cover images field.
191
  *
192
  * @since 2.4.0
 
193
  */
194
  function bp_admin_setting_callback_cover_image_uploads() {
195
  ?>
198
  <?php
199
  }
200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  /** Groups Section ************************************************************/
202
 
203
  /**
216
  function bp_admin_setting_callback_group_creation() {
217
  ?>
218
 
219
+ <input id="bp_restrict_group_creation" name="bp_restrict_group_creation" type="checkbox"value="1" <?php checked( !bp_restrict_group_creation( false ) ); ?> />
220
  <label for="bp_restrict_group_creation"><?php _e( 'Enable group creation for all users', 'buddypress' ); ?></label>
221
+ <p class="description"><?php _e( 'Administrators can always create groups, regardless of this setting.', 'buddypress' ); ?></p>
222
 
223
  <?php
224
  }
247
  <?php
248
  }
249
 
250
+ /** Forums Section ************************************************************/
251
+
252
+ /**
253
+ * Forums settings section description for the settings page.
254
+ *
255
+ * @since 1.6.0
256
+ */
257
+ function bp_admin_setting_callback_bbpress_section() { }
258
+
259
+ /**
260
+ * The bb-config.php location field.
261
+ *
262
+ * @since 1.6.0
263
+ *
264
+ */
265
+ function bp_admin_setting_callback_bbpress_configuration() {
266
+
267
+ $config_location = bp_get_option( 'bb-config-location' );
268
+ $file_exists = (bool) ( file_exists( $config_location ) || is_file( $config_location ) ); ?>
269
+
270
+ <input name="bb-config-location" type="text" id="bb-config-location" value="<?php bp_form_option( 'bb-config-location', '' ); ?>" class="medium-text" style="width: 300px;" />
271
+
272
+ <?php if ( false === $file_exists ) : ?>
273
+
274
+ <a class="button" href="<?php bp_admin_url( 'admin.php?page=bb-forums-setup&repair=1' ); ?>"><?php _e( 'Repair', 'buddypress' ) ?></a>
275
+ <span class="attention"><?php _e( 'File does not exist', 'buddypress' ); ?></span>
276
+
277
+ <?php endif; ?>
278
+
279
+ <p class="description"><?php _e( 'Absolute path to your bbPress configuration file.', 'buddypress' ); ?></p>
280
+
281
+ <?php
282
+ }
283
+
284
  /** Settings Page *************************************************************/
285
 
286
  /**
298
 
299
  <div class="wrap">
300
 
301
+ <h1><?php _e( 'BuddyPress Settings', 'buddypress' ); ?> </h1>
 
302
 
303
+ <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Options', 'buddypress' ) ); ?></h2>
304
 
305
  <form action="<?php echo esc_url( $form_action ) ?>" method="post">
306
 
bp-core/admin/bp-core-admin-slugs.php CHANGED
@@ -21,10 +21,9 @@ function bp_core_admin_slugs_settings() {
21
 
22
  <div class="wrap">
23
 
24
- <h1 class="wp-heading-inline"><?php esc_html_e( 'BuddyPress Settings', 'buddypress' ); ?> </h1>
25
- <hr class="wp-header-end">
26
 
27
- <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( esc_html__( 'Pages', 'buddypress' ) ); ?></h2>
28
  <form action="" method="post" id="bp-admin-page-form">
29
 
30
  <?php bp_core_admin_slugs_options(); ?>
@@ -111,17 +110,17 @@ function bp_core_admin_get_static_pages() {
111
  */
112
  function bp_core_admin_slugs_options() {
113
 
114
- // Get the existing WP pages.
115
  $existing_pages = bp_core_get_directory_page_ids();
116
 
117
  // Set up an array of components (along with component names) that have directory pages.
118
  $directory_pages = bp_core_admin_get_directory_pages();
119
 
120
- if ( ! empty( $directory_pages ) ) : ?>
121
 
122
- <h3><?php esc_html_e( 'Directories', 'buddypress' ); ?></h3>
123
 
124
- <p><?php esc_html_e( 'Associate a WordPress Page with each BuddyPress component directory.', 'buddypress' ); ?></p>
125
 
126
  <table class="form-table">
127
  <tbody>
@@ -141,15 +140,12 @@ function bp_core_admin_slugs_options() {
141
  'name' => 'bp_pages[' . esc_attr( $name ) . ']',
142
  'echo' => false,
143
  'show_option_none' => __( '- None -', 'buddypress' ),
144
- 'selected' => ! empty( $existing_pages[$name] ) ? $existing_pages[$name] : false
145
  ) ); ?>
146
 
147
- <?php if ( ! empty( $existing_pages[ $name ] ) && get_post( $existing_pages[ $name ] ) ) : ?>
148
 
149
- <a href="<?php echo esc_url( get_permalink( $existing_pages[$name] ) ); ?>" class="button-secondary" target="_bp">
150
- <?php esc_html_e( 'View', 'buddypress' ); ?> <span class="dashicons dashicons-external" aria-hidden="true"></span>
151
- <span class="screen-reader-text"><?php esc_html_e( '(opens in a new tab)', 'buddypress' ); ?></span>
152
- </a>
153
 
154
  <?php endif; ?>
155
 
@@ -185,49 +181,22 @@ function bp_core_admin_slugs_options() {
185
 
186
  if ( !empty( $static_pages ) ) : ?>
187
 
188
- <h3><?php esc_html_e( 'Registration', 'buddypress' ); ?></h3>
189
 
190
- <?php if ( bp_get_signup_allowed() || bp_get_members_invitations_allowed() ) : ?>
191
- <p>
192
- <?php esc_html_e( 'Associate WordPress Pages with the following BuddyPress Registration pages.', 'buddypress' ); ?>
193
- <?php esc_html_e( 'These pages will only be reachable by users who are not logged in.', 'buddypress' ); ?>
194
- </p>
195
  <?php else : ?>
196
  <?php if ( is_multisite() ) : ?>
197
- <p>
198
- <?php
199
- printf(
200
- /* translators: %s: the link to the Network settings page */
201
- esc_html_x( 'Registration is currently disabled. Before associating a page is allowed, please enable registration by selecting either the "User accounts may be registered" or "Both sites and user accounts can be registered" option on %s.', 'Disabled registration message for multisite config', 'buddypress' ),
202
- sprintf(
203
- '<a href="%1$s">%2$s</a>',
204
- esc_url( network_admin_url( 'settings.php' ) ),
205
- esc_html_x( 'this page', 'Link text for the Multisite’s network settings page', 'buddypress' )
206
- )
207
- );
208
- ?>
209
- </p>
210
  <?php else : ?>
211
- <p>
212
- <?php
213
- printf(
214
- /* translators: %s: the link to the Site general options page */
215
- esc_html_x( 'Registration is currently disabled. Before associating a page is allowed, please enable registration by clicking on the "Anyone can register" checkbox on %s.', 'Disabled registration message for regular site config', 'buddypress' ),
216
- sprintf(
217
- '<a href="%1$s">%2$s</a>',
218
- esc_url( admin_url( 'options-general.php' ) ),
219
- esc_html_x( 'this page', 'Link text for the Site’s general options page', 'buddypress' )
220
- )
221
- );
222
- ?>
223
- </p>
224
  <?php endif; ?>
225
  <?php endif; ?>
226
 
227
  <table class="form-table">
228
  <tbody>
229
 
230
- <?php if ( bp_get_signup_allowed() || bp_get_members_invitations_allowed() ) : foreach ( $static_pages as $name => $label ) : ?>
231
 
232
  <tr valign="top">
233
  <th scope="row">
@@ -245,6 +214,12 @@ function bp_core_admin_slugs_options() {
245
  'selected' => !empty( $existing_pages[$name] ) ? $existing_pages[$name] : false
246
  ) ) ?>
247
 
 
 
 
 
 
 
248
  <?php if ( ! bp_is_root_blog() ) restore_current_blog(); ?>
249
 
250
  </td>
@@ -277,9 +252,8 @@ function bp_core_admin_slugs_options() {
277
  function bp_core_admin_slugs_setup_handler() {
278
 
279
  if ( isset( $_POST['bp-admin-pages-submit'] ) ) {
280
- if ( ! check_admin_referer( 'bp-admin-pages-setup' ) ) {
281
  return false;
282
- }
283
 
284
  // Then, update the directory pages.
285
  if ( isset( $_POST['bp_pages'] ) ) {
21
 
22
  <div class="wrap">
23
 
24
+ <h1><?php _e( 'BuddyPress Settings', 'buddypress' ); ?> </h1>
 
25
 
26
+ <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Pages', 'buddypress' ) ); ?></h2>
27
  <form action="" method="post" id="bp-admin-page-form">
28
 
29
  <?php bp_core_admin_slugs_options(); ?>
110
  */
111
  function bp_core_admin_slugs_options() {
112
 
113
+ // Get the existing WP pages
114
  $existing_pages = bp_core_get_directory_page_ids();
115
 
116
  // Set up an array of components (along with component names) that have directory pages.
117
  $directory_pages = bp_core_admin_get_directory_pages();
118
 
119
+ if ( !empty( $directory_pages ) ) : ?>
120
 
121
+ <h3><?php _e( 'Directories', 'buddypress' ); ?></h3>
122
 
123
+ <p><?php _e( 'Associate a WordPress Page with each BuddyPress component directory.', 'buddypress' ); ?></p>
124
 
125
  <table class="form-table">
126
  <tbody>
140
  'name' => 'bp_pages[' . esc_attr( $name ) . ']',
141
  'echo' => false,
142
  'show_option_none' => __( '- None -', 'buddypress' ),
143
+ 'selected' => !empty( $existing_pages[$name] ) ? $existing_pages[$name] : false
144
  ) ); ?>
145
 
146
+ <?php if ( !empty( $existing_pages[$name] ) ) : ?>
147
 
148
+ <a href="<?php echo get_permalink( $existing_pages[$name] ); ?>" class="button-secondary" target="_bp"><?php _e( 'View', 'buddypress' ); ?></a>
 
 
 
149
 
150
  <?php endif; ?>
151
 
181
 
182
  if ( !empty( $static_pages ) ) : ?>
183
 
184
+ <h3><?php _e( 'Registration', 'buddypress' ); ?></h3>
185
 
186
+ <?php if ( bp_get_signup_allowed() ) : ?>
187
+ <p><?php _e( 'Associate WordPress Pages with the following BuddyPress Registration pages.', 'buddypress' ); ?></p>
 
 
 
188
  <?php else : ?>
189
  <?php if ( is_multisite() ) : ?>
190
+ <p><?php printf( __( 'Registration is currently disabled. Before associating a page is allowed, please enable registration by selecting either the "User accounts may be registered" or "Both sites and user accounts can be registered" option on <a href="%s">this page</a>.', 'buddypress' ), network_admin_url( 'settings.php' ) ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
191
  <?php else : ?>
192
+ <p><?php printf( __( 'Registration is currently disabled. Before associating a page is allowed, please enable registration by clicking on the "Anyone can register" checkbox on <a href="%s">this page</a>.', 'buddypress' ), admin_url( 'options-general.php' ) ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
193
  <?php endif; ?>
194
  <?php endif; ?>
195
 
196
  <table class="form-table">
197
  <tbody>
198
 
199
+ <?php if ( bp_get_signup_allowed() ) : foreach ( $static_pages as $name => $label ) : ?>
200
 
201
  <tr valign="top">
202
  <th scope="row">
214
  'selected' => !empty( $existing_pages[$name] ) ? $existing_pages[$name] : false
215
  ) ) ?>
216
 
217
+ <?php if ( !empty( $existing_pages[$name] ) ) : ?>
218
+
219
+ <a href="<?php echo get_permalink( $existing_pages[$name] ); ?>" class="button-secondary" target="_bp"><?php _e( 'View', 'buddypress' ); ?></a>
220
+
221
+ <?php endif; ?>
222
+
223
  <?php if ( ! bp_is_root_blog() ) restore_current_blog(); ?>
224
 
225
  </td>
252
  function bp_core_admin_slugs_setup_handler() {
253
 
254
  if ( isset( $_POST['bp-admin-pages-submit'] ) ) {
255
+ if ( !check_admin_referer( 'bp-admin-pages-setup' ) )
256
  return false;
 
257
 
258
  // Then, update the directory pages.
259
  if ( isset( $_POST['bp_pages'] ) ) {
bp-core/admin/bp-core-admin-tools.php CHANGED
@@ -19,30 +19,23 @@ function bp_core_admin_tools() {
19
  ?>
20
  <div class="wrap">
21
 
22
- <h1 class="wp-heading-inline"><?php esc_html_e( 'BuddyPress Tools', 'buddypress' ) ?></h1>
23
- <hr class="wp-header-end">
24
 
25
- <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Repair', 'buddypress' ), 'tools' ); ?></h2>
26
-
27
- <p><?php esc_html_e( 'BuddyPress keeps track of various relationships between members, groups, and activity items.', 'buddypress' ); ?></p>
28
- <p><?php esc_html_e( 'Occasionally these relationships become out of sync, most often after an import, update, or migration.', 'buddypress' ); ?></p>
29
  <p><?php esc_html_e( 'Use the tools below to manually recalculate these relationships.', 'buddypress' ); ?>
30
  </p>
31
-
32
- <h2><?php esc_html_e( 'Select the operation to perform', 'buddypress' ); ?></h2>
33
 
34
  <form class="settings" method="post" action="">
35
 
36
  <fieldset>
37
- <legend class="screen-reader-text"><?php esc_html_e( 'Repair tools', 'buddypress' ); ?></legend>
38
 
 
39
  <?php foreach ( bp_admin_repair_list() as $item ) : ?>
40
- <p>
41
- <label for="<?php echo esc_attr( str_replace( '_', '-', $item[0] ) ); ?>">
42
- <input type="radio" class="radio" name="bp-tools-run[]" id="<?php echo esc_attr( str_replace( '_', '-', $item[0] ) ); ?>" value="<?php echo esc_attr( $item[0] ); ?>" /> <?php echo esc_html( $item[1] ); ?>
43
- </label>
44
- </p>
45
  <?php endforeach; ?>
 
46
 
47
  <p class="submit">
48
  <input class="button-primary" type="submit" name="bp-tools-submit" value="<?php esc_attr_e( 'Repair Items', 'buddypress' ); ?>" />
@@ -80,7 +73,7 @@ function bp_admin_repair_handler() {
80
  $messages = array();
81
 
82
  foreach ( (array) bp_admin_repair_list() as $item ) {
83
- if ( isset( $item[2] ) && isset( $_POST['bp-tools-run'] ) && in_array( $item[0], (array) $_POST['bp-tools-run'], true ) && is_callable( $item[2] ) ) {
84
  $messages[] = call_user_func( $item[2] );
85
  }
86
  }
@@ -144,14 +137,6 @@ function bp_admin_repair_list() {
144
  __( 'Repopulate site tracking records.', 'buddypress' ),
145
  'bp_admin_repair_blog_records',
146
  );
147
-
148
- if ( is_multisite() && bp_is_active( 'blogs', 'site-icon' ) ) {
149
- $repair_list[91] = array(
150
- 'bp-blog-site-icons',
151
- __( 'Repair site tracking site icons/blog avatars synchronization.', 'buddypress' ),
152
- 'bp_admin_repair_blog_site_icons',
153
- );
154
- }
155
  }
156
 
157
  // Emails:
@@ -162,14 +147,6 @@ function bp_admin_repair_list() {
162
  'bp_admin_reinstall_emails',
163
  );
164
 
165
- // Invitations:
166
- // - maybe create the database table and migrate any existing group invitations.
167
- $repair_list[110] = array(
168
- 'bp-invitations-table',
169
- __( 'Create the database table for Invitations and migrate existing group invitations if needed.', 'buddypress' ),
170
- 'bp_admin_invitations_table',
171
- );
172
-
173
  ksort( $repair_list );
174
 
175
  /**
@@ -196,7 +173,6 @@ function bp_admin_repair_friend_count() {
196
  return;
197
  }
198
 
199
- /* translators: %s: the result of the action performed by the repair tool */
200
  $statement = __( 'Counting the number of friends for each user&hellip; %s', 'buddypress' );
201
  $result = __( 'Failed!', 'buddypress' );
202
 
@@ -255,7 +231,6 @@ function bp_admin_repair_group_count() {
255
  return;
256
  }
257
 
258
- /* translators: %s: the result of the action performed by the repair tool */
259
  $statement = __( 'Counting the number of groups for each user&hellip; %s', 'buddypress' );
260
  $result = __( 'Failed!', 'buddypress' );
261
 
@@ -298,7 +273,7 @@ function bp_admin_repair_group_count() {
298
  */
299
  function bp_admin_repair_blog_records() {
300
 
301
- /* translators: %s: the result of the action performed by the repair tool */
302
  $statement = __( 'Repopulating Blogs records&hellip; %s', 'buddypress' );
303
 
304
  // Default to failure text.
@@ -321,70 +296,12 @@ function bp_admin_repair_blog_records() {
321
  return array( 0, sprintf( $statement, $result ) );
322
  }
323
 
324
- /**
325
- * Repair site icons/blog avatars synchronization.
326
- *
327
- * @since 7.0.0
328
- *
329
- * @return array
330
- */
331
- function bp_admin_repair_blog_site_icons() {
332
-
333
- /* translators: %s: the result of the action performed by the repair tool */
334
- $statement = __( 'Repairing site icons/blog avatars synchronization&hellip; %s', 'buddypress' );
335
-
336
- if ( ! is_multisite() ) {
337
- return array( 0, sprintf( $statement, __( 'Failed!', 'buddypress' ) ) );
338
- }
339
-
340
- // Run function if blogs component is active.
341
- if ( bp_is_active( 'blogs', 'site-icon' ) ) {
342
- $blog_ids = get_sites(
343
- array(
344
- 'fields' => 'ids',
345
- 'archived' => 0,
346
- 'mature' => 0,
347
- 'spam' => 0,
348
- 'deleted' => 0,
349
- )
350
- );
351
-
352
- $sizes = array(
353
- array(
354
- 'key' => 'site_icon_url_full',
355
- 'size' => bp_core_avatar_full_width(),
356
- ),
357
- array(
358
- 'key' => 'site_icon_url_thumb',
359
- 'size' => bp_core_avatar_thumb_width(),
360
- ),
361
- );
362
-
363
- foreach ( $blog_ids as $blog_id ) {
364
- $site_icon = 0;
365
-
366
- foreach ( $sizes as $size ) {
367
- $site_icon = bp_blogs_get_site_icon_url( $blog_id, $size['size'] );
368
- if ( ! $site_icon ) {
369
- $site_icon = 0;
370
- }
371
-
372
- bp_blogs_update_blogmeta( $blog_id, $size['key'], $site_icon );
373
- }
374
- }
375
- }
376
-
377
- // All done!
378
- return array( 0, sprintf( $statement, __( 'Complete!', 'buddypress' ) ) );
379
- }
380
-
381
  /**
382
  * Recalculate the total number of active site members.
383
  *
384
  * @since 2.0.0
385
  */
386
  function bp_admin_repair_count_members() {
387
- /* translators: %s: the result of the action performed by the repair tool */
388
  $statement = __( 'Counting the number of active members on the site&hellip; %s', 'buddypress' );
389
  delete_transient( 'bp_active_member_count' );
390
  bp_core_get_active_member_count();
@@ -399,66 +316,11 @@ function bp_admin_repair_count_members() {
399
  * @since 2.0.0
400
  */
401
  function bp_admin_repair_last_activity() {
402
- /* translators: %s: the result of the action performed by the repair tool */
403
  $statement = __( 'Determining last activity dates for each user&hellip; %s', 'buddypress' );
404
  bp_last_activity_migrate();
405
  return array( 0, sprintf( $statement, __( 'Complete!', 'buddypress' ) ) );
406
  }
407
 
408
- /**
409
- * Create the invitations database table if it does not exist.
410
- * Migrate outstanding group invitations if needed.
411
- *
412
- * @since 6.0.0
413
- *
414
- * @return array
415
- */
416
- function bp_admin_invitations_table() {
417
- global $wpdb;
418
-
419
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
420
- require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
421
-
422
- /* translators: %s: the result of the action performed by the repair tool */
423
- $statement = __( 'Creating the Invitations database table if it does not exist&hellip; %s', 'buddypress' );
424
- $result = __( 'Failed to create table!', 'buddypress' );
425
-
426
- bp_core_install_invitations();
427
-
428
- // Check for existence of invitations table.
429
- $table_name = BP_Invitation_Manager::get_table_name();
430
- $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) );
431
- if ( ! $wpdb->get_var( $query ) == $table_name ) {
432
- // Early return if table creation failed.
433
- return array( 2, sprintf( $statement, $result ) );
434
- } else {
435
- $result = __( 'Created invitations table!', 'buddypress' );
436
- }
437
-
438
- // Migrate group invitations if needed.
439
- if ( bp_is_active( 'groups' ) ) {
440
- $bp = buddypress();
441
-
442
- /* translators: %s: the result of the action performed by the repair tool */
443
- $migrate_statement = __( 'Migrating group invitations&hellip; %s', 'buddypress' );
444
- $migrate_result = __( 'Failed to migrate invitations!', 'buddypress' );
445
-
446
- bp_groups_migrate_invitations();
447
-
448
- // Check that there are no outstanding group invites in the group_members table.
449
- $records = $wpdb->get_results( "SELECT id FROM {$bp->groups->table_name_members} WHERE is_confirmed = 0 AND is_banned = 0" );
450
- if ( empty( $records ) ) {
451
- $migrate_result = __( 'Migrated invitations!', 'buddypress' );
452
- return array( 0, sprintf( $statement . ' ' . $migrate_statement , $result, $migrate_result ) );
453
- } else {
454
- return array( 2, sprintf( $statement . ' ' . $migrate_statement , $result, $migrate_result ) );
455
- }
456
- }
457
-
458
- // Return a "create-only" success message.
459
- return array( 0, sprintf( $statement, $result ) );
460
- }
461
-
462
  /**
463
  * Assemble admin notices relating success/failure of repair processes.
464
  *
@@ -493,7 +355,7 @@ function bp_admin_tools_feedback( $message, $class = false ) {
493
  return false;
494
  }
495
 
496
- $message = '<div id="message" class="' . esc_attr( $class ) . ' notice is-dismissible">' . $message . '</div>';
497
  $message = str_replace( "'", "\'", $message );
498
  $lambda = function() use ( $message ) { echo $message; };
499
 
@@ -513,8 +375,7 @@ function bp_admin_tools_feedback( $message, $class = false ) {
513
  function bp_core_admin_available_tools_page() {
514
  ?>
515
  <div class="wrap">
516
- <h1 class="wp-heading-inline"><?php esc_html_e( 'Tools', 'buddypress' ) ?></h1>
517
- <hr class="wp-header-end">
518
 
519
  <?php
520
 
@@ -542,48 +403,12 @@ function bp_core_admin_available_tools_intro() {
542
  $page = bp_core_do_network_admin() ? 'admin.php' : 'tools.php' ;
543
  $url = add_query_arg( $query_arg, bp_get_admin_url( $page ) );
544
  ?>
545
- <div class="card tool-box bp-tools">
546
  <h2><?php esc_html_e( 'BuddyPress Tools', 'buddypress' ) ?></h2>
547
-
548
- <dl>
549
- <dt><?php esc_html_e( 'Repair Tools', 'buddypress' ) ?></dt>
550
- <dd>
551
- <?php esc_html_e( 'BuddyPress keeps track of various relationships between users, groups, and activity items. Occasionally these relationships become out of sync, most often after an import, update, or migration.', 'buddypress' ); ?>
552
- <?php
553
- printf(
554
- /* translators: %s: the link to the BuddyPress repair tools */
555
- esc_html_x( 'Use the %s to repair these relationships.', 'buddypress tools intro', 'buddypress' ),
556
- '<a href="' . esc_url( $url ) . '">' . esc_html__( 'BuddyPress Repair Tools', 'buddypress' ) . '</a>'
557
- );
558
- ?>
559
- </dd>
560
-
561
- <dt><?php esc_html_e( 'Manage Invitations', 'buddypress' ) ?></dt>
562
- <dd>
563
- <?php esc_html_e( 'When enabled, BuddyPress allows your users to invite nonmembers to join your site.', 'buddypress' ); ?>
564
- <?php
565
- $url = add_query_arg( 'page', 'bp-members-invitations', bp_get_admin_url( $page ) );
566
- printf(
567
- /* translators: %s: the link to the BuddyPress Invitations management tool screen */
568
- esc_html_x( 'Visit %s to manage your site&rsquo;s invitations.', 'buddypress invitations tool intro', 'buddypress' ),
569
- '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Invitations', 'buddypress' ) . '</a>'
570
- );
571
- ?>
572
- </dd>
573
-
574
- <dt><?php esc_html_e( 'Manage Opt-outs', 'buddypress' ) ?></dt>
575
- <dd>
576
- <?php esc_html_e( 'BuddyPress stores opt-out requests from people who are not members of this site, but have been contacted via communication from this site, and wish to opt-out from future communication.', 'buddypress' ); ?>
577
- <?php
578
- $url = add_query_arg( 'page', 'bp-optouts', bp_get_admin_url( $page ) );
579
- printf(
580
- /* translators: %s: the link to the BuddyPress Nonmember Opt-outs management tool screen */
581
- esc_html_x( 'Visit %s to manage your site&rsquo;s opt-out requests.', 'buddypress opt-outs intro', 'buddypress' ),
582
- '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Nonmember Opt-outs', 'buddypress' ) . '</a>'
583
- );
584
- ?>
585
- </dd>
586
- </dl>
587
  </div>
588
  <?php
589
  }
@@ -663,82 +488,3 @@ function bp_core_admin_notice_repopulate_blogs_resume() {
663
  echo '<div class="error"><p>' . __( 'It looks like you have more sites to record. Resume recording by checking the "Repopulate site tracking records" option.', 'buddypress' ) . '</p></div>';
664
  }
665
  add_action( 'network_admin_notices', 'bp_core_admin_notice_repopulate_blogs_resume' );
666
-
667
- /**
668
- * Add BuddyPress debug info to the WordPress Site Health info screen.
669
- *
670
- * @since 5.0.0
671
- *
672
- * @param array $debug_info The Site's debug info.
673
- * @return array The Site's debug info, including the BuddyPress specific ones.
674
- */
675
- function bp_core_admin_debug_information( $debug_info = array() ) {
676
- global $wp_settings_fields;
677
- $active_components = array_intersect_key( bp_core_get_components(), buddypress()->active_components );
678
- $bp_settings = array();
679
-
680
- foreach ( $wp_settings_fields['buddypress'] as $section => $settings ) {
681
- $prefix = '';
682
- $component_id = str_replace( 'bp_', '', $section );
683
-
684
- if ( isset( $active_components[ $component_id ]['title'] ) ) {
685
- $prefix = $active_components[ $component_id ]['title'] .': ';
686
- }
687
-
688
- foreach( $settings as $bp_setting ) {
689
- $reverse = (
690
- strpos( $bp_setting['id'], 'hide' ) !== false ||
691
- strpos( $bp_setting['id'], 'restrict' ) !== false ||
692
- strpos( $bp_setting['id'], 'disable' ) !== false
693
- );
694
-
695
- if ( ! isset( $bp_setting['id'] ) || '_bp_theme_package_id' === $bp_setting['id'] ) {
696
- continue;
697
- }
698
-
699
- $bp_setting_value = bp_get_option( $bp_setting['id'] );
700
- if ( '0' === $bp_setting_value || '1' === $bp_setting_value ) {
701
- if ( ( $reverse && '0' === $bp_setting_value ) || ( ! $reverse && '1' === $bp_setting_value ) ) {
702
- $bp_setting_value = __( 'Yes', 'buddypress' );
703
- } else {
704
- $bp_setting_value = __( 'No', 'buddypress' );
705
- }
706
- }
707
-
708
- // Make sure to show the setting is reversed when site info is copied to clipboard.
709
- $bp_settings_id = $bp_setting['id'];
710
- if ( $reverse ) {
711
- $bp_settings_id = '! ' . $bp_settings_id;
712
- }
713
-
714
- $bp_settings[ $bp_settings_id ] = array(
715
- 'label' => $prefix . $bp_setting['title'],
716
- 'value' => $bp_setting_value,
717
- );
718
- }
719
- }
720
-
721
- $debug_info['buddypress'] = array(
722
- 'label' => __( 'BuddyPress', 'buddypress' ),
723
- 'fields' => array_merge(
724
- array(
725
- 'version' => array(
726
- 'label' => __( 'Version', 'buddypress' ),
727
- 'value' => bp_get_version(),
728
- ),
729
- 'active_components' => array(
730
- 'label' => __( 'Active components', 'buddypress' ),
731
- 'value' => implode( ', ', wp_list_pluck( $active_components, 'title' ) ),
732
- ),
733
- 'template_pack' => array(
734
- 'label' => __( 'Active template pack', 'buddypress' ),
735
- 'value' => bp_get_theme_compat_name() . ' ' . bp_get_theme_compat_version(),
736
- ),
737
- ),
738
- $bp_settings
739
- )
740
- );
741
-
742
- return $debug_info;
743
- }
744
- add_filter( 'debug_information', 'bp_core_admin_debug_information' );
19
  ?>
20
  <div class="wrap">
21
 
22
+ <h1><?php esc_html_e( 'BuddyPress Tools', 'buddypress' ) ?></h1>
 
23
 
24
+ <p><?php esc_html_e( 'BuddyPress keeps track of various relationships between members, groups, and activity items. Occasionally these relationships become out of sync, most often after an import, update, or migration.', 'buddypress' ); ?></p>
 
 
 
25
  <p><?php esc_html_e( 'Use the tools below to manually recalculate these relationships.', 'buddypress' ); ?>
26
  </p>
27
+ <p class="description"><?php esc_html_e( 'Some of these tools create substantial database overhead. Avoid running more than one repair job at a time.', 'buddypress' ); ?></p>
 
28
 
29
  <form class="settings" method="post" action="">
30
 
31
  <fieldset>
32
+ <legend><?php esc_html_e( 'Repair tools', 'buddypress' ) ?></legend>
33
 
34
+ <div class="checkbox">
35
  <?php foreach ( bp_admin_repair_list() as $item ) : ?>
36
+ <label for="<?php echo esc_attr( str_replace( '_', '-', $item[0] ) ); ?>"><input type="checkbox" class="checkbox" name="<?php echo esc_attr( $item[0] ) . '" id="' . esc_attr( str_replace( '_', '-', $item[0] ) ); ?>" value="1" /> <?php echo esc_html( $item[1] ); ?></label>
 
 
 
 
37
  <?php endforeach; ?>
38
+ </div>
39
 
40
  <p class="submit">
41
  <input class="button-primary" type="submit" name="bp-tools-submit" value="<?php esc_attr_e( 'Repair Items', 'buddypress' ); ?>" />
73
  $messages = array();
74
 
75
  foreach ( (array) bp_admin_repair_list() as $item ) {
76
+ if ( isset( $item[2] ) && isset( $_POST[$item[0]] ) && 1 === absint( $_POST[$item[0]] ) && is_callable( $item[2] ) ) {
77
  $messages[] = call_user_func( $item[2] );
78
  }
79
  }
137
  __( 'Repopulate site tracking records.', 'buddypress' ),
138
  'bp_admin_repair_blog_records',
139
  );
 
 
 
 
 
 
 
 
140
  }
141
 
142
  // Emails:
147
  'bp_admin_reinstall_emails',
148
  );
149
 
 
 
 
 
 
 
 
 
150
  ksort( $repair_list );
151
 
152
  /**
173
  return;
174
  }
175
 
 
176
  $statement = __( 'Counting the number of friends for each user&hellip; %s', 'buddypress' );
177
  $result = __( 'Failed!', 'buddypress' );
178
 
231
  return;
232
  }
233
 
 
234
  $statement = __( 'Counting the number of groups for each user&hellip; %s', 'buddypress' );
235
  $result = __( 'Failed!', 'buddypress' );
236
 
273
  */
274
  function bp_admin_repair_blog_records() {
275
 
276
+ // Description of this tool, displayed to the user.
277
  $statement = __( 'Repopulating Blogs records&hellip; %s', 'buddypress' );
278
 
279
  // Default to failure text.
296
  return array( 0, sprintf( $statement, $result ) );
297
  }
298
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  /**
300
  * Recalculate the total number of active site members.
301
  *
302
  * @since 2.0.0
303
  */
304
  function bp_admin_repair_count_members() {
 
305
  $statement = __( 'Counting the number of active members on the site&hellip; %s', 'buddypress' );
306
  delete_transient( 'bp_active_member_count' );
307
  bp_core_get_active_member_count();
316
  * @since 2.0.0
317
  */
318
  function bp_admin_repair_last_activity() {
 
319
  $statement = __( 'Determining last activity dates for each user&hellip; %s', 'buddypress' );
320
  bp_last_activity_migrate();
321
  return array( 0, sprintf( $statement, __( 'Complete!', 'buddypress' ) ) );
322
  }
323
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  /**
325
  * Assemble admin notices relating success/failure of repair processes.
326
  *
355
  return false;
356
  }
357
 
358
+ $message = '<div id="message" class="' . esc_attr( $class ) . '">' . $message . '</div>';
359
  $message = str_replace( "'", "\'", $message );
360
  $lambda = function() use ( $message ) { echo $message; };
361
 
375
  function bp_core_admin_available_tools_page() {
376
  ?>
377
  <div class="wrap">
378
+ <h1><?php esc_attr_e( 'Tools', 'buddypress' ) ?></h1>
 
379
 
380
  <?php
381
 
403
  $page = bp_core_do_network_admin() ? 'admin.php' : 'tools.php' ;
404
  $url = add_query_arg( $query_arg, bp_get_admin_url( $page ) );
405
  ?>
406
+ <div class="card tool-box">
407
  <h2><?php esc_html_e( 'BuddyPress Tools', 'buddypress' ) ?></h2>
408
+ <p>
409
+ <?php esc_html_e( 'BuddyPress keeps track of various relationships between users, groups, and activity items. Occasionally these relationships become out of sync, most often after an import, update, or migration.', 'buddypress' ); ?>
410
+ <?php printf( esc_html_x( 'Use the %s to repair these relationships.', 'buddypress tools intro', 'buddypress' ), '<a href="' . esc_url( $url ) . '">' . esc_html__( 'BuddyPress Tools', 'buddypress' ) . '</a>' ); ?>
411
+ </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
412
  </div>
413
  <?php
414
  }
488
  echo '<div class="error"><p>' . __( 'It looks like you have more sites to record. Resume recording by checking the "Repopulate site tracking records" option.', 'buddypress' ) . '</p></div>';
489
  }
490
  add_action( 'network_admin_notices', 'bp_core_admin_notice_repopulate_blogs_resume' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/admin/bp-core-admin-types.php DELETED
@@ -1,298 +0,0 @@
1
- <?php
2
- /**
3
- * BuddyPress Types Admin functions.
4
- *
5
- * @package BuddyPress
6
- * @subpackage Core
7
- * @since 7.0.0
8
- */
9
-
10
- // Exit if accessed directly.
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- }
14
-
15
- /**
16
- * Get default values for the taxonomy registered metadata.
17
- *
18
- * @since 7.0.0
19
- *
20
- * @param string $type_taxonomy The type's taxonomy name.
21
- * @return array Default values for the taxonomy registered metadata.
22
- */
23
- function bp_core_admin_get_type_default_meta_values( $type_taxonomy ) {
24
- $metadata_schema = bp_get_type_metadata_schema( false, $type_taxonomy );
25
- $metadata = wp_list_pluck( $metadata_schema, 'type' );
26
-
27
- // Set default values according to their schema type.
28
- foreach ( $metadata as $meta_key => $meta_value ) {
29
- if ( in_array( $meta_value, array( 'boolean', 'integer' ), true ) ) {
30
- $metadata[ $meta_key ] = 0;
31
- } else {
32
- $metadata[ $meta_key ] = '';
33
- }
34
- }
35
-
36
- return $metadata;
37
- }
38
-
39
- /**
40
- * Insert a new type into the database.
41
- *
42
- * @since 7.0.0
43
- *
44
- * @param array $args {
45
- * Array of arguments describing the object type.
46
- *
47
- * @type string $taxonomy The Type's taxonomy. Required.
48
- * @type string $bp_type_id Unique string identifier for the member type. Required.
49
- * @see keys of the array returned by bp_get_type_metadata_schema() for the other arguments.
50
- * }
51
- * @return integer|WP_Error The Type's term ID on success. A WP_Error object otherwise.
52
- */
53
- function bp_core_admin_insert_type( $args = array() ) {
54
- $default_args = array(
55
- 'taxonomy' => '',
56
- 'bp_type_id' => '',
57
- );
58
-
59
- $args = array_map( 'wp_unslash', $args );
60
- $args = bp_parse_args(
61
- $args,
62
- $default_args,
63
- 'admin_insert_type'
64
- );
65
-
66
- if ( ! $args['bp_type_id'] || ! $args['taxonomy'] ) {
67
- return new WP_Error(
68
- 'invalid_type_taxonomy',
69
- __( 'The Type ID value is missing', 'buddypress' ),
70
- array(
71
- 'message' => 1,
72
- )
73
- );
74
- }
75
-
76
- $type_id = sanitize_title( $args['bp_type_id'] );
77
- $type_taxonomy = sanitize_key( $args['taxonomy'] );
78
-
79
- /**
80
- * Filter here to check for an already existing type.
81
- *
82
- * @since 7.0.0
83
- *
84
- * @param boolean $value True if the type exists. False otherwise.
85
- * @param string $type_id The Type's ID.
86
- */
87
- $type_exists = apply_filters( "{$type_taxonomy}_check_existing_type", false, $type_id );
88
-
89
- if ( false !== $type_exists ) {
90
- return new WP_Error(
91
- 'type_already_exists',
92
- __( 'The Type already exists', 'buddypress' ),
93
- array(
94
- 'message' => 5,
95
- )
96
- );
97
- }
98
-
99
- // Get defaulte values for metadata.
100
- $metadata = bp_core_admin_get_type_default_meta_values( $type_taxonomy );
101
-
102
- // Validate metadata
103
- $metas = array_filter( array_intersect_key( $args, $metadata ) );
104
-
105
- // Insert the Type into the database.
106
- $type_term_id = bp_insert_term(
107
- $type_id,
108
- $type_taxonomy,
109
- array(
110
- 'slug' => $type_id,
111
- 'metas' => $metas,
112
- )
113
- );
114
-
115
- if ( is_wp_error( $type_term_id ) ) {
116
- $type_term_id->add_data(
117
- array(
118
- 'message' => 3,
119
- )
120
- );
121
-
122
- return $type_term_id;
123
- }
124
-
125
- /**
126
- * Hook here to add code once the type has been inserted.
127
- *
128
- * @since 7.0.0
129
- *
130
- * @param integer $type_term_id The Type's term_ID.
131
- * @param string $type_taxonomy The Type's taxonomy name.
132
- * @param string $type_id The Type's ID.
133
- */
134
- do_action( 'bp_type_inserted', $type_term_id, $type_taxonomy, $type_id );
135
-
136
- // Finally return the inserted Type's term ID.
137
- return $type_term_id;
138
- }
139
-
140
- /**
141
- * Update a type into the database.
142
- *
143
- * @since 7.0.0
144
- *
145
- * @param array $args {
146
- * Array of arguments describing the object type.
147
- *
148
- * @type string $taxonomy The Type's taxonomy. Required.
149
- * @type integer $type_term_id The Type's term ID. Required.
150
- * @see keys of the array returned by bp_get_type_metadata_schema() for the other arguments.
151
- * }
152
- * @return boolean|WP_Error True on success. A WP_Error object otherwise.
153
- */
154
- function bp_core_admin_update_type( $args = array() ) {
155
- $default_args = array(
156
- 'taxonomy' => '',
157
- 'type_term_id' => 0,
158
- );
159
-
160
- $args = array_map( 'wp_unslash', $args );
161
- $args = bp_parse_args(
162
- $args,
163
- $default_args,
164
- 'admin_update_type'
165
- );
166
-
167
- if ( ! $args['type_term_id'] || ! $args['taxonomy'] ) {
168
- return new WP_Error(
169
- 'invalid_type_taxonomy',
170
- __( 'The Term Type ID value is missing', 'buddypress' ),
171
- array(
172
- 'message' => 10,
173
- )
174
- );
175
- }
176
-
177
- $type_term_id = (int) $args['type_term_id'];
178
- $type_taxonomy = sanitize_key( $args['taxonomy'] );
179
-
180
- // Get defaulte values for metadata.
181
- $metadata = bp_core_admin_get_type_default_meta_values( $type_taxonomy );
182
-
183
- // Merge customs with defaults.
184
- $metas = wp_parse_args( $args, $metadata );
185
-
186
- // Validate metadata
187
- $metas = array_intersect_key( $metas, $metadata );
188
-
189
- foreach ( $metas as $meta_key => $meta_value ) {
190
- if ( '' === $meta_value ) {
191
- delete_term_meta( $type_term_id, $meta_key );
192
- } else {
193
- update_term_meta( $type_term_id, $meta_key, $meta_value );
194
- }
195
- }
196
-
197
- /**
198
- * Hook here to add code once the type has been updated.
199
- *
200
- * @since 7.0.0
201
- *
202
- * @param integer $type_term_id The Type's term_ID.
203
- * @param string $type_taxonomy The Type's taxonomy name.
204
- */
205
- do_action( 'bp_type_updated', $type_term_id, $type_taxonomy );
206
-
207
- // Finally informs about the successfull update.
208
- return true;
209
- }
210
-
211
- /**
212
- * Delete a type from the database.
213
- *
214
- * @since 7.0.0
215
- *
216
- * @param array $args {
217
- * Array of arguments describing the object type.
218
- *
219
- * @type string $taxonomy The Type's taxonomy. Required.
220
- * @type integer $type_term_id The Type's term ID. Required.
221
- * }
222
- * @return boolean|WP_Error True on success. A WP_Error object otherwise.
223
- */
224
- function bp_core_admin_delete_type( $args = array() ) {
225
- $default_args = array(
226
- 'taxonomy' => '',
227
- 'type_term_id' => 0,
228
- );
229
-
230
- $args = array_map( 'wp_unslash', $args );
231
- $args = bp_parse_args(
232
- $args,
233
- $default_args,
234
- 'admin_delete_type'
235
- );
236
-
237
- if ( ! $args['type_term_id'] || ! $args['taxonomy'] ) {
238
- return new WP_Error(
239
- 'invalid_type_taxonomy',
240
- __( 'The Term Type ID value is missing', 'buddypress' ),
241
- array(
242
- 'message' => 10,
243
- )
244
- );
245
- }
246
-
247
- $type_term_id = (int) $args['type_term_id'];
248
- $type_taxonomy = sanitize_key( $args['taxonomy'] );
249
- $type_term = bp_get_term_by( 'id', $type_term_id, $type_taxonomy );
250
-
251
- if ( ! $type_term ) {
252
- return new WP_Error(
253
- 'type_doesnotexist',
254
- __( 'The type was not deleted: it does not exist.', 'buddypress' ),
255
- array(
256
- 'message' => 6,
257
- )
258
- );
259
- }
260
-
261
- /** This filter is documented in bp-core/classes/class-bp-admin-types.php */
262
- $registered_by_code_types = apply_filters( "{$type_taxonomy}_registered_by_code", array() );
263
-
264
- if ( isset( $registered_by_code_types[ $type_term->name ] ) ) {
265
- return new WP_Error(
266
- 'type_register_by_code',
267
- __( 'This type is registered using code, deactivate the plugin or remove the custom code before trying to delete it again.', 'buddypress' ),
268
- array(
269
- 'message' => 7,
270
- )
271
- );
272
- }
273
-
274
- $deleted = bp_delete_term( $type_term_id, $type_taxonomy );
275
-
276
- if ( true !== $deleted ) {
277
- return new WP_Error(
278
- 'type_not_deleted',
279
- __( 'There was an error while trying to delete this type.', 'buddypress' ),
280
- array(
281
- 'message' => 8,
282
- )
283
- );
284
- }
285
-
286
- /**
287
- * Hook here to add code once the type has been deleted.
288
- *
289
- * @since 7.0.0
290
- *
291
- * @param integer $type_term_id The Type's term_ID.
292
- * @param string $type_taxonomy The Type's taxonomy name.
293
- */
294
- do_action( 'bp_type_deleted', $type_term_id, $type_taxonomy );
295
-
296
- // Finally informs about the successfull delete.
297
- return true;
298
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/admin/css/common-rtl.css CHANGED
@@ -10,18 +10,17 @@ TABLE OF CONTENTS:
10
  --------------------------------------------------------------------------------
11
  1.0 Welcome Screen
12
  1.1 Version Badge
13
- 1.2 ---
14
- 1.3 Credits Panel
 
 
15
  2.0 Dashicons
16
  2.1 Top level menus
17
  2.2 Settings - Components
18
  2.3 Tools
19
- 2.4 Tooltips
20
- 3.0 Users
21
- 3.1 Users List
22
- 3.2 Site Notices
23
  4.0 Emails - Edit page
24
- 5.0 Block Editor
25
  6.0 Plugins page
26
  ------------------------------------------------------------------------------*/
27
 
@@ -42,132 +41,398 @@ TABLE OF CONTENTS:
42
  content: "\f448";
43
  }
44
 
45
- .settings_page_bp-credits code,
 
 
 
 
 
 
46
  .index_page_bp-about code {
47
  background-color: #e0e0e0;
48
  color: #636363;
49
  font-size: 1em;
50
  }
51
 
 
 
 
 
 
 
 
 
 
 
52
  /*
53
- * 1.3 Credits Panel
54
- *
55
- * Taken from WP 4.9.5.
56
  */
57
- .bp-about-wrap {
58
- position: relative;
59
- max-width: 1050px;
60
- font-size: 15px;
 
 
 
 
61
  }
62
 
63
- .bp-about-wrap img {
64
- margin: 0;
65
- max-width: 100%;
66
- height: auto;
67
- vertical-align: middle;
68
  }
69
 
70
- .bp-about-wrap p {
71
- line-height: 1.5;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  font-size: 14px;
 
 
 
 
 
73
  }
74
 
75
- .bp-about-wrap h2 {
76
- margin: 40px 0 0.6em;
77
- font-size: 2.7em;
78
- line-height: 1.3;
 
 
 
 
 
 
 
 
 
 
 
 
79
  font-weight: 300;
 
 
80
  text-align: center;
81
  }
82
 
83
- .bp-about-wrap h3 {
84
- margin: 1.25em 0 0.6em;
85
- font-size: 1.4em;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  line-height: 1.5;
87
  }
88
 
89
- .bp-about-wrap code {
90
- font-size: 14px;
91
- font-weight: 400;
 
92
  }
93
 
94
- .bp-about-wrap .about-description {
95
- margin-top: 1.4em;
96
- font-weight: 400;
97
- line-height: 1.6;
98
- font-size: 19px;
99
  }
100
 
101
- .bp-about-wrap h3.wp-people-group {
102
- margin: 2.6em 0 1.33em;
103
- padding: 0;
104
- font-size: 16px;
105
- line-height: inherit;
106
  }
107
 
108
- .bp-about-wrap .wp-people-group {
109
- padding: 0 5px;
110
- margin: 0 -5px 0 -15px;
111
  }
112
 
113
- .bp-about-wrap .compact {
 
 
114
  margin-bottom: 0;
 
 
 
115
  }
116
 
117
- .bp-about-wrap .wp-person {
118
- display: inline-block;
119
- vertical-align: top;
120
- margin-left: 10px;
121
- padding-bottom: 15px;
122
- height: 70px;
123
- width: 280px;
124
  }
125
 
126
- .bp-about-wrap .compact .wp-person {
127
- height: auto;
128
- width: 180px;
 
 
 
 
129
  padding-bottom: 0;
130
- margin-bottom: 0;
131
  }
132
 
133
- .bp-about-wrap .wp-person .gravatar {
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  float: right;
135
- margin: 0 0 10px 10px;
136
- padding: 1px;
137
- width: 60px;
138
- height: 60px;
139
  }
140
 
141
- .bp-about-wrap .compact .wp-person .gravatar {
142
- width: 30px;
143
- height: 30px;
 
 
144
  }
145
 
146
- .bp-about-wrap .wp-person .web {
147
- margin: 6px 0 2px;
148
- font-size: 16px;
149
- font-weight: 400;
150
- line-height: 2;
151
- text-decoration: none;
152
  }
153
 
154
- .bp-about-wrap .wp-person .title {
155
- display: block;
156
  }
157
 
158
- .bp-about-wrap p.wp-credits-list a {
159
- white-space: nowrap;
 
 
160
  }
161
 
162
- @media only screen and (max-width: 500px) {
 
 
 
 
163
 
164
- .bp-about-wrap {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  margin-left: 20px;
166
- margin-right: 10px;
167
  }
168
 
169
- .bp-about-wrap .bp-about-wrap h1 {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  margin-left: 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  }
172
  }
173
 
@@ -258,6 +523,10 @@ TABLE OF CONTENTS:
258
  content: "\f457";
259
  }
260
 
 
 
 
 
261
  .settings_page_bp-components tr.blogs td.plugin-title span:before {
262
  content: "\f120";
263
  }
@@ -274,11 +543,6 @@ TABLE OF CONTENTS:
274
  content: "\f307";
275
  }
276
 
277
- .settings_page_bp-page-settings .button-secondary .dashicons {
278
- position: relative;
279
- top: 3px;
280
- }
281
-
282
  #bp-admin-component-form .wp-list-table.plugins .plugin-title {
283
  width: 25%;
284
  }
@@ -307,92 +571,10 @@ TABLE OF CONTENTS:
307
  content: "";
308
  }
309
 
310
- body.tools-php .bp-tools dt {
311
- font-size: 1.1em;
312
- color: #646970;
313
- font-weight: 600;
314
- margin: 1em 0 0.5em 0;
315
- }
316
-
317
- body.tools-php .bp-tools dd {
318
- margin: 0;
319
- }
320
-
321
- body.tools_page_bp-members-invitations .nav-tab-wrapper,
322
- body.tools_page_bp-optouts .nav-tab-wrapper {
323
- margin-bottom: 1em;
324
- }
325
-
326
- /*
327
- * 2.4 Tooltips
328
- */
329
- .bp-tooltip {
330
- position: relative;
331
- }
332
-
333
- .bp-tooltip:after {
334
- background: #fff;
335
- border: 1px solid #aaa;
336
- border-collapse: separate;
337
- border-radius: 1px;
338
- box-shadow: -1px 1px 0 1px rgba(132, 132, 132, 0.3);
339
- color: #000;
340
- content: attr(data-bp-tooltip);
341
- display: none;
342
- font-family: sans-serif;
343
- font-size: 11px;
344
- font-weight: 400;
345
- letter-spacing: normal;
346
- line-height: 1.5;
347
- margin-top: 10px;
348
- max-width: 240px;
349
- opacity: 0;
350
- padding: 3px 6px;
351
- position: absolute;
352
- left: 50%;
353
- text-align: center;
354
- text-decoration: none;
355
- text-shadow: none;
356
- text-transform: none;
357
- top: 100%;
358
- transform: translateX(-50%);
359
- transition: opacity 2s ease-out;
360
- white-space: pre;
361
- word-wrap: break-word;
362
- z-index: 998;
363
- }
364
-
365
- .bp-hello-close .bp-tooltip:after {
366
- left: 0;
367
- text-align: left;
368
- transform: translateX(0);
369
- }
370
-
371
- .bp-hello-social .bp-tooltip:after {
372
- bottom: 120%;
373
- margin-bottom: 20px;
374
- margin-top: 0;
375
- top: auto;
376
- transform: translateX(-15%);
377
- }
378
-
379
- .bp-tooltip:hover:after,
380
- .bp-tooltip:active:after,
381
- .bp-tooltip:focus:after {
382
- display: inline-block;
383
- opacity: 1;
384
- overflow: visible;
385
- text-decoration: none;
386
- z-index: 999;
387
- }
388
 
389
  /*------------------------------------------------------------------------------
390
- * 3.0 Users
391
  *----------------------------------------------------------------------------*/
392
-
393
- /*
394
- * 3.1 Users List
395
- */
396
  body.site-users-php th#role,
397
  body.users-php th#role,
398
  body.users_page_bp-signups th#count_sent {
@@ -429,121 +611,75 @@ body.users_page_bp-signups td.count_sent {
429
  font-weight: 700;
430
  }
431
 
432
- /*
433
- * 3.2 Site Notices
434
- */
435
- .bp-new-notice-panel {
436
- background: #fff;
437
- border: 1px solid #e5e5e5;
438
- box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
439
- font-size: 13px;
440
- line-height: 2.1;
441
- margin: 1.5em 0 3em;
442
- overflow: auto;
443
- padding: 10px 25px 25px;
444
- position: relative;
445
  }
446
 
447
- .bp-new-notice-panel label {
448
- clear: both;
449
- float: right;
450
- margin-left: 3%;
451
  width: 20%;
452
  }
453
 
454
- .bp-new-notice-panel input,
455
- .bp-new-notice-panel textarea {
456
- clear: none;
457
- margin-bottom: 1em;
458
- width: 75%;
459
  }
460
 
461
- .bp-new-notice-panel input[type="text"]:after,
462
- .bp-new-notice-panel textarea:after {
463
- clear: both;
464
- content: " ";
465
- display: table;
466
  }
467
 
468
- .bp-new-notice-panel .button-primary {
469
- margin-right: 23%;
470
- width: auto;
 
 
471
  }
472
 
473
- .bp-notice-about {
474
- font-size: 1em;
475
- margin-bottom: 1em;
476
  }
477
 
478
- .bp-new-notice {
479
- margin-bottom: 1em;
480
- margin-top: 0;
481
  }
482
 
483
- .bp-notices-list {
484
- margin-bottom: 0;
 
 
 
485
  }
486
 
487
- @media screen and (max-width: 782px) {
488
-
489
- .bp-new-notice-panel {
490
- margin-bottom: 1.5em;
491
- }
492
-
493
- .bp-new-notice-panel input,
494
- .bp-new-notice-panel textarea {
495
- margin-right: 0;
496
- width: 100%;
497
- }
498
 
499
- .bp-new-notice-panel .button-primary {
500
- margin-right: 0;
501
- width: auto;
502
- }
503
 
504
- .bp-new-notice-panel .button {
505
- max-width: 45%;
506
- word-wrap: break-word;
507
  }
508
 
509
- .bp-notice-about {
510
- margin-top: 0;
511
  margin-bottom: 1em;
 
 
512
  }
513
 
514
- .bp-new-notice {
515
- margin-bottom: 0.5em;
516
  }
517
  }
518
 
519
- /*------------------------------------------------------------------------------
520
- * 4.0 Emails - Edit Page
521
- *----------------------------------------------------------------------------*/
522
- body.post-type-bp-email #excerpt {
523
- height: auto;
524
- }
525
-
526
- body.post-type-bp-email th#situation {
527
- width: 20%;
528
- }
529
-
530
- body.post-type-bp-email td.column-situation ul {
531
- margin: 0;
532
- }
533
-
534
- body.post-type-bp-email .categorydiv label {
535
- display: block;
536
- float: right;
537
- padding-right: 25px;
538
- text-indent: -25px;
539
- }
540
-
541
- /*------------------------------------------------------------------------------
542
- * 5.0 Block Editor
543
- *----------------------------------------------------------------------------*/
544
- .block-editor-inserter__panel-header span.dashicons-buddicons-buddypress-logo {
545
- color: #d84800;
546
- }
547
 
548
  /*------------------------------------------------------------------------------
549
  * 6.0 Plugins page
10
  --------------------------------------------------------------------------------
11
  1.0 Welcome Screen
12
  1.1 Version Badge
13
+ 1.2 About Panel
14
+ 1.2.1 Headline Feature
15
+ 1.2.2 Features Section
16
+ 1.2.3 Changelog Section
17
  2.0 Dashicons
18
  2.1 Top level menus
19
  2.2 Settings - Components
20
  2.3 Tools
21
+ 3.0 User's Lists
 
 
 
22
  4.0 Emails - Edit page
23
+ 5.0 Tools - BuddyPress
24
  6.0 Plugins page
25
  ------------------------------------------------------------------------------*/
26
 
41
  content: "\f448";
42
  }
43
 
44
+ .about-wrap .bp-badge {
45
+ position: absolute;
46
+ top: 0;
47
+ left: 0;
48
+ }
49
+
50
+ .index_page_bp-credits code,
51
  .index_page_bp-about code {
52
  background-color: #e0e0e0;
53
  color: #636363;
54
  font-size: 1em;
55
  }
56
 
57
+ @media only screen and (max-width: 500px) {
58
+
59
+ .about-wrap .bp-badge {
60
+ position: relative;
61
+ margin: 10px auto;
62
+ top: auto;
63
+ left: auto;
64
+ }
65
+ }
66
+
67
  /*
68
+ * 1.2 About Panel
 
 
69
  */
70
+
71
+ /*
72
+ * 1.2.1 Headline Feature
73
+ */
74
+ .buddypress .bp-headline-feature {
75
+ margin-bottom: 2em;
76
+ margin-top: 3em;
77
+ padding: 2em 3em;
78
  }
79
 
80
+ .buddypress .bp-headline {
81
+ margin: 0 auto;
82
+ width: 45em;
 
 
83
  }
84
 
85
+ .buddypress .bp-headline span.dashicons {
86
+ background-color: #f1f1f1;
87
+ color: #d84800;
88
+ clear: right;
89
+ font-size: 100px;
90
+ float: right;
91
+ height: 100px;
92
+ line-height: 100px;
93
+ margin: 0 0 15px 15px;
94
+ text-align: center;
95
+ width: 100px;
96
+ }
97
+
98
+ .buddypress .bp-headline-feature .headline-title {
99
+ font-size: 2.2em;
100
+ font-weight: 300;
101
+ line-height: 2;
102
+ margin: 0 0 1em;
103
+ text-align: center;
104
+ }
105
+
106
+ .buddypress .bp-headline-feature p {
107
+ font-size: 1.15em;
108
+ margin: 1.15em 0 0.6em auto;
109
+ }
110
+
111
+ /*
112
+ * 1.2.2 Features Section
113
+ */
114
+ .buddypress .bp-features-section {
115
+ border-bottom: 1px solid #ccc;
116
+ clear: both;
117
+ margin-bottom: 3em;
118
+ margin-top: 2em;
119
+ overflow: hidden;
120
+ padding-bottom: 2em;
121
+ }
122
+
123
+ .buddypress .bp-features-section p {
124
  font-size: 14px;
125
+ line-height: 1.5;
126
+ }
127
+
128
+ .buddypress .bp-features-section img {
129
+ margin-bottom: 20px;
130
  }
131
 
132
+ .buddypress .bp-features-section span.dashicons {
133
+ background-color: #fff;
134
+ border-radius: 50%;
135
+ clear: right;
136
+ color: #d84800;
137
+ font-size: 50px;
138
+ float: right;
139
+ height: 80px;
140
+ line-height: 80px;
141
+ margin: 0 0 15px 15px;
142
+ text-align: center;
143
+ width: 80px;
144
+ }
145
+
146
+ .buddypress .bp-features-section .headline-title {
147
+ font-size: 2em;
148
  font-weight: 300;
149
+ line-height: 1.5;
150
+ margin: 1em auto 2em;
151
  text-align: center;
152
  }
153
 
154
+ .buddypress .bp-features-section .bp-feature-with-images {
155
+ border-bottom: 1px solid #ccc;
156
+ margin-bottom: 5em;
157
+ padding-bottom: 2em;
158
+ }
159
+
160
+ .buddypress .bp-features-section .bp-feature,
161
+ .buddypress .bp-features-section .bp-feature-imaged {
162
+ float: right;
163
+ margin-bottom: 3em;
164
+ margin-left: 4.799999999%;
165
+ width: 47.6%;
166
+ }
167
+
168
+ .buddypress .bp-features-section .bp-feature.opposite,
169
+ .buddypress .bp-features-section .bp-feature-imaged.anon {
170
+ margin-left: 0;
171
+ }
172
+
173
+ .buddypress .bp-features-section .bp-feature code {
174
+ font-size: 0.95em;
175
  line-height: 1.5;
176
  }
177
 
178
+ .buddypress .bp-feature:after {
179
+ clear: both;
180
+ content: "";
181
+ margin-bottom: 2em;
182
  }
183
 
184
+ .buddypress .bp-feature-imaged .feature-title {
185
+ color: #23282d;
186
+ font-size: 1.25em;
187
+ margin-bottom: 0.6em;
188
+ margin-top: 0;
189
  }
190
 
191
+ .buddypress .bp-feature-imaged p {
192
+ clear: right;
193
+ font-size: 1.1em;
 
 
194
  }
195
 
196
+ .buddypress .bp-feature-imaged img {
197
+ clear: right;
 
198
  }
199
 
200
+ .buddypress .bp-feature .feature-title {
201
+ font-size: 1em;
202
+ line-height: 1.5;
203
  margin-bottom: 0;
204
+ margin-right: 110px;
205
+ margin-top: 0;
206
+ text-align: right;
207
  }
208
 
209
+ .buddypress .bp-feature p {
210
+ margin-right: 110px;
 
 
 
 
 
211
  }
212
 
213
+ /*
214
+ * 1.2.3 Changelog Section
215
+ */
216
+ .buddypress .bp-changelog-section {
217
+ clear: both;
218
+ margin-bottom: 3em;
219
+ margin-top: 4em;
220
  padding-bottom: 0;
 
221
  }
222
 
223
+ .buddypress .bp-changelog-section:after {
224
+ clear: both;
225
+ content: "";
226
+ display: table;
227
+ }
228
+
229
+ .buddypress .bp-changelog-section .changelog-title {
230
+ color: #23282d;
231
+ font-size: 1.25em;
232
+ line-height: 1.5;
233
+ margin: 0 auto 1.5em;
234
+ }
235
+
236
+ .buddypress .bp-two-column div {
237
  float: right;
238
+ margin-left: 4.799999999%;
239
+ position: relative;
240
+ width: 47.6%;
 
241
  }
242
 
243
+ .buddypress .bp-three-column .bp-column {
244
+ float: right;
245
+ margin-left: 5%;
246
+ position: relative;
247
+ width: 29.95%;
248
  }
249
 
250
+ .buddypress .bp-two-column .bp-column:nth-of-type(2n),
251
+ .buddypress .bp-three-column .bp-column:nth-of-type(3n) {
252
+ margin-left: 0;
 
 
 
253
  }
254
 
255
+ .buddypress .bp-changelog {
256
+ margin-bottom: 3em;
257
  }
258
 
259
+ .buddypress .bp-changelog:after {
260
+ clear: both;
261
+ content: "";
262
+ display: table;
263
  }
264
 
265
+ .buddypress .bp-changelog .title {
266
+ font-size: 14px;
267
+ margin-bottom: 0.75em;
268
+ margin-top: 0;
269
+ }
270
 
271
+ .buddypress .bp-changelog p {
272
+ margin-bottom: 0;
273
+ }
274
+
275
+ .bp-changelog-url {
276
+ text-align: center;
277
+ }
278
+
279
+ .bp-assets {
280
+ clear: both;
281
+ margin-bottom: 3em;
282
+ }
283
+
284
+ @media screen and ( max-width: 782px ) {
285
+
286
+ .bp-headline-feature,
287
+ .bp-features-section,
288
+ .bp-changelog-section,
289
+ .bp-assets {
290
+ margin-right: 20px;
291
  margin-left: 20px;
 
292
  }
293
 
294
+ .buddypress .bp-headline-feature {
295
+ padding: 0;
296
+ }
297
+
298
+ .buddypress .bp-headline {
299
+ margin: 0;
300
+ width: 97%;
301
+ }
302
+
303
+ .buddypress .bp-features-section {
304
+ clear: both;
305
+ margin-bottom: 0;
306
+ margin-top: 2em;
307
+ padding-bottom: 2em;
308
+ }
309
+
310
+ .buddypress .bp-features-section .bp-feature-with-images {
311
+ margin-bottom: 2em;
312
+ }
313
+
314
+ .buddypress .bp-features-section .headline-title {
315
+ margin-bottom: 1em;
316
+ }
317
+
318
+ .buddypress .bp-changelog-section .changelog-title {
319
+ font-size: 1.25em;
320
+ line-height: 1.5;
321
+ margin-bottom: 0.5em;
322
+ margin-top: 0.5em;
323
+ }
324
+
325
+ .buddypress .bp-features-section .feature-title,
326
+ .buddypress .bp-changelog-section .title {
327
+ font-size: 1.25em;
328
+ line-height: 1.25;
329
+ margin-top: 0.6em;
330
+ text-align: right;
331
+ }
332
+
333
+ .buddypress .bp-features-section .bp-feature,
334
+ .buddypress .bp-features-section .bp-feature-imaged {
335
+ clear: both;
336
+ float: right;
337
+ margin-bottom: 1em;
338
+ margin-top: 1em;
339
  margin-left: 0;
340
+ padding-left: 1em;
341
+ width: 100%;
342
+ }
343
+
344
+ .buddypress .bp-features-section .bp-feature-imaged p {
345
+ font-size: 1em;
346
+ }
347
+
348
+ .buddypress .bp-features-section .bp-feature span {
349
+ margin-top: 0.33em;
350
+ }
351
+
352
+ .buddypress .bp-feature.opposite .feature-title,
353
+ .buddypress .bp-feature.opposite p {
354
+ float: none;
355
+ }
356
+
357
+ .buddypress .bp-changelog-section {
358
+ clear: both;
359
+ margin-bottom: 2em;
360
+ margin-top: 2em;
361
+ }
362
+
363
+ .buddypress .bp-changelog {
364
+ margin-bottom: 0;
365
+ }
366
+
367
+ .buddypress .bp-changelog-section .changelog-title {
368
+ margin-bottom: 0.5em;
369
+ }
370
+
371
+ .buddypress .bp-changelog .title {
372
+ font-size: 1em;
373
+ }
374
+
375
+ .buddypress .bp-changelog p {
376
+ margin-bottom: 1em;
377
+ }
378
+
379
+ .buddypress .bp-changelog-section .two-col > div,
380
+ .buddypress .bp-changelog-section .three-col .col {
381
+ margin-top: 0;
382
+ padding-bottom: 0.5em;
383
+ width: 100%;
384
+ }
385
+
386
+ .buddypress .bp-three-column .bp-column {
387
+ width: 100%;
388
+ }
389
+ }
390
+
391
+ @media screen and ( max-width: 360px ) {
392
+
393
+ .buddypress .bp-headline {
394
+ text-align: center;
395
+ }
396
+
397
+ .buddypress .bp-headline span.dashicons {
398
+ clear: none;
399
+ font-size: 80px;
400
+ float: none;
401
+ height: 80px;
402
+ line-height: 80px;
403
+ margin: 0 auto;
404
+ width: 80px;
405
+ }
406
+
407
+ .buddypress .bp-headline-feature .headline-title,
408
+ .buddypress .bp-features-section .headline-title {
409
+ font-size: 1.5em;
410
+ line-height: 1.5;
411
+ text-align: right;
412
+ }
413
+
414
+ .buddypress .bp-headline-feature .headline-title {
415
+ margin: 1em 0 0;
416
+ }
417
+
418
+ .buddypress .bp-headline-feature p {
419
+ margin: 1.15em 0 0.6em auto;
420
+ text-align: right;
421
+ width: auto;
422
+ }
423
+
424
+ .buddypress .bp-features-section .bp-feature {
425
+ text-align: center;
426
+ }
427
+
428
+ .buddypress .bp-features-section span.dashicons {
429
+ float: none;
430
+ }
431
+
432
+ .buddypress .bp-features-section .feature-title,
433
+ .buddypress .bp-features-section p {
434
+ margin-right: 0;
435
+ text-align: right;
436
  }
437
  }
438
 
523
  content: "\f457";
524
  }
525
 
526
+ .settings_page_bp-components tr.forums td.plugin-title span:before {
527
+ content: "\f452";
528
+ }
529
+
530
  .settings_page_bp-components tr.blogs td.plugin-title span:before {
531
  content: "\f120";
532
  }
543
  content: "\f307";
544
  }
545
 
 
 
 
 
 
546
  #bp-admin-component-form .wp-list-table.plugins .plugin-title {
547
  width: 25%;
548
  }
571
  content: "";
572
  }
573
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
574
 
575
  /*------------------------------------------------------------------------------
576
+ * 3.0 User's Lists
577
  *----------------------------------------------------------------------------*/
 
 
 
 
578
  body.site-users-php th#role,
579
  body.users-php th#role,
580
  body.users_page_bp-signups th#count_sent {
611
  font-weight: 700;
612
  }
613
 
614
+ /*------------------------------------------------------------------------------
615
+ * 4.0 Emails - Edit Page
616
+ *----------------------------------------------------------------------------*/
617
+ body.post-type-bp-email #excerpt {
618
+ height: auto;
 
 
 
 
 
 
 
 
619
  }
620
 
621
+ body.post-type-bp-email th#situation {
 
 
 
622
  width: 20%;
623
  }
624
 
625
+ body.post-type-bp-email td.column-situation ul {
626
+ margin: 0;
 
 
 
627
  }
628
 
629
+ body.post-type-bp-email .categorydiv label {
630
+ display: block;
631
+ float: right;
632
+ padding-right: 25px;
633
+ text-indent: -25px;
634
  }
635
 
636
+ /*------------------------------------------------------------------------------
637
+ * 5.0 Tools - BuddyPress
638
+ *----------------------------------------------------------------------------*/
639
+ .tools_page_bp-tools .wrap {
640
+ max-width: 950px;
641
  }
642
 
643
+ .tools_page_bp-tools p {
644
+ line-height: 2;
 
645
  }
646
 
647
+ .tools_page_bp-tools fieldset {
648
+ margin: 2em 0 0;
 
649
  }
650
 
651
+ .tools_page_bp-tools legend {
652
+ color: #23282d;
653
+ font-size: 1.3em;
654
+ font-weight: 600;
655
+ margin: 1em 0;
656
  }
657
 
658
+ .tools_page_bp-tools label {
659
+ clear: right;
660
+ display: block;
661
+ line-height: 1.5;
662
+ margin: 0 0 1em;
663
+ vertical-align: middle;
664
+ }
 
 
 
 
665
 
666
+ @media screen and (max-width: 782px) {
 
 
 
667
 
668
+ .tools_page_bp-tools p {
669
+ line-height: 1.5;
 
670
  }
671
 
672
+ .tools_page_bp-tools label {
 
673
  margin-bottom: 1em;
674
+ padding-left: 25px;
675
+ text-indent: -33px;
676
  }
677
 
678
+ .tools_page_bp-tools .checkbox {
679
+ padding: 0 30px 0 0;
680
  }
681
  }
682
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
683
 
684
  /*------------------------------------------------------------------------------
685
  * 6.0 Plugins page
bp-core/admin/css/common-rtl.min.css CHANGED
@@ -1 +1 @@
1
- .bp-badge{color:#d84800;display:inline-block;font:400 150px/1 dashicons!important}.bp-badge:before{content:"\f448"}.index_page_bp-about code,.settings_page_bp-credits code{background-color:#e0e0e0;color:#636363;font-size:1em}.bp-about-wrap{position:relative;max-width:1050px;font-size:15px}.bp-about-wrap img{margin:0;max-width:100%;height:auto;vertical-align:middle}.bp-about-wrap p{line-height:1.5;font-size:14px}.bp-about-wrap h2{margin:40px 0 .6em;font-size:2.7em;line-height:1.3;font-weight:300;text-align:center}.bp-about-wrap h3{margin:1.25em 0 .6em;font-size:1.4em;line-height:1.5}.bp-about-wrap code{font-size:14px;font-weight:400}.bp-about-wrap .about-description{margin-top:1.4em;font-weight:400;line-height:1.6;font-size:19px}.bp-about-wrap h3.wp-people-group{margin:2.6em 0 1.33em;padding:0;font-size:16px;line-height:inherit}.bp-about-wrap .wp-people-group{padding:0 5px;margin:0 -5px 0 -15px}.bp-about-wrap .compact{margin-bottom:0}.bp-about-wrap .wp-person{display:inline-block;vertical-align:top;margin-left:10px;padding-bottom:15px;height:70px;width:280px}.bp-about-wrap .compact .wp-person{height:auto;width:180px;padding-bottom:0;margin-bottom:0}.bp-about-wrap .wp-person .gravatar{float:right;margin:0 0 10px 10px;padding:1px;width:60px;height:60px}.bp-about-wrap .compact .wp-person .gravatar{width:30px;height:30px}.bp-about-wrap .wp-person .web{margin:6px 0 2px;font-size:16px;font-weight:400;line-height:2;text-decoration:none}.bp-about-wrap .wp-person .title{display:block}.bp-about-wrap p.wp-credits-list a{white-space:nowrap}@media only screen and (max-width:500px){.bp-about-wrap{margin-left:20px;margin-right:10px}.bp-about-wrap .bp-about-wrap h1{margin-left:0}}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}.settings_page_bp-components td.plugin-title span{float:right;width:18px;height:18px;margin-left:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}.settings_page_bp-components tr.core td.plugin-title span:before{content:"\f448"}.settings_page_bp-components tr.members td.plugin-title span:before{content:"\f307"}.settings_page_bp-page-settings .button-secondary .dashicons{position:relative;top:3px}#bp-admin-component-form .wp-list-table.plugins .plugin-title{width:25%}@media screen and (max-width:782px){.settings_page_bp-components td.plugin-title span{margin-top:5px}#bp-admin-component-form .wp-list-table.plugins .plugin-title{display:block;width:auto}#bp-admin-component-form .subsubsub{margin-bottom:0;padding-bottom:35px}}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}body.tools-php .bp-tools dt{font-size:1.1em;color:#646970;font-weight:600;margin:1em 0 .5em 0}body.tools-php .bp-tools dd{margin:0}body.tools_page_bp-members-invitations .nav-tab-wrapper,body.tools_page_bp-optouts .nav-tab-wrapper{margin-bottom:1em}.bp-tooltip{position:relative}.bp-tooltip:after{background:#fff;border:1px solid #aaa;border-collapse:separate;border-radius:1px;box-shadow:-1px 1px 0 1px rgba(132,132,132,.3);color:#000;content:attr(data-bp-tooltip);display:none;font-family:sans-serif;font-size:11px;font-weight:400;letter-spacing:normal;line-height:1.5;margin-top:10px;max-width:240px;opacity:0;padding:3px 6px;position:absolute;left:50%;text-align:center;text-decoration:none;text-shadow:none;text-transform:none;top:100%;transform:translateX(-50%);transition:opacity 2s ease-out;white-space:pre;word-wrap:break-word;z-index:998}.bp-hello-close .bp-tooltip:after{left:0;text-align:left;transform:translateX(0)}.bp-hello-social .bp-tooltip:after{bottom:120%;margin-bottom:20px;margin-top:0;top:auto;transform:translateX(-15%)}.bp-tooltip:active:after,.bp-tooltip:focus:after,.bp-tooltip:hover:after{display:inline-block;opacity:1;overflow:visible;text-decoration:none;z-index:999}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}.bp-signups-list table{margin:1em 0}.bp-signups-list .column-fields{font-weight:700}.bp-new-notice-panel{background:#fff;border:1px solid #e5e5e5;box-shadow:0 1px 1px rgba(0,0,0,.04);font-size:13px;line-height:2.1;margin:1.5em 0 3em;overflow:auto;padding:10px 25px 25px;position:relative}.bp-new-notice-panel label{clear:both;float:right;margin-left:3%;width:20%}.bp-new-notice-panel input,.bp-new-notice-panel textarea{clear:none;margin-bottom:1em;width:75%}.bp-new-notice-panel input[type=text]:after,.bp-new-notice-panel textarea:after{clear:both;content:" ";display:table}.bp-new-notice-panel .button-primary{margin-right:23%;width:auto}.bp-notice-about{font-size:1em;margin-bottom:1em}.bp-new-notice{margin-bottom:1em;margin-top:0}.bp-notices-list{margin-bottom:0}@media screen and (max-width:782px){.bp-new-notice-panel{margin-bottom:1.5em}.bp-new-notice-panel input,.bp-new-notice-panel textarea{margin-right:0;width:100%}.bp-new-notice-panel .button-primary{margin-right:0;width:auto}.bp-new-notice-panel .button{max-width:45%;word-wrap:break-word}.bp-notice-about{margin-top:0;margin-bottom:1em}.bp-new-notice{margin-bottom:.5em}}body.post-type-bp-email #excerpt{height:auto}body.post-type-bp-email th#situation{width:20%}body.post-type-bp-email td.column-situation ul{margin:0}body.post-type-bp-email .categorydiv label{display:block;float:right;padding-right:25px;text-indent:-25px}.block-editor-inserter__panel-header span.dashicons-buddicons-buddypress-logo{color:#d84800}#buddypress-update.not-shiny .update-message{border-right:0;padding-right:36px}#buddypress-update.not-shiny .update-message:before{content:"\f534"}
1
+ .bp-badge{color:#d84800;display:inline-block;font:400 150px/1 dashicons!important}.bp-badge:before{content:"\f448"}.about-wrap .bp-badge{position:absolute;top:0;left:0}.index_page_bp-about code,.index_page_bp-credits code{background-color:#e0e0e0;color:#636363;font-size:1em}@media only screen and (max-width:500px){.about-wrap .bp-badge{position:relative;margin:10px auto;top:auto;left:auto}}.buddypress .bp-headline-feature{margin-bottom:2em;margin-top:3em;padding:2em 3em}.buddypress .bp-headline{margin:0 auto;width:45em}.buddypress .bp-headline span.dashicons{background-color:#f1f1f1;color:#d84800;clear:right;font-size:100px;float:right;height:100px;line-height:100px;margin:0 0 15px 15px;text-align:center;width:100px}.buddypress .bp-headline-feature .headline-title{font-size:2.2em;font-weight:300;line-height:2;margin:0 0 1em;text-align:center}.buddypress .bp-headline-feature p{font-size:1.15em;margin:1.15em 0 .6em auto}.buddypress .bp-features-section{border-bottom:1px solid #ccc;clear:both;margin-bottom:3em;margin-top:2em;overflow:hidden;padding-bottom:2em}.buddypress .bp-features-section p{font-size:14px;line-height:1.5}.buddypress .bp-features-section img{margin-bottom:20px}.buddypress .bp-features-section span.dashicons{background-color:#fff;border-radius:50%;clear:right;color:#d84800;font-size:50px;float:right;height:80px;line-height:80px;margin:0 0 15px 15px;text-align:center;width:80px}.buddypress .bp-features-section .headline-title{font-size:2em;font-weight:300;line-height:1.5;margin:1em auto 2em;text-align:center}.buddypress .bp-features-section .bp-feature-with-images{border-bottom:1px solid #ccc;margin-bottom:5em;padding-bottom:2em}.buddypress .bp-features-section .bp-feature,.buddypress .bp-features-section .bp-feature-imaged{float:right;margin-bottom:3em;margin-left:4.799999999%;width:47.6%}.buddypress .bp-features-section .bp-feature-imaged.anon,.buddypress .bp-features-section .bp-feature.opposite{margin-left:0}.buddypress .bp-features-section .bp-feature code{font-size:.95em;line-height:1.5}.buddypress .bp-feature:after{clear:both;content:"";margin-bottom:2em}.buddypress .bp-feature-imaged .feature-title{color:#23282d;font-size:1.25em;margin-bottom:.6em;margin-top:0}.buddypress .bp-feature-imaged p{clear:right;font-size:1.1em}.buddypress .bp-feature-imaged img{clear:right}.buddypress .bp-feature .feature-title{font-size:1em;line-height:1.5;margin-bottom:0;margin-right:110px;margin-top:0;text-align:right}.buddypress .bp-feature p{margin-right:110px}.buddypress .bp-changelog-section{clear:both;margin-bottom:3em;margin-top:4em;padding-bottom:0}.buddypress .bp-changelog-section:after{clear:both;content:"";display:table}.buddypress .bp-changelog-section .changelog-title{color:#23282d;font-size:1.25em;line-height:1.5;margin:0 auto 1.5em}.buddypress .bp-two-column div{float:right;margin-left:4.799999999%;position:relative;width:47.6%}.buddypress .bp-three-column .bp-column{float:right;margin-left:5%;position:relative;width:29.95%}.buddypress .bp-three-column .bp-column:nth-of-type(3n),.buddypress .bp-two-column .bp-column:nth-of-type(2n){margin-left:0}.buddypress .bp-changelog{margin-bottom:3em}.buddypress .bp-changelog:after{clear:both;content:"";display:table}.buddypress .bp-changelog .title{font-size:14px;margin-bottom:.75em;margin-top:0}.buddypress .bp-changelog p{margin-bottom:0}.bp-changelog-url{text-align:center}.bp-assets{clear:both;margin-bottom:3em}@media screen and (max-width:782px){.bp-assets,.bp-changelog-section,.bp-features-section,.bp-headline-feature{margin-right:20px;margin-left:20px}.buddypress .bp-headline-feature{padding:0}.buddypress .bp-headline{margin:0;width:97%}.buddypress .bp-features-section{clear:both;margin-bottom:0;margin-top:2em;padding-bottom:2em}.buddypress .bp-features-section .bp-feature-with-images{margin-bottom:2em}.buddypress .bp-features-section .headline-title{margin-bottom:1em}.buddypress .bp-changelog-section .changelog-title{font-size:1.25em;line-height:1.5;margin-bottom:.5em;margin-top:.5em}.buddypress .bp-changelog-section .title,.buddypress .bp-features-section .feature-title{font-size:1.25em;line-height:1.25;margin-top:.6em;text-align:right}.buddypress .bp-features-section .bp-feature,.buddypress .bp-features-section .bp-feature-imaged{clear:both;float:right;margin-bottom:1em;margin-top:1em;margin-left:0;padding-left:1em;width:100%}.buddypress .bp-features-section .bp-feature-imaged p{font-size:1em}.buddypress .bp-features-section .bp-feature span{margin-top:.33em}.buddypress .bp-feature.opposite .feature-title,.buddypress .bp-feature.opposite p{float:none}.buddypress .bp-changelog-section{clear:both;margin-bottom:2em;margin-top:2em}.buddypress .bp-changelog{margin-bottom:0}.buddypress .bp-changelog-section .changelog-title{margin-bottom:.5em}.buddypress .bp-changelog .title{font-size:1em}.buddypress .bp-changelog p{margin-bottom:1em}.buddypress .bp-changelog-section .three-col .col,.buddypress .bp-changelog-section .two-col>div{margin-top:0;padding-bottom:.5em;width:100%}.buddypress .bp-three-column .bp-column{width:100%}}@media screen and (max-width:360px){.buddypress .bp-headline{text-align:center}.buddypress .bp-headline span.dashicons{clear:none;font-size:80px;float:none;height:80px;line-height:80px;margin:0 auto;width:80px}.buddypress .bp-features-section .headline-title,.buddypress .bp-headline-feature .headline-title{font-size:1.5em;line-height:1.5;text-align:right}.buddypress .bp-headline-feature .headline-title{margin:1em 0 0}.buddypress .bp-headline-feature p{margin:1.15em 0 .6em auto;text-align:right;width:auto}.buddypress .bp-features-section .bp-feature{text-align:center}.buddypress .bp-features-section span.dashicons{float:none}.buddypress .bp-features-section .feature-title,.buddypress .bp-features-section p{margin-right:0;text-align:right}}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}.settings_page_bp-components td.plugin-title span{float:right;width:18px;height:18px;margin-left:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.forums td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}.settings_page_bp-components tr.core td.plugin-title span:before{content:"\f448"}.settings_page_bp-components tr.members td.plugin-title span:before{content:"\f307"}#bp-admin-component-form .wp-list-table.plugins .plugin-title{width:25%}@media screen and (max-width:782px){.settings_page_bp-components td.plugin-title span{margin-top:5px}#bp-admin-component-form .wp-list-table.plugins .plugin-title{display:block;width:auto}#bp-admin-component-form .subsubsub{margin-bottom:0;padding-bottom:35px}}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}.bp-signups-list table{margin:1em 0}.bp-signups-list .column-fields{font-weight:700}body.post-type-bp-email #excerpt{height:auto}body.post-type-bp-email th#situation{width:20%}body.post-type-bp-email td.column-situation ul{margin:0}body.post-type-bp-email .categorydiv label{display:block;float:right;padding-right:25px;text-indent:-25px}.tools_page_bp-tools .wrap{max-width:950px}.tools_page_bp-tools p{line-height:2}.tools_page_bp-tools fieldset{margin:2em 0 0}.tools_page_bp-tools legend{color:#23282d;font-size:1.3em;font-weight:600;margin:1em 0}.tools_page_bp-tools label{clear:right;display:block;line-height:1.5;margin:0 0 1em;vertical-align:middle}@media screen and (max-width:782px){.tools_page_bp-tools p{line-height:1.5}.tools_page_bp-tools label{margin-bottom:1em;padding-left:25px;text-indent:-33px}.tools_page_bp-tools .checkbox{padding:0 30px 0 0}}#buddypress-update.not-shiny .update-message{border-right:0;padding-right:36px}#buddypress-update.not-shiny .update-message:before{content:"\f534"}
bp-core/admin/css/common.css CHANGED
@@ -10,18 +10,17 @@ TABLE OF CONTENTS:
10
  --------------------------------------------------------------------------------
11
  1.0 Welcome Screen
12
  1.1 Version Badge
13
- 1.2 ---
14
- 1.3 Credits Panel
 
 
15
  2.0 Dashicons
16
  2.1 Top level menus
17
  2.2 Settings - Components
18
  2.3 Tools
19
- 2.4 Tooltips
20
- 3.0 Users
21
- 3.1 Users List
22
- 3.2 Site Notices
23
  4.0 Emails - Edit page
24
- 5.0 Block Editor
25
  6.0 Plugins page
26
  ------------------------------------------------------------------------------*/
27
 
@@ -42,132 +41,398 @@ TABLE OF CONTENTS:
42
  content: "\f448";
43
  }
44
 
45
- .settings_page_bp-credits code,
 
 
 
 
 
 
46
  .index_page_bp-about code {
47
  background-color: #e0e0e0;
48
  color: #636363;
49
  font-size: 1em;
50
  }
51
 
 
 
 
 
 
 
 
 
 
 
52
  /*
53
- * 1.3 Credits Panel
54
- *
55
- * Taken from WP 4.9.5.
56
  */
57
- .bp-about-wrap {
58
- position: relative;
59
- max-width: 1050px;
60
- font-size: 15px;
 
 
 
 
61
  }
62
 
63
- .bp-about-wrap img {
64
- margin: 0;
65
- max-width: 100%;
66
- height: auto;
67
- vertical-align: middle;
68
  }
69
 
70
- .bp-about-wrap p {
71
- line-height: 1.5;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  font-size: 14px;
 
 
 
 
 
73
  }
74
 
75
- .bp-about-wrap h2 {
76
- margin: 40px 0 0.6em;
77
- font-size: 2.7em;
78
- line-height: 1.3;
 
 
 
 
 
 
 
 
 
 
 
 
79
  font-weight: 300;
 
 
80
  text-align: center;
81
  }
82
 
83
- .bp-about-wrap h3 {
84
- margin: 1.25em 0 0.6em;
85
- font-size: 1.4em;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  line-height: 1.5;
87
  }
88
 
89
- .bp-about-wrap code {
90
- font-size: 14px;
91
- font-weight: 400;
 
92
  }
93
 
94
- .bp-about-wrap .about-description {
95
- margin-top: 1.4em;
96
- font-weight: 400;
97
- line-height: 1.6;
98
- font-size: 19px;
99
  }
100
 
101
- .bp-about-wrap h3.wp-people-group {
102
- margin: 2.6em 0 1.33em;
103
- padding: 0;
104
- font-size: 16px;
105
- line-height: inherit;
106
  }
107
 
108
- .bp-about-wrap .wp-people-group {
109
- padding: 0 5px;
110
- margin: 0 -15px 0 -5px;
111
  }
112
 
113
- .bp-about-wrap .compact {
 
 
114
  margin-bottom: 0;
 
 
 
115
  }
116
 
117
- .bp-about-wrap .wp-person {
118
- display: inline-block;
119
- vertical-align: top;
120
- margin-right: 10px;
121
- padding-bottom: 15px;
122
- height: 70px;
123
- width: 280px;
124
  }
125
 
126
- .bp-about-wrap .compact .wp-person {
127
- height: auto;
128
- width: 180px;
 
 
 
 
129
  padding-bottom: 0;
130
- margin-bottom: 0;
131
  }
132
 
133
- .bp-about-wrap .wp-person .gravatar {
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  float: left;
135
- margin: 0 10px 10px 0;
136
- padding: 1px;
137
- width: 60px;
138
- height: 60px;
139
  }
140
 
141
- .bp-about-wrap .compact .wp-person .gravatar {
142
- width: 30px;
143
- height: 30px;
 
 
144
  }
145
 
146
- .bp-about-wrap .wp-person .web {
147
- margin: 6px 0 2px;
148
- font-size: 16px;
149
- font-weight: 400;
150
- line-height: 2;
151
- text-decoration: none;
152
  }
153
 
154
- .bp-about-wrap .wp-person .title {
155
- display: block;
156
  }
157
 
158
- .bp-about-wrap p.wp-credits-list a {
159
- white-space: nowrap;
 
 
160
  }
161
 
162
- @media only screen and (max-width: 500px) {
 
 
 
 
163
 
164
- .bp-about-wrap {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  margin-right: 20px;
166
- margin-left: 10px;
167
  }
168
 
169
- .bp-about-wrap .bp-about-wrap h1 {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  margin-right: 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  }
172
  }
173
 
@@ -258,6 +523,10 @@ TABLE OF CONTENTS:
258
  content: "\f457";
259
  }
260
 
 
 
 
 
261
  .settings_page_bp-components tr.blogs td.plugin-title span:before {
262
  content: "\f120";
263
  }
@@ -274,11 +543,6 @@ TABLE OF CONTENTS:
274
  content: "\f307";
275
  }
276
 
277
- .settings_page_bp-page-settings .button-secondary .dashicons {
278
- position: relative;
279
- top: 3px;
280
- }
281
-
282
  #bp-admin-component-form .wp-list-table.plugins .plugin-title {
283
  width: 25%;
284
  }
@@ -307,92 +571,10 @@ TABLE OF CONTENTS:
307
  content: "";
308
  }
309
 
310
- body.tools-php .bp-tools dt {
311
- font-size: 1.1em;
312
- color: #646970;
313
- font-weight: 600;
314
- margin: 1em 0 0.5em 0;
315
- }
316
-
317
- body.tools-php .bp-tools dd {
318
- margin: 0;
319
- }
320
-
321
- body.tools_page_bp-members-invitations .nav-tab-wrapper,
322
- body.tools_page_bp-optouts .nav-tab-wrapper {
323
- margin-bottom: 1em;
324
- }
325
-
326
- /*
327
- * 2.4 Tooltips
328
- */
329
- .bp-tooltip {
330
- position: relative;
331
- }
332
-
333
- .bp-tooltip:after {
334
- background: #fff;
335
- border: 1px solid #aaa;
336
- border-collapse: separate;
337
- border-radius: 1px;
338
- box-shadow: 1px 1px 0 1px rgba(132, 132, 132, 0.3);
339
- color: #000;
340
- content: attr(data-bp-tooltip);
341
- display: none;
342
- font-family: sans-serif;
343
- font-size: 11px;
344
- font-weight: 400;
345
- letter-spacing: normal;
346
- line-height: 1.5;
347
- margin-top: 10px;
348
- max-width: 240px;
349
- opacity: 0;
350
- padding: 3px 6px;
351
- position: absolute;
352
- right: 50%;
353
- text-align: center;
354
- text-decoration: none;
355
- text-shadow: none;
356
- text-transform: none;
357
- top: 100%;
358
- transform: translateX(50%);
359
- transition: opacity 2s ease-out;
360
- white-space: pre;
361
- word-wrap: break-word;
362
- z-index: 998;
363
- }
364
-
365
- .bp-hello-close .bp-tooltip:after {
366
- right: 0;
367
- text-align: right;
368
- transform: translateX(0);
369
- }
370
-
371
- .bp-hello-social .bp-tooltip:after {
372
- bottom: 120%;
373
- margin-bottom: 20px;
374
- margin-top: 0;
375
- top: auto;
376
- transform: translateX(15%);
377
- }
378
-
379
- .bp-tooltip:hover:after,
380
- .bp-tooltip:active:after,
381
- .bp-tooltip:focus:after {
382
- display: inline-block;
383
- opacity: 1;
384
- overflow: visible;
385
- text-decoration: none;
386
- z-index: 999;
387
- }
388
 
389
  /*------------------------------------------------------------------------------
390
- * 3.0 Users
391
  *----------------------------------------------------------------------------*/
392
-
393
- /*
394
- * 3.1 Users List
395
- */
396
  body.site-users-php th#role,
397
  body.users-php th#role,
398
  body.users_page_bp-signups th#count_sent {
@@ -429,121 +611,75 @@ body.users_page_bp-signups td.count_sent {
429
  font-weight: 700;
430
  }
431
 
432
- /*
433
- * 3.2 Site Notices
434
- */
435
- .bp-new-notice-panel {
436
- background: #fff;
437
- border: 1px solid #e5e5e5;
438
- box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
439
- font-size: 13px;
440
- line-height: 2.1;
441
- margin: 1.5em 0 3em;
442
- overflow: auto;
443
- padding: 10px 25px 25px;
444
- position: relative;
445
  }
446
 
447
- .bp-new-notice-panel label {
448
- clear: both;
449
- float: left;
450
- margin-right: 3%;
451
  width: 20%;
452
  }
453
 
454
- .bp-new-notice-panel input,
455
- .bp-new-notice-panel textarea {
456
- clear: none;
457
- margin-bottom: 1em;
458
- width: 75%;
459
  }
460
 
461
- .bp-new-notice-panel input[type="text"]:after,
462
- .bp-new-notice-panel textarea:after {
463
- clear: both;
464
- content: " ";
465
- display: table;
466
  }
467
 
468
- .bp-new-notice-panel .button-primary {
469
- margin-left: 23%;
470
- width: auto;
 
 
471
  }
472
 
473
- .bp-notice-about {
474
- font-size: 1em;
475
- margin-bottom: 1em;
476
  }
477
 
478
- .bp-new-notice {
479
- margin-bottom: 1em;
480
- margin-top: 0;
481
  }
482
 
483
- .bp-notices-list {
484
- margin-bottom: 0;
 
 
 
485
  }
486
 
487
- @media screen and (max-width: 782px) {
488
-
489
- .bp-new-notice-panel {
490
- margin-bottom: 1.5em;
491
- }
492
-
493
- .bp-new-notice-panel input,
494
- .bp-new-notice-panel textarea {
495
- margin-left: 0;
496
- width: 100%;
497
- }
498
 
499
- .bp-new-notice-panel .button-primary {
500
- margin-left: 0;
501
- width: auto;
502
- }
503
 
504
- .bp-new-notice-panel .button {
505
- max-width: 45%;
506
- word-wrap: break-word;
507
  }
508
 
509
- .bp-notice-about {
510
- margin-top: 0;
511
  margin-bottom: 1em;
 
 
512
  }
513
 
514
- .bp-new-notice {
515
- margin-bottom: 0.5em;
516
  }
517
  }
518
 
519
- /*------------------------------------------------------------------------------
520
- * 4.0 Emails - Edit Page
521
- *----------------------------------------------------------------------------*/
522
- body.post-type-bp-email #excerpt {
523
- height: auto;
524
- }
525
-
526
- body.post-type-bp-email th#situation {
527
- width: 20%;
528
- }
529
-
530
- body.post-type-bp-email td.column-situation ul {
531
- margin: 0;
532
- }
533
-
534
- body.post-type-bp-email .categorydiv label {
535
- display: block;
536
- float: left;
537
- padding-left: 25px;
538
- text-indent: -25px;
539
- }
540
-
541
- /*------------------------------------------------------------------------------
542
- * 5.0 Block Editor
543
- *----------------------------------------------------------------------------*/
544
- .block-editor-inserter__panel-header span.dashicons-buddicons-buddypress-logo {
545
- color: #d84800;
546
- }
547
 
548
  /*------------------------------------------------------------------------------
549
  * 6.0 Plugins page
10
  --------------------------------------------------------------------------------
11
  1.0 Welcome Screen
12
  1.1 Version Badge
13
+ 1.2 About Panel
14
+ 1.2.1 Headline Feature
15
+ 1.2.2 Features Section
16
+ 1.2.3 Changelog Section
17
  2.0 Dashicons
18
  2.1 Top level menus
19
  2.2 Settings - Components
20
  2.3 Tools
21
+ 3.0 User's Lists
 
 
 
22
  4.0 Emails - Edit page
23
+ 5.0 Tools - BuddyPress
24
  6.0 Plugins page
25
  ------------------------------------------------------------------------------*/
26
 
41
  content: "\f448";
42
  }
43
 
44
+ .about-wrap .bp-badge {
45
+ position: absolute;
46
+ top: 0;
47
+ right: 0;
48
+ }
49
+
50
+ .index_page_bp-credits code,
51
  .index_page_bp-about code {
52
  background-color: #e0e0e0;
53
  color: #636363;
54
  font-size: 1em;
55
  }
56
 
57
+ @media only screen and (max-width: 500px) {
58
+
59
+ .about-wrap .bp-badge {
60
+ position: relative;
61
+ margin: 10px auto;
62
+ top: auto;
63
+ right: auto;
64
+ }
65
+ }
66
+
67
  /*
68
+ * 1.2 About Panel
 
 
69
  */
70
+
71
+ /*
72
+ * 1.2.1 Headline Feature
73
+ */
74
+ .buddypress .bp-headline-feature {
75
+ margin-bottom: 2em;
76
+ margin-top: 3em;
77
+ padding: 2em 3em;
78
  }
79
 
80
+ .buddypress .bp-headline {
81
+ margin: 0 auto;
82
+ width: 45em;
 
 
83
  }
84
 
85
+ .buddypress .bp-headline span.dashicons {
86
+ background-color: #f1f1f1;
87
+ color: #d84800;
88
+ clear: left;
89
+ font-size: 100px;
90
+ float: left;
91
+ height: 100px;
92
+ line-height: 100px;
93
+ margin: 0 15px 15px 0;
94
+ text-align: center;
95
+ width: 100px;
96
+ }
97
+
98
+ .buddypress .bp-headline-feature .headline-title {
99
+ font-size: 2.2em;
100
+ font-weight: 300;
101
+ line-height: 2;
102
+ margin: 0 0 1em;
103
+ text-align: center;
104
+ }
105
+
106
+ .buddypress .bp-headline-feature p {
107
+ font-size: 1.15em;
108
+ margin: 1.15em auto 0.6em 0;
109
+ }
110
+
111
+ /*
112
+ * 1.2.2 Features Section
113
+ */
114
+ .buddypress .bp-features-section {
115
+ border-bottom: 1px solid #ccc;
116
+ clear: both;
117
+ margin-bottom: 3em;
118
+ margin-top: 2em;
119
+ overflow: hidden;
120
+ padding-bottom: 2em;
121
+ }
122
+
123
+ .buddypress .bp-features-section p {
124
  font-size: 14px;
125
+ line-height: 1.5;
126
+ }
127
+
128
+ .buddypress .bp-features-section img {
129
+ margin-bottom: 20px;
130
  }
131
 
132
+ .buddypress .bp-features-section span.dashicons {
133
+ background-color: #fff;
134
+ border-radius: 50%;
135
+ clear: left;
136
+ color: #d84800;
137
+ font-size: 50px;
138
+ float: left;
139
+ height: 80px;
140
+ line-height: 80px;
141
+ margin: 0 15px 15px 0;
142
+ text-align: center;
143
+ width: 80px;
144
+ }
145
+
146
+ .buddypress .bp-features-section .headline-title {
147
+ font-size: 2em;
148
  font-weight: 300;
149
+ line-height: 1.5;
150
+ margin: 1em auto 2em;
151
  text-align: center;
152
  }
153
 
154
+ .buddypress .bp-features-section .bp-feature-with-images {
155
+ border-bottom: 1px solid #ccc;
156
+ margin-bottom: 5em;
157
+ padding-bottom: 2em;
158
+ }
159
+
160
+ .buddypress .bp-features-section .bp-feature,
161
+ .buddypress .bp-features-section .bp-feature-imaged {
162
+ float: left;
163
+ margin-bottom: 3em;
164
+ margin-right: 4.799999999%;
165
+ width: 47.6%;
166
+ }
167
+
168
+ .buddypress .bp-features-section .bp-feature.opposite,
169
+ .buddypress .bp-features-section .bp-feature-imaged.anon {
170
+ margin-right: 0;
171
+ }
172
+
173
+ .buddypress .bp-features-section .bp-feature code {
174
+ font-size: 0.95em;
175
  line-height: 1.5;
176
  }
177
 
178
+ .buddypress .bp-feature:after {
179
+ clear: both;
180
+ content: "";
181
+ margin-bottom: 2em;
182
  }
183
 
184
+ .buddypress .bp-feature-imaged .feature-title {
185
+ color: #23282d;
186
+ font-size: 1.25em;
187
+ margin-bottom: 0.6em;
188
+ margin-top: 0;
189
  }
190
 
191
+ .buddypress .bp-feature-imaged p {
192
+ clear: left;
193
+ font-size: 1.1em;
 
 
194
  }
195
 
196
+ .buddypress .bp-feature-imaged img {
197
+ clear: left;
 
198
  }
199
 
200
+ .buddypress .bp-feature .feature-title {
201
+ font-size: 1em;
202
+ line-height: 1.5;
203
  margin-bottom: 0;
204
+ margin-left: 110px;
205
+ margin-top: 0;
206
+ text-align: left;
207
  }
208
 
209
+ .buddypress .bp-feature p {
210
+ margin-left: 110px;
 
 
 
 
 
211
  }
212
 
213
+ /*
214
+ * 1.2.3 Changelog Section
215
+ */
216
+ .buddypress .bp-changelog-section {
217
+ clear: both;
218
+ margin-bottom: 3em;
219
+ margin-top: 4em;
220
  padding-bottom: 0;
 
221
  }
222
 
223
+ .buddypress .bp-changelog-section:after {
224
+ clear: both;
225
+ content: "";
226
+ display: table;
227
+ }
228
+
229
+ .buddypress .bp-changelog-section .changelog-title {
230
+ color: #23282d;
231
+ font-size: 1.25em;
232
+ line-height: 1.5;
233
+ margin: 0 auto 1.5em;
234
+ }
235
+
236
+ .buddypress .bp-two-column div {
237
  float: left;
238
+ margin-right: 4.799999999%;
239
+ position: relative;
240
+ width: 47.6%;
 
241
  }
242
 
243
+ .buddypress .bp-three-column .bp-column {
244
+ float: left;
245
+ margin-right: 5%;
246
+ position: relative;
247
+ width: 29.95%;
248
  }
249
 
250
+ .buddypress .bp-two-column .bp-column:nth-of-type(2n),
251
+ .buddypress .bp-three-column .bp-column:nth-of-type(3n) {
252
+ margin-right: 0;
 
 
 
253
  }
254
 
255
+ .buddypress .bp-changelog {
256
+ margin-bottom: 3em;
257
  }
258
 
259
+ .buddypress .bp-changelog:after {
260
+ clear: both;
261
+ content: "";
262
+ display: table;
263
  }
264
 
265
+ .buddypress .bp-changelog .title {
266
+ font-size: 14px;
267
+ margin-bottom: 0.75em;
268
+ margin-top: 0;
269
+ }
270
 
271
+ .buddypress .bp-changelog p {
272
+ margin-bottom: 0;
273
+ }
274
+
275
+ .bp-changelog-url {
276
+ text-align: center;
277
+ }
278
+
279
+ .bp-assets {
280
+ clear: both;
281
+ margin-bottom: 3em;
282
+ }
283
+
284
+ @media screen and ( max-width: 782px ) {
285
+
286
+ .bp-headline-feature,
287
+ .bp-features-section,
288
+ .bp-changelog-section,
289
+ .bp-assets {
290
+ margin-left: 20px;
291
  margin-right: 20px;
 
292
  }
293
 
294
+ .buddypress .bp-headline-feature {
295
+ padding: 0;
296
+ }
297
+
298
+ .buddypress .bp-headline {
299
+ margin: 0;
300
+ width: 97%;
301
+ }
302
+
303
+ .buddypress .bp-features-section {
304
+ clear: both;
305
+ margin-bottom: 0;
306
+ margin-top: 2em;
307
+ padding-bottom: 2em;
308
+ }
309
+
310
+ .buddypress .bp-features-section .bp-feature-with-images {
311
+ margin-bottom: 2em;
312
+ }
313
+
314
+ .buddypress .bp-features-section .headline-title {
315
+ margin-bottom: 1em;
316
+ }
317
+
318
+ .buddypress .bp-changelog-section .changelog-title {
319
+ font-size: 1.25em;
320
+ line-height: 1.5;
321
+ margin-bottom: 0.5em;
322
+ margin-top: 0.5em;
323
+ }
324
+
325
+ .buddypress .bp-features-section .feature-title,
326
+ .buddypress .bp-changelog-section .title {
327
+ font-size: 1.25em;
328
+ line-height: 1.25;
329
+ margin-top: 0.6em;
330
+ text-align: left;
331
+ }
332
+
333
+ .buddypress .bp-features-section .bp-feature,
334
+ .buddypress .bp-features-section .bp-feature-imaged {
335
+ clear: both;
336
+ float: left;
337
+ margin-bottom: 1em;
338
+ margin-top: 1em;
339
  margin-right: 0;
340
+ padding-right: 1em;
341
+ width: 100%;
342
+ }
343
+
344
+ .buddypress .bp-features-section .bp-feature-imaged p {
345
+ font-size: 1em;
346
+ }
347
+
348
+ .buddypress .bp-features-section .bp-feature span {
349
+ margin-top: 0.33em;
350
+ }
351
+
352
+ .buddypress .bp-feature.opposite .feature-title,
353
+ .buddypress .bp-feature.opposite p {
354
+ float: none;
355
+ }
356
+
357
+ .buddypress .bp-changelog-section {
358
+ clear: both;
359
+ margin-bottom: 2em;
360
+ margin-top: 2em;
361
+ }
362
+
363
+ .buddypress .bp-changelog {
364
+ margin-bottom: 0;
365
+ }
366
+
367
+ .buddypress .bp-changelog-section .changelog-title {
368
+ margin-bottom: 0.5em;
369
+ }
370
+
371
+ .buddypress .bp-changelog .title {
372
+ font-size: 1em;
373
+ }
374
+
375
+ .buddypress .bp-changelog p {
376
+ margin-bottom: 1em;
377
+ }
378
+
379
+ .buddypress .bp-changelog-section .two-col > div,
380
+ .buddypress .bp-changelog-section .three-col .col {
381
+ margin-top: 0;
382
+ padding-bottom: 0.5em;
383
+ width: 100%;
384
+ }
385
+
386
+ .buddypress .bp-three-column .bp-column {
387
+ width: 100%;
388
+ }
389
+ }
390
+
391
+ @media screen and ( max-width: 360px ) {
392
+
393
+ .buddypress .bp-headline {
394
+ text-align: center;
395
+ }
396
+
397
+ .buddypress .bp-headline span.dashicons {
398
+ clear: none;
399
+ font-size: 80px;
400
+ float: none;
401
+ height: 80px;
402
+ line-height: 80px;
403
+ margin: 0 auto;
404
+ width: 80px;
405
+ }
406
+
407
+ .buddypress .bp-headline-feature .headline-title,
408
+ .buddypress .bp-features-section .headline-title {
409
+ font-size: 1.5em;
410
+ line-height: 1.5;
411
+ text-align: left;
412
+ }
413
+
414
+ .buddypress .bp-headline-feature .headline-title {
415
+ margin: 1em 0 0;
416
+ }
417
+
418
+ .buddypress .bp-headline-feature p {
419
+ margin: 1.15em auto 0.6em 0;
420
+ text-align: left;
421
+ width: auto;
422
+ }
423
+
424
+ .buddypress .bp-features-section .bp-feature {
425
+ text-align: center;
426
+ }
427
+
428
+ .buddypress .bp-features-section span.dashicons {
429
+ float: none;
430
+ }
431
+
432
+ .buddypress .bp-features-section .feature-title,
433
+ .buddypress .bp-features-section p {
434
+ margin-left: 0;
435
+ text-align: left;
436
  }
437
  }
438
 
523
  content: "\f457";
524
  }
525
 
526
+ .settings_page_bp-components tr.forums td.plugin-title span:before {
527
+ content: "\f452";
528
+ }
529
+
530
  .settings_page_bp-components tr.blogs td.plugin-title span:before {
531
  content: "\f120";
532
  }
543
  content: "\f307";
544
  }
545
 
 
 
 
 
 
546
  #bp-admin-component-form .wp-list-table.plugins .plugin-title {
547
  width: 25%;
548
  }
571
  content: "";
572
  }
573
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
574
 
575
  /*------------------------------------------------------------------------------
576
+ * 3.0 User's Lists
577
  *----------------------------------------------------------------------------*/
 
 
 
 
578
  body.site-users-php th#role,
579
  body.users-php th#role,
580
  body.users_page_bp-signups th#count_sent {
611
  font-weight: 700;
612
  }
613
 
614
+ /*------------------------------------------------------------------------------
615
+ * 4.0 Emails - Edit Page
616
+ *----------------------------------------------------------------------------*/
617
+ body.post-type-bp-email #excerpt {
618
+ height: auto;
 
 
 
 
 
 
 
 
619
  }
620
 
621
+ body.post-type-bp-email th#situation {
 
 
 
622
  width: 20%;
623
  }
624
 
625
+ body.post-type-bp-email td.column-situation ul {
626
+ margin: 0;
 
 
 
627
  }
628
 
629
+ body.post-type-bp-email .categorydiv label {
630
+ display: block;
631
+ float: left;
632
+ padding-left: 25px;
633
+ text-indent: -25px;
634
  }
635
 
636
+ /*------------------------------------------------------------------------------
637
+ * 5.0 Tools - BuddyPress
638
+ *----------------------------------------------------------------------------*/
639
+ .tools_page_bp-tools .wrap {
640
+ max-width: 950px;
641
  }
642
 
643
+ .tools_page_bp-tools p {
644
+ line-height: 2;
 
645
  }
646
 
647
+ .tools_page_bp-tools fieldset {
648
+ margin: 2em 0 0;
 
649
  }
650
 
651
+ .tools_page_bp-tools legend {
652
+ color: #23282d;
653
+ font-size: 1.3em;
654
+ font-weight: 600;
655
+ margin: 1em 0;
656
  }
657
 
658
+ .tools_page_bp-tools label {
659
+ clear: left;
660
+ display: block;
661
+ line-height: 1.5;
662
+ margin: 0 0 1em;
663
+ vertical-align: middle;
664
+ }
 
 
 
 
665
 
666
+ @media screen and (max-width: 782px) {
 
 
 
667
 
668
+ .tools_page_bp-tools p {
669
+ line-height: 1.5;
 
670
  }
671
 
672
+ .tools_page_bp-tools label {
 
673
  margin-bottom: 1em;
674
+ padding-right: 25px;
675
+ text-indent: -33px;
676
  }
677
 
678
+ .tools_page_bp-tools .checkbox {
679
+ padding: 0 0 0 30px;
680
  }
681
  }
682
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
683
 
684
  /*------------------------------------------------------------------------------
685
  * 6.0 Plugins page
bp-core/admin/css/common.min.css CHANGED
@@ -1 +1 @@
1
- .bp-badge{color:#d84800;display:inline-block;font:400 150px/1 dashicons!important}.bp-badge:before{content:"\f448"}.index_page_bp-about code,.settings_page_bp-credits code{background-color:#e0e0e0;color:#636363;font-size:1em}.bp-about-wrap{position:relative;max-width:1050px;font-size:15px}.bp-about-wrap img{margin:0;max-width:100%;height:auto;vertical-align:middle}.bp-about-wrap p{line-height:1.5;font-size:14px}.bp-about-wrap h2{margin:40px 0 .6em;font-size:2.7em;line-height:1.3;font-weight:300;text-align:center}.bp-about-wrap h3{margin:1.25em 0 .6em;font-size:1.4em;line-height:1.5}.bp-about-wrap code{font-size:14px;font-weight:400}.bp-about-wrap .about-description{margin-top:1.4em;font-weight:400;line-height:1.6;font-size:19px}.bp-about-wrap h3.wp-people-group{margin:2.6em 0 1.33em;padding:0;font-size:16px;line-height:inherit}.bp-about-wrap .wp-people-group{padding:0 5px;margin:0 -15px 0 -5px}.bp-about-wrap .compact{margin-bottom:0}.bp-about-wrap .wp-person{display:inline-block;vertical-align:top;margin-right:10px;padding-bottom:15px;height:70px;width:280px}.bp-about-wrap .compact .wp-person{height:auto;width:180px;padding-bottom:0;margin-bottom:0}.bp-about-wrap .wp-person .gravatar{float:left;margin:0 10px 10px 0;padding:1px;width:60px;height:60px}.bp-about-wrap .compact .wp-person .gravatar{width:30px;height:30px}.bp-about-wrap .wp-person .web{margin:6px 0 2px;font-size:16px;font-weight:400;line-height:2;text-decoration:none}.bp-about-wrap .wp-person .title{display:block}.bp-about-wrap p.wp-credits-list a{white-space:nowrap}@media only screen and (max-width:500px){.bp-about-wrap{margin-right:20px;margin-left:10px}.bp-about-wrap .bp-about-wrap h1{margin-right:0}}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}.settings_page_bp-components td.plugin-title span{float:left;width:18px;height:18px;margin-right:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}.settings_page_bp-components tr.core td.plugin-title span:before{content:"\f448"}.settings_page_bp-components tr.members td.plugin-title span:before{content:"\f307"}.settings_page_bp-page-settings .button-secondary .dashicons{position:relative;top:3px}#bp-admin-component-form .wp-list-table.plugins .plugin-title{width:25%}@media screen and (max-width:782px){.settings_page_bp-components td.plugin-title span{margin-top:5px}#bp-admin-component-form .wp-list-table.plugins .plugin-title{display:block;width:auto}#bp-admin-component-form .subsubsub{margin-bottom:0;padding-bottom:35px}}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}body.tools-php .bp-tools dt{font-size:1.1em;color:#646970;font-weight:600;margin:1em 0 .5em 0}body.tools-php .bp-tools dd{margin:0}body.tools_page_bp-members-invitations .nav-tab-wrapper,body.tools_page_bp-optouts .nav-tab-wrapper{margin-bottom:1em}.bp-tooltip{position:relative}.bp-tooltip:after{background:#fff;border:1px solid #aaa;border-collapse:separate;border-radius:1px;box-shadow:1px 1px 0 1px rgba(132,132,132,.3);color:#000;content:attr(data-bp-tooltip);display:none;font-family:sans-serif;font-size:11px;font-weight:400;letter-spacing:normal;line-height:1.5;margin-top:10px;max-width:240px;opacity:0;padding:3px 6px;position:absolute;right:50%;text-align:center;text-decoration:none;text-shadow:none;text-transform:none;top:100%;transform:translateX(50%);transition:opacity 2s ease-out;white-space:pre;word-wrap:break-word;z-index:998}.bp-hello-close .bp-tooltip:after{right:0;text-align:right;transform:translateX(0)}.bp-hello-social .bp-tooltip:after{bottom:120%;margin-bottom:20px;margin-top:0;top:auto;transform:translateX(15%)}.bp-tooltip:active:after,.bp-tooltip:focus:after,.bp-tooltip:hover:after{display:inline-block;opacity:1;overflow:visible;text-decoration:none;z-index:999}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}.bp-signups-list table{margin:1em 0}.bp-signups-list .column-fields{font-weight:700}.bp-new-notice-panel{background:#fff;border:1px solid #e5e5e5;box-shadow:0 1px 1px rgba(0,0,0,.04);font-size:13px;line-height:2.1;margin:1.5em 0 3em;overflow:auto;padding:10px 25px 25px;position:relative}.bp-new-notice-panel label{clear:both;float:left;margin-right:3%;width:20%}.bp-new-notice-panel input,.bp-new-notice-panel textarea{clear:none;margin-bottom:1em;width:75%}.bp-new-notice-panel input[type=text]:after,.bp-new-notice-panel textarea:after{clear:both;content:" ";display:table}.bp-new-notice-panel .button-primary{margin-left:23%;width:auto}.bp-notice-about{font-size:1em;margin-bottom:1em}.bp-new-notice{margin-bottom:1em;margin-top:0}.bp-notices-list{margin-bottom:0}@media screen and (max-width:782px){.bp-new-notice-panel{margin-bottom:1.5em}.bp-new-notice-panel input,.bp-new-notice-panel textarea{margin-left:0;width:100%}.bp-new-notice-panel .button-primary{margin-left:0;width:auto}.bp-new-notice-panel .button{max-width:45%;word-wrap:break-word}.bp-notice-about{margin-top:0;margin-bottom:1em}.bp-new-notice{margin-bottom:.5em}}body.post-type-bp-email #excerpt{height:auto}body.post-type-bp-email th#situation{width:20%}body.post-type-bp-email td.column-situation ul{margin:0}body.post-type-bp-email .categorydiv label{display:block;float:left;padding-left:25px;text-indent:-25px}.block-editor-inserter__panel-header span.dashicons-buddicons-buddypress-logo{color:#d84800}#buddypress-update.not-shiny .update-message{border-left:0;padding-left:36px}#buddypress-update.not-shiny .update-message:before{content:"\f534"}
1
+ .bp-badge{color:#d84800;display:inline-block;font:400 150px/1 dashicons!important}.bp-badge:before{content:"\f448"}.about-wrap .bp-badge{position:absolute;top:0;right:0}.index_page_bp-about code,.index_page_bp-credits code{background-color:#e0e0e0;color:#636363;font-size:1em}@media only screen and (max-width:500px){.about-wrap .bp-badge{position:relative;margin:10px auto;top:auto;right:auto}}.buddypress .bp-headline-feature{margin-bottom:2em;margin-top:3em;padding:2em 3em}.buddypress .bp-headline{margin:0 auto;width:45em}.buddypress .bp-headline span.dashicons{background-color:#f1f1f1;color:#d84800;clear:left;font-size:100px;float:left;height:100px;line-height:100px;margin:0 15px 15px 0;text-align:center;width:100px}.buddypress .bp-headline-feature .headline-title{font-size:2.2em;font-weight:300;line-height:2;margin:0 0 1em;text-align:center}.buddypress .bp-headline-feature p{font-size:1.15em;margin:1.15em auto .6em 0}.buddypress .bp-features-section{border-bottom:1px solid #ccc;clear:both;margin-bottom:3em;margin-top:2em;overflow:hidden;padding-bottom:2em}.buddypress .bp-features-section p{font-size:14px;line-height:1.5}.buddypress .bp-features-section img{margin-bottom:20px}.buddypress .bp-features-section span.dashicons{background-color:#fff;border-radius:50%;clear:left;color:#d84800;font-size:50px;float:left;height:80px;line-height:80px;margin:0 15px 15px 0;text-align:center;width:80px}.buddypress .bp-features-section .headline-title{font-size:2em;font-weight:300;line-height:1.5;margin:1em auto 2em;text-align:center}.buddypress .bp-features-section .bp-feature-with-images{border-bottom:1px solid #ccc;margin-bottom:5em;padding-bottom:2em}.buddypress .bp-features-section .bp-feature,.buddypress .bp-features-section .bp-feature-imaged{float:left;margin-bottom:3em;margin-right:4.799999999%;width:47.6%}.buddypress .bp-features-section .bp-feature-imaged.anon,.buddypress .bp-features-section .bp-feature.opposite{margin-right:0}.buddypress .bp-features-section .bp-feature code{font-size:.95em;line-height:1.5}.buddypress .bp-feature:after{clear:both;content:"";margin-bottom:2em}.buddypress .bp-feature-imaged .feature-title{color:#23282d;font-size:1.25em;margin-bottom:.6em;margin-top:0}.buddypress .bp-feature-imaged p{clear:left;font-size:1.1em}.buddypress .bp-feature-imaged img{clear:left}.buddypress .bp-feature .feature-title{font-size:1em;line-height:1.5;margin-bottom:0;margin-left:110px;margin-top:0;text-align:left}.buddypress .bp-feature p{margin-left:110px}.buddypress .bp-changelog-section{clear:both;margin-bottom:3em;margin-top:4em;padding-bottom:0}.buddypress .bp-changelog-section:after{clear:both;content:"";display:table}.buddypress .bp-changelog-section .changelog-title{color:#23282d;font-size:1.25em;line-height:1.5;margin:0 auto 1.5em}.buddypress .bp-two-column div{float:left;margin-right:4.799999999%;position:relative;width:47.6%}.buddypress .bp-three-column .bp-column{float:left;margin-right:5%;position:relative;width:29.95%}.buddypress .bp-three-column .bp-column:nth-of-type(3n),.buddypress .bp-two-column .bp-column:nth-of-type(2n){margin-right:0}.buddypress .bp-changelog{margin-bottom:3em}.buddypress .bp-changelog:after{clear:both;content:"";display:table}.buddypress .bp-changelog .title{font-size:14px;margin-bottom:.75em;margin-top:0}.buddypress .bp-changelog p{margin-bottom:0}.bp-changelog-url{text-align:center}.bp-assets{clear:both;margin-bottom:3em}@media screen and (max-width:782px){.bp-assets,.bp-changelog-section,.bp-features-section,.bp-headline-feature{margin-left:20px;margin-right:20px}.buddypress .bp-headline-feature{padding:0}.buddypress .bp-headline{margin:0;width:97%}.buddypress .bp-features-section{clear:both;margin-bottom:0;margin-top:2em;padding-bottom:2em}.buddypress .bp-features-section .bp-feature-with-images{margin-bottom:2em}.buddypress .bp-features-section .headline-title{margin-bottom:1em}.buddypress .bp-changelog-section .changelog-title{font-size:1.25em;line-height:1.5;margin-bottom:.5em;margin-top:.5em}.buddypress .bp-changelog-section .title,.buddypress .bp-features-section .feature-title{font-size:1.25em;line-height:1.25;margin-top:.6em;text-align:left}.buddypress .bp-features-section .bp-feature,.buddypress .bp-features-section .bp-feature-imaged{clear:both;float:left;margin-bottom:1em;margin-top:1em;margin-right:0;padding-right:1em;width:100%}.buddypress .bp-features-section .bp-feature-imaged p{font-size:1em}.buddypress .bp-features-section .bp-feature span{margin-top:.33em}.buddypress .bp-feature.opposite .feature-title,.buddypress .bp-feature.opposite p{float:none}.buddypress .bp-changelog-section{clear:both;margin-bottom:2em;margin-top:2em}.buddypress .bp-changelog{margin-bottom:0}.buddypress .bp-changelog-section .changelog-title{margin-bottom:.5em}.buddypress .bp-changelog .title{font-size:1em}.buddypress .bp-changelog p{margin-bottom:1em}.buddypress .bp-changelog-section .three-col .col,.buddypress .bp-changelog-section .two-col>div{margin-top:0;padding-bottom:.5em;width:100%}.buddypress .bp-three-column .bp-column{width:100%}}@media screen and (max-width:360px){.buddypress .bp-headline{text-align:center}.buddypress .bp-headline span.dashicons{clear:none;font-size:80px;float:none;height:80px;line-height:80px;margin:0 auto;width:80px}.buddypress .bp-features-section .headline-title,.buddypress .bp-headline-feature .headline-title{font-size:1.5em;line-height:1.5;text-align:left}.buddypress .bp-headline-feature .headline-title{margin:1em 0 0}.buddypress .bp-headline-feature p{margin:1.15em auto .6em 0;text-align:left;width:auto}.buddypress .bp-features-section .bp-feature{text-align:center}.buddypress .bp-features-section span.dashicons{float:none}.buddypress .bp-features-section .feature-title,.buddypress .bp-features-section p{margin-left:0;text-align:left}}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}.settings_page_bp-components td.plugin-title span{float:left;width:18px;height:18px;margin-right:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.forums td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}.settings_page_bp-components tr.core td.plugin-title span:before{content:"\f448"}.settings_page_bp-components tr.members td.plugin-title span:before{content:"\f307"}#bp-admin-component-form .wp-list-table.plugins .plugin-title{width:25%}@media screen and (max-width:782px){.settings_page_bp-components td.plugin-title span{margin-top:5px}#bp-admin-component-form .wp-list-table.plugins .plugin-title{display:block;width:auto}#bp-admin-component-form .subsubsub{margin-bottom:0;padding-bottom:35px}}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}.bp-signups-list table{margin:1em 0}.bp-signups-list .column-fields{font-weight:700}body.post-type-bp-email #excerpt{height:auto}body.post-type-bp-email th#situation{width:20%}body.post-type-bp-email td.column-situation ul{margin:0}body.post-type-bp-email .categorydiv label{display:block;float:left;padding-left:25px;text-indent:-25px}.tools_page_bp-tools .wrap{max-width:950px}.tools_page_bp-tools p{line-height:2}.tools_page_bp-tools fieldset{margin:2em 0 0}.tools_page_bp-tools legend{color:#23282d;font-size:1.3em;font-weight:600;margin:1em 0}.tools_page_bp-tools label{clear:left;display:block;line-height:1.5;margin:0 0 1em;vertical-align:middle}@media screen and (max-width:782px){.tools_page_bp-tools p{line-height:1.5}.tools_page_bp-tools label{margin-bottom:1em;padding-right:25px;text-indent:-33px}.tools_page_bp-tools .checkbox{padding:0 0 0 30px}}#buddypress-update.not-shiny .update-message{border-left:0;padding-left:36px}#buddypress-update.not-shiny .update-message:before{content:"\f534"}
bp-core/admin/css/hello-rtl.css DELETED
@@ -1,292 +0,0 @@
1
- /*------------------------------------------------------------------------------
2
- Loaded in wp-admin for query string `hello=buddypress`.
3
-
4
- @since 3.0.0
5
-
6
- --------------------------------------------------------------------------------
7
- TABLE OF CONTENTS:
8
- --------------------------------------------------------------------------------
9
- 1.0 - Typography and colour
10
- 2.0 - Dashicons
11
- 3.0 - Elements
12
- 3.1 - Modal footer
13
- 3.2 - Modal content
14
- 4.0 - Content styles
15
- 4.1 - Footer content
16
- 4.2 - Header content
17
- 4.3 - Content content
18
- 5.0 - Media
19
- 6.0 - Media Queries
20
- 6.1 - Desktop Medium
21
- 6.2 - Desktop Large
22
- ------------------------------------------------------------------------------*/
23
- /*------------------------------------------------------------------------------
24
- * 1.0 - Typography and colour
25
- *----------------------------------------------------------------------------*/
26
- :root {
27
- --bp-hello-color-primary: #d34600;
28
- --bp-hello-color-secondary: #e5e5e5;
29
- --bp-hello-container-size: 15%;
30
- }
31
-
32
- .bp-hello-content p {
33
- font-size: 16px;
34
- }
35
-
36
- .bp-hello-content ul,
37
- .bp-hello-content ol {
38
- list-style: inherit;
39
- }
40
-
41
- .bp-hello-content h3 {
42
- font-size: 1.1em;
43
- font-weight: 500;
44
- }
45
-
46
- /*------------------------------------------------------------------------------
47
- * 2.0 - Dashicons
48
- *----------------------------------------------------------------------------*/
49
- .bp-hello-social li a:before {
50
- color: #23282d;
51
- /* wp toolbar */
52
- font: 400 30px/0.6 dashicons;
53
- speak: none;
54
- -webkit-font-smoothing: antialiased;
55
- -moz-osx-font-smoothing: grayscale;
56
- background-image: none !important;
57
- }
58
-
59
- .bp-hello-social li a:hover:before {
60
- transition: all 0.1s ease-in-out;
61
- color: var(--bp-hello-color-primary);
62
- }
63
-
64
- .bp-hello-social li a.support:before {
65
- content: "\f448";
66
- }
67
-
68
- .bp-hello-social li a.twitter:before {
69
- content: "\f301";
70
- }
71
-
72
- div.dashicons {
73
- width: fit-content;
74
- }
75
-
76
- div.dashicons.big {
77
- font-size: 128px;
78
- display: block;
79
- color: var(--bp-hello-color-primary);
80
- height: 128px;
81
- width: 128px;
82
- }
83
-
84
- /*------------------------------------------------------------------------------
85
- * 3.0 - Elements
86
- *----------------------------------------------------------------------------*/
87
- /*
88
- * 3.1 - Modal footer
89
- */
90
- #plugin-information-footer {
91
- display: flex;
92
- flex-wrap: wrap;
93
- padding: 0 16px;
94
- height: auto;
95
- }
96
-
97
- #plugin-information-footer .dashicons-heart {
98
- color: #be3631;
99
- }
100
-
101
- .bp-hello-social-cta,
102
- .bp-hello-social-links {
103
- flex-basis: 50%;
104
- }
105
-
106
- .bp-hello-social-links ul {
107
- display: inline-block;
108
- }
109
-
110
- .bp-hello-social li {
111
- position: relative;
112
- bottom: -5px;
113
- display: inline-block;
114
- list-style-type: none;
115
- margin-bottom: 0;
116
- }
117
-
118
- .bp-hello-social li:last-child a {
119
- margin-right: 4px;
120
- }
121
-
122
- /*
123
- * 3.2 - Modal content
124
- */
125
- #bp-hello-container {
126
- display: none;
127
- }
128
-
129
- .bp-hello-content {
130
- padding: 0 25px;
131
- padding-bottom: 20px;
132
- }
133
-
134
- #dynamic-content {
135
- padding-bottom: 40px;
136
- display: none;
137
- }
138
-
139
- #dynamic-content.show {
140
- display: block;
141
- }
142
-
143
- .plugin-details-modal #TB_title {
144
- /* stylelint-disable-line */
145
- height: 0;
146
- background: none;
147
- border: none;
148
- }
149
-
150
- #TB_window.plugin-details-modal.thickbox-loading:before {
151
- /* stylelint-disable-line */
152
- z-index: 10;
153
- margin-top: 40px;
154
- background-color: none;
155
- }
156
-
157
- .bp-hello-aligncenter * {
158
- margin: 10px auto;
159
- }
160
-
161
- .bp-hello-alignleft {
162
- float: right;
163
- }
164
-
165
- .bp-hello-alignleft:after {
166
- content: "";
167
- clear: right;
168
- }
169
-
170
- .bp-hello-alignright {
171
- float: left;
172
- }
173
-
174
- .bp-hello-alignright:after {
175
- content: "";
176
- clear: left;
177
- }
178
-
179
- .bp-hello-divider {
180
- clear: both;
181
- border: none;
182
- margin-bottom: 20px;
183
- }
184
-
185
- /*------------------------------------------------------------------------------
186
- * 4.0 - Content styles
187
- *----------------------------------------------------------------------------*/
188
- /*
189
- * 4.1 - Footer content
190
- */
191
- .bp-hello-social-cta {
192
- text-align: right;
193
- }
194
-
195
- .bp-hello-social-links {
196
- text-align: left;
197
- }
198
-
199
- .bp-hello-social li a {
200
- text-decoration: none;
201
- }
202
-
203
- /*
204
- * 4.2 - Header content
205
- */
206
- #plugin-information-title.with-banner {
207
- background-image: url(https://ps.w.org/buddypress/assets/banner-772x250.png);
208
- }
209
-
210
- #plugin-information-title h1 {
211
- font-size: 1em;
212
- font-weight: 600;
213
- padding: 0;
214
- margin: 0;
215
- overflow: hidden;
216
- text-overflow: ellipsis;
217
- white-space: nowrap;
218
- }
219
-
220
- #plugin-information-title.with-banner h1 {
221
- position: relative;
222
- font-family: "Helvetica Neue", sans-serif;
223
- display: inline-block;
224
- font-size: 20px;
225
- line-height: 1.68;
226
- box-sizing: border-box;
227
- max-width: 85%;
228
- padding: 0 15px;
229
- margin-top: 30px;
230
- color: #fff;
231
- background: rgba(30, 30, 30, 0.9);
232
- text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
233
- box-shadow: 0 0 30px rgba(255, 255, 255, 0.1);
234
- border-radius: 8px;
235
- }
236
-
237
- /*
238
- * 4.3 - Content content
239
- */
240
- .bp-hello-content {
241
- background-color: white;
242
- }
243
-
244
- /*------------------------------------------------------------------------------
245
- * 5.0 - Media
246
- *----------------------------------------------------------------------------*/
247
- .bp-hello-content img {
248
- border-radius: 2px;
249
- max-width: 100%;
250
- }
251
-
252
- .bp-hello-content iframe {
253
- width: 100%;
254
- }
255
-
256
- .bp-hello-content .bp-hello-alignleft img,
257
- .bp-hello-content .bp-hello-alignright img {
258
- max-width: 200px;
259
- }
260
-
261
- /*------------------------------------------------------------------------------
262
- * 6.0 - Media Queries
263
- *----------------------------------------------------------------------------*/
264
- @media screen and (min-width: 770px) {
265
- #plugin-information-title.with-banner h1 {
266
- font-size: 30px;
267
- line-height: 2;
268
- margin-top: 174px;
269
- max-width: 100%;
270
- }
271
- }
272
-
273
- /*
274
- * 6.1 - Desktop Medium
275
- */
276
- @media only screen and (min-width: 1024px) {
277
- .bp-hello-content {
278
- padding: 0 30px 20px;
279
- }
280
- .bp-hello-content p {
281
- font-size: 14px;
282
- }
283
- }
284
-
285
- /**
286
- * 6.2 - Desktop Large
287
- */
288
- @media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
289
- #plugin-information-title.with-banner {
290
- background-image: url(https://ps.w.org/buddypress/assets/banner-1544x500.png);
291
- }
292
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/admin/css/hello-rtl.min.css DELETED
@@ -1 +0,0 @@
1
- :root{--bp-hello-color-primary:#d34600;--bp-hello-color-secondary:#e5e5e5;--bp-hello-container-size:15%}.bp-hello-content p{font-size:16px}.bp-hello-content ol,.bp-hello-content ul{list-style:inherit}.bp-hello-content h3{font-size:1.1em;font-weight:500}.bp-hello-social li a:before{color:#23282d;font:400 30px/.6 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background-image:none!important}.bp-hello-social li a:hover:before{transition:all .1s ease-in-out;color:var(--bp-hello-color-primary)}.bp-hello-social li a.support:before{content:"\f448"}.bp-hello-social li a.twitter:before{content:"\f301"}div.dashicons{width:fit-content}div.dashicons.big{font-size:128px;display:block;color:var(--bp-hello-color-primary);height:128px;width:128px}#plugin-information-footer{display:flex;flex-wrap:wrap;padding:0 16px;height:auto}#plugin-information-footer .dashicons-heart{color:#be3631}.bp-hello-social-cta,.bp-hello-social-links{flex-basis:50%}.bp-hello-social-links ul{display:inline-block}.bp-hello-social li{position:relative;bottom:-5px;display:inline-block;list-style-type:none;margin-bottom:0}.bp-hello-social li:last-child a{margin-right:4px}#bp-hello-container{display:none}.bp-hello-content{padding:0 25px;padding-bottom:20px}#dynamic-content{padding-bottom:40px;display:none}#dynamic-content.show{display:block}.plugin-details-modal #TB_title{height:0;background:0 0;border:none}#TB_window.plugin-details-modal.thickbox-loading:before{z-index:10;margin-top:40px;background-color:none}.bp-hello-aligncenter *{margin:10px auto}.bp-hello-alignleft{float:right}.bp-hello-alignleft:after{content:"";clear:right}.bp-hello-alignright{float:left}.bp-hello-alignright:after{content:"";clear:left}.bp-hello-divider{clear:both;border:none;margin-bottom:20px}.bp-hello-social-cta{text-align:right}.bp-hello-social-links{text-align:left}.bp-hello-social li a{text-decoration:none}#plugin-information-title.with-banner{background-image:url(https://ps.w.org/buddypress/assets/banner-772x250.png)}#plugin-information-title h1{font-size:1em;font-weight:600;padding:0;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#plugin-information-title.with-banner h1{position:relative;font-family:"Helvetica Neue",sans-serif;display:inline-block;font-size:20px;line-height:1.68;box-sizing:border-box;max-width:85%;padding:0 15px;margin-top:30px;color:#fff;background:rgba(30,30,30,.9);text-shadow:0 1px 3px rgba(0,0,0,.4);box-shadow:0 0 30px rgba(255,255,255,.1);border-radius:8px}.bp-hello-content{background-color:#fff}.bp-hello-content img{border-radius:2px;max-width:100%}.bp-hello-content iframe{width:100%}.bp-hello-content .bp-hello-alignleft img,.bp-hello-content .bp-hello-alignright img{max-width:200px}@media screen and (min-width:770px){#plugin-information-title.with-banner h1{font-size:30px;line-height:2;margin-top:174px;max-width:100%}}@media only screen and (min-width:1024px){.bp-hello-content{padding:0 30px 20px}.bp-hello-content p{font-size:14px}}@media only screen and (-webkit-min-device-pixel-ratio:1.5){#plugin-information-title.with-banner{background-image:url(https://ps.w.org/buddypress/assets/banner-1544x500.png)}}
 
bp-core/admin/css/hello.css DELETED
@@ -1,292 +0,0 @@
1
- /*------------------------------------------------------------------------------
2
- Loaded in wp-admin for query string `hello=buddypress`.
3
-
4
- @since 3.0.0
5
-
6
- --------------------------------------------------------------------------------
7
- TABLE OF CONTENTS:
8
- --------------------------------------------------------------------------------
9
- 1.0 - Typography and colour
10
- 2.0 - Dashicons
11
- 3.0 - Elements
12
- 3.1 - Modal footer
13
- 3.2 - Modal content
14
- 4.0 - Content styles
15
- 4.1 - Footer content
16
- 4.2 - Header content
17
- 4.3 - Content content
18
- 5.0 - Media
19
- 6.0 - Media Queries
20
- 6.1 - Desktop Medium
21
- 6.2 - Desktop Large
22
- ------------------------------------------------------------------------------*/
23
- /*------------------------------------------------------------------------------
24
- * 1.0 - Typography and colour
25
- *----------------------------------------------------------------------------*/
26
- :root {
27
- --bp-hello-color-primary: #d34600;
28
- --bp-hello-color-secondary: #e5e5e5;
29
- --bp-hello-container-size: 15%;
30
- }
31
-
32
- .bp-hello-content p {
33
- font-size: 16px;
34
- }
35
-
36
- .bp-hello-content ul,
37
- .bp-hello-content ol {
38
- list-style: inherit;
39
- }
40
-
41
- .bp-hello-content h3 {
42
- font-size: 1.1em;
43
- font-weight: 500;
44
- }
45
-
46
- /*------------------------------------------------------------------------------
47
- * 2.0 - Dashicons
48
- *----------------------------------------------------------------------------*/
49
- .bp-hello-social li a:before {
50
- color: #23282d;
51
- /* wp toolbar */
52
- font: 400 30px/0.6 dashicons;
53
- speak: none;
54
- -webkit-font-smoothing: antialiased;
55
- -moz-osx-font-smoothing: grayscale;
56
- background-image: none !important;
57
- }
58
-
59
- .bp-hello-social li a:hover:before {
60
- transition: all 0.1s ease-in-out;
61
- color: var(--bp-hello-color-primary);
62
- }
63
-
64
- .bp-hello-social li a.support:before {
65
- content: "\f448";
66
- }
67
-
68
- .bp-hello-social li a.twitter:before {
69
- content: "\f301";
70
- }
71
-
72
- div.dashicons {
73
- width: fit-content;
74
- }
75
-
76
- div.dashicons.big {
77
- font-size: 128px;
78
- display: block;
79
- color: var(--bp-hello-color-primary);
80
- height: 128px;
81
- width: 128px;
82
- }
83
-
84
- /*------------------------------------------------------------------------------
85
- * 3.0 - Elements
86
- *----------------------------------------------------------------------------*/
87
- /*
88
- * 3.1 - Modal footer
89
- */
90
- #plugin-information-footer {
91
- display: flex;
92
- flex-wrap: wrap;
93
- padding: 0 16px;
94
- height: auto;
95
- }
96
-
97
- #plugin-information-footer .dashicons-heart {
98
- color: #be3631;
99
- }
100
-
101
- .bp-hello-social-cta,
102
- .bp-hello-social-links {
103
- flex-basis: 50%;
104
- }
105
-
106
- .bp-hello-social-links ul {
107
- display: inline-block;
108
- }
109
-
110
- .bp-hello-social li {
111
- position: relative;
112
- bottom: -5px;
113
- display: inline-block;
114
- list-style-type: none;
115
- margin-bottom: 0;
116
- }
117
-
118
- .bp-hello-social li:last-child a {
119
- margin-left: 4px;
120
- }
121
-
122
- /*
123
- * 3.2 - Modal content
124
- */
125
- #bp-hello-container {
126
- display: none;
127
- }
128
-
129
- .bp-hello-content {
130
- padding: 0 25px;
131
- padding-bottom: 20px;
132
- }
133
-
134
- #dynamic-content {
135
- padding-bottom: 40px;
136
- display: none;
137
- }
138
-
139
- #dynamic-content.show {
140
- display: block;
141
- }
142
-
143
- .plugin-details-modal #TB_title {
144
- /* stylelint-disable-line */
145
- height: 0;
146
- background: none;
147
- border: none;
148
- }
149
-
150
- #TB_window.plugin-details-modal.thickbox-loading:before {
151
- /* stylelint-disable-line */
152
- z-index: 10;
153
- margin-top: 40px;
154
- background-color: none;
155
- }
156
-
157
- .bp-hello-aligncenter * {
158
- margin: 10px auto;
159
- }
160
-
161
- .bp-hello-alignleft {
162
- float: left;
163
- }
164
-
165
- .bp-hello-alignleft:after {
166
- content: "";
167
- clear: left;
168
- }
169
-
170
- .bp-hello-alignright {
171
- float: right;
172
- }
173
-
174
- .bp-hello-alignright:after {
175
- content: "";
176
- clear: right;
177
- }
178
-
179
- .bp-hello-divider {
180
- clear: both;
181
- border: none;
182
- margin-bottom: 20px;
183
- }
184
-
185
- /*------------------------------------------------------------------------------
186
- * 4.0 - Content styles
187
- *----------------------------------------------------------------------------*/
188
- /*
189
- * 4.1 - Footer content
190
- */
191
- .bp-hello-social-cta {
192
- text-align: left;
193
- }
194
-
195
- .bp-hello-social-links {
196
- text-align: right;
197
- }
198
-
199
- .bp-hello-social li a {
200
- text-decoration: none;
201
- }
202
-
203
- /*
204
- * 4.2 - Header content
205
- */
206
- #plugin-information-title.with-banner {
207
- background-image: url(https://ps.w.org/buddypress/assets/banner-772x250.png);
208
- }
209
-
210
- #plugin-information-title h1 {
211
- font-size: 1em;
212
- font-weight: 600;
213
- padding: 0;
214
- margin: 0;
215
- overflow: hidden;
216
- text-overflow: ellipsis;
217
- white-space: nowrap;
218
- }
219
-
220
- #plugin-information-title.with-banner h1 {
221
- position: relative;
222
- font-family: "Helvetica Neue", sans-serif;
223
- display: inline-block;
224
- font-size: 20px;
225
- line-height: 1.68;
226
- box-sizing: border-box;
227
- max-width: 85%;
228
- padding: 0 15px;
229
- margin-top: 30px;
230
- color: #fff;
231
- background: rgba(30, 30, 30, 0.9);
232
- text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
233
- box-shadow: 0 0 30px rgba(255, 255, 255, 0.1);
234
- border-radius: 8px;
235
- }
236
-
237
- /*
238
- * 4.3 - Content content
239
- */
240
- .bp-hello-content {
241
- background-color: white;
242
- }
243
-
244
- /*------------------------------------------------------------------------------
245
- * 5.0 - Media
246
- *----------------------------------------------------------------------------*/
247
- .bp-hello-content img {
248
- border-radius: 2px;
249
- max-width: 100%;
250
- }
251
-
252
- .bp-hello-content iframe {
253
- width: 100%;
254
- }
255
-
256
- .bp-hello-content .bp-hello-alignleft img,
257
- .bp-hello-content .bp-hello-alignright img {
258
- max-width: 200px;
259
- }
260
-
261
- /*------------------------------------------------------------------------------
262
- * 6.0 - Media Queries
263
- *----------------------------------------------------------------------------*/
264
- @media screen and (min-width: 770px) {
265
- #plugin-information-title.with-banner h1 {
266
- font-size: 30px;
267
- line-height: 2;
268
- margin-top: 174px;
269
- max-width: 100%;
270
- }
271
- }
272
-
273
- /*
274
- * 6.1 - Desktop Medium
275
- */
276
- @media only screen and (min-width: 1024px) {
277
- .bp-hello-content {
278
- padding: 0 30px 20px;
279
- }
280
- .bp-hello-content p {
281
- font-size: 14px;
282
- }
283
- }
284
-
285
- /**
286
- * 6.2 - Desktop Large
287
- */
288
- @media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
289
- #plugin-information-title.with-banner {
290
- background-image: url(https://ps.w.org/buddypress/assets/banner-1544x500.png);
291
- }
292
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/admin/css/hello.min.css DELETED
@@ -1 +0,0 @@
1
- :root{--bp-hello-color-primary:#d34600;--bp-hello-color-secondary:#e5e5e5;--bp-hello-container-size:15%}.bp-hello-content p{font-size:16px}.bp-hello-content ol,.bp-hello-content ul{list-style:inherit}.bp-hello-content h3{font-size:1.1em;font-weight:500}.bp-hello-social li a:before{color:#23282d;font:400 30px/.6 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background-image:none!important}.bp-hello-social li a:hover:before{transition:all .1s ease-in-out;color:var(--bp-hello-color-primary)}.bp-hello-social li a.support:before{content:"\f448"}.bp-hello-social li a.twitter:before{content:"\f301"}div.dashicons{width:fit-content}div.dashicons.big{font-size:128px;display:block;color:var(--bp-hello-color-primary);height:128px;width:128px}#plugin-information-footer{display:flex;flex-wrap:wrap;padding:0 16px;height:auto}#plugin-information-footer .dashicons-heart{color:#be3631}.bp-hello-social-cta,.bp-hello-social-links{flex-basis:50%}.bp-hello-social-links ul{display:inline-block}.bp-hello-social li{position:relative;bottom:-5px;display:inline-block;list-style-type:none;margin-bottom:0}.bp-hello-social li:last-child a{margin-left:4px}#bp-hello-container{display:none}.bp-hello-content{padding:0 25px;padding-bottom:20px}#dynamic-content{padding-bottom:40px;display:none}#dynamic-content.show{display:block}.plugin-details-modal #TB_title{height:0;background:0 0;border:none}#TB_window.plugin-details-modal.thickbox-loading:before{z-index:10;margin-top:40px;background-color:none}.bp-hello-aligncenter *{margin:10px auto}.bp-hello-alignleft{float:left}.bp-hello-alignleft:after{content:"";clear:left}.bp-hello-alignright{float:right}.bp-hello-alignright:after{content:"";clear:right}.bp-hello-divider{clear:both;border:none;margin-bottom:20px}.bp-hello-social-cta{text-align:left}.bp-hello-social-links{text-align:right}.bp-hello-social li a{text-decoration:none}#plugin-information-title.with-banner{background-image:url(https://ps.w.org/buddypress/assets/banner-772x250.png)}#plugin-information-title h1{font-size:1em;font-weight:600;padding:0;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#plugin-information-title.with-banner h1{position:relative;font-family:"Helvetica Neue",sans-serif;display:inline-block;font-size:20px;line-height:1.68;box-sizing:border-box;max-width:85%;padding:0 15px;margin-top:30px;color:#fff;background:rgba(30,30,30,.9);text-shadow:0 1px 3px rgba(0,0,0,.4);box-shadow:0 0 30px rgba(255,255,255,.1);border-radius:8px}.bp-hello-content{background-color:#fff}.bp-hello-content img{border-radius:2px;max-width:100%}.bp-hello-content iframe{width:100%}.bp-hello-content .bp-hello-alignleft img,.bp-hello-content .bp-hello-alignright img{max-width:200px}@media screen and (min-width:770px){#plugin-information-title.with-banner h1{font-size:30px;line-height:2;margin-top:174px;max-width:100%}}@media only screen and (min-width:1024px){.bp-hello-content{padding:0 30px 20px}.bp-hello-content p{font-size:14px}}@media only screen and (-webkit-min-device-pixel-ratio:1.5){#plugin-information-title.with-banner{background-image:url(https://ps.w.org/buddypress/assets/banner-1544x500.png)}}
 
bp-core/admin/js/customizer-controls.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){t(window).on("load",function(){t(".customize-control-range input").on("input",function(){var n=t(this);n.siblings("output").text(n.val())})})}(jQuery);
1
+ !function(n){n(window).on("load",function(){n(".customize-control-range input").on("input",function(){var t=n(this);t.siblings("output").text(t.val())})})}(jQuery);
bp-core/admin/js/customizer-receiver-emails.js CHANGED
@@ -109,7 +109,7 @@
109
 
110
  wp.customize( 'bp_email_options[footer_text]', function( value ) {
111
  value.bind(function( newval ) {
112
- $( '.footer_text' ).html( newval );
113
  });
114
  });
115
  })( jQuery );
109
 
110
  wp.customize( 'bp_email_options[footer_text]', function( value ) {
111
  value.bind(function( newval ) {
112
+ $( '.footer_text' ).text( newval );
113
  });
114
  });
115
  })( jQuery );
bp-core/admin/js/customizer-receiver-emails.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){wp.customize("bp_email_options[email_bg]",function(o){o.bind(function(o){o.length&&(t(".email_bg").attr("bgcolor",o),t("hr").attr("color",o))})}),wp.customize("bp_email_options[header_bg]",function(o){o.bind(function(o){o.length&&t(".header_bg").attr("bgcolor",o)})}),wp.customize("bp_email_options[header_text_size]",function(o){o.bind(function(o){o.length&&t(".header_text_size").css("font-size",o+"px")})}),wp.customize("bp_email_options[header_text_color]",function(o){o.bind(function(o){o.length&&t(".header_text_color").css("color",o)})}),wp.customize("bp_email_options[highlight_color]",function(o){o.bind(function(o){o.length&&(t(".header_bg").css("border-top-color",o),t("a").css("color",o),t("hr").attr("color",o))})}),wp.customize("bp_email_options[body_bg]",function(o){o.bind(function(o){o.length&&t(".body_bg").attr("bgcolor",o)})}),wp.customize("bp_email_options[body_text_size]",function(o){o.bind(function(o){o.length&&(t(".body_text_size").css("font-size",o+"px").css("line-height",Math.floor(1.618*o)+"px"),t(".welcome").css("font-size",Math.floor(1.35*o)+"px"))})}),wp.customize("bp_email_options[body_text_color]",function(o){o.bind(function(o){o.length&&t(".body_text_color").css("color",o)})}),wp.customize("bp_email_options[footer_bg]",function(o){o.bind(function(o){o.length&&t(".footer_bg").attr("bgcolor",o)})}),wp.customize("bp_email_options[footer_text_size]",function(o){o.bind(function(o){o.length&&t(".footer_text_size").css("font-size",o+"px").css("line-height",Math.floor(1.618*o)+"px")})}),wp.customize("bp_email_options[footer_text_color]",function(o){o.bind(function(o){o.length&&t(".footer_text_color").css("color",o)})}),wp.customize("bp_email_options[footer_text]",function(o){o.bind(function(o){t(".footer_text").html(o)})})}(jQuery);
1
+ !function(o){wp.customize("bp_email_options[email_bg]",function(t){t.bind(function(t){t.length&&(o(".email_bg").attr("bgcolor",t),o("hr").attr("color",t))})}),wp.customize("bp_email_options[header_bg]",function(t){t.bind(function(t){t.length&&o(".header_bg").attr("bgcolor",t)})}),wp.customize("bp_email_options[header_text_size]",function(t){t.bind(function(t){t.length&&o(".header_text_size").css("font-size",t+"px")})}),wp.customize("bp_email_options[header_text_color]",function(t){t.bind(function(t){t.length&&o(".header_text_color").css("color",t)})}),wp.customize("bp_email_options[highlight_color]",function(t){t.bind(function(t){t.length&&(o(".header_bg").css("border-top-color",t),o("a").css("color",t),o("hr").attr("color",t))})}),wp.customize("bp_email_options[body_bg]",function(t){t.bind(function(t){t.length&&o(".body_bg").attr("bgcolor",t)})}),wp.customize("bp_email_options[body_text_size]",function(t){t.bind(function(t){t.length&&(o(".body_text_size").css("font-size",t+"px").css("line-height",Math.floor(1.618*t)+"px"),o(".welcome").css("font-size",Math.floor(1.35*t)+"px"))})}),wp.customize("bp_email_options[body_text_color]",function(t){t.bind(function(t){t.length&&o(".body_text_color").css("color",t)})}),wp.customize("bp_email_options[footer_bg]",function(t){t.bind(function(t){t.length&&o(".footer_bg").attr("bgcolor",t)})}),wp.customize("bp_email_options[footer_text_size]",function(t){t.bind(function(t){t.length&&o(".footer_text_size").css("font-size",t+"px").css("line-height",Math.floor(1.618*t)+"px")})}),wp.customize("bp_email_options[footer_text_color]",function(t){t.bind(function(t){t.length&&o(".footer_text_color").css("color",t)})}),wp.customize("bp_email_options[footer_text]",function(t){t.bind(function(t){o(".footer_text").text(t)})})}(jQuery);
bp-core/admin/js/dismissible-admin-notices.min.js CHANGED
@@ -1 +1 @@
1
- !function(s){s(document).ready(function(){s(".bp-is-dismissible .notice-dismiss").click(function(){var i=s(this).closest(".notice"),n=i.data("noticeid");s.post({url:ajaxurl,data:{action:"bp_dismiss_notice",nonce:s("#bp-dismissible-nonce-"+n).val(),notice_id:i.data("noticeid")}})})})}(jQuery);
1
+ !function(i){i(document).ready(function(){i(".bp-is-dismissible .notice-dismiss").click(function(){var n=i(this).closest(".notice"),s=n.data("noticeid");i.post({url:ajaxurl,data:{action:"bp_dismiss_notice",nonce:i("#bp-dismissible-nonce-"+s).val(),notice_id:n.data("noticeid")}})})})}(jQuery);
bp-core/admin/js/hello.js DELETED
@@ -1,125 +0,0 @@
1
- /* global bpHelloStrings */
2
- /**
3
- * Loads for BuddyPress Hello in wp-admin for query string `hello=buddypress`.
4
- *
5
- * @since 3.0.0
6
- */
7
- (function( $, bp ) {
8
- // Bail if not set
9
- if ( typeof bpHelloStrings === 'undefined' ) {
10
- return;
11
- }
12
-
13
- /**
14
- * Open the BuddyPress Hello modal.
15
- */
16
- var bpHelloOpenModal = function() {
17
- if ( 'function' !== typeof window.tb_show ) {
18
- return false;
19
- }
20
-
21
- window.tb_show( 'BuddyPress', '#TB_inline?inlineId=bp-hello-container' );
22
-
23
- $( '#TB_window' ).attr( {
24
- 'role': 'dialog',
25
- 'aria-label': bpHelloStrings.modalLabel
26
- } )
27
- .addClass( 'plugin-details-modal' )
28
- .removeClass( 'thickbox-loading' );
29
-
30
- $( '#TB_ajaxContent' ).prop( 'style', 'height: 100%; width: auto; padding: 0; border: none;' );
31
-
32
- var tabbables = $( ':tabbable', '#TB_ajaxContent' ), lastTabbable = tabbables.last();
33
-
34
- // Move the focus to the Modal's close button once the last Hello link was tabbed out.
35
- $( '#TB_window' ).on( 'keydown', function( event ) {
36
- if ( 9 === event.keyCode && ! event.shiftKey && $( lastTabbable ).prop( 'classList' ).value === $( event.target ).prop( 'classList' ).value ) {
37
- event.preventDefault();
38
-
39
- $( '#TB_closeWindowButton' ).focus();
40
- }
41
-
42
- if ( 9 === event.keyCode && event.shiftKey && 'TB_closeWindowButton' === $( event.target ).prop( 'id' ) ) {
43
- event.preventDefault();
44
-
45
- $( lastTabbable ).focus();
46
- }
47
- } );
48
- };
49
-
50
- /**
51
- * Prints an error message.
52
- *
53
- * @param {string} message The error message to display.
54
- */
55
- var printErrorMessage = function( message ) {
56
- if ( ! message ) {
57
- message = bpHelloStrings.pageNotFound;
58
- }
59
-
60
- $( '#dynamic-content' ).html(
61
- $('<div></div>' ).prop( 'id', 'message' )
62
- .addClass( 'notice notice-error error' )
63
- .html(
64
- $( '<p></p>' ).html( message )
65
- )
66
- );
67
- };
68
-
69
- // Listen to Tab Menu clicks to display the different screens.
70
- $( '#plugin-information-tabs').on( 'click', 'a', function( event ) {
71
- event.preventDefault();
72
-
73
- var anchor = $( event.currentTarget ), target = $( '#dynamic-content' );
74
-
75
- if ( anchor.hasClass( 'dynamic' ) ) {
76
- $( '#top-features' ).hide();
77
- target.html( '' );
78
- target.addClass( 'show' );
79
-
80
- $( '#TB_window' ).addClass( 'thickbox-loading' );
81
-
82
- bp.apiRequest( {
83
- url: anchor.data( 'endpoint' ),
84
- type: 'GET',
85
- beforeSend: function( xhr, settings ) {
86
- settings.url = settings.url.replace( '&_wpnonce=none', '' );
87
- },
88
- data: {
89
- context: 'view',
90
- slug: anchor.data( 'slug' ),
91
- _wpnonce: 'none'
92
- }
93
- } ).done( function( data ) {
94
- var page = _.first( data );
95
-
96
- if ( page && page.content ) {
97
- target.html( page.content.rendered );
98
- } else {
99
- printErrorMessage();
100
- }
101
-
102
- } ).fail( function( error ) {
103
- if ( ! error || ! error.message ) {
104
- return false;
105
- }
106
-
107
- printErrorMessage( error.message );
108
-
109
- } ).always( function() {
110
- $( '#TB_window' ).removeClass( 'thickbox-loading' );
111
- } );
112
-
113
- } else {
114
- $( '#top-features' ).show();
115
- target.html( '' );
116
- target.removeClass( 'show' );
117
- }
118
- } );
119
-
120
- // Init modal after the screen's loaded.
121
- $( document ).ready( function() {
122
- bpHelloOpenModal();
123
- } );
124
-
125
- }( jQuery, window.bp || {} ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/admin/js/hello.min.js DELETED
@@ -1 +0,0 @@
1
- !function(o,t){var a;"undefined"!=typeof bpHelloStrings&&(a=function(e){e=e||bpHelloStrings.pageNotFound,o("#dynamic-content").html(o("<div></div>").prop("id","message").addClass("notice notice-error error").html(o("<p></p>").html(e)))},o("#plugin-information-tabs").on("click","a",function(e){e.preventDefault();var e=o(e.currentTarget),n=o("#dynamic-content");e.hasClass("dynamic")?(o("#top-features").hide(),n.html(""),n.addClass("show"),o("#TB_window").addClass("thickbox-loading"),t.apiRequest({url:e.data("endpoint"),type:"GET",beforeSend:function(e,n){n.url=n.url.replace("&_wpnonce=none","")},data:{context:"view",slug:e.data("slug"),_wpnonce:"none"}}).done(function(e){e=_.first(e);e&&e.content?n.html(e.content.rendered):a()}).fail(function(e){return!(!e||!e.message)&&void a(e.message)}).always(function(){o("#TB_window").removeClass("thickbox-loading")})):(o("#top-features").show(),n.html(""),n.removeClass("show"))}),o(document).ready(function(){!function(){if("function"!=typeof window.tb_show)return;window.tb_show("BuddyPress","#TB_inline?inlineId=bp-hello-container"),o("#TB_window").attr({role:"dialog","aria-label":bpHelloStrings.modalLabel}).addClass("plugin-details-modal").removeClass("thickbox-loading"),o("#TB_ajaxContent").prop("style","height: 100%; width: auto; padding: 0; border: none;");var n=o(":tabbable","#TB_ajaxContent").last();o("#TB_window").on("keydown",function(e){9!==e.keyCode||e.shiftKey||o(n).prop("classList").value!==o(e.target).prop("classList").value||(e.preventDefault(),o("#TB_closeWindowButton").focus()),9===e.keyCode&&e.shiftKey&&"TB_closeWindowButton"===o(e.target).prop("id")&&(e.preventDefault(),o(n).focus())})}()}))}(jQuery,window.bp||{});
 
bp-core/admin/js/types-admin.js DELETED
@@ -1,41 +0,0 @@
1
- ( function() {
2
- var bpTypesCustomizeForm = function() {
3
- if ( document.querySelector( '#addtag input[name="post_type"]' ) ) {
4
- document.querySelector( '#addtag input[name="post_type"]' ).remove();
5
- }
6
-
7
- if ( document.querySelectorAll( '.form-field' ) ) {
8
- document.querySelectorAll( '.form-field' ).forEach( function( element ) {
9
- if ( -1 === element.classList.value.indexOf( 'bp-types-form' ) ) {
10
- element.remove();
11
- }
12
- } );
13
- }
14
-
15
- if ( document.querySelector( '#bp_type_has_directory' ) ) {
16
- if ( true === document.querySelector( '#bp_type_has_directory' ).checked ) {
17
- document.querySelector( '.term-bp_type_directory_slug-wrap' ).classList.add( 'bp-set-directory-slug' );
18
- }
19
-
20
- document.querySelector( '#bp_type_has_directory' ).addEventListener( 'change', function( event ) {
21
- if ( true === event.target.checked ) {
22
- document.querySelector( '.term-bp_type_directory_slug-wrap' ).classList.add( 'bp-set-directory-slug' );
23
- document.querySelector( '#bp_type_directory_slug' ).removeAttribute( 'disabled' );
24
- } else {
25
- document.querySelector( '.term-bp_type_directory_slug-wrap' ).classList.remove( 'bp-set-directory-slug' );
26
- document.querySelector( '#bp_type_directory_slug' ).setAttribute( 'disabled', 'disabled' );
27
- }
28
- } );
29
- }
30
-
31
- if ( document.querySelector( '#delete-link' ) ) {
32
- document.querySelector( '#delete-link' ).remove();
33
- }
34
- };
35
-
36
- if ( 'loading' === document.readyState ) {
37
- document.addEventListener( 'DOMContentLoaded', bpTypesCustomizeForm );
38
- } else {
39
- bpTypesCustomizeForm;
40
- }
41
- } )();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/admin/js/types-admin.min.js DELETED
@@ -1 +0,0 @@
1
- !function(){function e(){document.querySelector('#addtag input[name="post_type"]')&&document.querySelector('#addtag input[name="post_type"]').remove(),document.querySelectorAll(".form-field")&&document.querySelectorAll(".form-field").forEach(function(e){-1===e.classList.value.indexOf("bp-types-form")&&e.remove()}),document.querySelector("#bp_type_has_directory")&&(!0===document.querySelector("#bp_type_has_directory").checked&&document.querySelector(".term-bp_type_directory_slug-wrap").classList.add("bp-set-directory-slug"),document.querySelector("#bp_type_has_directory").addEventListener("change",function(e){!0===e.target.checked?(document.querySelector(".term-bp_type_directory_slug-wrap").classList.add("bp-set-directory-slug"),document.querySelector("#bp_type_directory_slug").removeAttribute("disabled")):(document.querySelector(".term-bp_type_directory_slug-wrap").classList.remove("bp-set-directory-slug"),document.querySelector("#bp_type_directory_slug").setAttribute("disabled","disabled"))})),document.querySelector("#delete-link")&&document.querySelector("#delete-link").remove()}"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",e)}();
 
bp-core/admin/sass/hello.scss DELETED
@@ -1,327 +0,0 @@
1
- /*------------------------------------------------------------------------------
2
- Loaded in wp-admin for query string `hello=buddypress`.
3
-
4
- @since 3.0.0
5
-
6
- --------------------------------------------------------------------------------
7
- TABLE OF CONTENTS:
8
- --------------------------------------------------------------------------------
9
- 1.0 - Typography and colour
10
- 2.0 - Dashicons
11
- 3.0 - Elements
12
- 3.1 - Modal footer
13
- 3.2 - Modal content
14
- 4.0 - Content styles
15
- 4.1 - Footer content
16
- 4.2 - Header content
17
- 4.3 - Content content
18
- 5.0 - Media
19
- 6.0 - Media Queries
20
- 6.1 - Desktop Medium
21
- 6.2 - Desktop Large
22
- ------------------------------------------------------------------------------*/
23
-
24
- /*------------------------------------------------------------------------------
25
- * 1.0 - Typography and colour
26
- *----------------------------------------------------------------------------*/
27
- :root {
28
- --bp-hello-color-primary: #d34600;
29
- --bp-hello-color-secondary: #e5e5e5;
30
- --bp-hello-container-size: 15%;
31
- }
32
-
33
- .bp-hello-content {
34
-
35
- p {
36
- font-size: 16px;
37
- }
38
-
39
- ul,
40
- ol {
41
- list-style: inherit;
42
- }
43
-
44
- h3 {
45
- font-size: 1.1em;
46
- font-weight: 500;
47
- }
48
- }
49
-
50
- /*------------------------------------------------------------------------------
51
- * 2.0 - Dashicons
52
- *----------------------------------------------------------------------------*/
53
- .bp-hello-social {
54
-
55
- li a {
56
-
57
- &:before {
58
- color: #23282d; /* wp toolbar */
59
- font: 400 30px/0.6 dashicons;
60
- speak: none;
61
- -webkit-font-smoothing: antialiased;
62
- -moz-osx-font-smoothing: grayscale;
63
- background-image: none !important;
64
- }
65
-
66
- &:hover:before {
67
- -webkit-transition: all 0.1s ease-in-out;
68
- -o-transition: all 0.1s ease-in-out;
69
- transition: all 0.1s ease-in-out;
70
- color: var(--bp-hello-color-primary);
71
- }
72
-
73
- &.support:before {
74
- content: "\f448";
75
- }
76
-
77
- &.twitter:before {
78
- content: "\f301";
79
- }
80
- }
81
- }
82
-
83
- div.dashicons {
84
-
85
- width: fit-content;
86
-
87
- &.big {
88
- font-size: 128px;
89
- display: block;
90
- color: var(--bp-hello-color-primary);
91
- height: 128px;
92
- width: 128px;
93
- }
94
- }
95
-
96
- /*------------------------------------------------------------------------------
97
- * 3.0 - Elements
98
- *----------------------------------------------------------------------------*/
99
-
100
- /*
101
- * 3.1 - Modal footer
102
- */
103
- #plugin-information-footer {
104
-
105
- display: flex;
106
- flex-wrap: wrap;
107
- padding: 0 16px;
108
- height: auto;
109
-
110
- .dashicons-heart {
111
- color: #be3631;
112
- }
113
- }
114
-
115
- .bp-hello-social-cta,
116
- .bp-hello-social-links {
117
- -ms-flex-preferred-size: 50%;
118
- flex-basis: 50%;
119
- }
120
-
121
- .bp-hello-social-links {
122
-
123
- ul {
124
- display: inline-block;
125
- }
126
- }
127
-
128
- .bp-hello-social {
129
-
130
- li {
131
- position: relative;
132
- bottom: -5px;
133
- display: inline-block;
134
- list-style-type: none;
135
- margin-bottom: 0;
136
-
137
- &:last-child a {
138
- margin-left: 4px;
139
- }
140
- }
141
- }
142
-
143
- /*
144
- * 3.2 - Modal content
145
- */
146
-
147
- #bp-hello-container {
148
- display: none;
149
- }
150
-
151
- .bp-hello-content {
152
- padding: 0 25px;
153
- padding-bottom: 20px;
154
- }
155
-
156
- #dynamic-content {
157
- padding-bottom: 40px;
158
- display: none;
159
-
160
- &.show {
161
- display: block;
162
- }
163
- }
164
-
165
- .plugin-details-modal #TB_title { /* stylelint-disable-line */
166
- height: 0;
167
- background: none;
168
- border: none;
169
- }
170
-
171
- #TB_window.plugin-details-modal.thickbox-loading:before { /* stylelint-disable-line */
172
- z-index: 10;
173
- margin-top: 40px;
174
- background-color: none;
175
- }
176
-
177
- .bp-hello-aligncenter * {
178
- margin: 10px auto;
179
- }
180
-
181
- .bp-hello-alignleft {
182
- float: left;
183
-
184
- &:after {
185
- content: "";
186
- clear: left;
187
- }
188
- }
189
-
190
- .bp-hello-alignright {
191
- float: right;
192
-
193
- &:after {
194
- content: "";
195
- clear: right;
196
- }
197
- }
198
-
199
- .bp-hello-divider {
200
- clear: both;
201
- border: none;
202
- margin-bottom: 20px;
203
- }
204
-
205
- /*------------------------------------------------------------------------------
206
- * 4.0 - Content styles
207
- *----------------------------------------------------------------------------*/
208
-
209
- /*
210
- * 4.1 - Footer content
211
- */
212
- .bp-hello-social-cta {
213
- text-align: left;
214
- }
215
-
216
- .bp-hello-social-links {
217
- text-align: right;
218
- }
219
-
220
- .bp-hello-social {
221
-
222
- li {
223
-
224
- a {
225
- text-decoration: none;
226
- }
227
- }
228
- }
229
-
230
- /*
231
- * 4.2 - Header content
232
- */
233
- #plugin-information-title.with-banner {
234
- background-image: url(https://ps.w.org/buddypress/assets/banner-772x250.png);
235
- }
236
-
237
- #plugin-information-title h1 {
238
- font-size: 1em;
239
- font-weight: 600;
240
- padding: 0;
241
- margin: 0;
242
- overflow: hidden;
243
- text-overflow: ellipsis;
244
- white-space: nowrap;
245
- }
246
-
247
- #plugin-information-title.with-banner h1 {
248
- position: relative;
249
- font-family: "Helvetica Neue", sans-serif;
250
- display: inline-block;
251
- font-size: 20px;
252
- line-height: 1.68;
253
- box-sizing: border-box;
254
- max-width: 85%;
255
- padding: 0 15px;
256
- margin-top: 30px;
257
- color: #fff;
258
- background: rgba(30, 30, 30, 0.9);
259
- text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
260
- box-shadow: 0 0 30px rgba(255, 255, 255, 0.1);
261
- border-radius: 8px;
262
- }
263
-
264
- /*
265
- * 4.3 - Content content
266
- */
267
- .bp-hello-content {
268
- background-color: rgb(255, 255, 255);
269
- }
270
-
271
- /*------------------------------------------------------------------------------
272
- * 5.0 - Media
273
- *----------------------------------------------------------------------------*/
274
- .bp-hello-content {
275
-
276
- img {
277
- border-radius: 2px;
278
- max-width: 100%;
279
- }
280
-
281
- iframe {
282
- width: 100%;
283
- }
284
-
285
- .bp-hello-alignleft img,
286
- .bp-hello-alignright img {
287
- max-width: 200px;
288
- }
289
- }
290
-
291
- /*------------------------------------------------------------------------------
292
- * 6.0 - Media Queries
293
- *----------------------------------------------------------------------------*/
294
-
295
- @media screen and (min-width: 770px) {
296
-
297
- #plugin-information-title.with-banner h1 {
298
- font-size: 30px;
299
- line-height: 2;
300
- margin-top: 174px;
301
- max-width: 100%;
302
- }
303
- }
304
-
305
- /*
306
- * 6.1 - Desktop Medium
307
- */
308
- @media only screen and (min-width: 1024px) {
309
-
310
- .bp-hello-content {
311
- padding: 0 30px 20px;
312
- }
313
-
314
- .bp-hello-content p {
315
- font-size: 14px;
316
- }
317
- }
318
-
319
- /**
320
- * 6.2 - Desktop Large
321
- */
322
- @media only screen and ( -webkit-min-device-pixel-ratio: 1.5 ) {
323
-
324
- #plugin-information-title.with-banner {
325
- background-image: url(https://ps.w.org/buddypress/assets/banner-1544x500.png);
326
- }
327
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/bp-core-actions.php CHANGED
@@ -75,25 +75,15 @@ add_action( 'bp_init', 'bp_setup_globals', 4 );
75
  add_action( 'bp_init', 'bp_setup_canonical_stack', 5 );
76
  add_action( 'bp_init', 'bp_setup_nav', 6 );
77
  add_action( 'bp_init', 'bp_setup_title', 8 );
78
- add_action( 'bp_init', 'bp_blocks_init', 10 );
79
  add_action( 'bp_init', 'bp_core_load_admin_bar_css', 12 );
80
  add_action( 'bp_init', 'bp_add_rewrite_tags', 20 );
81
  add_action( 'bp_init', 'bp_add_rewrite_rules', 30 );
82
  add_action( 'bp_init', 'bp_add_permastructs', 40 );
83
 
84
  /**
85
- * The bp_register_taxonomies hooks - Attached to 'bp_init' @ priority 2 above.
86
  */
87
  add_action( 'bp_register_taxonomies', 'bp_register_member_types' );
88
- add_action( 'bp_register_taxonomies', 'bp_register_type_metadata', 20 );
89
-
90
- /**
91
- * Late includes.
92
- *
93
- * Run after the canonical stack is setup to allow for conditional includes
94
- * on certain pages.
95
- */
96
- add_action( 'bp_setup_canonical_stack', 'bp_late_include', 20 );
97
 
98
  /**
99
  * The bp_template_redirect hook - Attached to 'template_redirect' above.
@@ -115,9 +105,8 @@ add_action( 'bp_template_redirect', 'bp_get_request', 10 );
115
  /**
116
  * Add the BuddyPress functions file and the Theme Compat Default features.
117
  */
118
- add_action( 'bp_after_setup_theme', 'bp_check_theme_template_pack_dependency', -10 );
119
- add_action( 'bp_after_setup_theme', 'bp_load_theme_functions', 1 );
120
- add_action( 'bp_after_setup_theme', 'bp_register_theme_compat_default_features', 10 );
121
 
122
  // Load the admin.
123
  if ( is_admin() ) {
75
  add_action( 'bp_init', 'bp_setup_canonical_stack', 5 );
76
  add_action( 'bp_init', 'bp_setup_nav', 6 );
77
  add_action( 'bp_init', 'bp_setup_title', 8 );
 
78
  add_action( 'bp_init', 'bp_core_load_admin_bar_css', 12 );
79
  add_action( 'bp_init', 'bp_add_rewrite_tags', 20 );
80
  add_action( 'bp_init', 'bp_add_rewrite_rules', 30 );
81
  add_action( 'bp_init', 'bp_add_permastructs', 40 );
82
 
83
  /**
84
+ * The bp_register_taxonomies hook - Attached to 'bp_init' @ priority 2 above.
85
  */
86
  add_action( 'bp_register_taxonomies', 'bp_register_member_types' );
 
 
 
 
 
 
 
 
 
87
 
88
  /**
89
  * The bp_template_redirect hook - Attached to 'template_redirect' above.
105
  /**
106
  * Add the BuddyPress functions file and the Theme Compat Default features.
107
  */
108
+ add_action( 'bp_after_setup_theme', 'bp_load_theme_functions', 1 );
109
+ add_action( 'bp_after_setup_theme', 'bp_register_theme_compat_default_features', 10 );
 
110
 
111
  // Load the admin.
112
  if ( is_admin() ) {
bp-core/bp-core-admin.php CHANGED
@@ -54,6 +54,5 @@ function bp_admin() {
54
  'buddypress'
55
  );
56
 
57
- /* translators: %s: the link to the BuddyPress release notes */
58
  __( 'For more information, see <a href="%s">the release notes</a>.', 'buddypress' );
59
  }
54
  'buddypress'
55
  );
56
 
 
57
  __( 'For more information, see <a href="%s">the release notes</a>.', 'buddypress' );
58
  }
bp-core/bp-core-adminbar.php CHANGED
@@ -30,7 +30,7 @@ function bp_admin_bar_my_account_root() {
30
  if ( is_user_logged_in() ) {
31
 
32
  // Add secondary parent item for all BuddyPress components.
33
- $wp_admin_bar->add_node( array(
34
  'parent' => 'my-account',
35
  'id' => 'my-account-buddypress',
36
  'title' => __( 'My Account', 'buddypress' ),
@@ -44,20 +44,41 @@ function bp_admin_bar_my_account_root() {
44
  add_action( 'admin_bar_menu', 'bp_admin_bar_my_account_root', 100 );
45
 
46
  /**
47
- * Toggle the display of the toolbar based on certain conditions.
48
  *
49
  * @since 1.2.0
 
 
50
  */
51
  function bp_core_load_admin_bar() {
 
52
  // Show the Toolbar for logged out users.
53
  if ( ! is_user_logged_in() && (int) bp_get_option( 'hide-loggedout-adminbar' ) != 1 ) {
54
  show_admin_bar( true );
55
  }
56
 
57
- // Hide the WordPress Toolbar.
58
  if ( ! bp_use_wp_admin_bar() ) {
 
 
 
 
 
 
 
59
  // Keep the WP Toolbar from loading.
60
  show_admin_bar( false );
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
  }
63
  add_action( 'init', 'bp_core_load_admin_bar', 9 );
30
  if ( is_user_logged_in() ) {
31
 
32
  // Add secondary parent item for all BuddyPress components.
33
+ $wp_admin_bar->add_menu( array(
34
  'parent' => 'my-account',
35
  'id' => 'my-account-buddypress',
36
  'title' => __( 'My Account', 'buddypress' ),
44
  add_action( 'admin_bar_menu', 'bp_admin_bar_my_account_root', 100 );
45
 
46
  /**
47
+ * Handle the Toolbar/BuddyBar business.
48
  *
49
  * @since 1.2.0
50
+ *
51
+ * @global string $wp_version
52
  */
53
  function bp_core_load_admin_bar() {
54
+
55
  // Show the Toolbar for logged out users.
56
  if ( ! is_user_logged_in() && (int) bp_get_option( 'hide-loggedout-adminbar' ) != 1 ) {
57
  show_admin_bar( true );
58
  }
59
 
60
+ // Hide the WordPress Toolbar and show the BuddyBar.
61
  if ( ! bp_use_wp_admin_bar() ) {
62
+ _doing_it_wrong( __FUNCTION__, __( 'The BuddyBar is no longer supported. Please migrate to the WordPress toolbar as soon as possible.', 'buddypress' ), '2.1.0' );
63
+
64
+ // Load deprecated code if not available.
65
+ if ( ! function_exists( 'bp_core_admin_bar' ) ) {
66
+ require buddypress()->plugin_dir . 'bp-core/deprecated/2.1.php';
67
+ }
68
+
69
  // Keep the WP Toolbar from loading.
70
  show_admin_bar( false );
71
+
72
+ // Actions used to build the BP Toolbar.
73
+ add_action( 'bp_adminbar_logo', 'bp_adminbar_logo' );
74
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu', 2 );
75
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
76
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_thisblog_menu', 6 );
77
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );
78
+
79
+ // Actions used to append BP Toolbar to footer.
80
+ add_action( 'wp_footer', 'bp_core_admin_bar', 8 );
81
+ add_action( 'admin_footer', 'bp_core_admin_bar' );
82
  }
83
  }
84
  add_action( 'init', 'bp_core_load_admin_bar', 9 );
bp-core/bp-core-attachments.php CHANGED
@@ -10,6 +10,21 @@
10
  // Exit if accessed directly.
11
  defined( 'ABSPATH' ) || exit;
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  /**
14
  * Get the Attachments Uploads dir data.
15
  *
@@ -68,58 +83,6 @@ function bp_attachments_uploads_dir_get( $data = '' ) {
68
  return apply_filters( 'bp_attachments_uploads_dir_get', $retval, $data );
69
  }
70
 
71
- /**
72
- * Gets the upload dir array for cover images.
73
- *
74
- * @since 3.0.0
75
- *
76
- * @return array See wp_upload_dir().
77
- */
78
- function bp_attachments_cover_image_upload_dir( $args = array() ) {
79
- // Default values are for members.
80
- $object_id = bp_displayed_user_id();
81
-
82
- if ( empty( $object_id ) ) {
83
- $object_id = bp_loggedin_user_id();
84
- }
85
-
86
- $object_directory = 'members';
87
-
88
- // We're in a group, edit default values.
89
- if ( bp_is_group() || bp_is_group_create() ) {
90
- $object_id = bp_get_current_group_id();
91
- $object_directory = 'groups';
92
- }
93
-
94
- $r = bp_parse_args( $args, array(
95
- 'object_id' => $object_id,
96
- 'object_directory' => $object_directory,
97
- ), 'cover_image_upload_dir' );
98
-
99
-
100
- // Set the subdir.
101
- $subdir = '/' . $r['object_directory'] . '/' . $r['object_id'] . '/cover-image';
102
-
103
- $upload_dir = bp_attachments_uploads_dir_get();
104
-
105
- /**
106
- * Filters the cover image upload directory.
107
- *
108
- * @since 2.4.0
109
- *
110
- * @param array $value Array containing the path, URL, and other helpful settings.
111
- * @param array $upload_dir The original Uploads dir.
112
- */
113
- return apply_filters( 'bp_attachments_cover_image_upload_dir', array(
114
- 'path' => $upload_dir['basedir'] . $subdir,
115
- 'url' => set_url_scheme( $upload_dir['baseurl'] ) . $subdir,
116
- 'subdir' => $subdir,
117
- 'basedir' => $upload_dir['basedir'],
118
- 'baseurl' => set_url_scheme( $upload_dir['baseurl'] ),
119
- 'error' => false,
120
- ), $upload_dir );
121
- }
122
-
123
  /**
124
  * Get the max upload file size for any attachment.
125
  *
@@ -272,7 +235,7 @@ function bp_attachments_check_filetype( $file, $filename, $allowed_mimes ) {
272
  * @param array $args {
273
  * @type int $item_id The ID of the object (Required). Default: 0.
274
  * @type string $object The object type (eg: group, user, blog) (Required). Default: 'user'.
275
- * @type string $component The component for the object (eg: groups, members, blogs). Default: ''.
276
  * @type string $image The absolute path to the image (Required). Default: ''.
277
  * @type int $crop_w Crop width. Default: 0.
278
  * @type int $crop_h Crop height. Default: 0.
@@ -309,7 +272,7 @@ function bp_attachments_create_item_type( $type = 'avatar', $args = array() ) {
309
  // Set the component if not already done.
310
  if ( empty( $r['component'] ) ) {
311
  if ( 'user' === $r['object'] ) {
312
- $r['component'] = 'members';
313
  } else {
314
  $r['component'] = $r['object'] . 's';
315
  }
@@ -341,15 +304,15 @@ function bp_attachments_create_item_type( $type = 'avatar', $args = array() ) {
341
  if ( is_callable( $r['component'] . '_avatar_upload_dir' ) ) {
342
  $dir_args = array( $r['item_id'] );
343
 
344
- // In case of members, we need an extra argument.
345
- if ( 'members' === $r['component'] ) {
346
  $dir_args = array( false, $r['item_id'] );
347
  }
348
 
349
  $attachment_data = call_user_func_array( $r['component'] . '_avatar_upload_dir', $dir_args );
350
  }
351
  } elseif ( 'cover_image' === $type ) {
352
- $attachment_data = bp_attachments_cover_image_upload_dir();
353
 
354
  // The BP Attachments Uploads Dir is not set, stop.
355
  if ( ! $attachment_data ) {
@@ -359,7 +322,7 @@ function bp_attachments_create_item_type( $type = 'avatar', $args = array() ) {
359
  // Default to members for xProfile.
360
  $object_subdir = 'members';
361
 
362
- if ( 'members' !== $r['component'] ) {
363
  $object_subdir = sanitize_key( $r['component'] );
364
  }
365
 
@@ -467,9 +430,8 @@ function bp_attachments_get_attachment( $data = 'url', $args = array() ) {
467
  * Defaults to 'cover-image'
468
  * @type string $file The name of the file.
469
  * }
470
- * @param string $data The requested data `url` or `path`.
471
  */
472
- $pre_filter = apply_filters( 'bp_attachments_pre_get_attachment', null, $r, $data );
473
  if ( $pre_filter !== null ) {
474
  return $pre_filter;
475
  }
@@ -550,7 +512,7 @@ function bp_attachments_delete_file( $args = array() ) {
550
  * @since 2.5.1
551
  *
552
  * @param bool $value Whether or not to delete the BuddyPress attachment.
553
- * @param array $args Array of arguments for the attachment deletion.
554
  */
555
  if ( ! apply_filters( 'bp_attachments_pre_delete_file', true, $args ) ) {
556
  return true;
@@ -630,19 +592,9 @@ function bp_attachments_get_plupload_default_settings() {
630
  * @return array Plupload default localization strings.
631
  */
632
  function bp_attachments_get_plupload_l10n() {
633
- /**
634
- * Use this filter to edit localization strings.
635
- *
636
- * @since 2.3.0
637
- *
638
- * @param array $value An associative array of the localization strings.
639
- */
640
- return apply_filters(
641
- 'bp_attachments_get_plupload_l10n',
642
- array(
643
  'queue_limit_exceeded' => __( 'You have attempted to queue too many files.', 'buddypress' ),
644
-
645
- /* translators: %s: File name. */
646
  'file_exceeds_size_limit' => __( '%s exceeds the maximum upload size for this site.', 'buddypress' ),
647
  'zero_byte_file' => __( 'This file is empty. Please try another.', 'buddypress' ),
648
  'invalid_filetype' => __( 'This file type is not allowed. Please try another.', 'buddypress' ),
@@ -654,11 +606,7 @@ function bp_attachments_get_plupload_l10n() {
654
  'upload_limit_exceeded' => __( 'You may only upload 1 file.', 'buddypress' ),
655
  'http_error' => __( 'HTTP error.', 'buddypress' ),
656
  'upload_failed' => __( 'Upload failed.', 'buddypress' ),
657
-
658
- /* translators: 1: Opening link tag, 2: Closing link tag. */
659
  'big_upload_failed' => __( 'Please try uploading this file with the %1$sbrowser uploader%2$s.', 'buddypress' ),
660
-
661
- /* translators: %s: File name. */
662
  'big_upload_queued' => __( '%s exceeds the maximum upload size for the multi-file uploader when used in your browser.', 'buddypress' ),
663
  'io_error' => __( 'IO error.', 'buddypress' ),
664
  'security_error' => __( 'Security error.', 'buddypress' ),
@@ -667,12 +615,9 @@ function bp_attachments_get_plupload_l10n() {
667
  'dismiss' => __( 'Dismiss', 'buddypress' ),
668
  'crunching' => __( 'Crunching&hellip;', 'buddypress' ),
669
  'unique_file_warning' => __( 'Make sure to upload a unique file', 'buddypress' ),
670
-
671
- /* translators: %s: File name. */
672
  'error_uploading' => __( '&#8220;%s&#8221; has failed to upload.', 'buddypress' ),
673
  'has_avatar_warning' => __( 'If you&#39;d like to delete the existing profile photo but not upload a new one, please use the delete tab.', 'buddypress' )
674
- )
675
- );
676
  }
677
 
678
  /**
@@ -821,8 +766,8 @@ function bp_attachments_enqueue_scripts( $class = '' ) {
821
  // Cover images only need 1 file and 1 only!
822
  $defaults['multi_selection'] = false;
823
 
824
- // Default cover component is members.
825
- $cover_component = 'members';
826
 
827
  // Get the object we're editing the cover image of.
828
  $object = $defaults['multipart_params']['bp_params']['object'];
@@ -839,11 +784,10 @@ function bp_attachments_enqueue_scripts( $class = '' ) {
839
  // Set warning messages.
840
  $strings['cover_image_warnings'] = apply_filters( 'bp_attachments_cover_image_ui_warnings', array(
841
  'dimensions' => sprintf(
842
- /* translators: 1: the advised width size in pixels. 2: the advised height size in pixels. */
843
- __( 'For better results, make sure to upload an image that is larger than %1$spx wide, and %2$spx tall.', 'buddypress' ),
844
- (int) $cover_dimensions['width'],
845
- (int) $cover_dimensions['height']
846
- ),
847
  ) );
848
  }
849
 
@@ -917,7 +861,7 @@ function bp_attachments_current_user_can( $capability, $args = array() ) {
917
  $can = (bool) groups_is_user_admin( bp_loggedin_user_id(), $args['item_id'] ) || bp_current_user_can( 'bp_moderate' );
918
  }
919
  // User profile photo.
920
- } elseif ( bp_is_active( 'members' ) && 'user' === $args['object'] ) {
921
  $can = bp_loggedin_user_id() === (int) $args['item_id'] || bp_current_user_can( 'bp_moderate' );
922
  }
923
  /**
@@ -977,25 +921,23 @@ function bp_attachments_json_response( $success, $is_html4 = false, $data = null
977
  * @return bool
978
  */
979
  function bp_attachments_get_template_part( $slug ) {
980
- $switched = false;
981
 
982
- /*
983
- * Use bp-legacy attachment template part for older bp-default themes or if in
984
- * admin area.
985
- */
986
- if ( ! bp_use_theme_compat_with_current_theme() || ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) ) {
987
- $current = bp_get_theme_compat_id();
988
- if ( 'legacy' !== $current ) {
989
- $switched = true;
990
- bp_setup_theme_compat( 'legacy' );
991
  }
992
- }
993
 
994
- // Load the template part.
995
- bp_get_template_part( 'assets/_attachments/' . $slug );
996
 
997
- if ( $switched ) {
998
- bp_setup_theme_compat( $current );
 
999
  }
1000
  }
1001
 
@@ -1006,10 +948,10 @@ function bp_attachments_get_template_part( $slug ) {
1006
  *
1007
  * @since 2.4.0
1008
  *
1009
- * @param string $component The component to get the settings for ("members" for user or "groups").
1010
  * @return false|array The cover image settings in array, false on failure.
1011
  */
1012
- function bp_attachments_get_cover_image_settings( $component = 'members' ) {
1013
  // Default parameters.
1014
  $args = array();
1015
 
@@ -1020,42 +962,24 @@ function bp_attachments_get_cover_image_settings( $component = 'members' ) {
1020
  $args = (array) $cover_image;
1021
  }
1022
 
1023
- // Set default args.
1024
- $default_args = wp_parse_args(
1025
- $args,
1026
- array(
1027
- 'components' => array(),
1028
- 'width' => 1300,
1029
- 'height' => 225,
1030
- 'callback' => '',
1031
- 'theme_handle' => '',
1032
- 'default_cover' => '',
1033
- )
1034
- );
1035
-
1036
- // Handle deprecated xProfile fitler.
1037
- if ( 'members' === $component ) {
1038
- /** This filter is documented in wp-includes/deprecated.php */
1039
- $args = apply_filters_deprecated( 'bp_before_xprofile_cover_image_settings_parse_args', array( $default_args ), '6.0.0', 'bp_before_members_cover_image_settings_parse_args' );
1040
- }
1041
-
1042
  /**
1043
  * Then let people override/set the feature using this dynamic filter
1044
  *
1045
  * Eg: for the user's profile cover image use:
1046
- * add_filter( 'bp_before_members_cover_image_settings_parse_args', 'your_filter', 10, 1 );
1047
  *
1048
  * @since 2.4.0
1049
  *
1050
  * @param array $settings The cover image settings
1051
  */
1052
- $settings = bp_parse_args( $args, $default_args, $component . '_cover_image_settings' );
1053
-
1054
- // Handle deprecated xProfile fitler.
1055
- if ( 'members' === $component ) {
1056
- /** This filter is documented in wp-includes/deprecated.php */
1057
- $settings = apply_filters_deprecated( 'bp_after_xprofile_cover_image_settings_parse_args', array( $settings ), '6.0.0', 'bp_after_members_cover_image_settings_parse_args' );
1058
- }
 
1059
 
1060
  if ( empty( $settings['components'] ) || empty( $settings['callback'] ) || empty( $settings['theme_handle'] ) ) {
1061
  return false;
@@ -1075,10 +999,10 @@ function bp_attachments_get_cover_image_settings( $component = 'members' ) {
1075
  *
1076
  * @since 2.4.0
1077
  *
1078
- * @param string $component The BuddyPress component concerned ("members" for user or "groups").
1079
  * @return array|bool An associative array containing the advised width and height for the cover image. False if settings are empty.
1080
  */
1081
- function bp_attachments_get_cover_image_dimensions( $component = 'members' ) {
1082
  // Let's prevent notices when setting the warning strings.
1083
  $default = array( 'width' => 0, 'height' => 0 );
1084
 
@@ -1114,8 +1038,8 @@ function bp_attachments_cover_image_is_edit() {
1114
  $retval = false;
1115
 
1116
  $current_component = bp_current_component();
1117
- if ( bp_is_user() ) {
1118
- $current_component = 'members';
1119
  }
1120
 
1121
  if ( ! bp_is_active( $current_component, 'cover_image' ) ) {
@@ -1158,7 +1082,6 @@ function bp_attachments_get_user_has_cover_image( $user_id = 0 ) {
1158
  * Does the group has a cover image?
1159
  *
1160
  * @since 2.4.0
1161
- * @since 6.0.0 Renamed the filter coherently.
1162
  *
1163
  * @param int $group_id Group ID to check cover image existence for.
1164
  * @return bool True if the group has a cover image, false otherwise.
@@ -1173,7 +1096,7 @@ function bp_attachments_get_group_has_cover_image( $group_id = 0 ) {
1173
  'item_id' => $group_id,
1174
  ) );
1175
 
1176
- return (bool) apply_filters( 'bp_attachments_get_group_has_cover_image', $cover_src, $group_id );
1177
  }
1178
 
1179
  /**
@@ -1183,7 +1106,7 @@ function bp_attachments_get_group_has_cover_image( $group_id = 0 ) {
1183
  *
1184
  * @param array $args {
1185
  * @type string $file The absolute path to the image. Required.
1186
- * @type string $component The component for the object (eg: groups, members). Required.
1187
  * @type string $cover_image_dir The Cover image dir to write the image into. Required.
1188
  * }
1189
  * @param BP_Attachment_Cover_Image|null $cover_image_class The class to use to fit the cover image.
@@ -1207,10 +1130,8 @@ function bp_attachments_cover_image_generate_file( $args = array(), $cover_image
1207
  $cover_image_class = new BP_Attachment_Cover_Image();
1208
  }
1209
 
1210
- $upload_dir = bp_attachments_cover_image_upload_dir();
1211
-
1212
  // Make sure the file is inside the Cover Image Upload path.
1213
- if ( false === strpos( $args['file'], $upload_dir['basedir'] ) ) {
1214
  return false;
1215
  }
1216
 
@@ -1268,27 +1189,36 @@ function bp_attachments_cover_image_generate_file( $args = array(), $cover_image
1268
  * error message otherwise.
1269
  */
1270
  function bp_attachments_cover_image_ajax_upload() {
1271
- if ( ! bp_is_post_request() ) {
 
1272
  wp_die();
1273
  }
1274
 
 
 
 
 
 
 
 
 
 
 
1275
  check_admin_referer( 'bp-uploader' );
1276
 
1277
- // Sending the json response will be different if the current Plupload runtime is html4.
1278
- $is_html4 = ! empty( $_POST['html4' ] );
1279
 
1280
- if ( empty( $_POST['bp_params'] ) ) {
 
 
 
 
 
 
1281
  bp_attachments_json_response( false, $is_html4 );
1282
  }
1283
 
1284
- $bp_params = bp_parse_args( $_POST['bp_params'], array(
1285
- 'object' => 'user',
1286
- 'item_id' => bp_loggedin_user_id(),
1287
- ), 'attachments_cover_image_ajax_upload' );
1288
-
1289
- $bp_params['item_id'] = (int) $bp_params['item_id'];
1290
- $bp_params['object'] = sanitize_text_field( $bp_params['object'] );
1291
-
1292
  // We need the object to set the uploads dir filter.
1293
  if ( empty( $bp_params['object'] ) ) {
1294
  bp_attachments_json_response( false, $is_html4 );
@@ -1304,7 +1234,7 @@ function bp_attachments_cover_image_ajax_upload() {
1304
 
1305
  // Member's cover image.
1306
  if ( 'user' === $bp_params['object'] ) {
1307
- $object_data = array( 'dir' => 'members', 'component' => 'members' );
1308
 
1309
  if ( ! bp_displayed_user_id() && ! empty( $bp_params['item_id'] ) ) {
1310
  $needs_reset = array( 'key' => 'displayed_user', 'value' => $bp->displayed_user );
@@ -1363,17 +1293,15 @@ function bp_attachments_cover_image_ajax_upload() {
1363
  // Upload error response.
1364
  bp_attachments_json_response( false, $is_html4, array(
1365
  'type' => 'upload_error',
1366
- 'message' => sprintf(
1367
- /* translators: %s: the upload error message */
1368
- __( 'Upload Failed! Error was: %s', 'buddypress' ),
1369
- $uploaded['error']
1370
- ),
1371
  ) );
1372
  }
1373
 
 
1374
  $error_message = __( 'There was a problem uploading the cover image.', 'buddypress' );
1375
 
1376
- $bp_attachments_uploads_dir = bp_attachments_cover_image_upload_dir();
 
1377
 
1378
  // The BP Attachments Uploads Dir is not set, stop.
1379
  if ( ! $bp_attachments_uploads_dir ) {
@@ -1394,10 +1322,10 @@ function bp_attachments_cover_image_ajax_upload() {
1394
  ) );
1395
  }
1396
 
1397
- /*
1398
  * Generate the cover image so that it fit to feature's dimensions
1399
  *
1400
- * Unlike the avatar, uploading and generating the cover image is happening during
1401
  * the same Ajax request, as we already instantiated the BP_Attachment_Cover_Image
1402
  * class, let's use it.
1403
  */
@@ -1408,15 +1336,17 @@ function bp_attachments_cover_image_ajax_upload() {
1408
  ), $cover_image_attachment );
1409
 
1410
  if ( ! $cover ) {
 
1411
  bp_attachments_json_response( false, $is_html4, array(
1412
  'type' => 'upload_error',
1413
  'message' => $error_message,
1414
  ) );
1415
  }
1416
 
 
1417
  $cover_url = trailingslashit( $bp_attachments_uploads_dir['baseurl'] ) . $cover_subdir . '/' . $cover['cover_basename'];
1418
 
1419
- // 1 is success.
1420
  $feedback_code = 1;
1421
 
1422
  // 0 is the size warning.
@@ -1425,53 +1355,23 @@ function bp_attachments_cover_image_ajax_upload() {
1425
  }
1426
 
1427
  // Set the name of the file.
1428
- $name = $_FILES['file']['name'];
1429
  $name_parts = pathinfo( $name );
1430
- $name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) );
1431
-
1432
- // Set some arguments for filters.
1433
- $item_id = (int) $bp_params['item_id'];
1434
- $component = $object_data['component'];
1435
 
1436
  /**
1437
  * Fires if the new cover image was successfully uploaded.
1438
  *
1439
- * The dynamic portion of the hook will be members in case of a user's
1440
  * cover image, groups in case of a group's cover image. For instance:
1441
- * Use add_action( 'members_cover_image_uploaded' ) to run your specific
1442
  * code once the user has set his cover image.
1443
  *
1444
  * @since 2.4.0
1445
- * @since 3.0.0 Added $cover_url, $name, $feedback_code arguments.
1446
  *
1447
- * @param int $item_id Inform about the item id the cover image was set for.
1448
- * @param string $name Filename.
1449
- * @param string $cover_url URL to the image.
1450
- * @param int $feedback_code If value not 1, an error occured.
1451
  */
1452
- do_action(
1453
- $component . '_cover_image_uploaded',
1454
- $item_id,
1455
- $name,
1456
- $cover_url,
1457
- $feedback_code
1458
- );
1459
-
1460
- // Handle deprecated xProfile action.
1461
- if ( 'members' === $component ) {
1462
- /** This filter is documented in wp-includes/deprecated.php */
1463
- do_action_deprecated(
1464
- 'xprofile_cover_image_uploaded',
1465
- array(
1466
- $item_id,
1467
- $name,
1468
- $cover_url,
1469
- $feedback_code,
1470
- ),
1471
- '6.0.0',
1472
- 'members_cover_image_deleted'
1473
- );
1474
- }
1475
 
1476
  // Finally return the cover image url to the UI.
1477
  bp_attachments_json_response( true, $is_html4, array(
@@ -1491,11 +1391,12 @@ add_action( 'wp_ajax_bp_cover_image_upload', 'bp_attachments_cover_image_ajax_up
1491
  * error message otherwise.
1492
  */
1493
  function bp_attachments_cover_image_ajax_delete() {
1494
- if ( ! bp_is_post_request() ) {
 
1495
  wp_send_json_error();
1496
  }
1497
 
1498
- if ( empty( $_POST['object'] ) || empty( $_POST['item_id'] ) || ( ! ctype_digit( $_POST['item_id'] ) && ! is_int( $_POST['item_id'] ) ) ) {
1499
  wp_send_json_error();
1500
  }
1501
 
@@ -1512,7 +1413,7 @@ function bp_attachments_cover_image_ajax_delete() {
1512
 
1513
  // Set object for the user's case.
1514
  if ( 'user' === $args['object'] ) {
1515
- $component = 'members';
1516
  $dir = 'members';
1517
 
1518
  // Set it for any other cases.
@@ -1523,31 +1424,24 @@ function bp_attachments_cover_image_ajax_delete() {
1523
 
1524
  // Handle delete.
1525
  if ( bp_attachments_delete_file( array( 'item_id' => $args['item_id'], 'object_dir' => $dir, 'type' => 'cover-image' ) ) ) {
1526
- $item_id = (int) $args['item_id'];
1527
-
1528
  /**
1529
  * Fires if the cover image was successfully deleted.
1530
  *
1531
- * The dynamic portion of the hook will be members in case of a user's
1532
  * cover image, groups in case of a group's cover image. For instance:
1533
- * Use add_action( 'members_cover_image_deleted' ) to run your specific
1534
  * code once the user has deleted his cover image.
1535
  *
1536
  * @since 2.8.0
1537
  *
1538
  * @param int $item_id Inform about the item id the cover image was deleted for.
1539
  */
1540
- do_action( "{$component}_cover_image_deleted", $item_id );
1541
-
1542
- // Handle deprecated xProfile action.
1543
- if ( 'members' === $component ) {
1544
- /** This filter is documented in wp-includes/deprecated.php */
1545
- do_action_deprecated( 'xprofile_cover_image_deleted', array( $item_id ), '6.0.0', 'members_cover_image_deleted' );
1546
- }
1547
 
 
1548
  $response = array(
1549
  'reset_url' => '',
1550
- 'feedback_code' => 3,
1551
  );
1552
 
1553
  // Get cover image settings in case there's a default header.
@@ -1558,6 +1452,7 @@ function bp_attachments_cover_image_ajax_delete() {
1558
  $response['reset_url'] = $cover_params['default_cover'];
1559
  }
1560
 
 
1561
  wp_send_json_success( $response );
1562
 
1563
  } else {
10
  // Exit if accessed directly.
11
  defined( 'ABSPATH' ) || exit;
12
 
13
+ /**
14
+ * Check if the current WordPress version is using Plupload 2.1.1
15
+ *
16
+ * Plupload 2.1.1 was introduced in WordPress 3.9. Our bp-plupload.js
17
+ * script requires it. So we need to make sure the current WordPress
18
+ * match with our needs.
19
+ *
20
+ * @since 2.3.0
21
+ *
22
+ * @return bool True if WordPress is 3.9+, false otherwise.
23
+ */
24
+ function bp_attachments_is_wp_version_supported() {
25
+ return (bool) version_compare( bp_get_major_wp_version(), '3.9', '>=' );
26
+ }
27
+
28
  /**
29
  * Get the Attachments Uploads dir data.
30
  *
83
  return apply_filters( 'bp_attachments_uploads_dir_get', $retval, $data );
84
  }
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  /**
87
  * Get the max upload file size for any attachment.
88
  *
235
  * @param array $args {
236
  * @type int $item_id The ID of the object (Required). Default: 0.
237
  * @type string $object The object type (eg: group, user, blog) (Required). Default: 'user'.
238
+ * @type string $component The component for the object (eg: groups, xprofile, blogs). Default: ''.
239
  * @type string $image The absolute path to the image (Required). Default: ''.
240
  * @type int $crop_w Crop width. Default: 0.
241
  * @type int $crop_h Crop height. Default: 0.
272
  // Set the component if not already done.
273
  if ( empty( $r['component'] ) ) {
274
  if ( 'user' === $r['object'] ) {
275
+ $r['component'] = 'xprofile';
276
  } else {
277
  $r['component'] = $r['object'] . 's';
278
  }
304
  if ( is_callable( $r['component'] . '_avatar_upload_dir' ) ) {
305
  $dir_args = array( $r['item_id'] );
306
 
307
+ // In case of xprofile, we need an extra argument.
308
+ if ( 'xprofile' === $r['component'] ) {
309
  $dir_args = array( false, $r['item_id'] );
310
  }
311
 
312
  $attachment_data = call_user_func_array( $r['component'] . '_avatar_upload_dir', $dir_args );
313
  }
314
  } elseif ( 'cover_image' === $type ) {
315
+ $attachment_data = bp_attachments_uploads_dir_get();
316
 
317
  // The BP Attachments Uploads Dir is not set, stop.
318
  if ( ! $attachment_data ) {
322
  // Default to members for xProfile.
323
  $object_subdir = 'members';
324
 
325
+ if ( 'xprofile' !== $r['component'] ) {
326
  $object_subdir = sanitize_key( $r['component'] );
327
  }
328
 
430
  * Defaults to 'cover-image'
431
  * @type string $file The name of the file.
432
  * }
 
433
  */
434
+ $pre_filter = apply_filters( 'bp_attachments_pre_get_attachment', null, $r );
435
  if ( $pre_filter !== null ) {
436
  return $pre_filter;
437
  }
512
  * @since 2.5.1
513
  *
514
  * @param bool $value Whether or not to delete the BuddyPress attachment.
515
+ ` * @param array $args Array of arguments for the attachment deletion.
516
  */
517
  if ( ! apply_filters( 'bp_attachments_pre_delete_file', true, $args ) ) {
518
  return true;
592
  * @return array Plupload default localization strings.
593
  */
594
  function bp_attachments_get_plupload_l10n() {
595
+ // Localization strings.
596
+ return apply_filters( 'bp_attachments_get_plupload_l10n', array(
 
 
 
 
 
 
 
 
597
  'queue_limit_exceeded' => __( 'You have attempted to queue too many files.', 'buddypress' ),
 
 
598
  'file_exceeds_size_limit' => __( '%s exceeds the maximum upload size for this site.', 'buddypress' ),
599
  'zero_byte_file' => __( 'This file is empty. Please try another.', 'buddypress' ),
600
  'invalid_filetype' => __( 'This file type is not allowed. Please try another.', 'buddypress' ),
606
  'upload_limit_exceeded' => __( 'You may only upload 1 file.', 'buddypress' ),
607
  'http_error' => __( 'HTTP error.', 'buddypress' ),
608
  'upload_failed' => __( 'Upload failed.', 'buddypress' ),
 
 
609
  'big_upload_failed' => __( 'Please try uploading this file with the %1$sbrowser uploader%2$s.', 'buddypress' ),
 
 
610
  'big_upload_queued' => __( '%s exceeds the maximum upload size for the multi-file uploader when used in your browser.', 'buddypress' ),
611
  'io_error' => __( 'IO error.', 'buddypress' ),
612
  'security_error' => __( 'Security error.', 'buddypress' ),
615
  'dismiss' => __( 'Dismiss', 'buddypress' ),
616
  'crunching' => __( 'Crunching&hellip;', 'buddypress' ),
617
  'unique_file_warning' => __( 'Make sure to upload a unique file', 'buddypress' ),
 
 
618
  'error_uploading' => __( '&#8220;%s&#8221; has failed to upload.', 'buddypress' ),
619
  'has_avatar_warning' => __( 'If you&#39;d like to delete the existing profile photo but not upload a new one, please use the delete tab.', 'buddypress' )
620
+ ) );
 
621
  }
622
 
623
  /**
766
  // Cover images only need 1 file and 1 only!
767
  $defaults['multi_selection'] = false;
768
 
769
+ // Default cover component is xprofile.
770
+ $cover_component = 'xprofile';
771
 
772
  // Get the object we're editing the cover image of.
773
  $object = $defaults['multipart_params']['bp_params']['object'];
784
  // Set warning messages.
785
  $strings['cover_image_warnings'] = apply_filters( 'bp_attachments_cover_image_ui_warnings', array(
786
  'dimensions' => sprintf(
787
+ __( 'For better results, make sure to upload an image that is larger than %1$spx wide, and %2$spx tall.', 'buddypress' ),
788
+ (int) $cover_dimensions['width'],
789
+ (int) $cover_dimensions['height']
790
+ ),
 
791
  ) );
792
  }
793
 
861
  $can = (bool) groups_is_user_admin( bp_loggedin_user_id(), $args['item_id'] ) || bp_current_user_can( 'bp_moderate' );
862
  }
863
  // User profile photo.
864
+ } elseif ( bp_is_active( 'xprofile' ) && 'user' === $args['object'] ) {
865
  $can = bp_loggedin_user_id() === (int) $args['item_id'] || bp_current_user_can( 'bp_moderate' );
866
  }
867
  /**
921
  * @return bool
922
  */
923
  function bp_attachments_get_template_part( $slug ) {
924
+ $attachment_template_part = 'assets/_attachments/' . $slug;
925
 
926
+ // Load the attachment template in WP Administration screens.
927
+ if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
928
+ $attachment_admin_template_part = buddypress()->themes_dir . '/bp-legacy/buddypress/' . $attachment_template_part . '.php';
929
+
930
+ // Check whether the template part exists.
931
+ if ( ! file_exists( $attachment_admin_template_part ) ) {
932
+ return false;
 
 
933
  }
 
934
 
935
+ // Load the template part.
936
+ require( $attachment_admin_template_part );
937
 
938
+ // Load the attachment template in WP_USE_THEMES env.
939
+ } else {
940
+ bp_get_template_part( $attachment_template_part );
941
  }
942
  }
943
 
948
  *
949
  * @since 2.4.0
950
  *
951
+ * @param string $component The component to get the settings for ("xprofile" for user or "groups").
952
  * @return false|array The cover image settings in array, false on failure.
953
  */
954
+ function bp_attachments_get_cover_image_settings( $component = 'xprofile' ) {
955
  // Default parameters.
956
  $args = array();
957
 
962
  $args = (array) $cover_image;
963
  }
964
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
965
  /**
966
  * Then let people override/set the feature using this dynamic filter
967
  *
968
  * Eg: for the user's profile cover image use:
969
+ * add_filter( 'bp_before_xprofile_cover_image_settings_parse_args', 'your_filter', 10, 1 );
970
  *
971
  * @since 2.4.0
972
  *
973
  * @param array $settings The cover image settings
974
  */
975
+ $settings = bp_parse_args( $args, array(
976
+ 'components' => array(),
977
+ 'width' => 1300,
978
+ 'height' => 225,
979
+ 'callback' => '',
980
+ 'theme_handle' => '',
981
+ 'default_cover' => '',
982
+ ), $component . '_cover_image_settings' );
983
 
984
  if ( empty( $settings['components'] ) || empty( $settings['callback'] ) || empty( $settings['theme_handle'] ) ) {
985
  return false;
999
  *
1000
  * @since 2.4.0
1001
  *
1002
+ * @param string $component The BuddyPress component concerned ("xprofile" for user or "groups").
1003
  * @return array|bool An associative array containing the advised width and height for the cover image. False if settings are empty.
1004
  */
1005
+ function bp_attachments_get_cover_image_dimensions( $component = 'xprofile' ) {
1006
  // Let's prevent notices when setting the warning strings.
1007
  $default = array( 'width' => 0, 'height' => 0 );
1008
 
1038
  $retval = false;
1039
 
1040
  $current_component = bp_current_component();
1041
+ if ( bp_is_active( 'xprofile' ) && bp_is_current_component( 'xprofile' ) ) {
1042
+ $current_component = 'xprofile';
1043
  }
1044
 
1045
  if ( ! bp_is_active( $current_component, 'cover_image' ) ) {
1082
  * Does the group has a cover image?
1083
  *
1084
  * @since 2.4.0
 
1085
  *
1086
  * @param int $group_id Group ID to check cover image existence for.
1087
  * @return bool True if the group has a cover image, false otherwise.
1096
  'item_id' => $group_id,
1097
  ) );
1098
 
1099
+ return (bool) apply_filters( 'bp_attachments_get_user_has_cover_image', $cover_src, $group_id );
1100
  }
1101
 
1102
  /**
1106
  *
1107
  * @param array $args {
1108
  * @type string $file The absolute path to the image. Required.
1109
+ * @type string $component The component for the object (eg: groups, xprofile). Required.
1110
  * @type string $cover_image_dir The Cover image dir to write the image into. Required.
1111
  * }
1112
  * @param BP_Attachment_Cover_Image|null $cover_image_class The class to use to fit the cover image.
1130
  $cover_image_class = new BP_Attachment_Cover_Image();
1131
  }
1132
 
 
 
1133
  // Make sure the file is inside the Cover Image Upload path.
1134
+ if ( false === strpos( $args['file'], $cover_image_class->upload_path ) ) {
1135
  return false;
1136
  }
1137
 
1189
  * error message otherwise.
1190
  */
1191
  function bp_attachments_cover_image_ajax_upload() {
1192
+ // Bail if not a POST action.
1193
+ if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
1194
  wp_die();
1195
  }
1196
 
1197
+ /**
1198
+ * Sending the json response will be different if
1199
+ * the current Plupload runtime is html4
1200
+ */
1201
+ $is_html4 = false;
1202
+ if ( ! empty( $_POST['html4' ] ) ) {
1203
+ $is_html4 = true;
1204
+ }
1205
+
1206
+ // Check the nonce.
1207
  check_admin_referer( 'bp-uploader' );
1208
 
1209
+ // Init the BuddyPress parameters.
1210
+ $bp_params = array();
1211
 
1212
+ // We need it to carry on.
1213
+ if ( ! empty( $_POST['bp_params'] ) ) {
1214
+ $bp_params = bp_parse_args( $_POST['bp_params'], array(
1215
+ 'object' => 'user',
1216
+ 'item_id' => bp_loggedin_user_id(),
1217
+ ), 'attachments_cover_image_ajax_upload' );
1218
+ } else {
1219
  bp_attachments_json_response( false, $is_html4 );
1220
  }
1221
 
 
 
 
 
 
 
 
 
1222
  // We need the object to set the uploads dir filter.
1223
  if ( empty( $bp_params['object'] ) ) {
1224
  bp_attachments_json_response( false, $is_html4 );
1234
 
1235
  // Member's cover image.
1236
  if ( 'user' === $bp_params['object'] ) {
1237
+ $object_data = array( 'dir' => 'members', 'component' => 'xprofile' );
1238
 
1239
  if ( ! bp_displayed_user_id() && ! empty( $bp_params['item_id'] ) ) {
1240
  $needs_reset = array( 'key' => 'displayed_user', 'value' => $bp->displayed_user );
1293
  // Upload error response.
1294
  bp_attachments_json_response( false, $is_html4, array(
1295
  'type' => 'upload_error',
1296
+ 'message' => sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $uploaded['error'] ),
 
 
 
 
1297
  ) );
1298
  }
1299
 
1300
+ // Default error message.
1301
  $error_message = __( 'There was a problem uploading the cover image.', 'buddypress' );
1302
 
1303
+ // Get BuddyPress Attachments Uploads Dir datas.
1304
+ $bp_attachments_uploads_dir = bp_attachments_uploads_dir_get();
1305
 
1306
  // The BP Attachments Uploads Dir is not set, stop.
1307
  if ( ! $bp_attachments_uploads_dir ) {
1322
  ) );
1323
  }
1324
 
1325
+ /**
1326
  * Generate the cover image so that it fit to feature's dimensions
1327
  *
1328
+ * Unlike the Avatar, Uploading and generating the cover image is happening during
1329
  * the same Ajax request, as we already instantiated the BP_Attachment_Cover_Image
1330
  * class, let's use it.
1331
  */
1336
  ), $cover_image_attachment );
1337
 
1338
  if ( ! $cover ) {
1339
+ // Upload error response.
1340
  bp_attachments_json_response( false, $is_html4, array(
1341
  'type' => 'upload_error',
1342
  'message' => $error_message,
1343
  ) );
1344
  }
1345
 
1346
+ // Build the url to the file.
1347
  $cover_url = trailingslashit( $bp_attachments_uploads_dir['baseurl'] ) . $cover_subdir . '/' . $cover['cover_basename'];
1348
 
1349
+ // Init Feedback code, 1 is success.
1350
  $feedback_code = 1;
1351
 
1352
  // 0 is the size warning.
1355
  }
1356
 
1357
  // Set the name of the file.
1358
+ $name = $_FILES['file']['name'];
1359
  $name_parts = pathinfo( $name );
1360
+ $name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) );
 
 
 
 
1361
 
1362
  /**
1363
  * Fires if the new cover image was successfully uploaded.
1364
  *
1365
+ * The dynamic portion of the hook will be xprofile in case of a user's
1366
  * cover image, groups in case of a group's cover image. For instance:
1367
+ * Use add_action( 'xprofile_cover_image_uploaded' ) to run your specific
1368
  * code once the user has set his cover image.
1369
  *
1370
  * @since 2.4.0
 
1371
  *
1372
+ * @param int $item_id Inform about the item id the cover image was set for.
 
 
 
1373
  */
1374
+ do_action( $object_data['component'] . '_cover_image_uploaded', (int) $bp_params['item_id'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1375
 
1376
  // Finally return the cover image url to the UI.
1377
  bp_attachments_json_response( true, $is_html4, array(
1391
  * error message otherwise.
1392
  */
1393
  function bp_attachments_cover_image_ajax_delete() {
1394
+ // Bail if not a POST action.
1395
+ if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
1396
  wp_send_json_error();
1397
  }
1398
 
1399
+ if ( empty( $_POST['object'] ) || empty( $_POST['item_id'] ) ) {
1400
  wp_send_json_error();
1401
  }
1402
 
1413
 
1414
  // Set object for the user's case.
1415
  if ( 'user' === $args['object'] ) {
1416
+ $component = 'xprofile';
1417
  $dir = 'members';
1418
 
1419
  // Set it for any other cases.
1424
 
1425
  // Handle delete.
1426
  if ( bp_attachments_delete_file( array( 'item_id' => $args['item_id'], 'object_dir' => $dir, 'type' => 'cover-image' ) ) ) {
 
 
1427
  /**
1428
  * Fires if the cover image was successfully deleted.
1429
  *
1430
+ * The dynamic portion of the hook will be xprofile in case of a user's
1431
  * cover image, groups in case of a group's cover image. For instance:
1432
+ * Use add_action( 'xprofile_cover_image_deleted' ) to run your specific
1433
  * code once the user has deleted his cover image.
1434
  *
1435
  * @since 2.8.0
1436
  *
1437
  * @param int $item_id Inform about the item id the cover image was deleted for.
1438
  */
1439
+ do_action( "{$component}_cover_image_deleted", (int) $args['item_id'] );
 
 
 
 
 
 
1440
 
1441
+ // Defaults no cover image.
1442
  $response = array(
1443
  'reset_url' => '',
1444
+ 'feedback_code' => 3 ,
1445
  );
1446
 
1447
  // Get cover image settings in case there's a default header.
1452
  $response['reset_url'] = $cover_params['default_cover'];
1453
  }
1454
 
1455
+ // Finally send the reset url.
1456
  wp_send_json_success( $response );
1457
 
1458
  } else {
bp-core/bp-core-avatars.php CHANGED
@@ -95,39 +95,6 @@ function bp_core_set_avatar_globals() {
95
  }
96
  add_action( 'bp_setup_globals', 'bp_core_set_avatar_globals' );
97
 
98
- /**
99
- * Checks whether a given gravatar is one of the default ones.
100
- *
101
- * @since 8.0.0
102
- *
103
- * @param string $d The name of the default gravatar.
104
- * @return bool True if it's a default gravatar. False otherwise.
105
- */
106
- function bp_core_is_default_gravatar( $d = '' ) {
107
- if ( ! $d ) {
108
- return false;
109
- }
110
-
111
- /** this filter is documented in wp-admin/options-discussion.php */
112
- $gravatar_defaults = apply_filters(
113
- 'avatar_defaults',
114
- array_fill_keys(
115
- array(
116
- 'mystery',
117
- 'blank',
118
- 'gravatar_default',
119
- 'identicon',
120
- 'wavatar',
121
- 'monsterid',
122
- 'retro',
123
- ),
124
- ''
125
- )
126
- );
127
-
128
- return isset( $gravatar_defaults[ $d ] );
129
- }
130
-
131
  /**
132
  * Get an avatar for a BuddyPress object.
133
  *
@@ -226,10 +193,12 @@ function bp_core_fetch_avatar( $args = '' ) {
226
  $bp = buddypress();
227
 
228
  // If avatars are disabled for the root site, obey that request and bail.
229
- if ( ! $bp->avatar || ! $bp->avatar->show_avatars ) {
230
  return;
231
  }
232
 
 
 
233
  // Set the default variables array and parse it against incoming $args array.
234
  $params = wp_parse_args( $args, array(
235
  'item_id' => false,
@@ -258,7 +227,7 @@ function bp_core_fetch_avatar( $args = '' ) {
258
  switch ( $params['object'] ) {
259
 
260
  case 'blog' :
261
- $params['item_id'] = get_current_blog_id();
262
  break;
263
 
264
  case 'group' :
@@ -395,10 +364,7 @@ function bp_core_fetch_avatar( $args = '' ) {
395
  }
396
 
397
  // Extra attributes.
398
- $extra_attr = '';
399
- if ( ! empty( $params['extra_attr'] ) ) {
400
- $extra_attr = ' ' . $params['extra_attr'];
401
- }
402
 
403
  // Set CSS ID and create html string.
404
  $html_css_id = '';
@@ -510,7 +476,7 @@ function bp_core_fetch_avatar( $args = '' ) {
510
  $legacy_group_avatar_name = ( 'full' == $params['type'] ) ? '-groupavatar-full' : '-groupavatar-thumb';
511
 
512
  // Check for directory.
513
- if ( ! $params['force_default'] && file_exists( $avatar_folder_dir ) ) {
514
 
515
  // Open directory.
516
  if ( $av_dir = opendir( $avatar_folder_dir ) ) {
@@ -671,38 +637,23 @@ function bp_core_fetch_avatar( $args = '' ) {
671
  // Custom Gravatar URL args.
672
  if ( ! empty( $params['force_default'] ) ) {
673
  $url_args['f'] = 'y';
674
- $url_args['d'] = $params['default'];
675
  }
676
  if ( ! empty( $params['rating'] ) ) {
677
  $url_args['r'] = strtolower( $params['rating'] );
678
  }
679
 
680
- /** This filter is documented in wp-includes/deprecated.php */
681
- $d = apply_filters_deprecated(
682
- 'bp_core_avatar_default',
683
- array( $default_grav, $params ),
684
- '8.0.0',
685
- 'bp_core_avatar_gravatar_default||bp_core_default_avatar',
686
- __( 'This filter was used for 2 different purposes. If your goal was to filter the default *Gravatar*, please use `bp_core_avatar_gravatar_default` instead. Otherwise, please use `bp_core_default_avatar` instead.', 'buddypress' )
687
- );
688
-
689
- if ( bp_core_is_default_gravatar( $d ) ) {
690
- $default_grav = $d;
691
- }
692
-
693
  /**
694
  * Filters the Gravatar "d" parameter.
695
  *
696
  * @since 2.6.0
697
- * @since 8.0.0 The name of the filter was changed to `bp_core_avatar_gravatar_default`.
698
  *
699
  * @param string $default_grav The avatar default.
700
  * @param array $params The avatar's data.
701
  */
702
- $default_grav = apply_filters( 'bp_core_avatar_gravatar_default', $default_grav, $params );
703
 
704
  // Only set default image if 'Gravatar Logo' is not requested.
705
- if ( ! $params['force_default'] && 'gravatar_default' !== $default_grav ) {
706
  $url_args['d'] = $default_grav;
707
  }
708
 
@@ -766,6 +717,7 @@ function bp_core_delete_existing_avatar( $args = '' ) {
766
  );
767
 
768
  $args = wp_parse_args( $args, $defaults );
 
769
 
770
  /**
771
  * Filters whether or not to handle deleting an existing avatar.
@@ -792,61 +744,47 @@ function bp_core_delete_existing_avatar( $args = '' ) {
792
  return true;
793
  }
794
 
795
- if ( empty( $args['item_id'] ) ) {
796
- if ( 'user' === $args['object'] ) {
797
- $args['item_id'] = bp_displayed_user_id();
798
- } elseif ( 'group' === $args['object'] ) {
799
- $args['item_id'] = buddypress()->groups->current_group->id;
800
- } elseif ( 'blog' === $args['object'] ) {
801
- $args['item_id'] = get_current_blog_id();
802
- }
803
 
804
  /** This filter is documented in bp-core/bp-core-avatars.php */
805
- $item_id = apply_filters( 'bp_core_avatar_item_id', $args['item_id'], $args['object'] );
806
- } else {
807
- $item_id = $args['item_id'];
808
- }
809
 
810
- if ( $item_id && ( ctype_digit( $item_id ) || is_int( $item_id ) ) ) {
811
- $item_id = (int) $item_id;
812
- } else {
813
- return false;
814
  }
815
 
816
- if ( empty( $args['avatar_dir'] ) ) {
817
- if ( 'user' === $args['object'] ) {
818
- $args['avatar_dir'] = 'avatars';
819
- } elseif ( 'group' === $args['object'] ) {
820
- $args['avatar_dir'] = 'group-avatars';
821
- } elseif ( 'blog' === $args['object'] ) {
822
- $args['avatar_dir'] = 'blog-avatars';
823
- }
824
 
825
  /** This filter is documented in bp-core/bp-core-avatars.php */
826
- $avatar_dir = apply_filters( 'bp_core_avatar_dir', $args['avatar_dir'], $args['object'] );
827
- } else {
828
- $avatar_dir = $args['avatar_dir'];
829
- }
830
 
831
- if ( ! $avatar_dir ) {
832
- return false;
833
  }
834
 
835
  /** This filter is documented in bp-core/bp-core-avatars.php */
836
- $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $args['object'], $avatar_dir );
837
 
838
- if ( ! is_dir( $avatar_folder_dir ) ) {
839
  return false;
840
- }
841
 
842
  if ( $av_dir = opendir( $avatar_folder_dir ) ) {
843
- while ( false !== ( $avatar_file = readdir( $av_dir ) ) ) {
844
- if ( ( preg_match( "/-bpfull/", $avatar_file ) || preg_match( "/-bpthumb/", $avatar_file ) ) && '.' != $avatar_file && '..' != $avatar_file ) {
845
  @unlink( $avatar_folder_dir . '/' . $avatar_file );
846
- }
847
  }
848
  }
849
- closedir( $av_dir );
850
 
851
  @rmdir( $avatar_folder_dir );
852
 
@@ -871,7 +809,8 @@ function bp_core_delete_existing_avatar( $args = '' ) {
871
  * error message otherwise.
872
  */
873
  function bp_avatar_ajax_delete() {
874
- if ( ! bp_is_post_request() ) {
 
875
  wp_send_json_error();
876
  }
877
 
@@ -897,7 +836,7 @@ function bp_avatar_ajax_delete() {
897
  // Handle delete.
898
  if ( bp_core_delete_existing_avatar( array( 'item_id' => $avatar_data['item_id'], 'object' => $avatar_data['object'] ) ) ) {
899
  $return = array(
900
- 'avatar' => esc_url( bp_core_fetch_avatar( array(
901
  'object' => $avatar_data['object'],
902
  'item_id' => $avatar_data['item_id'],
903
  'html' => false,
@@ -961,7 +900,6 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
961
 
962
  // In case of an error, stop the process and display a feedback to the user.
963
  if ( ! empty( $bp->avatar_admin->original['error'] ) ) {
964
- /* translators: %s: the upload error message */
965
  bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->original['error'] ), 'error' );
966
  return false;
967
  }
@@ -979,7 +917,7 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
979
  $bp->avatar_admin->image = new stdClass();
980
 
981
  // We only want to handle one image after resize.
982
- if ( empty( $bp->avatar_admin->resized ) || is_wp_error( $bp->avatar_admin->resized ) ) {
983
  $bp->avatar_admin->image->file = $bp->avatar_admin->original['file'];
984
  $bp->avatar_admin->image->dir = str_replace( $upload_path, '', $bp->avatar_admin->original['file'] );
985
  } else {
@@ -990,15 +928,13 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
990
 
991
  // Check for WP_Error on what should be an image.
992
  if ( is_wp_error( $bp->avatar_admin->image->dir ) ) {
993
- /* translators: %s: the upload error message */
994
  bp_core_add_message( sprintf( __( 'Upload failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->image->dir->get_error_message() ), 'error' );
995
  return false;
996
  }
997
 
998
  // If the uploaded image is smaller than the "full" dimensions, throw a warning.
999
  if ( $avatar_attachment->is_too_small( $bp->avatar_admin->image->file ) ) {
1000
- /* translators: 1: the advised width size in pixels. 2: the advised height size in pixels. */
1001
- bp_core_add_message( sprintf( __( 'You have selected an image that is smaller than recommended. For best results, upload a picture larger than %1$d x %2$d pixels.', 'buddypress' ), bp_core_avatar_full_width(), bp_core_avatar_full_height() ), 'error' );
1002
  }
1003
 
1004
  // Set the url value for the image.
@@ -1016,7 +952,8 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
1016
  * error message otherwise.
1017
  */
1018
  function bp_avatar_ajax_upload() {
1019
- if ( ! bp_is_post_request() ) {
 
1020
  wp_die();
1021
  }
1022
 
@@ -1056,8 +993,8 @@ function bp_avatar_ajax_upload() {
1056
  $bp_params['upload_dir_filter'] = '';
1057
  $needs_reset = array();
1058
 
1059
- if ( 'user' === $bp_params['object'] && bp_is_active( 'members' ) ) {
1060
- $bp_params['upload_dir_filter'] = 'bp_members_avatar_upload_dir';
1061
 
1062
  if ( ! bp_displayed_user_id() && ! empty( $bp_params['item_id'] ) ) {
1063
  $needs_reset = array( 'key' => 'displayed_user', 'value' => $bp->displayed_user );
@@ -1300,7 +1237,8 @@ function bp_core_avatar_handle_crop( $args = '' ) {
1300
  * error message otherwise.
1301
  */
1302
  function bp_avatar_ajax_set() {
1303
- if ( ! bp_is_post_request() ) {
 
1304
  wp_send_json_error();
1305
  }
1306
 
@@ -1338,7 +1276,7 @@ function bp_avatar_ajax_set() {
1338
 
1339
  } else {
1340
  $return = array(
1341
- 'avatar' => esc_url( bp_core_fetch_avatar( array(
1342
  'object' => $avatar_data['object'],
1343
  'item_id' => $avatar_data['item_id'],
1344
  'html' => false,
@@ -1348,19 +1286,20 @@ function bp_avatar_ajax_set() {
1348
  'item_id' => $avatar_data['item_id'],
1349
  );
1350
 
1351
- /** This action is documented in wp-includes/deprecated.php */
1352
- do_action_deprecated( 'xprofile_avatar_uploaded', array( (int) $avatar_data['item_id'], $avatar_data['type'], $avatar_data ), '6.0.0', 'bp_members_avatar_uploaded' );
1353
-
1354
  /**
1355
  * Fires if the new avatar was successfully captured.
1356
  *
1357
- * @since 6.0.0
 
 
 
 
1358
  *
1359
  * @param string $item_id Inform about the user id the avatar was set for.
1360
  * @param string $type Inform about the way the avatar was set ('camera').
1361
  * @param array $avatar_data Array of parameters passed to the avatar handler.
1362
  */
1363
- do_action( 'bp_members_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'], $avatar_data );
1364
 
1365
  wp_send_json_success( $return );
1366
  }
@@ -1394,7 +1333,7 @@ function bp_avatar_ajax_set() {
1394
  // Handle crop.
1395
  if ( bp_core_avatar_handle_crop( $r ) ) {
1396
  $return = array(
1397
- 'avatar' => esc_url( bp_core_fetch_avatar( array(
1398
  'object' => $avatar_data['object'],
1399
  'item_id' => $avatar_data['item_id'],
1400
  'html' => false,
@@ -1405,11 +1344,8 @@ function bp_avatar_ajax_set() {
1405
  );
1406
 
1407
  if ( 'user' === $avatar_data['object'] ) {
1408
- /** This action is documented in wp-includes/deprecated.php */
1409
- do_action_deprecated( 'xprofile_avatar_uploaded', array( (int) $avatar_data['item_id'], $avatar_data['type'], $r ), '6.0.0', 'bp_members_avatar_uploaded' );
1410
-
1411
  /** This action is documented in bp-core/bp-core-avatars.php */
1412
- do_action( 'bp_members_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'], $r );
1413
  } elseif ( 'group' === $avatar_data['object'] ) {
1414
  /** This action is documented in bp-groups/bp-groups-screens.php */
1415
  do_action( 'groups_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'], $r );
@@ -1888,30 +1824,16 @@ function bp_core_avatar_default( $type = 'gravatar', $params = array() ) {
1888
  $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&amp;s=' . $size;
1889
  }
1890
 
1891
- /** This filter is documented in wp-includes/deprecated.php */
1892
- $a = apply_filters_deprecated(
1893
- 'bp_core_avatar_default',
1894
- array( $avatar, $params ),
1895
- '8.0.0',
1896
- 'bp_core_avatar_gravatar_default||bp_core_default_avatar',
1897
- __( 'This filter was used for 2 different purposes. If your goal was to filter the default *Gravatar*, please use `bp_core_avatar_gravatar_default` instead. Otherwise, please use `bp_core_default_avatar` instead.', 'buddypress' )
1898
- );
1899
-
1900
- if ( ! bp_core_is_default_gravatar( $a ) && false !== strpos( $avatar, '//' ) ) {
1901
- $avatar = $a;
1902
- }
1903
-
1904
  /**
1905
  * Filters the URL of the 'full' default avatar.
1906
  *
1907
  * @since 1.5.0
1908
  * @since 2.6.0 Added `$params`.
1909
- * @since 8.0.0 The name of the filter was changed to `bp_core_default_avatar`.
1910
  *
1911
  * @param string $avatar URL of the default avatar.
1912
  * @param array $params Params provided to bp_core_fetch_avatar().
1913
  */
1914
- return apply_filters( 'bp_core_default_avatar', $avatar, $params );
1915
  }
1916
 
1917
  /**
@@ -2003,6 +1925,11 @@ add_action( 'bp_parse_query', 'bp_core_avatar_reset_query', 10, 1 );
2003
  function bp_avatar_is_front_edit() {
2004
  $retval = false;
2005
 
 
 
 
 
 
2006
  if ( bp_is_user_change_avatar() && 'crop-image' !== bp_get_avatar_admin_step() ) {
2007
  $retval = ! bp_core_get_root_option( 'bp-disable-avatar-uploads' );
2008
  }
95
  }
96
  add_action( 'bp_setup_globals', 'bp_core_set_avatar_globals' );
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  /**
99
  * Get an avatar for a BuddyPress object.
100
  *
193
  $bp = buddypress();
194
 
195
  // If avatars are disabled for the root site, obey that request and bail.
196
+ if ( ! $bp->avatar->show_avatars ) {
197
  return;
198
  }
199
 
200
+ global $current_blog;
201
+
202
  // Set the default variables array and parse it against incoming $args array.
203
  $params = wp_parse_args( $args, array(
204
  'item_id' => false,
227
  switch ( $params['object'] ) {
228
 
229
  case 'blog' :
230
+ $params['item_id'] = $current_blog->id;
231
  break;
232
 
233
  case 'group' :
364
  }
365
 
366
  // Extra attributes.
367
+ $extra_attr = ! empty( $args['extra_attr'] ) ? ' ' . $args['extra_attr'] : '';
 
 
 
368
 
369
  // Set CSS ID and create html string.
370
  $html_css_id = '';
476
  $legacy_group_avatar_name = ( 'full' == $params['type'] ) ? '-groupavatar-full' : '-groupavatar-thumb';
477
 
478
  // Check for directory.
479
+ if ( file_exists( $avatar_folder_dir ) ) {
480
 
481
  // Open directory.
482
  if ( $av_dir = opendir( $avatar_folder_dir ) ) {
637
  // Custom Gravatar URL args.
638
  if ( ! empty( $params['force_default'] ) ) {
639
  $url_args['f'] = 'y';
 
640
  }
641
  if ( ! empty( $params['rating'] ) ) {
642
  $url_args['r'] = strtolower( $params['rating'] );
643
  }
644
 
 
 
 
 
 
 
 
 
 
 
 
 
 
645
  /**
646
  * Filters the Gravatar "d" parameter.
647
  *
648
  * @since 2.6.0
 
649
  *
650
  * @param string $default_grav The avatar default.
651
  * @param array $params The avatar's data.
652
  */
653
+ $default_grav = apply_filters( 'bp_core_avatar_default', $default_grav, $params );
654
 
655
  // Only set default image if 'Gravatar Logo' is not requested.
656
+ if ( 'gravatar_default' !== $default_grav ) {
657
  $url_args['d'] = $default_grav;
658
  }
659
 
717
  );
718
 
719
  $args = wp_parse_args( $args, $defaults );
720
+ extract( $args, EXTR_SKIP );
721
 
722
  /**
723
  * Filters whether or not to handle deleting an existing avatar.
744
  return true;
745
  }
746
 
747
+ if ( empty( $item_id ) ) {
748
+ if ( 'user' == $object )
749
+ $item_id = bp_displayed_user_id();
750
+ elseif ( 'group' == $object )
751
+ $item_id = buddypress()->groups->current_group->id;
752
+ elseif ( 'blog' == $object )
753
+ $item_id = $current_blog->id;
 
754
 
755
  /** This filter is documented in bp-core/bp-core-avatars.php */
756
+ $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object );
 
 
 
757
 
758
+ if ( !$item_id ) return false;
 
 
 
759
  }
760
 
761
+ if ( empty( $avatar_dir ) ) {
762
+ if ( 'user' == $object )
763
+ $avatar_dir = 'avatars';
764
+ elseif ( 'group' == $object )
765
+ $avatar_dir = 'group-avatars';
766
+ elseif ( 'blog' == $object )
767
+ $avatar_dir = 'blog-avatars';
 
768
 
769
  /** This filter is documented in bp-core/bp-core-avatars.php */
770
+ $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object );
 
 
 
771
 
772
+ if ( !$avatar_dir ) return false;
 
773
  }
774
 
775
  /** This filter is documented in bp-core/bp-core-avatars.php */
776
+ $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
777
 
778
+ if ( !file_exists( $avatar_folder_dir ) )
779
  return false;
 
780
 
781
  if ( $av_dir = opendir( $avatar_folder_dir ) ) {
782
+ while ( false !== ( $avatar_file = readdir($av_dir) ) ) {
783
+ if ( ( preg_match( "/-bpfull/", $avatar_file ) || preg_match( "/-bpthumb/", $avatar_file ) ) && '.' != $avatar_file && '..' != $avatar_file )
784
  @unlink( $avatar_folder_dir . '/' . $avatar_file );
 
785
  }
786
  }
787
+ closedir($av_dir);
788
 
789
  @rmdir( $avatar_folder_dir );
790
 
809
  * error message otherwise.
810
  */
811
  function bp_avatar_ajax_delete() {
812
+ // Bail if not a POST action.
813
+ if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
814
  wp_send_json_error();
815
  }
816
 
836
  // Handle delete.
837
  if ( bp_core_delete_existing_avatar( array( 'item_id' => $avatar_data['item_id'], 'object' => $avatar_data['object'] ) ) ) {
838
  $return = array(
839
+ 'avatar' => html_entity_decode( bp_core_fetch_avatar( array(
840
  'object' => $avatar_data['object'],
841
  'item_id' => $avatar_data['item_id'],
842
  'html' => false,
900
 
901
  // In case of an error, stop the process and display a feedback to the user.
902
  if ( ! empty( $bp->avatar_admin->original['error'] ) ) {
 
903
  bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->original['error'] ), 'error' );
904
  return false;
905
  }
917
  $bp->avatar_admin->image = new stdClass();
918
 
919
  // We only want to handle one image after resize.
920
+ if ( empty( $bp->avatar_admin->resized ) ) {
921
  $bp->avatar_admin->image->file = $bp->avatar_admin->original['file'];
922
  $bp->avatar_admin->image->dir = str_replace( $upload_path, '', $bp->avatar_admin->original['file'] );
923
  } else {
928
 
929
  // Check for WP_Error on what should be an image.
930
  if ( is_wp_error( $bp->avatar_admin->image->dir ) ) {
 
931
  bp_core_add_message( sprintf( __( 'Upload failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->image->dir->get_error_message() ), 'error' );
932
  return false;
933
  }
934
 
935
  // If the uploaded image is smaller than the "full" dimensions, throw a warning.
936
  if ( $avatar_attachment->is_too_small( $bp->avatar_admin->image->file ) ) {
937
+ bp_core_add_message( sprintf( __( 'You have selected an image that is smaller than recommended. For best results, upload a picture larger than %d x %d pixels.', 'buddypress' ), bp_core_avatar_full_width(), bp_core_avatar_full_height() ), 'error' );
 
938
  }
939
 
940
  // Set the url value for the image.
952
  * error message otherwise.
953
  */
954
  function bp_avatar_ajax_upload() {
955
+ // Bail if not a POST action.
956
+ if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
957
  wp_die();
958
  }
959
 
993
  $bp_params['upload_dir_filter'] = '';
994
  $needs_reset = array();
995
 
996
+ if ( 'user' === $bp_params['object'] && bp_is_active( 'xprofile' ) ) {
997
+ $bp_params['upload_dir_filter'] = 'xprofile_avatar_upload_dir';
998
 
999
  if ( ! bp_displayed_user_id() && ! empty( $bp_params['item_id'] ) ) {
1000
  $needs_reset = array( 'key' => 'displayed_user', 'value' => $bp->displayed_user );
1237
  * error message otherwise.
1238
  */
1239
  function bp_avatar_ajax_set() {
1240
+ // Bail if not a POST action.
1241
+ if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
1242
  wp_send_json_error();
1243
  }
1244
 
1276
 
1277
  } else {
1278
  $return = array(
1279
+ 'avatar' => html_entity_decode( bp_core_fetch_avatar( array(
1280
  'object' => $avatar_data['object'],
1281
  'item_id' => $avatar_data['item_id'],
1282
  'html' => false,
1286
  'item_id' => $avatar_data['item_id'],
1287
  );
1288
 
 
 
 
1289
  /**
1290
  * Fires if the new avatar was successfully captured.
1291
  *
1292
+ * @since 1.1.0 Used to inform the avatar was successfully cropped
1293
+ * @since 2.3.4 Add two new parameters to inform about the user id and
1294
+ * about the way the avatar was set (eg: 'crop' or 'camera')
1295
+ * Move the action at the right place, once the avatar is set
1296
+ * @since 2.8.0 Added the `$avatar_data` parameter.
1297
  *
1298
  * @param string $item_id Inform about the user id the avatar was set for.
1299
  * @param string $type Inform about the way the avatar was set ('camera').
1300
  * @param array $avatar_data Array of parameters passed to the avatar handler.
1301
  */
1302
+ do_action( 'xprofile_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'], $avatar_data );
1303
 
1304
  wp_send_json_success( $return );
1305
  }
1333
  // Handle crop.
1334
  if ( bp_core_avatar_handle_crop( $r ) ) {
1335
  $return = array(
1336
+ 'avatar' => html_entity_decode( bp_core_fetch_avatar( array(
1337
  'object' => $avatar_data['object'],
1338
  'item_id' => $avatar_data['item_id'],
1339
  'html' => false,
1344
  );
1345
 
1346
  if ( 'user' === $avatar_data['object'] ) {
 
 
 
1347
  /** This action is documented in bp-core/bp-core-avatars.php */
1348
+ do_action( 'xprofile_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'], $r );
1349
  } elseif ( 'group' === $avatar_data['object'] ) {
1350
  /** This action is documented in bp-groups/bp-groups-screens.php */
1351
  do_action( 'groups_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'], $r );
1824
  $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&amp;s=' . $size;
1825
  }
1826
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1827
  /**
1828
  * Filters the URL of the 'full' default avatar.
1829
  *
1830
  * @since 1.5.0
1831
  * @since 2.6.0 Added `$params`.
 
1832
  *
1833
  * @param string $avatar URL of the default avatar.
1834
  * @param array $params Params provided to bp_core_fetch_avatar().
1835
  */
1836
+ return apply_filters( 'bp_core_avatar_default', $avatar, $params );
1837
  }
1838
 
1839
  /**
1925
  function bp_avatar_is_front_edit() {
1926
  $retval = false;
1927
 
1928
+ // No need to carry on if the current WordPress version is not supported.
1929
+ if ( ! bp_attachments_is_wp_version_supported() ) {
1930
+ return $retval;
1931
+ }
1932
+
1933
  if ( bp_is_user_change_avatar() && 'crop-image' !== bp_get_avatar_admin_step() ) {
1934
  $retval = ! bp_core_get_root_option( 'bp-disable-avatar-uploads' );
1935
  }
bp-core/bp-core-blocks.php DELETED
@@ -1,399 +0,0 @@
1
- <?php
2
- /**
3
- * Core BP Blocks functions.
4
- *
5
- * @package BuddyPress
6
- * @subpackage Core
7
- * @since 6.0.0
8
- */
9
-
10
- // Exit if accessed directly.
11
- defined( 'ABSPATH' ) || exit;
12
-
13
- /**
14
- * BuddyPress blocks require WordPress >= 5.0.0 & the BP REST API.
15
- *
16
- * @since 6.0.0
17
- *
18
- * @return bool True if the current installation supports BP Blocks.
19
- * False otherwise.
20
- */
21
- function bp_support_blocks() {
22
- return bp_is_running_wp( '5.0.0' ) && bp_rest_api_is_available();
23
- }
24
-
25
- /**
26
- * Registers the BP Block components.
27
- *
28
- * @since 6.0.0
29
- * @since 9.0.0 Adds a dependency to `wp-server-side-render` if WP >= 5.3.
30
- * Uses a dependency to `wp-editor` otherwise.
31
- */
32
- function bp_register_block_components() {
33
- $server_side_renderer_dep = 'wp-server-side-render';
34
- if ( bp_is_running_wp( '5.3.0', '<' ) ) {
35
- $server_side_renderer_dep = 'wp-editor';
36
- }
37
-
38
- wp_register_script(
39
- 'bp-block-components',
40
- plugins_url( 'js/block-components.js', __FILE__ ),
41
- array(
42
- 'wp-element',
43
- 'wp-components',
44
- 'wp-i18n',
45
- 'wp-api-fetch',
46
- 'wp-url',
47
- $server_side_renderer_dep,
48
- ),
49
- bp_get_version(),
50
- false
51
- );
52
-
53
- // Adds BP Block Components to the `bp` global.
54
- wp_add_inline_script(
55
- 'bp-block-components',
56
- 'window.bp = window.bp || {};
57
- bp.blockComponents = bpBlock.blockComponents;
58
- delete bpBlock;',
59
- 'after'
60
- );
61
- }
62
- add_action( 'bp_blocks_init', 'bp_register_block_components', 1 );
63
-
64
- /**
65
- * Registers the BP Block Assets.
66
- *
67
- * @since 9.0.0
68
- */
69
- function bp_register_block_assets() {
70
- wp_register_script(
71
- 'bp-block-data',
72
- plugins_url( 'js/block-data.js', __FILE__ ),
73
- array(
74
- 'wp-data',
75
- 'wp-api-fetch',
76
- 'lodash',
77
- ),
78
- bp_get_version(),
79
- false
80
- );
81
-
82
- // Adds BP Block Assets to the `bp` global.
83
- wp_add_inline_script(
84
- 'bp-block-data',
85
- sprintf(
86
- 'window.bp = window.bp || {};
87
- bp.blockData = bpBlock.blockData;
88
- bp.blockData.embedScriptURL = \'%s\';
89
- delete bpBlock;',
90
- esc_url_raw( includes_url( 'js/wp-embed.min.js' ) )
91
- ),
92
- 'after'
93
- );
94
- }
95
- add_action( 'bp_blocks_init', 'bp_register_block_assets', 2 );
96
-
97
- /**
98
- * Filters the Block Editor settings to gather BuddyPress ones into a `bp` key.
99
- *
100
- * @since 6.0.0
101
- *
102
- * @param array $editor_settings Default editor settings.
103
- * @return array The editor settings including BP blocks specific ones.
104
- */
105
- function bp_blocks_editor_settings( $editor_settings = array() ) {
106
- /**
107
- * Filter here to include your BP Blocks specific settings.
108
- *
109
- * @since 6.0.0
110
- *
111
- * @param array $bp_editor_settings BP blocks specific editor settings.
112
- */
113
- $bp_editor_settings = (array) apply_filters( 'bp_blocks_editor_settings', array() );
114
-
115
- if ( $bp_editor_settings ) {
116
- $editor_settings['bp'] = $bp_editor_settings;
117
- }
118
-
119
- return $editor_settings;
120
- }
121
-
122
- /**
123
- * Select the right `block_editor_settings` filter according to WP version.
124
- *
125
- * @since 8.0.0
126
- */
127
- function bp_block_init_editor_settings_filter() {
128
- if ( function_exists( 'get_block_editor_settings' ) ) {
129
- add_filter( 'block_editor_settings_all', 'bp_blocks_editor_settings' );
130
- } else {
131
- add_filter( 'block_editor_settings', 'bp_blocks_editor_settings' );
132
- }
133
- }
134
- add_action( 'bp_init', 'bp_block_init_editor_settings_filter' );
135
-
136
- /**
137
- * Preload the Active BuddyPress Components.
138
- *
139
- * @since 9.0.0
140
- *
141
- * @param string[] $paths The Block Editors preload paths.
142
- * @return string[] The Block Editors preload paths.
143
- */
144
- function bp_blocks_preload_paths( $paths = array() ) {
145
- return array_merge(
146
- $paths,
147
- array(
148
- '/buddypress/v1/components?status=active',
149
- )
150
- );
151
- }
152
- add_filter( 'block_editor_rest_api_preload_paths', 'bp_blocks_preload_paths' );
153
-
154
- /**
155
- * Register a BuddyPress block type.
156
- *
157
- * @since 6.0.0
158
- *
159
- * @param array $args The registration arguments for the block type.
160
- * @return BP_Block The BuddyPress block type object.
161
- */
162
- function bp_register_block( $args = array() ) {
163
- return new BP_Block( $args );
164
- }
165
-
166
- /**
167
- * Gets a Widget Block list of classnames.
168
- *
169
- * @since 9.0.0
170
- *
171
- * @param string $block_name The Block name.
172
- * @return array The list of widget classnames for the Block.
173
- */
174
- function bp_blocks_get_widget_block_classnames( $block_name = '' ) {
175
- $components = bp_core_get_active_components( array(), 'objects' );
176
- $components['core'] = buddypress()->core;
177
- $classnames = array();
178
-
179
- foreach ( $components as $component ) {
180
- if ( isset( $component->block_globals[ $block_name ] ) ) {
181
- $block_props = $component->block_globals[ $block_name ]->props;
182
-
183
- if ( isset( $block_props['widget_classnames'] ) && $block_props['widget_classnames'] ) {
184
- $classnames = (array) $block_props['widget_classnames'];
185
- break;
186
- }
187
- }
188
- }
189
-
190
- return $classnames;
191
- }
192
-
193
- /**
194
- * Make sure the BP Widget Block classnames are included into Widget Blocks.
195
- *
196
- * @since 9.0.0
197
- *
198
- * @param string $classname The classname to be used in the block widget's container HTML.
199
- * @param string $block_name The name of the block.
200
- * @return string The classname to be used in the block widget's container HTML.
201
- */
202
- function bp_widget_block_dynamic_classname( $classname, $block_name ) {
203
- $bp_classnames = bp_blocks_get_widget_block_classnames( $block_name );
204
-
205
- if ( $bp_classnames ) {
206
- $bp_classnames = array_map( 'sanitize_html_class', $bp_classnames );
207
- $classname .= ' ' . implode( ' ', $bp_classnames );
208
- }
209
-
210
- return $classname;
211
- }
212
- add_filter( 'widget_block_dynamic_classname', 'bp_widget_block_dynamic_classname', 10, 2 );
213
-
214
- /**
215
- * Create a link to the registration form for use on the bottom of the login form widget.
216
- *
217
- * @since 9.0.0
218
- *
219
- * @param string $content Content to display. Default empty.
220
- * @param array $args Array of login form arguments.
221
- * @return string HTML output.
222
- */
223
- function bp_blocks_get_login_widget_registration_link( $content = '', $args = array() ) {
224
- if ( isset( $args['form_id'] ) && 'bp-login-widget-form' === $args['form_id'] && bp_get_signup_allowed() ) {
225
- $content .= sprintf(
226
- '<p class="bp-login-widget-register-link"><a href="%1$s">%2$s</a></p>',
227
- esc_url( bp_get_signup_page() ),
228
- esc_html__( 'Register', 'buddypress' )
229
- );
230
- }
231
-
232
- $action_output = '';
233
- if ( has_action( 'bp_login_widget_form' ) ) {
234
- ob_start();
235
- /**
236
- * Fires inside the display of the login widget form.
237
- *
238
- * @since 2.4.0
239
- */
240
- do_action( 'bp_login_widget_form' );
241
- $action_output = ob_get_clean();
242
- }
243
-
244
- if ( $action_output ) {
245
- $content .= $action_output;
246
- }
247
-
248
- return $content;
249
- }
250
-
251
- /**
252
- * Callback function to render the BP Login Form.
253
- *
254
- * @since 9.0.0
255
- *
256
- * @param array $attributes The block attributes.
257
- * @return string HTML output.
258
- */
259
- function bp_block_render_login_form_block( $attributes = array() ) {
260
- $block_args = wp_parse_args(
261
- $attributes,
262
- array(
263
- 'title' => '',
264
- )
265
- );
266
-
267
- $title = $block_args['title'];
268
-
269
- $classnames = 'widget_bp_core_login_widget buddypress widget';
270
- $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) );
271
-
272
- $widget_content = '';
273
-
274
- if ( $title ) {
275
- $widget_content .= sprintf(
276
- '<h2 class="widget-title">%s</h2>',
277
- esc_html( $title )
278
- );
279
- }
280
-
281
- if ( is_user_logged_in() ) {
282
- $action_output = '';
283
- if ( has_action( 'bp_before_login_widget_loggedin' ) ) {
284
- ob_start();
285
- /**
286
- * Fires before the display of widget content if logged in.
287
- *
288
- * @since 1.9.0
289
- */
290
- do_action( 'bp_before_login_widget_loggedin' );
291
- $action_output = ob_get_clean();
292
- }
293
-
294
- if ( $action_output ) {
295
- $widget_content .= $action_output;
296
- }
297
-
298
- $widget_content .= sprintf(
299
- '<div class="bp-login-widget-user-avatar">
300
- <a href="%1$s">
301
- %2$s
302
- </a>
303
- </div>',
304
- bp_loggedin_user_domain(),
305
- bp_get_loggedin_user_avatar(
306
- array(
307
- 'type' => 'thumb',
308
- 'width' => 50,
309
- 'height' => 50,
310
- )
311
- )
312
- );
313
-
314
- $widget_content .= sprintf(
315
- '<div class="bp-login-widget-user-links">
316
- <div class="bp-login-widget-user-link">%1$s</div>
317
- <div class="bp-login-widget-user-logout"><a class="logout" href="%2$s">%3$s</a></div>
318
- </div>',
319
- bp_core_get_userlink( bp_loggedin_user_id() ),
320
- wp_logout_url( bp_get_requested_url() ),
321
- __( 'Log Out', 'buddypress' )
322
- );
323
-
324
- $action_output = '';
325
- if ( has_action( 'bp_after_login_widget_loggedin' ) ) {
326
- ob_start();
327
- /**
328
- * Fires after the display of widget content if logged in.
329
- *
330
- * @since 1.9.0
331
- */
332
- do_action( 'bp_after_login_widget_loggedin' );
333
- $action_output = ob_get_clean();
334
- }
335
-
336
- if ( $action_output ) {
337
- $widget_content .= $action_output;
338
- }
339
- } else {
340
- $action_output = '';
341
- if ( has_action( 'bp_before_login_widget_loggedout' ) ) {
342
- ob_start();
343
- /**
344
- * Fires before the display of widget content if logged out.
345
- *
346
- * @since 1.9.0
347
- */
348
- do_action( 'bp_before_login_widget_loggedout' );
349
- $action_output = ob_get_clean();
350
- }
351
-
352
- if ( $action_output ) {
353
- $widget_content .= $action_output;
354
- }
355
-
356
- add_filter( 'login_form_bottom', 'bp_blocks_get_login_widget_registration_link', 10, 2 );
357
-
358
- $widget_content .= wp_login_form(
359
- array(
360
- 'echo' => false,
361
- 'form_id' => 'bp-login-widget-form',
362
- 'id_username' => 'bp-login-widget-user-login',
363
- 'label_username' => __( 'Username', 'buddypress' ),
364
- 'id_password' => 'bp-login-widget-user-pass',
365
- 'label_password' => __( 'Password', 'buddypress' ),
366
- 'id_remember' => 'bp-login-widget-rememberme',
367
- 'id_submit' => 'bp-login-widget-submit',
368
- )
369
- );
370
-
371
- remove_filter( 'login_form_bottom', 'bp_blocks_get_login_widget_registration_link', 10, 2 );
372
-
373
- $action_output = '';
374
- if ( has_action( 'bp_after_login_widget_loggedout' ) ) {
375
- ob_start();
376
- /**
377
- * Fires after the display of widget content if logged out.
378
- *
379
- * @since 1.9.0
380
- */
381
- do_action( 'bp_after_login_widget_loggedout' );
382
- $action_output = ob_get_clean();
383
- }
384
-
385
- if ( $action_output ) {
386
- $widget_content .= $action_output;
387
- }
388
- }
389
-
390
- if ( ! did_action( 'dynamic_sidebar_before' ) ) {
391
- return sprintf(
392
- '<div %1$s>%2$s</div>',
393
- $wrapper_attributes,
394
- $widget_content
395
- );
396
- }
397
-
398
- return $widget_content;
399
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/bp-core-buddybar.php CHANGED
@@ -5,6 +5,8 @@
5
  * @package BuddyPress
6
  * @subpackage Core
7
  * @since 1.5.0
 
 
8
  */
9
 
10
  // Exit if accessed directly.
@@ -15,13 +17,11 @@ defined( 'ABSPATH' ) || exit;
15
  *
16
  * @since 1.1.0
17
  * @since 2.6.0 Introduced the `$component` parameter.
18
- * @since 4.0.0 Introduced the `$component_id` argument.
19
  *
20
  * @param array|string $args {
21
  * Array describing the new nav item.
22
  * @type string $name Display name for the nav item.
23
  * @type string $slug Unique URL slug for the nav item.
24
- * @type string $component_id Optional. The ID of the component registering the nav item. Defaults to slug.
25
  * @type bool|string $item_css_id Optional. 'id' attribute for the nav item. Default: the value of `$slug`.
26
  * @type bool $show_for_displayed_user Optional. Whether the nav item should be visible when viewing a
27
  * member profile other than your own. Default: true.
@@ -44,7 +44,6 @@ function bp_core_new_nav_item( $args, $component = 'members' ) {
44
  $defaults = array(
45
  'name' => false, // Display name for the nav item.
46
  'slug' => false, // URL slug for the nav item.
47
- 'component_id' => '', // ID of the component registering the nav item.
48
  'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item.
49
  'show_for_displayed_user' => true, // When viewing another user does this nav item show up?
50
  'site_admin_only' => false, // Can only site admins see this nav item?
@@ -91,14 +90,10 @@ function bp_core_new_nav_item( $args, $component = 'members' ) {
91
  * Add a link to the main BuddyPress navigation.
92
  *
93
  * @since 2.4.0
94
- * @since 2.6.0 Introduced the `$component` parameter. Began returning a BP_Core_Nav_Item
95
- * object on success.
96
- * @since 4.0.0 Introduced `$component_id` argument.
97
  *
98
  * @param array|string $args {
99
  * Array describing the new nav item.
100
- * @type string $component_id Optional. The ID of the component registering this nav item. Defaults to the
101
- * the value of `$slug`.
102
  * @type string $name Display name for the nav item.
103
  * @type string $slug Unique URL slug for the nav item.
104
  * @type bool|string $item_css_id Optional. 'id' attribute for the nav item. Default: the value of `$slug`.
@@ -119,7 +114,6 @@ function bp_core_create_nav_link( $args = '', $component = 'members' ) {
119
  $bp = buddypress();
120
 
121
  $defaults = array(
122
- 'component_id' => '', // The component ID registering this nav item.
123
  'name' => false, // Display name for the nav item.
124
  'slug' => false, // URL slug for the nav item.
125
  'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item.
@@ -142,16 +136,11 @@ function bp_core_create_nav_link( $args = '', $component = 'members' ) {
142
  return false;
143
  }
144
 
145
- if ( empty( $r['component_id'] ) ) {
146
- $r['component_id'] = $r['slug'];
147
- }
148
-
149
  if ( empty( $r['item_css_id'] ) ) {
150
  $r['item_css_id'] = $r['slug'];
151
  }
152
 
153
  $nav_item = array(
154
- 'component_id' => $r['component_id'],
155
  'name' => $r['name'],
156
  'slug' => $r['slug'],
157
  'link' => trailingslashit( bp_loggedin_user_domain() . $r['slug'] ),
@@ -353,21 +342,6 @@ function bp_core_new_nav_default( $args = '' ) {
353
  // No subnav item has been requested in the URL, so set a new nav default.
354
  if ( empty( $unfiltered_action ) ) {
355
  if ( ! bp_is_current_action( $r['subnav_slug'] ) ) {
356
- /*
357
- * If the screen function isn't available, attempt to find it.
358
- *
359
- * This is due to our conditional-loading code since v3.0.0.
360
- */
361
- if ( ! is_callable( $r['screen_function'] ) && ! empty( $parent_nav->component_id ) ) {
362
- $file = $bp->core->path . 'bp-' . $parent_nav->component_id . '/screens/' . $r['subnav_slug'] . '.php';
363
- $file_path = realpath( $file );
364
-
365
- // Found the file, so require it.
366
- if ( $file === $file_path && file_exists( $file ) ) {
367
- require_once $file;
368
- }
369
- }
370
-
371
  if ( is_callable( $r['screen_function'] ) ) {
372
  add_action( 'bp_screens', $r['screen_function'], 3 );
373
  }
@@ -634,9 +608,6 @@ function bp_core_register_subnav_screen_function( $args = '', $component = 'memb
634
  }
635
 
636
  $parent_nav = $bp->{$component}->nav->get_primary( array( 'slug' => $r['parent_slug'] ), false );
637
- if ( is_array( $parent_nav ) ) {
638
- $parent_nav = reset( $parent_nav );
639
- }
640
 
641
  // If we *do* meet condition (2), then the added subnav item is currently being requested.
642
  if ( ( bp_current_action() && bp_is_current_action( $r['slug'] ) ) || ( bp_is_user() && ! bp_current_action() && ! empty( $parent_nav->screen_function ) && $r['screen_function'] == $parent_nav->screen_function ) ) {
@@ -699,9 +670,10 @@ function bp_core_maybe_hook_new_subnav_screen_function( $subnav_item, $component
699
 
700
  $bp = buddypress();
701
 
702
- // If a redirect URL has been passed to the subnav item, respect it.
 
703
  if ( ! empty( $subnav_item['no_access_url'] ) ) {
704
- $message = __( 'You do not have access to that page.', 'buddypress' );
705
  $redirect_to = trailingslashit( $subnav_item['no_access_url'] );
706
 
707
  // In the case of a user page, we try to assume a
@@ -717,7 +689,7 @@ function bp_core_maybe_hook_new_subnav_screen_function( $subnav_item, $component
717
  // component, as long as that component is
718
  // publicly accessible.
719
  if ( bp_is_my_profile() || ( isset( $parent_nav_default_item ) && $parent_nav_default_item->show_for_displayed_user ) ) {
720
- $message = __( 'You do not have access to that page.', 'buddypress' );
721
  $redirect_to = bp_displayed_user_domain();
722
 
723
  // In some cases, the default tab is not accessible to
@@ -745,7 +717,6 @@ function bp_core_maybe_hook_new_subnav_screen_function( $subnav_item, $component
745
  'message' => $message,
746
  'root' => $redirect_to,
747
  'redirect' => false,
748
- 'mode' => 1
749
  );
750
 
751
  } else {
5
  * @package BuddyPress
6
  * @subpackage Core
7
  * @since 1.5.0
8
+ *
9
+ * @todo Deprecate BuddyBar functions.
10
  */
11
 
12
  // Exit if accessed directly.
17
  *
18
  * @since 1.1.0
19
  * @since 2.6.0 Introduced the `$component` parameter.
 
20
  *
21
  * @param array|string $args {
22
  * Array describing the new nav item.
23
  * @type string $name Display name for the nav item.
24
  * @type string $slug Unique URL slug for the nav item.
 
25
  * @type bool|string $item_css_id Optional. 'id' attribute for the nav item. Default: the value of `$slug`.
26
  * @type bool $show_for_displayed_user Optional. Whether the nav item should be visible when viewing a
27
  * member profile other than your own. Default: true.
44
  $defaults = array(
45
  'name' => false, // Display name for the nav item.
46
  'slug' => false, // URL slug for the nav item.
 
47
  'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item.
48
  'show_for_displayed_user' => true, // When viewing another user does this nav item show up?
49
  'site_admin_only' => false, // Can only site admins see this nav item?
90
  * Add a link to the main BuddyPress navigation.
91
  *
92
  * @since 2.4.0
93
+ * @since 2.6.0 Introduced the `$component` parameter. Began returning a BP_Core_Nav_Item object on success.
 
 
94
  *
95
  * @param array|string $args {
96
  * Array describing the new nav item.
 
 
97
  * @type string $name Display name for the nav item.
98
  * @type string $slug Unique URL slug for the nav item.
99
  * @type bool|string $item_css_id Optional. 'id' attribute for the nav item. Default: the value of `$slug`.
114
  $bp = buddypress();
115
 
116
  $defaults = array(
 
117
  'name' => false, // Display name for the nav item.
118
  'slug' => false, // URL slug for the nav item.
119
  'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item.
136
  return false;
137
  }
138
 
 
 
 
 
139
  if ( empty( $r['item_css_id'] ) ) {
140
  $r['item_css_id'] = $r['slug'];
141
  }
142
 
143
  $nav_item = array(
 
144
  'name' => $r['name'],
145
  'slug' => $r['slug'],
146
  'link' => trailingslashit( bp_loggedin_user_domain() . $r['slug'] ),
342
  // No subnav item has been requested in the URL, so set a new nav default.
343
  if ( empty( $unfiltered_action ) ) {
344
  if ( ! bp_is_current_action( $r['subnav_slug'] ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
345
  if ( is_callable( $r['screen_function'] ) ) {
346
  add_action( 'bp_screens', $r['screen_function'], 3 );
347
  }
608
  }
609
 
610
  $parent_nav = $bp->{$component}->nav->get_primary( array( 'slug' => $r['parent_slug'] ), false );
 
 
 
611
 
612
  // If we *do* meet condition (2), then the added subnav item is currently being requested.
613
  if ( ( bp_current_action() && bp_is_current_action( $r['slug'] ) ) || ( bp_is_user() && ! bp_current_action() && ! empty( $parent_nav->screen_function ) && $r['screen_function'] == $parent_nav->screen_function ) ) {
670
 
671
  $bp = buddypress();
672
 
673
+ // If a redirect URL has been passed to the subnav
674
+ // item, respect it.
675
  if ( ! empty( $subnav_item['no_access_url'] ) ) {
676
+ $message = __( 'You do not have access to this page.', 'buddypress' );
677
  $redirect_to = trailingslashit( $subnav_item['no_access_url'] );
678
 
679
  // In the case of a user page, we try to assume a
689
  // component, as long as that component is
690
  // publicly accessible.
691
  if ( bp_is_my_profile() || ( isset( $parent_nav_default_item ) && $parent_nav_default_item->show_for_displayed_user ) ) {
692
+ $message = __( 'You do not have access to this page.', 'buddypress' );
693
  $redirect_to = bp_displayed_user_domain();
694
 
695
  // In some cases, the default tab is not accessible to
717
  'message' => $message,
718
  'root' => $redirect_to,
719
  'redirect' => false,
 
720
  );
721
 
722
  } else {
bp-core/bp-core-cache.php CHANGED
@@ -6,7 +6,7 @@
6
  * actions throughout BuddyPress.
7
  *
8
  * @package BuddyPress
9
- * @subpackage Cache
10
  * @since 1.5.0
11
  */
12
 
@@ -80,14 +80,14 @@ function bp_core_clear_directory_pages_cache_page_edit( $post_id = 0 ) {
80
  return;
81
  }
82
 
83
- // Bail if not on the root blog.
84
  if ( ! bp_is_root_blog() ) {
85
  return;
86
  }
87
 
88
  $page_ids = bp_core_get_directory_page_ids( 'all' );
89
 
90
- // Bail if post ID is not a directory page.
91
  if ( ! in_array( $post_id, $page_ids ) ) {
92
  return;
93
  }
@@ -306,23 +306,6 @@ function bp_core_set_incremented_cache( $key, $group, $ids ) {
306
  return wp_cache_set( $cache_key, $ids, $group );
307
  }
308
 
309
- /**
310
- * Delete a value that has been cached using an incremented key.
311
- *
312
- * A utility function for use by query methods like BP_Activity_Activity::get().
313
- *
314
- * @since 3.0.0
315
- * @see bp_core_set_incremented_cache()
316
- *
317
- * @param string $key Unique key for the query. Usually a SQL string.
318
- * @param string $group Cache group. Eg 'bp_activity'.
319
- * @return bool True on successful removal, false on failure.
320
- */
321
- function bp_core_delete_incremented_cache( $key, $group ) {
322
- $cache_key = bp_core_get_incremented_cache_key( $key, $group );
323
- return wp_cache_delete( $cache_key, $group );
324
- }
325
-
326
  /**
327
  * Gets the key to be used when caching a value using an incremented cache key.
328
  *
@@ -379,50 +362,3 @@ function bp_core_get_incrementor( $group ) {
379
  function bp_core_reset_incrementor( $group ) {
380
  return wp_cache_delete( 'incrementor', $group );
381
  }
382
-
383
- /**
384
- * Resets all incremented bp_invitations caches.
385
- *
386
- * @since 5.0.0
387
- */
388
- function bp_invitations_reset_cache_incrementor() {
389
- bp_core_reset_incrementor( 'bp_invitations' );
390
- }
391
- add_action( 'bp_invitation_after_save', 'bp_invitations_reset_cache_incrementor' );
392
- add_action( 'bp_invitation_after_delete', 'bp_invitations_reset_cache_incrementor' );
393
-
394
- /**
395
- * Add a cache group for Database object types.
396
- *
397
- * @since 7.0.0
398
- */
399
- function bp_set_object_type_terms_cache_group() {
400
- wp_cache_add_global_groups( 'bp_object_terms' );
401
- }
402
- add_action( 'bp_setup_cache_groups', 'bp_set_object_type_terms_cache_group' );
403
-
404
- /**
405
- * Clear the Database object types cache.
406
- *
407
- * @since 7.0.0
408
- *
409
- * @param int $type_id The Type's term ID.
410
- * @param string $taxonomy The Type's taxonomy name.
411
- */
412
- function bp_clear_object_type_terms_cache( $type_id = 0, $taxonomy = '' ) {
413
- wp_cache_delete( $taxonomy, 'bp_object_terms' );
414
- }
415
- add_action( 'bp_type_inserted', 'bp_clear_object_type_terms_cache' );
416
- add_action( 'bp_type_updated', 'bp_clear_object_type_terms_cache' );
417
- add_action( 'bp_type_deleted', 'bp_clear_object_type_terms_cache' );
418
-
419
- /**
420
- * Resets all incremented bp_optout caches.
421
- *
422
- * @since 8.0.0
423
- */
424
- function bp_optouts_reset_cache_incrementor() {
425
- bp_core_reset_incrementor( 'bp_optouts' );
426
- }
427
- add_action( 'bp_optout_after_save', 'bp_optouts_reset_cache_incrementor' );
428
- add_action( 'bp_optout_after_delete', 'bp_optouts_reset_cache_incrementor' );
6
  * actions throughout BuddyPress.
7
  *
8
  * @package BuddyPress
9
+ * @supackage Cache
10
  * @since 1.5.0
11
  */
12
 
80
  return;
81
  }
82
 
83
+ // Bail if not on the root blog
84
  if ( ! bp_is_root_blog() ) {
85
  return;
86
  }
87
 
88
  $page_ids = bp_core_get_directory_page_ids( 'all' );
89
 
90
+ // Bail if post ID is not a directory page
91
  if ( ! in_array( $post_id, $page_ids ) ) {
92
  return;
93
  }
306
  return wp_cache_set( $cache_key, $ids, $group );
307
  }
308
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
  /**
310
  * Gets the key to be used when caching a value using an incremented cache key.
311
  *
362
  function bp_core_reset_incrementor( $group ) {
363
  return wp_cache_delete( 'incrementor', $group );
364
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/bp-core-caps.php CHANGED
@@ -344,49 +344,6 @@ function bp_user_can( $user_id, $capability, $args = array() ) {
344
  return $retval;
345
  }
346
 
347
- /**
348
- * Adds the `bp_moderate` cap to Roles having the `manage_options` cap when
349
- * BuddyPress is not active on the network.
350
- *
351
- * @since 7.0.0
352
- *
353
- * @access private
354
- *
355
- * @param WP_Roles $wp_roles The WordPress roles object.
356
- */
357
- function _bp_roles_init( WP_Roles $wp_roles ) {
358
- $roles_list = array();
359
- $caps_list = wp_list_pluck( $wp_roles->role_objects, 'capabilities' );
360
-
361
- // Look for roles having the `manage_options` capability set to true.
362
- $filtered_list = wp_list_filter( $caps_list, array( 'manage_options' => true ) );
363
-
364
- if ( $filtered_list ) {
365
- $roles_list = array_keys( $filtered_list );
366
-
367
- // Loop into roles list to add the `bp_moderate` capability.
368
- foreach ( $roles_list as $role ) {
369
- if ( isset( $wp_roles->roles[ $role ] ) ) {
370
- $wp_roles->roles[ $role ]['capabilities']['bp_moderate'] = true;
371
- }
372
-
373
- if ( isset( $wp_roles->role_objects[ $role ] ) ) {
374
- $wp_roles->role_objects[ $role ]->capabilities['bp_moderate'] = true;
375
- }
376
- }
377
- }
378
-
379
- // Make sure to remove the `bp_moderate` capability from roles when BuddyPress is network activated.
380
- if ( bp_is_network_activated() ) {
381
- foreach ( $roles_list as $role ) {
382
- unset( $wp_roles->roles[ $role ]['capabilities']['bp_moderate'], $wp_roles->role_objects[ $role ]->capabilities['bp_moderate'] );
383
- }
384
- }
385
- }
386
- add_action( 'wp_roles_init', '_bp_roles_init', 10, 1 );
387
-
388
- /** Deprecated ****************************************************************/
389
-
390
  /**
391
  * Temporary implementation of 'bp_moderate' cap.
392
  *
@@ -406,7 +363,6 @@ add_action( 'wp_roles_init', '_bp_roles_init', 10, 1 );
406
  * Plugin authors: Please do not use this function; thank you. :)
407
  *
408
  * @since 1.6.0
409
- * @deprecated 7.0.0
410
  *
411
  * @access private
412
  *
@@ -419,7 +375,6 @@ add_action( 'wp_roles_init', '_bp_roles_init', 10, 1 );
419
  * @return array $allcaps The user's cap list, with 'bp_moderate' appended, if relevant.
420
  */
421
  function _bp_enforce_bp_moderate_cap_for_admins( $caps = array(), $cap = '', $user_id = 0, $args = array() ) {
422
- _deprecated_function( __FUNCTION__, '7.0.0' );
423
 
424
  // Bail if not checking the 'bp_moderate' cap.
425
  if ( 'bp_moderate' !== $cap ) {
@@ -439,6 +394,9 @@ function _bp_enforce_bp_moderate_cap_for_admins( $caps = array(), $cap = '', $us
439
  // Only users that can 'manage_options' on this site can 'bp_moderate'.
440
  return array( 'manage_options' );
441
  }
 
 
 
442
 
443
  /**
444
  * Adds BuddyPress-specific user roles.
344
  return $retval;
345
  }
346
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
  /**
348
  * Temporary implementation of 'bp_moderate' cap.
349
  *
363
  * Plugin authors: Please do not use this function; thank you. :)
364
  *
365
  * @since 1.6.0
 
366
  *
367
  * @access private
368
  *
375
  * @return array $allcaps The user's cap list, with 'bp_moderate' appended, if relevant.
376
  */
377
  function _bp_enforce_bp_moderate_cap_for_admins( $caps = array(), $cap = '', $user_id = 0, $args = array() ) {
 
378
 
379
  // Bail if not checking the 'bp_moderate' cap.
380
  if ( 'bp_moderate' !== $cap ) {
394
  // Only users that can 'manage_options' on this site can 'bp_moderate'.
395
  return array( 'manage_options' );
396
  }
397
+ add_filter( 'map_meta_cap', '_bp_enforce_bp_moderate_cap_for_admins', 10, 4 );
398
+
399
+ /** Deprecated ****************************************************************/
400
 
401
  /**
402
  * Adds BuddyPress-specific user roles.
bp-core/bp-core-catchuri.php CHANGED
@@ -97,7 +97,7 @@ function bp_core_set_uri_globals() {
97
  foreach( $chunks as $key => $chunk ) {
98
  $bkey = array_search( $chunk, $bp_uri );
99
 
100
- // ...and unset offending keys.
101
  if ( false !== $bkey ) {
102
  unset( $bp_uri[$bkey] );
103
  }
@@ -240,7 +240,7 @@ function bp_core_set_uri_globals() {
240
  }
241
 
242
  // Search doesn't have an associated page, so we check for it separately.
243
- if ( isset( $_POST['search-terms'] ) && !empty( $bp_uri[0] ) && ( bp_get_search_slug() == $bp_uri[0] ) ) {
244
  $matches[] = 1;
245
  $match = new stdClass;
246
  $match->key = 'search';
@@ -463,7 +463,7 @@ function bp_core_load_template( $templates ) {
463
  * Wiping out the bp-default template allows WordPress to use their special
464
  * embed template, which is what we want.
465
  */
466
- if ( is_embed() ) {
467
  $located_template = '';
468
  }
469
 
97
  foreach( $chunks as $key => $chunk ) {
98
  $bkey = array_search( $chunk, $bp_uri );
99
 
100
+ // ...and unset offending keys
101
  if ( false !== $bkey ) {
102
  unset( $bp_uri[$bkey] );
103
  }
240
  }
241
 
242
  // Search doesn't have an associated page, so we check for it separately.
243
+ if ( !empty( $bp_uri[0] ) && ( bp_get_search_slug() == $bp_uri[0] ) ) {
244
  $matches[] = 1;
245
  $match = new stdClass;
246
  $match->key = 'search';
463
  * Wiping out the bp-default template allows WordPress to use their special
464
  * embed template, which is what we want.
465
  */
466
+ if ( function_exists( 'is_embed' ) && is_embed() ) {
467
  $located_template = '';
468
  }
469
 
bp-core/bp-core-cssjs.php CHANGED
@@ -27,23 +27,7 @@ function bp_core_register_common_scripts() {
27
  * eg. French (France) locale for WP is fr_FR. Here, we try to find fr-fr.js
28
  * (this file doesn't exist).
29
  */
30
- $wp_locale = sanitize_file_name( strtolower( get_locale() ) );
31
-
32
- // WP uses ISO 639-2 or -3 codes for some locales, which we must translate back to ISO 639-1.
33
- $iso_locales = array(
34
- 'bel' => 'be',
35
- 'bre' => 'br',
36
- 'kir' => 'ky',
37
- 'mri' => 'mi',
38
- 'ssw' => 'ss',
39
- );
40
-
41
- if ( isset( $iso_locales[ $wp_locale ] ) ) {
42
- $locale = $iso_locales[ $wp_locale ];
43
- } else {
44
- $locale = $wp_locale;
45
- }
46
-
47
  $locale = str_replace( '_', '-', $locale );
48
  if ( file_exists( buddypress()->core->path . "bp-core/js/vendor/moment-js/locale/{$locale}{$min}.js" ) ) {
49
  $moment_locale_url = $url . "vendor/moment-js/locale/{$locale}{$min}.js";
@@ -85,9 +69,6 @@ function bp_core_register_common_scripts() {
85
  // Version 2.7.
86
  'bp-moment' => array( 'file' => "{$url}vendor/moment-js/moment{$min}.js", 'dependencies' => array(), 'footer' => true ),
87
  'bp-livestamp' => array( 'file' => "{$url}vendor/livestamp{$min}.js", 'dependencies' => array( 'jquery', 'bp-moment' ), 'footer' => true ),
88
-
89
- // Version 9.0.
90
- 'bp-dynamic-widget-block-script' => array( 'file' => "{$url}dynamic-widget-block.js", 'dependencies' => array( 'lodash', 'wp-url' ), 'footer' => true ),
91
  );
92
 
93
  // Version 2.7 - Add Moment.js locale to our $scripts array if we found one.
@@ -159,7 +140,7 @@ function bp_core_register_common_styles() {
159
  foreach ( $styles as $id => $style ) {
160
  wp_register_style( $id, $style['file'], $style['dependencies'], bp_get_version() );
161
 
162
- wp_style_add_data( $id, 'rtl', 'replace' );
163
  if ( $min ) {
164
  wp_style_add_data( $id, 'suffix', $min );
165
  }
@@ -303,14 +284,14 @@ function bp_core_add_cropper_inline_js() {
303
  ?>
304
 
305
  <script type="text/javascript">
306
- jQuery( window ).on( 'load', function() {
307
- jQuery( '#avatar-to-crop' ).Jcrop( {
308
  onChange: showPreview,
309
  onSelect: updateCoords,
310
  aspectRatio: <?php echo (int) $aspect_ratio; ?>,
311
  setSelect: [ <?php echo (int) $crop_left; ?>, <?php echo (int) $crop_top; ?>, <?php echo (int) $crop_right; ?>, <?php echo (int) $crop_bottom; ?> ]
312
- } );
313
- } );
314
 
315
  function updateCoords(c) {
316
  jQuery('#x').val(c.x);
@@ -445,7 +426,7 @@ function bp_add_cover_image_inline_css( $return = false ) {
445
  }
446
 
447
  $cover_image_object = array(
448
- 'component' => 'members',
449
  'object' => $bp->displayed_user
450
  );
451
  } elseif ( bp_is_group() ) {
@@ -482,7 +463,7 @@ function bp_add_cover_image_inline_css( $return = false ) {
482
 
483
  $object_dir = $cover_image_object['component'];
484
 
485
- if ( 'members' === $object_dir ) {
486
  $object_dir = 'members';
487
  }
488
 
@@ -555,7 +536,12 @@ function bp_core_enqueue_livestamp() {
555
  */
556
  if ( wp_script_is( 'bp-moment-locale', 'registered' ) ) {
557
  wp_enqueue_script( 'bp-moment-locale' );
558
- wp_add_inline_script ( 'bp-livestamp', bp_core_moment_js_config() );
 
 
 
 
 
559
  }
560
 
561
  wp_enqueue_script( 'bp-livestamp' );
@@ -582,3 +568,20 @@ EOD;
582
 
583
  return $inline_js;
584
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  * eg. French (France) locale for WP is fr_FR. Here, we try to find fr-fr.js
28
  * (this file doesn't exist).
29
  */
30
+ $locale = sanitize_file_name( strtolower( get_locale() ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  $locale = str_replace( '_', '-', $locale );
32
  if ( file_exists( buddypress()->core->path . "bp-core/js/vendor/moment-js/locale/{$locale}{$min}.js" ) ) {
33
  $moment_locale_url = $url . "vendor/moment-js/locale/{$locale}{$min}.js";
69
  // Version 2.7.
70
  'bp-moment' => array( 'file' => "{$url}vendor/moment-js/moment{$min}.js", 'dependencies' => array(), 'footer' => true ),
71
  'bp-livestamp' => array( 'file' => "{$url}vendor/livestamp{$min}.js", 'dependencies' => array( 'jquery', 'bp-moment' ), 'footer' => true ),
 
 
 
72
  );
73
 
74
  // Version 2.7 - Add Moment.js locale to our $scripts array if we found one.
140
  foreach ( $styles as $id => $style ) {
141
  wp_register_style( $id, $style['file'], $style['dependencies'], bp_get_version() );
142
 
143
+ wp_style_add_data( $id, 'rtl', true );
144
  if ( $min ) {
145
  wp_style_add_data( $id, 'suffix', $min );
146
  }
284
  ?>
285
 
286
  <script type="text/javascript">
287
+ jQuery(window).load( function(){
288
+ jQuery('#avatar-to-crop').Jcrop({
289
  onChange: showPreview,
290
  onSelect: updateCoords,
291
  aspectRatio: <?php echo (int) $aspect_ratio; ?>,
292
  setSelect: [ <?php echo (int) $crop_left; ?>, <?php echo (int) $crop_top; ?>, <?php echo (int) $crop_right; ?>, <?php echo (int) $crop_bottom; ?> ]
293
+ });
294
+ });
295
 
296
  function updateCoords(c) {
297
  jQuery('#x').val(c.x);
426
  }
427
 
428
  $cover_image_object = array(
429
+ 'component' => 'xprofile',
430
  'object' => $bp->displayed_user
431
  );
432
  } elseif ( bp_is_group() ) {
463
 
464
  $object_dir = $cover_image_object['component'];
465
 
466
+ if ( 'xprofile' === $object_dir ) {
467
  $object_dir = 'members';
468
  }
469
 
536
  */
537
  if ( wp_script_is( 'bp-moment-locale', 'registered' ) ) {
538
  wp_enqueue_script( 'bp-moment-locale' );
539
+
540
+ if ( function_exists( 'wp_add_inline_script' ) ) {
541
+ wp_add_inline_script ( 'bp-livestamp', bp_core_moment_js_config() );
542
+ } else {
543
+ add_action( 'wp_footer', '_bp_core_moment_js_config_footer', 20 );
544
+ }
545
  }
546
 
547
  wp_enqueue_script( 'bp-livestamp' );
568
 
569
  return $inline_js;
570
  }
571
+
572
+ /**
573
+ * Print moment.js config in page footer.
574
+ *
575
+ * Will be removed once we set our minimum version of WP 4.5.
576
+ *
577
+ * @since 2.7.0
578
+ *
579
+ * @access private
580
+ */
581
+ function _bp_core_moment_js_config_footer() {
582
+ if ( ! wp_script_is( 'bp-moment-locale' ) ) {
583
+ return;
584
+ }
585
+
586
+ printf( '<script>%s</script>', bp_core_moment_js_config() );
587
+ }
bp-core/bp-core-customizer-email.php CHANGED
@@ -18,6 +18,12 @@ defined( 'ABSPATH' ) || exit;
18
  * @param WP_Customize_Manager $wp_customize The Customizer object.
19
  */
20
  function bp_email_init_customizer( WP_Customize_Manager $wp_customize ) {
 
 
 
 
 
 
21
  if ( ! bp_is_email_customizer() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
22
  return;
23
  }
18
  * @param WP_Customize_Manager $wp_customize The Customizer object.
19
  */
20
  function bp_email_init_customizer( WP_Customize_Manager $wp_customize ) {
21
+
22
+ // Require WP 4.0+.
23
+ if ( ! method_exists( $wp_customize, 'add_panel' ) ) {
24
+ return;
25
+ }
26
+
27
  if ( ! bp_is_email_customizer() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
28
  return;
29
  }
bp-core/bp-core-dependency.php CHANGED
@@ -7,7 +7,7 @@
7
  * own in a safe and reliable way.
8
  *
9
  * We do this in BuddyPress by mirroring existing WordPress hooks in many places
10
- * allowing dependent plugins to hook into the BuddyPress specific ones, thus
11
  * guaranteeing proper code execution only when BuddyPress is active.
12
  *
13
  * The following functions are wrappers for hooks, allowing them to be
@@ -33,23 +33,6 @@ function bp_include() {
33
  do_action( 'bp_include' );
34
  }
35
 
36
- /**
37
- * Fire the 'bp_late_include' action for loading conditional files.
38
- *
39
- * @since 3.0.0
40
- */
41
- function bp_late_include() {
42
-
43
- /**
44
- * Fires the 'bp_late_include' action.
45
- *
46
- * Allow for conditional includes on certain pages.
47
- *
48
- * @since 3.0.0
49
- */
50
- do_action( 'bp_late_include' );
51
- }
52
-
53
  /**
54
  * Fire the 'bp_setup_components' action, where plugins should initialize components.
55
  *
@@ -95,21 +78,6 @@ function bp_register_taxonomies() {
95
  do_action( 'bp_register_taxonomies' );
96
  }
97
 
98
- /**
99
- * Fire the 'bp_register_type_metadata' action, where plugins should register metadata for their custom BuddyPress types.
100
- *
101
- * @since 7.0.0
102
- */
103
- function bp_register_type_metadata() {
104
-
105
- /**
106
- * Fires inside the 'bp_register_type_metadata' function, where plugins should register metadata for their custom BuddyPress types.
107
- *
108
- * @since 7.0.0
109
- */
110
- do_action( 'bp_register_type_metadata' );
111
- }
112
-
113
  /**
114
  * Fire the 'bp_register_post_types' action, where plugins should register post types.
115
  *
@@ -282,20 +250,6 @@ function bp_rest_api_init() {
282
  do_action( 'bp_rest_api_init' );
283
  }
284
 
285
- /**
286
- * BP Blocks Init hook.
287
- *
288
- * @since 6.0.0
289
- */
290
- function bp_blocks_init() {
291
- /**
292
- * Hook here to register your BuddyPress blocks.
293
- *
294
- * @since 6.0.0
295
- */
296
- do_action( 'bp_blocks_init' );
297
- }
298
-
299
  /**
300
  * Fire the 'bp_customize_register' action when the Customizer has loaded,
301
  * allowing scripts and styles to be initialized.
7
  * own in a safe and reliable way.
8
  *
9
  * We do this in BuddyPress by mirroring existing WordPress hooks in many places
10
+ * allowing dependant plugins to hook into the BuddyPress specific ones, thus
11
  * guaranteeing proper code execution only when BuddyPress is active.
12
  *
13
  * The following functions are wrappers for hooks, allowing them to be
33
  do_action( 'bp_include' );
34
  }
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  /**
37
  * Fire the 'bp_setup_components' action, where plugins should initialize components.
38
  *
78
  do_action( 'bp_register_taxonomies' );
79
  }
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  /**
82
  * Fire the 'bp_register_post_types' action, where plugins should register post types.
83
  *
250
  do_action( 'bp_rest_api_init' );
251
  }
252
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  /**
254
  * Fire the 'bp_customize_register' action when the Customizer has loaded,
255
  * allowing scripts and styles to be initialized.
bp-core/bp-core-filters.php CHANGED
@@ -59,9 +59,6 @@ add_filter( 'bp_email_set_content_html', 'stripslashes', 8 );
59
  add_filter( 'bp_email_set_content_plaintext', 'wp_strip_all_tags', 6 );
60
  add_filter( 'bp_email_set_subject', 'sanitize_text_field', 6 );
61
 
62
- // Avatars.
63
- add_filter( 'bp_core_fetch_avatar', 'bp_core_add_loading_lazy_attribute' );
64
-
65
  /**
66
  * Template Compatibility.
67
  *
@@ -104,6 +101,9 @@ function bp_core_exclude_pages( $pages = array() ) {
104
  if ( !empty( $bp->pages->register ) )
105
  $pages[] = $bp->pages->register->id;
106
 
 
 
 
107
  /**
108
  * Filters specific pages that shouldn't show up on page listings.
109
  *
@@ -437,7 +437,7 @@ function bp_core_filter_blog_welcome_email( $welcome_email, $blog_id, $user_id,
437
  if ( ! bp_has_custom_signup_page() )
438
  return $welcome_email;
439
 
440
- // [User Set] Replaces $password in welcome email; Represents value set by user.
441
  return str_replace( $password, __( '[User Set]', 'buddypress' ), $welcome_email );
442
  }
443
  add_filter( 'update_welcome_email', 'bp_core_filter_blog_welcome_email', 10, 4 );
@@ -472,22 +472,7 @@ function bp_core_activation_signup_blog_notification( $domain, $path, $title, $u
472
  'user.email' => $user_email,
473
  ),
474
  );
475
-
476
- $signups = BP_Signup::get(
477
- array(
478
- 'user_login' => $user,
479
- )
480
- );
481
-
482
- $salutation = $user;
483
- if ( $signups && bp_is_active( 'xprofile' ) ) {
484
- $signup = $signups['signups'][0];
485
- if ( isset( $signup->meta[ 'field_' . bp_xprofile_fullname_field_id() ] ) ) {
486
- $salutation = $signup->meta[ 'field_' . bp_xprofile_fullname_field_id() ];
487
- }
488
- }
489
-
490
- bp_send_email( 'core-user-registration-with-blog', array( array( $user_email => $salutation ) ), $args );
491
 
492
  // Return false to stop the original WPMU function from continuing.
493
  return false;
@@ -541,13 +526,6 @@ function bp_core_activation_signup_user_notification( $user, $user_email, $key,
541
  $user_id = $user_object->ID;
542
  }
543
 
544
- $salutation = $user;
545
- if ( bp_is_active( 'xprofile' ) && isset( $meta[ 'field_' . bp_xprofile_fullname_field_id() ] ) ) {
546
- $salutation = $meta[ 'field_' . bp_xprofile_fullname_field_id() ];
547
- } elseif ( $user_id ) {
548
- $salutation = bp_core_get_user_displayname( $user_id );
549
- }
550
-
551
  $args = array(
552
  'tokens' => array(
553
  'activate.url' => esc_url( trailingslashit( bp_get_activation_page() ) . "{$key}/" ),
@@ -556,7 +534,7 @@ function bp_core_activation_signup_user_notification( $user, $user_email, $key,
556
  'user.id' => $user_id,
557
  ),
558
  );
559
- bp_send_email( 'core-user-registration', array( array( $user_email => $salutation ) ), $args );
560
 
561
  // Return false to stop the original WPMU function from continuing.
562
  return false;
@@ -603,7 +581,6 @@ function bp_modify_page_title( $title = '', $sep = '&raquo;', $seplocation = 'ri
603
  $bp_title_parts['site'] = $blogname;
604
 
605
  if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() && ! bp_is_single_activity() ) {
606
- /* translators: %s: the page number. */
607
  $bp_title_parts['page'] = sprintf( __( 'Page %s', 'buddypress' ), max( $paged, $page ) );
608
  }
609
  }
@@ -694,16 +671,6 @@ add_filter( 'document_title_parts', 'bp_modify_document_title_parts', 20, 1 );
694
  */
695
  function bp_setup_nav_menu_item( $menu_item ) {
696
  if ( is_admin() ) {
697
- if ( 'bp_nav_menu_item' === $menu_item->object ) {
698
- $menu_item->type = 'custom';
699
- $menu_item->url = $menu_item->guid;
700
-
701
- if ( ! in_array( array( 'bp-menu', 'bp-'. $menu_item->post_excerpt .'-nav' ), $menu_item->classes ) ) {
702
- $menu_item->classes[] = 'bp-menu';
703
- $menu_item->classes[] = 'bp-'. $menu_item->post_excerpt .'-nav';
704
- }
705
- }
706
-
707
  return $menu_item;
708
  }
709
 
@@ -825,7 +792,7 @@ add_filter( 'customize_nav_menu_available_items', 'bp_customizer_nav_menus_get_i
825
  *
826
  * @since 2.3.3
827
  *
828
- * @param array $item_types An associative array structured for the customizer.
829
  * @return array $item_types An associative array structured for the customizer.
830
  */
831
  function bp_customizer_nav_menus_set_item_types( $item_types = array() ) {
@@ -902,31 +869,6 @@ function bp_core_filter_edit_post_link( $edit_link = '', $post_id = 0 ) {
902
  return $edit_link;
903
  }
904
 
905
- /**
906
- * Add 'loading="lazy"' attribute into images and iframes.
907
- *
908
- * @since 7.0.0
909
- *
910
- * @string $content Content to inject attribute into.
911
- * @return string
912
- */
913
- function bp_core_add_loading_lazy_attribute( $content = '' ) {
914
- if ( false === strpos( $content, '<img ' ) && false === strpos( $content, '<iframe ' ) ) {
915
- return $content;
916
- }
917
-
918
- $content = str_replace( '<img ', '<img loading="lazy" ', $content );
919
- $content = str_replace( '<iframe ', '<iframe loading="lazy" ', $content );
920
-
921
- // WordPress posts need their position absolute removed for lazyloading.
922
- $find_pos_absolute = ' style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" ';
923
- if ( false !== strpos( $content, 'data-secret=' ) && false !== strpos( $content, $find_pos_absolute ) ) {
924
- $content = str_replace( $find_pos_absolute, '', $content );
925
- }
926
-
927
- return $content;
928
- }
929
-
930
  /**
931
  * Should BuddyPress load the mentions scripts and related assets, including results to prime the
932
  * mentions suggestions?
@@ -1025,7 +967,7 @@ function bp_email_add_link_color_to_template( $value, $property_name, $transform
1025
  }
1026
 
1027
  $settings = bp_email_get_appearance_settings();
1028
- $replacement = 'style="color: ' . esc_attr( $settings['link_text_color'] ) . ';';
1029
 
1030
  // Find all links.
1031
  preg_match_all( '#<a[^>]+>#i', $value, $links, PREG_SET_ORDER );
@@ -1066,22 +1008,13 @@ function bp_email_set_default_headers( $headers, $property, $transform, $email )
1066
  $tokens = $email->get_tokens();
1067
 
1068
  // Add 'List-Unsubscribe' header if applicable.
1069
- if ( ! empty( $tokens['unsubscribe'] ) && $tokens['unsubscribe'] !== wp_login_url() ) {
1070
- $user = get_user_by( 'email', $tokens['recipient.email'] );
1071
- $user_id = isset( $user->ID ) ? $user->ID : 0;
1072
 
1073
- $args = array(
1074
- 'user_id' => $user_id,
1075
  'notification_type' => $email->get( 'type' ),
1076
- );
1077
-
1078
- // If this email is not to a current member, include the nonmember's email address and the Inviter ID.
1079
- if ( ! $user_id ) {
1080
- $args['email_address'] = $tokens['recipient.email'];
1081
- $args['member_id'] = bp_loggedin_user_id();
1082
- }
1083
-
1084
- $link = bp_email_get_unsubscribe_link( $args );
1085
 
1086
  if ( ! empty( $link ) ) {
1087
  $headers['List-Unsubscribe'] = sprintf( '<%s>', esc_url_raw( $link ) );
@@ -1105,8 +1038,7 @@ add_filter( 'bp_email_get_headers', 'bp_email_set_default_headers', 6, 4 );
1105
  */
1106
  function bp_email_set_default_tokens( $tokens, $property_name, $transform, $email ) {
1107
  $tokens['site.admin-email'] = bp_get_option( 'admin_email' );
1108
- $tokens['site.url'] = bp_get_root_domain();
1109
- $tokens['email.subject'] = $email->get_subject();
1110
 
1111
  // These options are escaped with esc_html on the way into the database in sanitize_option().
1112
  $tokens['site.description'] = wp_specialchars_decode( bp_get_option( 'blogdescription' ), ENT_QUOTES );
@@ -1118,6 +1050,7 @@ function bp_email_set_default_tokens( $tokens, $property_name, $transform, $emai
1118
  $tokens['recipient.name'] = '';
1119
  $tokens['recipient.username'] = '';
1120
 
 
1121
  // Who is the email going to?
1122
  $recipient = $email->get( 'to' );
1123
  if ( $recipient ) {
@@ -1133,7 +1066,6 @@ function bp_email_set_default_tokens( $tokens, $property_name, $transform, $emai
1133
 
1134
  if ( $user_obj ) {
1135
  $tokens['recipient.username'] = $user_obj->user_login;
1136
-
1137
  if ( bp_is_active( 'settings' ) && empty( $tokens['unsubscribe'] ) ) {
1138
  $tokens['unsubscribe'] = esc_url( sprintf(
1139
  '%s%s/notifications/',
@@ -1146,13 +1078,13 @@ function bp_email_set_default_tokens( $tokens, $property_name, $transform, $emai
1146
 
1147
  // Set default unsubscribe link if not passed.
1148
  if ( empty( $tokens['unsubscribe'] ) ) {
1149
- $tokens['unsubscribe'] = wp_login_url();
1150
  }
1151
 
1152
  // Email preheader.
1153
- $preheader = $email->get_preheader();
1154
- if ( $preheader ) {
1155
- $tokens['email.preheader'] = $preheader;
1156
  }
1157
 
1158
  return $tokens;
@@ -1201,7 +1133,7 @@ function bp_core_render_email_template( $template ) {
1201
 
1202
  // Make sure we add a <title> tag so WP Customizer picks it up.
1203
  $template = str_replace( '<head>', '<head><title>' . esc_html_x( 'BuddyPress Emails', 'screen heading', 'buddypress' ) . '</title>', $template );
1204
- echo str_replace( '{{{content}}}', wpautop( get_post()->post_content ), $template );
1205
 
1206
  /*
1207
  * Link colours are applied directly in the email template before sending, so we
@@ -1216,18 +1148,3 @@ function bp_core_render_email_template( $template ) {
1216
  return '';
1217
  }
1218
  add_action( 'bp_template_include', 'bp_core_render_email_template', 12 );
1219
-
1220
- /**
1221
- * Adds BuddyPress components' slugs to the WordPress Multisite subdirectory reserved names.
1222
- *
1223
- * @since 6.0.0
1224
- *
1225
- * @param array $names The WordPress Multisite subdirectory reserved names.
1226
- * @return array The WordPress & BuddyPress Multisite subdirectory reserved names.
1227
- */
1228
- function bp_core_components_subdirectory_reserved_names( $names = array() ) {
1229
- $bp_pages = (array) buddypress()->pages;
1230
-
1231
- return array_merge( $names, wp_list_pluck( $bp_pages, 'slug' ) );
1232
- }
1233
- add_filter( 'subdirectory_reserved_names', 'bp_core_components_subdirectory_reserved_names' );
59
  add_filter( 'bp_email_set_content_plaintext', 'wp_strip_all_tags', 6 );
60
  add_filter( 'bp_email_set_subject', 'sanitize_text_field', 6 );
61
 
 
 
 
62
  /**
63
  * Template Compatibility.
64
  *
101
  if ( !empty( $bp->pages->register ) )
102
  $pages[] = $bp->pages->register->id;
103
 
104
+ if ( !empty( $bp->pages->forums ) && ( !bp_is_active( 'forums' ) || ( bp_is_active( 'forums' ) && bp_forums_has_directory() && !bp_forums_is_installed_correctly() ) ) )
105
+ $pages[] = $bp->pages->forums->id;
106
+
107
  /**
108
  * Filters specific pages that shouldn't show up on page listings.
109
  *
437
  if ( ! bp_has_custom_signup_page() )
438
  return $welcome_email;
439
 
440
+ // [User Set] Replaces $password in welcome email; Represents value set by user
441
  return str_replace( $password, __( '[User Set]', 'buddypress' ), $welcome_email );
442
  }
443
  add_filter( 'update_welcome_email', 'bp_core_filter_blog_welcome_email', 10, 4 );
472
  'user.email' => $user_email,
473
  ),
474
  );
475
+ bp_send_email( 'core-user-registration-with-blog', array( array( $user_email => $user ) ), $args );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
476
 
477
  // Return false to stop the original WPMU function from continuing.
478
  return false;
526
  $user_id = $user_object->ID;
527
  }
528
 
 
 
 
 
 
 
 
529
  $args = array(
530
  'tokens' => array(
531
  'activate.url' => esc_url( trailingslashit( bp_get_activation_page() ) . "{$key}/" ),
534
  'user.id' => $user_id,
535
  ),
536
  );
537
+ bp_send_email( 'core-user-registration', array( array( $user_email => $user ) ), $args );
538
 
539
  // Return false to stop the original WPMU function from continuing.
540
  return false;
581
  $bp_title_parts['site'] = $blogname;
582
 
583
  if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() && ! bp_is_single_activity() ) {
 
584
  $bp_title_parts['page'] = sprintf( __( 'Page %s', 'buddypress' ), max( $paged, $page ) );
585
  }
586
  }
671
  */
672
  function bp_setup_nav_menu_item( $menu_item ) {
673
  if ( is_admin() ) {
 
 
 
 
 
 
 
 
 
 
674
  return $menu_item;
675
  }
676
 
792
  *
793
  * @since 2.3.3
794
  *
795
+ * @param array $item_types An associative array structured for the customizer.
796
  * @return array $item_types An associative array structured for the customizer.
797
  */
798
  function bp_customizer_nav_menus_set_item_types( $item_types = array() ) {
869
  return $edit_link;
870
  }
871
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
872
  /**
873
  * Should BuddyPress load the mentions scripts and related assets, including results to prime the
874
  * mentions suggestions?
967
  }
968
 
969
  $settings = bp_email_get_appearance_settings();
970
+ $replacement = 'style="color: ' . esc_attr( $settings['highlight_color'] ) . ';';
971
 
972
  // Find all links.
973
  preg_match_all( '#<a[^>]+>#i', $value, $links, PREG_SET_ORDER );
1008
  $tokens = $email->get_tokens();
1009
 
1010
  // Add 'List-Unsubscribe' header if applicable.
1011
+ if ( ! empty( $tokens['unsubscribe'] ) && $tokens['unsubscribe'] !== site_url( 'wp-login.php' ) ) {
1012
+ $user = get_user_by( 'email', $tokens['recipient.email'] );
 
1013
 
1014
+ $link = bp_email_get_unsubscribe_link( array(
1015
+ 'user_id' => $user->ID,
1016
  'notification_type' => $email->get( 'type' ),
1017
+ ) );
 
 
 
 
 
 
 
 
1018
 
1019
  if ( ! empty( $link ) ) {
1020
  $headers['List-Unsubscribe'] = sprintf( '<%s>', esc_url_raw( $link ) );
1038
  */
1039
  function bp_email_set_default_tokens( $tokens, $property_name, $transform, $email ) {
1040
  $tokens['site.admin-email'] = bp_get_option( 'admin_email' );
1041
+ $tokens['site.url'] = home_url();
 
1042
 
1043
  // These options are escaped with esc_html on the way into the database in sanitize_option().
1044
  $tokens['site.description'] = wp_specialchars_decode( bp_get_option( 'blogdescription' ), ENT_QUOTES );
1050
  $tokens['recipient.name'] = '';
1051
  $tokens['recipient.username'] = '';
1052
 
1053
+
1054
  // Who is the email going to?
1055
  $recipient = $email->get( 'to' );
1056
  if ( $recipient ) {
1066
 
1067
  if ( $user_obj ) {
1068
  $tokens['recipient.username'] = $user_obj->user_login;
 
1069
  if ( bp_is_active( 'settings' ) && empty( $tokens['unsubscribe'] ) ) {
1070
  $tokens['unsubscribe'] = esc_url( sprintf(
1071
  '%s%s/notifications/',
1078
 
1079
  // Set default unsubscribe link if not passed.
1080
  if ( empty( $tokens['unsubscribe'] ) ) {
1081
+ $tokens['unsubscribe'] = site_url( 'wp-login.php' );
1082
  }
1083
 
1084
  // Email preheader.
1085
+ $post = $email->get_post_object();
1086
+ if ( $post ) {
1087
+ $tokens['email.preheader'] = sanitize_text_field( get_post_meta( $post->ID, 'bp_email_preheader', true ) );
1088
  }
1089
 
1090
  return $tokens;
1133
 
1134
  // Make sure we add a <title> tag so WP Customizer picks it up.
1135
  $template = str_replace( '<head>', '<head><title>' . esc_html_x( 'BuddyPress Emails', 'screen heading', 'buddypress' ) . '</title>', $template );
1136
+ echo str_replace( '{{{content}}}', nl2br( get_post()->post_content ), $template );
1137
 
1138
  /*
1139
  * Link colours are applied directly in the email template before sending, so we
1148
  return '';
1149
  }
1150
  add_action( 'bp_template_include', 'bp_core_render_email_template', 12 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/bp-core-functions.php CHANGED
@@ -16,6 +16,7 @@ defined( 'ABSPATH' ) || exit;
16
  * Output the BuddyPress version.
17
  *
18
  * @since 1.6.0
 
19
  */
20
  function bp_version() {
21
  echo bp_get_version();
@@ -35,6 +36,7 @@ function bp_version() {
35
  * Output the BuddyPress database version.
36
  *
37
  * @since 1.6.0
 
38
  */
39
  function bp_db_version() {
40
  echo bp_get_db_version();
@@ -54,6 +56,7 @@ function bp_db_version() {
54
  * Output the BuddyPress database version.
55
  *
56
  * @since 1.6.0
 
57
  */
58
  function bp_db_version_raw() {
59
  echo bp_get_db_version_raw();
@@ -70,19 +73,6 @@ function bp_db_version_raw() {
70
  return !empty( $bp->db_version_raw ) ? $bp->db_version_raw : 0;
71
  }
72
 
73
- /**
74
- * Check whether the current version of WP exceeds a given version.
75
- *
76
- * @since 7.0.0
77
- *
78
- * @param string $version WP version, in "PHP-standardized" format.
79
- * @param string $compare Optional. Comparison operator. Default '>='.
80
- * @return bool
81
- */
82
- function bp_is_running_wp( $version, $compare = '>=' ) {
83
- return version_compare( $GLOBALS['wp_version'], $version, $compare );
84
- }
85
-
86
  /** Functions *****************************************************************/
87
 
88
  /**
@@ -246,7 +236,7 @@ function bp_core_number_format( $number = 0, $decimals = false ) {
246
  *
247
  * @since 1.6.0
248
  *
249
- * @param array $old_args_keys Old argument indexes, keyed to their positions.
250
  * @param array $func_args The parameters passed to the originating function.
251
  * @return array $new_args The parsed arguments.
252
  */
@@ -331,7 +321,7 @@ function bp_parse_args( $args, $defaults = array(), $filter_key = '' ) {
331
  /**
332
  * Sanitizes a pagination argument based on both the request override and the
333
  * original value submitted via a query argument, likely to a template class
334
- * responsible for limiting the result set of a template loop.
335
  *
336
  * @since 2.2.0
337
  *
@@ -433,12 +423,16 @@ function bp_is_username_compatibility_mode() {
433
  */
434
  function bp_use_wp_admin_bar() {
435
 
436
- // Default to true.
437
  $use_admin_bar = true;
438
 
439
  // Has the WP Toolbar constant been explicitly opted into?
440
  if ( defined( 'BP_USE_WP_ADMIN_BAR' ) ) {
441
  $use_admin_bar = (bool) BP_USE_WP_ADMIN_BAR;
 
 
 
 
442
  }
443
 
444
  /**
@@ -451,27 +445,6 @@ function bp_use_wp_admin_bar() {
451
  return (bool) apply_filters( 'bp_use_wp_admin_bar', $use_admin_bar );
452
  }
453
 
454
-
455
- /**
456
- * Return the parent forum ID for the Legacy Forums abstraction layer.
457
- *
458
- * @since 1.5.0
459
- * @since 3.0.0 Supported for compatibility with bbPress 2.
460
- *
461
- * @return int Forum ID.
462
- */
463
- function bp_forums_parent_forum_id() {
464
-
465
- /**
466
- * Filters the parent forum ID for the bbPress abstraction layer.
467
- *
468
- * @since 1.5.0
469
- *
470
- * @param int BP_FORUMS_PARENT_FORUM_ID The Parent forum ID constant.
471
- */
472
- return apply_filters( 'bp_forums_parent_forum_id', BP_FORUMS_PARENT_FORUM_ID );
473
- }
474
-
475
  /** Directory *****************************************************************/
476
 
477
  /**
@@ -494,6 +467,12 @@ function bp_core_get_packaged_component_ids() {
494
  'notifications',
495
  );
496
 
 
 
 
 
 
 
497
  return $components;
498
  }
499
 
@@ -511,7 +490,7 @@ function bp_core_get_packaged_component_ids() {
511
  function bp_core_get_directory_page_ids( $status = 'active' ) {
512
  $page_ids = bp_get_option( 'bp-pages', array() );
513
 
514
- // Loop through pages.
515
  foreach ( $page_ids as $component_name => $page_id ) {
516
 
517
  // Ensure that empty indexes are unset. Should only matter in edge cases.
@@ -524,7 +503,7 @@ function bp_core_get_directory_page_ids( $status = 'active' ) {
524
  unset( $page_ids[ $component_name ] );
525
  }
526
 
527
- // 'register' and 'activate' do not have components, but are allowed as special cases.
528
  if ( in_array( $component_name, array( 'register', 'activate' ), true ) ) {
529
  continue;
530
  }
@@ -702,7 +681,7 @@ function bp_core_add_page_mappings( $components, $existing = 'keep' ) {
702
 
703
  // Register and Activate are not components, but need pages when
704
  // registration is enabled.
705
- if ( bp_get_signup_allowed() || bp_get_members_invitations_allowed() ) {
706
  foreach ( array( 'register', 'activate' ) as $slug ) {
707
  if ( ! isset( $pages[ $slug ] ) ) {
708
  $pages_to_create[ $slug ] = $page_titles[ $slug ];
@@ -914,6 +893,19 @@ function bp_core_create_root_component_page() {
914
  bp_core_update_directory_page_ids( $page_ids );
915
  }
916
 
 
 
 
 
 
 
 
 
 
 
 
 
 
917
  /**
918
  * Get the 'search' query argument for a given component.
919
  *
@@ -945,54 +937,6 @@ function bp_core_get_component_search_query_arg( $component = null ) {
945
  return apply_filters( 'bp_core_get_component_search_query_arg', $query_arg, $component );
946
  }
947
 
948
- /**
949
- * Get a list of all active component objects.
950
- *
951
- * @since 8.0.0
952
- *
953
- * @param array $args {
954
- * Optional. An array of key => value arguments to match against the component objects.
955
- * Default empty array.
956
- *
957
- * @type string $name Translatable name for the component.
958
- * @type string $id Unique ID for the component.
959
- * @type string $slug Unique slug for the component, for use in query strings and URLs.
960
- * @type bool $has_directory True if the component has a top-level directory. False otherwise.
961
- * @type string $root_slug Slug used by the component's directory page.
962
- * }
963
- * @param string $output Optional. The type of output to return. Accepts 'ids'
964
- * or 'objects'. Default 'ids'.
965
- * @param string $operator Optional. The logical operation to perform. 'or' means only one
966
- * element from the array needs to match; 'and' means all elements
967
- * must match. Accepts 'or' or 'and'. Default 'and'.
968
- * @return array A list of component ids or objects.
969
- */
970
- function bp_core_get_active_components( $args = array(), $output = 'ids', $operator = 'and' ) {
971
- $bp = buddypress();
972
-
973
- $active_components = array_keys( $bp->active_components );
974
-
975
- $xprofile_id = array_search( 'xprofile', $active_components, true );
976
- if ( false !== $xprofile_id ) {
977
- $active_components[ $xprofile_id ] = 'profile';
978
- }
979
-
980
- $components = array();
981
- foreach ( $active_components as $id ) {
982
- if ( isset( $bp->{$id} ) && $bp->{$id} instanceof BP_Component ) {
983
- $components[ $id ] = $bp->{$id};
984
- }
985
- }
986
-
987
- $components = wp_filter_object_list( $components, $args, $operator );
988
-
989
- if ( 'ids' === $output ) {
990
- $components = wp_list_pluck( $components, 'id' );
991
- }
992
-
993
- return $components;
994
- }
995
-
996
  /**
997
  * Determine whether BuddyPress should register the bp-themes directory.
998
  *
@@ -1078,11 +1022,7 @@ function bp_core_redirect( $location = '', $status = 302 ) {
1078
  buddypress()->no_status_set = true;
1079
 
1080
  wp_safe_redirect( $location, $status );
1081
-
1082
- // If PHPUnit is running, do not kill execution.
1083
- if ( ! defined( 'BP_TESTS_DIR' ) ) {
1084
- die;
1085
- }
1086
  }
1087
 
1088
  /**
@@ -1177,32 +1117,72 @@ function bp_core_current_time( $gmt = true, $type = 'mysql' ) {
1177
  }
1178
 
1179
  /**
1180
- * Calculate the human time difference between two dates.
1181
  *
1182
  * Based on function created by Dunstan Orchard - http://1976design.com
1183
  *
1184
- * @since 8.0.0
 
 
 
 
1185
  *
1186
- * @param array $args {
1187
- * An array of arguments. All arguments are technically optional.
 
1188
  *
1189
- * @type int|string $older_date An integer Unix timestamp or a date string of the format 'Y-m-d h:i:s'.
1190
- * @type int|string $newer_date An integer Unix timestamp or a date string of the format 'Y-m-d h:i:s'.
1191
- * @type int $time_chunks The number of time chunks to get (1 or 2).
1192
- * }
1193
- * @return null|array|false Null if there's no time diff. An array containing 1 or 2 chunks
1194
- * of human time. False if travelling into the future.
 
 
 
1195
  */
1196
- function bp_core_time_diff( $args = array() ) {
1197
- $retval = null;
1198
- $r = wp_parse_args(
1199
- $args,
1200
- array(
1201
- 'older_date' => 0,
1202
- 'newer_date' => bp_core_current_time( true, 'timestamp' ),
1203
- 'time_chunks' => 2,
1204
- )
1205
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1206
 
1207
  // Array of time period chunks.
1208
  $chunks = array(
@@ -1215,218 +1195,121 @@ function bp_core_time_diff( $args = array() ) {
1215
  1
1216
  );
1217
 
1218
- foreach ( array( 'older_date', 'newer_date' ) as $date ) {
1219
- if ( ! $r[ $date ] ) {
1220
- continue;
1221
- }
1222
-
1223
- if ( ! is_numeric( $r[ $date ] ) ) {
1224
- $time_chunks = explode( ':', str_replace( ' ', ':', $r[ $date ] ) );
1225
- $date_chunks = explode( '-', str_replace( ' ', '-', $r[ $date ] ) );
1226
- $r[ $date ] = gmmktime(
1227
- (int) $time_chunks[1],
1228
- (int) $time_chunks[2],
1229
- (int) $time_chunks[3],
1230
- (int) $date_chunks[1],
1231
- (int) $date_chunks[2],
1232
- (int) $date_chunks[0]
1233
- );
1234
- }
1235
  }
1236
 
 
 
 
 
 
 
 
1237
  // Difference in seconds.
1238
- $diff = $r['newer_date'] - $r['older_date'];
 
 
 
 
1239
 
1240
  /**
1241
- * We only want to return one or two chunks of time here, eg:
1242
- * - `array( 'x years', 'xx months' )`,
1243
- * - `array( 'x days', 'xx hours' )`.
1244
- * So there's only two bits of calculation below.
1245
  */
1246
- if ( 0 <= $diff && (int) $r['time_chunks'] ) {
 
1247
  // Step one: the first chunk.
1248
  for ( $i = 0, $j = count( $chunks ); $i < $j; ++$i ) {
1249
  $seconds = $chunks[$i];
1250
 
1251
  // Finding the biggest chunk (if the chunk fits, break).
1252
- $count = floor( $diff / $seconds );
1253
  if ( 0 != $count ) {
1254
  break;
1255
  }
1256
  }
1257
 
1258
- // Add the first chunk of time diff.
1259
- if ( isset( $chunks[ $i ] ) ) {
1260
- $retval = array();
 
 
1261
 
 
1262
  switch ( $seconds ) {
1263
  case YEAR_IN_SECONDS :
1264
- /* translators: %s: the number of years. */
1265
- $retval[] = sprintf( _n( '%s year', '%s years', $count, 'buddypress' ), $count );
1266
  break;
1267
  case 30 * DAY_IN_SECONDS :
1268
- /* translators: %s: the number of months. */
1269
- $retval[] = sprintf( _n( '%s month', '%s months', $count, 'buddypress' ), $count );
1270
  break;
1271
  case WEEK_IN_SECONDS :
1272
- /* translators: %s: the number of weeks. */
1273
- $retval[]= sprintf( _n( '%s week', '%s weeks', $count, 'buddypress' ), $count );
1274
  break;
1275
  case DAY_IN_SECONDS :
1276
- /* translators: %s: the number of days. */
1277
- $retval[] = sprintf( _n( '%s day', '%s days', $count, 'buddypress' ), $count );
1278
  break;
1279
  case HOUR_IN_SECONDS :
1280
- /* translators: %s: the number of hours. */
1281
- $retval[] = sprintf( _n( '%s hour', '%s hours', $count, 'buddypress' ), $count );
1282
  break;
1283
  case MINUTE_IN_SECONDS :
1284
- /* translators: %s: the number of minutes. */
1285
- $retval[] = sprintf( _n( '%s minute', '%s minutes', $count, 'buddypress' ), $count );
1286
  break;
1287
  default:
1288
- /* translators: %s: the number of seconds. */
1289
- $retval[] = sprintf( _n( '%s second', '%s seconds', $count, 'buddypress' ), $count );
1290
  }
1291
 
1292
- /**
1293
- * Step two: the second chunk.
1294
- *
1295
- * A quirk in the implementation means that this condition fails in the case of minutes and seconds.
1296
- * We've left the quirk in place, since fractions of a minute are not a useful piece of information
1297
- * for our purposes.
1298
- */
1299
- if ( 2 === (int) $r['time_chunks'] && $i + 2 < $j ) {
1300
  $seconds2 = $chunks[$i + 1];
1301
- $count2 = floor( ( $diff - ( $seconds * $count ) ) / $seconds2 );
1302
 
1303
- // Add the second chunk of time diff.
1304
- if ( 0 !== (int) $count2 ) {
 
1305
 
1306
  switch ( $seconds2 ) {
1307
  case 30 * DAY_IN_SECONDS :
1308
- /* translators: %s: the number of months. */
1309
- $retval[] = sprintf( _n( '%s month', '%s months', $count2, 'buddypress' ), $count2 );
1310
  break;
1311
  case WEEK_IN_SECONDS :
1312
- /* translators: %s: the number of weeks. */
1313
- $retval[] = sprintf( _n( '%s week', '%s weeks', $count2, 'buddypress' ), $count2 );
1314
  break;
1315
  case DAY_IN_SECONDS :
1316
- /* translators: %s: the number of days. */
1317
- $retval[] = sprintf( _n( '%s day', '%s days', $count2, 'buddypress' ), $count2 );
1318
  break;
1319
  case HOUR_IN_SECONDS :
1320
- /* translators: %s: the number of hours. */
1321
- $retval[] = sprintf( _n( '%s hour', '%s hours', $count2, 'buddypress' ), $count2 );
1322
  break;
1323
  case MINUTE_IN_SECONDS :
1324
- /* translators: %s: the number of minutes. */
1325
- $retval[] = sprintf( _n( '%s minute', '%s minutes', $count2, 'buddypress' ), $count2 );
1326
  break;
1327
  default:
1328
- /* translators: %s: the number of seconds. */
1329
- $retval[] = sprintf( _n( '%s second', '%s seconds', $count2, 'buddypress' ), $count2 );
1330
  }
1331
  }
1332
  }
1333
- }
1334
- } else {
1335
- // Something went wrong with date calculation and we ended up with a negative date.
1336
- $retval = false;
1337
- }
1338
-
1339
- return $retval;
1340
- }
1341
-
1342
- /**
1343
- * Get an English-language representation of the time elapsed since a given date.
1344
- *
1345
- * This function will return an English representation of the time elapsed
1346
- * since a given date.
1347
- * eg: 2 hours, 50 minutes
1348
- * eg: 4 days
1349
- * eg: 4 weeks, 6 days
1350
- *
1351
- * Note that fractions of minutes are not represented in the return string. So
1352
- * an interval of 3 minutes will be represented by "3 minutes ago", as will an
1353
- * interval of 3 minutes 59 seconds.
1354
- *
1355
- * @since 1.0.0
1356
- * @since 8.0.0 Move the time difference calculation into `bp_core_time_diff()`.
1357
- *
1358
- * @param int|string $older_date The earlier time from which you're calculating
1359
- * the time elapsed. Enter either as an integer Unix timestamp,
1360
- * or as a date string of the format 'Y-m-d h:i:s'.
1361
- * @param int|bool $newer_date Optional. Unix timestamp of date to compare older
1362
- * date to. Default: false (current time).
1363
- * @return string String representing the time since the older date, eg
1364
- * "2 hours, 50 minutes".
1365
- */
1366
- function bp_core_time_since( $older_date, $newer_date = false ) {
1367
-
1368
- /**
1369
- * Filters whether or not to bypass BuddyPress' time_since calculations.
1370
- *
1371
- * @since 1.7.0
1372
- *
1373
- * @param bool $value Whether or not to bypass.
1374
- * @param string $older_date Earlier time from which we're calculating time elapsed.
1375
- * @param string $newer_date Unix timestamp of date to compare older time to.
1376
- */
1377
- $pre_value = apply_filters( 'bp_core_time_since_pre', false, $older_date, $newer_date );
1378
- if ( false !== $pre_value ) {
1379
- return $pre_value;
1380
- }
1381
-
1382
- $newer_date = (int) $newer_date;
1383
- $args = array(
1384
- 'older_date' => $older_date,
1385
- );
1386
 
1387
- if ( $newer_date) {
1388
- $args['newer_date'] = $newer_date;
 
 
 
1389
  }
1390
 
1391
- // Calculate the time difference.
1392
- $time_diff = bp_core_time_diff( $args );
1393
-
1394
- /**
1395
- * Filters the value to use if the time since is some time ago.
1396
- *
1397
- * @since 1.5.0
1398
- *
1399
- * @param string $value String representing the time since the older date.
1400
- */
1401
- $ago_text = apply_filters(
1402
- 'bp_core_time_since_ago_text',
1403
- /* translators: %s: the human time diff. */
1404
- __( '%s ago', 'buddypress' )
1405
- );
1406
-
1407
- /**
1408
- * Filters the value to use if the time since is right now.
1409
- *
1410
- * @since 1.5.0
1411
- *
1412
- * @param string $value String representing the time since the older date.
1413
- */
1414
- $output = apply_filters( 'bp_core_time_since_right_now_text', __( 'right now', 'buddypress' ) );
1415
-
1416
- if ( is_array( $time_diff ) ) {
1417
- $separator = _x( ',', 'Separator in time since', 'buddypress' ) . ' ';
1418
- $diff_text = implode( $separator, $time_diff );
1419
- $output = sprintf( $ago_text, $diff_text );
1420
- } elseif ( false === $time_diff ) {
1421
- /**
1422
- * Filters the value to use if the time since is unknown.
1423
- *
1424
- * @since 1.5.0
1425
- *
1426
- * @param string $value String representing the time since the older date.
1427
- */
1428
- $unknown_text = apply_filters( 'bp_core_time_since_unknown_text', __( 'sometime', 'buddypress' ) );
1429
- $output = sprintf( $ago_text, $unknown_text );
1430
  }
1431
 
1432
  /**
@@ -1441,42 +1324,6 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
1441
  return apply_filters( 'bp_core_time_since', $output, $older_date, $newer_date );
1442
  }
1443
 
1444
- /**
1445
- * Get an age to display according to the birth date.
1446
- *
1447
- * @since 8.0.0
1448
- *
1449
- * @param int|string $birth_date A timestamp or a MySQL formatted date.
1450
- * @return string The age to display.
1451
- */
1452
- function bp_core_time_old( $birth_date ) {
1453
- $time_diff = bp_core_time_diff( array( 'older_date' => $birth_date, 'time_chunks' => 1 ) );
1454
- $retval = '&mdash;';
1455
-
1456
- if ( $time_diff ) {
1457
- $age = reset( $time_diff );
1458
-
1459
- /**
1460
- * Filters the value to use to display the age.
1461
- *
1462
- * @since 8.0.0
1463
- *
1464
- * @param string $value String representing the time since the older date.
1465
- * @param int $age The age.
1466
- */
1467
- $age_text = apply_filters(
1468
- 'bp_core_time_old_text',
1469
- /* translators: %d: the age . */
1470
- __( '%s old', 'buddypress' ),
1471
- $age
1472
- );
1473
-
1474
- $retval = sprintf( $age_text, $age );
1475
- }
1476
-
1477
- return $retval;
1478
- }
1479
-
1480
  /**
1481
  * Output an ISO-8601 date from a date string.
1482
  *
@@ -1556,6 +1403,7 @@ function bp_core_add_message( $message, $type = '' ) {
1556
  * so that the message is not shown to the user multiple times.
1557
  *
1558
  * @since 1.1.0
 
1559
  */
1560
  function bp_core_setup_message() {
1561
 
@@ -1639,6 +1487,8 @@ function bp_core_render_message() {
1639
  *
1640
  * @since 1.0.0
1641
  *
 
 
1642
  * @return false|null Returns false if there is nothing to do.
1643
  */
1644
  function bp_core_record_activity() {
@@ -1694,15 +1544,17 @@ add_action( 'wp_head', 'bp_core_record_activity' );
1694
  *
1695
  * @since 1.0.0
1696
  *
 
 
1697
  * @param int|string $last_activity_date The date of last activity.
1698
- * @param string $string A sprintf()-able statement of the form 'Active %s'.
1699
  * @return string $last_active A string of the form '3 years ago'.
1700
  */
1701
  function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {
1702
 
1703
  // Setup a default string if none was passed.
1704
  $string = empty( $string )
1705
- ? '%s' // Gettext library's placeholder.
1706
  : $string;
1707
 
1708
  // Use the string if a last activity date was passed.
@@ -1717,7 +1569,7 @@ function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {
1717
  *
1718
  * @param string $last_active Last activity string based on time since date given.
1719
  * @param string $last_activity_date The date of last activity.
1720
- * @param string $string A sprintf()-able statement of the form 'Active %s'.
1721
  */
1722
  return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
1723
  }
@@ -1727,7 +1579,7 @@ function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {
1727
  /**
1728
  * Get the meta_key for a given piece of user metadata
1729
  *
1730
- * BuddyPress stores a number of pieces of user data in the WordPress central
1731
  * usermeta table. In order to allow plugins to enable multiple instances of
1732
  * BuddyPress on a single WP installation, BP's usermeta keys are filtered
1733
  * through this function, so that they can be altered on the fly.
@@ -1877,6 +1729,26 @@ function bp_use_embed_in_activity_replies() {
1877
  return apply_filters( 'bp_use_embed_in_activity_replies', !defined( 'BP_EMBED_DISABLE_ACTIVITY_REPLIES' ) || !BP_EMBED_DISABLE_ACTIVITY_REPLIES );
1878
  }
1879
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1880
  /**
1881
  * Are oembeds allowed in private messages?
1882
  *
@@ -2483,6 +2355,11 @@ function bp_core_action_search_site( $slug = '' ) {
2483
  $slug = bp_is_active( 'blogs' ) ? bp_get_blogs_root_slug() : '';
2484
  break;
2485
 
 
 
 
 
 
2486
  case 'groups':
2487
  $slug = bp_is_active( 'groups' ) ? bp_get_groups_root_slug() : '';
2488
  break;
@@ -2586,6 +2463,10 @@ function bp_core_get_components( $type = 'all' ) {
2586
  );
2587
 
2588
  $retired_components = array(
 
 
 
 
2589
  );
2590
 
2591
  $optional_components = array(
@@ -2617,6 +2498,10 @@ function bp_core_get_components( $type = 'all' ) {
2617
  'title' => __( 'User Groups', 'buddypress' ),
2618
  'description' => __( 'Groups allow your users to organize themselves into specific public, private or hidden sections with separate activity streams and member listings.', 'buddypress' )
2619
  ),
 
 
 
 
2620
  'blogs' => array(
2621
  'title' => __( 'Site Tracking', 'buddypress' ),
2622
  'description' => __( 'Record activity for new posts and comments from your site.', 'buddypress' )
@@ -2677,15 +2562,14 @@ function bp_core_get_components( $type = 'all' ) {
2677
  * @return mixed A URL or an array of dummy pages.
2678
  */
2679
  function bp_nav_menu_get_loggedin_pages() {
2680
- $bp = buddypress();
2681
 
2682
  // Try to catch the cached version first.
2683
- if ( ! empty( $bp->wp_nav_menu_items->loggedin ) ) {
2684
- return $bp->wp_nav_menu_items->loggedin;
2685
  }
2686
 
2687
  // Pull up a list of items registered in BP's primary nav for the member.
2688
- $bp_menu_items = $bp->members->nav->get_primary();
2689
 
2690
  // Some BP nav menu items will not be represented in bp_nav, because
2691
  // they are not real BP components. We add them manually here.
@@ -2713,18 +2597,18 @@ function bp_nav_menu_get_loggedin_pages() {
2713
  'post_author' => 0,
2714
  'post_date' => 0,
2715
  'post_excerpt' => $bp_item['slug'],
2716
- 'post_type' => 'bp_nav_menu_item',
2717
  'post_status' => 'publish',
2718
  'comment_status' => 'closed',
2719
  'guid' => $bp_item['link']
2720
  );
2721
  }
2722
 
2723
- if ( empty( $bp->wp_nav_menu_items ) ) {
2724
  buddypress()->wp_nav_menu_items = new stdClass;
2725
  }
2726
 
2727
- $bp->wp_nav_menu_items->loggedin = $page_args;
2728
 
2729
  return $page_args;
2730
  }
@@ -2744,11 +2628,10 @@ function bp_nav_menu_get_loggedin_pages() {
2744
  * @return mixed A URL or an array of dummy pages.
2745
  */
2746
  function bp_nav_menu_get_loggedout_pages() {
2747
- $bp = buddypress();
2748
 
2749
  // Try to catch the cached version first.
2750
- if ( ! empty( $bp->wp_nav_menu_items->loggedout ) ) {
2751
- return $bp->wp_nav_menu_items->loggedout;
2752
  }
2753
 
2754
  $bp_menu_items = array();
@@ -2788,18 +2671,18 @@ function bp_nav_menu_get_loggedout_pages() {
2788
  'post_author' => 0,
2789
  'post_date' => 0,
2790
  'post_excerpt' => $bp_item['slug'],
2791
- 'post_type' => 'bp_nav_menu_item',
2792
  'post_status' => 'publish',
2793
  'comment_status' => 'closed',
2794
  'guid' => $bp_item['link']
2795
  );
2796
  }
2797
 
2798
- if ( empty( $bp->wp_nav_menu_items ) ) {
2799
- $bp->wp_nav_menu_items = new stdClass;
2800
  }
2801
 
2802
- $bp->wp_nav_menu_items->loggedout = $page_args;
2803
 
2804
  return $page_args;
2805
  }
@@ -2868,7 +2751,7 @@ function bp_core_get_suggestions( $args ) {
2868
  * @since 2.1.0
2869
  *
2870
  * @param string $value Custom class to use. Default: none.
2871
- * @param array $args Array of arguments for suggestions.
2872
  */
2873
  $class = apply_filters( 'bp_suggestions_services', '', $args );
2874
  }
@@ -2898,40 +2781,6 @@ function bp_core_get_suggestions( $args ) {
2898
  return apply_filters( 'bp_core_get_suggestions', $retval, $args );
2899
  }
2900
 
2901
- /**
2902
- * AJAX endpoint for Suggestions API lookups.
2903
- *
2904
- * @since 2.1.0
2905
- * @since 4.0.0 Moved here to make sure this function is available
2906
- * even if the Activity component is not active.
2907
- */
2908
- function bp_ajax_get_suggestions() {
2909
- if ( ! bp_is_user_active() || empty( $_GET['term'] ) || empty( $_GET['type'] ) ) {
2910
- wp_send_json_error( 'missing_parameter' );
2911
- exit;
2912
- }
2913
-
2914
- $args = array(
2915
- 'term' => sanitize_text_field( $_GET['term'] ),
2916
- 'type' => sanitize_text_field( $_GET['type'] ),
2917
- );
2918
-
2919
- // Support per-Group suggestions.
2920
- if ( ! empty( $_GET['group-id'] ) ) {
2921
- $args['group_id'] = absint( $_GET['group-id'] );
2922
- }
2923
-
2924
- $results = bp_core_get_suggestions( $args );
2925
-
2926
- if ( is_wp_error( $results ) ) {
2927
- wp_send_json_error( $results->get_error_message() );
2928
- exit;
2929
- }
2930
-
2931
- wp_send_json_success( $results );
2932
- }
2933
- add_action( 'wp_ajax_bp_get_suggestions', 'bp_ajax_get_suggestions' );
2934
-
2935
  /**
2936
  * Set data from the BP root blog's upload directory.
2937
  *
@@ -3070,42 +2919,7 @@ function bp_get_email_post_type_supports() {
3070
  /** Taxonomies *****************************************************************/
3071
 
3072
  /**
3073
- * Returns the BP Taxonomy common arguments.
3074
- *
3075
- * @since 7.0.0
3076
- *
3077
- * @return array The BP Taxonomy common arguments.
3078
- */
3079
- function bp_get_taxonomy_common_args() {
3080
- return array(
3081
- 'public' => false,
3082
- 'show_in_rest' => false,
3083
- 'query_var' => false,
3084
- 'rewrite' => false,
3085
- 'show_in_menu' => false,
3086
- 'show_tagcloud' => false,
3087
- 'show_ui' => bp_is_root_blog() && bp_current_user_can( 'bp_moderate' ),
3088
- );
3089
- }
3090
-
3091
- /**
3092
- * Returns the BP Taxonomy common labels.
3093
- *
3094
- * @since 7.0.0
3095
- *
3096
- * @return array The BP Taxonomy common labels.
3097
- */
3098
- function bp_get_taxonomy_common_labels() {
3099
- return array(
3100
- 'bp_type_name' => _x( 'Plural Name', 'BP Type name label', 'buddypress' ),
3101
- 'bp_type_singular_name' => _x( 'Singular name', 'BP Type singular name label', 'buddypress' ),
3102
- 'bp_type_has_directory' => _x( 'Has Directory View', 'BP Type has directory checkbox label', 'buddypress' ),
3103
- 'bp_type_directory_slug' => _x( 'Custom type directory slug', 'BP Type slug label', 'buddypress' ),
3104
- );
3105
- }
3106
-
3107
- /**
3108
- * Output the name of the email type taxonomy.
3109
  *
3110
  * @since 2.5.0
3111
  */
@@ -3166,233 +2980,6 @@ function bp_get_email_tax_type_labels() {
3166
  ) );
3167
  }
3168
 
3169
- /**
3170
- * Return arguments used by the email type taxonomy.
3171
- *
3172
- * @since 7.0.0
3173
- *
3174
- * @return array
3175
- */
3176
- function bp_get_email_tax_type_args() {
3177
-
3178
- /**
3179
- * Filters emails type taxonomy args.
3180
- *
3181
- * @since 7.0.0
3182
- *
3183
- * @param array $value Associative array (key => arg).
3184
- */
3185
- return apply_filters(
3186
- 'bp_register_email_tax_type',
3187
- array_merge(
3188
- array(
3189
- 'description' => _x( 'BuddyPress email types', 'email type taxonomy description', 'buddypress' ),
3190
- 'labels' => bp_get_email_tax_type_labels(),
3191
- 'meta_box_cb' => 'bp_email_tax_type_metabox',
3192
- ),
3193
- bp_get_taxonomy_common_args()
3194
- )
3195
- );
3196
- }
3197
-
3198
- /**
3199
- * Returns the default BuddyPress type metadata schema.
3200
- *
3201
- * @since 7.0.0
3202
- *
3203
- * @param boolean $suppress_filters Whether to suppress filters. Default `false`.
3204
- * @param string $type_taxonomy Optional. the Type's taxonomy name.
3205
- * @return array The default BuddyPress type metadata schema.
3206
- */
3207
- function bp_get_type_metadata_schema( $suppress_filters = false, $type_taxonomy = '' ) {
3208
- $schema = array(
3209
- 'bp_type_singular_name' => array(
3210
- 'description' => __( 'The name of this type in singular form. ', 'buddypress' ),
3211
- 'type' => 'string',
3212
- 'single' => true,
3213
- 'sanitize_callback' => 'sanitize_text_field',
3214
- ),
3215
- 'bp_type_name' => array(
3216
- 'description' => __( 'The name of this type in plural form.', 'buddypress' ),
3217
- 'type' => 'string',
3218
- 'single' => true,
3219
- 'sanitize_callback' => 'sanitize_text_field',
3220
- ),
3221
- 'bp_type_has_directory' => array(
3222
- 'description' => __( 'Make a list matching this type available on the directory.', 'buddypress' ),
3223
- 'type' => 'boolean',
3224
- 'single' => true,
3225
- 'sanitize_callback' => 'absint',
3226
- ),
3227
- 'bp_type_directory_slug' => array(
3228
- 'label' => __( 'Type slug', 'buddypress' ),
3229
- 'description' => __( 'Enter if you want the type slug to be different from its ID.', 'buddypress' ),
3230
- 'type' => 'string',
3231
- 'single' => true,
3232
- 'sanitize_callback' => 'sanitize_title',
3233
- ),
3234
- );
3235
-
3236
- if ( true === $suppress_filters ) {
3237
- return $schema;
3238
- }
3239
-
3240
- /**
3241
- * Filter here to add new meta to the BuddyPress type metadata.
3242
- *
3243
- * @since 7.0.0
3244
- *
3245
- * @param array $schema Associative array (name => arguments).
3246
- * @param string $type_taxonomy The Type's taxonomy name.
3247
- */
3248
- return apply_filters( 'bp_get_type_metadata_schema', $schema, $type_taxonomy );
3249
- }
3250
-
3251
- /**
3252
- * Registers a meta key for BuddyPress types.
3253
- *
3254
- * @since 7.0.0
3255
- *
3256
- * @param string $type_tax The BuddyPress type taxonomy.
3257
- * @param string $meta_key The meta key to register.
3258
- * @param array $args Data used to describe the meta key when registered. See
3259
- * {@see register_meta()} for a list of supported arguments.
3260
- * @return bool True if the meta key was successfully registered, false if not.
3261
- */
3262
- function bp_register_type_meta( $type_tax, $meta_key, array $args ) {
3263
- $taxonomies = wp_list_pluck( bp_get_default_taxonomies(), 'component' );
3264
-
3265
- if ( ! isset( $taxonomies[ $type_tax ] ) ) {
3266
- return false;
3267
- }
3268
-
3269
- // register_term_meta() was introduced in WP 4.9.8.
3270
- if ( ! bp_is_running_wp( '4.9.8' ) ) {
3271
- $args['object_subtype'] = $type_tax;
3272
-
3273
- return register_meta( 'term', $meta_key, $args );
3274
- }
3275
-
3276
- return register_term_meta( $type_tax, $meta_key, $args );
3277
- }
3278
-
3279
- /**
3280
- * Update a list of metadata for a given type ID and a given taxonomy.
3281
- *
3282
- * @since 7.0.0
3283
- *
3284
- * @param integer $type_id The database ID of the BP Type.
3285
- * @param string $taxonomy The BP Type taxonomy.
3286
- * @param array $type_metas An associative array (meta_key=>meta_value).
3287
- * @return boolean False on failure. True otherwise.
3288
- */
3289
- function bp_update_type_metadata( $type_id = 0, $taxonomy = '', $type_metas = array() ) {
3290
- if ( ! $type_id || ! $taxonomy || ! is_array( $type_metas ) ) {
3291
- return false;
3292
- }
3293
-
3294
- foreach ( $type_metas as $meta_key => $meta_value ) {
3295
- if ( ! registered_meta_key_exists( 'term', $meta_key, $taxonomy ) ) {
3296
- continue;
3297
- }
3298
-
3299
- update_term_meta( $type_id, $meta_key, $meta_value );
3300
- }
3301
-
3302
- return true;
3303
- }
3304
-
3305
- /**
3306
- * Get types for a given BP Taxonomy.
3307
- *
3308
- * @since 7.0.0
3309
- *
3310
- * @param string $taxonomy The taxonomy to transform terms in types for.
3311
- * @param array $types Existing types to merge with the types found into the database.
3312
- * For instance this function is used internally to merge Group/Member
3313
- * types registered using code with the ones created by the administrator
3314
- * from the Group/Member types Administration screen. If not provided, only
3315
- * Types created by the administrator will be returned.
3316
- * Optional.
3317
- * @return array The types of the given taxonomy.
3318
- */
3319
- function bp_get_taxonomy_types( $taxonomy = '', $types = array() ) {
3320
- if ( ! $taxonomy ) {
3321
- return $types;
3322
- }
3323
-
3324
- $db_types = wp_cache_get( $taxonomy, 'bp_object_terms' );
3325
-
3326
- if ( ! $db_types ) {
3327
- $terms = bp_get_terms(
3328
- array(
3329
- 'taxonomy' => $taxonomy,
3330
- )
3331
- );
3332
-
3333
- if ( ! is_array( $terms ) || ! $terms ) {
3334
- return $types;
3335
- }
3336
-
3337
- $type_metadata = array_keys( get_registered_meta_keys( 'term', $taxonomy ) );
3338
-
3339
- foreach ( $terms as $term ) {
3340
- $type_name = $term->name;
3341
- $db_types[ $type_name ] = new stdClass();
3342
- $db_types[ $type_name ]->db_id = $term->term_id;
3343
- $db_types[ $type_name ]->labels = array();
3344
- $db_types[ $type_name ]->name = $type_name;
3345
-
3346
- if ( $type_metadata ) {
3347
- foreach ( $type_metadata as $meta_key ) {
3348
- $type_key = str_replace( 'bp_type_', '', $meta_key );
3349
- if ( in_array( $type_key, array( 'name', 'singular_name' ), true ) ) {
3350
- $db_types[ $type_name ]->labels[ $type_key ] = get_term_meta( $term->term_id, $meta_key, true );
3351
- } else {
3352
- $db_types[ $type_name ]->{$type_key} = get_term_meta( $term->term_id, $meta_key, true );
3353
- }
3354
- }
3355
-
3356
- if ( ! empty( $db_types[ $type_name ]->has_directory ) && empty( $db_types[ $type_name ]->directory_slug ) ) {
3357
- $db_types[ $type_name ]->directory_slug = $term->slug;
3358
- }
3359
- }
3360
- }
3361
-
3362
- wp_cache_set( $taxonomy, $db_types, 'bp_object_terms' );
3363
- }
3364
-
3365
- if ( is_array( $db_types ) ) {
3366
- foreach ( $db_types as $db_type_name => $db_type ) {
3367
- // Override props of registered by code types if customized by the admun user.
3368
- if ( isset( $types[ $db_type_name ] ) && isset( $types[ $db_type_name ]->code ) && $types[ $db_type_name ]->code ) {
3369
- // Merge Labels.
3370
- if ( $db_type->labels ) {
3371
- foreach ( $db_type->labels as $key_label => $value_label ) {
3372
- if ( '' !== $value_label ) {
3373
- $types[ $db_type_name ]->labels[ $key_label ] = $value_label;
3374
- }
3375
- }
3376
- }
3377
-
3378
- // Merge other properties.
3379
- foreach ( get_object_vars( $types[ $db_type_name ] ) as $key_prop => $value_prop ) {
3380
- if ( 'labels' === $key_prop || 'name' === $key_prop ) {
3381
- continue;
3382
- }
3383
-
3384
- if ( isset( $db_type->{$key_prop} ) && '' !== $db_type->{$key_prop} ) {
3385
- $types[ $db_type_name ]->{$key_prop} = $db_type->{$key_prop};
3386
- }
3387
- }
3388
-
3389
- unset( $db_types[ $db_type_name ] );
3390
- }
3391
- }
3392
- }
3393
-
3394
- return array_merge( $types, (array) $db_types );
3395
- }
3396
 
3397
  /** Email *****************************************************************/
3398
 
@@ -3501,11 +3088,11 @@ function bp_get_email( $email_type ) {
3501
  *
3502
  * @param string $email_type Type of email being sent.
3503
  * @param string|array|int|WP_User $to Either a email address, user ID, WP_User object,
3504
- * or an array containing the address and name.
3505
  * @param array $args {
3506
  * Optional. Array of extra parameters.
3507
  *
3508
- * @type array $tokens Optional. Associative arrays of string replacements for the email.
3509
  * }
3510
  * @return bool|WP_Error True if the email was sent successfully. Otherwise, a WP_Error object
3511
  * describing why the email failed to send. The contents will vary based
@@ -3546,15 +3133,7 @@ function bp_send_email( $email_type, $to, $args = array() ) {
3546
  }
3547
 
3548
  // From, subject, content are set automatically.
3549
- if ( 'settings-verify-email-change' === $email_type && isset( $args['tokens']['displayname'] ) ) {
3550
- $email->set_to( $to, $args['tokens']['displayname'] );
3551
- // Emails sent to nonmembers will have no recipient.name populated.
3552
- } else if ( 'bp-members-invitation' === $email_type ) {
3553
- $email->set_to( $to, $to );
3554
- } else {
3555
- $email->set_to( $to );
3556
- }
3557
-
3558
  $email->set_tokens( $args['tokens'] );
3559
 
3560
  /**
@@ -3565,11 +3144,11 @@ function bp_send_email( $email_type, $to, $args = array() ) {
3565
  * @param BP_Email $email The email (object) about to be sent.
3566
  * @param string $email_type Type of email being sent.
3567
  * @param string|array|int|WP_User $to Either a email address, user ID, WP_User object,
3568
- * or an array containing the address and name.
3569
  * @param array $args {
3570
  * Optional. Array of extra parameters.
3571
  *
3572
- * @type array $tokens Optional. Associative arrays of string replacements for the email.
3573
  * }
3574
  */
3575
  do_action_ref_array( 'bp_send_email', array( &$email, $email_type, $to, $args ) );
@@ -3619,12 +3198,12 @@ function bp_send_email( $email_type, $to, $args = array() ) {
3619
  * @param array $args {
3620
  * Optional. Array of extra parameters.
3621
  *
3622
- * @type array $tokens Optional. Associative arrays of string replacements for the email.
3623
  * }
3624
  */
3625
  $delivery_class = apply_filters( 'bp_send_email_delivery_class', 'BP_PHPMailer', $email_type, $to, $args );
3626
  if ( ! class_exists( $delivery_class ) ) {
3627
- return new WP_Error( 'missing_class', 'No class found by that name', $delivery_class );
3628
  }
3629
 
3630
  $delivery = new $delivery_class();
@@ -3646,7 +3225,7 @@ function bp_send_email( $email_type, $to, $args = array() ) {
3646
  } else {
3647
 
3648
  /**
3649
- * Fires after BuddyPress has successfully sent an email.
3650
  *
3651
  * @since 2.5.0
3652
  *
@@ -3663,32 +3242,10 @@ function bp_send_email( $email_type, $to, $args = array() ) {
3663
  * Return email appearance settings.
3664
  *
3665
  * @since 2.5.0
3666
- * @since 3.0.0 Added "direction" parameter for LTR/RTL email support, and
3667
- * "link_text_color" to override that in the email body.
3668
  *
3669
  * @return array
3670
  */
3671
  function bp_email_get_appearance_settings() {
3672
- $footer_text = array(
3673
- sprintf(
3674
- /* translators: 1. Copyright year, 2. Site name */
3675
- _x( '&copy; %1$s %2$s', 'copyright text for email footers', 'buddypress' ),
3676
- date_i18n( 'Y' ),
3677
- bp_get_option( 'blogname' )
3678
- )
3679
- );
3680
-
3681
- if ( bp_is_running_wp( '4.9.6' ) ) {
3682
- $privacy_policy_url = get_privacy_policy_url();
3683
- if ( $privacy_policy_url ) {
3684
- $footer_text[] = sprintf(
3685
- '<a href="%s">%s</a>',
3686
- esc_url( $privacy_policy_url ),
3687
- esc_html__( 'Privacy Policy', 'buddypress' )
3688
- );
3689
- }
3690
- }
3691
-
3692
  $default_args = array(
3693
  'body_bg' => '#FFFFFF',
3694
  'body_text_color' => '#555555',
@@ -3701,23 +3258,20 @@ function bp_email_get_appearance_settings() {
3701
  'highlight_color' => '#D84800',
3702
  'header_text_color' => '#000000',
3703
  'header_text_size' => 30,
3704
- 'direction' => is_rtl() ? 'right' : 'left',
3705
 
3706
- 'footer_text' => implode( ' &middot; ', $footer_text ),
 
 
 
 
 
3707
  );
3708
 
3709
- $options = bp_parse_args(
3710
  bp_get_option( 'bp_email_options', array() ),
3711
  $default_args,
3712
  'email_appearance_settings'
3713
  );
3714
-
3715
- // Link text colour defaults to the highlight colour.
3716
- if ( ! isset( $options['link_text_color'] ) ) {
3717
- $options['link_text_color'] = $options['highlight_color'];
3718
- }
3719
-
3720
- return $options;
3721
  }
3722
 
3723
  /**
@@ -3740,7 +3294,6 @@ function bp_email_get_template( WP_Post $object ) {
3740
  * @param WP_Post $object WP_Post object.
3741
  */
3742
  return apply_filters( 'bp_email_get_template', array(
3743
- "assets/emails/{$single}-{$object->post_name}.php",
3744
  "{$single}-{$object->post_name}.php",
3745
  "{$single}.php",
3746
  "assets/emails/{$single}.php",
@@ -3798,23 +3351,7 @@ function bp_core_replace_tokens_in_text( $text, $tokens ) {
3798
  * @return array
3799
  */
3800
  function bp_email_get_schema() {
3801
-
3802
- /**
3803
- * Filters the list of `bp_email_get_schema()` allowing anyone to add/remove emails.
3804
- *
3805
- * @since 7.0.0
3806
- *
3807
- * @param array $emails The array of emails schema.
3808
- */
3809
- return (array) apply_filters( 'bp_email_get_schema', array(
3810
- 'core-user-activation' => array(
3811
- /* translators: do not remove {} brackets or translate its contents. */
3812
- 'post_title' => __( '[{{{site.name}}}] Welcome!', 'buddypress' ),
3813
- /* translators: do not remove {} brackets or translate its contents. */
3814
- 'post_content' => __( "Welcome to {{site.name}}!\n\nVisit your <a href=\"{{{profile.url}}}\">profile</a>, where you can tell us more about yourself, change your preferences, or make new connections, to get started.\n\nForgot your password? Don't worry, you can reset it with your email address from <a href=\"{{{lostpassword.url}}}\">this page</a> of our site", 'buddypress' ),
3815
- /* translators: do not remove {} brackets or translate its contents. */
3816
- 'post_excerpt' => __( "Welcome to {{site.name}}!\n\nVisit your profile, where you can tell us more about yourself, change your preferences, or make new connections, to get started: {{{profile.url}}}\n\nForgot your password? Don't worry, you can reset it with your email address from this page of our site: {{{lostpassword.url}}}", 'buddypress' ),
3817
- ),
3818
  'activity-comment' => array(
3819
  /* translators: do not remove {} brackets or translate its contents. */
3820
  'post_title' => __( '[{{{site.name}}}] {{poster.name}} replied to one of your updates', 'buddypress' ),
@@ -3851,9 +3388,9 @@ function bp_email_get_schema() {
3851
  /* translators: do not remove {} brackets or translate its contents. */
3852
  'post_title' => __( '[{{{site.name}}}] Activate your account', 'buddypress' ),
3853
  /* translators: do not remove {} brackets or translate its contents. */
3854
- 'post_content' => __( "Thanks for registering!\n\nTo complete the activation of your account, go to the following link and click on the <strong>Activate</strong> button:\n<a href=\"{{{activate.url}}}\">{{{activate.url}}}</a>\n\nIf the 'Activation Key' field is empty, copy and paste the following into the field - {{key}}", 'buddypress' ),
3855
  /* translators: do not remove {} brackets or translate its contents. */
3856
- 'post_excerpt' => __( "Thanks for registering!\n\nTo complete the activation of your account, go to the following link and click on the 'Activate' button: {{{activate.url}}}\n\nIf the 'Activation Key' field is empty, copy and paste the following into the field - {{key}}", 'buddypress' )
3857
  ),
3858
  'core-user-registration-with-blog' => array(
3859
  /* translators: do not remove {} brackets or translate its contents. */
@@ -3862,9 +3399,6 @@ function bp_email_get_schema() {
3862
  'post_content' => __( "Thanks for registering!\n\nTo complete the activation of your account and site, go to the following link: <a href=\"{{{activate-site.url}}}\">{{{activate-site.url}}}</a>.\n\nAfter you activate, you can visit your site at <a href=\"{{{user-site.url}}}\">{{{user-site.url}}}</a>.", 'buddypress' ),
3863
  /* translators: do not remove {} brackets or translate its contents. */
3864
  'post_excerpt' => __( "Thanks for registering!\n\nTo complete the activation of your account and site, go to the following link: {{{activate-site.url}}}\n\nAfter you activate, you can visit your site at {{{user-site.url}}}.", 'buddypress' ),
3865
- 'args' => array(
3866
- 'multisite' => true,
3867
- ),
3868
  ),
3869
  'friends-request' => array(
3870
  /* translators: do not remove {} brackets or translate its contents. */
@@ -3894,9 +3428,9 @@ function bp_email_get_schema() {
3894
  /* translators: do not remove {} brackets or translate its contents. */
3895
  'post_title' => __( '[{{{site.name}}}] You have an invitation to the group: "{{group.name}}"', 'buddypress' ),
3896
  /* translators: do not remove {} brackets or translate its contents. */
3897
- 'post_content' => __( "<a href=\"{{{inviter.url}}}\">{{inviter.name}}</a> has invited you to join the group: &quot;{{group.name}}&quot;.\n\n{{invite.message}}\n\n<a href=\"{{{invites.url}}}\">Go here to accept your invitation</a> or <a href=\"{{{group.url}}}\">visit the group</a> to learn more.", 'buddypress' ),
3898
  /* translators: do not remove {} brackets or translate its contents. */
3899
- 'post_excerpt' => __( "{{inviter.name}} has invited you to join the group: \"{{group.name}}\".\n\n{{invite.message}}\n\nTo accept your invitation, visit: {{{invites.url}}}\n\nTo learn more about the group, visit: {{{group.url}}}.\nTo view {{inviter.name}}'s profile, visit: {{{inviter.url}}}", 'buddypress' ),
3900
  ),
3901
  'groups-member-promoted' => array(
3902
  /* translators: do not remove {} brackets or translate its contents. */
@@ -3910,7 +3444,7 @@ function bp_email_get_schema() {
3910
  /* translators: do not remove {} brackets or translate its contents. */
3911
  'post_title' => __( '[{{{site.name}}}] Membership request for group: {{group.name}}', 'buddypress' ),
3912
  /* translators: do not remove {} brackets or translate its contents. */
3913
- 'post_content' => __( "<a href=\"{{{profile.url}}}\">{{requesting-user.name}}</a> wants to join the group &quot;{{group.name}}&quot;.\n {{request.message}}\n As you are an administrator of this group, you must either accept or reject the membership request.\n\n<a href=\"{{{group-requests.url}}}\">Go here to manage this</a> and all other pending requests.", 'buddypress' ),
3914
  /* translators: do not remove {} brackets or translate its contents. */
3915
  'post_excerpt' => __( "{{requesting-user.name}} wants to join the group \"{{group.name}}\". As you are the administrator of this group, you must either accept or reject the membership request.\n\nTo manage this and all other pending requests, visit: {{{group-requests.url}}}\n\nTo view {{requesting-user.name}}'s profile, visit: {{{profile.url}}}", 'buddypress' ),
3916
  ),
@@ -3946,15 +3480,7 @@ function bp_email_get_schema() {
3946
  /* translators: do not remove {} brackets or translate its contents. */
3947
  'post_excerpt' => __( "Your membership request for the group \"{{group.name}}\" has been rejected.\n\nTo request membership again, visit: {{{group.url}}}", 'buddypress' ),
3948
  ),
3949
- 'bp-members-invitation' => array(
3950
- /* translators: do not remove {} brackets or translate its contents. */
3951
- 'post_title' => __( '{{inviter.name}} has invited you to join {{site.name}}', 'buddypress' ),
3952
- /* translators: do not remove {} brackets or translate its contents. */
3953
- 'post_content' => __( "<a href=\"{{{inviter.url}}}\">{{inviter.name}}</a> has invited you to join the site: &quot;{{site.name}}&quot;.\n\n{{usermessage}}\n\n<a href=\"{{{invite.accept_url}}}\">Accept your invitation</a> or <a href=\"{{{site.url}}}\">visit the site</a> to learn more.", 'buddypress' ),
3954
- /* translators: do not remove {} brackets or translate its contents. */
3955
- 'post_excerpt' => __( "{{inviter.name}} has invited you to join the site \"{{site.name}}\".\n\n{{usermessage}}\n\nTo accept your invitation, visit: {{{invite.accept_url}}}\n\nTo learn more about the site, visit: {{{site.url}}}.\nTo view {{inviter.name}}'s profile, visit: {{{inviter.url}}}", 'buddypress' ),
3956
- ),
3957
- ) );
3958
  }
3959
 
3960
  /**
@@ -3977,152 +3503,137 @@ function bp_email_get_schema() {
3977
  */
3978
  function bp_email_get_type_schema( $field = 'description' ) {
3979
  $activity_comment = array(
3980
- 'description' => __( 'A member has replied to an activity update that the recipient posted.', 'buddypress' ),
3981
- 'named_salutation' => true,
3982
- 'unsubscribe' => array(
3983
- 'meta_key' => 'notification_activity_new_reply',
3984
- 'message' => __( 'You will no longer receive emails when someone replies to an update or comment you posted.', 'buddypress' ),
3985
- ),
3986
  );
3987
 
3988
  $activity_comment_author = array(
3989
- 'description' => __( 'A member has replied to a comment on an activity update that the recipient posted.', 'buddypress' ),
3990
- 'named_salutation' => true,
3991
- 'unsubscribe' => array(
3992
- 'meta_key' => 'notification_activity_new_reply',
3993
- 'message' => __( 'You will no longer receive emails when someone replies to an update or comment you posted.', 'buddypress' ),
3994
- ),
3995
  );
3996
 
3997
  $activity_at_message = array(
3998
- 'description' => __( 'Recipient was mentioned in an activity update.', 'buddypress' ),
3999
- 'named_salutation' => true,
4000
- 'unsubscribe' => array(
4001
- 'meta_key' => 'notification_activity_new_mention',
4002
- 'message' => __( 'You will no longer receive emails when someone mentions you in an update.', 'buddypress' ),
4003
  ),
4004
  );
4005
 
4006
  $groups_at_message = array(
4007
- 'description' => __( 'Recipient was mentioned in a group activity update.', 'buddypress' ),
4008
- 'named_salutation' => true,
4009
- 'unsubscribe' => array(
4010
- 'meta_key' => 'notification_activity_new_mention',
4011
- 'message' => __( 'You will no longer receive emails when someone mentions you in an update.', 'buddypress' ),
4012
  ),
4013
  );
4014
 
4015
  $core_user_registration = array(
4016
- 'description' => __( 'Recipient has registered for an account.', 'buddypress' ),
4017
- 'named_salutation' => true,
4018
- 'unsubscribe' => false,
4019
  );
4020
 
4021
  $core_user_registration_with_blog = array(
4022
- 'description' => __( 'Recipient has registered for an account and site.', 'buddypress' ),
4023
- 'named_salutation' => true,
4024
- 'unsubscribe' => false,
4025
  );
4026
 
4027
  $friends_request = array(
4028
- 'description' => __( 'A member has sent a friend request to the recipient.', 'buddypress' ),
4029
- 'named_salutation' => true,
4030
- 'unsubscribe' => array(
4031
- 'meta_key' => 'notification_friends_friendship_request',
4032
- 'message' => __( 'You will no longer receive emails when someone sends you a friend request.', 'buddypress' ),
4033
  ),
4034
  );
4035
 
4036
  $friends_request_accepted = array(
4037
- 'description' => __( 'Recipient has had a friend request accepted by a member.', 'buddypress' ),
4038
- 'named_salutation' => true,
4039
- 'unsubscribe' => array(
4040
- 'meta_key' => 'notification_friends_friendship_accepted',
4041
- 'message' => __( 'You will no longer receive emails when someone accepts your friendship request.', 'buddypress' ),
4042
  ),
4043
  );
4044
 
4045
  $groups_details_updated = array(
4046
- 'description' => __( "A group's details were updated.", 'buddypress' ),
4047
- 'named_salutation' => true,
4048
- 'unsubscribe' => array(
4049
- 'meta_key' => 'notification_groups_group_updated',
4050
- 'message' => __( 'You will no longer receive emails when one of your groups is updated.', 'buddypress' ),
 
 
 
 
 
 
 
4051
  ),
4052
  );
4053
 
4054
  $groups_invitation = array(
4055
- 'description' => __( 'A member has sent a group invitation to the recipient.', 'buddypress' ),
4056
- 'named_salutation' => true,
4057
- 'unsubscribe' => array(
4058
- 'meta_key' => 'notification_groups_invite',
4059
- 'message' => __( 'You will no longer receive emails when you are invited to join a group.', 'buddypress' ),
4060
  ),
4061
  );
4062
 
4063
  $groups_member_promoted = array(
4064
- 'description' => __( "Recipient's status within a group has changed.", 'buddypress' ),
4065
- 'named_salutation' => true,
4066
- 'unsubscribe' => array(
4067
- 'meta_key' => 'notification_groups_admin_promotion',
4068
- 'message' => __( 'You will no longer receive emails when you have been promoted in a group.', 'buddypress' ),
 
 
 
 
 
 
 
4069
  ),
4070
  );
4071
 
4072
  $groups_membership_request = array(
4073
- 'description' => __( 'A member has requested permission to join a group.', 'buddypress' ),
4074
- 'named_salutation' => true,
4075
- 'unsubscribe' => array(
4076
- 'meta_key' => 'notification_groups_membership_request',
4077
- 'message' => __( 'You will no longer receive emails when someone requests to be a member of your group.', 'buddypress' ),
4078
  ),
4079
  );
4080
 
4081
  $messages_unread = array(
4082
- 'description' => __( 'Recipient has received a private message.', 'buddypress' ),
4083
- 'named_salutation' => true,
4084
- 'unsubscribe' => array(
4085
- 'meta_key' => 'notification_messages_new_message',
4086
- 'message' => __( 'You will no longer receive emails when someone sends you a message.', 'buddypress' ),
4087
  ),
4088
  );
4089
 
4090
  $settings_verify_email_change = array(
4091
- 'description' => __( 'Recipient has changed their email address.', 'buddypress' ),
4092
- 'named_salutation' => true,
4093
- 'unsubscribe' => false,
4094
  );
4095
 
4096
  $groups_membership_request_accepted = array(
4097
- 'description' => __( 'Recipient had requested to join a group, which was accepted.', 'buddypress' ),
4098
- 'named_salutation' => true,
4099
- 'unsubscribe' => array(
4100
- 'meta_key' => 'notification_membership_request_completed',
4101
- 'message' => __( 'You will no longer receive emails when your request to join a group has been accepted or denied.', 'buddypress' ),
4102
  ),
4103
  );
4104
 
4105
  $groups_membership_request_rejected = array(
4106
- 'description' => __( 'Recipient had requested to join a group, which was rejected.', 'buddypress' ),
4107
- 'named_salutation' => true,
4108
- 'unsubscribe' => array(
4109
- 'meta_key' => 'notification_membership_request_completed',
4110
- 'message' => __( 'You will no longer receive emails when your request to join a group has been accepted or denied.', 'buddypress' ),
4111
- ),
4112
- );
4113
-
4114
- $core_user_activation = array(
4115
- 'description' => __( 'Recipient has successfully activated an account.', 'buddypress' ),
4116
- 'named_salutation' => true,
4117
- 'unsubscribe' => false,
4118
- );
4119
-
4120
- $members_invitation = array(
4121
- 'description' => __( 'A site member has sent a site invitation to the recipient.', 'buddypress' ),
4122
- 'named_salutation' => false,
4123
- 'unsubscribe' => array(
4124
- 'meta_key' => 'notification_bp_members_invite',
4125
- 'message' => __( 'You will no longer receive emails when you are invited to join this site.', 'buddypress' ),
4126
  ),
4127
  );
4128
 
@@ -4143,8 +3654,6 @@ function bp_email_get_type_schema( $field = 'description' ) {
4143
  'settings-verify-email-change' => $settings_verify_email_change,
4144
  'groups-membership-request-accepted' => $groups_membership_request_accepted,
4145
  'groups-membership-request-rejected' => $groups_membership_request_rejected,
4146
- 'core-user-activation' => $core_user_activation,
4147
- 'bp-members-invitation' => $members_invitation,
4148
  );
4149
 
4150
  if ( $field !== 'all' ) {
@@ -4164,26 +3673,17 @@ function bp_email_unsubscribe_handler() {
4164
  $raw_email_type = ! empty( $_GET['nt'] ) ? $_GET['nt'] : '';
4165
  $raw_hash = ! empty( $_GET['nh'] ) ? $_GET['nh'] : '';
4166
  $raw_user_id = ! empty( $_GET['uid'] ) ? absint( $_GET['uid'] ) : 0;
4167
- $raw_user_email = ! empty( $_GET['uem'] ) ? $_GET['uem'] : '';
4168
- $raw_member_id = ! empty( $_GET['mid'] ) ? absint( $_GET['mid'] ) : 0;
4169
- $redirect_to = '';
4170
-
4171
- $new_hash = '';
4172
- if ( ! empty( $raw_user_id ) ) {
4173
- $new_hash = hash_hmac( 'sha1', "{$raw_email_type}:{$raw_user_id}", bp_email_get_salt() );
4174
- } else if ( ! empty( $raw_user_email ) ) {
4175
- $new_hash = hash_hmac( 'sha1', "{$raw_email_type}:{$raw_user_email}", bp_email_get_salt() );
4176
- }
4177
 
4178
  // Check required values.
4179
- if ( ( ! $raw_user_id && ! $raw_user_email ) || ! $raw_email_type || ! $raw_hash || ! array_key_exists( $raw_email_type, $emails ) ) {
4180
- $redirect_to = wp_login_url();
4181
  $result_msg = __( 'Something has gone wrong.', 'buddypress' );
4182
  $unsub_msg = __( 'Please log in and go to your settings to unsubscribe from notification emails.', 'buddypress' );
4183
 
4184
  // Check valid hash.
4185
  } elseif ( ! hash_equals( $new_hash, $raw_hash ) ) {
4186
- $redirect_to = wp_login_url();
4187
  $result_msg = __( 'Something has gone wrong.', 'buddypress' );
4188
  $unsub_msg = __( 'Please log in and go to your settings to unsubscribe from notification emails.', 'buddypress' );
4189
 
@@ -4202,25 +3702,6 @@ function bp_email_unsubscribe_handler() {
4202
  $redirect_to = bp_core_get_user_domain( get_current_user_id() );
4203
  }
4204
 
4205
- // This is an unsubscribe request from a nonmember.
4206
- } else if ( $raw_user_email ) {
4207
- // Unsubscribe.
4208
- if ( bp_user_has_opted_out() ) {
4209
- $result_msg = $emails[ $raw_email_type ]['unsubscribe']['message'];
4210
- $unsub_msg = __( 'You have already unsubscribed from all communication from this site.', 'buddypress' );
4211
- } else {
4212
- $optout_args = array(
4213
- 'email_address' => $raw_user_email,
4214
- 'user_id' => $raw_member_id,
4215
- 'email_type' => $raw_email_type,
4216
- 'date_modified' => bp_core_current_time(),
4217
- );
4218
- bp_add_optout( $optout_args );
4219
- $result_msg = $emails[ $raw_email_type ]['unsubscribe']['message'];
4220
- $unsub_msg = __( 'You have been unsubscribed.', 'buddypress' );
4221
- }
4222
-
4223
- // This is an unsubscribe request from a current member.
4224
  } else {
4225
  if ( bp_is_active( 'settings' ) ) {
4226
  $redirect_to = sprintf(
@@ -4240,29 +3721,17 @@ function bp_email_unsubscribe_handler() {
4240
  $unsub_msg = __( 'You can change this or any other email notification preferences in your email settings.', 'buddypress' );
4241
  }
4242
 
4243
- if ( $raw_user_id && $redirect_to ) {
4244
- $message = sprintf(
4245
- '%1$s <a href="%2$s">%3$s</a>',
4246
- $result_msg,
4247
- esc_url( $redirect_to ),
4248
- esc_html( $unsub_msg )
4249
- );
4250
 
4251
- // Template notices are only displayed on BP pages.
4252
- bp_core_add_message( $message );
4253
- bp_core_redirect( bp_core_get_user_domain( $raw_user_id ) );
4254
 
4255
- exit;
4256
- } else {
4257
- wp_die(
4258
- sprintf( '%1$s %2$s', esc_html( $unsub_msg ), esc_html( $result_msg ) ),
4259
- esc_html( $unsub_msg ),
4260
- array(
4261
- 'link_url' => home_url(),
4262
- 'link_text' => __( 'Go to website\'s home page.', 'buddypress' ),
4263
- )
4264
- );
4265
- }
4266
  }
4267
 
4268
  /**
@@ -4277,7 +3746,6 @@ function bp_email_unsubscribe_handler() {
4277
  * @type string $notification_type Which notification type is being sent.
4278
  * @type string $user_id The ID of the user to whom the notification is sent.
4279
  * @type string $redirect_to Optional. The url to which the user will be redirected. Default is the activity directory.
4280
- * @type string $email Optional. The email address of the user to whom the notification is sent.
4281
  * }
4282
  * @return string The unsubscribe link.
4283
  */
@@ -4285,7 +3753,7 @@ function bp_email_get_unsubscribe_link( $args ) {
4285
  $emails = bp_email_get_unsubscribe_type_schema();
4286
 
4287
  if ( empty( $args['notification_type'] ) || ! array_key_exists( $args['notification_type'], $emails ) ) {
4288
- return wp_login_url();
4289
  }
4290
 
4291
  $email_type = $args['notification_type'];
@@ -4297,34 +3765,15 @@ function bp_email_get_unsubscribe_link( $args ) {
4297
  return '';
4298
  }
4299
 
4300
- $link = '';
4301
- // Case where the recipient is a member of the site.
4302
- if ( ! empty( $user_id ) ) {
4303
- $link = add_query_arg(
4304
- array(
4305
- 'action' => 'unsubscribe',
4306
- 'nh' => hash_hmac( 'sha1', "{$email_type}:{$user_id}", bp_email_get_salt() ),
4307
- 'nt' => $args['notification_type'],
4308
- 'uid' => $user_id,
4309
- ),
4310
- $redirect_to
4311
- );
4312
-
4313
- // Case where the recipient is not a member of the site.
4314
- } else if ( ! empty( $args['email_address'] ) ) {
4315
- $email_address = $args['email_address'];
4316
- $member_id = (int) $args['member_id'];
4317
- $link = add_query_arg(
4318
- array(
4319
- 'action' => 'unsubscribe',
4320
- 'nh' => hash_hmac( 'sha1', "{$email_type}:{$email_address}", bp_email_get_salt() ),
4321
- 'nt' => $args['notification_type'],
4322
- 'mid' => $member_id,
4323
- 'uem' => $email_address,
4324
- ),
4325
- $redirect_to
4326
- );
4327
- }
4328
 
4329
  /**
4330
  * Filters the unsubscribe link.
@@ -4367,222 +3816,3 @@ function bp_email_get_unsubscribe_type_schema() {
4367
  */
4368
  return (array) apply_filters( 'bp_email_get_unsubscribe_type_schema', $emails );
4369
  }
4370
-
4371
- /**
4372
- * Gets the BP Email type of a BP Email ID or object.
4373
- *
4374
- * @since 8.0.0
4375
- *
4376
- * @param int|WP_Post $email Optional. BP Email ID or BP Email object. Defaults to global $post.
4377
- * @return string The type of the BP Email object.
4378
- */
4379
- function bp_email_get_type( $email = null ) {
4380
- $email = get_post( $email );
4381
-
4382
- if ( ! $email ) {
4383
- return '';
4384
- }
4385
-
4386
- $types = bp_get_object_terms( $email->ID, bp_get_email_tax_type(), array( 'fields' => 'slugs' ) );
4387
- $type = reset( $types );
4388
-
4389
- return $type;
4390
- }
4391
-
4392
- /**
4393
- * Get BuddyPress content allowed tags.
4394
- *
4395
- * @since 3.0.0
4396
- *
4397
- * @global array $allowedtags KSES allowed HTML elements.
4398
- * @return array BuddyPress content allowed tags.
4399
- */
4400
- function bp_get_allowedtags() {
4401
- global $allowedtags;
4402
-
4403
- return array_merge_recursive( $allowedtags, array(
4404
- 'a' => array(
4405
- 'aria-label' => array(),
4406
- 'class' => array(),
4407
- 'data-bp-tooltip' => array(),
4408
- 'id' => array(),
4409
- 'rel' => array(),
4410
- ),
4411
- 'img' => array(
4412
- 'src' => array(),
4413
- 'alt' => array(),
4414
- 'width' => array(),
4415
- 'height' => array(),
4416
- 'class' => array(),
4417
- 'id' => array(),
4418
- ),
4419
- 'span'=> array(
4420
- 'class' => array(),
4421
- 'data-livestamp' => array(),
4422
- ),
4423
- 'ul' => array(),
4424
- 'ol' => array(),
4425
- 'li' => array(),
4426
- ) );
4427
- }
4428
-
4429
- /**
4430
- * Remove script and style tags from a string.
4431
- *
4432
- * @since 3.0.1
4433
- *
4434
- * @param string $string The string to strip tags from.
4435
- * @return string The stripped tags string.
4436
- */
4437
- function bp_strip_script_and_style_tags( $string ) {
4438
- return preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );
4439
- }
4440
-
4441
- /**
4442
- * Checks whether the current installation is "large".
4443
- *
4444
- * By default, an installation counts as "large" if there are 10000 users or more.
4445
- * Filter 'bp_is_large_install' to adjust.
4446
- *
4447
- * @since 4.1.0
4448
- *
4449
- * @return bool
4450
- */
4451
- function bp_is_large_install() {
4452
- // Use the Multisite function if available.
4453
- if ( function_exists( 'wp_is_large_network' ) ) {
4454
- $is_large = wp_is_large_network( 'users' );
4455
- } else {
4456
- $is_large = bp_core_get_total_member_count() > 10000;
4457
- }
4458
-
4459
- /**
4460
- * Filters whether the current installation is "large".
4461
- *
4462
- * @since 4.1.0
4463
- *
4464
- * @param bool $is_large True if the network is "large".
4465
- */
4466
- return (bool) apply_filters( 'bp_is_large_install', $is_large );
4467
- }
4468
-
4469
- /**
4470
- * Returns the upper limit on the "max" item count, for widgets that support it.
4471
- *
4472
- * @since 5.0.0
4473
- *
4474
- * @param string $widget_class Optional. Class name of the calling widget.
4475
- * @return int
4476
- */
4477
- function bp_get_widget_max_count_limit( $widget_class = '' ) {
4478
- /**
4479
- * Filters the upper limit on the "max" item count, for widgets that support it.
4480
- *
4481
- * @since 5.0.0
4482
- *
4483
- * @param int $count Defaults to 50.
4484
- * @param string $widget_class Class name of the calling widget.
4485
- */
4486
- return apply_filters( 'bp_get_widget_max_count_limit', 50, $widget_class );
4487
- }
4488
-
4489
- /**
4490
- * Add a new BP_Optout.
4491
- *
4492
- * @since 8.0.0
4493
- *
4494
- * @param array $args {
4495
- * An array of arguments describing the new opt-out.
4496
- * @type string $email_address Email address of user who has opted out.
4497
- * @type int $user_id Optional. ID of user whose communication
4498
- * prompted the user to opt-out.
4499
- * @type string $email_type Optional. Name of the email type that
4500
- * prompted the user to opt-out.
4501
- * @type string $date_modified Optional. Specify a time, else now will be used.
4502
- * }
4503
- * @return false|int False on failure, ID of new (or existing) opt-out if successful.
4504
- */
4505
- function bp_add_optout( $args = array() ) {
4506
- $optout = new BP_Optout();
4507
- $r = bp_parse_args(
4508
- $args, array(
4509
- 'email_address' => '',
4510
- 'user_id' => 0,
4511
- 'email_type' => '',
4512
- 'date_modified' => bp_core_current_time(),
4513
- ),
4514
- 'add_optout'
4515
- );
4516
-
4517
- // Opt-outs must have an email address.
4518
- if ( empty( $r['email_address'] ) ) {
4519
- return false;
4520
- }
4521
-
4522
- // Avoid creating duplicate opt-outs.
4523
- $optout_id = $optout->optout_exists(
4524
- array(
4525
- 'email_address' => $r['email_address'],
4526
- 'user_id' => $r['user_id'],
4527
- 'email_type' => $r['email_type'],
4528
- )
4529
- );
4530
-
4531
- if ( ! $optout_id ) {
4532
- // Set up the new opt-out.
4533
- $optout->email_address = $r['email_address'];
4534
- $optout->user_id = $r['user_id'];
4535
- $optout->email_type = $r['email_type'];
4536
- $optout->date_modified = $r['date_modified'];
4537
-
4538
- $optout_id = $optout->save();
4539
- }
4540
-
4541
- return $optout_id;
4542
- }
4543
-
4544
- /**
4545
- * Find matching BP_Optouts.
4546
- *
4547
- * @since 8.0.0
4548
- *
4549
- * @see BP_Optout::get() for a description of parameters and return values.
4550
- *
4551
- * @param array $args See {@link BP_Optout::get()}.
4552
- * @return array See {@link BP_Optout::get()}.
4553
- */
4554
- function bp_get_optouts( $args = array() ) {
4555
- $optout_class = new BP_Optout();
4556
- return $optout_class::get( $args );
4557
- }
4558
-
4559
- /**
4560
- * Check an email address to see if that individual has opted out.
4561
- *
4562
- * @since 8.0.0
4563
- *
4564
- * @param string $email_address Email address to check.
4565
- * @return bool True if the user has opted out, false otherwise.
4566
- */
4567
- function bp_user_has_opted_out( $email_address = '' ) {
4568
- $optout_class = new BP_Optout();
4569
- $optout_id = $optout_class->optout_exists(
4570
- array(
4571
- 'email_address' => $email_address,
4572
- )
4573
- );
4574
- return (bool) $optout_id;
4575
- }
4576
-
4577
- /**
4578
- * Delete a BP_Optout by ID.
4579
- *
4580
- * @since 8.0.0
4581
- *
4582
- * @param int $id ID of the optout to delete.
4583
- * @return bool True on success, false on failure.
4584
- */
4585
- function bp_delete_optout_by_id( $id = 0 ) {
4586
- $optout_class = new BP_Optout();
4587
- return $optout_class::delete_by_id( $id );
4588
- }
16
  * Output the BuddyPress version.
17
  *
18
  * @since 1.6.0
19
+ *
20
  */
21
  function bp_version() {
22
  echo bp_get_version();
36
  * Output the BuddyPress database version.
37
  *
38
  * @since 1.6.0
39
+ *
40
  */
41
  function bp_db_version() {
42
  echo bp_get_db_version();
56
  * Output the BuddyPress database version.
57
  *
58
  * @since 1.6.0
59
+ *
60
  */
61
  function bp_db_version_raw() {
62
  echo bp_get_db_version_raw();
73
  return !empty( $bp->db_version_raw ) ? $bp->db_version_raw : 0;
74
  }
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  /** Functions *****************************************************************/
77
 
78
  /**
236
  *
237
  * @since 1.6.0
238
  *
239
+ * @param array $old_args_keys Old argument indexs, keyed to their positions.
240
  * @param array $func_args The parameters passed to the originating function.
241
  * @return array $new_args The parsed arguments.
242
  */
321
  /**
322
  * Sanitizes a pagination argument based on both the request override and the
323
  * original value submitted via a query argument, likely to a template class
324
+ * responsible for limiting the resultset of a template loop.
325
  *
326
  * @since 2.2.0
327
  *
423
  */
424
  function bp_use_wp_admin_bar() {
425
 
426
+ // Default to true (to avoid loading deprecated BuddyBar code).
427
  $use_admin_bar = true;
428
 
429
  // Has the WP Toolbar constant been explicitly opted into?
430
  if ( defined( 'BP_USE_WP_ADMIN_BAR' ) ) {
431
  $use_admin_bar = (bool) BP_USE_WP_ADMIN_BAR;
432
+
433
+ // ...or is the old BuddyBar being forced back into use?
434
+ } elseif ( bp_force_buddybar( false ) ) {
435
+ $use_admin_bar = false;
436
  }
437
 
438
  /**
445
  return (bool) apply_filters( 'bp_use_wp_admin_bar', $use_admin_bar );
446
  }
447
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
448
  /** Directory *****************************************************************/
449
 
450
  /**
467
  'notifications',
468
  );
469
 
470
+ // Only add legacy forums if it is enabled
471
+ // prevents conflicts with bbPress, which also uses the same 'forums' id.
472
+ if ( class_exists( 'BP_Forums_Component' ) ) {
473
+ $components[] = 'forums';
474
+ }
475
+
476
  return $components;
477
  }
478
 
490
  function bp_core_get_directory_page_ids( $status = 'active' ) {
491
  $page_ids = bp_get_option( 'bp-pages', array() );
492
 
493
+ // Loop through pages
494
  foreach ( $page_ids as $component_name => $page_id ) {
495
 
496
  // Ensure that empty indexes are unset. Should only matter in edge cases.
503
  unset( $page_ids[ $component_name ] );
504
  }
505
 
506
+ // 'register' and 'activate' do not have components, but should be whitelisted.
507
  if ( in_array( $component_name, array( 'register', 'activate' ), true ) ) {
508
  continue;
509
  }
681
 
682
  // Register and Activate are not components, but need pages when
683
  // registration is enabled.
684
+ if ( bp_get_signup_allowed() ) {
685
  foreach ( array( 'register', 'activate' ) as $slug ) {
686
  if ( ! isset( $pages[ $slug ] ) ) {
687
  $pages_to_create[ $slug ] = $page_titles[ $slug ];
893
  bp_core_update_directory_page_ids( $page_ids );
894
  }
895
 
896
+ /**
897
+ * Add illegal blog names to WP so that root components will not conflict with blog names on a subdirectory installation.
898
+ *
899
+ * For example, it would stop someone creating a blog with the slug "groups".
900
+ *
901
+ * @since 1.0.0
902
+ *
903
+ * @todo Deprecate?
904
+ */
905
+ function bp_core_add_illegal_names() {
906
+ update_site_option( 'illegal_names', get_site_option( 'illegal_names' ), array() );
907
+ }
908
+
909
  /**
910
  * Get the 'search' query argument for a given component.
911
  *
937
  return apply_filters( 'bp_core_get_component_search_query_arg', $query_arg, $component );
938
  }
939
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
940
  /**
941
  * Determine whether BuddyPress should register the bp-themes directory.
942
  *
1022
  buddypress()->no_status_set = true;
1023
 
1024
  wp_safe_redirect( $location, $status );
1025
+ die;
 
 
 
 
1026
  }
1027
 
1028
  /**
1117
  }
1118
 
1119
  /**
1120
+ * Get an English-language representation of the time elapsed since a given date.
1121
  *
1122
  * Based on function created by Dunstan Orchard - http://1976design.com
1123
  *
1124
+ * This function will return an English representation of the time elapsed
1125
+ * since a given date.
1126
+ * eg: 2 hours and 50 minutes
1127
+ * eg: 4 days
1128
+ * eg: 4 weeks and 6 days
1129
  *
1130
+ * Note that fractions of minutes are not represented in the return string. So
1131
+ * an interval of 3 minutes will be represented by "3 minutes ago", as will an
1132
+ * interval of 3 minutes 59 seconds.
1133
  *
1134
+ * @since 1.0.0
1135
+ *
1136
+ * @param int|string $older_date The earlier time from which you're calculating
1137
+ * the time elapsed. Enter either as an integer Unix timestamp,
1138
+ * or as a date string of the format 'Y-m-d h:i:s'.
1139
+ * @param int|bool $newer_date Optional. Unix timestamp of date to compare older
1140
+ * date to. Default: false (current time).
1141
+ * @return string String representing the time since the older date, eg
1142
+ * "2 hours and 50 minutes".
1143
  */
1144
+ function bp_core_time_since( $older_date, $newer_date = false ) {
1145
+
1146
+ /**
1147
+ * Filters whether or not to bypass BuddyPress' time_since calculations.
1148
+ *
1149
+ * @since 1.7.0
1150
+ *
1151
+ * @param bool $value Whether or not to bypass.
1152
+ * @param string $older_date Earlier time from which we're calculating time elapsed.
1153
+ * @param string $newer_date Unix timestamp of date to compare older time to.
1154
+ */
1155
+ $pre_value = apply_filters( 'bp_core_time_since_pre', false, $older_date, $newer_date );
1156
+ if ( false !== $pre_value ) {
1157
+ return $pre_value;
1158
+ }
1159
+
1160
+ /**
1161
+ * Filters the value to use if the time since is unknown.
1162
+ *
1163
+ * @since 1.5.0
1164
+ *
1165
+ * @param string $value String representing the time since the older date.
1166
+ */
1167
+ $unknown_text = apply_filters( 'bp_core_time_since_unknown_text', __( 'sometime', 'buddypress' ) );
1168
+
1169
+ /**
1170
+ * Filters the value to use if the time since is right now.
1171
+ *
1172
+ * @since 1.5.0
1173
+ *
1174
+ * @param string $value String representing the time since the older date.
1175
+ */
1176
+ $right_now_text = apply_filters( 'bp_core_time_since_right_now_text', __( 'right now', 'buddypress' ) );
1177
+
1178
+ /**
1179
+ * Filters the value to use if the time since is some time ago.
1180
+ *
1181
+ * @since 1.5.0
1182
+ *
1183
+ * @param string $value String representing the time since the older date.
1184
+ */
1185
+ $ago_text = apply_filters( 'bp_core_time_since_ago_text', __( '%s ago', 'buddypress' ) );
1186
 
1187
  // Array of time period chunks.
1188
  $chunks = array(
1195
  1
1196
  );
1197
 
1198
+ if ( !empty( $older_date ) && !is_numeric( $older_date ) ) {
1199
+ $time_chunks = explode( ':', str_replace( ' ', ':', $older_date ) );
1200
+ $date_chunks = explode( '-', str_replace( ' ', '-', $older_date ) );
1201
+ $older_date = gmmktime( (int) $time_chunks[1], (int) $time_chunks[2], (int) $time_chunks[3], (int) $date_chunks[1], (int) $date_chunks[2], (int) $date_chunks[0] );
 
 
 
 
 
 
 
 
 
 
 
 
 
1202
  }
1203
 
1204
+ /**
1205
+ * $newer_date will equal false if we want to know the time elapsed between
1206
+ * a date and the current time. $newer_date will have a value if we want to
1207
+ * work out time elapsed between two known dates.
1208
+ */
1209
+ $newer_date = ( !$newer_date ) ? bp_core_current_time( true, 'timestamp' ) : $newer_date;
1210
+
1211
  // Difference in seconds.
1212
+ $since = $newer_date - $older_date;
1213
+
1214
+ // Something went wrong with date calculation and we ended up with a negative date.
1215
+ if ( 0 > $since ) {
1216
+ $output = $unknown_text;
1217
 
1218
  /**
1219
+ * We only want to output two chunks of time here, eg:
1220
+ * x years, xx months
1221
+ * x days, xx hours
1222
+ * so there's only two bits of calculation below:
1223
  */
1224
+ } else {
1225
+
1226
  // Step one: the first chunk.
1227
  for ( $i = 0, $j = count( $chunks ); $i < $j; ++$i ) {
1228
  $seconds = $chunks[$i];
1229
 
1230
  // Finding the biggest chunk (if the chunk fits, break).
1231
+ $count = floor( $since / $seconds );
1232
  if ( 0 != $count ) {
1233
  break;
1234
  }
1235
  }
1236
 
1237
+ // If $i iterates all the way to $j, then the event happened 0 seconds ago.
1238
+ if ( !isset( $chunks[$i] ) ) {
1239
+ $output = $right_now_text;
1240
+
1241
+ } else {
1242
 
1243
+ // Set output var.
1244
  switch ( $seconds ) {
1245
  case YEAR_IN_SECONDS :
1246
+ $output = sprintf( _n( '%s year', '%s years', $count, 'buddypress' ), $count );
 
1247
  break;
1248
  case 30 * DAY_IN_SECONDS :
1249
+ $output = sprintf( _n( '%s month', '%s months', $count, 'buddypress' ), $count );
 
1250
  break;
1251
  case WEEK_IN_SECONDS :
1252
+ $output = sprintf( _n( '%s week', '%s weeks', $count, 'buddypress' ), $count );
 
1253
  break;
1254
  case DAY_IN_SECONDS :
1255
+ $output = sprintf( _n( '%s day', '%s days', $count, 'buddypress' ), $count );
 
1256
  break;
1257
  case HOUR_IN_SECONDS :
1258
+ $output = sprintf( _n( '%s hour', '%s hours', $count, 'buddypress' ), $count );
 
1259
  break;
1260
  case MINUTE_IN_SECONDS :
1261
+ $output = sprintf( _n( '%s minute', '%s minutes', $count, 'buddypress' ), $count );
 
1262
  break;
1263
  default:
1264
+ $output = sprintf( _n( '%s second', '%s seconds', $count, 'buddypress' ), $count );
 
1265
  }
1266
 
1267
+ // Step two: the second chunk
1268
+ // A quirk in the implementation means that this
1269
+ // condition fails in the case of minutes and seconds.
1270
+ // We've left the quirk in place, since fractions of a
1271
+ // minute are not a useful piece of information for our
1272
+ // purposes.
1273
+ if ( $i + 2 < $j ) {
 
1274
  $seconds2 = $chunks[$i + 1];
1275
+ $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 );
1276
 
1277
+ // Add to output var.
1278
+ if ( 0 != $count2 ) {
1279
+ $output .= _x( ',', 'Separator in time since', 'buddypress' ) . ' ';
1280
 
1281
  switch ( $seconds2 ) {
1282
  case 30 * DAY_IN_SECONDS :
1283
+ $output .= sprintf( _n( '%s month', '%s months', $count2, 'buddypress' ), $count2 );
 
1284
  break;
1285
  case WEEK_IN_SECONDS :
1286
+ $output .= sprintf( _n( '%s week', '%s weeks', $count2, 'buddypress' ), $count2 );
 
1287
  break;
1288
  case DAY_IN_SECONDS :
1289
+ $output .= sprintf( _n( '%s day', '%s days', $count2, 'buddypress' ), $count2 );
 
1290
  break;
1291
  case HOUR_IN_SECONDS :
1292
+ $output .= sprintf( _n( '%s hour', '%s hours', $count2, 'buddypress' ), $count2 );
 
1293
  break;
1294
  case MINUTE_IN_SECONDS :
1295
+ $output .= sprintf( _n( '%s minute', '%s minutes', $count2, 'buddypress' ), $count2 );
 
1296
  break;
1297
  default:
1298
+ $output .= sprintf( _n( '%s second', '%s seconds', $count2, 'buddypress' ), $count2 );
 
1299
  }
1300
  }
1301
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1302
 
1303
+ // No output, so happened right now.
1304
+ if ( ! (int) trim( $output ) ) {
1305
+ $output = $right_now_text;
1306
+ }
1307
+ }
1308
  }
1309
 
1310
+ // Append 'ago' to the end of time-since if not 'right now'.
1311
+ if ( $output != $right_now_text ) {
1312
+ $output = sprintf( $ago_text, $output );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1313
  }
1314
 
1315
  /**
1324
  return apply_filters( 'bp_core_time_since', $output, $older_date, $newer_date );
1325
  }
1326
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1327
  /**
1328
  * Output an ISO-8601 date from a date string.
1329
  *
1403
  * so that the message is not shown to the user multiple times.
1404
  *
1405
  * @since 1.1.0
1406
+ *
1407
  */
1408
  function bp_core_setup_message() {
1409
 
1487
  *
1488
  * @since 1.0.0
1489
  *
1490
+ * usermeta table.
1491
+ *
1492
  * @return false|null Returns false if there is nothing to do.
1493
  */
1494
  function bp_core_record_activity() {
1544
  *
1545
  * @since 1.0.0
1546
  *
1547
+ * representation of the time elapsed.
1548
+ *
1549
  * @param int|string $last_activity_date The date of last activity.
1550
+ * @param string $string A sprintf()-able statement of the form 'active %s'.
1551
  * @return string $last_active A string of the form '3 years ago'.
1552
  */
1553
  function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {
1554
 
1555
  // Setup a default string if none was passed.
1556
  $string = empty( $string )
1557
+ ? '%s' // Gettext placeholder.
1558
  : $string;
1559
 
1560
  // Use the string if a last activity date was passed.
1569
  *
1570
  * @param string $last_active Last activity string based on time since date given.
1571
  * @param string $last_activity_date The date of last activity.
1572
+ * @param string $string A sprintf()-able statement of the form 'active %s'.
1573
  */
1574
  return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
1575
  }
1579
  /**
1580
  * Get the meta_key for a given piece of user metadata
1581
  *
1582
+ * BuddyPress stores a number of pieces of userdata in the WordPress central
1583
  * usermeta table. In order to allow plugins to enable multiple instances of
1584
  * BuddyPress on a single WP installation, BP's usermeta keys are filtered
1585
  * through this function, so that they can be altered on the fly.
1729
  return apply_filters( 'bp_use_embed_in_activity_replies', !defined( 'BP_EMBED_DISABLE_ACTIVITY_REPLIES' ) || !BP_EMBED_DISABLE_ACTIVITY_REPLIES );
1730
  }
1731
 
1732
+ /**
1733
+ * Are oembeds allowed in forum posts?
1734
+ *
1735
+ * @since 1.5.0
1736
+ *
1737
+ * @return bool False when forum post embed support is disabled; true when
1738
+ * enabled. Default: true.
1739
+ */
1740
+ function bp_use_embed_in_forum_posts() {
1741
+
1742
+ /**
1743
+ * Filters whether or not oEmbeds are allowed in forum posts.
1744
+ *
1745
+ * @since 1.5.0
1746
+ *
1747
+ * @param bool $value Whether or not oEmbeds are allowed.
1748
+ */
1749
+ return apply_filters( 'bp_use_embed_in_forum_posts', !defined( 'BP_EMBED_DISABLE_FORUM_POSTS' ) || !BP_EMBED_DISABLE_FORUM_POSTS );
1750
+ }
1751
+
1752
  /**
1753
  * Are oembeds allowed in private messages?
1754
  *
2355
  $slug = bp_is_active( 'blogs' ) ? bp_get_blogs_root_slug() : '';
2356
  break;
2357
 
2358
+ case 'forums':
2359
+ $slug = bp_is_active( 'forums' ) ? bp_get_forums_root_slug() : '';
2360
+ $query_string = '/?fs=';
2361
+ break;
2362
+
2363
  case 'groups':
2364
  $slug = bp_is_active( 'groups' ) ? bp_get_groups_root_slug() : '';
2365
  break;
2463
  );
2464
 
2465
  $retired_components = array(
2466
+ 'forums' => array(
2467
+ 'title' => __( 'Group Forums', 'buddypress' ),
2468
+ 'description' => sprintf( __( 'BuddyPress Forums are retired. Use %s.', 'buddypress' ), '<a href="https://bbpress.org/">bbPress</a>' )
2469
+ ),
2470
  );
2471
 
2472
  $optional_components = array(
2498
  'title' => __( 'User Groups', 'buddypress' ),
2499
  'description' => __( 'Groups allow your users to organize themselves into specific public, private or hidden sections with separate activity streams and member listings.', 'buddypress' )
2500
  ),
2501
+ 'forums' => array(
2502
+ 'title' => __( 'Group Forums (Legacy)', 'buddypress' ),
2503
+ 'description' => __( 'Group forums allow for focused, bulletin-board style conversations.', 'buddypress' )
2504
+ ),
2505
  'blogs' => array(
2506
  'title' => __( 'Site Tracking', 'buddypress' ),
2507
  'description' => __( 'Record activity for new posts and comments from your site.', 'buddypress' )
2562
  * @return mixed A URL or an array of dummy pages.
2563
  */
2564
  function bp_nav_menu_get_loggedin_pages() {
 
2565
 
2566
  // Try to catch the cached version first.
2567
+ if ( ! empty( buddypress()->wp_nav_menu_items->loggedin ) ) {
2568
+ return buddypress()->wp_nav_menu_items->loggedin;
2569
  }
2570
 
2571
  // Pull up a list of items registered in BP's primary nav for the member.
2572
+ $bp_menu_items = buddypress()->members->nav->get_primary();
2573
 
2574
  // Some BP nav menu items will not be represented in bp_nav, because
2575
  // they are not real BP components. We add them manually here.
2597
  'post_author' => 0,
2598
  'post_date' => 0,
2599
  'post_excerpt' => $bp_item['slug'],
2600
+ 'post_type' => 'page',
2601
  'post_status' => 'publish',
2602
  'comment_status' => 'closed',
2603
  'guid' => $bp_item['link']
2604
  );
2605
  }
2606
 
2607
+ if ( empty( buddypress()->wp_nav_menu_items ) ) {
2608
  buddypress()->wp_nav_menu_items = new stdClass;
2609
  }
2610
 
2611
+ buddypress()->wp_nav_menu_items->loggedin = $page_args;
2612
 
2613
  return $page_args;
2614
  }
2628
  * @return mixed A URL or an array of dummy pages.
2629
  */
2630
  function bp_nav_menu_get_loggedout_pages() {
 
2631
 
2632
  // Try to catch the cached version first.
2633
+ if ( ! empty( buddypress()->wp_nav_menu_items->loggedout ) ) {
2634
+ return buddypress()->wp_nav_menu_items->loggedout;
2635
  }
2636
 
2637
  $bp_menu_items = array();
2671
  'post_author' => 0,
2672
  'post_date' => 0,
2673
  'post_excerpt' => $bp_item['slug'],
2674
+ 'post_type' => 'page',
2675
  'post_status' => 'publish',
2676
  'comment_status' => 'closed',
2677
  'guid' => $bp_item['link']
2678
  );
2679
  }
2680
 
2681
+ if ( empty( buddypress()->wp_nav_menu_items ) ) {
2682
+ buddypress()->wp_nav_menu_items = new stdClass;
2683
  }
2684
 
2685
+ buddypress()->wp_nav_menu_items->loggedout = $page_args;
2686
 
2687
  return $page_args;
2688
  }
2751
  * @since 2.1.0
2752
  *
2753
  * @param string $value Custom class to use. Default: none.
2754
+ * @param array $args Array of arguments for sugggestions.
2755
  */
2756
  $class = apply_filters( 'bp_suggestions_services', '', $args );
2757
  }
2781
  return apply_filters( 'bp_core_get_suggestions', $retval, $args );
2782
  }
2783
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2784
  /**
2785
  * Set data from the BP root blog's upload directory.
2786
  *
2919
  /** Taxonomies *****************************************************************/
2920
 
2921
  /**
2922
+ * Output the name of the email type taxonomy.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2923
  *
2924
  * @since 2.5.0
2925
  */
2980
  ) );
2981
  }
2982
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2983
 
2984
  /** Email *****************************************************************/
2985
 
3088
  *
3089
  * @param string $email_type Type of email being sent.
3090
  * @param string|array|int|WP_User $to Either a email address, user ID, WP_User object,
3091
+ * or an array containg the address and name.
3092
  * @param array $args {
3093
  * Optional. Array of extra parameters.
3094
  *
3095
+ * @type array $tokens Optional. Assocative arrays of string replacements for the email.
3096
  * }
3097
  * @return bool|WP_Error True if the email was sent successfully. Otherwise, a WP_Error object
3098
  * describing why the email failed to send. The contents will vary based
3133
  }
3134
 
3135
  // From, subject, content are set automatically.
3136
+ $email->set_to( $to );
 
 
 
 
 
 
 
 
3137
  $email->set_tokens( $args['tokens'] );
3138
 
3139
  /**
3144
  * @param BP_Email $email The email (object) about to be sent.
3145
  * @param string $email_type Type of email being sent.
3146
  * @param string|array|int|WP_User $to Either a email address, user ID, WP_User object,
3147
+ * or an array containg the address and name.
3148
  * @param array $args {
3149
  * Optional. Array of extra parameters.
3150
  *
3151
+ * @type array $tokens Optional. Assocative arrays of string replacements for the email.
3152
  * }
3153
  */
3154
  do_action_ref_array( 'bp_send_email', array( &$email, $email_type, $to, $args ) );
3198
  * @param array $args {
3199
  * Optional. Array of extra parameters.
3200
  *
3201
+ * @type array $tokens Optional. Assocative arrays of string replacements for the email.
3202
  * }
3203
  */
3204
  $delivery_class = apply_filters( 'bp_send_email_delivery_class', 'BP_PHPMailer', $email_type, $to, $args );
3205
  if ( ! class_exists( $delivery_class ) ) {
3206
+ return new WP_Error( 'missing_class', __CLASS__, $this );
3207
  }
3208
 
3209
  $delivery = new $delivery_class();
3225
  } else {
3226
 
3227
  /**
3228
+ * Fires after BuddyPress has succesfully sent an email.
3229
  *
3230
  * @since 2.5.0
3231
  *
3242
  * Return email appearance settings.
3243
  *
3244
  * @since 2.5.0
 
 
3245
  *
3246
  * @return array
3247
  */
3248
  function bp_email_get_appearance_settings() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3249
  $default_args = array(
3250
  'body_bg' => '#FFFFFF',
3251
  'body_text_color' => '#555555',
3258
  'highlight_color' => '#D84800',
3259
  'header_text_color' => '#000000',
3260
  'header_text_size' => 30,
 
3261
 
3262
+ 'footer_text' => sprintf(
3263
+ /* translators: email disclaimer, e.g. "© 2016 Site Name". */
3264
+ _x( '&copy; %s %s', 'email', 'buddypress' ),
3265
+ date_i18n( 'Y' ),
3266
+ bp_get_option( 'blogname' )
3267
+ ),
3268
  );
3269
 
3270
+ return bp_parse_args(
3271
  bp_get_option( 'bp_email_options', array() ),
3272
  $default_args,
3273
  'email_appearance_settings'
3274
  );
 
 
 
 
 
 
 
3275
  }
3276
 
3277
  /**
3294
  * @param WP_Post $object WP_Post object.
3295
  */
3296
  return apply_filters( 'bp_email_get_template', array(
 
3297
  "{$single}-{$object->post_name}.php",
3298
  "{$single}.php",
3299
  "assets/emails/{$single}.php",
3351
  * @return array
3352
  */
3353
  function bp_email_get_schema() {
3354
+ return array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3355
  'activity-comment' => array(
3356
  /* translators: do not remove {} brackets or translate its contents. */
3357
  'post_title' => __( '[{{{site.name}}}] {{poster.name}} replied to one of your updates', 'buddypress' ),
3388
  /* translators: do not remove {} brackets or translate its contents. */
3389
  'post_title' => __( '[{{{site.name}}}] Activate your account', 'buddypress' ),
3390
  /* translators: do not remove {} brackets or translate its contents. */
3391
+ 'post_content' => __( "Thanks for registering!\n\nTo complete the activation of your account, go to the following link: <a href=\"{{{activate.url}}}\">{{{activate.url}}}</a>", 'buddypress' ),
3392
  /* translators: do not remove {} brackets or translate its contents. */
3393
+ 'post_excerpt' => __( "Thanks for registering!\n\nTo complete the activation of your account, go to the following link: {{{activate.url}}}", 'buddypress' ),
3394
  ),
3395
  'core-user-registration-with-blog' => array(
3396
  /* translators: do not remove {} brackets or translate its contents. */
3399
  'post_content' => __( "Thanks for registering!\n\nTo complete the activation of your account and site, go to the following link: <a href=\"{{{activate-site.url}}}\">{{{activate-site.url}}}</a>.\n\nAfter you activate, you can visit your site at <a href=\"{{{user-site.url}}}\">{{{user-site.url}}}</a>.", 'buddypress' ),
3400
  /* translators: do not remove {} brackets or translate its contents. */
3401
  'post_excerpt' => __( "Thanks for registering!\n\nTo complete the activation of your account and site, go to the following link: {{{activate-site.url}}}\n\nAfter you activate, you can visit your site at {{{user-site.url}}}.", 'buddypress' ),
 
 
 
3402
  ),
3403
  'friends-request' => array(
3404
  /* translators: do not remove {} brackets or translate its contents. */
3428
  /* translators: do not remove {} brackets or translate its contents. */
3429
  'post_title' => __( '[{{{site.name}}}] You have an invitation to the group: "{{group.name}}"', 'buddypress' ),
3430
  /* translators: do not remove {} brackets or translate its contents. */
3431
+ 'post_content' => __( "<a href=\"{{{inviter.url}}}\">{{inviter.name}}</a> has invited you to join the group: &quot;{{group.name}}&quot;.\n<a href=\"{{{invites.url}}}\">Go here to accept your invitation</a> or <a href=\"{{{group.url}}}\">visit the group</a> to learn more.", 'buddypress' ),
3432
  /* translators: do not remove {} brackets or translate its contents. */
3433
+ 'post_excerpt' => __( "{{inviter.name}} has invited you to join the group: \"{{group.name}}\".\n\nTo accept your invitation, visit: {{{invites.url}}}\n\nTo learn more about the group, visit: {{{group.url}}}.\nTo view {{inviter.name}}'s profile, visit: {{{inviter.url}}}", 'buddypress' ),
3434
  ),
3435
  'groups-member-promoted' => array(
3436
  /* translators: do not remove {} brackets or translate its contents. */
3444
  /* translators: do not remove {} brackets or translate its contents. */
3445
  'post_title' => __( '[{{{site.name}}}] Membership request for group: {{group.name}}', 'buddypress' ),
3446
  /* translators: do not remove {} brackets or translate its contents. */
3447
+ 'post_content' => __( "<a href=\"{{{profile.url}}}\">{{requesting-user.name}}</a> wants to join the group &quot;{{group.name}}&quot;. As you are an administrator of this group, you must either accept or reject the membership request.\n\n<a href=\"{{{group-requests.url}}}\">Go here to manage this</a> and all other pending requests.", 'buddypress' ),
3448
  /* translators: do not remove {} brackets or translate its contents. */
3449
  'post_excerpt' => __( "{{requesting-user.name}} wants to join the group \"{{group.name}}\". As you are the administrator of this group, you must either accept or reject the membership request.\n\nTo manage this and all other pending requests, visit: {{{group-requests.url}}}\n\nTo view {{requesting-user.name}}'s profile, visit: {{{profile.url}}}", 'buddypress' ),
3450
  ),
3480
  /* translators: do not remove {} brackets or translate its contents. */
3481
  'post_excerpt' => __( "Your membership request for the group \"{{group.name}}\" has been rejected.\n\nTo request membership again, visit: {{{group.url}}}", 'buddypress' ),
3482
  ),
3483
+ );
 
 
 
 
 
 
 
 
3484
  }
3485
 
3486
  /**
3503
  */
3504
  function bp_email_get_type_schema( $field = 'description' ) {
3505
  $activity_comment = array(
3506
+ 'description' => __( 'A member has replied to an activity update that the recipient posted.', 'buddypress' ),
3507
+ 'unsubscribe' => array(
3508
+ 'meta_key' => 'notification_activity_new_reply',
3509
+ 'message' => __( 'You will no longer receive emails when someone replies to an update or comment you posted.', 'buddypress' ),
3510
+ ),
 
3511
  );
3512
 
3513
  $activity_comment_author = array(
3514
+ 'description' => __( 'A member has replied to a comment on an activity update that the recipient posted.', 'buddypress' ),
3515
+ 'unsubscribe' => array(
3516
+ 'meta_key' => 'notification_activity_new_reply',
3517
+ 'message' => __( 'You will no longer receive emails when someone replies to an update or comment you posted.', 'buddypress' ),
3518
+ ),
 
3519
  );
3520
 
3521
  $activity_at_message = array(
3522
+ 'description' => __( 'Recipient was mentioned in an activity update.', 'buddypress' ),
3523
+ 'unsubscribe' => array(
3524
+ 'meta_key' => 'notification_activity_new_mention',
3525
+ 'message' => __( 'You will no longer receive emails when someone mentions you in an update.', 'buddypress' ),
 
3526
  ),
3527
  );
3528
 
3529
  $groups_at_message = array(
3530
+ 'description' => __( 'Recipient was mentioned in a group activity update.', 'buddypress' ),
3531
+ 'unsubscribe' => array(
3532
+ 'meta_key' => 'notification_activity_new_mention',
3533
+ 'message' => __( 'You will no longer receive emails when someone mentions you in an update.', 'buddypress' ),
 
3534
  ),
3535
  );
3536
 
3537
  $core_user_registration = array(
3538
+ 'description' => __( 'Recipient has registered for an account.', 'buddypress' ),
3539
+ 'unsubscribe' => false,
 
3540
  );
3541
 
3542
  $core_user_registration_with_blog = array(
3543
+ 'description' => __( 'Recipient has registered for an account and site.', 'buddypress' ),
3544
+ 'unsubscribe' => false,
 
3545
  );
3546
 
3547
  $friends_request = array(
3548
+ 'description' => __( 'A member has sent a friend request to the recipient.', 'buddypress' ),
3549
+ 'unsubscribe' => array(
3550
+ 'meta_key' => 'notification_friends_friendship_request',
3551
+ 'message' => __( 'You will no longer receive emails when someone sends you a friend request.', 'buddypress' ),
 
3552
  ),
3553
  );
3554
 
3555
  $friends_request_accepted = array(
3556
+ 'description' => __( 'Recipient has had a friend request accepted by a member.', 'buddypress' ),
3557
+ 'unsubscribe' => array(
3558
+ 'meta_key' => 'notification_friends_friendship_accepted',
3559
+ 'message' => __( 'You will no longer receive emails when someone accepts your friendship request.', 'buddypress' ),
 
3560
  ),
3561
  );
3562
 
3563
  $groups_details_updated = array(
3564
+ 'description' => __( "A group's details were updated.", 'buddypress' ),
3565
+ 'unsubscribe' => array(
3566
+ 'meta_key' => 'notification_groups_group_updated',
3567
+ 'message' => __( 'You will no longer receive emails when one of your groups is updated.', 'buddypress' ),
3568
+ ),
3569
+ );
3570
+
3571
+ $groups_details_updated = array(
3572
+ 'description' => __( "A group's details were updated.", 'buddypress' ),
3573
+ 'unsubscribe' => array(
3574
+ 'meta_key' => 'notification_groups_group_updated',
3575
+ 'message' => __( 'You will no longer receive emails when one of your groups is updated.', 'buddypress' ),
3576
  ),
3577
  );
3578
 
3579
  $groups_invitation = array(
3580
+ 'description' => __( 'A member has sent a group invitation to the recipient.', 'buddypress' ),
3581
+ 'unsubscribe' => array(
3582
+ 'meta_key' => 'notification_groups_invite',
3583
+ 'message' => __( 'You will no longer receive emails when you are invited to join a group.', 'buddypress' ),
 
3584
  ),
3585
  );
3586
 
3587
  $groups_member_promoted = array(
3588
+ 'description' => __( "Recipient's status within a group has changed.", 'buddypress' ),
3589
+ 'unsubscribe' => array(
3590
+ 'meta_key' => 'notification_groups_admin_promotion',
3591
+ 'message' => __( 'You will no longer receive emails when you have been promoted in a group.', 'buddypress' ),
3592
+ ),
3593
+ );
3594
+
3595
+ $groups_member_promoted = array(
3596
+ 'description' => __( "Recipient's status within a group has changed.", 'buddypress' ),
3597
+ 'unsubscribe' => array(
3598
+ 'meta_key' => 'notification_groups_admin_promotion',
3599
+ 'message' => __( 'You will no longer receive emails when you have been promoted in a group.', 'buddypress' ),
3600
  ),
3601
  );
3602
 
3603
  $groups_membership_request = array(
3604
+ 'description' => __( 'A member has requested permission to join a group.', 'buddypress' ),
3605
+ 'unsubscribe' => array(
3606
+ 'meta_key' => 'notification_groups_membership_request',
3607
+ 'message' => __( 'You will no longer receive emails when someone requests to be a member of your group.', 'buddypress' ),
 
3608
  ),
3609
  );
3610
 
3611
  $messages_unread = array(
3612
+ 'description' => __( 'Recipient has received a private message.', 'buddypress' ),
3613
+ 'unsubscribe' => array(
3614
+ 'meta_key' => 'notification_messages_new_message',
3615
+ 'message' => __( 'You will no longer receive emails when someone sends you a message.', 'buddypress' ),
 
3616
  ),
3617
  );
3618
 
3619
  $settings_verify_email_change = array(
3620
+ 'description' => __( 'Recipient has changed their email address.', 'buddypress' ),
3621
+ 'unsubscribe' => false,
 
3622
  );
3623
 
3624
  $groups_membership_request_accepted = array(
3625
+ 'description' => __( 'Recipient had requested to join a group, which was accepted.', 'buddypress' ),
3626
+ 'unsubscribe' => array(
3627
+ 'meta_key' => 'notification_membership_request_completed',
3628
+ 'message' => __( 'You will no longer receive emails when your request to join a group has been accepted or denied.', 'buddypress' ),
 
3629
  ),
3630
  );
3631
 
3632
  $groups_membership_request_rejected = array(
3633
+ 'description' => __( 'Recipient had requested to join a group, which was rejected.', 'buddypress' ),
3634
+ 'unsubscribe' => array(
3635
+ 'meta_key' => 'notification_membership_request_completed',
3636
+ 'message' => __( 'You will no longer receive emails when your request to join a group has been accepted or denied.', 'buddypress' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3637
  ),
3638
  );
3639
 
3654
  'settings-verify-email-change' => $settings_verify_email_change,
3655
  'groups-membership-request-accepted' => $groups_membership_request_accepted,
3656
  'groups-membership-request-rejected' => $groups_membership_request_rejected,
 
 
3657
  );
3658
 
3659
  if ( $field !== 'all' ) {
3673
  $raw_email_type = ! empty( $_GET['nt'] ) ? $_GET['nt'] : '';
3674
  $raw_hash = ! empty( $_GET['nh'] ) ? $_GET['nh'] : '';
3675
  $raw_user_id = ! empty( $_GET['uid'] ) ? absint( $_GET['uid'] ) : 0;
3676
+ $new_hash = hash_hmac( 'sha1', "{$raw_email_type}:{$raw_user_id}", bp_email_get_salt() );
 
 
 
 
 
 
 
 
 
3677
 
3678
  // Check required values.
3679
+ if ( ! $raw_user_id || ! $raw_email_type || ! $raw_hash || ! array_key_exists( $raw_email_type, $emails ) ) {
3680
+ $redirect_to = site_url( 'wp-login.php' );
3681
  $result_msg = __( 'Something has gone wrong.', 'buddypress' );
3682
  $unsub_msg = __( 'Please log in and go to your settings to unsubscribe from notification emails.', 'buddypress' );
3683
 
3684
  // Check valid hash.
3685
  } elseif ( ! hash_equals( $new_hash, $raw_hash ) ) {
3686
+ $redirect_to = site_url( 'wp-login.php' );
3687
  $result_msg = __( 'Something has gone wrong.', 'buddypress' );
3688
  $unsub_msg = __( 'Please log in and go to your settings to unsubscribe from notification emails.', 'buddypress' );
3689
 
3702
  $redirect_to = bp_core_get_user_domain( get_current_user_id() );
3703
  }
3704
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3705
  } else {
3706
  if ( bp_is_active( 'settings' ) ) {
3707
  $redirect_to = sprintf(
3721
  $unsub_msg = __( 'You can change this or any other email notification preferences in your email settings.', 'buddypress' );
3722
  }
3723
 
3724
+ $message = sprintf(
3725
+ '%1$s <a href="%2$s">%3$s</a>',
3726
+ $result_msg,
3727
+ esc_url( $redirect_to ),
3728
+ esc_html( $unsub_msg )
3729
+ );
 
3730
 
3731
+ bp_core_add_message( $message );
3732
+ bp_core_redirect( bp_core_get_user_domain( $raw_user_id ) );
 
3733
 
3734
+ exit;
 
 
 
 
 
 
 
 
 
 
3735
  }
3736
 
3737
  /**
3746
  * @type string $notification_type Which notification type is being sent.
3747
  * @type string $user_id The ID of the user to whom the notification is sent.
3748
  * @type string $redirect_to Optional. The url to which the user will be redirected. Default is the activity directory.
 
3749
  * }
3750
  * @return string The unsubscribe link.
3751
  */
3753
  $emails = bp_email_get_unsubscribe_type_schema();
3754
 
3755
  if ( empty( $args['notification_type'] ) || ! array_key_exists( $args['notification_type'], $emails ) ) {
3756
+ return site_url( 'wp-login.php' );
3757
  }
3758
 
3759
  $email_type = $args['notification_type'];
3765
  return '';
3766
  }
3767
 
3768
+ $link = add_query_arg(
3769
+ array(
3770
+ 'action' => 'unsubscribe',
3771
+ 'nh' => hash_hmac( 'sha1', "{$email_type}:{$user_id}", bp_email_get_salt() ),
3772
+ 'nt' => $args['notification_type'],
3773
+ 'uid' => $user_id,
3774
+ ),
3775
+ $redirect_to
3776
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3777
 
3778
  /**
3779
  * Filters the unsubscribe link.
3816
  */
3817
  return (array) apply_filters( 'bp_email_get_unsubscribe_type_schema', $emails );
3818
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/bp-core-moderation.php CHANGED
@@ -141,13 +141,13 @@ function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = '',
141
  */
142
 
143
  // Get the moderation keys.
144
- $disallowed = trim( get_option( 'moderation_keys' ) );
145
 
146
- // Bail if list is empty.
147
- if ( ! empty( $disallowed ) ) {
148
 
149
  // Get words separated by new lines.
150
- $words = explode( "\n", $disallowed );
151
 
152
  // Loop through words.
153
  foreach ( (array) $words as $word ) {
@@ -187,7 +187,10 @@ function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = '',
187
  /**
188
  * Check for blocked keys.
189
  *
190
- * @since 7.0.0
 
 
 
191
  *
192
  * @param int $user_id User ID.
193
  * @param string $title The title of the content.
@@ -195,34 +198,19 @@ function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = '',
195
  * @param string $error_type The error type to return. Either 'bool' or 'wp_error'.
196
  * @return bool|WP_Error True if test is passed, false if fail.
197
  */
198
- function bp_core_check_for_disallowed_keys( $user_id = 0, $title = '', $content = '', $error_type = 'bool' ) {
199
 
200
  /**
201
  * Filters whether or not to bypass checking for blocked keys.
202
  *
203
  * @since 2.2.0
204
- * @deprecated 7.0.0 Use 'bp_bypass_check_for_disallowed_keys' instead.
205
- *
206
- * @param bool $value Whether or not to bypass checking. Default false.
207
- * @param int $user_id Topic of reply author ID.
208
- * @param string $title The title of the content.
209
- * @param string $content $the content being posted.
210
- */
211
- if ( apply_filters_deprecated( 'bp_bypass_check_for_blacklist', array( false, $user_id, $title, $content ), '7.0.0', 'bp_bypass_check_for_disallowed_keys' ) ) {
212
- return true;
213
- }
214
-
215
- /**
216
- * Filters whether or not to bypass checking for blocked keys.
217
- *
218
- * @since 7.0.0
219
  *
220
  * @param bool $value Whether or not to bypass checking. Default false.
221
  * @param int $user_id Topic of reply author ID.
222
  * @param string $title The title of the content.
223
  * @param string $content $the content being posted.
224
  */
225
- if ( apply_filters( 'bp_bypass_check_for_disallowed_keys', false, $user_id, $title, $content ) ) {
226
  return true;
227
  }
228
 
@@ -238,17 +226,10 @@ function bp_core_check_for_disallowed_keys( $user_id = 0, $title = '', $content
238
  */
239
 
240
  // Get the moderation keys.
241
- $disallowed = get_option( 'disallowed_keys' );
242
-
243
- // Support for WP < 5.5.
244
- if ( false === $disallowed ) {
245
- $disallowed = get_option( 'blacklist_keys' );
246
- }
247
-
248
- $disallowed = trim( $disallowed );
249
 
250
- // Bail if disallowed list is empty.
251
- if ( empty( $disallowed ) ) {
252
  return true;
253
  }
254
 
@@ -281,7 +262,7 @@ function bp_core_check_for_disallowed_keys( $user_id = 0, $title = '', $content
281
  */
282
 
283
  // Get words separated by new lines.
284
- $words = explode( "\n", $disallowed );
285
 
286
  // Loop through words.
287
  foreach ( (array) $words as $word ) {
@@ -305,7 +286,7 @@ function bp_core_check_for_disallowed_keys( $user_id = 0, $title = '', $content
305
  if ( 'bool' === $error_type ) {
306
  return false;
307
  } else {
308
- return new WP_Error( 'bp_moderation_disallowed_key_match', _x( 'You have posted an inappropriate word.', 'Comment disallowed key', 'buddypress' ) );
309
  }
310
  }
311
  }
141
  */
142
 
143
  // Get the moderation keys.
144
+ $blacklist = trim( get_option( 'moderation_keys' ) );
145
 
146
+ // Bail if blacklist is empty.
147
+ if ( ! empty( $blacklist ) ) {
148
 
149
  // Get words separated by new lines.
150
+ $words = explode( "\n", $blacklist );
151
 
152
  // Loop through words.
153
  foreach ( (array) $words as $word ) {
187
  /**
188
  * Check for blocked keys.
189
  *
190
+ * @since 1.6.0
191
+ * @since 2.6.0 Added $error_type parameter.
192
+ *
193
+ * @todo Why don't we use wp_blacklist_check() for this?
194
  *
195
  * @param int $user_id User ID.
196
  * @param string $title The title of the content.
198
  * @param string $error_type The error type to return. Either 'bool' or 'wp_error'.
199
  * @return bool|WP_Error True if test is passed, false if fail.
200
  */
201
+ function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '', $error_type = 'bool' ) {
202
 
203
  /**
204
  * Filters whether or not to bypass checking for blocked keys.
205
  *
206
  * @since 2.2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  *
208
  * @param bool $value Whether or not to bypass checking. Default false.
209
  * @param int $user_id Topic of reply author ID.
210
  * @param string $title The title of the content.
211
  * @param string $content $the content being posted.
212
  */
213
+ if ( apply_filters( 'bp_bypass_check_for_blacklist', false, $user_id, $title, $content ) ) {
214
  return true;
215
  }
216
 
226
  */
227
 
228
  // Get the moderation keys.
229
+ $blacklist = trim( get_option( 'blacklist_keys' ) );
 
 
 
 
 
 
 
230
 
231
+ // Bail if blacklist is empty.
232
+ if ( empty( $blacklist ) ) {
233
  return true;
234
  }
235
 
262
  */
263
 
264
  // Get words separated by new lines.
265
+ $words = explode( "\n", $blacklist );
266
 
267
  // Loop through words.
268
  foreach ( (array) $words as $word ) {
286
  if ( 'bool' === $error_type ) {
287
  return false;
288
  } else {
289
+ return new WP_Error( 'bp_moderation_blacklist_match', _x( 'You have posted an inappropriate word.', 'Comment blacklist', 'buddypress' ) );
290
  }
291
  }
292
  }
bp-core/bp-core-options.php CHANGED
@@ -29,6 +29,11 @@ function bp_get_default_options() {
29
 
30
  'bp-deactivated-components' => array(),
31
 
 
 
 
 
 
32
  /* XProfile **********************************************************/
33
 
34
  // Base profile groups name.
@@ -65,11 +70,11 @@ function bp_get_default_options() {
65
  // Allow users to delete their own accounts.
66
  'bp-disable-account-deletion' => false,
67
 
68
- // Allow comments on post and comment activity items.
69
  'bp-disable-blogforum-comments' => true,
70
 
71
  // The ID for the current theme package.
72
- '_bp_theme_package_id' => 'nouveau',
73
 
74
  // Email unsubscribe salt.
75
  'bp-emails-unsubscribe-salt' => '',
@@ -90,6 +95,11 @@ function bp_get_default_options() {
90
  // HeartBeat is on to refresh activities.
91
  '_bp_enable_heartbeat_refresh' => true,
92
 
 
 
 
 
 
93
  /* Legacy *********************************************/
94
 
95
  // Do not register the bp-default themes directory.
@@ -616,7 +626,7 @@ function bp_disable_account_deletion( $default = false ) {
616
  }
617
 
618
  /**
619
- * Are post/comment activity stream comments disabled?
620
  *
621
  * @since 1.6.0
622
  *
@@ -662,6 +672,78 @@ function bp_restrict_group_creation( $default = true ) {
662
  return (bool) apply_filters( 'bp_restrict_group_creation', (bool) bp_get_option( 'bp_restrict_group_creation', $default ) );
663
  }
664
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
665
  /**
666
  * Check whether Akismet is enabled.
667
  *
29
 
30
  'bp-deactivated-components' => array(),
31
 
32
+ /* bbPress ***********************************************************/
33
+
34
+ // Legacy bbPress config location.
35
+ 'bb-config-location' => ABSPATH . 'bb-config.php',
36
+
37
  /* XProfile **********************************************************/
38
 
39
  // Base profile groups name.
70
  // Allow users to delete their own accounts.
71
  'bp-disable-account-deletion' => false,
72
 
73
+ // Allow comments on blog and forum activity items.
74
  'bp-disable-blogforum-comments' => true,
75
 
76
  // The ID for the current theme package.
77
+ '_bp_theme_package_id' => 'legacy',
78
 
79
  // Email unsubscribe salt.
80
  'bp-emails-unsubscribe-salt' => '',
95
  // HeartBeat is on to refresh activities.
96
  '_bp_enable_heartbeat_refresh' => true,
97
 
98
+ /* BuddyBar **********************************************************/
99
+
100
+ // Force the BuddyBar.
101
+ '_bp_force_buddybar' => false,
102
+
103
  /* Legacy *********************************************/
104
 
105
  // Do not register the bp-default themes directory.
626
  }
627
 
628
  /**
629
+ * Are blog and forum activity stream comments disabled?
630
  *
631
  * @since 1.6.0
632
  *
672
  return (bool) apply_filters( 'bp_restrict_group_creation', (bool) bp_get_option( 'bp_restrict_group_creation', $default ) );
673
  }
674
 
675
+ /**
676
+ * Should the old BuddyBar be forced in place of the WP admin bar?
677
+ *
678
+ * @since 1.6.0
679
+ *
680
+ * @param bool $default Optional. Fallback value if not found in the database.
681
+ * Default: true.
682
+ * @return bool True if the BuddyBar should be forced on, otherwise false.
683
+ */
684
+ function bp_force_buddybar( $default = true ) {
685
+
686
+ /**
687
+ * Filters whether or not BuddyBar should be forced in place of WP Admin Bar.
688
+ *
689
+ * @since 1.6.0
690
+ *
691
+ * @param bool $value Whether or not BuddyBar should be forced in place of WP Admin Bar.
692
+ */
693
+ return (bool) apply_filters( 'bp_force_buddybar', (bool) bp_get_option( '_bp_force_buddybar', $default ) );
694
+ }
695
+
696
+ /**
697
+ * Output the group forums root parent forum id.
698
+ *
699
+ * @since 1.6.0
700
+ *
701
+ * @param bool|string $default Optional. Default: '0'.
702
+ */
703
+ function bp_group_forums_root_id( $default = '0' ) {
704
+ echo bp_get_group_forums_root_id( $default );
705
+ }
706
+ /**
707
+ * Return the group forums root parent forum id.
708
+ *
709
+ * @since 1.6.0
710
+ *
711
+ * @param bool|string $default Optional. Default: '0'.
712
+ * @return int The ID of the group forums root forum.
713
+ */
714
+ function bp_get_group_forums_root_id( $default = '0' ) {
715
+
716
+ /**
717
+ * Filters the group forums root parent forum id.
718
+ *
719
+ * @since 1.6.0
720
+ *
721
+ * @param int $value The group forums root parent forum id.
722
+ */
723
+ return (int) apply_filters( 'bp_get_group_forums_root_id', (int) bp_get_option( '_bp_group_forums_root_id', $default ) );
724
+ }
725
+
726
+ /**
727
+ * Check whether BuddyPress Group Forums are enabled.
728
+ *
729
+ * @since 1.6.0
730
+ *
731
+ * @param bool $default Optional. Fallback value if not found in the database.
732
+ * Default: true.
733
+ * @return bool True if group forums are active, otherwise false.
734
+ */
735
+ function bp_is_group_forums_active( $default = true ) {
736
+
737
+ /**
738
+ * Filters whether or not BuddyPress Group Forums are enabled.
739
+ *
740
+ * @since 1.6.0
741
+ *
742
+ * @param bool $value Whether or not BuddyPress Group Forums are enabled.
743
+ */
744
+ return (bool) apply_filters( 'bp_is_group_forums_active', (bool) bp_get_option( '_bp_enable_group_forums', $default ) );
745
+ }
746
+
747
  /**
748
  * Check whether Akismet is enabled.
749
  *
bp-core/bp-core-rest-api.php DELETED
@@ -1,398 +0,0 @@
1
- <?php
2
- /**
3
- * Core REST API functions.
4
- *
5
- * @package BuddyPress
6
- * @subpackage Core
7
- * @since 5.0.0
8
- */
9
-
10
- // Exit if accessed directly.
11
- defined( 'ABSPATH' ) || exit;
12
-
13
- /**
14
- * Is the BP REST plugin is active?
15
- *
16
- * @since 5.0.0
17
- *
18
- * @return boolean True if the BP REST plugin is active. False otherwise.
19
- */
20
- function bp_rest_is_plugin_active() {
21
- return (bool) has_action( 'bp_rest_api_init', 'bp_rest', 5 );
22
- }
23
-
24
- /**
25
- * Should we use the REST Endpoints of built BuddyPress?
26
- *
27
- * If the BP REST plugin is active, it overrides BuddyPress REST enpoints.
28
- * This allows us to carry on maintaining all the BP REST API endpoints from
29
- * the BP REST plugin on GitHub.
30
- *
31
- * @since 5.0.0
32
- *
33
- * @return bool Whether to use the REST Endpoints of built BuddyPress.
34
- */
35
- function bp_rest_in_buddypress() {
36
- $is_src = defined( 'BP_SOURCE_SUBDIRECTORY' ) && BP_SOURCE_SUBDIRECTORY === 'src';
37
-
38
- return ! $is_src && ! bp_rest_is_plugin_active();
39
- }
40
-
41
- /**
42
- * Check the availability of the BP REST API.
43
- *
44
- * @since 5.0.0
45
- *
46
- * @return boolean True if the BP REST API is available. False otherwise.
47
- */
48
- function bp_rest_api_is_available() {
49
-
50
- /**
51
- * Filter here to disable the BP REST API.
52
- *
53
- * The BP REST API requires at least WordPress 4.7.0
54
- *
55
- * @since 5.0.0
56
- *
57
- * @param boolean $value True if the BP REST API is available. False otherwise.
58
- */
59
- return apply_filters( 'bp_rest_api_is_available', bp_is_running_wp( '4.7.0' ) && bp_rest_in_buddypress() ) || bp_rest_is_plugin_active();
60
- }
61
-
62
- /**
63
- * Register the jQuery.ajax wrapper for BP REST API requests.
64
- *
65
- * @since 5.0.0
66
- */
67
- function bp_rest_api_register_request_script() {
68
- if ( ! bp_rest_api_is_available() ) {
69
- return;
70
- }
71
-
72
- $dependencies = array( 'jquery' );
73
-
74
- // The wrapper for WP REST API requests was introduced in WordPress 4.9.0.
75
- if ( wp_script_is( 'wp-api-request', 'registered' ) ) {
76
- $dependencies = array( 'wp-api-request' );
77
- }
78
-
79
- wp_register_script(
80
- 'bp-api-request',
81
- sprintf( '%1$sbp-core/js/bp-api-request%2$s.js', buddypress()->plugin_url, bp_core_get_minified_asset_suffix() ),
82
- $dependencies,
83
- bp_get_version(),
84
- true
85
- );
86
-
87
- wp_localize_script(
88
- 'bp-api-request',
89
- 'bpApiSettings',
90
- array(
91
- 'root' => esc_url_raw( get_rest_url() ),
92
- 'nonce' => wp_create_nonce( 'wp_rest' ),
93
- 'unexpectedError' => __( 'An unexpected error occured. Please try again.', 'buddypress' ),
94
- )
95
- );
96
- }
97
- add_action( 'bp_init', 'bp_rest_api_register_request_script' );
98
-
99
- /**
100
- * BuddyPress REST API namespace.
101
- *
102
- * @since 5.0.0
103
- *
104
- * @return string
105
- */
106
- function bp_rest_namespace() {
107
-
108
- /**
109
- * Filter API namespace.
110
- *
111
- * @since 5.0.0
112
- *
113
- * @param string $namespace BuddyPress core namespace.
114
- */
115
- return apply_filters( 'bp_rest_namespace', 'buddypress' );
116
- }
117
-
118
- /**
119
- * BuddyPress REST API version.
120
- *
121
- * @since 5.0.0
122
- *
123
- * @return string
124
- */
125
- function bp_rest_version() {
126
-
127
- /**
128
- * Filter API version.
129
- *
130
- * @since 5.0.0
131
- *
132
- * @param string $version BuddyPress core version.
133
- */
134
- return apply_filters( 'bp_rest_version', 'v1' );
135
- }
136
-
137
- /**
138
- * Get a REST API object URL from a component.
139
- *
140
- * @since 9.0.0
141
- *
142
- * @param integer $object_id Object ID.
143
- * @param string $object_path Path of the component endpoint.
144
- * @return string
145
- */
146
- function bp_rest_get_object_url( $object_id, $object_path ) {
147
- return rest_url(
148
- sprintf(
149
- '/%1$s/%2$s/%3$s/%4$d',
150
- bp_rest_namespace(),
151
- bp_rest_version(),
152
- $object_path,
153
- $object_id
154
- )
155
- );
156
- }
157
-
158
- /**
159
- * Set headers to let the Client Script be aware of the pagination.
160
- *
161
- * @since 5.0.0
162
- *
163
- * @param WP_REST_Response $response The response data.
164
- * @param integer $total The total number of found items.
165
- * @param integer $per_page The number of items per page of results.
166
- * @return WP_REST_Response $response The response data.
167
- */
168
- function bp_rest_response_add_total_headers( WP_REST_Response $response, $total = 0, $per_page = 0 ) {
169
- if ( ! $total || ! $per_page ) {
170
- return $response;
171
- }
172
-
173
- $total_items = (int) $total;
174
- $max_pages = ceil( $total_items / (int) $per_page );
175
-
176
- $response->header( 'X-WP-Total', $total_items );
177
- $response->header( 'X-WP-TotalPages', (int) $max_pages );
178
-
179
- return $response;
180
- }
181
-
182
- /**
183
- * Convert the input date to RFC3339 format.
184
- *
185
- * @since 5.0.0
186
- *
187
- * @param string $date_gmt Date GMT format.
188
- * @param string|null $date Optional. Date object.
189
- * @return string|null ISO8601/RFC3339 formatted datetime.
190
- */
191
- function bp_rest_prepare_date_response( $date_gmt, $date = null ) {
192
- if ( isset( $date ) ) {
193
- return mysql_to_rfc3339( $date );
194
- }
195
-
196
- if ( '0000-00-00 00:00:00' === $date_gmt ) {
197
- return null;
198
- }
199
-
200
- return mysql_to_rfc3339( $date_gmt );
201
- }
202
-
203
- /**
204
- * Clean up member_type input.
205
- *
206
- * @since 5.0.0
207
- *
208
- * @param string $value Comma-separated list of group types.
209
- * @return array|null
210
- */
211
- function bp_rest_sanitize_member_types( $value ) {
212
- if ( empty( $value ) ) {
213
- return $value;
214
- }
215
-
216
- $types = explode( ',', $value );
217
- $registered_types = bp_get_member_types();
218
- $registered_types[] = 'any';
219
- $valid_types = array_intersect( $types, $registered_types );
220
-
221
- return ( ! empty( $valid_types ) ) ? $valid_types : null;
222
- }
223
-
224
- /**
225
- * Validate member_type input.
226
- *
227
- * @since 5.0.0
228
- *
229
- * @param mixed $value Mixed value.
230
- * @return WP_Error|boolean
231
- */
232
- function bp_rest_validate_member_types( $value ) {
233
- if ( empty( $value ) ) {
234
- return true;
235
- }
236
-
237
- $types = explode( ',', $value );
238
- $registered_types = bp_get_member_types();
239
-
240
- // Add the special value.
241
- $registered_types[] = 'any';
242
- foreach ( $types as $type ) {
243
- if ( ! in_array( $type, $registered_types, true ) ) {
244
- return new WP_Error(
245
- 'bp_rest_invalid_member_type',
246
- sprintf(
247
- /* translators: %1$s and %2$s is replaced with the registered type(s) */
248
- __( 'The member type you provided, %1$s, is not one of %2$s.', 'buddypress' ),
249
- $type,
250
- implode( ', ', $registered_types )
251
- )
252
- );
253
- }
254
- }
255
- }
256
-
257
- /**
258
- * Clean up group_type input.
259
- *
260
- * @since 5.0.0
261
- *
262
- * @param string $value Comma-separated list of group types.
263
- * @return array|null
264
- */
265
- function bp_rest_sanitize_group_types( $value ) {
266
- if ( empty( $value ) ) {
267
- return null;
268
- }
269
-
270
- $types = explode( ',', $value );
271
- $valid_types = array_intersect( $types, bp_groups_get_group_types() );
272
-
273
- return empty( $valid_types ) ? null : $valid_types;
274
- }
275
-
276
- /**
277
- * Validate group_type input.
278
- *
279
- * @since 5.0.0
280
- *
281
- * @param mixed $value Mixed value.
282
- * @return WP_Error|bool
283
- */
284
- function bp_rest_validate_group_types( $value ) {
285
- if ( empty( $value ) ) {
286
- return true;
287
- }
288
-
289
- $types = explode( ',', $value );
290
- $registered_types = bp_groups_get_group_types();
291
- foreach ( $types as $type ) {
292
- if ( ! in_array( $type, $registered_types, true ) ) {
293
- return new WP_Error(
294
- 'bp_rest_invalid_group_type',
295
- sprintf(
296
- /* translators: %1$s and %2$s is replaced with the registered types */
297
- __( 'The group type you provided, %1$s, is not one of %2$s.', 'buddypress' ),
298
- $type,
299
- implode( ', ', $registered_types )
300
- )
301
- );
302
- }
303
- }
304
- }
305
-
306
- /**
307
- * Clean up an array, comma- or space-separated list of strings.
308
- *
309
- * @since 5.0.0
310
- *
311
- * @param array|string $list List of strings.
312
- * @return array Sanitized array of strings.
313
- */
314
- function bp_rest_sanitize_string_list( $list ) {
315
- if ( ! is_array( $list ) ) {
316
- $list = preg_split( '/[\s,]+/', $list );
317
- }
318
-
319
- return array_unique( array_map( 'sanitize_text_field', $list ) );
320
- }
321
-
322
- /**
323
- * Get the user object, if the ID is valid.
324
- *
325
- * @since 5.0.0
326
- *
327
- * @param int $user_id Supplied user ID.
328
- * @return WP_User|boolean
329
- */
330
- function bp_rest_get_user( $user_id ) {
331
- if ( (int) $user_id <= 0 ) {
332
- return false;
333
- }
334
-
335
- $user = get_userdata( (int) $user_id );
336
- if ( empty( $user ) || ! $user->exists() ) {
337
- return false;
338
- }
339
-
340
- return $user;
341
- }
342
-
343
- /**
344
- * Registers a new field on an existing BuddyPress object.
345
- *
346
- * @since 5.0.0
347
- *
348
- * @param string $component_id The name of the *active* component (eg: `activity`, `groups`, `xprofile`).
349
- * Required.
350
- * @param string $attribute The attribute name. Required.
351
- * @param array $args {
352
- * Optional. An array of arguments used to handle the registered field.
353
- * @see `register_rest_field()` for a full description.
354
- * }
355
- * @param string $object_type The xProfile object type to get. This parameter is only required for
356
- * the Extended Profiles component. Not used for all other components.
357
- * Possible values are `data`, `field` or `group`.
358
- * @return bool True if the field has been registered successfully. False otherwise.
359
- */
360
- function bp_rest_register_field( $component_id, $attribute, $args = array(), $object_type = '' ) {
361
- $registered_fields = false;
362
-
363
- if ( ! $component_id || ! bp_is_active( $component_id ) || ! $attribute ) {
364
- return $registered_fields;
365
- }
366
-
367
- // Use the `bp_` prefix as we're using a WordPress global used for Post Types.
368
- $field_name = 'bp_' . $component_id;
369
-
370
- // Use the meta type as a suffix for the field name.
371
- if ( 'xprofile' === $component_id ) {
372
- if ( ! in_array( $object_type, array( 'data', 'field', 'group' ), true ) ) {
373
- return $registered_fields;
374
- }
375
-
376
- $field_name .= '_' . $object_type;
377
- }
378
-
379
- $args = bp_parse_args(
380
- $args,
381
- array(
382
- 'get_callback' => null,
383
- 'update_callback' => null,
384
- 'schema' => null,
385
- ),
386
- 'rest_register_field'
387
- );
388
-
389
- // Register the field.
390
- register_rest_field( $field_name, $attribute, $args );
391
-
392
- if ( isset( $GLOBALS['wp_rest_additional_fields'][ $field_name ] ) ) {
393
- $registered_fields = $GLOBALS['wp_rest_additional_fields'][ $field_name ];
394
- }
395
-
396
- // Check it has been registered.
397
- return isset( $registered_fields[ $attribute ] );
398
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/bp-core-taxonomy.php CHANGED
@@ -14,58 +14,33 @@
14
  // Exit if accessed directly.
15
  defined( 'ABSPATH' ) || exit;
16
 
17
- /**
18
- * Returns default BuddyPress taxonomies.
19
- *
20
- * @since 7.0.0
21
- *
22
- * @return array The BuddyPress default taxonomies.
23
- */
24
- function bp_get_default_taxonomies() {
25
- $taxonomies = array(
26
- // Member Type.
27
- bp_get_member_type_tax_name() => array(
28
- 'object' => 'user',
29
- 'component' => 'members',
30
- 'args' => bp_get_member_type_tax_args(),
31
- ),
32
- // Email type.
33
- bp_get_email_tax_type() => array(
34
- 'object' => bp_get_email_post_type(),
35
- 'component' => 'core',
36
- 'args' => bp_get_email_tax_type_args(),
37
- ),
38
- );
39
-
40
- /**
41
- * This filter should only be used by built-in BuddyPress Components.
42
- *
43
- * @since 7.0.0
44
- *
45
- * @param array $taxonomies The taxonomy arguments used for WordPress registration.
46
- */
47
- return apply_filters( 'bp_get_default_taxonomies', $taxonomies );
48
- }
49
-
50
  /**
51
  * Register our default taxonomies.
52
  *
53
  * @since 2.2.0
54
  */
55
  function bp_register_default_taxonomies() {
56
- $taxonomies = bp_get_default_taxonomies();
57
-
58
- foreach ( $taxonomies as $taxonomy_name => $taxonomy_params ) {
59
- if ( ! isset( $taxonomy_params['object'] ) || ! isset( $taxonomy_params['args'] ) ) {
60
- continue;
61
- }
62
-
63
- register_taxonomy(
64
- $taxonomy_name,
65
- $taxonomy_params['object'],
66
- $taxonomy_params['args']
67
- );
68
- }
 
 
 
 
 
 
 
 
69
  }
70
  add_action( 'bp_register_taxonomies', 'bp_register_default_taxonomies' );
71
 
@@ -302,201 +277,3 @@ function bp_get_term_by( $field, $value, $taxonomy = '', $output = OBJECT, $filt
302
 
303
  return $term;
304
  }
305
-
306
- /**
307
- * Add a new taxonomy term to the database.
308
- *
309
- * @since 7.0.0
310
- *
311
- * @param string $term The BP term name to add.
312
- * @param string $taxonomy The BP taxonomy to which to add the BP term.
313
- * @param array $args {
314
- * Optional. Array of arguments for inserting a BP term.
315
- * @type string $description The term description. Default empty string.
316
- * @type string $slug The term slug to use. Default empty string.
317
- * @type array $metas The term metas to add. Default empty array.
318
- * }
319
- * @return array|WP_Error An array containing the `term_id` and `term_taxonomy_id`,
320
- * WP_Error otherwise.
321
- */
322
- function bp_insert_term( $term, $taxonomy = '', $args = array() ) {
323
- if ( ! taxonomy_exists( $taxonomy ) ) {
324
- return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.', 'buddypress' ) );
325
- }
326
-
327
- $site_id = bp_get_taxonomy_term_site_id( $taxonomy );
328
-
329
- $switched = false;
330
- if ( $site_id !== get_current_blog_id() ) {
331
- switch_to_blog( $site_id );
332
- bp_register_taxonomies();
333
- $switched = true;
334
- }
335
-
336
- $term_metas = array();
337
- if ( isset( $args['metas'] ) ) {
338
- $term_metas = (array) $args['metas'];
339
- unset( $args['metas'] );
340
- }
341
-
342
- /**
343
- * Fires before a BP Term is added to the database.
344
- *
345
- * @since 7.0.0
346
- *
347
- * @param string $term The BP term name to add.
348
- * @param string $taxonomy The BP taxonomy to which to add the term.
349
- * @param array $args Array of arguments for inserting a BP term.
350
- */
351
- do_action( 'bp_before_insert_term', $term, $taxonomy, $args );
352
-
353
- $tt_id = wp_insert_term( $term, $taxonomy, $args );
354
-
355
- if ( is_wp_error( $tt_id ) ) {
356
- return $tt_id;
357
- }
358
-
359
- $term_id = reset( $tt_id );
360
-
361
- if ( $term_metas ) {
362
- bp_update_type_metadata( $term_id, $taxonomy, $term_metas );
363
- }
364
-
365
- if ( $switched ) {
366
- restore_current_blog();
367
- }
368
-
369
- /**
370
- * Fires when taxonomy terms have been set on BuddyPress objects.
371
- *
372
- * @since 7.0.0
373
- *
374
- * @param array $tt_ids An array containing the `term_id` and `term_taxonomy_id`.
375
- * @param string $taxonomy Taxonomy name.
376
- * @param array $term_metas The term metadata.
377
- */
378
- do_action( 'bp_insert_term', $tt_id, $taxonomy, $term_metas );
379
-
380
- return $tt_id;
381
- }
382
-
383
- /**
384
- * Get taxonomy BP Terms from the database.
385
- *
386
- * @since 7.0.0
387
- *
388
- * @param array $args {
389
- * Array of arguments to query BP Terms.
390
- * @see `get_terms()` for full description of arguments in case of a member type.
391
- * }
392
- * @return array The list of terms matching arguments.
393
- */
394
- function bp_get_terms( $args = array() ) {
395
- $args = bp_parse_args(
396
- $args,
397
- array(
398
- 'taxonomy' => '',
399
- 'number' => '',
400
- 'hide_empty' => false,
401
- ),
402
- 'get_terms'
403
- );
404
-
405
- if ( ! $args['taxonomy'] ) {
406
- return array();
407
- }
408
-
409
- $site_id = bp_get_taxonomy_term_site_id( $args['taxonomy'] );
410
-
411
- $switched = false;
412
- if ( $site_id !== get_current_blog_id() ) {
413
- switch_to_blog( $site_id );
414
- bp_register_taxonomies();
415
- $switched = true;
416
- }
417
-
418
- $terms = get_terms( $args );
419
-
420
- if ( $switched ) {
421
- restore_current_blog();
422
- }
423
-
424
- /**
425
- * Filter here to modify the BP Terms found into the database.
426
- *
427
- * @since 7.0.0
428
- *
429
- * @param array $terms The list of terms matching arguments.
430
- * @param array $args Array of arguments used to query BP Terms.
431
- */
432
- return apply_filters(
433
- 'bp_get_terms',
434
- $terms,
435
- $args
436
- );
437
- }
438
-
439
- /**
440
- * Deletes a BP Term.
441
- *
442
- * @since 7.0.0
443
- *
444
- * @param int $term_id The BP Term ID. Required.
445
- * @param string $taxonomy The BP Taxonomy Name. Required.
446
- * @return bool|WP_Error True on success, WP_Error on failure.
447
- */
448
- function bp_delete_term( $term_id = 0, $taxonomy = '' ) {
449
- if ( ! $term_id || ! $taxonomy ) {
450
- return new WP_Error( 'missing_arguments', __( 'Sorry, the term ID and the taxonomy are required arguments.', 'buddypress' ) );
451
- }
452
-
453
- $site_id = bp_get_taxonomy_term_site_id( $taxonomy );
454
-
455
- $switched = false;
456
- if ( $site_id !== get_current_blog_id() ) {
457
- switch_to_blog( $site_id );
458
- bp_register_taxonomies();
459
- $switched = true;
460
- }
461
-
462
- /**
463
- * Fires before a BP Term is deleted from the database.
464
- *
465
- * @since 7.0.0
466
- *
467
- * @param int $term_id The BP Term ID.
468
- * @param string $taxonomy The BP Taxonomy Name.
469
- */
470
- do_action( 'bp_before_delete_term', $term_id, $taxonomy );
471
-
472
- $deleted = wp_delete_term( $term_id, $taxonomy );
473
-
474
- if ( $switched ) {
475
- restore_current_blog();
476
- }
477
-
478
- if ( is_wp_error( $deleted ) ) {
479
- return $deleted;
480
- }
481
-
482
- if ( false === $deleted ) {
483
- return new WP_Error( 'inexistant_term', __( 'Sorry, the term does not exist.', 'buddypress' ) );
484
- }
485
-
486
- if ( 0 === $deleted ) {
487
- return new WP_Error( 'default_term', __( 'Sorry, the default term cannot be deleted.', 'buddypress' ) );
488
- }
489
-
490
- /**
491
- * Fires once a BP Term has been deleted from the database.
492
- *
493
- * @since 7.0.0
494
- *
495
- * @param boolean $deleted True.
496
- * @param int $term_id The deleted BP Term ID.
497
- * @param string $taxonomy The BP Taxonomy Name of the deleted BP Term ID.
498
- */
499
- do_action( 'bp_delete_term', $deleted, $term_id, $taxonomy );
500
-
501
- return $deleted;
502
- }
14
  // Exit if accessed directly.
15
  defined( 'ABSPATH' ) || exit;
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  /**
18
  * Register our default taxonomies.
19
  *
20
  * @since 2.2.0
21
  */
22
  function bp_register_default_taxonomies() {
23
+ // Member Type.
24
+ register_taxonomy( bp_get_member_type_tax_name(), 'user', array(
25
+ 'public' => false,
26
+ ) );
27
+
28
+ // Email type.
29
+ register_taxonomy(
30
+ bp_get_email_tax_type(),
31
+ bp_get_email_post_type(),
32
+ apply_filters( 'bp_register_email_tax_type', array(
33
+ 'description' => _x( 'BuddyPress email types', 'email type taxonomy description', 'buddypress' ),
34
+ 'labels' => bp_get_email_tax_type_labels(),
35
+ 'meta_box_cb' => 'bp_email_tax_type_metabox',
36
+ 'public' => false,
37
+ 'query_var' => false,
38
+ 'rewrite' => false,
39
+ 'show_in_menu' => false,
40
+ 'show_tagcloud' => false,
41
+ 'show_ui' => bp_is_root_blog() && bp_current_user_can( 'bp_moderate' ),
42
+ ) )
43
+ );
44
  }
45
  add_action( 'bp_register_taxonomies', 'bp_register_default_taxonomies' );
46
 
277
 
278
  return $term;
279
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/bp-core-template-loader.php CHANGED
@@ -18,16 +18,14 @@ defined( 'ABSPATH' ) || exit;
18
  * Get a BuddyPress template part for display in a theme.
19
  *
20
  * @since 1.7.0
21
- * @since 7.0.0 Added $args parameter.
22
  *
23
  * @param string $slug Template part slug. Used to generate filenames,
24
  * eg 'friends' for 'friends.php'.
25
  * @param string|null $name Optional. Template part name. Used to generate
26
  * secondary filenames, eg 'personal' for 'activity-personal.php'.
27
- * @param array $args Optional. Extra args to pass to locate_template().
28
  * @return false|string Path to located template. See {@link bp_locate_template()}.
29
  */
30
- function bp_get_template_part( $slug, $name = null, $args = array() ) {
31
 
32
  /**
33
  * Fires at the start of bp_get_template_part().
@@ -35,13 +33,11 @@ function bp_get_template_part( $slug, $name = null, $args = array() ) {
35
  * This is a variable hook that is dependent on the slug passed in.
36
  *
37
  * @since 1.7.0
38
- * @since 7.0.0 Added $args parameter.
39
  *
40
  * @param string $slug Template part slug requested.
41
  * @param string $name Template part name requested.
42
- * @param array $args Extra args to pass to locate_template().
43
  */
44
- do_action( 'get_template_part_' . $slug, $slug, $name, $args );
45
 
46
  // Setup possible parts.
47
  $templates = array();
@@ -54,17 +50,15 @@ function bp_get_template_part( $slug, $name = null, $args = array() ) {
54
  * Filters the template parts to be loaded.
55
  *
56
  * @since 1.7.0
57
- * @since 7.0.0 Added $args parameter.
58
  *
59
  * @param array $templates Array of templates located.
60
  * @param string $slug Template part slug requested.
61
  * @param string $name Template part name requested.
62
- * @param array $args Extra args to pass to locate_template().
63
  */
64
- $templates = apply_filters( 'bp_get_template_part', $templates, $slug, $name, $args );
65
 
66
  // Return the part that is found.
67
- return bp_locate_template( $templates, true, false, $args );
68
  }
69
 
70
  /**
@@ -74,74 +68,15 @@ function bp_get_template_part( $slug, $name = null, $args = array() ) {
74
  * prepended to the slug.
75
  *
76
  * @since 2.6.0
77
- * @since 7.0.0 Added $args parameter.
78
  *
79
  * @see bp_get_template_part() for full documentation.
80
  *
81
  * @param string $slug Template slug.
82
  * @param string|null $name Template name.
83
- * @param array $args Optional. Extra args to pass to locate_template().
84
  * @return false|string
85
  */
86
- function bp_get_asset_template_part( $slug, $name = null, $args = array() ) {
87
- return bp_get_template_part( "assets/{$slug}", $name, $args );
88
- }
89
-
90
- /**
91
- * Get a dynamic template part.
92
- *
93
- * @since 9.0.0
94
- *
95
- * @param string $template The Template Pack's relative path to the templata.
96
- * Optional.
97
- * @param string $type Whether to use the template for JavaScript or PHP.
98
- * Optional. Defaults to `js`.
99
- * @param array $tokens The data to use to customize the template. Optional.
100
- * @param array $allowed_tags The allowed tags to use. Optional.
101
- * @return string HTML/JS output.
102
- */
103
- function bp_get_dynamic_template_part( $template = '', $type = 'js', $tokens = array(), $allowed_tags = array() ) {
104
- $template_string = '';
105
-
106
- if ( ! $template ) {
107
- return '';
108
- }
109
-
110
- // Use the BP Theme Compat API to allow template override.
111
- $template_path = bp_locate_template( $template );
112
- if ( $template_path ) {
113
- $template_string = file_get_contents( $template_path );
114
- }
115
-
116
- if ( ! $template_string ) {
117
- return '';
118
- }
119
-
120
- if ( ! $allowed_tags ) {
121
- $allowed_tags = array(
122
- 'li' => array( 'class' => true ),
123
- 'div' => array( 'class' => true ),
124
- 'span' => array( 'class' => true ),
125
- 'a' => array(
126
- 'href' => true,
127
- 'class' => true,
128
- 'data-bp-tooltip' => true,
129
- ),
130
- 'img' => array(
131
- 'src' => true,
132
- 'class' => true,
133
- 'loading' => true,
134
- ),
135
- );
136
- }
137
-
138
- if ( 'js' !== $type ) {
139
- $template_string = wp_kses( $template_string, $allowed_tags );
140
-
141
- return bp_core_replace_tokens_in_text( $template_string, $tokens );
142
- }
143
-
144
- return $template_string;
145
  }
146
 
147
  /**
@@ -152,19 +87,17 @@ function bp_get_dynamic_template_part( $template = '', $type = 'js', $tokens = a
152
  * not found in either of those, it looks in the theme-compat folder last.
153
  *
154
  * @since 1.7.0
155
- * @since 7.0.0 Added $args parameter.
156
  *
157
  * @param string|array $template_names Template file(s) to search for, in order.
158
  * @param bool $load Optional. If true, the template file will be loaded when
159
  * found. If false, the path will be returned. Default: false.
160
  * @param bool $require_once Optional. Whether to require_once or require. Has
161
  * no effect if $load is false. Default: true.
162
- * @param array $args Optional. Extra args to pass to locate_template().
163
  * @return string The template filename if one is located.
164
  */
165
- function bp_locate_template( $template_names, $load = false, $require_once = true, $args = array() ) {
166
 
167
- // Bail when there are no templates to locate.
168
  if ( empty( $template_names ) ) {
169
  return false;
170
  }
@@ -202,12 +135,12 @@ function bp_locate_template( $template_names, $load = false, $require_once = tru
202
 
203
  /**
204
  * This action exists only to follow the standard BuddyPress coding convention,
205
- * and should not be used to short-circuit any part of the template locater.
206
  *
207
  * If you want to override a specific template part, please either filter
208
  * 'bp_get_template_part' or add a new location to the template stack.
209
  */
210
- do_action( 'bp_locate_template', $located, $template_name, $template_names, $template_locations, $load, $require_once, $args );
211
 
212
  /**
213
  * Filter here to allow/disallow template loading.
@@ -219,7 +152,7 @@ function bp_locate_template( $template_names, $load = false, $require_once = tru
219
  $load_template = (bool) apply_filters( 'bp_locate_template_and_load', true );
220
 
221
  if ( $load_template && $load && ! empty( $located ) ) {
222
- load_template( $located, $require_once, $args );
223
  }
224
 
225
  return $located;
@@ -387,24 +320,22 @@ function bp_get_template_stack() {
387
  * Put a template part into an output buffer, and return it.
388
  *
389
  * @since 1.7.0
390
- * @since 7.0.0 Added $args parameter.
391
  *
392
- * @see bp_get_template_part() for a description of $slug, $name and $args params.
393
  *
394
  * @param string $slug See {@link bp_get_template_part()}.
395
  * @param string|null $name See {@link bp_get_template_part()}.
396
  * @param bool $echo If true, template content will be echoed. If false,
397
  * returned. Default: true.
398
- * @param array $args See {@link bp_get_template_part()}.
399
  * @return string|null If $echo, returns the template content.
400
  */
401
- function bp_buffer_template_part( $slug, $name = null, $echo = true, $args = array() ) {
402
  ob_start();
403
 
404
  // Remove 'bp_replace_the_content' filter to prevent infinite loops.
405
  remove_filter( 'the_content', 'bp_replace_the_content' );
406
 
407
- bp_get_template_part( $slug, $name, $args );
408
 
409
  // Remove 'bp_replace_the_content' filter to prevent infinite loops.
410
  add_filter( 'the_content', 'bp_replace_the_content' );
@@ -631,7 +562,7 @@ function bp_set_template_included( $template = false ) {
631
  * @return bool True if yes, false if no.
632
  */
633
  function bp_is_template_included() {
634
- return isset( buddypress()->theme_compat->found_template ) && buddypress()->theme_compat->found_template;
635
  }
636
 
637
  /**
18
  * Get a BuddyPress template part for display in a theme.
19
  *
20
  * @since 1.7.0
 
21
  *
22
  * @param string $slug Template part slug. Used to generate filenames,
23
  * eg 'friends' for 'friends.php'.
24
  * @param string|null $name Optional. Template part name. Used to generate
25
  * secondary filenames, eg 'personal' for 'activity-personal.php'.
 
26
  * @return false|string Path to located template. See {@link bp_locate_template()}.
27
  */
28
+ function bp_get_template_part( $slug, $name = null ) {
29
 
30
  /**
31
  * Fires at the start of bp_get_template_part().
33
  * This is a variable hook that is dependent on the slug passed in.
34
  *
35
  * @since 1.7.0
 
36
  *
37
  * @param string $slug Template part slug requested.
38
  * @param string $name Template part name requested.
 
39
  */
40
+ do_action( 'get_template_part_' . $slug, $slug, $name );
41
 
42
  // Setup possible parts.
43
  $templates = array();
50
  * Filters the template parts to be loaded.
51
  *
52
  * @since 1.7.0
 
53
  *
54
  * @param array $templates Array of templates located.
55
  * @param string $slug Template part slug requested.
56
  * @param string $name Template part name requested.
 
57
  */
58
+ $templates = apply_filters( 'bp_get_template_part', $templates, $slug, $name );
59
 
60
  // Return the part that is found.
61
+ return bp_locate_template( $templates, true, false );
62
  }
63
 
64
  /**
68
  * prepended to the slug.
69
  *
70
  * @since 2.6.0
 
71
  *
72
  * @see bp_get_template_part() for full documentation.
73
  *
74
  * @param string $slug Template slug.
75
  * @param string|null $name Template name.
 
76
  * @return false|string
77
  */
78
+ function bp_get_asset_template_part( $slug, $name = null ) {
79
+ return bp_get_template_part( "assets/{$slug}", $name );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
 
82
  /**
87
  * not found in either of those, it looks in the theme-compat folder last.
88
  *
89
  * @since 1.7.0
 
90
  *
91
  * @param string|array $template_names Template file(s) to search for, in order.
92
  * @param bool $load Optional. If true, the template file will be loaded when
93
  * found. If false, the path will be returned. Default: false.
94
  * @param bool $require_once Optional. Whether to require_once or require. Has
95
  * no effect if $load is false. Default: true.
 
96
  * @return string The template filename if one is located.
97
  */
98
+ function bp_locate_template( $template_names, $load = false, $require_once = true ) {
99
 
100
+ // Bail when there are no templates to locate
101
  if ( empty( $template_names ) ) {
102
  return false;
103
  }
135
 
136
  /**
137
  * This action exists only to follow the standard BuddyPress coding convention,
138
+ * and should not be used to short-circuit any part of the template locator.
139
  *
140
  * If you want to override a specific template part, please either filter
141
  * 'bp_get_template_part' or add a new location to the template stack.
142
  */
143
+ do_action( 'bp_locate_template', $located, $template_name, $template_names, $template_locations, $load, $require_once );
144
 
145
  /**
146
  * Filter here to allow/disallow template loading.
152
  $load_template = (bool) apply_filters( 'bp_locate_template_and_load', true );
153
 
154
  if ( $load_template && $load && ! empty( $located ) ) {
155
+ load_template( $located, $require_once );
156
  }
157
 
158
  return $located;
320
  * Put a template part into an output buffer, and return it.
321
  *
322
  * @since 1.7.0
 
323
  *
324
+ * @see bp_get_template_part() for a description of $slug and $name params.
325
  *
326
  * @param string $slug See {@link bp_get_template_part()}.
327
  * @param string|null $name See {@link bp_get_template_part()}.
328
  * @param bool $echo If true, template content will be echoed. If false,
329
  * returned. Default: true.
 
330
  * @return string|null If $echo, returns the template content.
331
  */
332
+ function bp_buffer_template_part( $slug, $name = null, $echo = true ) {
333
  ob_start();
334
 
335
  // Remove 'bp_replace_the_content' filter to prevent infinite loops.
336
  remove_filter( 'the_content', 'bp_replace_the_content' );
337
 
338
+ bp_get_template_part( $slug, $name );
339
 
340
  // Remove 'bp_replace_the_content' filter to prevent infinite loops.
341
  add_filter( 'the_content', 'bp_replace_the_content' );
562
  * @return bool True if yes, false if no.
563
  */
564
  function bp_is_template_included() {
565
+ return ! empty( buddypress()->theme_compat->found_template );
566
  }
567
 
568
  /**
bp-core/bp-core-template.php CHANGED
@@ -138,12 +138,11 @@ function bp_get_directory_title( $component = '' ) {
138
  $title = '';
139
 
140
  // Use the string provided by the component.
141
- if ( isset( buddypress()->{$component}->directory_title ) && buddypress()->{$component}->directory_title ) {
142
  $title = buddypress()->{$component}->directory_title;
143
 
144
  // If none is found, concatenate.
145
  } elseif ( isset( buddypress()->{$component}->name ) ) {
146
- /* translators: %s: Name of the BuddyPress component */
147
  $title = sprintf( __( '%s Directory', 'buddypress' ), buddypress()->{$component}->name );
148
  }
149
 
@@ -153,7 +152,7 @@ function bp_get_directory_title( $component = '' ) {
153
  * @since 2.0.0
154
  *
155
  * @param string $title Text to be used in <title> tag.
156
- * @param string $component Current component being displayed.
157
  */
158
  return apply_filters( 'bp_get_directory_title', $title, $component );
159
  }
@@ -193,15 +192,15 @@ function bp_get_options_avatar() {
193
  function bp_comment_author_avatar() {
194
  global $comment;
195
 
196
- echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array(
197
- 'item_id' => $comment->user_id,
198
- 'type' => 'thumb',
199
- 'alt' => sprintf(
200
- /* translators: %s: member name */
201
- __( 'Profile photo of %s', 'buddypress' ),
202
- bp_core_get_user_displayname( $comment->user_id )
203
- ),
204
- ) ) );
205
  }
206
 
207
  /**
@@ -212,15 +211,15 @@ function bp_comment_author_avatar() {
212
  function bp_post_author_avatar() {
213
  global $post;
214
 
215
- echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array(
216
- 'item_id' => $post->post_author,
217
- 'type' => 'thumb',
218
- 'alt' => sprintf(
219
- /* translators: %s: member name */
220
- __( 'Profile photo of %s', 'buddypress' ),
221
- bp_core_get_user_displayname( $post->post_author )
222
- ),
223
- ) ) );
224
  }
225
 
226
  /**
@@ -361,7 +360,7 @@ function bp_site_name() {
361
  * Format a date based on a UNIX timestamp.
362
  *
363
  * This function can be used to turn a UNIX timestamp into a properly formatted
364
- * (and possibly localized) string, useful for outputting the date & time an
365
  * action took place.
366
  *
367
  * Not to be confused with `bp_core_time_since()`, this function is best used
@@ -551,6 +550,10 @@ function bp_search_form_type_select() {
551
  $options['blogs'] = _x( 'Blogs', 'search form', 'buddypress' );
552
  }
553
 
 
 
 
 
554
  $options['posts'] = _x( 'Posts', 'search form', 'buddypress' );
555
 
556
  // Eventually this won't be needed and a page will be built to integrate all search results.
@@ -793,14 +796,7 @@ function bp_form_field_attributes( $name = '', $attributes = array() ) {
793
  $attributes = (array) apply_filters( 'bp_get_form_field_attributes', $attributes, $name );
794
 
795
  foreach( $attributes as $attr => $value ) {
796
- // Numeric keyed array.
797
- if (is_numeric( $attr ) ) {
798
- $retval .= sprintf( ' %s', esc_attr( $value ) );
799
-
800
- // Associative keyed array.
801
- } else {
802
- $retval .= sprintf( ' %s="%s"', sanitize_key( $attr ), esc_attr( $value ) );
803
- }
804
  }
805
 
806
  return $retval;
@@ -988,7 +984,7 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
988
  *
989
  * @since 1.1.0
990
  *
991
- * @param string $text Generated excerpt.
992
  * @param string $original_text Original text provided.
993
  * @param int $length Length of returned string, including ellipsis.
994
  * @param array $options Array of HTML attributes and options.
@@ -1158,9 +1154,10 @@ function bp_blog_signup_allowed() {
1158
  * otherwise false.
1159
  */
1160
  function bp_account_was_activated() {
1161
- $bp = buddypress();
1162
-
1163
- $activation_complete = ! empty( $bp->activation_complete ) || ( bp_is_current_component( 'activate' ) && ! empty( $_GET['activated'] ) );
 
1164
 
1165
  return $activation_complete;
1166
  }
@@ -1228,7 +1225,7 @@ function bp_get_email_subject( $args = array() ) {
1228
  *
1229
  * @since 1.7.0
1230
  *
1231
- * @param string $subject Client friendly version of the root blog name.
1232
  * @param array $r Array of arguments for the email subject.
1233
  */
1234
  return apply_filters( 'bp_get_email_subject', $subject, $r );
@@ -1257,7 +1254,7 @@ function bp_ajax_querystring( $object = false ) {
1257
  }
1258
 
1259
  /**
1260
- * Filters the template parameters to be used in the query string.
1261
  *
1262
  * Allows templates to pass parameters into the template loops via AJAX.
1263
  *
@@ -2082,7 +2079,7 @@ function bp_is_active( $component = '', $feature = '' ) {
2082
  }
2083
 
2084
  // Is component in either the active or required components arrays.
2085
- if ( isset( buddypress()->active_components[ $component ] ) || in_array( $component, buddypress()->required_components, true ) ) {
2086
  $retval = true;
2087
 
2088
  // Is feature active?
@@ -2090,24 +2087,9 @@ function bp_is_active( $component = '', $feature = '' ) {
2090
  // The xProfile component is specific.
2091
  if ( 'xprofile' === $component ) {
2092
  $component = 'profile';
2093
-
2094
- // The Cover Image feature has been moved to the Members component in 6.0.0.
2095
- if ( 'cover_image' === $feature && 'profile' === $component ) {
2096
- _doing_it_wrong( 'bp_is_active( \'profile\', \'cover_image\' )', esc_html__( 'The cover image is a Members component feature, please use bp_is_active( \'members\', \'cover_image\' ) instead.', 'buddypress' ), '6.0.0' );
2097
- $members_component = buddypress()->members;
2098
-
2099
- if ( ! isset( $members_component->features ) || false === in_array( $feature, $members_component->features, true ) ) {
2100
- $retval = false;
2101
- }
2102
-
2103
- /** This filter is documented in wp-includes/deprecated.php */
2104
- return apply_filters_deprecated( 'bp_is_profile_cover_image_active', array( $retval ), '6.0.0', 'bp_is_members_cover_image_active' );
2105
- }
2106
  }
2107
 
2108
- $component_features = isset( buddypress()->{$component}->features ) ? buddypress()->{$component}->features : array();
2109
-
2110
- if ( empty( $component_features ) || false === in_array( $feature, $component_features, true ) ) {
2111
  $retval = false;
2112
  }
2113
 
@@ -2217,7 +2199,6 @@ function bp_is_groups_component() {
2217
  * Check whether the current page is part of the Forums component.
2218
  *
2219
  * @since 1.5.0
2220
- * @since 3.0.0 Required for bbPress 2 integration.
2221
  *
2222
  * @return bool True if the current page is part of the Forums component.
2223
  */
@@ -2247,17 +2228,6 @@ function bp_is_settings_component() {
2247
  return (bool) bp_is_current_component( 'settings' );
2248
  }
2249
 
2250
- /**
2251
- * Check whether the current page is an Invitations screen.
2252
- *
2253
- * @since 8.0.0
2254
- *
2255
- * @return bool True if the current page is an Invitations screen.
2256
- */
2257
- function bp_is_members_invitations_screen() {
2258
- return (bool) bp_is_current_component( bp_get_members_invitations_slug() );
2259
- }
2260
-
2261
  /**
2262
  * Is the current component an active core component?
2263
  *
@@ -2502,6 +2472,54 @@ function bp_is_user_change_cover_image() {
2502
  return (bool) ( bp_is_profile_component() && bp_is_current_action( 'change-cover-image' ) );
2503
  }
2504
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2505
  /**
2506
  * Is the current page part of a user's Groups page?
2507
  *
@@ -2658,45 +2676,6 @@ function bp_is_user_settings_profile() {
2658
  return (bool) ( bp_is_user_settings() && bp_is_current_action( 'profile' ) );
2659
  }
2660
 
2661
- /**
2662
- * Is the current page a user's community invitations page?
2663
- *
2664
- * Eg http://example.com/members/cassie/invitations/ (or a subpage thereof).
2665
- *
2666
- * @since 8.0.0
2667
- *
2668
- * @return bool True if the current page is a user's community invitations page.
2669
- */
2670
- function bp_is_user_members_invitations() {
2671
- return (bool) ( bp_is_user() && bp_is_members_invitations_screen() );
2672
- }
2673
-
2674
- /**
2675
- * Is the current page a user's List Invites page?
2676
- *
2677
- * Eg http://example.com/members/cassie/invitations/list-invites/.
2678
- *
2679
- * @since 8.0.0
2680
- *
2681
- * @return bool True if the current page is a user's List Invites page.
2682
- */
2683
- function bp_is_user_members_invitations_list() {
2684
- return (bool) ( bp_is_user_members_invitations() && bp_is_current_action( 'list-invites' ) );
2685
- }
2686
-
2687
- /**
2688
- * Is the current page a user's Send Invites page?
2689
- *
2690
- * Eg http://example.com/members/cassie/invitations/send-invites/.
2691
- *
2692
- * @since 8.0.0
2693
- *
2694
- * @return bool True if the current page is a user's Send Invites page.
2695
- */
2696
- function bp_is_user_members_invitations_send_screen() {
2697
- return (bool) ( bp_is_user_members_invitations() && bp_is_current_action( 'send-invites' ) );
2698
- }
2699
-
2700
  /** Groups ********************************************************************/
2701
 
2702
  /**
@@ -2775,6 +2754,32 @@ function bp_is_group_admin_page() {
2775
  return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'admin' ) );
2776
  }
2777
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2778
  /**
2779
  * Is the current page a group's activity page?
2780
  *
@@ -2799,8 +2804,9 @@ function bp_is_group_activity() {
2799
  /**
2800
  * Is the current page a group forum topic?
2801
  *
 
 
2802
  * @since 1.1.0
2803
- * @since 3.0.0 Required for bbPress 2 integration.
2804
  *
2805
  * @return bool True if the current page is part of a group forum topic.
2806
  */
@@ -2811,8 +2817,9 @@ function bp_is_group_forum_topic() {
2811
  /**
2812
  * Is the current page a group forum topic edit page?
2813
  *
 
 
2814
  * @since 1.2.0
2815
- * @since 3.0.0 Required for bbPress 2 integration.
2816
  *
2817
  * @return bool True if the current page is part of a group forum topic edit page.
2818
  */
@@ -3088,7 +3095,7 @@ function bp_get_title_parts( $seplocation = 'right' ) {
3088
  return $bp_title_parts;
3089
  }
3090
 
3091
- // Now we can build the BP Title Parts.
3092
  // Is there a displayed user, and do they have a name?
3093
  $displayed_user_name = bp_get_displayed_user_fullname();
3094
 
@@ -3102,7 +3109,7 @@ function bp_get_title_parts( $seplocation = 'right' ) {
3102
  $component_subnav_name = '';
3103
 
3104
  if ( ! empty( $bp->members->nav ) ) {
3105
- $primary_nav_item = (array) $bp->members->nav->get_primary( array( 'slug' => $component_id ), false );
3106
  $primary_nav_item = reset( $primary_nav_item );
3107
  }
3108
 
@@ -3313,7 +3320,7 @@ function bp_the_body_class() {
3313
  $bp_classes[] = 'my-activity';
3314
  }
3315
  } else {
3316
- if ( bp_get_current_member_type() || ( bp_is_groups_directory() && bp_get_current_group_directory_type() ) ) {
3317
  $bp_classes[] = 'type';
3318
  }
3319
  }
@@ -3409,6 +3416,18 @@ function bp_the_body_class() {
3409
  $bp_classes[] = 'group-members';
3410
  }
3411
 
 
 
 
 
 
 
 
 
 
 
 
 
3412
  if ( bp_is_group_admin_page() ) {
3413
  $bp_classes[] = 'group-admin';
3414
  $bp_classes[] = bp_get_group_current_admin_tab();
@@ -3506,6 +3525,9 @@ function bp_get_the_post_class( $wp_classes = array() ) {
3506
 
3507
  } elseif ( bp_is_activation_page() ) {
3508
  $bp_classes[] = 'bp_activate';
 
 
 
3509
  }
3510
 
3511
  if ( empty( $bp_classes ) ) {
@@ -3691,7 +3713,7 @@ function bp_nav_menu( $args = array() ) {
3691
  $args->walker = new BP_Walker_Nav_Menu;
3692
  }
3693
 
3694
- // Sanitize values for class and ID.
3695
  $args->container_class = sanitize_html_class( $args->container_class );
3696
  $args->container_id = sanitize_html_class( $args->container_id );
3697
 
@@ -3800,110 +3822,21 @@ function bp_email_the_salutation( $settings = array() ) {
3800
  * Gets the Recipient Salutation.
3801
  *
3802
  * @since 2.5.0
3803
- * @since 8.0.0 Checks current BP Email type schema to eventually use the unnamed salutation.
3804
  *
3805
  * @param array $settings Email Settings.
3806
  * @return string The Recipient Salutation.
3807
  */
3808
  function bp_email_get_salutation( $settings = array() ) {
3809
- $email_type = bp_email_get_type();
3810
- $salutation = '';
3811
-
3812
- if ( $email_type ) {
3813
- $types_schema = bp_email_get_type_schema( 'named_salutation' );
3814
-
3815
- if ( isset( $types_schema[ $email_type ] ) && false === $types_schema[ $email_type ] ) {
3816
- /**
3817
- * Filters The Recipient Unnamed Salutation inside the Email Template.
3818
- *
3819
- * @since 8.0.0
3820
- *
3821
- * @param string $value The Recipient Salutation.
3822
- * @param array $settings Email Settings.
3823
- */
3824
- $salutation = apply_filters(
3825
- 'bp_email_get_unnamed_salutation',
3826
- _x( 'Hi,', 'Unnamed recipient salutation', 'buddypress' ),
3827
- $settings
3828
- );
3829
- }
3830
- }
3831
 
3832
- // Named salutations are default.
3833
- if ( ! $salutation ) {
3834
- $token = '{{recipient.name}}';
3835
-
3836
- /**
3837
- * Filters The Recipient Named Salutation inside the Email Template.
3838
- *
3839
- * @since 2.5.0
3840
- *
3841
- * @param string $value The Recipient Salutation.
3842
- * @param array $settings Email Settings.
3843
- * @param string $token The Recipient token.
3844
- */
3845
- $salutation = apply_filters(
3846
- 'bp_email_get_salutation',
3847
- sprintf(
3848
- /* translators: %s: the email token for the recipient name */
3849
- _x( 'Hi %s,', 'Named recipient salutation', 'buddypress' ),
3850
- $token
3851
- ),
3852
- $settings,
3853
- $token
3854
- );
3855
- }
3856
-
3857
- return $salutation;
3858
- }
3859
-
3860
- /**
3861
- * Checks if a Widget/Block is active.
3862
- *
3863
- * @since 9.0.0
3864
- *
3865
- * @param string $block_name The Block name to check (eg: 'bp/sitewide-notices'). Optional.
3866
- * @param string $widget_id_base The Widget ID base to check (eg: 'bp_messages_sitewide_notices_widget' ). Optional.
3867
- * @return boolean True if the Widget/Block is active. False otherwise.
3868
- */
3869
- function bp_is_widget_block_active( $block_name = '', $widget_id_base = '' ) {
3870
- $is_active = array(
3871
- 'widget' => false,
3872
- 'block' => false,
3873
- );
3874
-
3875
- if ( $block_name && bp_is_running_wp( '5.0.0', '>=' ) ) {
3876
- $widget_blocks = get_option( 'widget_block', array() );
3877
- $sidebars = wp_get_sidebars_widgets();
3878
-
3879
- if ( ! $widget_blocks || ! $sidebars ) {
3880
- return false;
3881
- }
3882
-
3883
- // Neutralize inactive sidebar.
3884
- unset( $sidebars['wp_inactive_widgets'] );
3885
-
3886
- $widgets_content = '';
3887
- foreach ( $widget_blocks as $key => $widget_block ) {
3888
- $widget_block_reference = 'block-' . $key;
3889
-
3890
- if ( ! isset( $widget_block['content'] ) || ! $widget_block['content'] ) {
3891
- continue;
3892
- }
3893
-
3894
- foreach ( $sidebars as $sidebar ) {
3895
- if ( is_array( $sidebar ) && in_array( $widget_block_reference, $sidebar, true ) ) {
3896
- $widgets_content .= $widget_block['content'] . "\n";
3897
- }
3898
- }
3899
- }
3900
-
3901
- $is_active['block'] = has_block( $block_name, $widgets_content );
3902
- }
3903
-
3904
- if ( $widget_id_base ) {
3905
- $is_active['widget'] = is_active_widget( false, false, $widget_id_base, true );
3906
  }
3907
-
3908
- return 0 !== count( array_filter( $is_active ) );
3909
- }
138
  $title = '';
139
 
140
  // Use the string provided by the component.
141
+ if ( ! empty( buddypress()->{$component}->directory_title ) ) {
142
  $title = buddypress()->{$component}->directory_title;
143
 
144
  // If none is found, concatenate.
145
  } elseif ( isset( buddypress()->{$component}->name ) ) {
 
146
  $title = sprintf( __( '%s Directory', 'buddypress' ), buddypress()->{$component}->name );
147
  }
148
 
152
  * @since 2.0.0
153
  *
154
  * @param string $title Text to be used in <title> tag.
155
+ * @param string $component Current componet being displayed.
156
  */
157
  return apply_filters( 'bp_get_directory_title', $title, $component );
158
  }
192
  function bp_comment_author_avatar() {
193
  global $comment;
194
 
195
+ if ( function_exists( 'bp_core_fetch_avatar' ) ) {
196
+ echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array(
197
+ 'item_id' => $comment->user_id,
198
+ 'type' => 'thumb',
199
+ 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $comment->user_id ) )
200
+ ) ) );
201
+ } elseif ( function_exists( 'get_avatar' ) ) {
202
+ get_avatar();
203
+ }
204
  }
205
 
206
  /**
211
  function bp_post_author_avatar() {
212
  global $post;
213
 
214
+ if ( function_exists( 'bp_core_fetch_avatar' ) ) {
215
+ echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array(
216
+ 'item_id' => $post->post_author,
217
+ 'type' => 'thumb',
218
+ 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $post->post_author ) )
219
+ ) ) );
220
+ } elseif ( function_exists( 'get_avatar' ) ) {
221
+ get_avatar();
222
+ }
223
  }
224
 
225
  /**
360
  * Format a date based on a UNIX timestamp.
361
  *
362
  * This function can be used to turn a UNIX timestamp into a properly formatted
363
+ * (and possibly localized) string, userful for ouputting the date & time an
364
  * action took place.
365
  *
366
  * Not to be confused with `bp_core_time_since()`, this function is best used
550
  $options['blogs'] = _x( 'Blogs', 'search form', 'buddypress' );
551
  }
552
 
553
+ if ( bp_is_active( 'forums' ) && bp_forums_is_installed_correctly() && bp_forums_has_directory() ) {
554
+ $options['forums'] = _x( 'Forums', 'search form', 'buddypress' );
555
+ }
556
+
557
  $options['posts'] = _x( 'Posts', 'search form', 'buddypress' );
558
 
559
  // Eventually this won't be needed and a page will be built to integrate all search results.
796
  $attributes = (array) apply_filters( 'bp_get_form_field_attributes', $attributes, $name );
797
 
798
  foreach( $attributes as $attr => $value ) {
799
+ $retval .= sprintf( ' %s="%s"', sanitize_key( $attr ), esc_attr( $value ) );
 
 
 
 
 
 
 
800
  }
801
 
802
  return $retval;
984
  *
985
  * @since 1.1.0
986
  *
987
+ * @param string $truncate Generated excerpt.
988
  * @param string $original_text Original text provided.
989
  * @param int $length Length of returned string, including ellipsis.
990
  * @param array $options Array of HTML attributes and options.
1154
  * otherwise false.
1155
  */
1156
  function bp_account_was_activated() {
1157
+ $bp = buddypress();
1158
+ $activation_complete = !empty( $bp->activation_complete )
1159
+ ? $bp->activation_complete
1160
+ : false;
1161
 
1162
  return $activation_complete;
1163
  }
1225
  *
1226
  * @since 1.7.0
1227
  *
1228
+ * @param string $subject Client friendy version of the root blog name.
1229
  * @param array $r Array of arguments for the email subject.
1230
  */
1231
  return apply_filters( 'bp_get_email_subject', $subject, $r );
1254
  }
1255
 
1256
  /**
1257
+ * Filters the template paramenters to be used in the query string.
1258
  *
1259
  * Allows templates to pass parameters into the template loops via AJAX.
1260
  *
2079
  }
2080
 
2081
  // Is component in either the active or required components arrays.
2082
+ if ( isset( buddypress()->active_components[ $component ] ) || isset( buddypress()->required_components[ $component ] ) ) {
2083
  $retval = true;
2084
 
2085
  // Is feature active?
2087
  // The xProfile component is specific.
2088
  if ( 'xprofile' === $component ) {
2089
  $component = 'profile';
 
 
 
 
 
 
 
 
 
 
 
 
 
2090
  }
2091
 
2092
+ if ( empty( buddypress()->$component->features ) || false === in_array( $feature, buddypress()->$component->features, true ) ) {
 
 
2093
  $retval = false;
2094
  }
2095
 
2199
  * Check whether the current page is part of the Forums component.
2200
  *
2201
  * @since 1.5.0
 
2202
  *
2203
  * @return bool True if the current page is part of the Forums component.
2204
  */
2228
  return (bool) bp_is_current_component( 'settings' );
2229
  }
2230
 
 
 
 
 
 
 
 
 
 
 
 
2231
  /**
2232
  * Is the current component an active core component?
2233
  *
2472
  return (bool) ( bp_is_profile_component() && bp_is_current_action( 'change-cover-image' ) );
2473
  }
2474
 
2475
+ /**
2476
+ * Is this a user's forums page?
2477
+ *
2478
+ * Eg http://example.com/members/joe/forums/ (or a subpage thereof).
2479
+ *
2480
+ * @since 1.5.0
2481
+ *
2482
+ * @return bool True if the current page is a user's forums page.
2483
+ */
2484
+ function bp_is_user_forums() {
2485
+
2486
+ if ( ! bp_is_active( 'forums' ) ) {
2487
+ return false;
2488
+ }
2489
+
2490
+ if ( bp_is_user() && bp_is_forums_component() ) {
2491
+ return true;
2492
+ }
2493
+
2494
+ return false;
2495
+ }
2496
+
2497
+ /**
2498
+ * Is this a user's "Topics Started" page?
2499
+ *
2500
+ * Eg http://example.com/members/joe/forums/topics/.
2501
+ *
2502
+ * @since 1.5.0
2503
+ *
2504
+ * @return bool True if the current page is a user's Topics Started page.
2505
+ */
2506
+ function bp_is_user_forums_started() {
2507
+ return (bool) ( bp_is_user_forums() && bp_is_current_action( 'topics' ) );
2508
+ }
2509
+
2510
+ /**
2511
+ * Is this a user's "Replied To" page?
2512
+ *
2513
+ * Eg http://example.com/members/joe/forums/replies/.
2514
+ *
2515
+ * @since 1.5.0
2516
+ *
2517
+ * @return bool True if the current page is a user's Replied To forums page.
2518
+ */
2519
+ function bp_is_user_forums_replied_to() {
2520
+ return (bool) ( bp_is_user_forums() && bp_is_current_action( 'replies' ) );
2521
+ }
2522
+
2523
  /**
2524
  * Is the current page part of a user's Groups page?
2525
  *
2676
  return (bool) ( bp_is_user_settings() && bp_is_current_action( 'profile' ) );
2677
  }
2678
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2679
  /** Groups ********************************************************************/
2680
 
2681
  /**
2754
  return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'admin' ) );
2755
  }
2756
 
2757
+ /**
2758
+ * Is the current page a group's forum page?
2759
+ *
2760
+ * Only applies to legacy bbPress forums.
2761
+ *
2762
+ * @since 1.1.0
2763
+ *
2764
+ * @return bool True if the current page is a group forum page.
2765
+ */
2766
+ function bp_is_group_forum() {
2767
+ $retval = false;
2768
+
2769
+ // At a forum URL.
2770
+ if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) ) {
2771
+ $retval = true;
2772
+
2773
+ // If at a forum URL, set back to false if forums are inactive, or not
2774
+ // installed correctly.
2775
+ if ( ! bp_is_active( 'forums' ) || ! bp_forums_is_installed_correctly() ) {
2776
+ $retval = false;
2777
+ }
2778
+ }
2779
+
2780
+ return $retval;
2781
+ }
2782
+
2783
  /**
2784
  * Is the current page a group's activity page?
2785
  *
2804
  /**
2805
  * Is the current page a group forum topic?
2806
  *
2807
+ * Only applies to legacy bbPress (1.x) forums.
2808
+ *
2809
  * @since 1.1.0
 
2810
  *
2811
  * @return bool True if the current page is part of a group forum topic.
2812
  */
2817
  /**
2818
  * Is the current page a group forum topic edit page?
2819
  *
2820
+ * Only applies to legacy bbPress (1.x) forums.
2821
+ *
2822
  * @since 1.2.0
 
2823
  *
2824
  * @return bool True if the current page is part of a group forum topic edit page.
2825
  */
3095
  return $bp_title_parts;
3096
  }
3097
 
3098
+ // Now we can build the BP Title Parts
3099
  // Is there a displayed user, and do they have a name?
3100
  $displayed_user_name = bp_get_displayed_user_fullname();
3101
 
3109
  $component_subnav_name = '';
3110
 
3111
  if ( ! empty( $bp->members->nav ) ) {
3112
+ $primary_nav_item = $bp->members->nav->get_primary( array( 'slug' => $component_id ), false );
3113
  $primary_nav_item = reset( $primary_nav_item );
3114
  }
3115
 
3320
  $bp_classes[] = 'my-activity';
3321
  }
3322
  } else {
3323
+ if ( bp_get_current_member_type() ) {
3324
  $bp_classes[] = 'type';
3325
  }
3326
  }
3416
  $bp_classes[] = 'group-members';
3417
  }
3418
 
3419
+ if ( bp_is_group_forum_topic() ) {
3420
+ $bp_classes[] = 'group-forum-topic';
3421
+ }
3422
+
3423
+ if ( bp_is_group_forum_topic_edit() ) {
3424
+ $bp_classes[] = 'group-forum-topic-edit';
3425
+ }
3426
+
3427
+ if ( bp_is_group_forum() ) {
3428
+ $bp_classes[] = 'group-forum';
3429
+ }
3430
+
3431
  if ( bp_is_group_admin_page() ) {
3432
  $bp_classes[] = 'group-admin';
3433
  $bp_classes[] = bp_get_group_current_admin_tab();
3525
 
3526
  } elseif ( bp_is_activation_page() ) {
3527
  $bp_classes[] = 'bp_activate';
3528
+
3529
+ } elseif ( bp_is_forums_component() && bp_is_directory() ) {
3530
+ $bp_classes[] = 'bp_forum';
3531
  }
3532
 
3533
  if ( empty( $bp_classes ) ) {
3713
  $args->walker = new BP_Walker_Nav_Menu;
3714
  }
3715
 
3716
+ // Sanitise values for class and ID.
3717
  $args->container_class = sanitize_html_class( $args->container_class );
3718
  $args->container_id = sanitize_html_class( $args->container_id );
3719
 
3822
  * Gets the Recipient Salutation.
3823
  *
3824
  * @since 2.5.0
 
3825
  *
3826
  * @param array $settings Email Settings.
3827
  * @return string The Recipient Salutation.
3828
  */
3829
  function bp_email_get_salutation( $settings = array() ) {
3830
+ $token = '{{recipient.name}}';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3831
 
3832
+ /**
3833
+ * Filters The Recipient Salutation inside the Email Template.
3834
+ *
3835
+ * @since 2.5.0
3836
+ *
3837
+ * @param string $value The Recipient Salutation.
3838
+ * @param array $settings Email Settings.
3839
+ * @param string $token The Recipient token.
3840
+ */
3841
+ return apply_filters( 'bp_email_get_salutation', sprintf( _x( 'Hi %s,', 'recipient salutation', 'buddypress' ), $token ), $settings, $token );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3842
  }
 
 
 
bp-core/bp-core-theme-compatibility.php CHANGED
@@ -189,7 +189,7 @@ function bp_use_theme_compat_with_current_theme() {
189
  * fallback check for themes that were derived from bp-default, and have
190
  * not been updated for BP 1.7+; we make the assumption that any theme in
191
  * this category will have the members-loop.php template, and so use its
192
- * presence as an indicator that theme compatibility is not required.
193
  *
194
  * @since 1.9.0
195
  *
@@ -432,7 +432,7 @@ function bp_register_theme_compat_default_features() {
432
  * than the width used by BuddyPress, so we need to manually set the
433
  * content width for the concerned themes.
434
  *
435
- * Example: array( stylesheet => content width used by BuddyPress ).
436
  */
437
  $bp_content_widths = array(
438
  'twentyfifteen' => 1300,
@@ -464,7 +464,7 @@ function bp_register_theme_compat_default_features() {
464
  bp_set_theme_compat_feature( 'legacy', array(
465
  'name' => 'cover_image',
466
  'settings' => array(
467
- 'components' => array( 'members', 'groups' ),
468
  'width' => $bp_content_width,
469
  'height' => $top_offset + round( $avatar_height / 2 ),
470
  'callback' => 'bp_legacy_theme_cover_image',
@@ -665,7 +665,7 @@ function bp_theme_compat_reset_post( $args = array() ) {
665
  */
666
  function bp_template_include_theme_compat( $template = '' ) {
667
  // If embed template, bail.
668
- if ( is_embed() ) {
669
  return $template;
670
  }
671
 
@@ -686,7 +686,7 @@ function bp_template_include_theme_compat( $template = '' ) {
686
  do_action( 'bp_template_include_reset_dummy_post_data' );
687
 
688
  // Bail if the template already matches a BuddyPress template.
689
- if ( isset( buddypress()->theme_compat->found_template ) && buddypress()->theme_compat->found_template ) {
690
  return $template;
691
  }
692
 
@@ -945,7 +945,7 @@ function bp_comments_open( $open, $post_id = 0 ) {
945
  *
946
  * @since 1.9.2
947
  *
948
- * @param string $retval The current post content.
949
  * @return string $retval
950
  */
951
  function bp_theme_compat_toggle_is_page( $retval = '' ) {
@@ -987,26 +987,3 @@ function bp_theme_compat_loop_end( $query ) {
987
  unset( $bp->theme_compat->is_page_toggled );
988
  }
989
  add_action( 'loop_end', 'bp_theme_compat_loop_end' );
990
-
991
- /**
992
- * Maybe override the preferred template pack if the theme declares a dependency.
993
- *
994
- * @since 3.0.0
995
- */
996
- function bp_check_theme_template_pack_dependency() {
997
- if ( bp_is_deactivation() ) {
998
- return;
999
- }
1000
-
1001
- $all_packages = array_keys( buddypress()->theme_compat->packages );
1002
-
1003
- foreach ( $all_packages as $package ) {
1004
- // e.g. "buddypress-use-nouveau", "buddypress-use-legacy".
1005
- if ( ! current_theme_supports( "buddypress-use-{$package}" ) ) {
1006
- continue;
1007
- }
1008
-
1009
- bp_setup_theme_compat( $package );
1010
- return;
1011
- }
1012
- }
189
  * fallback check for themes that were derived from bp-default, and have
190
  * not been updated for BP 1.7+; we make the assumption that any theme in
191
  * this category will have the members-loop.php template, and so use its
192
+ * presence as an indicator that theme compatibility is not required
193
  *
194
  * @since 1.9.0
195
  *
432
  * than the width used by BuddyPress, so we need to manually set the
433
  * content width for the concerned themes.
434
  *
435
+ * Example: array( stylesheet => content width used by BuddyPress )
436
  */
437
  $bp_content_widths = array(
438
  'twentyfifteen' => 1300,
464
  bp_set_theme_compat_feature( 'legacy', array(
465
  'name' => 'cover_image',
466
  'settings' => array(
467
+ 'components' => array( 'xprofile', 'groups' ),
468
  'width' => $bp_content_width,
469
  'height' => $top_offset + round( $avatar_height / 2 ),
470
  'callback' => 'bp_legacy_theme_cover_image',
665
  */
666
  function bp_template_include_theme_compat( $template = '' ) {
667
  // If embed template, bail.
668
+ if ( true === function_exists( 'is_embed' ) && is_embed() ) {
669
  return $template;
670
  }
671
 
686
  do_action( 'bp_template_include_reset_dummy_post_data' );
687
 
688
  // Bail if the template already matches a BuddyPress template.
689
+ if ( ! empty( buddypress()->theme_compat->found_template ) ) {
690
  return $template;
691
  }
692
 
945
  *
946
  * @since 1.9.2
947
  *
948
+ * @param string $retval The current post content.
949
  * @return string $retval
950
  */
951
  function bp_theme_compat_toggle_is_page( $retval = '' ) {
987
  unset( $bp->theme_compat->is_page_toggled );
988
  }
989
  add_action( 'loop_end', 'bp_theme_compat_loop_end' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/bp-core-update.php CHANGED
@@ -268,16 +268,6 @@ function bp_version_updater() {
268
  if ( $raw_db_version < 11105 ) {
269
  bp_update_to_2_7();
270
  }
271
-
272
- // Version 5.0.0.
273
- if ( $raw_db_version < 12385 ) {
274
- bp_update_to_5_0();
275
- }
276
-
277
- // Version 8.0.0.
278
- if ( $raw_db_version < 12850 ) {
279
- bp_update_to_8_0();
280
- }
281
  }
282
 
283
  /* All done! *************************************************************/
@@ -552,158 +542,6 @@ function bp_update_to_2_7() {
552
  bp_add_option( '_bp_ignore_deprecated_code', false );
553
  }
554
 
555
- /**
556
- * Retuns needed the fullname field ID for an update task.
557
- *
558
- * @since 8.0.0
559
- *
560
- * @return int The fullname field ID.
561
- */
562
- function bp_get_fullname_field_id_for_update() {
563
- /**
564
- * The xProfile component is active by default on new installs, even if it
565
- * might be inactive during this update, we need to set the custom visibility
566
- * for the default field, in case the Administrator decides to reactivate it.
567
- */
568
- global $wpdb;
569
- $bp_prefix = bp_core_get_table_prefix();
570
- return (int) $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE name = %s", addslashes( bp_get_option( 'bp-xprofile-fullname-field-name' ) ) ) );
571
- }
572
-
573
- /**
574
- * 5.0.0 update routine.
575
- *
576
- * - Make sure the custom visibility is disabled for the default profile field.
577
- * - Create the invitations table.
578
- * - Migrate requests and invitations to the new table.
579
- *
580
- * @since 5.0.0
581
- */
582
- function bp_update_to_5_0() {
583
- /**
584
- * The xProfile component is active by default on new installs, even if it
585
- * might be inactive during this update, we need to set the custom visibility
586
- * for the default field, in case the Administrator decides to reactivate it.
587
- */
588
- global $wpdb;
589
- $bp_prefix = bp_core_get_table_prefix();
590
- $field_id = bp_get_fullname_field_id_for_update();
591
-
592
- $wpdb->insert(
593
- $bp_prefix . 'bp_xprofile_meta',
594
- array(
595
- 'object_id' => $field_id,
596
- 'object_type' => 'field',
597
- 'meta_key' => 'allow_custom_visibility',
598
- 'meta_value' => 'disabled'
599
- ),
600
- array(
601
- '%d',
602
- '%s',
603
- '%s',
604
- '%s'
605
- )
606
- );
607
-
608
- bp_core_install_invitations();
609
-
610
- if ( bp_is_active( 'groups' ) ) {
611
- bp_groups_migrate_invitations();
612
- }
613
- }
614
-
615
- /**
616
- * 8.0.0 update routine.
617
- *
618
- * - Edit the `new_avatar` activity type's component to `members`.
619
- * - Upgrade Primary xProfile Group's fields to signup fields.
620
- *
621
- * @since 8.0.0
622
- */
623
- function bp_update_to_8_0() {
624
- global $wpdb;
625
- $bp_prefix = bp_core_get_table_prefix();
626
-
627
- // Install welcome email to email list.
628
- add_filter( 'bp_email_get_schema', 'bp_core_get_8_0_upgrade_email_schema' );
629
-
630
- bp_core_install_emails();
631
-
632
- remove_filter( 'bp_email_get_schema', 'bp_core_get_8_0_upgrade_email_schema' );
633
-
634
- // Update the `new_avatar` activity type's component to `members`.
635
- $wpdb->update(
636
- $bp_prefix . 'bp_activity',
637
- array(
638
- 'component' => 'members',
639
- ),
640
- array(
641
- 'type' => 'new_avatar',
642
- ),
643
- array(
644
- '%s',
645
- ),
646
- array(
647
- '%s',
648
- )
649
- );
650
-
651
- // Check if we need to create default signup fields.
652
- $field_id = bp_get_fullname_field_id_for_update();
653
- $has_signup_position = (bool) $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM {$bp_prefix}bp_xprofile_meta WHERE meta_key = 'signup_position' AND object_type = 'field' AND object_id = %d", $field_id ) );
654
- if ( bp_get_signup_allowed() && ! $has_signup_position ) {
655
- // Get the Primary Group's fields.
656
- $signup_fields = $wpdb->get_col( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE group_id = 1 ORDER BY field_order ASC" );
657
-
658
- // Migrate potential signup fields.
659
- if ( $signup_fields ) {
660
- $signup_position = 0;
661
- foreach ( $signup_fields as $signup_field_id ) {
662
- $signup_position += 1;
663
-
664
- $wpdb->insert(
665
- $bp_prefix . 'bp_xprofile_meta',
666
- array(
667
- 'object_id' => $signup_field_id,
668
- 'object_type' => 'field',
669
- 'meta_key' => 'signup_position',
670
- 'meta_value' => $signup_position,
671
- ),
672
- array(
673
- '%d',
674
- '%s',
675
- '%s',
676
- '%d',
677
- )
678
- );
679
- }
680
- }
681
- }
682
-
683
- bp_core_install_nonmember_opt_outs();
684
- }
685
-
686
- /**
687
- * Select only the emails that need to be installed with version 8.0.
688
- *
689
- * @since 8.0.0
690
- *
691
- * @param array $emails The array of emails schema.
692
- */
693
- function bp_core_get_8_0_upgrade_email_schema( $emails ) {
694
- $new_emails = array();
695
-
696
- if ( isset( $emails['core-user-activation'] ) ) {
697
- $new_emails['core-user-activation'] = $emails['core-user-activation'];
698
- }
699
-
700
- if ( isset( $emails['bp-members-invitation'] ) ) {
701
- $new_emails['bp-members-invitation'] = $emails['bp-members-invitation'];
702
- }
703
-
704
- return $new_emails;
705
- }
706
-
707
  /**
708
  * Updates the component field for new_members type.
709
  *
268
  if ( $raw_db_version < 11105 ) {
269
  bp_update_to_2_7();
270
  }
 
 
 
 
 
 
 
 
 
 
271
  }
272
 
273
  /* All done! *************************************************************/
542
  bp_add_option( '_bp_ignore_deprecated_code', false );
543
  }
544
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
545
  /**
546
  * Updates the component field for new_members type.
547
  *
bp-core/bp-core-wpabstraction.php CHANGED
@@ -307,189 +307,3 @@ if ( !function_exists( 'mb_strrpos' ) ) {
307
  }
308
  }
309
  }
310
-
311
- /**
312
- * Returns the name of the hook to use once a WordPress Site is inserted into the Database.
313
- *
314
- * WordPress 5.1.0 deprecated the `wpmu_new_blog` action. As BuddyPress is supporting WordPress back
315
- * to 4.9.0, this function makes sure we are using the new hook `wp_initialize_site` when the current
316
- * WordPress version is upper or equal to 5.1.0 and that we keep on using `wpmu_new_blog` for earlier
317
- * versions of WordPress.
318
- *
319
- * @since 6.0.0
320
- *
321
- * @return string The name of the hook to use.
322
- */
323
- function bp_insert_site_hook() {
324
- $wp_hook = 'wpmu_new_blog';
325
-
326
- if ( function_exists( 'wp_insert_site' ) ) {
327
- $wp_hook = 'wp_initialize_site';
328
- }
329
-
330
- return $wp_hook;
331
- }
332
-
333
- /**
334
- * Catch the new site data for a later use.
335
- *
336
- * @since 6.0.0
337
- */
338
- function bp_catch_site_data( $errors = null, $data = array() ) {
339
- buddypress()->new_site_data = $data;
340
- }
341
- add_action( 'wp_validate_site_data', 'bp_catch_site_data', 10, 2 );
342
-
343
- /**
344
- * Fires a BuddyPress hook when a new WordPress site is inserted into the database.
345
- *
346
- * This hook makes sure BuddyPress is back compatible with WordPress versions < 5.1.0.
347
- *
348
- * @since 6.0.0
349
- *
350
- * @param int|WP_Site $site The Site ID or the WP Site object.
351
- * @param int|array $args_or_user_id An array of Site arguments or the User ID.
352
- * @param string $domain Site domain.
353
- * @param string $path Site path.
354
- * @param int $network_id Network ID. Only relevant on multi-network installations.
355
- * @param array $meta Meta data. Used to set initial site options.
356
- */
357
- function bp_insert_site( $site, $args_or_user_id = null, $domain = '', $path = '', $network_id = 0, $meta = array() ) {
358
- if ( $site instanceof WP_Site ) {
359
- $bp = buddypress();
360
- $site_id = $site->id;
361
- $domain = $site->domain;
362
- $path = $site->path;
363
- $network_id = $site->network_id;
364
- $args = (array) $args_or_user_id;
365
-
366
- $user_id = 0;
367
- if ( isset( $args['user_id'] ) && $args['user_id'] ) {
368
- $user_id = (int) $args['user_id'];
369
- }
370
-
371
- $meta = array();
372
- if ( isset( $args['options'] ) && $args['options'] ) {
373
- $meta = (array) $args['options'];
374
-
375
- if ( ! array_key_exists( 'WPLANG', $meta ) ) {
376
- $meta['WPLANG'] = get_network_option( $site->network_id, 'WPLANG' );
377
- }
378
-
379
- if ( isset( $bp->new_site_data ) ) {
380
- $meta = array_merge( $bp->new_site_data, $meta );
381
- }
382
- }
383
- } else {
384
- $site_id = $site;
385
- $user_id = (int) $args_or_user_id;
386
- }
387
-
388
- /**
389
- * Fires when a new WordPress site has been inserted into the database.
390
- *
391
- * @since 6.0.0
392
- *
393
- * @param int $site_id Site ID.
394
- * @param int $user_id User ID.
395
- * @param string $domain Site domain.
396
- * @param string $path Site path.
397
- * @param int $network_id Network ID. Only relevant on multi-network installations.
398
- * @param array $meta Meta data. Used to set initial site options.
399
- */
400
- do_action( 'bp_insert_site', $site_id, $user_id, $domain, $path, $network_id, $meta );
401
- }
402
- add_action( bp_insert_site_hook(), 'bp_insert_site' );
403
-
404
- /**
405
- * Returns the name of the hook to use once a WordPress Site is deleted.
406
- *
407
- * WordPress 5.1.0 deprecated the `delete_blog` action. As BuddyPress is supporting WordPress back
408
- * to 4.9.0, this function makes sure we are using the new hook `wp_validate_site_deletion` when the
409
- * current WordPress version is upper or equal to 5.1.0 and that we keep on using `delete_blog` for
410
- * earlier versions of WordPress.
411
- *
412
- * @since 6.0.0
413
- *
414
- * @return string The name of the hook to use.
415
- */
416
- function bp_delete_site_hook() {
417
- $wp_hook = 'delete_blog';
418
-
419
- if ( function_exists( 'wp_delete_site' ) ) {
420
- $wp_hook = 'wp_validate_site_deletion';
421
- }
422
-
423
- return $wp_hook;
424
- }
425
-
426
- /**
427
- * Makes sure the `bp_delete_site` hook is fired if site's deletion
428
- * was performed without dropping tables.
429
- *
430
- * @since 6.0.0
431
- *
432
- * @param WP_Site $site The site object.
433
- */
434
- function bp_delete_site_no_tables_drop( $site ) {
435
- if ( isset( $site->deleted ) && 1 === (int) $site->deleted ) {
436
- return bp_delete_site( $site->id, false );
437
- }
438
- }
439
- add_action( 'wp_update_site', 'bp_delete_site_no_tables_drop', 10, 1 );
440
-
441
- /**
442
- * Fires a BuddyPress hook when a new WordPress site is deleted.
443
- *
444
- * This hook makes sure BuddyPress is back compatible with WordPress versions < 5.1.0.
445
- *
446
- * @since 6.0.0
447
- *
448
- * @param int|WP_Error $site_id_or_error A WP Error object or the site ID.
449
- * @param bool|WP_Site $drop_or_site A WP Site object or a boolean to inform whether site's table should be dropped.
450
- */
451
- function bp_delete_site( $site_id_or_error, $drop_or_site = false ) {
452
- if ( $drop_or_site instanceof WP_Site ) {
453
- if ( ! empty( $site_id_or_error->errors ) ) {
454
- return;
455
- }
456
-
457
- $site_id = (int) $drop_or_site->id;
458
- $drop = true;
459
- } else {
460
- $site_id = (int) $site_id_or_error;
461
- $drop = (bool) $drop_or_site;
462
- }
463
-
464
- /**
465
- * Fires when a WordPress site is deleted.
466
- *
467
- * @since 6.0.0
468
- *
469
- * @param int $site_id The site ID.
470
- * @param bool $drop True if site's table should be dropped. Default is false.
471
- */
472
- do_action( 'bp_delete_site', $site_id, $drop );
473
- }
474
- add_action( bp_delete_site_hook(), 'bp_delete_site', 10, 2 );
475
-
476
- if ( ! function_exists( 'wp_parse_list' ) ) {
477
- /**
478
- * Cleans up an array, comma- or space-separated list of scalar values.
479
- *
480
- * As BuddyPress supports older WordPress versions than 5.1 (4.9 & 5.0),
481
- * the BP REST API needs this function to be available.
482
- *
483
- * @since 7.0.0
484
- *
485
- * @param array|string $list List of values.
486
- * @return array Sanitized array of values.
487
- */
488
- function wp_parse_list( $list ) {
489
- if ( ! is_array( $list ) ) {
490
- return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
491
- }
492
-
493
- return $list;
494
- }
495
- }
307
  }
308
  }
309
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/classes/class-bp-admin-types.php DELETED
@@ -1,618 +0,0 @@
1
- <?php
2
- /**
3
- * BuddyPress Types Admin Class.
4
- *
5
- * @package BuddyPress
6
- * @subpackage CoreAdministration
7
- * @since 7.0.0
8
- */
9
-
10
- // Exit if accessed directly.
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- }
14
-
15
- if ( ! class_exists( 'BP_Admin_Types' ) ) :
16
-
17
- /**
18
- * Load BuddyPress Types admin area.
19
- *
20
- * @since 7.O.0
21
- */
22
- class BP_Admin_Types {
23
- /**
24
- * Current BuddyPress taxonomy.
25
- *
26
- * @since 7.0.0
27
- * @var string
28
- */
29
- public $taxonomy = '';
30
-
31
- /**
32
- * All registered BuddyPress taxonomies.
33
- *
34
- * @since 7.0.0
35
- * @var array()
36
- */
37
- public $taxonomies = array();
38
-
39
- /**
40
- * Current screen ID.
41
- *
42
- * @since 7.0.0
43
- * @var string
44
- */
45
- public $screen_id = '';
46
-
47
- /**
48
- * The main BuddyPress Types admin loader.
49
- *
50
- * @since 7.0.0
51
- */
52
- public function __construct() {
53
- $this->setup_globals();
54
-
55
- if ( $this->taxonomy && $this->screen_id ) {
56
- $this->includes();
57
- $this->setup_hooks();
58
-
59
- if ( isset( $_POST['action'] ) || isset( $_GET['action'] ) ) {
60
- if ( isset( $_GET['action'] ) ) {
61
- $action = wp_unslash( $_GET['action'] );
62
- } else {
63
- $action = wp_unslash( $_POST['action'] );
64
- }
65
-
66
- $this->handle_action( $action );
67
- }
68
- }
69
- }
70
-
71
- /**
72
- * Register BP Types Admin.
73
- *
74
- * @since 7.0.0
75
- *
76
- * @return BP_Admin_Types
77
- */
78
- public static function register_types_admin() {
79
- if ( ! is_admin() ) {
80
- return;
81
- }
82
-
83
- $bp = buddypress();
84
-
85
- if ( empty( $bp->core->types_admin ) ) {
86
- $bp->core->types_admin = new self;
87
- }
88
-
89
- return $bp->core->types_admin;
90
- }
91
-
92
- /**
93
- * Set the globals.
94
- *
95
- * @since 7.0.0
96
- */
97
- private function setup_globals() {
98
- $current_screen = get_current_screen();
99
-
100
- if ( isset( $current_screen->taxonomy ) && $current_screen->taxonomy ) {
101
- $this->taxonomies = bp_get_default_taxonomies();
102
-
103
- if ( isset( $this->taxonomies[ $current_screen->taxonomy ] ) ) {
104
- $this->taxonomy = $current_screen->taxonomy;
105
- $this->screen_id = $current_screen->id;
106
- }
107
- }
108
- }
109
-
110
- /**
111
- * Include Admin functions.
112
- *
113
- * @since 7.0.0
114
- */
115
- private function includes() {
116
- require plugin_dir_path( dirname( __FILE__ ) ) . 'admin/bp-core-admin-types.php';
117
- }
118
-
119
- /**
120
- * Set hooks.
121
- *
122
- * @since 7.0.0
123
- */
124
- private function setup_hooks() {
125
- // Actions.
126
- add_action( 'admin_head-edit-tags.php', array( $this, 'screen_head' ) );
127
- add_action( 'admin_head-term.php', array( $this, 'screen_head' ) );
128
- add_action( 'bp_admin_enqueue_scripts', array( $this, 'screen_scripts' ) );
129
- add_action( "{$this->taxonomy}_add_form_fields", array( $this, 'add_form_fields' ), 10, 1 );
130
- add_action( "{$this->taxonomy}_edit_form_fields", array( $this, 'edit_form_fields' ), 10, 2 );
131
-
132
- // Filters
133
- add_filter( 'bp_core_admin_register_scripts', array( $this, 'register_scripts' ) );
134
- add_filter( "manage_{$this->screen_id}_columns", array( $this, 'column_headers' ), 10, 1 );
135
- add_filter( "manage_{$this->taxonomy}_custom_column", array( $this, 'column_contents' ), 10, 3 );
136
- add_filter( "{$this->taxonomy}_row_actions", array( $this, 'row_actions' ), 10, 2 );
137
- add_filter( "bulk_actions-{$this->screen_id}", '__return_empty_array', 10, 1 );
138
- }
139
-
140
- /**
141
- * Handle BP Type actions.
142
- *
143
- * @since 7.0.0
144
- *
145
- * @param string $action Required. The action to handle ('add-tag', 'editedtag' or 'delete' ).
146
- */
147
- private function handle_action( $action ) {
148
- $referer = wp_get_referer();
149
-
150
- if ( ! bp_current_user_can( 'bp_moderate' ) ) {
151
- return;
152
- }
153
-
154
- // Adding a new type into the database.
155
- if ( 'add-tag' === $action ) {
156
- check_admin_referer( 'add-tag', '_wpnonce_add-tag' );
157
-
158
- $result = bp_core_admin_insert_type( $_POST );
159
-
160
- if ( is_wp_error( $result ) ) {
161
- $referer = add_query_arg(
162
- array_merge(
163
- $result->get_error_data(),
164
- array(
165
- 'error' => 1,
166
- )
167
- ),
168
- $referer
169
- );
170
-
171
- wp_safe_redirect( $referer );
172
- exit;
173
- }
174
-
175
- wp_safe_redirect( add_query_arg( 'message', 2, $referer ) );
176
- exit;
177
-
178
- // Updating an existing type intot the Database.
179
- } elseif ( 'editedtag' === $action ) {
180
- $args = $_POST;
181
- $args['type_term_id'] = 0;
182
- unset( $args['tag_ID'] );
183
-
184
- if ( isset( $_POST['tag_ID'] ) ) {
185
- $args['type_term_id'] = $_POST['tag_ID'];
186
- }
187
-
188
- if ( isset( $_POST['taxonomy'] ) ) {
189
- $args['taxonomy'] = $_POST['taxonomy'];
190
- }
191
-
192
- check_admin_referer( 'update-tag_' . $args['type_term_id'] );
193
-
194
- $result = bp_core_admin_update_type( $args );
195
-
196
- if ( is_wp_error( $result ) ) {
197
- $referer = add_query_arg(
198
- array_merge(
199
- $result->get_error_data(),
200
- array(
201
- 'error' => 1,
202
- )
203
- ),
204
- $referer
205
- );
206
-
207
- wp_safe_redirect( $referer );
208
- exit;
209
- }
210
-
211
- wp_safe_redirect( add_query_arg( 'message', 4, $referer ) );
212
- exit;
213
-
214
- // Deletes a type.
215
- } elseif ( 'delete' === $action ) {
216
- $args = $_GET;
217
- $args['type_term_id'] = 0;
218
- unset( $args['tag_ID'] );
219
-
220
- if ( isset( $_GET['tag_ID'] ) ) {
221
- $args['type_term_id'] = $_GET['tag_ID'];
222
- }
223
-
224
- if ( isset( $_GET['taxonomy'] ) ) {
225
- $args['taxonomy'] = $_GET['taxonomy'];
226
- }
227
-
228
- check_admin_referer( 'delete-tag_' . $args['type_term_id'] );
229
- $referer = remove_query_arg( array( 'action', 'tag_ID', '_wpnonce' ), $referer );
230
-
231
- // Delete the type.
232
- $result = bp_core_admin_delete_type( $args );
233
-
234
- if ( is_wp_error( $result ) ) {
235
- $referer = add_query_arg(
236
- array_merge(
237
- $result->get_error_data(),
238
- array(
239
- 'error' => 1,
240
- )
241
- ),
242
- $referer
243
- );
244
-
245
- wp_safe_redirect( $referer );
246
- exit;
247
- }
248
-
249
- wp_safe_redirect( add_query_arg( 'message', 9, $referer ) );
250
- exit;
251
- }
252
- }
253
-
254
- /**
255
- * Override the Admin parent file to highlight the right menu.
256
- *
257
- * @since 7.0.0
258
- */
259
- public function screen_head() {
260
- global $parent_file;
261
-
262
- if ( 'members' === $this->taxonomies[ $this->taxonomy ]['component'] ) {
263
- $parent_file = 'users.php';
264
- } else {
265
- $parent_file = 'bp-' . $this->taxonomies[ $this->taxonomy ]['component'];
266
- }
267
- }
268
-
269
- /**
270
- * Registers script.
271
- *
272
- * @since 7.0.0
273
- */
274
- public function register_scripts( $scripts = array() ) {
275
- // Neutralize WordPress Taxonomy scripts.
276
- wp_dequeue_script( 'admin-tags' );
277
- wp_dequeue_script( 'inline-edit-tax' );
278
-
279
- // Adapt some styles.
280
- wp_add_inline_style(
281
- 'common',
282
- '.form-field:not(.bp-types-form), .term-bp_type_directory_slug-wrap:not(.bp-set-directory-slug), .edit-tag-actions #delete-link { display: none; }'
283
- );
284
-
285
- // Register the Types admin script.
286
- return array_merge(
287
- $scripts,
288
- array(
289
- 'bp-admin-types' => array(
290
- 'file' => sprintf(
291
- '%1$sadmin/js/types-admin%2$s.js',
292
- plugin_dir_url( dirname( __FILE__ ) ),
293
- bp_core_get_minified_asset_suffix()
294
- ),
295
- 'dependencies' => array(),
296
- 'footer' => true,
297
- ),
298
- )
299
- );
300
- }
301
-
302
- /**
303
- * Enqueues script.
304
- *
305
- * @since 7.0.0
306
- */
307
- public function screen_scripts() {
308
- wp_enqueue_script( 'bp-admin-types' );
309
- }
310
-
311
- /**
312
- * Outputs the BP type add form.
313
- *
314
- * @since 7.0.0
315
- *
316
- * @param string $taxonomy The type taxonomy name.
317
- * @param null|object $type The type object, `null` if not passed to the method.
318
- */
319
- public function add_form_fields( $taxonomy = '', $type = null ) {
320
- $taxonomy_object = get_taxonomy( $taxonomy );
321
- $labels = get_taxonomy_labels( $taxonomy_object );
322
-
323
- // Default values for the Type ID field.
324
- $type_id_label = __( 'Type ID', 'buddypress' );
325
- $type_id_desc = __( 'Enter a lower-case string without spaces or special characters (used internally to identify the type).', 'buddypress' );
326
-
327
- if ( isset( $labels->bp_type_id_label ) && $labels->bp_type_id_label ) {
328
- $type_id_label = $labels->bp_type_id_label;
329
- }
330
-
331
- if ( isset( $labels->bp_type_id_description ) && $labels->bp_type_id_description ) {
332
- $type_id_desc = $labels->bp_type_id_description;
333
- }
334
-
335
- // Outputs the Type ID field.
336
- if ( isset( $type->name ) ) {
337
- printf(
338
- '<tr class="form-field bp-types-form form-required term-bp_type_id-wrap">
339
- <th scope="row"><label for="bp_type_id">%1$s</label></th>
340
- <td>
341
- <input name="bp_type_id" id="bp_type_id" type="text" value="%2$s" size="40" disabled="disabled">
342
- </td>
343
- </tr>',
344
- esc_html( $type_id_label ),
345
- esc_attr( $type->name ),
346
- esc_html( $type_id_desc )
347
- );
348
- } else {
349
- printf(
350
- '<div class="form-field bp-types-form form-required term-bp_type_id-wrap">
351
- <label for="bp_type_id">%1$s</label>
352
- <input name="bp_type_id" id="bp_type_id" type="text" value="" size="40" aria-required="true">
353
- <p>%2$s</p>
354
- </div>',
355
- esc_html( $type_id_label ),
356
- esc_html( $type_id_desc )
357
- );
358
- }
359
-
360
- // Gets the Type's metadata.
361
- $metafields = get_registered_meta_keys( 'term', $taxonomy );
362
-
363
- foreach ( $metafields as $meta_key => $meta_schema ) {
364
- if ( ! isset( $labels->{ $meta_key } ) || ! $labels->{ $meta_key } ) {
365
- _doing_it_wrong(
366
- __METHOD__,
367
- __( 'Type metadata labels need to be set into the labels argument when registering your taxonomy using the meta key as the label’s key.', 'buddypress' )
368
- . ' ' .
369
- sprintf(
370
- /* translators: %s is the name of the Type meta key */
371
- __( 'As a result, the form elements for the "%s" meta key cannot be displayed', 'buddypress' ), $meta_key ),
372
- '7.0.0'
373
- );
374
- continue;
375
- }
376
-
377
- $type_key = str_replace( 'bp_type_', '', $meta_key );
378
-
379
- if ( 'string' === $meta_schema['type'] ) {
380
- if ( isset( $type->name ) ) {
381
- $type_prop_value = null;
382
- if ( in_array( $type_key, array( 'name', 'singular_name' ), true ) ) {
383
- if ( isset( $type->labels[ $type_key ] ) ) {
384
- $type_prop_value = $type->labels[ $type_key ];
385
- }
386
-
387
- } elseif ( isset( $type->{$type_key} ) ) {
388
- $type_prop_value = $type->{$type_key};
389
- }
390
-
391
- printf(
392
- '<tr class="form-field bp-types-form form-required term-%1$s-wrap">
393
- <th scope="row"><label for="%1$s">%2$s</label></th>
394
- <td>
395
- <input name="%1$s" id="%1$s" type="text" value="%3$s" size="40" aria-required="true">
396
- <p class="description">%4$s</p>
397
- </td>
398
- </tr>',
399
- esc_attr( $meta_key ),
400
- esc_html( $labels->{ $meta_key } ),
401
- esc_attr( $type_prop_value ),
402
- esc_html( $meta_schema['description'] )
403
- );
404
-
405
- } else {
406
- printf(
407
- '<div class="form-field bp-types-form form-required term-%1$s-wrap">
408
- <label for="%1$s">%2$s</label>
409
- <input name="%1$s" id="%1$s" type="text" value="" size="40">
410
- <p>%3$s</p>
411
- </div>',
412
- esc_attr( $meta_key ),
413
- esc_html( $labels->{ $meta_key } ),
414
- esc_html( $meta_schema['description'] )
415
- );
416
- }
417
- } else {
418
- if ( isset( $type->name ) ) {
419
- $checked = '';
420
- if ( isset( $type->{$type_key} ) && true === (bool) $type->{$type_key} ) {
421
- $checked = ' checked="checked"';
422
- }
423
-
424
- printf(
425
- '<tr class="form-field bp-types-form term-%1$s-wrap">
426
- <th scope="row"><label for="%1$s">%2$s</label></th>
427
- <td>
428
- <input name="%1$s" id="%1$s" type="checkbox" value="1"%3$s> %4$s
429
- <p class="description">%5$s</p>
430
- </td>
431
- </tr>',
432
- esc_attr( $meta_key ),
433
- esc_html( $labels->{ $meta_key } ),
434
- $checked,
435
- esc_html__( 'Yes', 'buddypress' ),
436
- esc_html( $meta_schema['description'] )
437
- );
438
- } else {
439
- printf(
440
- '<div class="form-field bp-types-form term-%1$s-wrap">
441
- <label for="%1$s">
442
- <input name="%1$s" id="%1$s" type="checkbox" value="1"> %2$s
443
- </label>
444
- <p>%3$s</p>
445
- </div>',
446
- esc_attr( $meta_key ),
447
- esc_html( $labels->{ $meta_key } ),
448
- esc_html( $meta_schema['description'] )
449
- );
450
- }
451
- }
452
- }
453
- }
454
-
455
- /**
456
- * Outputs the BP type edit form.
457
- *
458
- * @since 7.0.0
459
- *
460
- * @param WP_Term $term The term object for the BP Type.
461
- * @param string $taxonomy The type taxonomy name.
462
- * @return string HTML Output.
463
- */
464
- public function edit_form_fields( $term = null, $taxonomy = '' ) {
465
- if ( ! isset( $term->name ) || ! $term->name || ! $taxonomy ) {
466
- return;
467
- }
468
-
469
- $type = new stdClass();
470
- $type->name = $term->name;
471
- $type->labels = array();
472
- $metadatas = get_metadata( 'term', $term->term_id );
473
-
474
- foreach ( $metadatas as $meta_key => $meta_values ) {
475
- $meta_value = reset( $meta_values );
476
- $type_key = str_replace( 'bp_type_', '', $meta_key );
477
-
478
- if ( in_array( $type_key, array( 'name', 'singular_name' ), true ) ) {
479
- $type->labels[ $type_key ] = $meta_value;
480
- } else {
481
- $type->{$type_key} = $meta_value;
482
- }
483
- }
484
-
485
- return $this->add_form_fields( $taxonomy, $type );
486
- }
487
-
488
- /**
489
- * Filters the terms list table column headers to customize them for BuddyPress Types.
490
- *
491
- * @since 7.0.0
492
- *
493
- * @param array $column_headers The column header labels keyed by column ID.
494
- * @return array The column header labels keyed by column ID.
495
- */
496
- public function column_headers( $column_headers = array() ) {
497
- if ( isset( $column_headers['name'] ) ) {
498
- $column_headers['name'] = __( 'Type ID', 'buddypress' );
499
- }
500
-
501
- unset( $column_headers['cb'], $column_headers['description'], $column_headers['posts'] );
502
-
503
- $column_headers['plural_name'] = __( 'Name', 'buddypress' );
504
- $column_headers['counts'] = _x( 'Count', 'Number/count of types', 'buddypress' );
505
-
506
- return $column_headers;
507
- }
508
-
509
- /**
510
- * Sets the content for the Plural name & Counts columns.
511
- *
512
- * @since 7.0.0
513
- *
514
- * @param string $string Blank string.
515
- * @param string $column_name Name of the column.
516
- * @param int $type_id The type's term ID.
517
- * @return string The Type Plural name.
518
- */
519
- public function column_contents( $column_content = '', $column_name = '', $type_id = 0 ) {
520
- if ( 'plural_name' !== $column_name && 'counts' !== $column_name || ! $type_id ) {
521
- return $column_content;
522
- }
523
-
524
- // Set the Plural name column.
525
- if ( 'plural_name' === $column_name ) {
526
- $type_plural_name = get_term_meta( $type_id, 'bp_type_name', true );
527
-
528
- // Plural name meta is not set? Let's check register by code types!
529
- if ( ! $type_plural_name ) {
530
- $type_name = get_term_field( 'name', $type_id, $this->taxonomy );
531
-
532
- /**
533
- * Filter here to set missing term meta for registered by code types.
534
- *
535
- * @see bp_set_registered_by_code_member_type_metadata() for an example of use.
536
- *
537
- * @since 7.0.0
538
- *
539
- * @param string $value Metadata for the BP Type.
540
- */
541
- $metadata = apply_filters( "{$this->taxonomy}_set_registered_by_code_metada", array(), $type_name );
542
-
543
- if ( isset( $metadata['bp_type_name'] ) ) {
544
- $type_plural_name = $metadata['bp_type_name'];
545
- }
546
- }
547
-
548
- echo esc_html( $type_plural_name );
549
-
550
- // Set the Totals column.
551
- } elseif ( 'counts' === $column_name ) {
552
- global $parent_file;
553
- $type = bp_get_term_by( 'id', $type_id, $this->taxonomy );
554
- if ( 0 === (int) $type->count ) {
555
- return 0;
556
- }
557
-
558
- // Format the count.
559
- $count = number_format_i18n( $type->count );
560
-
561
- $args = array(
562
- str_replace( '_', '-', $this->taxonomy ) => $type->slug,
563
- );
564
-
565
- $base_url = $parent_file;
566
- if ( false === strpos( $parent_file, '.php' ) ) {
567
- $base_url = add_query_arg( 'page', $parent_file, 'admin.php' );
568
- }
569
-
570
- printf(
571
- '<a href="%1$s">%2$s</a>',
572
- esc_url( add_query_arg( $args, bp_get_admin_url( $base_url ) ) ),
573
- esc_html( $count )
574
- );
575
- }
576
- }
577
-
578
- /**
579
- * Customizes the Types Admin list table row actions.
580
- *
581
- * @since 7.0.0
582
- *
583
- * @param array $actions The table row actions.
584
- * @param WP_Term $type The current BP Type for the row.
585
- * @return array The table row actions for the current BP type.
586
- */
587
- public function row_actions( $actions = array(), $type = null ) {
588
- if ( ! isset( $type->taxonomy ) || ! $type->taxonomy ) {
589
- return $actions;
590
- }
591
-
592
- /**
593
- * Filter here to set the types "registered by code".
594
- *
595
- * @see bp_get_member_types_registered_by_code() for an example of use.
596
- *
597
- * @since 7.0.0
598
- */
599
- $registered_by_code_types = apply_filters( "{$type->taxonomy}_registered_by_code", array() );
600
-
601
- // Types registered by code cannot be deleted as long as the custom registration code exists.
602
- if ( isset( $registered_by_code_types[ $type->name ] ) ) {
603
- unset( $actions['delete'] );
604
- }
605
-
606
- // Inline edits are disabled for all types.
607
- unset( $actions['inline hide-if-no-js'] );
608
-
609
- // Removes the post type query argument for the edit action.
610
- if ( isset( $actions['edit'] ) ) {
611
- $actions['edit'] = str_replace( '&#038;post_type=post', '', $actions['edit'] );
612
- }
613
-
614
- return $actions;
615
- }
616
- }
617
-
618
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/classes/class-bp-admin.php CHANGED
@@ -123,7 +123,6 @@ class BP_Admin {
123
  require( $this->admin_dir . 'bp-core-admin-components.php' );
124
  require( $this->admin_dir . 'bp-core-admin-slugs.php' );
125
  require( $this->admin_dir . 'bp-core-admin-tools.php' );
126
- require( $this->admin_dir . 'bp-core-admin-optouts.php' );
127
  }
128
 
129
  /**
@@ -156,8 +155,8 @@ class BP_Admin {
156
  // Add settings.
157
  add_action( 'bp_register_admin_settings', array( $this, 'register_admin_settings' ) );
158
 
159
- // Add a link to BuddyPress Hello in the admin bar.
160
- add_action( 'admin_bar_menu', array( $this, 'admin_bar_about_link' ), 100 );
161
 
162
  // Add a description of new BuddyPress tools in the available tools page.
163
  add_action( 'tool_box', 'bp_core_admin_available_tools_intro' );
@@ -170,15 +169,6 @@ class BP_Admin {
170
  add_filter( 'manage_' . bp_get_email_post_type() . '_posts_columns', array( $this, 'emails_register_situation_column' ) );
171
  add_action( 'manage_' . bp_get_email_post_type() . '_posts_custom_column', array( $this, 'emails_display_situation_column_data' ), 10, 2 );
172
 
173
- // Privacy Policy.
174
- add_action( 'bp_admin_init', array( $this, 'add_privacy_policy_content' ) );
175
-
176
- // BuddyPress Hello.
177
- add_action( 'admin_footer', array( $this, 'about_screen' ) );
178
-
179
- // BuddyPress Types administration.
180
- add_action( 'load-edit-tags.php', array( 'BP_Admin_Types', 'register_types_admin' ) );
181
-
182
  /* Filters ***********************************************************/
183
 
184
  // Add link to settings page.
@@ -207,6 +197,24 @@ class BP_Admin {
207
  return;
208
  }
209
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  $hooks = array();
211
 
212
  // Changed in BP 1.6 . See bp_core_admin_backpat_menu().
@@ -256,16 +264,6 @@ class BP_Admin {
256
  'bp_core_admin_settings'
257
  );
258
 
259
- // Credits.
260
- $hooks[] = add_submenu_page(
261
- $this->settings_page,
262
- __( 'BuddyPress Credits', 'buddypress' ),
263
- __( 'BuddyPress Credits', 'buddypress' ),
264
- $this->capability,
265
- 'bp-credits',
266
- array( $this, 'credits_screen' )
267
- );
268
-
269
  // For consistency with non-Multisite, we add a Tools menu in
270
  // the Network Admin as a home for our Tools panel.
271
  if ( is_multisite() && bp_core_do_network_admin() ) {
@@ -302,15 +300,6 @@ class BP_Admin {
302
  'bp_core_admin_tools'
303
  );
304
 
305
- $hooks[] = add_submenu_page(
306
- $tools_parent,
307
- __( 'Manage Opt-outs', 'buddypress' ),
308
- __( 'Manage Opt-outs', 'buddypress' ),
309
- $this->capability,
310
- 'bp-optouts',
311
- 'bp_core_optouts_admin'
312
- );
313
-
314
  // For network-wide configs, add a link to (the root site's) Emails screen.
315
  if ( is_network_admin() && bp_is_network_activated() ) {
316
  $email_labels = bp_get_email_post_type_labels();
@@ -347,24 +336,27 @@ class BP_Admin {
347
 
348
  $hooks = array();
349
 
350
- // Appearance > Emails.
351
- $hooks[] = add_theme_page(
352
- _x( 'Emails', 'screen heading', 'buddypress' ),
353
- _x( 'Emails', 'screen heading', 'buddypress' ),
354
- $this->capability,
355
- 'bp-emails-customizer-redirect',
356
- 'bp_email_redirect_to_customizer'
357
- );
 
 
358
 
359
- // Emails > Customize.
360
- $hooks[] = add_submenu_page(
361
- 'edit.php?post_type=' . bp_get_email_post_type(),
362
- _x( 'Customize', 'email menu label', 'buddypress' ),
363
- _x( 'Customize', 'email menu label', 'buddypress' ),
364
- $this->capability,
365
- 'bp-emails-customizer-redirect',
366
- 'bp_email_redirect_to_customizer'
367
- );
 
368
 
369
  foreach( $hooks as $hook ) {
370
  add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' );
@@ -388,35 +380,25 @@ class BP_Admin {
388
  add_settings_field( 'hide-loggedout-adminbar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_admin_bar', 'buddypress', 'bp_main' );
389
  register_setting( 'buddypress', 'hide-loggedout-adminbar', 'intval' );
390
 
 
 
 
 
 
 
 
 
 
 
 
391
  // Allow account deletion.
392
  add_settings_field( 'bp-disable-account-deletion', __( 'Account Deletion', 'buddypress' ), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main' );
393
  register_setting( 'buddypress', 'bp-disable-account-deletion', 'intval' );
394
 
395
  // Template pack picker.
396
- add_settings_field( '_bp_theme_package_id', __( 'Template Pack', 'buddypress' ), 'bp_admin_setting_callback_theme_package_id', 'buddypress', 'bp_main', array( 'label_for' => '_bp_theme_package_id' ) );
397
  register_setting( 'buddypress', '_bp_theme_package_id', 'sanitize_text_field' );
398
 
399
- /* Members Section **************************************************/
400
-
401
- // Add the main section.
402
- add_settings_section( 'bp_members', _x( 'Members Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_members_section', 'buddypress' );
403
-
404
- // Avatars.
405
- add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', 'bp_members' );
406
- register_setting( 'buddypress', 'bp-disable-avatar-uploads', 'intval' );
407
-
408
- // Cover images.
409
- if ( bp_is_active( 'members', 'cover_image' ) ) {
410
- add_settings_field( 'bp-disable-cover-image-uploads', __( 'Cover Image Uploads', 'buddypress' ), 'bp_admin_setting_callback_cover_image_uploads', 'buddypress', 'bp_members' );
411
- register_setting( 'buddypress', 'bp-disable-cover-image-uploads', 'intval' );
412
- }
413
-
414
- // Community Invitations.
415
- if ( bp_is_active( 'members', 'invitations' ) ) {
416
- add_settings_field( 'bp-enable-members-invitations', __( 'Invitations', 'buddypress' ), 'bp_admin_setting_callback_members_invitations', 'buddypress', 'bp_members' );
417
- register_setting( 'buddypress', 'bp-enable-members-invitations', 'intval' );
418
- }
419
-
420
  /* XProfile Section **************************************************/
421
 
422
  if ( bp_is_active( 'xprofile' ) ) {
@@ -424,6 +406,16 @@ class BP_Admin {
424
  // Add the main section.
425
  add_settings_section( 'bp_xprofile', _x( 'Profile Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress' );
426
 
 
 
 
 
 
 
 
 
 
 
427
  // Profile sync setting.
428
  add_settings_field( 'bp-disable-profile-sync', __( 'Profile Syncing', 'buddypress' ), 'bp_admin_setting_callback_profile_sync', 'buddypress', 'bp_xprofile' );
429
  register_setting ( 'buddypress', 'bp-disable-profile-sync', 'intval' );
@@ -451,6 +443,18 @@ class BP_Admin {
451
  }
452
  }
453
 
 
 
 
 
 
 
 
 
 
 
 
 
454
  /* Activity Section **************************************************/
455
 
456
  if ( bp_is_active( 'activity' ) ) {
@@ -458,8 +462,8 @@ class BP_Admin {
458
  // Add the main section.
459
  add_settings_section( 'bp_activity', __( 'Activity Settings', 'buddypress' ), 'bp_admin_setting_callback_activity_section', 'buddypress' );
460
 
461
- // Activity commenting on post and comments.
462
- add_settings_field( 'bp-disable-blogforum-comments', __( 'Post Comments', 'buddypress' ), 'bp_admin_setting_callback_blogforum_comments', 'buddypress', 'bp_activity' );
463
  register_setting( 'buddypress', 'bp-disable-blogforum-comments', 'bp_admin_sanitize_callback_blogforum_comments' );
464
 
465
  // Activity Heartbeat refresh.
@@ -475,27 +479,21 @@ class BP_Admin {
475
  }
476
 
477
  /**
478
- * Add a link to BuddyPress Hello to the admin bar.
479
  *
480
  * @since 1.9.0
481
- * @since 3.0.0 Hooked at priority 100 (was 15).
482
  *
483
- * @param WP_Admin_Bar $wp_admin_bar
484
  */
485
  public function admin_bar_about_link( $wp_admin_bar ) {
486
- if ( ! is_user_logged_in() ) {
487
- return;
 
 
 
 
 
488
  }
489
-
490
- $wp_admin_bar->add_node( array(
491
- 'parent' => 'wp-logo',
492
- 'id' => 'bp-about',
493
- 'title' => esc_html_x( 'Hello, BuddyPress!', 'Colloquial alternative to "learn about BuddyPress"', 'buddypress' ),
494
- 'href' => bp_get_admin_url( '?hello=buddypress' ),
495
- 'meta' => array(
496
- 'class' => 'say-hello-buddypress',
497
- ),
498
- ) );
499
  }
500
 
501
  /**
@@ -517,7 +515,7 @@ class BP_Admin {
517
  // Add a few links to the existing links array.
518
  return array_merge( $links, array(
519
  'settings' => '<a href="' . esc_url( add_query_arg( array( 'page' => 'bp-components' ), bp_get_admin_url( $this->settings_page ) ) ) . '">' . esc_html__( 'Settings', 'buddypress' ) . '</a>',
520
- 'about' => '<a href="' . esc_url( bp_get_admin_url( '?hello=buddypress' ) ) . '">' . esc_html_x( 'Hello, BuddyPress!', 'Colloquial alternative to "learn about BuddyPress"', 'buddypress' ) . '</a>'
521
  ) );
522
  }
523
 
@@ -531,7 +529,6 @@ class BP_Admin {
531
  // Settings pages.
532
  remove_submenu_page( $this->settings_page, 'bp-page-settings' );
533
  remove_submenu_page( $this->settings_page, 'bp-settings' );
534
- remove_submenu_page( $this->settings_page, 'bp-credits' );
535
 
536
  // Network Admin Tools.
537
  remove_submenu_page( 'network-tools', 'network-tools' );
@@ -539,13 +536,6 @@ class BP_Admin {
539
  // About and Credits pages.
540
  remove_submenu_page( 'index.php', 'bp-about' );
541
  remove_submenu_page( 'index.php', 'bp-credits' );
542
-
543
- // Nonmembers Opt-outs page.
544
- if ( is_network_admin() ) {
545
- remove_submenu_page( 'network-tools', 'bp-optouts' );
546
- } else {
547
- remove_submenu_page( 'tools.php', 'bp-optouts' );
548
- }
549
  }
550
 
551
  /**
@@ -555,247 +545,156 @@ class BP_Admin {
555
  */
556
  public function enqueue_scripts() {
557
  wp_enqueue_style( 'bp-admin-common-css' );
558
-
559
- // BuddyPress Hello.
560
- if ( 0 === strpos( get_current_screen()->id, 'dashboard' ) && ! empty( $_GET['hello'] ) && $_GET['hello'] === 'buddypress' ) {
561
- wp_enqueue_style( 'bp-hello-css' );
562
- wp_enqueue_script( 'bp-hello-js' );
563
- wp_localize_script( 'bp-hello-js', 'bpHelloStrings', array(
564
- 'pageNotFound' => __( 'Sorry, the page you requested was not found.', 'buddypress' ),
565
- 'modalLabel' => __( 'Hello BuddyPress', 'buddypress' ),
566
- ) );
567
- }
568
  }
569
 
 
 
570
  /**
571
- * Registers BuddyPress's suggested privacy policy language.
572
  *
573
- * @since 4.0.0
574
  */
575
- public function add_privacy_policy_content() {
576
- // Nothing to do if we're running < WP 4.9.6.
577
- if ( bp_is_running_wp( '4.9.6', '<' ) ) {
578
- return;
579
- }
580
-
581
- $suggested_text = '<strong class="privacy-policy-tutorial">' . esc_html__( 'Suggested text:', 'buddypress' ) . ' </strong>';
582
- $content = '';
583
-
584
- $content .= '<div class="wp-suggested-text">';
585
-
586
- $content .= '<h2>' . esc_html__( 'What personal data we collect and why we collect it', 'buddypress' ) . '</h2>';
587
- $content .= '<p class="privacy-policy-tutorial">' . esc_html__( 'Sites powered by BuddyPress rely heavily on user-provided data. In this section, you should note what data you collect, from both registered users and anonymous visitors.', 'buddypress' ) . '</p>';
588
-
589
- if ( bp_is_active( 'xprofile' ) ) {
590
- $content .= '<h3>' . esc_html__( 'Profile Data', 'buddypress' ) . '</h3>';
591
- $content .= '<p class="privacy-policy-tutorial">' . esc_html__( 'In this section you should note what information is collected on user profiles. The suggested text gives an overview of the kinds of profile data collected by BuddyPress.', 'buddypress' ) . '</p>';
592
-
593
- $content .= '<p>' . $suggested_text . esc_html__( 'When you register for the site, you may be asked to provide certain personal data for display on your profile. The "Name" field is required as well as public, and user profiles are visible to any site visitor. Other profile information may be required or optional, as configured by the site administrator.', 'buddypress' ) . '</p>';
594
- $content .= '<p>' . esc_html__( 'User information provided during account registration can be modified or removed on the Profile > Edit panel. In most cases, users also have control over who is able to view a particular piece of profile content, limiting visibility on a field-by-field basis to friends, logged-in users, or administrators only. Site administrators can read and edit all profile data for all users.', 'buddypress' ) . '</p>';
595
- }
596
-
597
- if ( bp_is_active( 'activity' ) ) {
598
- $content .= '<h3>' . esc_html__( 'Activity', 'buddypress' ) . '</h3>';
599
- $content .= '<p class="privacy-policy-tutorial">' . esc_html__( 'In this section you should describe the kinds of information collected in the activity stream, how and whether it can be edited or deleted, and to whom the activity is visible.', 'buddypress' ) . '</p>';
600
 
601
- $content .= '<p>' . $suggested_text . esc_html__( 'This site records certain user actions, in the form of "activity" data. Activity includes updates and comments posted directly to activity streams, as well as descriptions of other actions performed while using the site, such as new friendships, newly joined groups, and profile updates.', 'buddypress' ) . '</p>';
602
- $content .= '<p>' . esc_html__( 'The content of activity items obey the same privacy rules as the contexts in which the activity items are created. For example, activity updates created in a user\'s profile is publicly visible, while activity items generated in a private group are visible only to members of that group. Site administrators can view all activity items, regardless of context.', 'buddypress' ) . '</p>';
603
- $content .= '<p>' . esc_html__( 'Activity items may be deleted at any time by users who created them. Site administrators can edit all activity items.', 'buddypress' ) . '</p>';
604
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
605
 
606
- if ( bp_is_active( 'messages' ) ) {
607
- $content .= '<h3>' . esc_html__( 'Messages', 'buddypress' ) . '</h3>';
608
- $content .= '<p class="privacy-policy-tutorial">' . esc_html__( 'In this section you should describe any personal data related to private messages.', 'buddypress' ) . '</p>';
609
 
610
- $content .= '<p>' . $suggested_text . esc_html__( 'The content of private messages is visible only to the sender and the recipients of the message. With the exception of site administrators, who can read all private messages, private message content is never visible to other users or site visitors. Site administrators may delete the content of any message.', 'buddypress' ) . '</p>';
611
- }
612
 
613
- $content .= '<h3>' . esc_html__( 'Cookies', 'buddypress' ) . '</h3>';
614
- $content .= '<p class="privacy-policy-tutorial">' . esc_html__( 'In this section you should describe the BuddyPress-specific cookies that your site collects. The suggested text describes the default cookies.', 'buddypress' ) . '</p>';
615
 
616
- $content .= '<p>' . $suggested_text . esc_html__( 'We use a cookie to show success and failure messages to logged-in users, in response to certain actions, like joining a group. These cookies contain no personal data, and are deleted immediately after the next page load.', 'buddypress' ) . '</p>';
 
 
 
 
617
 
618
- $content .= '<p>' . esc_html__( 'We use cookies on group, member, and activity directories to keep track of a user\'s browsing preferences. These preferences include the last-selected values of the sort and filter dropdowns, as well as pagination information. These cookies contain no personal data, and are deleted after 24 hours.', 'buddypress' ) . '</p>';
 
 
 
 
619
 
620
- if ( bp_is_active( 'groups' ) ) {
621
- $content .= '<p>' . esc_html__( 'When a logged-in user creates a new group, we use a number of cookies to keep track of the group creation process. These cookies contain no personal data, and are deleted either upon the successful creation of the group or after 24 hours.', 'buddypress' ) . '</p>';
622
- }
 
 
623
 
624
- $content .= '</div><!-- .wp-suggested-text -->';
 
 
625
 
626
- wp_add_privacy_policy_content(
627
- 'BuddyPress',
628
- wp_kses_post( wpautop( $content, false ) )
629
- );
630
- }
631
 
632
- /** About *****************************************************************/
633
 
634
- /**
635
- * Output the BuddyPress Hello template.
636
- *
637
- * @since 1.7.0 Screen content.
638
- * @since 3.0.0 Now outputs BuddyPress Hello template.
639
- */
640
- public function about_screen() {
641
- if ( 0 !== strpos( get_current_screen()->id, 'dashboard' ) || empty( $_GET['hello'] ) || $_GET['hello'] !== 'buddypress' ) {
642
- return;
643
- }
644
 
645
- // Get BuddyPress stable version.
646
- $version = self::display_version();
647
- $version_slug = 'version-' . str_replace( '.', '-', $version );
648
- ?>
 
 
 
 
 
 
649
 
650
- <div id="bp-hello-container">
651
- <div id="plugin-information-scrollable" role="document">
652
- <div id='plugin-information-title' class="with-banner">
653
- <div class='vignette'></div>
654
- <h1>
655
- <?php printf(
656
- /* translators: %s is the placeholder for the BuddyPress version number. */
657
- esc_html__( 'BuddyPress %s', 'buddypress' ),
658
- $version
659
- ); ?>
660
- </h1>
661
- </div>
662
- <div id="plugin-information-tabs">
663
- <a name="whats-new" href="#whats-new" class="current"><?php esc_html_e( 'What\'s new?', 'buddypress' ); ?></a>
664
- <a name="changelog" href="#changelog" class="dynamic" data-slug="<?php echo esc_attr( $version_slug ); ?>" data-endpoint="https://codex.buddypress.org/wp-json/wp/v2/pages"><?php esc_html_e( 'Changelog', 'buddypress' ); ?></a>
665
- <a name="get-involved" href="#get-involved" class="dynamic" data-slug="participate-and-contribute" data-endpoint="https://codex.buddypress.org/wp-json/wp/v2/pages"><?php esc_html_e( 'Get involved', 'buddypress' ); ?></a>
666
  </div>
667
 
668
- <div class="bp-hello-content">
669
- <div id="dynamic-content"></div>
670
- <div id="top-features">
671
- <h2><?php esc_html_e( 'It’s all about Widget Blocks!', 'buddypress' ); ?></h2>
672
- <figure class="bp-hello-aligncenter">
673
- <img src="<?php echo esc_url( buddypress()->plugin_url . 'bp-core/images/latest-activities.jpg' ); ?>" alt="<?php esc_attr_e( 'Illustration showing the Latest Activities Widget Block.', 'buddypress' ); ?>" />
674
- </figure>
675
- <p>
676
- <?php esc_html_e( 'WordPress 5.8 is right around the corner and debuts a brand new way to manage widgets: the Widget Block Editor. With BuddyPress 9.0.0, we have introduced 10 new BuddyPress Blocks, so you can continue to use your favorite BP Widgets with the new WP Block approach.', 'buddypress' ); ?>
677
- </p>
678
- <p>
679
- <?php esc_html_e( 'The new BP Widget Blocks are simply Legacy Widgets we’ve rebuilt as BP Blocks, which means you can also access them in the Block Editor for use in your posts or pages!', 'buddypress' ); ?>
680
- </p>
681
- <figure class="bp-hello-aligncenter">
682
- <img src="<?php echo esc_url( buddypress()->plugin_url . 'bp-core/images/bp-widget-blocks.jpg' ); ?>" alt="<?php esc_attr_e( 'Illustration showing BP Blocks collection.', 'buddypress' ); ?>" />
683
- </figure>
684
- <p>
685
- <em><?php esc_html_e( 'PS: Have you noticed that the icons for BuddyPress Blocks are now bright red?', 'buddypress' ); ?></em>
686
- </p>
687
- <h3>
688
- <?php
689
- printf(
690
- /* Translators: %s is a smiling face with sunglasses emoji. */
691
- esc_html__( 'Convert a Legacy Widget into a Block Widget in two clicks %s', 'buddypress' ),
692
- wp_staticize_emoji( '😎' )
693
- );
694
- ?>
695
- </h3>
696
- <figure class="bp-hello-aligncenter">
697
- <img src="<?php echo esc_url( buddypress()->plugin_url . 'bp-core/images/legacy-widget-to-block.jpg' ); ?>" alt="<?php esc_attr_e( 'Illustration showing the Legacy Widget to Widget Block transformation.', 'buddypress' ); ?>" />
698
- </figure>
699
- <p>
700
- <?php esc_html_e( 'As shown in the image above, it’s very easy to transform a Widget into a Block. Your existing Widget settings will automagically be imported into your shiny, new BP Block.', 'buddypress' ); ?>
701
- </p>
702
- <p>
703
- <?php esc_html_e( 'NB: Creating a BP Block for each existing BP Legacy Widget marks the first step toward the progressive retirement of these tiny pieces of BuddyPress content.', 'buddypress' ); ?>
704
- </p>
705
-
706
- <hr class="bp-hello-divider"/>
707
-
708
- <h2><?php esc_html_e( 'The BP REST API: Improved endpoints and a new one!', 'buddypress' ); ?></h2>
709
- <p>
710
- <?php esc_html_e( 'This BuddyPress release was built in a short time frame to be ready for the release of WordPress 5.8.', 'buddypress' ); ?>
711
- </p>
712
- <p>
713
- <?php esc_html_e( 'While doing the work on BP Widget Blocks, we’ve also manipulated many of our REST API endpoints and took this opportunity to improve several of them. We’re also introducing a new Sitewide Notices endpoint to allow site admins to create, edit, or delete notices and let all of your users fetch the active notice.', 'buddypress' ); ?>
714
- </p>
715
-
716
- <hr class="bp-hello-divider"/>
717
-
718
- <h2><?php esc_html_e( 'Under the hood', 'buddypress' ); ?></h2>
719
- <p>
720
- <?php esc_html_e( '9.0.0 comes with fewer changes than most of our releases but includes fixes for issues which appeared in 8.0.0 and BP Nouveau Template Pack improvements.', 'buddypress' ); ?>
721
- <?php esc_html_e( 'Click on the "Changelog" tab to discover them all!', 'buddypress' ); ?>
722
- </p>
723
- <figure class="bp-hello-aligncenter">
724
- <div class="dashicons dashicons-buddicons-buddypress-logo big"></div>
725
- </figure>
726
-
727
- <hr class="bp-hello-divider"/>
728
-
729
- <h2><?php echo esc_html( _x( 'Your feedback', 'screen heading', 'buddypress' ) ); ?></h2>
730
- <p>
731
- <?php esc_html_e( 'How are you using BuddyPress? Receiving your feedback and suggestions for future versions of BuddyPress genuinely motivates and encourages our contributors.', 'buddypress' ); ?>
732
- <?php
733
- printf(
734
- /* translators: %s is the placeholder for the link to BuddyPress support forums. */
735
- esc_html__( 'Please %s about this version of BuddyPress on our website.', 'buddypress' ),
736
- sprintf(
737
- '<a href="%1$s">%2$s</a>',
738
- esc_url( 'https://buddypress.org/support/' ),
739
- esc_html__( 'share your feedback', 'buddypress' )
740
- )
741
- );
742
- ?>
743
- </p>
744
- <p>
745
- <?php
746
- printf(
747
- /* Translators: %s is a hugging face emoji. */
748
- esc_html__( 'Thank you for using BuddyPress! %s', 'buddypress' ),
749
- wp_staticize_emoji( '🤗' )
750
- );
751
- ?>
752
- </p>
753
-
754
- <br /><br />
755
  </div>
756
  </div>
 
757
  </div>
758
- <div id="plugin-information-footer">
759
- <div class="bp-hello-social-cta">
760
- <p>
761
- <?php
762
- printf(
763
- /* translators: 1: heart dashicons. 2: BP Credits screen url. 3: number of BuddyPress contributors to this version. */
764
- _n( 'Built with %1$s by <a href="%2$s">%3$d volunteer</a>.', 'Built with %1$s by <a href="%2$s">%3$d volunteers</a>.', 24, 'buddypress' ),
765
- '<span class="dashicons dashicons-heart"></span>',
766
- esc_url( bp_get_admin_url( 'admin.php?page=bp-credits' ) ),
767
- number_format_i18n( 24 )
768
- );
769
- ?>
770
- </p>
771
- </div>
772
 
773
- <div class="bp-hello-social-links">
774
- <ul class="bp-hello-social">
775
- <li>
776
- <?php
777
- printf(
778
- '<a class="twitter bp-tooltip" data-bp-tooltip="%1$s" href="%2$s"><span class="screen-reader-text">%3$s</span></a>',
779
- esc_attr__( 'Follow BuddyPress on Twitter', 'buddypress' ),
780
- esc_url( 'https://twitter.com/buddypress' ),
781
- esc_html__( 'Follow BuddyPress on Twitter', 'buddypress' )
782
- );
783
- ?>
784
- </li>
785
-
786
- <li>
787
- <?php
788
- printf(
789
- '<a class="support bp-tooltip" data-bp-tooltip="%1$s" href="%2$s"><span class="screen-reader-text">%3$s</span></a>',
790
- esc_attr__( 'Visit the Support Forums', 'buddypress' ),
791
- esc_url( 'https://buddypress.org/support/' ),
792
- esc_html__( 'Visit the Support Forums', 'buddypress' )
793
- );
794
- ?>
795
- </li>
796
- </ul>
797
- </div>
798
  </div>
 
799
  </div>
800
 
801
  <?php
@@ -812,165 +711,168 @@ class BP_Admin {
812
  public function credits_screen() {
813
  ?>
814
 
815
- <div class="wrap bp-about-wrap">
816
 
817
- <h1 class="wp-heading-inline"><?php esc_html_e( 'BuddyPress Settings', 'buddypress' ); ?></h1>
818
- <hr class="wp-header-end">
819
 
820
- <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( esc_html__( 'Credits', 'buddypress' ) ); ?></h2>
821
 
822
- <p class="about-description"><?php esc_html_e( 'Meet the contributors behind BuddyPress:', 'buddypress' ); ?></p>
823
 
824
- <h3 class="wp-people-group"><?php esc_html_e( 'Project Leaders', 'buddypress' ); ?></h3>
825
  <ul class="wp-people-group " id="wp-people-group-project-leaders">
826
  <li class="wp-person" id="wp-person-johnjamesjacoby">
827
- <a class="web" href="https://profiles.wordpress.org/johnjamesjacoby"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/7a2644fb53ae2f7bfd7143b504af396c?s=120">
828
  John James Jacoby</a>
829
- <span class="title"><?php esc_html_e( 'Project Lead', 'buddypress' ); ?></span>
830
  </li>
831
  <li class="wp-person" id="wp-person-boonebgorges">
832
- <a class="web" href="https://profiles.wordpress.org/boonebgorges"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/9cf7c4541a582729a5fc7ae484786c0c?s=120">
833
  Boone B. Gorges</a>
834
- <span class="title"><?php esc_html_e( 'Lead Developer', 'buddypress' ); ?></span>
835
  </li>
836
  <li class="wp-person" id="wp-person-djpaul">
837
- <a class="web" href="https://profiles.wordpress.org/djpaul"><img alt="" class="gravatar" src="https://avatars2.githubusercontent.com/u/1275914?s=120">
838
  Paul Gibbs</a>
839
- <span class="title"><?php esc_html_e( 'Lead Developer', 'buddypress' ); ?></span>
 
 
 
 
 
 
 
 
 
840
  </li>
841
  <li class="wp-person" id="wp-person-r-a-y">
842
- <a class="web" href="https://profiles.wordpress.org/r-a-y"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/3bfa556a62b5bfac1012b6ba5f42ebfa?s=120">
843
  Ray</a>
844
- <span class="title"><?php esc_html_e( 'Lead Developer', 'buddypress' ); ?></span>
845
  </li>
846
  <li class="wp-person" id="wp-person-imath">
847
- <a class="web" href="https://profiles.wordpress.org/imath"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/8b208ca408dad63888253ee1800d6a03?s=120">
848
  Mathieu Viet</a>
849
- <span class="title"><?php esc_html_e( 'Lead Developer', 'buddypress' ); ?></span>
850
  </li>
851
  <li class="wp-person" id="wp-person-mercime">
852
- <a class="web" href="https://profiles.wordpress.org/mercime"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/fae451be6708241627983570a1a1817a?s=120">
853
  Mercime</a>
854
- <span class="title"><?php esc_html_e( 'Lead Developer', 'buddypress' ); ?></span>
855
- </li>
856
- </ul>
857
-
858
- <h3 class="wp-people-group"><?php esc_html_e( 'BuddyPress Team', 'buddypress' ); ?></h3>
859
- <ul class="wp-people-group " id="wp-people-group-core-team">
860
- <li class="wp-person" id="wp-person-hnla">
861
- <a class="web" href="https://profiles.wordpress.org/hnla"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/3860c955aa3f79f13b92826ae47d07fe?s=120">
862
- Hugo Ashmore</a>
863
- <span class="title"><?php esc_html_e( 'Core Developer', 'buddypress' ); ?></span>
864
  </li>
865
  <li class="wp-person" id="wp-person-dcavins">
866
- <a class="web" href="https://profiles.wordpress.org/dcavins"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/a5fa7e83d59cb45ebb616235a176595a?s=120">
867
  David Cavins</a>
868
- <span class="title"><?php esc_html_e( 'Core Developer', 'buddypress' ); ?></span>
869
  </li>
870
  <li class="wp-person" id="wp-person-tw2113">
871
- <a class="web" href="https://profiles.wordpress.org/tw2113"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/a5d7c934621fa1c025b83ee79bc62366?s=120">
872
  Michael Beckwith</a>
873
- <span class="title"><?php esc_html_e( 'Core Developer', 'buddypress' ); ?></span>
874
  </li>
875
  <li class="wp-person" id="wp-person-henry-wright">
876
- <a class="web" href="https://profiles.wordpress.org/henry.wright"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/0da2f1a9340d6af196b870f6c107a248?s=120">
877
  Henry Wright</a>
878
- <span class="title"><?php esc_html_e( 'Community Support', 'buddypress' ); ?></span>
879
  </li>
880
  <li class="wp-person" id="wp-person-danbp">
881
- <a class="web" href="https://profiles.wordpress.org/danbp"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/0deae2e7003027fbf153500cd3fa5501?s=120">
882
  danbp</a>
883
- <span class="title"><?php esc_html_e( 'Community Support', 'buddypress' ); ?></span>
884
  </li>
885
  <li class="wp-person" id="wp-person-shanebp">
886
- <a class="web" href="https://profiles.wordpress.org/shanebp"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/ffd294ab5833ba14aaf175f9acc71cc4?s=120">
887
  shanebp</a>
888
- <span class="title"><?php esc_html_e( 'Community Support', 'buddypress' ); ?></span>
889
  </li>
890
  <li class="wp-person" id="wp-person-slaffik">
891
- <a class="web" href="https://profiles.wordpress.org/r-a-y"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/61fb07ede3247b63f19015f200b3eb2c?s=120">
892
  Slava Abakumov</a>
893
- <span class="title"><?php esc_html_e( 'Core Developer', 'buddypress' ); ?></span>
894
  </li>
895
  <li class="wp-person" id="wp-person-offereins">
896
- <a class="web" href="https://profiles.wordpress.org/Offereins"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/2404ed0a35bb41aedefd42b0a7be61c1?s=120">
897
  Laurens Offereins</a>
898
- <span class="title"><?php esc_html_e( 'Core Developer', 'buddypress' ); ?></span>
899
  </li>
900
  <li class="wp-person" id="wp-person-netweb">
901
- <a class="web" href="https://profiles.wordpress.org/netweb"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/97e1620b501da675315ba7cfb740e80f?s=120">
902
  Stephen Edgar</a>
903
- <span class="title"><?php esc_html_e( 'Core Developer', 'buddypress' ); ?></span>
904
- </li>
905
- <li class="wp-person" id="wp-person-espellcaste">
906
- <a class="web" href="https://profiles.wordpress.org/espellcaste"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/b691e67be0ba5cad6373770656686bc3?s=120">
907
- Renato Alves</a>
908
- <span class="title"><?php esc_html_e( 'Core Developer', 'buddypress' ); ?></span>
909
- </li>
910
- <li class="wp-person" id="wp-person-venutius">
911
- <a class="web" href="https://profiles.wordpress.org/venutius"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/6a7c42a77fd94b82b217a7a97afdddbc?s=120">
912
- Venutius</a>
913
- <span class="title"><?php esc_html_e( 'Community Support', 'buddypress' ); ?></span>
914
  </li>
915
  </ul>
916
 
917
- <h3 class="wp-people-group">
918
- <?php
919
- printf(
920
- /* translators: %s: BuddyPress version number */
921
- esc_html__( 'Noteworthy Contributors to %s', 'buddypress' ),
922
- self::display_version()
923
- );
924
- ?>
925
- </h3>
926
- <ul class="wp-people-group " id="wp-people-group-noteworthy">
927
- <li class="wp-person" id="wp-person-vapvarun">
928
- <a class="web" href="https://profiles.wordpress.org/vapvarun"><img alt="" class="gravatar" src="//gravatar.com/avatar/78a3bf7eb3a1132fc667f96f2631e448?s=120">
929
- Varun Dubey</a>
930
  </li>
931
- <li class="wp-person" id="wp-person-sbrajesh">
932
- <a class="web" href="https://profiles.wordpress.org/sbrajesh/"><img alt="" class="gravatar" src="//gravatar.com/avatar/2106622ee90d53d15ac1402806616aca?s=120">
933
- Brajesh Singh</a>
934
  </li>
935
  </ul>
936
 
937
- <h3 class="wp-people-group">
938
- <?php
939
- printf(
940
- /* translators: %s: BuddyPress version number */
941
- esc_html__( 'All Contributors to BuddyPress %s', 'buddypress' ),
942
- self::display_version()
943
- );
944
- ?>
945
- </h3>
946
  <p class="wp-credits-list">
 
 
 
 
 
947
  <a href="https://profiles.wordpress.org/boonebgorges/">Boone B Gorges (boonebgorges)</a>,
 
948
  <a href="https://profiles.wordpress.org/sbrajesh/">Brajesh Singh (sbrajesh)</a>,
 
 
 
949
  <a href="https://profiles.wordpress.org/dcavins/">David Cavins (dcavins)</a>,
950
- <a href="https://profiles.wordpress.org/dancaragea/">Dan Caragea (dancaragea)</a>,
951
- <a href="https://profiles.wordpress.org/ianbarnes/">Ian Barnes (ianbarnes)</a>,
952
- <a href="https://profiles.wordpress.org/nobnob/">Javier Esteban (nobnob)</a>,
 
 
 
 
 
953
  <a href="https://profiles.wordpress.org/johnjamesjacoby/">John James Jacoby (johnjamesjacoby)</a>,
954
- <a href="https://profiles.wordpress.org/leahkoerper/">leahkoerper</a>,
955
- <a href="https://profiles.wordpress.org/marbaque/">marbaque</a>,
956
- <a href="https://profiles.wordpress.org/markscottrobson/">Mark Robson (markscottrobson)</a>,
 
 
 
957
  <a href="https://profiles.wordpress.org/imath/">Mathieu Viet (imath)</a>,
 
 
 
 
958
  <a href="https://profiles.wordpress.org/modemlooper/">modemlooper</a>,
959
- <a href="https://profiles.wordpress.org/niftythree/">Nifty (niftythree)</a>,
 
 
960
  <a href="https://profiles.wordpress.org/DJPaul/">Paul Gibbs (DJPaul)</a>,
961
- <a href="https://profiles.wordpress.org/nekojonez/">Pieterjan Deneys (nekojonez)</a>,
962
  <a href="https://profiles.wordpress.org/r-a-y/">r-a-y</a>,
963
  <a href="https://profiles.wordpress.org/espellcaste/">Renato Alves (espellcaste)</a>,
964
- <a href="https://profiles.wordpress.org/shanebp">shanebp</a>,
965
- <a href="https://profiles.wordpress.org/shawfactor/">shawfactor</a>,
 
966
  <a href="https://profiles.wordpress.org/slaffik/">Slava Abakumov (slaffik)</a>,
967
  <a href="https://profiles.wordpress.org/netweb/">Stephen Edgar (netweb)</a>,
968
- <a href="https://profiles.wordpress.org/tamarazambrana/">tamarazambrana</a>,
969
- <a href="https://github.com/tkserver">TKServer</a>,
970
- <a href="https://profiles.wordpress.org/vapvarun/">Varun Dubey (vapvarun)</a>.
971
  </p>
972
 
973
- <h3 class="wp-people-group"><?php esc_html_e( 'With our thanks to these Open Source projects', 'buddypress' ); ?></h3>
974
  <p class="wp-credits-list">
975
  <a href="https://github.com/ichord/At.js">At.js</a>,
976
  <a href="https://bbpress.org">bbPress</a>,
@@ -980,43 +882,67 @@ class BP_Admin {
980
  <a href="https://github.com/carhartl/jquery-cookie">jquery.cookie</a>,
981
  <a href="https://mattbradley.github.io/livestampjs/">Livestamp.js</a>,
982
  <a href="https://www.mediawiki.org/wiki/MediaWiki">MediaWiki</a>,
983
- <a href="https://momentjs.com/">Moment.js</a>,
984
  <a href="https://wordpress.org">WordPress</a>.
985
  </p>
986
 
987
- <h3 class="wp-people-group"><?php esc_html_e( 'Contributor Emeriti', 'buddypress' ); ?></h3>
988
- <ul class="wp-people-group " id="wp-people-group-emeriti">
989
- <li class="wp-person" id="wp-person-apeatling">
990
- <a class="web" href="https://profiles.wordpress.org/apeatling/"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/bb29d699b5cba218c313b61aa82249da?s=120">
991
- Andy Peatling</a>
992
- <span class="title"><?php esc_html_e( 'Project Founder', 'buddypress' ); ?></span>
993
- </li>
994
- <li class="wp-person" id="wp-person-burtadsit">
995
- <a class="web" href="https://profiles.wordpress.org/burtadsit"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/185e1d3e2d653af9d49a4e8e4fc379df?s=120">
996
- Burt Adsit</a>
997
- </li>
998
- <li class="wp-person" id="wp-person-dimensionmedia">
999
- <a class="web" href="https://profiles.wordpress.org/dimensionmedia"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/7735aada1ec39d0c1118bd92ed4551f1?s=120">
1000
- David Bisset</a>
1001
- </li>
1002
- <li class="wp-person" id="wp-person-jeffsayre">
1003
- <a class="web" href="https://profiles.wordpress.org/jeffsayre"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/8e009a84ff5d245c22a69c7df6ab45f7?s=120">
1004
- Jeff Sayre</a>
1005
- </li>
1006
- <li class="wp-person" id="wp-person-karmatosed">
1007
- <a class="web" href="https://profiles.wordpress.org/karmatosed"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/ca7d4273a689cdbf524d8332771bb1ca?s=120">
1008
- Tammie Lister</a>
1009
- </li>
1010
- <li class="wp-person" id="wp-person-modemlooper">
1011
- <a class="web" href="https://profiles.wordpress.org/modemlooper"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/1c07be1016e845de514931477c939307?s=120">
1012
- modemlooper</a>
1013
- </li>
1014
- </ul>
1015
  </div>
1016
 
1017
  <?php
1018
  }
1019
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1020
  /** Emails ****************************************************************/
1021
 
1022
  /**
@@ -1166,19 +1092,14 @@ class BP_Admin {
1166
  'file' => "{$url}customizer-controls{$min}.css",
1167
  'dependencies' => array(),
1168
  ),
1169
-
1170
- // 3.0
1171
- 'bp-hello-css' => array(
1172
- 'file' => "{$url}hello{$min}.css",
1173
- 'dependencies' => array( 'bp-admin-common-css', 'thickbox' ),
1174
- ),
1175
  ) );
1176
 
 
1177
  $version = bp_get_version();
1178
 
1179
  foreach ( $styles as $id => $style ) {
1180
  wp_register_style( $id, $style['file'], $style['dependencies'], $version );
1181
- wp_style_add_data( $id, 'rtl', 'replace' );
1182
 
1183
  if ( $min ) {
1184
  wp_style_add_data( $id, 'suffix', $min );
@@ -1209,13 +1130,6 @@ class BP_Admin {
1209
  'dependencies' => array( 'jquery' ),
1210
  'footer' => true,
1211
  ),
1212
-
1213
- // 3.0
1214
- 'bp-hello-js' => array(
1215
- 'file' => "{$url}hello{$min}.js",
1216
- 'dependencies' => array( 'thickbox', 'bp-api-request' ),
1217
- 'footer' => true,
1218
- ),
1219
  ) );
1220
 
1221
  $version = bp_get_version();
123
  require( $this->admin_dir . 'bp-core-admin-components.php' );
124
  require( $this->admin_dir . 'bp-core-admin-slugs.php' );
125
  require( $this->admin_dir . 'bp-core-admin-tools.php' );
 
126
  }
127
 
128
  /**
155
  // Add settings.
156
  add_action( 'bp_register_admin_settings', array( $this, 'register_admin_settings' ) );
157
 
158
+ // Add a link to BuddyPress About page to the admin bar.
159
+ add_action( 'admin_bar_menu', array( $this, 'admin_bar_about_link' ), 15 );
160
 
161
  // Add a description of new BuddyPress tools in the available tools page.
162
  add_action( 'tool_box', 'bp_core_admin_available_tools_intro' );
169
  add_filter( 'manage_' . bp_get_email_post_type() . '_posts_columns', array( $this, 'emails_register_situation_column' ) );
170
  add_action( 'manage_' . bp_get_email_post_type() . '_posts_custom_column', array( $this, 'emails_display_situation_column_data' ), 10, 2 );
171
 
 
 
 
 
 
 
 
 
 
172
  /* Filters ***********************************************************/
173
 
174
  // Add link to settings page.
197
  return;
198
  }
199
 
200
+ // About.
201
+ add_dashboard_page(
202
+ __( 'Welcome to BuddyPress', 'buddypress' ),
203
+ __( 'Welcome to BuddyPress', 'buddypress' ),
204
+ 'manage_options',
205
+ 'bp-about',
206
+ array( $this, 'about_screen' )
207
+ );
208
+
209
+ // Credits.
210
+ add_dashboard_page(
211
+ __( 'Welcome to BuddyPress', 'buddypress' ),
212
+ __( 'Welcome to BuddyPress', 'buddypress' ),
213
+ 'manage_options',
214
+ 'bp-credits',
215
+ array( $this, 'credits_screen' )
216
+ );
217
+
218
  $hooks = array();
219
 
220
  // Changed in BP 1.6 . See bp_core_admin_backpat_menu().
264
  'bp_core_admin_settings'
265
  );
266
 
 
 
 
 
 
 
 
 
 
 
267
  // For consistency with non-Multisite, we add a Tools menu in
268
  // the Network Admin as a home for our Tools panel.
269
  if ( is_multisite() && bp_core_do_network_admin() ) {
300
  'bp_core_admin_tools'
301
  );
302
 
 
 
 
 
 
 
 
 
 
303
  // For network-wide configs, add a link to (the root site's) Emails screen.
304
  if ( is_network_admin() && bp_is_network_activated() ) {
305
  $email_labels = bp_get_email_post_type_labels();
336
 
337
  $hooks = array();
338
 
339
+ // Require WP 4.0+.
340
+ if ( bp_is_root_blog() && version_compare( $GLOBALS['wp_version'], '4.0', '>=' ) ) {
341
+ // Appearance > Emails.
342
+ $hooks[] = add_theme_page(
343
+ _x( 'Emails', 'screen heading', 'buddypress' ),
344
+ _x( 'Emails', 'screen heading', 'buddypress' ),
345
+ $this->capability,
346
+ 'bp-emails-customizer-redirect',
347
+ 'bp_email_redirect_to_customizer'
348
+ );
349
 
350
+ // Emails > Customize.
351
+ $hooks[] = add_submenu_page(
352
+ 'edit.php?post_type=' . bp_get_email_post_type(),
353
+ _x( 'Customize', 'email menu label', 'buddypress' ),
354
+ _x( 'Customize', 'email menu label', 'buddypress' ),
355
+ $this->capability,
356
+ 'bp-emails-customizer-redirect',
357
+ 'bp_email_redirect_to_customizer'
358
+ );
359
+ }
360
 
361
  foreach( $hooks as $hook ) {
362
  add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' );
380
  add_settings_field( 'hide-loggedout-adminbar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_admin_bar', 'buddypress', 'bp_main' );
381
  register_setting( 'buddypress', 'hide-loggedout-adminbar', 'intval' );
382
 
383
+ // Only show 'switch to Toolbar' option if the user chose to retain the BuddyBar during the 1.6 upgrade.
384
+ if ( (bool) bp_get_option( '_bp_force_buddybar', false ) ) {
385
+ // Load deprecated code if not available.
386
+ if ( ! function_exists( 'bp_admin_setting_callback_force_buddybar' ) ) {
387
+ require buddypress()->plugin_dir . 'bp-core/deprecated/2.1.php';
388
+ }
389
+
390
+ add_settings_field( '_bp_force_buddybar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_force_buddybar', 'buddypress', 'bp_main' );
391
+ register_setting( 'buddypress', '_bp_force_buddybar', 'bp_admin_sanitize_callback_force_buddybar' );
392
+ }
393
+
394
  // Allow account deletion.
395
  add_settings_field( 'bp-disable-account-deletion', __( 'Account Deletion', 'buddypress' ), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main' );
396
  register_setting( 'buddypress', 'bp-disable-account-deletion', 'intval' );
397
 
398
  // Template pack picker.
399
+ add_settings_field( '_bp_theme_package_id', __( 'Template Pack', 'buddypress' ), 'bp_admin_setting_callback_theme_package_id', 'buddypress', 'bp_main' );
400
  register_setting( 'buddypress', '_bp_theme_package_id', 'sanitize_text_field' );
401
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
402
  /* XProfile Section **************************************************/
403
 
404
  if ( bp_is_active( 'xprofile' ) ) {
406
  // Add the main section.
407
  add_settings_section( 'bp_xprofile', _x( 'Profile Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress' );
408
 
409
+ // Avatars.
410
+ add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', 'bp_xprofile' );
411
+ register_setting( 'buddypress', 'bp-disable-avatar-uploads', 'intval' );
412
+
413
+ // Cover images.
414
+ if ( bp_is_active( 'xprofile', 'cover_image' ) ) {
415
+ add_settings_field( 'bp-disable-cover-image-uploads', __( 'Cover Image Uploads', 'buddypress' ), 'bp_admin_setting_callback_cover_image_uploads', 'buddypress', 'bp_xprofile' );
416
+ register_setting( 'buddypress', 'bp-disable-cover-image-uploads', 'intval' );
417
+ }
418
+
419
  // Profile sync setting.
420
  add_settings_field( 'bp-disable-profile-sync', __( 'Profile Syncing', 'buddypress' ), 'bp_admin_setting_callback_profile_sync', 'buddypress', 'bp_xprofile' );
421
  register_setting ( 'buddypress', 'bp-disable-profile-sync', 'intval' );
443
  }
444
  }
445
 
446
+ /* Forums ************************************************************/
447
+
448
+ if ( bp_is_active( 'forums' ) ) {
449
+
450
+ // Add the main section.
451
+ add_settings_section( 'bp_forums', __( 'Legacy Group Forums', 'buddypress' ), 'bp_admin_setting_callback_bbpress_section', 'buddypress' );
452
+
453
+ // Allow subscriptions setting.
454
+ add_settings_field( 'bb-config-location', __( 'bbPress Configuration', 'buddypress' ), 'bp_admin_setting_callback_bbpress_configuration', 'buddypress', 'bp_forums' );
455
+ register_setting( 'buddypress', 'bb-config-location', '' );
456
+ }
457
+
458
  /* Activity Section **************************************************/
459
 
460
  if ( bp_is_active( 'activity' ) ) {
462
  // Add the main section.
463
  add_settings_section( 'bp_activity', __( 'Activity Settings', 'buddypress' ), 'bp_admin_setting_callback_activity_section', 'buddypress' );
464
 
465
+ // Activity commenting on blog and forum posts.
466
+ add_settings_field( 'bp-disable-blogforum-comments', __( 'Blog &amp; Forum Comments', 'buddypress' ), 'bp_admin_setting_callback_blogforum_comments', 'buddypress', 'bp_activity' );
467
  register_setting( 'buddypress', 'bp-disable-blogforum-comments', 'bp_admin_sanitize_callback_blogforum_comments' );
468
 
469
  // Activity Heartbeat refresh.
479
  }
480
 
481
  /**
482
+ * Add a link to BuddyPress About page to the admin bar.
483
  *
484
  * @since 1.9.0
 
485
  *
486
+ * @param WP_Admin_Bar $wp_admin_bar As passed to 'admin_bar_menu'.
487
  */
488
  public function admin_bar_about_link( $wp_admin_bar ) {
489
+ if ( is_user_logged_in() ) {
490
+ $wp_admin_bar->add_menu( array(
491
+ 'parent' => 'wp-logo',
492
+ 'id' => 'bp-about',
493
+ 'title' => esc_html__( 'About BuddyPress', 'buddypress' ),
494
+ 'href' => add_query_arg( array( 'page' => 'bp-about' ), bp_get_admin_url( 'index.php' ) ),
495
+ ) );
496
  }
 
 
 
 
 
 
 
 
 
 
497
  }
498
 
499
  /**
515
  // Add a few links to the existing links array.
516
  return array_merge( $links, array(
517
  'settings' => '<a href="' . esc_url( add_query_arg( array( 'page' => 'bp-components' ), bp_get_admin_url( $this->settings_page ) ) ) . '">' . esc_html__( 'Settings', 'buddypress' ) . '</a>',
518
+ 'about' => '<a href="' . esc_url( add_query_arg( array( 'page' => 'bp-about' ), bp_get_admin_url( 'index.php' ) ) ) . '">' . esc_html__( 'About', 'buddypress' ) . '</a>'
519
  ) );
520
  }
521
 
529
  // Settings pages.
530
  remove_submenu_page( $this->settings_page, 'bp-page-settings' );
531
  remove_submenu_page( $this->settings_page, 'bp-settings' );
 
532
 
533
  // Network Admin Tools.
534
  remove_submenu_page( 'network-tools', 'network-tools' );
536
  // About and Credits pages.
537
  remove_submenu_page( 'index.php', 'bp-about' );
538
  remove_submenu_page( 'index.php', 'bp-credits' );
 
 
 
 
 
 
 
539
  }
540
 
541
  /**
545
  */
546
  public function enqueue_scripts() {
547
  wp_enqueue_style( 'bp-admin-common-css' );
 
 
 
 
 
 
 
 
 
 
548
  }
549
 
550
+ /** About *****************************************************************/
551
+
552
  /**
553
+ * Output the about screen.
554
  *
555
+ * @since 1.7.0
556
  */
557
+ public function about_screen() {
558
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
559
 
560
+ <div class="wrap about-wrap">
561
+
562
+ <?php self::welcome_text(); ?>
563
+
564
+ <?php self::tab_navigation( __METHOD__ ); ?>
565
+
566
+ <?php if ( self::is_new_install() ) : ?>
567
+
568
+ <div id="welcome-panel" class="welcome-panel">
569
+ <div class="welcome-panel-content">
570
+ <h3 style="margin:0;"><?php _e( 'Getting Started with BuddyPress', 'buddypress' ); ?></h3>
571
+ <div class="welcome-panel-column-container">
572
+ <div class="welcome-panel-column">
573
+ <h4><?php _e( 'Configure BuddyPress', 'buddypress' ); ?></h4>
574
+ <ul>
575
+ <li><?php printf(
576
+ '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Set Up Components', 'buddypress' ) . '</a>', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), $this->settings_page ) ) )
577
+ ); ?></li>
578
+ <li><?php printf(
579
+ '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Assign Components to Pages', 'buddypress' ) . '</a>', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), $this->settings_page ) ) )
580
+ ); ?></li>
581
+ <li><?php printf(
582
+ '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Customize Settings', 'buddypress' ) . '</a>', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), $this->settings_page ) ) )
583
+ ); ?></li>
584
+ </ul>
585
+ <a class="button button-primary button-hero" style="margin-bottom:20px;margin-top:0;" href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), $this->settings_page ) ) ); ?>"><?php _e( 'Get Started', 'buddypress' ); ?></a>
586
+ </div>
587
+ <div class="welcome-panel-column">
588
+ <h4><?php _e( 'Administration Tools', 'buddypress' ); ?></h4>
589
+ <ul>
590
+ <?php if ( bp_is_active( 'members' ) ) : ?>
591
+ <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add User Profile Fields', 'buddypress' ) . '</a>', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-profile-setup' ), 'users.php' ) ) ) ); ?></li>
592
+ <?php endif; ?>
593
+ <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Manage User Signups', 'buddypress' ) . '</a>', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-signups' ), 'users.php' ) ) ) ); ?></li>
594
+ <?php if ( bp_is_active( 'activity' ) ) : ?>
595
+ <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Moderate Activity Streams', 'buddypress' ) . '</a>', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-activity' ), 'admin.php' ) ) ) ); ?></li>
596
+ <?php endif; ?>
597
+ <?php if ( bp_is_active( 'groups' ) ) : ?>
598
+ <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Manage Groups', 'buddypress' ) . '</a>', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-groups' ), 'admin.php' ) ) ) ); ?></li>
599
+ <?php endif; ?>
600
+ <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Repair Data', 'buddypress' ) . '</a>', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-tools' ), 'tools.php' ) ) ) ); ?>
601
+ </li>
602
+ </ul>
603
+ </div>
604
+ <div class="welcome-panel-column welcome-panel-last">
605
+ <h4><?php _e( 'Community and Support', 'buddypress' ); ?></h4>
606
+ <p class="welcome-icon welcome-learn-more" style="margin-right:10px"><?php _e( 'Looking for help? The <a href="https://codex.buddypress.org/">BuddyPress Codex</a> has you covered.', 'buddypress' ) ?></p>
607
+ <p class="welcome-icon welcome-learn-more" style="margin-right:10px"><?php _e( 'Can&#8217;t find what you need? Stop by <a href="https://buddypress.org/support/">our support forums</a>, where active BuddyPress users and developers are waiting to share tips and more.', 'buddypress' ) ?></p>
608
+ </div>
609
+ </div>
610
+ </div>
611
+ </div>
612
 
613
+ <?php endif; ?>
 
 
614
 
615
+ <div class="bp-features-section">
 
616
 
617
+ <h3 class="headline-title"><?php esc_html_e( 'For Developers &amp; Site Builders', 'buddypress' ); ?></h3>
 
618
 
619
+ <div class="bp-feature">
620
+ <span class="dashicons dashicons-groups" aria-hidden="true"></span>
621
+ <h4 class="feature-title"><?php esc_html_e( 'Edit Group Slug', 'buddypress' ); ?></h4>
622
+ <p><?php esc_html_e( 'Allow administrators to change group names and permalinks. Navigate to the Groups screen in the wp-admin dashboard, click on the Edit link under the Group name, and adjust as needed.', 'buddypress' ); ?></p>
623
+ </div>
624
 
625
+ <div class="bp-feature opposite">
626
+ <span class="dashicons dashicons-admin-users" aria-hidden="true"></span>
627
+ <h4 class="feature-title"><?php esc_html_e( 'Improve accessibility of Extended Profile Fields', 'buddypress' ); ?></h4>
628
+ <p><?php esc_html_e( 'Related form fields are grouped together in fieldsets and all interactive form controls are associated with necessary ARIA states and properties.', 'buddypress' ); ?></p>
629
+ </div>
630
 
631
+ <div class="bp-feature">
632
+ <span class="dashicons dashicons-email" aria-hidden="true"></span>
633
+ <h4 class="feature-title"><?php esc_html_e( 'Send group invitation only once per user', 'buddypress' ); ?></h4>
634
+ <p><?php esc_html_e( 'Prevent duplicate group invitations from being sent to a user by double-checking if a group invitation has already been sent to that user.', 'buddypress' ); ?></p>
635
+ </div>
636
 
637
+ <div class="bp-feature opposite">
638
+ <span class="dashicons dashicons-testimonial" aria-hidden="true"></span>
639
+ <h4 class="feature-title"><?php esc_html_e( 'Tooltips Usable for All Devices', 'buddypress' ); ?></h4>
640
 
641
+ <p><?php esc_html_e( 'Replaced HTML title attributes with tooltips which provide additional information and visual cues where needed on mouse hover and keyboard focus events.', 'buddypress' );
642
+ ?></p>
643
+ </div>
 
 
644
 
645
+ </div>
646
 
647
+ <div class="bp-changelog-section">
 
 
 
 
 
 
 
 
 
648
 
649
+ <h3 class="changelog-title"><?php esc_html_e( 'More under the hood &#8230;', 'buddypress' ); ?></h3>
650
+ <div class="bp-changelog bp-three-column">
651
+ <div class="bp-column">
652
+ <h4 class="title"><?php esc_html_e( 'Better support for private message thread links in emails', 'buddypress' ); ?></h4>
653
+ <p><?php esc_html_e( 'Redirect non-authenticated users to the login screen and authenticated users to the message linked.', 'buddypress' ); ?></p>
654
+ </div>
655
+ <div class="bp-column">
656
+ <h4 class="title"><?php esc_html_e( 'Compatibility with Bootstrap themes', 'buddypress' ); ?></h4>
657
+ <p><?php esc_html_e( 'Removed issues with BuddyPress-generated content being hidden in the Groups loop and Activity comments in Bootstrap themes.', 'buddypress' ); ?></p>
658
+ </div>
659
 
660
+ <div class="bp-column">
661
+ <h4 class="title"><?php esc_html_e( 'Improve profile image uploads', 'buddypress' ); ?></h4>
662
+ <p><?php esc_html_e( 'Fixed issues with uploading in iOS Safari and uploading files with non-ASCII filenames.', 'buddypress' ); ?></p>
663
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
664
  </div>
665
 
666
+ <div class="bp-changelog bp-three-column">
667
+ <div class="bp-column">
668
+ <h4 class="title"><?php esc_html_e( 'URL compatibility for LightSpeed Servers', 'buddypress' ); ?></h4>
669
+ <p><?php
670
+ /* translators: %s: trailingslashit() */
671
+ printf( __( 'Audited and changed template link functions to use %s where necessary.', 'buddypress' ),
672
+ '<code>trailingslashit()</code>' );
673
+ ?></p>
674
+ </div>
675
+ <div class="bp-column">
676
+ <h4 class="title"><?php esc_html_e( 'Template Packs UI in BuddyPress > Settings.', 'buddypress' ); ?></h4>
677
+ <p><?php esc_html_e( 'Register your new BuddyPress theme package and allow the user to select which template pack to use.', 'buddypress' ); ?></p>
678
+ </div>
679
+
680
+ <div class="bp-column">
681
+ <h4 class="title"><?php
682
+ /* translators: %s: bp_group_link() */
683
+ printf( __( 'New template function %s', 'buddypress' ),
684
+ '<code>bp_group_link()</code>' );
685
+ ?></h4>
686
+ <p><?php esc_html_e( 'Output a group name as a text hyperlink where appropriate.', 'buddypress' ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
687
  </div>
688
  </div>
689
+
690
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
691
 
692
+ <div class="bp-assets">
693
+ <p><?php _ex( 'Learn more:', 'About screen, website links', 'buddypress' ); ?> <a href="https://buddypress.org/blog/"><?php _ex( 'News', 'About screen, link to project blog', 'buddypress' ); ?></a> &bullet; <a href="https://buddypress.org/support/"><?php _ex( 'Support', 'About screen, link to support site', 'buddypress' ); ?></a> &bullet; <a href="https://codex.buddypress.org/"><?php _ex( 'Documentation', 'About screen, link to documentation', 'buddypress' ); ?></a> &bullet; <a href="https://bpdevel.wordpress.com/"><?php _ex( 'Development Blog', 'About screen, link to development blog', 'buddypress' ); ?></a></p>
694
+
695
+ <p><?php _ex( 'Twitter:', 'official Twitter accounts:', 'buddypress' ); ?> <a href="https://twitter.com/buddypress/"><?php _ex( 'BuddyPress', '@buddypress twitter account name', 'buddypress' ); ?></a> &bullet; <a href="https://twitter.com/bptrac/"><?php _ex( 'Trac', '@bptrac twitter account name', 'buddypress' ); ?></a> &bullet; <a href="https://twitter.com/buddypressdev/"><?php _ex( 'Development', '@buddypressdev twitter account name', 'buddypress' ); ?></a></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
696
  </div>
697
+
698
  </div>
699
 
700
  <?php
711
  public function credits_screen() {
712
  ?>
713
 
714
+ <div class="wrap about-wrap">
715
 
716
+ <?php self::welcome_text(); ?>
 
717
 
718
+ <?php self::tab_navigation( __METHOD__ ); ?>
719
 
720
+ <p class="about-description"><?php _e( 'BuddyPress is created by a worldwide network of friendly folks like these.', 'buddypress' ); ?></p>
721
 
722
+ <h3 class="wp-people-group"><?php _e( 'Project Leaders', 'buddypress' ); ?></h3>
723
  <ul class="wp-people-group " id="wp-people-group-project-leaders">
724
  <li class="wp-person" id="wp-person-johnjamesjacoby">
725
+ <a class="web" href="https://profiles.wordpress.org/johnjamesjacoby"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/7a2644fb53ae2f7bfd7143b504af396c?s=60">
726
  John James Jacoby</a>
727
+ <span class="title"><?php _e( 'Project Lead', 'buddypress' ); ?></span>
728
  </li>
729
  <li class="wp-person" id="wp-person-boonebgorges">
730
+ <a class="web" href="https://profiles.wordpress.org/boonebgorges"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/9cf7c4541a582729a5fc7ae484786c0c?s=60">
731
  Boone B. Gorges</a>
732
+ <span class="title"><?php _e( 'Lead Developer', 'buddypress' ); ?></span>
733
  </li>
734
  <li class="wp-person" id="wp-person-djpaul">
735
+ <a class="web" href="https://profiles.wordpress.org/djpaul"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/3bc9ab796299d67ce83dceb9554f75df?s=60">
736
  Paul Gibbs</a>
737
+ <span class="title"><?php _e( 'Lead Developer', 'buddypress' ); ?></span>
738
+ </li>
739
+ </ul>
740
+
741
+ <h3 class="wp-people-group"><?php _e( 'BuddyPress Team', 'buddypress' ); ?></h3>
742
+ <ul class="wp-people-group " id="wp-people-group-core-team">
743
+ <li class="wp-person" id="wp-person-hnla">
744
+ <a class="web" href="https://profiles.wordpress.org/hnla"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/3860c955aa3f79f13b92826ae47d07fe?s=60">
745
+ Hugo Ashmore</a>
746
+ <span class="title"><?php _e( '2.9 Release Lead', 'buddypress' ); ?></span>
747
  </li>
748
  <li class="wp-person" id="wp-person-r-a-y">
749
+ <a class="web" href="https://profiles.wordpress.org/r-a-y"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/3bfa556a62b5bfac1012b6ba5f42ebfa?s=60">
750
  Ray</a>
751
+ <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
752
  </li>
753
  <li class="wp-person" id="wp-person-imath">
754
+ <a class="web" href="https://profiles.wordpress.org/imath"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/8b208ca408dad63888253ee1800d6a03?s=60">
755
  Mathieu Viet</a>
756
+ <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
757
  </li>
758
  <li class="wp-person" id="wp-person-mercime">
759
+ <a class="web" href="https://profiles.wordpress.org/mercime"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/fae451be6708241627983570a1a1817a?s=60">
760
  Mercime</a>
761
+ <span class="title"><?php _e( 'Navigator', 'buddypress' ); ?></span>
 
 
 
 
 
 
 
 
 
762
  </li>
763
  <li class="wp-person" id="wp-person-dcavins">
764
+ <a class="web" href="https://profiles.wordpress.org/dcavins"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/a5fa7e83d59cb45ebb616235a176595a?s=60">
765
  David Cavins</a>
766
+ <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
767
  </li>
768
  <li class="wp-person" id="wp-person-tw2113">
769
+ <a class="web" href="https://profiles.wordpress.org/tw2113"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/a5d7c934621fa1c025b83ee79bc62366?s=60">
770
  Michael Beckwith</a>
771
+ <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
772
  </li>
773
  <li class="wp-person" id="wp-person-henry-wright">
774
+ <a class="web" href="https://profiles.wordpress.org/henry.wright"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/0da2f1a9340d6af196b870f6c107a248?s=60">
775
  Henry Wright</a>
776
+ <span class="title"><?php _e( 'Community Support', 'buddypress' ); ?></span>
777
  </li>
778
  <li class="wp-person" id="wp-person-danbp">
779
+ <a class="web" href="https://profiles.wordpress.org/danbp"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/0deae2e7003027fbf153500cd3fa5501?s=60">
780
  danbp</a>
781
+ <span class="title"><?php _e( 'Community Support', 'buddypress' ); ?></span>
782
  </li>
783
  <li class="wp-person" id="wp-person-shanebp">
784
+ <a class="web" href="https://profiles.wordpress.org/shanebp"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/ffd294ab5833ba14aaf175f9acc71cc4?s=60">
785
  shanebp</a>
786
+ <span class="title"><?php _e( 'Community Support', 'buddypress' ); ?></span>
787
  </li>
788
  <li class="wp-person" id="wp-person-slaffik">
789
+ <a class="web" href="https://profiles.wordpress.org/r-a-y"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/61fb07ede3247b63f19015f200b3eb2c?s=60">
790
  Slava Abakumov</a>
791
+ <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
792
  </li>
793
  <li class="wp-person" id="wp-person-offereins">
794
+ <a class="web" href="https://profiles.wordpress.org/Offereins"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/2404ed0a35bb41aedefd42b0a7be61c1?s=60">
795
  Laurens Offereins</a>
796
+ <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
797
  </li>
798
  <li class="wp-person" id="wp-person-netweb">
799
+ <a class="web" href="https://profiles.wordpress.org/netweb"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/97e1620b501da675315ba7cfb740e80f?s=60">
800
  Stephen Edgar</a>
801
+ <span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
 
 
 
 
 
 
 
 
 
 
802
  </li>
803
  </ul>
804
 
805
+ <h3 class="wp-people-group"><?php _e( '&#x1f31f;Recent Rockstars&#x1f31f;', 'buddypress' ); ?></h3>
806
+ <ul class="wp-people-group " id="wp-people-group-rockstars">
807
+ <li class="wp-person" id="wp-person-dimensionmedia">
808
+ <a class="web" href="https://profiles.wordpress.org/dimensionmedia"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/7735aada1ec39d0c1118bd92ed4551f1?s=60">
809
+ David Bisset</a>
810
+ </li>
811
+ <li class="wp-person" id="wp-person-garrett-eclipse">
812
+ <a class="web" href="https://profiles.wordpress.org/garrett-eclipse"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/7f68f24441c61514d5d0e1451bb5bc9d?s=60">
813
+ Garrett Hyder</a>
814
+ </li>
815
+ <li class="wp-person" id="wp-person-thebrandonallen">
816
+ <a class="web" href="https://profiles.wordpress.org/thebrandonallen"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/6d3f77bf3c9ca94c406dea401b566950?s=60">
817
+ Brandon Allen</a>
818
  </li>
819
+ <li class="wp-person" id="wp-person-ramiy">
820
+ <a class="web" href="https://profiles.wordpress.org/ramiy"><img alt="" class="gravatar" src="//www.gravatar.com/avatar/ce2a269e424156d79cb0c4e1d4d82db1?s=60">
821
+ Rami Yushuvaev</a>
822
  </li>
823
  </ul>
824
 
825
+ <h3 class="wp-people-group"><?php printf( esc_html__( 'Contributors to BuddyPress %s', 'buddypress' ), self::display_version() ); ?></h3>
 
 
 
 
 
 
 
 
826
  <p class="wp-credits-list">
827
+ <a href="https://profiles.wordpress.org/55don/">55don</a>,
828
+ <a href="https://profiles.wordpress.org/aaronoftomorrow/">AaronOfTomorrow</a>,
829
+ <a href="https://profiles.wordpress.org/allianse/">allianse</a>,
830
+ <a href="https://profiles.wordpress.org/antonioeatgoat/">Antonio Mangiacapra (antonioeatgoat)</a>,
831
+ <a href="https://profiles.wordpress.org/benjlipchak/">Benj (benjlipchak)</a>,
832
  <a href="https://profiles.wordpress.org/boonebgorges/">Boone B Gorges (boonebgorges)</a>,
833
+ <a href="https://profiles.wordpress.org/bhargavbhandari90/">Bunty (bhargavbhandari90)</a>,
834
  <a href="https://profiles.wordpress.org/sbrajesh/">Brajesh Singh (sbrajesh)</a>,
835
+ <a href="https://profiles.wordpress.org/needle/">Christian Wach (needle)</a>,
836
+ <a href="https://profiles.wordpress.org/brandonliles/">brandonliles</a>,
837
+ <a href="https://profiles.wordpress.org/danbp/">danbp</a>,
838
  <a href="https://profiles.wordpress.org/dcavins/">David Cavins (dcavins)</a>,
839
+ <a href="https://profiles.wordpress.org/dkelm/">dkelm</a>,
840
+ <a href="https://profiles.wordpress.org/dsar/">dsar</a>,
841
+ <a href="https://profiles.wordpress.org/dsided/">dsided</a>,
842
+ <a href="https://profiles.wordpress.org/henry.wright">Henry Wright (henry.wright)</a>,
843
+ <a href="https://profiles.wordpress.org/hnla/">Hugo (hnla)</a>,
844
+ <a href="https://profiles.wordpress.org/idofri/">Ido Friedlander (idofri)</a>,
845
+ <a href="https://profiles.wordpress.org/uscore713/">Jay (uscore713)</a>,
846
+ <a href="https://profiles.wordpress.org/johnbillion/">John Blackbourn (johnbillion)</a>,
847
  <a href="https://profiles.wordpress.org/johnjamesjacoby/">John James Jacoby (johnjamesjacoby)</a>,
848
+ <a href="https://profiles.wordpress.org/juanho/">Juanho</a>,
849
+ <a href="https://profiles.wordpress.org/lakrisgubben/">lakrisgubben</a>,
850
+ <a href="https://profiles.wordpress.org/Offereins">Laurens Offereins (Offereins)</a>,
851
+ <a href="https://profiles.wordpress.org/lne1030/">lne1030</a>,
852
+ <a href="https://profiles.wordpress.org/lenasterg/">lenasterg</a>,
853
+ <a href="https://profiles.wordpress.org/maniou/">Maniou</a>,
854
  <a href="https://profiles.wordpress.org/imath/">Mathieu Viet (imath)</a>,
855
+ <a href="https://profiles.wordpress.org/mercime/">mercime</a>,
856
+ <a href="https://profiles.wordpress.org/tw2113/">Michael Beckwith (tw2113)</a>,
857
+ <a href="https://profiles.wordpress.org/mikegillihan/">Mike Gillihan (MikeGillihan)</a>,
858
+ <a href="https://profiles.wordpress.org/milindmore22/">Milind More (milindmore22)</a>,
859
  <a href="https://profiles.wordpress.org/modemlooper/">modemlooper</a>,
860
+ <a href="https://profiles.wordpress.org/mrjarbenne/">mrjarbenne</a>,
861
+ <a href="https://profiles.wordpress.org/nicolaskulka/">Nicolas Kulka (NicolasKulka)</a>,
862
+ <a href="https://profiles.wordpress.org/oelita/">Oelita</a>,
863
  <a href="https://profiles.wordpress.org/DJPaul/">Paul Gibbs (DJPaul)</a>,
864
+ <a href="https://profiles.wordpress.org/pareshradadiya/">paresh.radadiya (pareshradadiya)</a>,
865
  <a href="https://profiles.wordpress.org/r-a-y/">r-a-y</a>,
866
  <a href="https://profiles.wordpress.org/espellcaste/">Renato Alves (espellcaste)</a>,
867
+ <a href="https://profiles.wordpress.org/rianrietveld/">Rian Rietveld (rianrietvelde)</a>,
868
+ <a href="https://profiles.wordpress.org/elhardoum/">Samuel Elh (elhardoum)</a>,
869
+ <a href="https://profiles.wordpress.org/seventhqueen/">seventhqueen</a>,
870
  <a href="https://profiles.wordpress.org/slaffik/">Slava Abakumov (slaffik)</a>,
871
  <a href="https://profiles.wordpress.org/netweb/">Stephen Edgar (netweb)</a>,
872
+ <a href="https://profiles.wordpress.org/vishalkakadiya/">Vishal Kakadiya (vishalkakadiya)</a>
 
 
873
  </p>
874
 
875
+ <h3 class="wp-people-group"><?php _e( '&#x1f496;With our thanks to these Open Source projects&#x1f496;', 'buddypress' ); ?></h3>
876
  <p class="wp-credits-list">
877
  <a href="https://github.com/ichord/At.js">At.js</a>,
878
  <a href="https://bbpress.org">bbPress</a>,
882
  <a href="https://github.com/carhartl/jquery-cookie">jquery.cookie</a>,
883
  <a href="https://mattbradley.github.io/livestampjs/">Livestamp.js</a>,
884
  <a href="https://www.mediawiki.org/wiki/MediaWiki">MediaWiki</a>,
885
+ <a href="http://momentjs.com/">Moment.js</a>,
886
  <a href="https://wordpress.org">WordPress</a>.
887
  </p>
888
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
889
  </div>
890
 
891
  <?php
892
  }
893
 
894
+ /**
895
+ * Output welcome text and badge for What's New and Credits pages.
896
+ *
897
+ * @since 2.2.0
898
+ */
899
+ public static function welcome_text() {
900
+
901
+ // Switch welcome text based on whether this is a new installation or not.
902
+ $welcome_text = ( self::is_new_install() )
903
+ ? __( 'Thank you for installing BuddyPress! BuddyPress adds community features to WordPress. Member Profiles, Activity Streams, Direct Messaging, Notifications, and more!', 'buddypress' )
904
+ : __( 'Thank you for updating! BuddyPress %s has many new improvements that you will enjoy.', 'buddypress' );
905
+
906
+ ?>
907
+
908
+ <h1><?php printf( esc_html__( 'Welcome to BuddyPress %s', 'buddypress' ), self::display_version() ); ?></h1>
909
+
910
+ <div class="about-text">
911
+ <?php
912
+ if ( self::is_new_install() ) {
913
+ echo $welcome_text;
914
+ } else {
915
+ printf( $welcome_text, self::display_version() );
916
+ }
917
+ ?>
918
+ </div>
919
+
920
+ <div class="bp-badge"></div>
921
+
922
+ <?php
923
+ }
924
+
925
+ /**
926
+ * Output tab navigation for `What's New` and `Credits` pages.
927
+ *
928
+ * @since 2.2.0
929
+ *
930
+ * @param string $tab Tab to highlight as active.
931
+ */
932
+ public static function tab_navigation( $tab = 'whats_new' ) {
933
+ ?>
934
+
935
+ <h2 class="nav-tab-wrapper">
936
+ <a class="nav-tab <?php if ( 'BP_Admin::about_screen' === $tab ) : ?>nav-tab-active<?php endif; ?>" href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-about' ), 'index.php' ) ) ); ?>">
937
+ <?php esc_html_e( 'What&#8217;s New', 'buddypress' ); ?>
938
+ </a><a class="nav-tab <?php if ( 'BP_Admin::credits_screen' === $tab ) : ?>nav-tab-active<?php endif; ?>" href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-credits' ), 'index.php' ) ) ); ?>">
939
+ <?php esc_html_e( 'Credits', 'buddypress' ); ?>
940
+ </a>
941
+ </h2>
942
+
943
+ <?php
944
+ }
945
+
946
  /** Emails ****************************************************************/
947
 
948
  /**
1092
  'file' => "{$url}customizer-controls{$min}.css",
1093
  'dependencies' => array(),
1094
  ),
 
 
 
 
 
 
1095
  ) );
1096
 
1097
+
1098
  $version = bp_get_version();
1099
 
1100
  foreach ( $styles as $id => $style ) {
1101
  wp_register_style( $id, $style['file'], $style['dependencies'], $version );
1102
+ wp_style_add_data( $id, 'rtl', true );
1103
 
1104
  if ( $min ) {
1105
  wp_style_add_data( $id, 'suffix', $min );
1130
  'dependencies' => array( 'jquery' ),
1131
  'footer' => true,
1132
  ),
 
 
 
 
 
 
 
1133
  ) );
1134
 
1135
  $version = bp_get_version();
bp-core/classes/class-bp-attachment-avatar.php CHANGED
@@ -37,11 +37,8 @@ class BP_Attachment_Avatar extends BP_Attachment {
37
 
38
  // Specific errors for avatars.
39
  'upload_error_strings' => array(
40
- /* translators: %s: Max file size for the profile photo */
41
- 9 => sprintf( _x( 'That photo is too big. Please upload one smaller than %s', 'profile photo upload error', 'buddypress' ), size_format( bp_core_avatar_original_max_filesize() ) ),
42
-
43
- /* translators: %s: comma separated list of file types allowed for the profile photo */
44
- 10 => sprintf( _nx( 'Please upload only this file type: %s.', 'Please upload only these file types: %s.', count( $allowed_types ), 'profile photo upload error', 'buddypress' ), self::get_avatar_types( $allowed_types ) ),
45
  ),
46
  ) );
47
  }
@@ -133,7 +130,7 @@ class BP_Attachment_Avatar extends BP_Attachment {
133
  */
134
  $original_max_width = $ui_available_width;
135
 
136
- // $original_max_width has to be larger than the avatar's full width.
137
  if ( $original_max_width < bp_core_avatar_full_width() ) {
138
  $original_max_width = bp_core_avatar_full_width();
139
  }
@@ -340,7 +337,7 @@ class BP_Attachment_Avatar extends BP_Attachment {
340
  }
341
 
342
  /**
343
- * Build script data for the Uploader UI.
344
  *
345
  * @since 2.3.0
346
  *
37
 
38
  // Specific errors for avatars.
39
  'upload_error_strings' => array(
40
+ 9 => sprintf( __( 'That photo is too big. Please upload one smaller than %s', 'buddypress' ), size_format( bp_core_avatar_original_max_filesize() ) ),
41
+ 10 => sprintf( _n( 'Please upload only this file type: %s.', 'Please upload only these file types: %s.', count( $allowed_types ), 'buddypress' ), self::get_avatar_types( $allowed_types ) ),
 
 
 
42
  ),
43
  ) );
44
  }
130
  */
131
  $original_max_width = $ui_available_width;
132
 
133
+ // $original_max_width has to be larger than the avatar's full width
134
  if ( $original_max_width < bp_core_avatar_full_width() ) {
135
  $original_max_width = bp_core_avatar_full_width();
136
  }
337
  }
338
 
339
  /**
340
+ * Build script datas for the Uploader UI.
341
  *
342
  * @since 2.3.0
343
  *
bp-core/classes/class-bp-attachment-cover-image.php CHANGED
@@ -37,11 +37,8 @@ class BP_Attachment_Cover_Image extends BP_Attachment {
37
 
38
  // Specific errors for cover images.
39
  'upload_error_strings' => array(
40
- /* translators: %s: Max file size for the cover image */
41
- 11 => sprintf( _x( 'That image is too big. Please upload one smaller than %s', 'cover image upload error', 'buddypress' ), size_format( $max_upload_file_size ) ),
42
-
43
- /* translators: %s: comma separated list of file types allowed for the cover image */
44
- 12 => sprintf( _nx( 'Please upload only this file type: %s.', 'Please upload only these file types: %s.', count( $allowed_types ), 'cover image upload error', 'buddypress' ), self::get_cover_image_types( $allowed_types ) ),
45
  ),
46
  ) );
47
  }
@@ -78,11 +75,11 @@ class BP_Attachment_Cover_Image extends BP_Attachment {
78
  }
79
 
80
  // File size is too big.
81
- if ( isset( $file['size'] ) && ( $file['size'] > $this->original_max_filesize ) ) {
82
  $file['error'] = 11;
83
 
84
  // File is of invalid type.
85
- } elseif ( isset( $file['tmp_name'] ) && isset( $file['name'] ) && ! bp_attachments_check_filetype( $file['tmp_name'], $file['name'], bp_attachments_get_allowed_mimes( 'cover_image' ) ) ) {
86
  $file['error'] = 12;
87
  }
88
 
@@ -99,7 +96,40 @@ class BP_Attachment_Cover_Image extends BP_Attachment {
99
  * @return array $value Upload data (path, url, basedir...).
100
  */
101
  public function upload_dir_filter( $upload_dir = array() ) {
102
- return bp_attachments_cover_image_upload_dir();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  }
104
 
105
  /**
37
 
38
  // Specific errors for cover images.
39
  'upload_error_strings' => array(
40
+ 11 => sprintf( __( 'That image is too big. Please upload one smaller than %s', 'buddypress' ), size_format( $max_upload_file_size ) ),
41
+ 12 => sprintf( _n( 'Please upload only this file type: %s.', 'Please upload only these file types: %s.', count( $allowed_types ), 'buddypress' ), self::get_cover_image_types( $allowed_types ) ),
 
 
 
42
  ),
43
  ) );
44
  }
75
  }
76
 
77
  // File size is too big.
78
+ if ( $file['size'] > $this->original_max_filesize ) {
79
  $file['error'] = 11;
80
 
81
  // File is of invalid type.
82
+ } elseif ( ! bp_attachments_check_filetype( $file['tmp_name'], $file['name'], bp_attachments_get_allowed_mimes( 'cover_image' ) ) ) {
83
  $file['error'] = 12;
84
  }
85
 
96
  * @return array $value Upload data (path, url, basedir...).
97
  */
98
  public function upload_dir_filter( $upload_dir = array() ) {
99
+ // Default values are for profiles.
100
+ $object_id = bp_displayed_user_id();
101
+
102
+ if ( empty( $object_id ) ) {
103
+ $object_id = bp_loggedin_user_id();
104
+ }
105
+
106
+ $object_directory = 'members';
107
+
108
+ // We're in a group, edit default values.
109
+ if ( bp_is_group() || bp_is_group_create() ) {
110
+ $object_id = bp_get_current_group_id();
111
+ $object_directory = 'groups';
112
+ }
113
+
114
+ // Set the subdir.
115
+ $subdir = '/' . $object_directory . '/' . $object_id . '/cover-image';
116
+
117
+ /**
118
+ * Filters the cover image upload directory.
119
+ *
120
+ * @since 2.4.0
121
+ *
122
+ * @param array $value Array containing the path, URL, and other helpful settings.
123
+ * @param array $upload_dir The original Uploads dir.
124
+ */
125
+ return apply_filters( 'bp_attachments_cover_image_upload_dir', array(
126
+ 'path' => $this->upload_path . $subdir,
127
+ 'url' => $this->url . $subdir,
128
+ 'subdir' => $subdir,
129
+ 'basedir' => $this->upload_path,
130
+ 'baseurl' => $this->url,
131
+ 'error' => false
132
+ ), $upload_dir );
133
  }
134
 
135
  /**
bp-core/classes/class-bp-attachment.php CHANGED
@@ -77,7 +77,7 @@ abstract class BP_Attachment {
77
 
78
  /**
79
  * Max file size defaults to php ini settings or, in the case of
80
- * a multisite config, the root site fileupload_maxk option.
81
  */
82
  $this->default_args['original_max_filesize'] = (int) wp_max_upload_size();
83
 
@@ -159,8 +159,6 @@ abstract class BP_Attachment {
159
  $upload_errors = array(
160
  0 => __( 'The file was uploaded successfully', 'buddypress' ),
161
  1 => __( 'The uploaded file exceeds the maximum allowed file size for this site', 'buddypress' ),
162
-
163
- /* translators: %s: Max file size for the file */
164
  2 => sprintf( __( 'The uploaded file exceeds the maximum allowed file size of: %s', 'buddypress' ), size_format( $this->original_max_filesize ) ),
165
  3 => __( 'The uploaded file was only partially uploaded.', 'buddypress' ),
166
  4 => __( 'No file was uploaded.', 'buddypress' ),
@@ -502,15 +500,7 @@ abstract class BP_Attachment {
502
  $ext = $is_image['ext'];
503
 
504
  if ( empty( $ext ) || empty( $supported_image_types[ $ext ] ) ) {
505
- $wp_error->add(
506
- 'crop_error',
507
- sprintf(
508
- /* translators: %s: image file extension */
509
- __( 'Cropping the file failed: %s is not a supported image file.', 'buddypress' ),
510
- $file['error']
511
- )
512
- );
513
-
514
  return $wp_error;
515
  }
516
  }
77
 
78
  /**
79
  * Max file size defaults to php ini settings or, in the case of
80
+ * a multisite config, the root site fileupload_maxk option
81
  */
82
  $this->default_args['original_max_filesize'] = (int) wp_max_upload_size();
83
 
159
  $upload_errors = array(
160
  0 => __( 'The file was uploaded successfully', 'buddypress' ),
161
  1 => __( 'The uploaded file exceeds the maximum allowed file size for this site', 'buddypress' ),
 
 
162
  2 => sprintf( __( 'The uploaded file exceeds the maximum allowed file size of: %s', 'buddypress' ), size_format( $this->original_max_filesize ) ),
163
  3 => __( 'The uploaded file was only partially uploaded.', 'buddypress' ),
164
  4 => __( 'No file was uploaded.', 'buddypress' ),
500
  $ext = $is_image['ext'];
501
 
502
  if ( empty( $ext ) || empty( $supported_image_types[ $ext ] ) ) {
503
+ $wp_error->add( 'crop_error', sprintf( __( 'Cropping the file failed: %s is not a supported image file.', 'buddypress' ), $file['error'] ) );
 
 
 
 
 
 
 
 
504
  return $wp_error;
505
  }
506
  }
bp-core/classes/class-bp-block.php DELETED
@@ -1,219 +0,0 @@
1
- <?php
2
- /**
3
- * BP Block class.
4
- *
5
- * @package BuddyPress
6
- * @subpackage Core
7
- * @since 6.0.0
8
- */
9
-
10
- // Exit if accessed directly.
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- }
14
-
15
- /**
16
- * BP Block Class.
17
- *
18
- * @since 6.0.0
19
- */
20
- class BP_Block {
21
- /**
22
- * WP Block Type object.
23
- *
24
- * @since 6.0.0
25
- * @var WP_Block_Type|WP_Error
26
- */
27
- public $block;
28
-
29
- /**
30
- * The script types registered.
31
- *
32
- * @since 6.0.0
33
- * @var array
34
- */
35
- private $registered_scripts;
36
-
37
- /**
38
- * The style types registered.
39
- *
40
- * @since 6.0.0
41
- * @var array
42
- */
43
- private $registered_styles;
44
-
45
- /**
46
- * Construct the BuddyPress Block.
47
- *
48
- * @since 6.0.0
49
- *
50
- * @param array $args {
51
- * The registration arguments for the BP Block. Part of the arguments are the ones
52
- * used by `WP_Block_Type`. Below are BP specific arguments.
53
- *
54
- * @type string $name The name of the block (eg: `bp/member`).
55
- * @type string $editor_script_url URL to the JavaScript main file of the BP Block
56
- * to load into the Block Editor.
57
- * @type array $editor_script_deps The list of JavaScript dependency handles for the
58
- * BP Block main file.
59
- * @type string $script_url URL to the JavaScript file to load into the Block
60
- * Editor and on front-end.
61
- * @type array $script_deps The list of JavaScript dependency handles for the
62
- * JavaScript file to load into the Block Editor and
63
- * on front-end.
64
- * @type string $editor_style_url URL to the CSS main file of the BP Block to load
65
- * into the Block Editor.
66
- * @type array $editor_style_deps The list of CSS dependency handles for the
67
- * CSS main file.
68
- * @type string $style_url URL to the CSS file to load into the Block Editor
69
- * and on front-end.
70
- * @type array $style_deps The list of CSS dependency handles for the CSS file
71
- * to load into the Block Editor and on front-end.
72
- * }
73
- */
74
- public function __construct( $args ) {
75
- if ( ! did_action( 'bp_blocks_init' ) ) {
76
- _doing_it_wrong( __METHOD__, esc_html__( 'BP Blocks needs to be registered hooking `bp_blocks_init`', 'buddypress' ), '6.0.0' );
77
- }
78
-
79
- $min = bp_core_get_minified_asset_suffix();
80
- $wp_args = array_intersect_key(
81
- $args,
82
- array(
83
- 'name' => '',
84
- 'render_callback' => '',
85
- 'attributes' => '',
86
- 'editor_script' => '',
87
- 'script' => '',
88
- 'editor_style' => '',
89
- 'style' => '',
90
- )
91
- );
92
-
93
- if ( ! isset( $wp_args['name'] ) || ! $wp_args['name'] || ! isset( $wp_args['editor_script'] ) || ! $wp_args['editor_script'] ) {
94
- $this->block = new WP_Error( 'missing_parameters', __( 'The `name` or `editor_script` required keys are missing.', 'buddypress' ) );
95
- } else {
96
- // Get specific BP Blocks arguments.
97
- $bp_args = array_intersect_key(
98
- $args,
99
- array(
100
- 'editor_script_url' => '',
101
- 'editor_script_deps' => array(),
102
- 'script_url' => '',
103
- 'script_deps' => array(),
104
- 'editor_style_url' => '',
105
- 'editor_style_deps' => array(),
106
- 'style_url' => '',
107
- 'style_deps' => array(),
108
- )
109
- );
110
-
111
- // Register the scripts.
112
- $version = bp_get_version();
113
- $this->registered_scripts = array();
114
-
115
- foreach ( array( 'editor_script', 'script' ) as $script_handle_key ) {
116
- if ( ! isset( $wp_args[ $script_handle_key ] ) || ! $wp_args[ $script_handle_key ] ) {
117
- continue;
118
- }
119
-
120
- if ( ! isset( $bp_args[ $script_handle_key . '_url' ] ) || ! $bp_args[ $script_handle_key . '_url' ] ) {
121
- continue;
122
- }
123
-
124
- $deps = array();
125
- if ( isset( $bp_args[ $script_handle_key . '_deps' ] ) && is_array( $bp_args[ $script_handle_key . '_deps' ] ) ) {
126
- $deps = $bp_args[ $script_handle_key . '_deps' ];
127
- }
128
-
129
- $this->registered_scripts[ $script_handle_key ] = wp_register_script(
130
- $wp_args[ $script_handle_key ],
131
- $bp_args[ $script_handle_key . '_url' ],
132
- $deps,
133
- $version,
134
- true
135
- );
136
- }
137
-
138
- if ( ! isset( $this->registered_scripts['editor_script'] ) || ! $this->registered_scripts['editor_script'] ) {
139
- $this->block = new WP_Error( 'script_registration_error', __( 'The required `editor_script` could not be registered.', 'buddypress' ) );
140
- } else {
141
- // Register the styles.
142
- $registered_styles = array();
143
-
144
- foreach ( array( 'editor_style', 'style' ) as $style_handle_key ) {
145
- if ( ! isset( $wp_args[ $style_handle_key ] ) || ! $wp_args[ $style_handle_key ] ) {
146
- continue;
147
- }
148
-
149
- if ( ! isset( $bp_args[ $style_handle_key . '_url' ] ) || ! $bp_args[ $style_handle_key . '_url' ] ) {
150
- continue;
151
- }
152
-
153
- if ( $min ) {
154
- $minified_css = str_replace( '.css', $min . '.css', $bp_args[ $style_handle_key . '_url' ] );
155
- $css_file_path = str_replace( content_url(), WP_CONTENT_DIR, $minified_css );
156
-
157
- if ( file_exists( $css_file_path ) ) {
158
- $bp_args[ $style_handle_key . '_url' ] = $minified_css;
159
- }
160
- }
161
-
162
- $deps = array();
163
- if ( isset( $bp_args[ $style_handle_key . '_deps' ] ) && is_array( $bp_args[ $style_handle_key . '_deps' ] ) ) {
164
- $deps = $bp_args[ $style_handle_key . '_deps' ];
165
- }
166
-
167
- $this->registered_styles[ $style_handle_key ] = wp_register_style(
168
- $wp_args[ $style_handle_key ],
169
- $bp_args[ $style_handle_key . '_url' ],
170
- $deps,
171
- $version
172
- );
173
-
174
- wp_style_add_data( $wp_args[ $style_handle_key ], 'rtl', 'replace' );
175
- if ( $min ) {
176
- wp_style_add_data( $wp_args[ $style_handle_key ], 'suffix', $min );
177
- }
178
- }
179
-
180
- $name = $wp_args['name'];
181
- unset( $wp_args['name'] );
182
-
183
- // Set the Block Type.
184
- $this->block = new WP_Block_Type( $name, $wp_args );
185
-
186
- // Register the Block Type.
187
- register_block_type( $this->block );
188
-
189
- // Load Block translations if found.
190
- if ( $this->block->editor_script ) {
191
- /**
192
- * Filter here to use a custom directory to look for the JSON translation file into.
193
- *
194
- * @since 6.0.0
195
- *
196
- * @param string $value Absolute path to the directory to look for the JSON translation file into.
197
- * @param string $editor_script The editor's script handle.
198
- * @param string $name The block's name.
199
- */
200
- $translation_dir = apply_filters( 'bp_block_translation_dir', null, $this->block->editor_script, $name );
201
-
202
- /**
203
- * Filter here to use a custom domain for the JSON translation file.
204
- *
205
- * @since 6.0.0
206
- *
207
- * @param string $value The custom domain for the JSON translation file.
208
- * @param string $editor_script The editor's script handle.
209
- * @param string $name The block's name.
210
- */
211
- $translation_domain = apply_filters( 'bp_block_translation_domain', 'buddypress', $this->block->editor_script, $name );
212
-
213
- // Try to load the translation.
214
- $translated = wp_set_script_translations( $this->block->editor_script, $translation_domain, $translation_dir );
215
- }
216
- }
217
- }
218
- }
219
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-core/classes/class-bp-button.php CHANGED
@@ -324,17 +324,6 @@ class BP_Button {
324
  // Button properties.
325
  $button = '';
326
  if ( ! empty( $r['button_element'] ) ) {
327
- // Ensure the `href` attribute is not wrongly used inside buttons.
328
- if ( 'button' === $r['button_element'] && ! empty( $r['button_attr']['href'] ) ) {
329
- _doing_it_wrong(
330
- __CLASS__,
331
- __( 'The `href` attribute is not available inside the `&lt;button&gt;` tag. Please use a `data-*` attribute to transport a link into this tag.', 'buddypress' ),
332
- '9.0.0'
333
- );
334
-
335
- unset( $r['button_attr']['href'] );
336
- }
337
-
338
  $button = new BP_Core_HTML_Element( array(
339
  'element' => $r['button_element'],
340
  'attr' => $r['button_attr'],
324
  // Button properties.
325
  $button = '';
326
  if ( ! empty( $r['button_element'] ) ) {
 
 
 
 
 
 
 
 
 
 
 
327
  $button = new BP_Core_HTML_Element( array(
328
  'element' => $r['button_element'],
329
  'attr' => $r['button_attr'],
bp-core/classes/class-bp-component.php CHANGED
@@ -140,15 +140,6 @@ class BP_Component {
140
  */
141
  public $search_query_arg = 's';
142
 
143
- /**
144
- * An array of globalized data for BP Blocks.
145
- *
146
- * @since 9.0.0
147
- *
148
- * @var array
149
- */
150
- public $block_globals = array();
151
-
152
  /** Methods ***************************************************************/
153
 
154
  /**
@@ -214,7 +205,7 @@ class BP_Component {
214
  * Set up component global variables.
215
  *
216
  * @since 1.5.0
217
- * @since 9.0.0 Adds the `$block_globals` argument to the `$args` parameter.
218
  *
219
  * @param array $args {
220
  * All values are optional.
@@ -230,124 +221,98 @@ class BP_Component {
230
  * 'Search Groups...'.
231
  * @type array $global_tables Optional. An array of database table names.
232
  * @type array $meta_tables Optional. An array of metadata table names.
233
- * @type array $block_globals Optional. An array of globalized data for BP Blocks.
234
  * }
235
  */
236
  public function setup_globals( $args = array() ) {
 
 
 
 
 
 
 
 
237
  $r = wp_parse_args( $args, array(
238
  'slug' => $this->id,
239
- 'root_slug' => '',
240
  'has_directory' => false,
241
  'directory_title' => '',
242
  'notification_callback' => '',
243
  'search_string' => '',
244
  'global_tables' => '',
245
  'meta_tables' => '',
246
- 'block_globals' => array(),
247
  ) );
248
 
249
- /** Slugs ************************************************************
 
 
 
 
 
250
  */
 
251
 
252
- // For all Components except Core.
253
- if ( 'core' !== $this->id ) {
254
- /**
255
- * If a WP directory page exists for the component, it should
256
- * be the default value of 'root_slug'.
257
- */
258
- if ( isset( buddypress()->pages->{$this->id}->slug ) ) {
259
- $r['root_slug'] = buddypress()->pages->{$this->id}->slug;
260
- }
261
 
262
- /**
263
- * Filters the slug to be used for the permalink URI chunk after root.
264
- *
265
- * @since 1.5.0
266
- *
267
- * @param string $value Slug to use in permalink URI chunk.
268
- */
269
- $this->slug = apply_filters( 'bp_' . $this->id . '_slug', $r['slug'] );
270
-
271
- /**
272
- * Filters the slug used for root directory.
273
- *
274
- * @since 1.5.0
275
- *
276
- * @param string $value Root directory slug.
277
- */
278
- $this->root_slug = apply_filters( 'bp_' . $this->id . '_root_slug', $r['root_slug'] );
279
-
280
- /**
281
- * Filters the component's top-level directory if available.
282
- *
283
- * @since 1.5.0
284
- *
285
- * @param bool $value Whether or not there is a top-level directory.
286
- */
287
- $this->has_directory = apply_filters( 'bp_' . $this->id . '_has_directory', $r['has_directory'] );
288
-
289
- /**
290
- * Filters the component's directory title.
291
- *
292
- * @since 2.0.0
293
- *
294
- * @param string $value Title to use for the directory.
295
- */
296
- $this->directory_title = apply_filters( 'bp_' . $this->id . '_directory_title', $r['directory_title'] );
297
-
298
- /**
299
- * Filters the placeholder text for search inputs for component.
300
- *
301
- * @since 1.5.0
302
- *
303
- * @param string $value Name to use in search input placeholders.
304
- */
305
- $this->search_string = apply_filters( 'bp_' . $this->id . '_search_string', $r['search_string'] );
306
-
307
- /**
308
- * Filters the callable function that formats the component's notifications.
309
- *
310
- * @since 1.5.0
311
- *
312
- * @param string $value Function callback.
313
- */
314
- $this->notification_callback = apply_filters( 'bp_' . $this->id . '_notification_callback', $r['notification_callback'] );
315
-
316
- // Set the global table names, if applicable.
317
- if ( ! empty( $r['global_tables'] ) ) {
318
- $this->register_global_tables( $r['global_tables'] );
319
- }
320
 
321
- // Set the metadata table, if applicable.
322
- if ( ! empty( $r['meta_tables'] ) ) {
323
- $this->register_meta_tables( $r['meta_tables'] );
324
- }
 
 
 
 
325
 
326
- // Register this component in the loaded components array.
327
- buddypress()->loaded_components[ $this->slug ] = $this->id;
328
- }
 
 
 
 
 
329
 
330
  /**
331
- * Filters the $blocks global value.
332
  *
333
- * @since 9.0.0
334
  *
335
- * @param array $blocks a list of global properties for blocks keyed
336
- * by their corresponding block name.
337
  */
338
- $block_globals = apply_filters( 'bp_' . $this->id . '_block_globals', $r['block_globals'] );
339
- if ( is_array( $block_globals ) && array_filter( $block_globals ) ) {
340
- foreach ( $block_globals as $block_name => $block_props ) {
341
- $this->block_globals[ $block_name ] = new stdClass();
342
 
343
- // Initialize an `items` property for Widget Block occurrences.
344
- $this->block_globals[ $block_name ]->items = array();
 
 
345
 
346
- // Set the global properties for the Block.
347
- $this->block_globals[ $block_name ]->props = (array) $block_props;
348
- }
349
  }
350
 
 
 
 
 
 
 
351
  /**
352
  * Fires at the end of the setup_globals method inside BP_Component.
353
  *
@@ -428,17 +393,6 @@ class BP_Component {
428
  do_action( 'bp_' . $this->id . '_includes' );
429
  }
430
 
431
- /**
432
- * Late includes method.
433
- *
434
- * Components should include files here only on specific pages using
435
- * conditionals such as {@link bp_is_current_component()}. Intentionally left
436
- * empty.
437
- *
438
- * @since 3.0.0
439
- */
440
- public function late_includes() {}
441
-
442
  /**
443
  * Set up the actions.
444
  *
@@ -460,9 +414,6 @@ class BP_Component {
460
  // extending this base class.
461
  add_action( 'bp_include', array( $this, 'includes' ), 8 );
462
 
463
- // Load files conditionally, based on certain pages.
464
- add_action( 'bp_late_include', array( $this, 'late_includes' ) );
465
-
466
  // Setup navigation.
467
  add_action( 'bp_setup_nav', array( $this, 'setup_nav' ), 10 );
468
 
@@ -496,16 +447,6 @@ class BP_Component {
496
  // Generate rewrite rules.
497
  add_action( 'bp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10 );
498
 
499
- // Register BP REST Endpoints.
500
- if ( bp_rest_in_buddypress() && bp_rest_api_is_available() ) {
501
- add_action( 'bp_rest_api_init', array( $this, 'rest_api_init' ), 10 );
502
- }
503
-
504
- // Register BP Blocks.
505
- if ( bp_support_blocks() ) {
506
- add_action( 'bp_blocks_init', array( $this, 'blocks_init' ), 10 );
507
- }
508
-
509
  /**
510
  * Fires at the end of the setup_actions method inside BP_Component.
511
  *
@@ -543,9 +484,6 @@ class BP_Component {
543
 
544
  // No sub nav items without a main nav item.
545
  if ( !empty( $main_nav ) ) {
546
- // Always set the component ID.
547
- $main_nav['component_id'] = $this->id;
548
-
549
  bp_core_new_nav_item( $main_nav, 'members' );
550
 
551
  // Sub nav items are not required.
@@ -618,7 +556,7 @@ class BP_Component {
618
  } else {
619
  $pos = $nav['position'];
620
 
621
- // Reset not set pos to 1.
622
  if ( $pos % 10 === 0 ) {
623
  $not_set_pos = 1;
624
  }
@@ -636,7 +574,7 @@ class BP_Component {
636
 
637
  // Add each admin menu.
638
  foreach( $this->admin_menu as $admin_menu ) {
639
- $wp_admin_bar->add_node( $admin_menu );
640
  }
641
  }
642
 
@@ -709,7 +647,7 @@ class BP_Component {
709
  // Add to the BuddyPress global object.
710
  if ( !empty( $tables ) && is_array( $tables ) ) {
711
  foreach ( $tables as $global_name => $table_name ) {
712
- $this->{$global_name} = $table_name;
713
  }
714
 
715
  // Keep a record of the metadata tables in the component.
@@ -902,87 +840,5 @@ class BP_Component {
902
  */
903
  do_action( 'bp_' . $this->id . '_generate_rewrite_rules' );
904
  }
905
-
906
- /**
907
- * Init the BP REST API.
908
- *
909
- * @since 5.0.0
910
- *
911
- * @param array $controllers The list of BP REST controllers to load.
912
- */
913
- public function rest_api_init( $controllers = array() ) {
914
- if ( is_array( $controllers ) && $controllers ) {
915
- // Built-in controllers.
916
- $_controllers = $controllers;
917
-
918
- /**
919
- * Use this filter to disable all or some REST API controllers
920
- * for the component.
921
- *
922
- * This is a dynamic hook that is based on the component string ID.
923
- *
924
- * @since 5.0.0
925
- *
926
- * @param array $controllers The list of BP REST API controllers to load.
927
- */
928
- $controllers = (array) apply_filters( 'bp_' . $this->id . '_rest_api_controllers', $controllers );
929
-
930
- foreach( $controllers as $controller ) {
931
- if ( ! in_array( $controller, $_controllers, true ) ) {
932
- continue;
933
- }
934
-
935
- $component_controller = new $controller;
936
- $component_controller->register_routes();
937
- }
938
- }
939
-
940
- /**
941
- * Fires in the rest_api_init method inside BP_Component.
942
- *
943
- * This is a dynamic hook that is based on the component string ID.
944
- *
945
- * @since 5.0.0
946
- */
947
- do_action( 'bp_' . $this->id . '_rest_api_init' );
948
- }
949
-
950
- /**
951
- * Register the BP Blocks.
952
- *
953
- * @since 6.0.0
954
- *
955
- * @see `BP_Block->construct()` for a full description of a BP Block arguments.
956
- *
957
- * @param array $blocks The list of BP Blocks to register.
958
- */
959
- public function blocks_init( $blocks = array() ) {
960
- /**
961
- * Filter here to add new BP Blocks, disable some or all BP Blocks for a component.
962
- *
963
- * This is a dynamic hook that is based on the component string ID.
964
- *
965
- * @since 6.0.0
966
- *
967
- * @param array $blocks The list of BP Blocks for the component.
968
- */
969
- $blocks = (array) apply_filters( 'bp_' . $this->id . '_register_blocks', $blocks );
970
- $blocks = array_filter( $blocks );
971
-
972
- if ( $blocks ) {
973
- foreach ( $blocks as $block ) {
974
- bp_register_block( $block );
975
- }
976
- }
977
-
978
- /**
979
- * Fires in the blocks_init method inside BP_Component.
980
- *
981
- * This is a dynamic hook that is based on the component string ID.
982
- *
983
- * @since 6.0.0
984
- */
985
- do_action( 'bp_' . $this->id . '_blocks_init' );
986
- }
987
  }
988
  endif; // BP_Component.
140
  */
141
  public $search_query_arg = 's';
142
 
 
 
 
 
 
 
 
 
 
143
  /** Methods ***************************************************************/
144
 
145
  /**
205
  * Set up component global variables.
206
  *
207
  * @since 1.5.0
208
+ *
209
  *
210
  * @param array $args {
211
  * All values are optional.
221
  * 'Search Groups...'.
222
  * @type array $global_tables Optional. An array of database table names.
223
  * @type array $meta_tables Optional. An array of metadata table names.
 
224
  * }
225
  */
226
  public function setup_globals( $args = array() ) {
227
+
228
+ /** Slugs ************************************************************
229
+ */
230
+
231
+ // If a WP directory page exists for the component, it should
232
+ // be the default value of 'root_slug'.
233
+ $default_root_slug = isset( buddypress()->pages->{$this->id}->slug ) ? buddypress()->pages->{$this->id}->slug : '';
234
+
235
  $r = wp_parse_args( $args, array(
236
  'slug' => $this->id,
237
+ 'root_slug' => $default_root_slug,
238
  'has_directory' => false,
239
  'directory_title' => '',
240
  'notification_callback' => '',
241
  'search_string' => '',
242
  'global_tables' => '',
243
  'meta_tables' => '',
 
244
  ) );
245
 
246
+ /**
247
+ * Filters the slug to be used for the permalink URI chunk after root.
248
+ *
249
+ * @since 1.5.0
250
+ *
251
+ * @param string $value Slug to use in permalink URI chunk.
252
  */
253
+ $this->slug = apply_filters( 'bp_' . $this->id . '_slug', $r['slug'] );
254
 
255
+ /**
256
+ * Filters the slug used for root directory.
257
+ *
258
+ * @since 1.5.0
259
+ *
260
+ * @param string $value Root directory slug.
261
+ */
262
+ $this->root_slug = apply_filters( 'bp_' . $this->id . '_root_slug', $r['root_slug'] );
 
263
 
264
+ /**
265
+ * Filters the component's top-level directory if available.
266
+ *
267
+ * @since 1.5.0
268
+ *
269
+ * @param bool $value Whether or not there is a top-level directory.
270
+ */
271
+ $this->has_directory = apply_filters( 'bp_' . $this->id . '_has_directory', $r['has_directory'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
 
273
+ /**
274
+ * Filters the component's directory title.
275
+ *
276
+ * @since 2.0.0
277
+ *
278
+ * @param string $value Title to use for the directory.
279
+ */
280
+ $this->directory_title = apply_filters( 'bp_' . $this->id . '_directory_title', $r['directory_title'] );
281
 
282
+ /**
283
+ * Filters the placeholder text for search inputs for component.
284
+ *
285
+ * @since 1.5.0
286
+ *
287
+ * @param string $value Name to use in search input placeholders.
288
+ */
289
+ $this->search_string = apply_filters( 'bp_' . $this->id . '_search_string', $r['search_string'] );
290
 
291
  /**
292
+ * Filters the callable function that formats the component's notifications.
293
  *
294
+ * @since 1.5.0
295
  *
296
+ * @param string $value Function callback.
 
297
  */
298
+ $this->notification_callback = apply_filters( 'bp_' . $this->id . '_notification_callback', $r['notification_callback'] );
 
 
 
299
 
300
+ // Set the global table names, if applicable.
301
+ if ( ! empty( $r['global_tables'] ) ) {
302
+ $this->register_global_tables( $r['global_tables'] );
303
+ }
304
 
305
+ // Set the metadata table, if applicable.
306
+ if ( ! empty( $r['meta_tables'] ) ) {
307
+ $this->register_meta_tables( $r['meta_tables'] );
308
  }
309
 
310
+ /** BuddyPress *******************************************************
311
+ */
312
+
313
+ // Register this component in the loaded components array.
314
+ buddypress()->loaded_components[$this->slug] = $this->id;
315
+
316
  /**
317
  * Fires at the end of the setup_globals method inside BP_Component.
318
  *
393
  do_action( 'bp_' . $this->id . '_includes' );
394
  }
395
 
 
 
 
 
 
 
 
 
 
 
 
396
  /**
397
  * Set up the actions.
398
  *
414
  // extending this base class.
415
  add_action( 'bp_include', array( $this, 'includes' ), 8 );
416
 
 
 
 
417
  // Setup navigation.
418
  add_action( 'bp_setup_nav', array( $this, 'setup_nav' ), 10 );
419
 
447
  // Generate rewrite rules.
448
  add_action( 'bp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10 );
449
 
 
 
 
 
 
 
 
 
 
 
450
  /**
451
  * Fires at the end of the setup_actions method inside BP_Component.
452
  *
484
 
485
  // No sub nav items without a main nav item.
486
  if ( !empty( $main_nav ) ) {
 
 
 
487
  bp_core_new_nav_item( $main_nav, 'members' );
488
 
489
  // Sub nav items are not required.
556
  } else {
557
  $pos = $nav['position'];
558
 
559
+ // Reset not set pos to 1
560
  if ( $pos % 10 === 0 ) {
561
  $not_set_pos = 1;
562
  }
574
 
575
  // Add each admin menu.
576
  foreach( $this->admin_menu as $admin_menu ) {
577
+ $wp_admin_bar->add_menu( $admin_menu );
578
  }
579
  }
580
 
647
  // Add to the BuddyPress global object.
648
  if ( !empty( $tables ) && is_array( $tables ) ) {
649
  foreach ( $tables as $global_name => $table_name ) {
650
+ $this->$global_name = $table_name;
651
  }
652
 
653
  // Keep a record of the metadata tables in the component.
840
  */
841
  do_action( 'bp_' . $this->id . '_generate_rewrite_rules' );
842
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
843
  }
844
  endif; // BP_Component.
bp-core/classes/class-bp-core-login-widget.php CHANGED
@@ -21,7 +21,6 @@ class BP_Core_Login_Widget extends WP_Widget {
21
  * Constructor method.
22
  *
23
  * @since 1.9.0
24
- * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
25
  */
26
  public function __construct() {
27
  parent::__construct(
@@ -31,7 +30,6 @@ class BP_Core_Login_Widget extends WP_Widget {
31
  'description' => __( 'Show a Log In form to logged-out visitors, and a Log Out link to those who are logged in.', 'buddypress' ),
32
  'classname' => 'widget_bp_core_login_widget buddypress widget',
33
  'customize_selective_refresh' => true,
34
- 'show_instance_in_rest' => true,
35
  )
36
  );
37
  }
21
  * Constructor method.
22
  *
23
  * @since 1.9.0
 
24
  */
25
  public function __construct() {
26
  parent::__construct(
30
  'description' => __( 'Show a Log In form to logged-out visitors, and a Log Out link to those who are logged in.', 'buddypress' ),
31
  'classname' => 'widget_bp_core_login_widget buddypress widget',
32
  'customize_selective_refresh' => true,
 
33
  )
34
  );
35
  }
bp-core/classes/class-bp-core-nav.php CHANGED
@@ -216,15 +216,15 @@ class BP_Core_Nav {
216
  */
217
  public function delete_nav( $slug = '', $parent_slug = '' ) {
218
 
219
- // Bail if slug is empty.
220
  if ( empty( $slug ) ) {
221
  return false;
222
  }
223
 
224
- // We're deleting a child.
225
  if ( ! empty( $parent_slug ) ) {
226
 
227
- // Validate the subnav.
228
  $sub_items = $this->get_secondary( array( 'parent_slug' => $parent_slug, 'slug' => $slug ), false );
229
 
230
  if ( ! $sub_items ) {
@@ -237,15 +237,15 @@ class BP_Core_Nav {
237
  return false;
238
  }
239
 
240
- // Delete the child.
241
  unset( $this->nav[ $this->object_id ][ $parent_slug . '/' . $slug ] );
242
 
243
- // Return the deleted item's screen function.
244
  return array( $sub_item->screen_function );
245
 
246
- // We're deleting a parent.
247
  } else {
248
- // Validate the nav.
249
  $nav_items = $this->get_primary( array( 'slug' => $slug ), false );
250
 
251
  if ( ! $nav_items ) {
@@ -267,7 +267,7 @@ class BP_Core_Nav {
267
  foreach ( $sub_items as $sub_item ) {
268
  $screen_functions[] = $sub_item->screen_function;
269
 
270
- // Delete the child.
271
  unset( $this->nav[ $this->object_id ][ $nav_item->slug . '/' . $sub_item->slug ] );
272
  }
273
  }
@@ -292,14 +292,14 @@ class BP_Core_Nav {
292
  $sorted = array();
293
 
294
  foreach ( $items as $item ) {
295
- // Default position.
296
  $position = 99;
297
 
298
  if ( isset( $item->position ) ) {
299
  $position = (int) $item->position;
300
  }
301
 
302
- // If position is already taken, move to the first next available.
303
  if ( isset( $sorted[ $position ] ) ) {
304
  $sorted_keys = array_keys( $sorted );
305
 
@@ -352,7 +352,7 @@ class BP_Core_Nav {
352
  *
353
  * @param array $args Filters to select the specific secondary items. See wp_list_filter().
354
  * @param bool $sort True to sort the nav items. False otherwise.
355
- * @return bool|array The list of secondary objects nav, or false if none set.
356
  */
357
  public function get_secondary( $args = array(), $sort = true ) {
358
  $params = wp_parse_args( $args, array( 'parent_slug' => '' ) );
216
  */
217
  public function delete_nav( $slug = '', $parent_slug = '' ) {
218
 
219
+ // Bail if slug is empty
220
  if ( empty( $slug ) ) {
221
  return false;
222
  }
223
 
224
+ // We're deleting a child
225
  if ( ! empty( $parent_slug ) ) {
226
 
227
+ // Validate the subnav
228
  $sub_items = $this->get_secondary( array( 'parent_slug' => $parent_slug, 'slug' => $slug ), false );
229
 
230
  if ( ! $sub_items ) {
237
  return false;
238
  }
239
 
240
+ // Delete the child
241
  unset( $this->nav[ $this->object_id ][ $parent_slug . '/' . $slug ] );
242
 
243
+ // Return the deleted item's screen function
244
  return array( $sub_item->screen_function );
245
 
246
+ // We're deleting a parent
247
  } else {
248
+ // Validate the nav
249
  $nav_items = $this->get_primary( array( 'slug' => $slug ), false );
250
 
251
  if ( ! $nav_items ) {
267
  foreach ( $sub_items as $sub_item ) {
268
  $screen_functions[] = $sub_item->screen_function;
269
 
270
+ // Delete the child
271
  unset( $this->nav[ $this->object_id ][ $nav_item->slug . '/' . $sub_item->slug ] );
272
  }
273
  }
292
  $sorted = array();
293
 
294
  foreach ( $items as $item ) {
295
+ // Default position
296
  $position = 99;
297
 
298
  if ( isset( $item->position ) ) {
299
  $position = (int) $item->position;
300
  }
301
 
302
+ // If position is already taken, move to the first next available
303
  if ( isset( $sorted[ $position ] ) ) {
304
  $sorted_keys = array_keys( $sorted );
305
 
352
  *
353
  * @param array $args Filters to select the specific secondary items. See wp_list_filter().
354
  * @param bool $sort True to sort the nav items. False otherwise.
355
+ * @return array The list of secondary objects nav
356
  */
357
  public function get_secondary( $args = array(), $sort = true ) {
358
  $params = wp_parse_args( $args, array( 'parent_slug' => '' ) );
bp-core/classes/class-bp-core-notification.php CHANGED
@@ -24,14 +24,14 @@ class BP_Core_Notification {
24
  *
25
  * @var int
26
  */
27
- public $id = 0;
28
 
29
  /**
30
  * The ID to which the notification relates to within the component.
31
  *
32
  * @var int
33
  */
34
- public $item_id = 0;
35
 
36
  /**
37
  * The secondary ID to which the notification relates to within the component.
@@ -45,35 +45,35 @@ class BP_Core_Notification {
45
  *
46
  * @var int
47
  */
48
- public $user_id = 0;
49
 
50
  /**
51
  * The name of the component that the notification is for.
52
  *
53
  * @var string
54
  */
55
- public $component_name = '';
56
 
57
  /**
58
  * The action within the component which the notification is related to.
59
  *
60
  * @var string
61
  */
62
- public $component_action = '';
63
 
64
  /**
65
  * The date the notification was created.
66
  *
67
  * @var string
68
  */
69
- public $date_notified = '';
70
 
71
  /**
72
  * Is the notification new or has it already been read.
73
  *
74
  * @var boolean
75
  */
76
- public $is_new = false;
77
 
78
  /** Public Methods ********************************************************/
79
 
@@ -83,14 +83,10 @@ class BP_Core_Notification {
83
  * @param int $id ID for the notification.
84
  */
85
  public function __construct( $id = 0 ) {
86
-
87
- // Bail if no ID
88
- if ( empty( $id ) ) {
89
- return;
90
  }
91
-
92
- $this->id = absint( $id );
93
- $this->populate();
94
  }
95
 
96
  /**
@@ -106,21 +102,16 @@ class BP_Core_Notification {
106
  $bp = buddypress();
107
 
108
  // Update.
109
- if ( ! empty( $this->id ) ) {
110
- $query = "UPDATE {$bp->notifications->table_name} SET item_id = %d, secondary_item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = %s, is_new = %d ) WHERE id = %d";
111
- $sql = $wpdb->prepare( $query, $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id );
112
 
113
  // Save.
114
  } else {
115
- $query = "INSERT INTO {$bp->notifications->table_name} ( item_id, secondary_item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %d, %s, %s, %s, %d )";
116
- $sql = $wpdb->prepare( $query, $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new );
117
  }
118
 
119
- $result = $wpdb->query( $sql );
120
-
121
- if ( empty( $result ) || is_wp_error( $result ) ) {
122
  return false;
123
- }
124
 
125
  $this->id = $wpdb->insert_id;
126
 
@@ -139,18 +130,14 @@ class BP_Core_Notification {
139
 
140
  $bp = buddypress();
141
 
142
- $query = "SELECT * FROM {$bp->notifications->table_name} WHERE id = %d";
143
- $prepare = $wpdb->prepare( $query, $this->id );
144
- $result = $wpdb->get_row( $prepare );
145
-
146
- if ( ! empty( $result ) ) {
147
- $this->item_id = $result->item_id;
148
- $this->secondary_item_id = $result->secondary_item_id;
149
- $this->user_id = $result->user_id;
150
- $this->component_name = $result->component_name;
151
- $this->component_action = $result->component_action;
152
- $this->date_notified = $result->date_notified;
153
- $this->is_new = $result->is_new;
154
  }
155
  }
156
 
@@ -163,16 +150,12 @@ class BP_Core_Notification {
163
  * @param int $notification_id Notification ID to check for.
164
  * @return string
165
  */
166
- public static function check_access( $user_id = 0, $notification_id = 0 ) {
167
  global $wpdb;
168
 
169
  $bp = buddypress();
170
 
171
- $query = "SELECT COUNT(id) FROM {$bp->notifications->table_name} WHERE id = %d AND user_id = %d";
172
- $prepare = $wpdb->prepare( $query, $notification_id, $user_id );
173
- $result = $wpdb->get_var( $prepare );
174
-
175
- return $result;
176
  }
177
 
178
  /**
@@ -195,11 +178,7 @@ class BP_Core_Notification {
195
  ? ' AND is_new = 1 '
196
  : '';
197
 
198
- $query = "SELECT * FROM {$bp->notifications->table_name} WHERE user_id = %d {$is_new}";
199
- $prepare = $wpdb->prepare( $query, $user_id );
200
- $result = $wpdb->get_results( $prepare );
201
-
202
- return $result;
203
  }
204
 
205
  /**
@@ -219,11 +198,7 @@ class BP_Core_Notification {
219
 
220
  $bp = buddypress();
221
 
222
- $query = "DELETE FROM {$bp->notifications->table_name} WHERE user_id = %d AND component_name = %s AND component_action = %s";
223
- $prepare = $wpdb->prepare( $query, $user_id, $component_name, $component_action );
224
- $result = $wpdb->query( $prepare );
225
-
226
- return $result;
227
  }
228
 
229
  /**
@@ -237,24 +212,20 @@ class BP_Core_Notification {
237
  * @param int $item_id The item ID of the notifications we wish to delete.
238
  * @param string $component_name The name of the component that the notifications we wish to delete.
239
  * @param string $component_action The action of the component that the notifications we wish to delete.
240
- * @param int $secondary_item_id (optional) The secondary item id of the notifications that we wish to
241
  * use to delete.
242
  * @return mixed
243
  */
244
- public static function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = 0 ) {
245
  global $wpdb;
246
 
247
  $bp = buddypress();
248
 
249
- $secondary_item_sql = ! empty( $secondary_item_id )
250
  ? $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id )
251
  : '';
252
 
253
- $query = "DELETE FROM {$bp->notifications->table_name} WHERE user_id = %d AND item_id = %d AND component_name = %s AND component_action = %s{$secondary_item_sql}";
254
- $prepare = $wpdb->prepare( $query, $user_id, $item_id, $component_name, $component_action );
255
- $result = $wpdb->query( $prepare );
256
-
257
- return $result;
258
  }
259
 
260
  /**
@@ -274,11 +245,7 @@ class BP_Core_Notification {
274
 
275
  $bp = buddypress();
276
 
277
- $query = "DELETE FROM {$bp->notifications->table_name} WHERE item_id = %d AND component_name = %s AND component_action = %s";
278
- $prepare = $wpdb->prepare( $query, $user_id, $component_name, $component_action );
279
- $result = $wpdb->query( $prepare );
280
-
281
- return $result;
282
  }
283
 
284
  /**
@@ -289,29 +256,27 @@ class BP_Core_Notification {
289
  *
290
  * @static
291
  *
292
- * @param int $item_id The item id that they notifications are to be for.
293
  * @param string $component_name The component that the notifications are to be from.
294
  * @param string $component_action The action that the notifications are to be from.
295
- * @param int $secondary_item_id Optional secondary item id that the notifications are to have.
296
  * @return mixed
297
  */
298
- public static function delete_all_by_type( $item_id, $component_name, $component_action = '', $secondary_item_id = 0 ) {
299
  global $wpdb;
300
 
301
- $component_action_sql = ! empty( $component_action )
302
- ? $wpdb->prepare( "AND component_action = %s", $component_action )
303
- : '';
 
304
 
305
- $secondary_item_sql = ! empty( $secondary_item_id )
306
- ? $wpdb->prepare( "AND secondary_item_id = %d", $secondary_item_id )
307
- : '';
 
308
 
309
  $bp = buddypress();
310
 
311
- $query = "DELETE FROM {$bp->notifications->table_name} WHERE item_id = %d AND component_name = %s {$component_action_sql} {$secondary_item_sql}";
312
- $prepare = $wpdb->prepare( $query, $item_id, $component_name );
313
- $result = $wpdb->query( $prepare );
314
-
315
- return $result;
316
  }
317
  }
24
  *
25
  * @var int
26
  */
27
+ public $id;
28
 
29
  /**
30
  * The ID to which the notification relates to within the component.
31
  *
32
  * @var int
33
  */
34
+ public $item_id;
35
 
36
  /**
37
  * The secondary ID to which the notification relates to within the component.
45
  *
46
  * @var int
47
  */
48
+ public $user_id;
49
 
50
  /**
51
  * The name of the component that the notification is for.
52
  *
53
  * @var string
54
  */
55
+ public $component_name;
56
 
57
  /**
58
  * The action within the component which the notification is related to.
59
  *
60
  * @var string
61
  */
62
+ public $component_action;
63
 
64
  /**
65
  * The date the notification was created.
66
  *
67
  * @var string
68
  */
69
+ public $date_notified;
70
 
71
  /**
72
  * Is the notification new or has it already been read.
73
  *
74
  * @var boolean
75
  */
76
+ public $is_new;
77
 
78
  /** Public Methods ********************************************************/
79
 
83
  * @param int $id ID for the notification.
84
  */
85
  public function __construct( $id = 0 ) {
86
+ if ( !empty( $id ) ) {
87
+ $this->id = $id;
88
+ $this->populate();
 
89
  }
 
 
 
90
  }
91
 
92
  /**
102
  $bp = buddypress();
103
 
104
  // Update.
105
+ if ( !empty( $this->id ) ) {
106
+ $sql = $wpdb->prepare( "UPDATE {$bp->core->table_name_notifications} SET item_id = %d, secondary_item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = %s, is_new = %d ) WHERE id = %d", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id );
 
107
 
108
  // Save.
109
  } else {
110
+ $sql = $wpdb->prepare( "INSERT INTO {$bp->core->table_name_notifications} ( item_id, secondary_item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %d, %s, %s, %s, %d )", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new );
 
111
  }
112
 
113
+ if ( !$result = $wpdb->query( $sql ) )
 
 
114
  return false;
 
115
 
116
  $this->id = $wpdb->insert_id;
117
 
130
 
131
  $bp = buddypress();
132
 
133
+ if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) {
134
+ $this->item_id = $notification->item_id;
135
+ $this->secondary_item_id = $notification->secondary_item_id;
136
+ $this->user_id = $notification->user_id;
137
+ $this->component_name = $notification->component_name;
138
+ $this->component_action = $notification->component_action;
139
+ $this->date_notified = $notification->date_notified;
140
+ $this->is_new = $notification->is_new;
 
 
 
 
141
  }
142
  }
143
 
150
  * @param int $notification_id Notification ID to check for.
151
  * @return string
152
  */
153
+ public static function check_access( $user_id, $notification_id ) {
154
  global $wpdb;
155
 
156
  $bp = buddypress();
157
 
158
+ 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 ) );
 
 
 
 
159
  }
160
 
161
  /**
178
  ? ' AND is_new = 1 '
179
  : '';
180
 
181
+ return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d {$is_new}", $user_id ) );
 
 
 
 
182
  }
183
 
184
  /**
198
 
199
  $bp = buddypress();
200
 
201
+ 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 ) );
 
 
 
 
202
  }
203
 
204
  /**
212
  * @param int $item_id The item ID of the notifications we wish to delete.
213
  * @param string $component_name The name of the component that the notifications we wish to delete.
214
  * @param string $component_action The action of the component that the notifications we wish to delete.
215
+ * @param int|bool $secondary_item_id (optional) The secondary item id of the notifications that we wish to
216
  * use to delete.
217
  * @return mixed
218
  */
219
+ public static function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) {
220
  global $wpdb;
221
 
222
  $bp = buddypress();
223
 
224
+ $secondary_item_sql = !empty( $secondary_item_id )
225
  ? $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id )
226
  : '';
227
 
228
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND item_id = %d AND component_name = %s AND component_action = %s{$secondary_item_sql}", $user_id, $item_id, $component_name, $component_action ) );
 
 
 
 
229
  }
230
 
231
  /**
245
 
246
  $bp = buddypress();
247
 
248
+ 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 ) );
 
 
 
 
249
  }
250
 
251
  /**
256
  *
257
  * @static
258
  *
259
+ * @param string $item_id The item id that they notifications are to be for.
260
  * @param string $component_name The component that the notifications are to be from.
261
  * @param string $component_action The action that the notifications are to be from.
262
+ * @param string $secondary_item_id Optional secondary item id that the notifications are to have.
263
  * @return mixed
264
  */
265
+ public static function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) {
266
  global $wpdb;
267
 
268
+ if ( $component_action )
269
+ $component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action );
270
+ else
271
+ $component_action_sql = '';
272
 
273
+ if ( $secondary_item_id )
274
+ $secondary_item_sql = $wpdb->prepare( "AND secondary_item_id = %d", $secondary_item_id );
275
+ else
276
+ $secondary_item_sql = '';
277
 
278
  $bp = buddypress();
279
 
280
+ return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s {$component_action_sql} {$secondary_item_sql}", $item_id, $component_name ) );
 
 
 
 
281
  }
282
  }
bp-core/classes/class-bp-core-oembed-extension.php CHANGED
@@ -230,10 +230,9 @@ abstract class BP_Core_oEmbed_Extension {
230
 
231
  register_rest_route( 'oembed/1.0', "/embed/{$this->slug_endpoint}", array(
232
  array(
233
- 'methods' => WP_REST_Server::READABLE,
234
- 'callback' => array( $this, 'get_item' ),
235
- 'permission_callback' => '__return_true',
236
- 'args' => $args
237
  ),
238
  ) );
239
  }
@@ -425,7 +424,7 @@ abstract class BP_Core_oEmbed_Extension {
425
  if ( ! empty( $item_id ) ) {
426
  // Add markers to tell that we're embedding a single activity.
427
  // This is needed for various oEmbed response data filtering.
428
- if ( ! isset( buddypress()->{$this->slug_endpoint} ) || ! buddypress()->{$this->slug_endpoint} ) {
429
  buddypress()->{$this->slug_endpoint} = new stdClass;
430
  }
431
  buddypress()->{$this->slug_endpoint}->embedurl_in_progress = $url;
@@ -534,7 +533,7 @@ abstract class BP_Core_oEmbed_Extension {
534
  $url = add_query_arg( 'embed', 'true', trailingslashit( $url ) );
535
 
536
  // Add custom route args to iframe.
537
- if ( isset( buddypress()->{$this->slug_endpoint}->embedargs_in_progress ) && buddypress()->{$this->slug_endpoint}->embedargs_in_progress ) {
538
  foreach( buddypress()->{$this->slug_endpoint}->embedargs_in_progress as $key => $value ) {
539
  $url = add_query_arg( $key, $value, $url );
540
  }
230
 
231
  register_rest_route( 'oembed/1.0', "/embed/{$this->slug_endpoint}", array(
232
  array(
233
+ 'methods' => WP_REST_Server::READABLE,
234
+ 'callback' => array( $this, 'get_item' ),
235
+ 'args' => $args
 
236
  ),
237
  ) );
238
  }
424
  if ( ! empty( $item_id ) ) {
425
  // Add markers to tell that we're embedding a single activity.
426
  // This is needed for various oEmbed response data filtering.
427
+ if ( empty( buddypress()->{$this->slug_endpoint} ) ) {
428
  buddypress()->{$this->slug_endpoint} = new stdClass;
429
  }
430
  buddypress()->{$this->slug_endpoint}->embedurl_in_progress = $url;
533
  $url = add_query_arg( 'embed', 'true', trailingslashit( $url ) );
534
 
535
  // Add custom route args to iframe.
536
+ if ( ! empty( buddypress()->{$this->slug_endpoint}->embedargs_in_progress ) ) {
537
  foreach( buddypress()->{$this->slug_endpoint}->embedargs_in_progress as $key => $value ) {
538
  $url = add_query_arg( $key, $value, $url );
539
  }
bp-core/classes/class-bp-core-user.php CHANGED
@@ -166,46 +166,15 @@ class BP_Core_User {
166
  $this->email = esc_attr( bp_core_get_user_email( $this->id ) );
167
  }
168
 
169
- $this->avatar = bp_core_fetch_avatar(
170
- array(
171
- 'item_id' => $this->id,
172
- 'type' => 'full',
173
- 'alt' => sprintf(
174
- /* translators: %s: member name */
175
- __( 'Profile photo of %s', 'buddypress' ),
176
- $this->fullname
177
- )
178
- )
179
- );
180
-
181
- $this->avatar_thumb = bp_core_fetch_avatar(
182
- array(
183
- 'item_id' => $this->id,
184
- 'type' => 'thumb',
185
- 'alt' => sprintf(
186
- /* translators: %s: member name */
187
- __( 'Profile photo of %s', 'buddypress' ),
188
- $this->fullname
189
- )
190
- )
191
- );
192
-
193
- $this->avatar_mini = bp_core_fetch_avatar(
194
- array(
195
- 'item_id' => $this->id,
196
- 'type' => 'thumb',
197
- 'alt' => sprintf(
198
- /* translators: %s: member name */
199
- __( 'Profile photo of %s', 'buddypress' ),
200
- $this->fullname
201
- ),
202
- 'width' => 30,
203
- 'height' => 30
204
- )
205
- );
206
-
207
- /* translators: %s: human time diff of the last time the user was active on the site. */
208
- $this->last_active = bp_core_get_last_activity( bp_get_user_last_activity( $this->id ), _x( 'Active %s', 'last time the user was active', 'buddypress' ) );
209
  }
210
 
211
  /**
@@ -219,11 +188,7 @@ class BP_Core_User {
219
 
220
  if ( bp_is_active( 'groups' ) ) {
221
  $this->total_groups = BP_Groups_Member::total_group_count( $this->id );
222
- $this->total_groups = sprintf(
223
- /* translators: %s: total groups count */
224
- _n( '%d group', '%d groups', $this->total_groups, 'buddypress' ),
225
- $this->total_groups
226
- );
227
  }
228
  }
229
 
@@ -760,12 +725,11 @@ class BP_Core_User {
760
 
761
  // Fetch the user's last_activity.
762
  if ( 'active' != $type ) {
763
- $user_activity = self::get_last_activity( $user_ids );
764
  for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
765
  foreach ( (array) $user_activity as $activity ) {
766
- if ( ! empty( $activity['user_id'] ) && (int) $activity['user_id'] === (int) $paged_users[$i]->id ) {
767
- $paged_users[$i]->last_activity = $activity['date_recorded'];
768
- }
769
  }
770
  }
771
  }
@@ -785,13 +749,18 @@ class BP_Core_User {
785
  /**
786
  * Get WordPress user details for a specified user.
787
  *
788
- * @since 3.0.0 Results might be from cache
789
  *
790
  * @param int $user_id User ID.
791
- * @return false|object WP_User if successful, false on failure.
792
  */
793
  public static function get_core_userdata( $user_id ) {
794
- return WP_User::get_data_by( 'id', $user_id );
 
 
 
 
 
795
  }
796
 
797
  /**
166
  $this->email = esc_attr( bp_core_get_user_email( $this->id ) );
167
  }
168
 
169
+ // Cache a few things that are fetched often.
170
+ wp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, 'bp' );
171
+ wp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' );
172
+ wp_cache_set( 'bp_user_url_' . $this->id, $this->user_url, 'bp' );
173
+
174
+ $this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) );
175
+ $this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) );
176
+ $this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ), 'width' => 30, 'height' => 30 ) );
177
+ $this->last_active = bp_core_get_last_activity( bp_get_user_last_activity( $this->id ), __( 'active %s', 'buddypress' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  }
179
 
180
  /**
188
 
189
  if ( bp_is_active( 'groups' ) ) {
190
  $this->total_groups = BP_Groups_Member::total_group_count( $this->id );
191
+ $this->total_groups = sprintf( _n( '%d group', '%d groups', $this->total_groups, 'buddypress' ), $this->total_groups );
 
 
 
 
192
  }
193
  }
194
 
725
 
726
  // Fetch the user's last_activity.
727
  if ( 'active' != $type ) {
728
+ $user_activity = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as last_activity FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'last_activity' ) ) );
729
  for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
730
  foreach ( (array) $user_activity as $activity ) {
731
+ if ( $activity->id == $paged_users[$i]->id )
732
+ $paged_users[$i]->last_activity = $activity->last_activity;
 
733
  }
734
  }
735
  }
749
  /**
750
  * Get WordPress user details for a specified user.
751
  *
752
+ * @global wpdb $wpdb WordPress database object.
753
  *
754
  * @param int $user_id User ID.
755
+ * @return array Associative array.
756
  */
757
  public static function get_core_userdata( $user_id ) {
758
+ global $wpdb;
759
+
760
+ if ( !$user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->users} WHERE ID = %d LIMIT 1", $user_id ) ) )
761
+ return false;
762
+
763
+ return $user;
764
  }
765
 
766
  /**
bp-core/classes/class-bp-core.php CHANGED
@@ -35,31 +35,6 @@ class BP_Core extends BP_Component {
35
  $this->bootstrap();
36
  }
37
 
38
- /**
39
- * Magic getter.
40
- *
41
- * This exists specifically for supporting deprecated object vars.
42
- *
43
- * @since 7.0.0
44
- *
45
- * @param string $key
46
- * @return mixed
47
- */
48
- public function __get( $key = '' ) {
49
-
50
- // Backwards compatibility for the original Notifications table var
51
- if ( 'table_name_notifications' === $key ) {
52
- return bp_is_active( 'notifications' )
53
- ? buddypress()->notifications->table_name
54
- : buddypress()->table_prefix . 'bp_notifications';
55
- }
56
-
57
- // Return object var if set, else null
58
- return isset( $this->{$key} )
59
- ? $this->{$key}
60
- : null;
61
- }
62
-
63
  /**
64
  * Populate the global data needed before BuddyPress can continue.
65
  *
@@ -90,7 +65,7 @@ class BP_Core extends BP_Component {
90
  *
91
  * @param array $value Array of included and optional components.
92
  */
93
- $bp->optional_components = apply_filters( 'bp_optional_components', array( 'activity', 'blogs', 'friends', 'groups', 'messages', 'notifications', 'settings', 'xprofile' ) );
94
 
95
  /**
96
  * Filters the required components.
@@ -274,6 +249,10 @@ class BP_Core extends BP_Component {
274
  */
275
  $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', $bp->grav_default->user );
276
 
 
 
 
 
277
  // Backward compatibility for plugins modifying the legacy bp_nav and bp_options_nav global properties.
278
  $bp->bp_nav = new BP_Core_BP_Nav_BackCompat();
279
  $bp->bp_options_nav = new BP_Core_BP_Options_Nav_BackCompat();
@@ -289,17 +268,14 @@ class BP_Core extends BP_Component {
289
  bp_update_is_item_admin( bp_user_has_access(), 'core' );
290
 
291
  // Is the logged in user is a mod for the current item?
292
- bp_update_is_item_mod( false, 'core' );
293
-
294
- parent::setup_globals(
295
- array(
296
- 'block_globals' => array(
297
- 'bp/login-form' => array(
298
- 'widget_classnames' => array( 'widget_bp_core_login_widget', 'buddyp
35
  $this->bootstrap();
36
  }
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  /**
39
  * Populate the global data needed before BuddyPress can continue.
40
  *
65
  *
66
  * @param array $value Array of included and optional components.
67
  */
68
+ $bp->optional_components = apply_filters( 'bp_optional_components', array( 'activity', 'blogs', 'forums', 'friends', 'groups', 'messages', 'notifications', 'settings', 'xprofile' ) );
69
 
70
  /**
71
  * Filters the required components.
249
  */
250
  $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', $bp->grav_default->user );
251
 
252
+ // Notifications table. Included here for legacy purposes. Use
253
+ // bp-notifications instead.
254
+ $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
255
+
256
  // Backward compatibility for plugins modifying the legacy bp_nav and bp_options_nav global properties.
257
  $bp->bp_nav = new BP_Core_BP_Nav_BackCompat();
258
  $bp->bp_options_nav = new BP_Core_BP_Options_Nav_BackCompat();
268
  bp_update_is_item_admin( bp_user_has_access(), 'core' );
269
 
270
  // Is the logged in user is a mod for the current item?