Version Description
See: https://codex.buddypress.org/releases/version-2-3-5/
Download this release
Release Info
Developer | boonebgorges |
Plugin | BuddyPress |
Version | 2.3.5 |
Comparing to | |
See all releases |
Code changes from version 2.2.4 to 2.3.5
- bp-activity/admin/css/admin-rtl.css +7 -0
- bp-activity/admin/css/admin-rtl.min.css +1 -1
- bp-activity/admin/css/admin.css +7 -0
- bp-activity/admin/css/admin.min.css +1 -1
- bp-activity/admin/js/admin.min.js +1 -1
- bp-activity/bp-activity-actions.php +41 -36
- bp-activity/bp-activity-admin.php +98 -37
- bp-activity/bp-activity-akismet.php +74 -64
- bp-activity/bp-activity-cache.php +6 -6
- bp-activity/bp-activity-classes.php +3 -2379
- bp-activity/bp-activity-cssjs.php +24 -2
- bp-activity/bp-activity-filters.php +50 -23
- bp-activity/bp-activity-functions.php +417 -217
- bp-activity/bp-activity-loader.php +32 -29
- bp-activity/bp-activity-notifications.php +69 -63
- bp-activity/bp-activity-screens.php +14 -13
- bp-activity/bp-activity-template.php +507 -341
- bp-activity/classes/class-bp-activity-activity.php +1800 -0
- bp-activity/classes/class-bp-activity-feed.php +446 -0
- bp-activity/classes/class-bp-activity-query.php +258 -0
- bp-activity/js/mentions.js +23 -29
- bp-activity/js/mentions.min.js +2 -2
- bp-blogs/bp-blogs-activity.php +6 -12
- bp-blogs/bp-blogs-classes.php +1 -564
- bp-blogs/bp-blogs-filters.php +6 -4
- bp-blogs/bp-blogs-functions.php +44 -22
- bp-blogs/bp-blogs-loader.php +25 -5
- bp-blogs/bp-blogs-template.php +45 -27
- bp-blogs/bp-blogs-widgets.php +45 -29
- bp-blogs/classes/class-bp-blogs-blog.php +608 -0
- bp-core/admin/{bp-core-actions.php → bp-core-admin-actions.php} +92 -29
- bp-core/admin/{bp-core-components.php → bp-core-admin-components.php} +29 -9
- bp-core/admin/{bp-core-functions.php → bp-core-admin-functions.php} +49 -28
- bp-core/admin/{bp-core-schema.php → bp-core-admin-schema.php} +19 -6
- bp-core/admin/{bp-core-settings.php → bp-core-admin-settings.php} +52 -25
- bp-core/admin/{bp-core-slugs.php → bp-core-admin-slugs.php} +36 -6
- bp-core/admin/{bp-core-tools.php → bp-core-admin-tools.php} +23 -5
- bp-core/admin/css/common-rtl.css +53 -0
- bp-core/admin/css/common-rtl.min.css +1 -1
- bp-core/admin/css/common.css +53 -0
- bp-core/admin/css/common.min.css +1 -1
- bp-core/admin/images/avatar-ui.gif +0 -0
- bp-core/admin/images/member-types.png +0 -0
- bp-core/bp-core-actions.php +1 -0
- bp-core/bp-core-admin.php +124 -125
- bp-core/bp-core-attachments.php +406 -0
- bp-core/bp-core-avatars.php +845 -182
- bp-core/bp-core-buddybar.php +43 -25
- bp-core/bp-core-cache.php +6 -0
- bp-core/bp-core-caps.php +64 -2
- bp-core/bp-core-catchuri.php +155 -30
- bp-core/bp-core-classes.php +14 -2965
- bp-core/bp-core-component.php +224 -47
- bp-core/bp-core-cssjs.php +91 -16
- bp-core/bp-core-dependency.php +266 -10
- bp-core/bp-core-filters.php +226 -8
- bp-core/bp-core-functions.php +423 -15
- bp-core/bp-core-loader.php +65 -9
- bp-core/bp-core-moderation.php +43 -2
- bp-core/bp-core-options.php +215 -6
- bp-core/bp-core-taxonomy.php +28 -0
- bp-core/bp-core-template-loader.php +90 -4
- bp-core/bp-core-template.php +552 -51
- bp-core/bp-core-theme-compatibility.php +78 -8
- bp-core/bp-core-update.php +90 -8
- bp-core/bp-core-widgets.php +45 -6
- bp-core/classes/class-bp-attachment-avatar.php +415 -0
- bp-core/classes/class-bp-attachment.php +518 -0
- bp-core/classes/class-bp-button.php +270 -0
- bp-core/classes/class-bp-core-notification.php +258 -0
- bp-core/classes/class-bp-core-user.php +958 -0
- bp-core/classes/class-bp-date-query.php +65 -0
- bp-core/classes/class-bp-embed.php +239 -0
bp-activity/admin/css/admin-rtl.css
CHANGED
@@ -44,6 +44,7 @@
|
|
44 |
Â
}
|
45 |
Â
#bp-activities-form .column-response img {
|
46 |
Â
float: right;
|
Â
|
|
47 |
Â
margin-left: 10px;
|
48 |
Â
margin-top: 1px;
|
49 |
Â
}
|
@@ -78,3 +79,9 @@
|
|
78 |
Â
.column-action {
|
79 |
Â
width: 12%;
|
80 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
44 |
Â
}
|
45 |
Â
#bp-activities-form .column-response img {
|
46 |
Â
float: right;
|
47 |
+
margin-bottom: 5px;
|
48 |
Â
margin-left: 10px;
|
49 |
Â
margin-top: 1px;
|
50 |
Â
}
|
79 |
Â
.column-action {
|
80 |
Â
width: 12%;
|
81 |
Â
}
|
82 |
+
|
83 |
+
@media screen and (max-width: 782px) {
|
84 |
+
body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column) {
|
85 |
+
display: table-cell;
|
86 |
+
}
|
87 |
+
}
|
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.4em;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:left;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:right;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%}
|
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.4em;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float: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
@@ -44,6 +44,7 @@
|
|
44 |
Â
}
|
45 |
Â
#bp-activities-form .column-response img {
|
46 |
Â
float: left;
|
Â
|
|
47 |
Â
margin-right: 10px;
|
48 |
Â
margin-top: 1px;
|
49 |
Â
}
|
@@ -78,3 +79,9 @@
|
|
78 |
Â
.column-action {
|
79 |
Â
width: 12%;
|
80 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
44 |
Â
}
|
45 |
Â
#bp-activities-form .column-response img {
|
46 |
Â
float: left;
|
47 |
+
margin-bottom: 5px;
|
48 |
Â
margin-right: 10px;
|
49 |
Â
margin-top: 1px;
|
50 |
Â
}
|
79 |
Â
.column-action {
|
80 |
Â
width: 12%;
|
81 |
Â
}
|
82 |
+
|
83 |
+
@media screen and (max-width: 782px) {
|
84 |
+
body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column) {
|
85 |
+
display: table-cell;
|
86 |
+
}
|
87 |
+
}
|
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.4em;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:left;margin-right:10px;margin-top:1px}.activity-errors{list-style-type:disc;margin-left:2em}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0}#bp_activity_action h3,#bp_activity_content h3{cursor:auto}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:#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%}
|
1 |
+
.akismet-status{float:right}.akismet-status a{color:#AAA;font-style:italic}.akismet-history{margin:13px}.akismet-history div{margin-bottom:13px}.akismet-history span{color:#999}#wp-bp-activities-wrap{padding:5px 0}#bp-activities{height:120px}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:left;margin-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.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
/*! buddypress - v2.
|
2 |
Â
!function(a){var b={init:function(){a(document).on("click",".row-actions a.reply",b.open),a(document).on("click","#bp-activities-container a.cancel",b.close),a(document).on("click","#bp-activities-container a.save",b.send),a(document).on("keyup","#bp-activities:visible",function(a){27===a.which&&b.close()})},open:function(){var b=a("#bp-activities-container").hide();return a(this).parents("tr").after(b),b.fadeIn("300"),a("#bp-activities").focus(),!1},close:function(){return a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide()}),!1},send:function(){a("#bp-replysubmit .error").hide(),a("#bp-replysubmit .waiting").show();var c={};return c["_ajax_nonce-bp-activity-admin-reply"]=a('#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]').val(),c.action="bp-activity-admin-reply",c.content=a("#bp-activities").val(),c.parent_id=a("#bp-activities-container").prev().data("parent_id"),c.root_id=a("#bp-activities-container").prev().data("root_id"),a.ajax({data:c,type:"POST",url:ajaxurl,error:function(a){b.error(a)},success:function(a){b.show(a)}}),!1},error:function(b){var c=b.statusText;a("#bp-replysubmit .waiting").hide(),b.responseText&&(c=b.responseText.replace(/<.[^<>]*?>/g,"")),c&&a("#bp-replysubmit .error").html(c).show()},show:function(c){var d,e,f;return"string"==typeof c?(b.error({responseText:c}),!1):(f=wpAjax.parseAjaxResponse(c),f.errors?(b.error({responseText:wpAjax.broken}),!1):(f=f.responses[0],void a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide(),a("#bp-activities-container").before(f.data),e=a("#activity-"+f.id),d=e.closest(".widefat").css("backgroundColor"),e.animate({backgroundColor:"#CEB"},300).animate({backgroundColor:d},300)})))}};a(document).ready(function(){b.init(),a("#bp_activity_action h3, #bp_activity_content h3").unbind("click"),"undefined"!=typeof postboxes&&postboxes.add_postbox_toggles(bp_activity_admin_vars.page)})}(jQuery);
|
1 |
+
/*! buddypress - v2.3.5 - 2015-11-11 5:23:00 AM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
Â
!function(a){var b={init:function(){a(document).on("click",".row-actions a.reply",b.open),a(document).on("click","#bp-activities-container a.cancel",b.close),a(document).on("click","#bp-activities-container a.save",b.send),a(document).on("keyup","#bp-activities:visible",function(a){27===a.which&&b.close()})},open:function(){var b=a("#bp-activities-container").hide();return a(this).parents("tr").after(b),b.fadeIn("300"),a("#bp-activities").focus(),!1},close:function(){return a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide()}),!1},send:function(){a("#bp-replysubmit .error").hide(),a("#bp-replysubmit .waiting").show();var c={};return c["_ajax_nonce-bp-activity-admin-reply"]=a('#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]').val(),c.action="bp-activity-admin-reply",c.content=a("#bp-activities").val(),c.parent_id=a("#bp-activities-container").prev().data("parent_id"),c.root_id=a("#bp-activities-container").prev().data("root_id"),a.ajax({data:c,type:"POST",url:ajaxurl,error:function(a){b.error(a)},success:function(a){b.show(a)}}),!1},error:function(b){var c=b.statusText;a("#bp-replysubmit .waiting").hide(),b.responseText&&(c=b.responseText.replace(/<.[^<>]*?>/g,"")),c&&a("#bp-replysubmit .error").html(c).show()},show:function(c){var d,e,f;return"string"==typeof c?(b.error({responseText:c}),!1):(f=wpAjax.parseAjaxResponse(c),f.errors?(b.error({responseText:wpAjax.broken}),!1):(f=f.responses[0],void a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide(),a("#bp-activities-container").before(f.data),e=a("#activity-"+f.id),d=e.closest(".widefat").css("backgroundColor"),e.animate({backgroundColor:"#CEB"},300).animate({backgroundColor:d},300)})))}};a(document).ready(function(){b.init(),a("#bp_activity_action h3, #bp_activity_content h3").unbind("click"),"undefined"!=typeof postboxes&&postboxes.add_postbox_toggles(bp_activity_admin_vars.page)})}(jQuery);
|
bp-activity/bp-activity-actions.php
CHANGED
@@ -33,9 +33,8 @@ add_action( 'bp_init', 'bp_register_activity_actions', 8 );
|
|
33 |
Â
/**
|
34 |
Â
* Catch and route requests for single activity item permalinks.
|
35 |
Â
*
|
36 |
-
* @since BuddyPress (1.2)
|
37 |
Â
*
|
38 |
-
* @global object $bp BuddyPress global settings
|
39 |
Â
* @uses bp_is_activity_component()
|
40 |
Â
* @uses bp_is_current_action()
|
41 |
Â
* @uses bp_action_variable()
|
@@ -121,7 +120,7 @@ add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
|
|
121 |
Â
/**
|
122 |
Â
* Delete specific activity item and redirect to previous page.
|
123 |
Â
*
|
124 |
-
* @since BuddyPress (1.1)
|
125 |
Â
*
|
126 |
Â
* @param int $activity_id Activity id to be deleted. Defaults to 0.
|
127 |
Â
*
|
@@ -167,7 +166,7 @@ function bp_activity_action_delete_activity( $activity_id = 0 ) {
|
|
167 |
Â
* @since BuddyPress (1.5.0)
|
168 |
Â
*
|
169 |
Â
* @param int $activity_id The activity ID.
|
170 |
-
* @param int $user_id
|
171 |
Â
*/
|
172 |
Â
do_action( 'bp_activity_before_action_delete_activity', $activity_id, $activity->user_id );
|
173 |
Â
|
@@ -183,7 +182,7 @@ function bp_activity_action_delete_activity( $activity_id = 0 ) {
|
|
183 |
Â
* @since BuddyPress (1.1.0)
|
184 |
Â
*
|
185 |
Â
* @param int $activity_id The activity ID.
|
186 |
-
* @param int $user_id
|
187 |
Â
*/
|
188 |
Â
do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id );
|
189 |
Â
|
@@ -198,14 +197,14 @@ add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
|
|
198 |
Â
/**
|
199 |
Â
* Mark specific activity item as spam and redirect to previous page.
|
200 |
Â
*
|
201 |
-
* @since BuddyPress (1.6)
|
202 |
Â
*
|
203 |
-
* @global object $bp BuddyPress global settings
|
204 |
Â
* @param int $activity_id Activity id to be deleted. Defaults to 0.
|
Â
|
|
205 |
Â
* @return bool False on failure.
|
206 |
Â
*/
|
207 |
Â
function bp_activity_action_spam_activity( $activity_id = 0 ) {
|
208 |
-
|
209 |
Â
|
210 |
Â
// Not viewing activity, or action is not spam, or Akismet isn't present
|
211 |
Â
if ( !bp_is_activity_component() || !bp_is_current_action( 'spam' ) || empty( $bp->activity->akismet ) )
|
@@ -236,7 +235,7 @@ function bp_activity_action_spam_activity( $activity_id = 0 ) {
|
|
236 |
Â
* @since BuddyPress (1.6.0)
|
237 |
Â
*
|
238 |
Â
* @param int $activity_id Activity ID to be marked as spam.
|
239 |
-
* @param object $activity
|
240 |
Â
*/
|
241 |
Â
do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity );
|
242 |
Â
|
@@ -253,7 +252,7 @@ function bp_activity_action_spam_activity( $activity_id = 0 ) {
|
|
253 |
Â
* @since BuddyPress (1.6.0)
|
254 |
Â
*
|
255 |
Â
* @param int $activity_id Activity ID that was marked as spam.
|
256 |
-
* @param int $user_id
|
257 |
Â
*/
|
258 |
Â
do_action( 'bp_activity_action_spam_activity', $activity_id, $activity->user_id );
|
259 |
Â
|
@@ -268,7 +267,7 @@ add_action( 'bp_actions', 'bp_activity_action_spam_activity' );
|
|
268 |
Â
/**
|
269 |
Â
* Post user/group activity update.
|
270 |
Â
*
|
271 |
-
* @since BuddyPress (1.2)
|
272 |
Â
*
|
273 |
Â
* @uses is_user_logged_in()
|
274 |
Â
* @uses bp_is_activity_component()
|
@@ -300,7 +299,7 @@ function bp_activity_action_post_update() {
|
|
300 |
Â
*
|
301 |
Â
* @since BuddyPress (1.2.0)
|
302 |
Â
*
|
303 |
-
* @param string $
|
304 |
Â
*/
|
305 |
Â
$content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
|
306 |
Â
|
@@ -311,7 +310,7 @@ function bp_activity_action_post_update() {
|
|
311 |
Â
*
|
312 |
Â
* @since BuddyPress (1.2.0)
|
313 |
Â
*
|
314 |
-
* @param string $
|
315 |
Â
*/
|
316 |
Â
$object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
|
317 |
Â
}
|
@@ -323,7 +322,7 @@ function bp_activity_action_post_update() {
|
|
323 |
Â
*
|
324 |
Â
* @since BuddyPress (1.2.0)
|
325 |
Â
*
|
326 |
-
* @param string $
|
327 |
Â
*/
|
328 |
Â
$item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
|
329 |
Â
}
|
@@ -351,7 +350,7 @@ function bp_activity_action_post_update() {
|
|
351 |
Â
*
|
352 |
Â
* @since BuddyPress (1.2.0)
|
353 |
Â
*
|
354 |
-
* @param string $object
|
355 |
Â
* @param string $item_id Component ID being posted to.
|
356 |
Â
* @param string $content Activity content being posted.
|
357 |
Â
*/
|
@@ -372,7 +371,7 @@ add_action( 'bp_actions', 'bp_activity_action_post_update' );
|
|
372 |
Â
/**
|
373 |
Â
* Post new activity comment.
|
374 |
Â
*
|
375 |
-
* @since BuddyPress (1.2)
|
376 |
Â
*
|
377 |
Â
* @uses is_user_logged_in()
|
378 |
Â
* @uses bp_is_activity_component()
|
@@ -400,7 +399,7 @@ function bp_activity_action_post_comment() {
|
|
400 |
Â
*
|
401 |
Â
* @since BuddyPress (1.2.0)
|
402 |
Â
*
|
403 |
-
* @param string $
|
404 |
Â
*/
|
405 |
Â
$activity_id = apply_filters( 'bp_activity_post_comment_activity_id', $_POST['comment_form_id'] );
|
406 |
Â
|
@@ -409,7 +408,7 @@ function bp_activity_action_post_comment() {
|
|
409 |
Â
*
|
410 |
Â
* @since BuddyPress (1.2.0)
|
411 |
Â
*
|
412 |
-
* @param string $
|
413 |
Â
*/
|
414 |
Â
$content = apply_filters( 'bp_activity_post_comment_content', $_POST['ac_input_' . $activity_id] );
|
415 |
Â
|
@@ -436,7 +435,7 @@ add_action( 'bp_actions', 'bp_activity_action_post_comment' );
|
|
436 |
Â
/**
|
437 |
Â
* Mark activity as favorite.
|
438 |
Â
*
|
439 |
-
* @since BuddyPress (1.2)
|
440 |
Â
*
|
441 |
Â
* @uses is_user_logged_in()
|
442 |
Â
* @uses bp_is_activity_component()
|
@@ -470,7 +469,7 @@ add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
|
|
470 |
Â
/**
|
471 |
Â
* Remove activity from favorites.
|
472 |
Â
*
|
473 |
-
* @since BuddyPress (1.2)
|
474 |
Â
*
|
475 |
Â
* @uses is_user_logged_in()
|
476 |
Â
* @uses bp_is_activity_component()
|
@@ -504,9 +503,8 @@ add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
|
|
504 |
Â
/**
|
505 |
Â
* Load the sitewide activity feed.
|
506 |
Â
*
|
507 |
-
* @since BuddyPress (1.0)
|
508 |
Â
*
|
509 |
-
* @global object $bp BuddyPress global settings
|
510 |
Â
* @uses bp_is_activity_component()
|
511 |
Â
* @uses bp_is_current_action()
|
512 |
Â
* @uses bp_is_user()
|
@@ -515,7 +513,7 @@ add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
|
|
515 |
Â
* @return bool False on failure.
|
516 |
Â
*/
|
517 |
Â
function bp_activity_action_sitewide_feed() {
|
518 |
-
|
519 |
Â
|
520 |
Â
if ( ! bp_is_activity_component() || ! bp_is_current_action( 'feed' ) || bp_is_user() || ! empty( $bp->groups->current_group ) )
|
521 |
Â
return false;
|
@@ -537,7 +535,7 @@ add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
|
|
537 |
Â
/**
|
538 |
Â
* Load a user's personal activity feed.
|
539 |
Â
*
|
540 |
-
* @since BuddyPress (1.0)
|
541 |
Â
*
|
542 |
Â
* @uses bp_is_user_activity()
|
543 |
Â
* @uses bp_is_current_action()
|
@@ -567,7 +565,7 @@ add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
|
|
567 |
Â
/**
|
568 |
Â
* Load a user's friends' activity feed.
|
569 |
Â
*
|
570 |
-
* @since BuddyPress (1.0)
|
571 |
Â
*
|
572 |
Â
* @uses bp_is_active()
|
573 |
Â
* @uses bp_is_user_activity()
|
@@ -600,7 +598,7 @@ add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
|
|
600 |
Â
/**
|
601 |
Â
* Load the activity feed for a user's groups.
|
602 |
Â
*
|
603 |
-
* @since BuddyPress (1.2)
|
604 |
Â
*
|
605 |
Â
* @uses bp_is_active()
|
606 |
Â
* @uses bp_is_user_activity()
|
@@ -641,7 +639,7 @@ add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
|
|
641 |
Â
/**
|
642 |
Â
* Load a user's @mentions feed.
|
643 |
Â
*
|
644 |
-
* @since BuddyPress (1.2)
|
645 |
Â
*
|
646 |
Â
* @uses bp_is_user_activity()
|
647 |
Â
* @uses bp_is_current_action()
|
@@ -678,7 +676,7 @@ add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
|
|
678 |
Â
/**
|
679 |
Â
* Load a user's favorites feed.
|
680 |
Â
*
|
681 |
-
* @since BuddyPress (1.2)
|
682 |
Â
*
|
683 |
Â
* @uses bp_is_user_activity()
|
684 |
Â
* @uses bp_is_current_action()
|
@@ -713,30 +711,37 @@ add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
|
|
713 |
Â
/**
|
714 |
Â
* Loads Akismet filtering for activity.
|
715 |
Â
*
|
716 |
-
* @since BuddyPress (1.6)
|
717 |
-
*
|
718 |
-
* @global object $bp BuddyPress global settings
|
719 |
Â
*/
|
720 |
Â
function bp_activity_setup_akismet() {
|
721 |
-
|
722 |
Â
|
723 |
Â
// Bail if Akismet is not active
|
724 |
-
if ( ! defined( 'AKISMET_VERSION' ) )
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
725 |
Â
return;
|
Â
|
|
726 |
Â
|
727 |
Â
// Bail if no Akismet key is set
|
728 |
-
if ( ! bp_get_option( 'wordpress_api_key' ) && ! defined( 'WPCOM_API_KEY' ) )
|
729 |
Â
return;
|
Â
|
|
730 |
Â
|
731 |
Â
/**
|
732 |
Â
* Filters if BuddyPress Activity Akismet support has been disabled by another plugin.
|
733 |
Â
*
|
734 |
Â
* @since BuddyPress (1.6.0)
|
735 |
Â
*
|
736 |
-
* @param bool
|
737 |
Â
*/
|
738 |
-
if ( ! apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) )
|
739 |
Â
return;
|
Â
|
|
740 |
Â
|
741 |
Â
// Instantiate Akismet for BuddyPress
|
742 |
Â
$bp->activity->akismet = new BP_Akismet();
|
33 |
Â
/**
|
34 |
Â
* Catch and route requests for single activity item permalinks.
|
35 |
Â
*
|
36 |
+
* @since BuddyPress (1.2.0)
|
37 |
Â
*
|
Â
|
|
38 |
Â
* @uses bp_is_activity_component()
|
39 |
Â
* @uses bp_is_current_action()
|
40 |
Â
* @uses bp_action_variable()
|
120 |
Â
/**
|
121 |
Â
* Delete specific activity item and redirect to previous page.
|
122 |
Â
*
|
123 |
+
* @since BuddyPress (1.1.0)
|
124 |
Â
*
|
125 |
Â
* @param int $activity_id Activity id to be deleted. Defaults to 0.
|
126 |
Â
*
|
166 |
Â
* @since BuddyPress (1.5.0)
|
167 |
Â
*
|
168 |
Â
* @param int $activity_id The activity ID.
|
169 |
+
* @param int $user_id The user associated with the activity.
|
170 |
Â
*/
|
171 |
Â
do_action( 'bp_activity_before_action_delete_activity', $activity_id, $activity->user_id );
|
172 |
Â
|
182 |
Â
* @since BuddyPress (1.1.0)
|
183 |
Â
*
|
184 |
Â
* @param int $activity_id The activity ID.
|
185 |
+
* @param int $user_id The user associated with the activity.
|
186 |
Â
*/
|
187 |
Â
do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id );
|
188 |
Â
|
197 |
Â
/**
|
198 |
Â
* Mark specific activity item as spam and redirect to previous page.
|
199 |
Â
*
|
200 |
+
* @since BuddyPress (1.6.0)
|
201 |
Â
*
|
Â
|
|
202 |
Â
* @param int $activity_id Activity id to be deleted. Defaults to 0.
|
203 |
+
*
|
204 |
Â
* @return bool False on failure.
|
205 |
Â
*/
|
206 |
Â
function bp_activity_action_spam_activity( $activity_id = 0 ) {
|
207 |
+
$bp = buddypress();
|
208 |
Â
|
209 |
Â
// Not viewing activity, or action is not spam, or Akismet isn't present
|
210 |
Â
if ( !bp_is_activity_component() || !bp_is_current_action( 'spam' ) || empty( $bp->activity->akismet ) )
|
235 |
Â
* @since BuddyPress (1.6.0)
|
236 |
Â
*
|
237 |
Â
* @param int $activity_id Activity ID to be marked as spam.
|
238 |
+
* @param object $activity Activity object for the ID to be marked as spam.
|
239 |
Â
*/
|
240 |
Â
do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity );
|
241 |
Â
|
252 |
Â
* @since BuddyPress (1.6.0)
|
253 |
Â
*
|
254 |
Â
* @param int $activity_id Activity ID that was marked as spam.
|
255 |
+
* @param int $user_id User ID associated with activity.
|
256 |
Â
*/
|
257 |
Â
do_action( 'bp_activity_action_spam_activity', $activity_id, $activity->user_id );
|
258 |
Â
|
267 |
Â
/**
|
268 |
Â
* Post user/group activity update.
|
269 |
Â
*
|
270 |
+
* @since BuddyPress (1.2.0)
|
271 |
Â
*
|
272 |
Â
* @uses is_user_logged_in()
|
273 |
Â
* @uses bp_is_activity_component()
|
299 |
Â
*
|
300 |
Â
* @since BuddyPress (1.2.0)
|
301 |
Â
*
|
302 |
+
* @param string $value Activity message being posted.
|
303 |
Â
*/
|
304 |
Â
$content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
|
305 |
Â
|
310 |
Â
*
|
311 |
Â
* @since BuddyPress (1.2.0)
|
312 |
Â
*
|
313 |
+
* @param string $value Item type to associate with.
|
314 |
Â
*/
|
315 |
Â
$object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
|
316 |
Â
}
|
322 |
Â
*
|
323 |
Â
* @since BuddyPress (1.2.0)
|
324 |
Â
*
|
325 |
+
* @param string $value Chosen component to post activity to.
|
326 |
Â
*/
|
327 |
Â
$item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
|
328 |
Â
}
|
350 |
Â
*
|
351 |
Â
* @since BuddyPress (1.2.0)
|
352 |
Â
*
|
353 |
+
* @param string $object Activity item being associated to.
|
354 |
Â
* @param string $item_id Component ID being posted to.
|
355 |
Â
* @param string $content Activity content being posted.
|
356 |
Â
*/
|
371 |
Â
/**
|
372 |
Â
* Post new activity comment.
|
373 |
Â
*
|
374 |
+
* @since BuddyPress (1.2.0)
|
375 |
Â
*
|
376 |
Â
* @uses is_user_logged_in()
|
377 |
Â
* @uses bp_is_activity_component()
|
399 |
Â
*
|
400 |
Â
* @since BuddyPress (1.2.0)
|
401 |
Â
*
|
402 |
+
* @param string $value ID of the activity being replied to.
|
403 |
Â
*/
|
404 |
Â
$activity_id = apply_filters( 'bp_activity_post_comment_activity_id', $_POST['comment_form_id'] );
|
405 |
Â
|
408 |
Â
*
|
409 |
Â
* @since BuddyPress (1.2.0)
|
410 |
Â
*
|
411 |
+
* @param string $value Comment content being posted.
|
412 |
Â
*/
|
413 |
Â
$content = apply_filters( 'bp_activity_post_comment_content', $_POST['ac_input_' . $activity_id] );
|
414 |
Â
|
435 |
Â
/**
|
436 |
Â
* Mark activity as favorite.
|
437 |
Â
*
|
438 |
+
* @since BuddyPress (1.2.0)
|
439 |
Â
*
|
440 |
Â
* @uses is_user_logged_in()
|
441 |
Â
* @uses bp_is_activity_component()
|
469 |
Â
/**
|
470 |
Â
* Remove activity from favorites.
|
471 |
Â
*
|
472 |
+
* @since BuddyPress (1.2.0)
|
473 |
Â
*
|
474 |
Â
* @uses is_user_logged_in()
|
475 |
Â
* @uses bp_is_activity_component()
|
503 |
Â
/**
|
504 |
Â
* Load the sitewide activity feed.
|
505 |
Â
*
|
506 |
+
* @since BuddyPress (1.0.0)
|
507 |
Â
*
|
Â
|
|
508 |
Â
* @uses bp_is_activity_component()
|
509 |
Â
* @uses bp_is_current_action()
|
510 |
Â
* @uses bp_is_user()
|
513 |
Â
* @return bool False on failure.
|
514 |
Â
*/
|
515 |
Â
function bp_activity_action_sitewide_feed() {
|
516 |
+
$bp = buddypress();
|
517 |
Â
|
518 |
Â
if ( ! bp_is_activity_component() || ! bp_is_current_action( 'feed' ) || bp_is_user() || ! empty( $bp->groups->current_group ) )
|
519 |
Â
return false;
|
535 |
Â
/**
|
536 |
Â
* Load a user's personal activity feed.
|
537 |
Â
*
|
538 |
+
* @since BuddyPress (1.0.0)
|
539 |
Â
*
|
540 |
Â
* @uses bp_is_user_activity()
|
541 |
Â
* @uses bp_is_current_action()
|
565 |
Â
/**
|
566 |
Â
* Load a user's friends' activity feed.
|
567 |
Â
*
|
568 |
+
* @since BuddyPress (1.0.0)
|
569 |
Â
*
|
570 |
Â
* @uses bp_is_active()
|
571 |
Â
* @uses bp_is_user_activity()
|
598 |
Â
/**
|
599 |
Â
* Load the activity feed for a user's groups.
|
600 |
Â
*
|
601 |
+
* @since BuddyPress (1.2.0)
|
602 |
Â
*
|
603 |
Â
* @uses bp_is_active()
|
604 |
Â
* @uses bp_is_user_activity()
|
639 |
Â
/**
|
640 |
Â
* Load a user's @mentions feed.
|
641 |
Â
*
|
642 |
+
* @since BuddyPress (1.2.0)
|
643 |
Â
*
|
644 |
Â
* @uses bp_is_user_activity()
|
645 |
Â
* @uses bp_is_current_action()
|
676 |
Â
/**
|
677 |
Â
* Load a user's favorites feed.
|
678 |
Â
*
|
679 |
+
* @since BuddyPress (1.2.0)
|
680 |
Â
*
|
681 |
Â
* @uses bp_is_user_activity()
|
682 |
Â
* @uses bp_is_current_action()
|
711 |
Â
/**
|
712 |
Â
* Loads Akismet filtering for activity.
|
713 |
Â
*
|
714 |
+
* @since BuddyPress (1.6.0)
|
715 |
+
* @since BuddyPress (2.3.0) We only support Akismet 3+.
|
Â
|
|
716 |
Â
*/
|
717 |
Â
function bp_activity_setup_akismet() {
|
718 |
+
$bp = buddypress();
|
719 |
Â
|
720 |
Â
// Bail if Akismet is not active
|
721 |
+
if ( ! defined( 'AKISMET_VERSION' ) ) {
|
722 |
+
return;
|
723 |
+
}
|
724 |
+
|
725 |
+
// Bail if older version of Akismet
|
726 |
+
if ( ! class_exists( 'Akismet' ) ) {
|
727 |
Â
return;
|
728 |
+
}
|
729 |
Â
|
730 |
Â
// Bail if no Akismet key is set
|
731 |
+
if ( ! bp_get_option( 'wordpress_api_key' ) && ! defined( 'WPCOM_API_KEY' ) ) {
|
732 |
Â
return;
|
733 |
+
}
|
734 |
Â
|
735 |
Â
/**
|
736 |
Â
* Filters if BuddyPress Activity Akismet support has been disabled by another plugin.
|
737 |
Â
*
|
738 |
Â
* @since BuddyPress (1.6.0)
|
739 |
Â
*
|
740 |
+
* @param bool $value Return value of bp_is_akismet_active boolean function.
|
741 |
Â
*/
|
742 |
+
if ( ! apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) ) {
|
743 |
Â
return;
|
744 |
+
}
|
745 |
Â
|
746 |
Â
// Instantiate Akismet for BuddyPress
|
747 |
Â
$bp->activity->akismet = new BP_Akismet();
|
bp-activity/bp-activity-admin.php
CHANGED
@@ -52,7 +52,8 @@ add_action( bp_core_admin_hook(), 'bp_activity_add_admin_menu' );
|
|
52 |
Â
* @since BuddyPress (1.7.0)
|
53 |
Â
*
|
54 |
Â
* @param array $custom_menus The list of top-level BP menu items.
|
55 |
-
*
|
Â
|
|
56 |
Â
*/
|
57 |
Â
function bp_activity_admin_menu_order( $custom_menus = array() ) {
|
58 |
Â
array_push( $custom_menus, 'bp-activity' );
|
@@ -138,10 +139,10 @@ add_action( 'wp_ajax_bp-activity-admin-reply', 'bp_activity_admin_reply' );
|
|
138 |
Â
*
|
139 |
Â
* @since BuddyPress (1.6.0)
|
140 |
Â
*
|
141 |
-
* @param string $value
|
142 |
-
*
|
143 |
-
* @param string $option Screen option name.
|
144 |
Â
* @param string $new_value Screen option form value.
|
Â
|
|
145 |
Â
* @return string Option value. False to abandon update.
|
146 |
Â
*/
|
147 |
Â
function bp_activity_admin_screen_options( $value, $option, $new_value ) {
|
@@ -161,7 +162,9 @@ function bp_activity_admin_screen_options( $value, $option, $new_value ) {
|
|
161 |
Â
*
|
162 |
Â
* @since BuddyPress (1.6.0)
|
163 |
Â
*
|
Â
|
|
164 |
Â
* @param WP_Screen $screen Screen identifier.
|
Â
|
|
165 |
Â
* @return array Hidden Meta Boxes.
|
166 |
Â
*/
|
167 |
Â
function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) {
|
@@ -188,12 +191,12 @@ add_filter( 'default_hidden_meta_boxes', 'bp_activity_admin_edit_hidden_metaboxe
|
|
188 |
Â
*
|
189 |
Â
* Does the following:
|
190 |
Â
* - Register contextual help and screen options for this admin page.
|
191 |
-
* - Enqueues scripts and styles
|
192 |
-
* - Catches POST and GET requests related to Activity
|
193 |
Â
*
|
194 |
Â
* @since BuddyPress (1.6.0)
|
195 |
Â
*
|
196 |
-
* @global object
|
197 |
Â
* @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table.
|
198 |
Â
*/
|
199 |
Â
function bp_activity_admin_load() {
|
@@ -242,8 +245,8 @@ function bp_activity_admin_load() {
|
|
242 |
Â
// Help panel - sidebar links
|
243 |
Â
get_current_screen()->set_help_sidebar(
|
244 |
Â
'<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
|
245 |
-
'<p>' . __( '<a href="
|
246 |
-
'<p>' . __( '<a href="
|
247 |
Â
);
|
248 |
Â
|
249 |
Â
// Register metaboxes for the edit screen.
|
@@ -253,7 +256,7 @@ function bp_activity_admin_load() {
|
|
253 |
Â
add_meta_box( 'bp_activity_type', _x( 'Type', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_type', get_current_screen()->id, 'normal', 'core' );
|
254 |
Â
add_meta_box( 'bp_activity_userid', _x( 'Author ID', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_userid', get_current_screen()->id, 'normal', 'core' );
|
255 |
Â
|
256 |
-
// Enqueue
|
257 |
Â
wp_enqueue_script( 'postbox' );
|
258 |
Â
wp_enqueue_script( 'dashboard' );
|
259 |
Â
wp_enqueue_script( 'comment' );
|
@@ -287,7 +290,7 @@ function bp_activity_admin_load() {
|
|
287 |
Â
// Help panel - sidebar links
|
288 |
Â
get_current_screen()->set_help_sidebar(
|
289 |
Â
'<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
|
290 |
-
'<p>' . __( '<a href="
|
291 |
Â
);
|
292 |
Â
}
|
293 |
Â
|
@@ -411,8 +414,8 @@ function bp_activity_admin_load() {
|
|
411 |
Â
*
|
412 |
Â
* @since BuddyPress (1.6.0)
|
413 |
Â
*
|
414 |
-
* @param array Array holding spam, not spam, deleted counts, error IDs.
|
415 |
-
* @param string $redirect_to
|
416 |
Â
* @param array $activity_ids Original array of activity IDs.
|
417 |
Â
*/
|
418 |
Â
do_action( 'bp_activity_admin_action_after', array( $spammed, $unspammed, $deleted, $errors ), $redirect_to, $activity_ids );
|
@@ -639,7 +642,7 @@ function bp_activity_admin_edit() {
|
|
639 |
Â
*
|
640 |
Â
* @since BuddyPress (1.6.0)
|
641 |
Â
*
|
642 |
-
* @param array Array holding single activity object.
|
643 |
Â
*/
|
644 |
Â
do_action_ref_array( 'bp_activity_admin_edit', array( &$activity ) ); ?>
|
645 |
Â
|
@@ -816,16 +819,14 @@ function bp_activity_admin_get_activity_actions() {
|
|
816 |
Â
}
|
817 |
Â
|
818 |
Â
/**
|
819 |
-
* Activity type metabox for the Activity admin edit screen
|
820 |
Â
*
|
821 |
Â
* @since BuddyPress (1.6.0)
|
822 |
Â
*
|
823 |
-
* @global object $bp BuddyPress global settings.
|
824 |
-
*
|
825 |
Â
* @param object $item Activity item.
|
826 |
Â
*/
|
827 |
Â
function bp_activity_admin_edit_metabox_type( $item ) {
|
828 |
-
|
829 |
Â
|
830 |
Â
$actions = array();
|
831 |
Â
$selected = $item->type;
|
@@ -890,9 +891,8 @@ function bp_activity_admin_edit_metabox_itemids( $item ) {
|
|
890 |
Â
*
|
891 |
Â
* @since BuddyPress (1.6.0)
|
892 |
Â
*
|
893 |
-
* @global BP_Activity_List_Table $bp_activity_list_table Activity screen list
|
894 |
-
*
|
895 |
-
* @global string $plugin_page The current plugin page.
|
896 |
Â
*/
|
897 |
Â
function bp_activity_admin_index() {
|
898 |
Â
global $bp_activity_list_table, $plugin_page;
|
@@ -1004,7 +1004,7 @@ function bp_activity_admin_index() {
|
|
1004 |
Â
<a href="#" class="cancel button-secondary alignleft"><?php _e( 'Cancel', 'buddypress' ); ?></a>
|
1005 |
Â
<a href="#" class="save button-primary alignright"><?php _e( 'Reply', 'buddypress' ); ?></a>
|
1006 |
Â
|
1007 |
-
<img class="waiting" style="display:none;" src="<?php echo esc_url(
|
1008 |
Â
<span class="error" style="display:none;"></span>
|
1009 |
Â
<br class="clear" />
|
1010 |
Â
</p>
|
@@ -1023,7 +1023,7 @@ function bp_activity_admin_index() {
|
|
1023 |
Â
/**
|
1024 |
Â
* List table class for the Activity component admin page.
|
1025 |
Â
*
|
1026 |
-
* @since BuddyPress (1.6)
|
1027 |
Â
*/
|
1028 |
Â
class BP_Activity_List_Table extends WP_List_Table {
|
1029 |
Â
|
@@ -1054,7 +1054,7 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1054 |
Â
protected $activity_user_id = array();
|
1055 |
Â
|
1056 |
Â
/**
|
1057 |
-
* If users can comment on blog & forum activity items
|
1058 |
Â
*
|
1059 |
Â
* @since BuddyPress (2.2.2)
|
1060 |
Â
*
|
@@ -1197,6 +1197,7 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1197 |
Â
$this->get_columns(),
|
1198 |
Â
array(),
|
1199 |
Â
$this->get_sortable_columns(),
|
Â
|
|
1200 |
Â
);
|
1201 |
Â
|
1202 |
Â
return $this->_column_headers;
|
@@ -1219,7 +1220,7 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1219 |
Â
function display() {
|
1220 |
Â
$this->display_tablenav( 'top' ); ?>
|
1221 |
Â
|
1222 |
-
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
|
1223 |
Â
<thead>
|
1224 |
Â
<tr>
|
1225 |
Â
<?php $this->print_column_headers(); ?>
|
@@ -1276,11 +1277,11 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1276 |
Â
* @since BuddyPress (1.6.0)
|
1277 |
Â
*/
|
1278 |
Â
function get_views() {
|
1279 |
-
$url_base =
|
1280 |
Â
|
1281 |
Â
<ul class="subsubsub">
|
1282 |
Â
<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>
|
1283 |
-
<li class="spam"><a href="<?php echo esc_url( add_query_arg( 'activity_status'
|
1284 |
Â
|
1285 |
Â
<?php
|
1286 |
Â
|
@@ -1290,7 +1291,7 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1290 |
Â
* @since BuddyPress (1.6.0)
|
1291 |
Â
*
|
1292 |
Â
* @param string $url_base Current URL base for view.
|
1293 |
-
* @param string $view
|
1294 |
Â
*/
|
1295 |
Â
do_action( 'bp_activity_list_table_get_views', $url_base, $this->view ); ?>
|
1296 |
Â
</ul>
|
@@ -1411,6 +1412,37 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1411 |
Â
<?php
|
1412 |
Â
}
|
1413 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1414 |
Â
/**
|
1415 |
Â
* Checkbox column markup.
|
1416 |
Â
*
|
@@ -1493,7 +1525,7 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1493 |
Â
|
1494 |
Â
// Rollover actions
|
1495 |
Â
|
1496 |
-
// Reply -
|
1497 |
Â
if ( 'spam' != $item_status ) {
|
1498 |
Â
if ( $this->can_comment( $item ) ) {
|
1499 |
Â
$actions['reply'] = sprintf( '<a href="#" class="reply hide-if-no-js">%s</a>', __( 'Reply', 'buddypress' ) );
|
@@ -1523,7 +1555,7 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1523 |
Â
* @since BuddyPress (1.6.0)
|
1524 |
Â
*
|
1525 |
Â
* @param array $actions Array of available actions user could use.
|
1526 |
-
* @param array $item
|
1527 |
Â
*/
|
1528 |
Â
$actions = apply_filters( 'bp_activity_admin_comment_row_actions', array_filter( $actions ), $item );
|
1529 |
Â
|
@@ -1569,33 +1601,47 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1569 |
Â
*/
|
1570 |
Â
function column_response( $item ) {
|
1571 |
Â
// Is $item is a root activity?
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1572 |
Â
|
1573 |
Â
/**
|
1574 |
Â
* Filters default list of default root activity types.
|
1575 |
Â
*
|
1576 |
Â
* @since BuddyPress (1.6.0)
|
1577 |
Â
*
|
1578 |
-
* @param array Array of default activity types.
|
1579 |
-
* @param array $item
|
1580 |
Â
*/
|
1581 |
Â
if ( empty( $item['item_id'] ) || ! in_array( $item['type'], apply_filters( 'bp_activity_admin_root_activity_types', array( 'activity_comment' ), $item ) ) ) {
|
Â
|
|
Â
|
|
1582 |
Â
$comment_count = !empty( $item['children'] ) ? bp_activity_recurse_comment_count( (object) $item ) : 0;
|
1583 |
Â
$root_activity_url = bp_get_admin_url( 'admin.php?page=bp-activity&aid=' . $item['id'] );
|
1584 |
Â
|
1585 |
Â
// If the activity has comments, display a link to the activity's permalink, with its comment count in a speech bubble
|
1586 |
Â
if ( $comment_count ) {
|
1587 |
Â
$title_attr = sprintf( _n( '%s related activity', '%s related activities', $comment_count, 'buddypress' ), number_format_i18n( $comment_count ) );
|
1588 |
-
printf( '<a href="%1$s" title="%2$s" class="post-com-count"><span class="comment-count">%3$s</span></a>', esc_url( $root_activity_url ), esc_attr( $title_attr ), number_format_i18n( $comment_count ) );
|
1589 |
Â
}
|
1590 |
Â
|
1591 |
Â
// For non-root activities, display a link to the replied-to activity's author's profile
|
1592 |
Â
} else {
|
1593 |
Â
echo '<strong>' . get_avatar( $this->get_activity_user_id( $item['item_id'] ), '32' ) . ' ' . bp_core_get_userlink( $this->get_activity_user_id( $item['item_id'] ) ) . '</strong><br />';
|
Â
|
|
1594 |
Â
}
|
Â
|
|
1595 |
Â
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
Â
}
|
1600 |
Â
|
1601 |
Â
/**
|
@@ -1607,6 +1653,7 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1607 |
Â
* @since BuddyPress (1.6.0)
|
1608 |
Â
*
|
1609 |
Â
* @param int $activity_id Activity ID to retrieve User ID for.
|
Â
|
|
1610 |
Â
* @return int User ID of the activity item in question.
|
1611 |
Â
*/
|
1612 |
Â
protected function get_activity_user_id( $activity_id ) {
|
@@ -1640,13 +1687,14 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1640 |
Â
* Checks if an activity item can be replied to.
|
1641 |
Â
*
|
1642 |
Â
* This method merges functionality from {@link bp_activity_can_comment()} and
|
1643 |
-
* {@link bp_blogs_disable_activity_commenting()}.
|
1644 |
Â
* list table doesn't use a BuddyPress activity loop, which prevents those
|
1645 |
Â
* functions from working as intended.
|
1646 |
Â
*
|
1647 |
Â
* @since BuddyPress (2.0.0)
|
1648 |
Â
*
|
1649 |
Â
* @param array $item An array version of the BP_Activity_Activity object.
|
Â
|
|
1650 |
Â
* @return bool
|
1651 |
Â
*/
|
1652 |
Â
protected function can_comment( $item ) {
|
@@ -1711,6 +1759,7 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1711 |
Â
* @since BuddyPress (1.6.0)
|
1712 |
Â
*
|
1713 |
Â
* @param array $tree Source array.
|
Â
|
|
1714 |
Â
* @return array Flattened array.
|
1715 |
Â
*/
|
1716 |
Â
public static function flatten_activity_array( $tree ){
|
@@ -1727,4 +1776,16 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1727 |
Â
|
1728 |
Â
return $tree;
|
1729 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1730 |
Â
}
|
52 |
Â
* @since BuddyPress (1.7.0)
|
53 |
Â
*
|
54 |
Â
* @param array $custom_menus The list of top-level BP menu items.
|
55 |
+
*
|
56 |
+
* @return array $custom_menus List of top-level BP menu items, with Activity added.
|
57 |
Â
*/
|
58 |
Â
function bp_activity_admin_menu_order( $custom_menus = array() ) {
|
59 |
Â
array_push( $custom_menus, 'bp-activity' );
|
139 |
Â
*
|
140 |
Â
* @since BuddyPress (1.6.0)
|
141 |
Â
*
|
142 |
+
* @param string $value Will always be false unless another plugin filters it first.
|
143 |
+
* @param string $option Screen option name.
|
Â
|
|
144 |
Â
* @param string $new_value Screen option form value.
|
145 |
+
*
|
146 |
Â
* @return string Option value. False to abandon update.
|
147 |
Â
*/
|
148 |
Â
function bp_activity_admin_screen_options( $value, $option, $new_value ) {
|
162 |
Â
*
|
163 |
Â
* @since BuddyPress (1.6.0)
|
164 |
Â
*
|
165 |
+
* @param array $hidden Array of items to hide.
|
166 |
Â
* @param WP_Screen $screen Screen identifier.
|
167 |
+
*
|
168 |
Â
* @return array Hidden Meta Boxes.
|
169 |
Â
*/
|
170 |
Â
function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) {
|
191 |
Â
*
|
192 |
Â
* Does the following:
|
193 |
Â
* - Register contextual help and screen options for this admin page.
|
194 |
+
* - Enqueues scripts and styles.
|
195 |
+
* - Catches POST and GET requests related to Activity.
|
196 |
Â
*
|
197 |
Â
* @since BuddyPress (1.6.0)
|
198 |
Â
*
|
199 |
+
* @global object $bp BuddyPress global settings.
|
200 |
Â
* @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table.
|
201 |
Â
*/
|
202 |
Â
function bp_activity_admin_load() {
|
245 |
Â
// Help panel - sidebar links
|
246 |
Â
get_current_screen()->set_help_sidebar(
|
247 |
Â
'<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
|
248 |
+
'<p>' . __( '<a href="https://codex.buddypress.org/administrator-guide/activity-stream-management-panels/">Managing Activity</a>', 'buddypress' ) . '</p>' .
|
249 |
+
'<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
|
250 |
Â
);
|
251 |
Â
|
252 |
Â
// Register metaboxes for the edit screen.
|
256 |
Â
add_meta_box( 'bp_activity_type', _x( 'Type', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_type', get_current_screen()->id, 'normal', 'core' );
|
257 |
Â
add_meta_box( 'bp_activity_userid', _x( 'Author ID', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_userid', get_current_screen()->id, 'normal', 'core' );
|
258 |
Â
|
259 |
+
// Enqueue JavaScript files
|
260 |
Â
wp_enqueue_script( 'postbox' );
|
261 |
Â
wp_enqueue_script( 'dashboard' );
|
262 |
Â
wp_enqueue_script( 'comment' );
|
290 |
Â
// Help panel - sidebar links
|
291 |
Â
get_current_screen()->set_help_sidebar(
|
292 |
Â
'<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
|
293 |
+
'<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
|
294 |
Â
);
|
295 |
Â
}
|
296 |
Â
|
414 |
Â
*
|
415 |
Â
* @since BuddyPress (1.6.0)
|
416 |
Â
*
|
417 |
+
* @param array $value Array holding spam, not spam, deleted counts, error IDs.
|
418 |
+
* @param string $redirect_to URL to redirect to.
|
419 |
Â
* @param array $activity_ids Original array of activity IDs.
|
420 |
Â
*/
|
421 |
Â
do_action( 'bp_activity_admin_action_after', array( $spammed, $unspammed, $deleted, $errors ), $redirect_to, $activity_ids );
|
642 |
Â
*
|
643 |
Â
* @since BuddyPress (1.6.0)
|
644 |
Â
*
|
645 |
+
* @param array $value Array holding single activity object that was passed by reference.
|
646 |
Â
*/
|
647 |
Â
do_action_ref_array( 'bp_activity_admin_edit', array( &$activity ) ); ?>
|
648 |
Â
|
819 |
Â
}
|
820 |
Â
|
821 |
Â
/**
|
822 |
+
* Activity type metabox for the Activity admin edit screen.
|
823 |
Â
*
|
824 |
Â
* @since BuddyPress (1.6.0)
|
825 |
Â
*
|
Â
|
|
Â
|
|
826 |
Â
* @param object $item Activity item.
|
827 |
Â
*/
|
828 |
Â
function bp_activity_admin_edit_metabox_type( $item ) {
|
829 |
+
$bp = buddypress();
|
830 |
Â
|
831 |
Â
$actions = array();
|
832 |
Â
$selected = $item->type;
|
891 |
Â
*
|
892 |
Â
* @since BuddyPress (1.6.0)
|
893 |
Â
*
|
894 |
+
* @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table.
|
895 |
+
* @global string $plugin_page The current plugin page.
|
Â
|
|
896 |
Â
*/
|
897 |
Â
function bp_activity_admin_index() {
|
898 |
Â
global $bp_activity_list_table, $plugin_page;
|
1004 |
Â
<a href="#" class="cancel button-secondary alignleft"><?php _e( 'Cancel', 'buddypress' ); ?></a>
|
1005 |
Â
<a href="#" class="save button-primary alignright"><?php _e( 'Reply', 'buddypress' ); ?></a>
|
1006 |
Â
|
1007 |
+
<img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
|
1008 |
Â
<span class="error" style="display:none;"></span>
|
1009 |
Â
<br class="clear" />
|
1010 |
Â
</p>
|
1023 |
Â
/**
|
1024 |
Â
* List table class for the Activity component admin page.
|
1025 |
Â
*
|
1026 |
+
* @since BuddyPress (1.6.0)
|
1027 |
Â
*/
|
1028 |
Â
class BP_Activity_List_Table extends WP_List_Table {
|
1029 |
Â
|
1054 |
Â
protected $activity_user_id = array();
|
1055 |
Â
|
1056 |
Â
/**
|
1057 |
+
* If users can comment on blog & forum activity items.
|
1058 |
Â
*
|
1059 |
Â
* @since BuddyPress (2.2.2)
|
1060 |
Â
*
|
1197 |
Â
$this->get_columns(),
|
1198 |
Â
array(),
|
1199 |
Â
$this->get_sortable_columns(),
|
1200 |
+
$this->get_default_primary_column_name(),
|
1201 |
Â
);
|
1202 |
Â
|
1203 |
Â
return $this->_column_headers;
|
1220 |
Â
function display() {
|
1221 |
Â
$this->display_tablenav( 'top' ); ?>
|
1222 |
Â
|
1223 |
+
<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
|
1224 |
Â
<thead>
|
1225 |
Â
<tr>
|
1226 |
Â
<?php $this->print_column_headers(); ?>
|
1277 |
Â
* @since BuddyPress (1.6.0)
|
1278 |
Â
*/
|
1279 |
Â
function get_views() {
|
1280 |
+
$url_base = add_query_arg( array( 'page' => 'bp-activity' ), bp_get_admin_url( 'admin.php' ) ); ?>
|
1281 |
Â
|
1282 |
Â
<ul class="subsubsub">
|
1283 |
Â
<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>
|
1284 |
+
<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>
|
1285 |
Â
|
1286 |
Â
<?php
|
1287 |
Â
|
1291 |
Â
* @since BuddyPress (1.6.0)
|
1292 |
Â
*
|
1293 |
Â
* @param string $url_base Current URL base for view.
|
1294 |
+
* @param string $view Current view being displayed.
|
1295 |
Â
*/
|
1296 |
Â
do_action( 'bp_activity_list_table_get_views', $url_base, $this->view ); ?>
|
1297 |
Â
</ul>
|
1412 |
Â
<?php
|
1413 |
Â
}
|
1414 |
Â
|
1415 |
+
/**
|
1416 |
+
* Override WP_List_Table::row_actions().
|
1417 |
+
*
|
1418 |
+
* Basically a duplicate of the row_actions() method, but removes the
|
1419 |
+
* unnecessary <button> addition.
|
1420 |
+
*
|
1421 |
+
* @since 2.3.3
|
1422 |
+
* @since 2.3.4 Visibility set to public for compatibility with WP < 4.0.0.
|
1423 |
+
*
|
1424 |
+
* @param array $actions The list of actions
|
1425 |
+
* @param bool $always_visible Whether the actions should be always visible
|
1426 |
+
* @return string
|
1427 |
+
*/
|
1428 |
+
public function row_actions( $actions, $always_visible = false ) {
|
1429 |
+
$action_count = count( $actions );
|
1430 |
+
$i = 0;
|
1431 |
+
|
1432 |
+
if ( !$action_count )
|
1433 |
+
return '';
|
1434 |
+
|
1435 |
+
$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
|
1436 |
+
foreach ( $actions as $action => $link ) {
|
1437 |
+
++$i;
|
1438 |
+
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
|
1439 |
+
$out .= "<span class='$action'>$link$sep</span>";
|
1440 |
+
}
|
1441 |
+
$out .= '</div>';
|
1442 |
+
|
1443 |
+
return $out;
|
1444 |
+
}
|
1445 |
+
|
1446 |
Â
/**
|
1447 |
Â
* Checkbox column markup.
|
1448 |
Â
*
|
1525 |
Â
|
1526 |
Â
// Rollover actions
|
1527 |
Â
|
1528 |
+
// Reply - JavaScript only; implemented by AJAX.
|
1529 |
Â
if ( 'spam' != $item_status ) {
|
1530 |
Â
if ( $this->can_comment( $item ) ) {
|
1531 |
Â
$actions['reply'] = sprintf( '<a href="#" class="reply hide-if-no-js">%s</a>', __( 'Reply', 'buddypress' ) );
|
1555 |
Â
* @since BuddyPress (1.6.0)
|
1556 |
Â
*
|
1557 |
Â
* @param array $actions Array of available actions user could use.
|
1558 |
+
* @param array $item Current item being added to page.
|
1559 |
Â
*/
|
1560 |
Â
$actions = apply_filters( 'bp_activity_admin_comment_row_actions', array_filter( $actions ), $item );
|
1561 |
Â
|
1601 |
Â
*/
|
1602 |
Â
function column_response( $item ) {
|
1603 |
Â
// Is $item is a root activity?
|
1604 |
+
?>
|
1605 |
+
|
1606 |
+
<div class="response-links">
|
1607 |
+
|
1608 |
+
<?php
|
1609 |
+
// Activity permalink
|
1610 |
+
$activity_permalink = '';
|
1611 |
+
if ( ! $item['is_spam'] ) {
|
1612 |
+
$activity_permalink = sprintf( __( '<a href="%1$s" class="comments-view-item-link">View Activity</a>', 'buddypress' ), bp_activity_get_permalink( $item['id'], (object) $item ) );
|
1613 |
+
}
|
1614 |
Â
|
1615 |
Â
/**
|
1616 |
Â
* Filters default list of default root activity types.
|
1617 |
Â
*
|
1618 |
Â
* @since BuddyPress (1.6.0)
|
1619 |
Â
*
|
1620 |
+
* @param array $value Array of default activity types.
|
1621 |
+
* @param array $item Current item being displayed.
|
1622 |
Â
*/
|
1623 |
Â
if ( empty( $item['item_id'] ) || ! in_array( $item['type'], apply_filters( 'bp_activity_admin_root_activity_types', array( 'activity_comment' ), $item ) ) ) {
|
1624 |
+
echo $activity_permalink;
|
1625 |
+
|
1626 |
Â
$comment_count = !empty( $item['children'] ) ? bp_activity_recurse_comment_count( (object) $item ) : 0;
|
1627 |
Â
$root_activity_url = bp_get_admin_url( 'admin.php?page=bp-activity&aid=' . $item['id'] );
|
1628 |
Â
|
1629 |
Â
// If the activity has comments, display a link to the activity's permalink, with its comment count in a speech bubble
|
1630 |
Â
if ( $comment_count ) {
|
1631 |
Â
$title_attr = sprintf( _n( '%s related activity', '%s related activities', $comment_count, 'buddypress' ), number_format_i18n( $comment_count ) );
|
1632 |
+
printf( '<a href="%1$s" title="%2$s" class="post-com-count post-com-count-approved"><span class="comment-count comment-count-approved">%3$s</span></a>', esc_url( $root_activity_url ), esc_attr( $title_attr ), number_format_i18n( $comment_count ) );
|
1633 |
Â
}
|
1634 |
Â
|
1635 |
Â
// For non-root activities, display a link to the replied-to activity's author's profile
|
1636 |
Â
} else {
|
1637 |
Â
echo '<strong>' . get_avatar( $this->get_activity_user_id( $item['item_id'] ), '32' ) . ' ' . bp_core_get_userlink( $this->get_activity_user_id( $item['item_id'] ) ) . '</strong><br />';
|
1638 |
+
echo $activity_permalink;
|
1639 |
Â
}
|
1640 |
+
?>
|
1641 |
Â
|
1642 |
+
</div>
|
1643 |
+
|
1644 |
+
<?php
|
1645 |
Â
}
|
1646 |
Â
|
1647 |
Â
/**
|
1653 |
Â
* @since BuddyPress (1.6.0)
|
1654 |
Â
*
|
1655 |
Â
* @param int $activity_id Activity ID to retrieve User ID for.
|
1656 |
+
*
|
1657 |
Â
* @return int User ID of the activity item in question.
|
1658 |
Â
*/
|
1659 |
Â
protected function get_activity_user_id( $activity_id ) {
|
1687 |
Â
* Checks if an activity item can be replied to.
|
1688 |
Â
*
|
1689 |
Â
* This method merges functionality from {@link bp_activity_can_comment()} and
|
1690 |
+
* {@link bp_blogs_disable_activity_commenting()}. This is done because the activity
|
1691 |
Â
* list table doesn't use a BuddyPress activity loop, which prevents those
|
1692 |
Â
* functions from working as intended.
|
1693 |
Â
*
|
1694 |
Â
* @since BuddyPress (2.0.0)
|
1695 |
Â
*
|
1696 |
Â
* @param array $item An array version of the BP_Activity_Activity object.
|
1697 |
+
*
|
1698 |
Â
* @return bool
|
1699 |
Â
*/
|
1700 |
Â
protected function can_comment( $item ) {
|
1759 |
Â
* @since BuddyPress (1.6.0)
|
1760 |
Â
*
|
1761 |
Â
* @param array $tree Source array.
|
1762 |
+
*
|
1763 |
Â
* @return array Flattened array.
|
1764 |
Â
*/
|
1765 |
Â
public static function flatten_activity_array( $tree ){
|
1776 |
Â
|
1777 |
Â
return $tree;
|
1778 |
Â
}
|
1779 |
+
|
1780 |
+
/**
|
1781 |
+
* Get name of default primary column
|
1782 |
+
*
|
1783 |
+
* @since BuddyPress (2.3.3)
|
1784 |
+
* @access protected
|
1785 |
+
*
|
1786 |
+
* @return string
|
1787 |
+
*/
|
1788 |
+
protected function get_default_primary_column_name() {
|
1789 |
+
return 'author';
|
1790 |
+
}
|
1791 |
Â
}
|
bp-activity/bp-activity-akismet.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Â
* Akismet support for BuddyPress' Activity Stream.
|
4 |
Â
*
|
5 |
Â
* @package BuddyPress
|
6 |
-
* @since BuddyPress (1.6)
|
7 |
Â
* @subpackage Activity
|
8 |
Â
*/
|
9 |
Â
|
@@ -13,7 +13,8 @@ defined( 'ABSPATH' ) || exit;
|
|
13 |
Â
/**
|
14 |
Â
* Akismet support for the Activity component.
|
15 |
Â
*
|
16 |
-
* @since BuddyPress (1.6)
|
Â
|
|
17 |
Â
*/
|
18 |
Â
class BP_Akismet {
|
19 |
Â
/**
|
@@ -21,14 +22,14 @@ class BP_Akismet {
|
|
21 |
Â
*
|
22 |
Â
* @access protected
|
23 |
Â
* @var BP_Activity_Activity
|
24 |
-
* @since BuddyPress (1.6)
|
25 |
Â
*/
|
26 |
Â
protected $last_activity = null;
|
27 |
Â
|
28 |
Â
/**
|
29 |
Â
* Constructor.
|
30 |
Â
*
|
31 |
-
* @since BuddyPress (1.6)
|
32 |
Â
*/
|
33 |
Â
public function __construct() {
|
34 |
Â
$this->setup_actions();
|
@@ -37,7 +38,7 @@ class BP_Akismet {
|
|
37 |
Â
/**
|
38 |
Â
* Hook Akismet into the activity stream.
|
39 |
Â
*
|
40 |
-
* @since BuddyPress (1.6)
|
41 |
Â
*/
|
42 |
Â
protected function setup_actions() {
|
43 |
Â
// Add nonces to activity stream lists
|
@@ -69,10 +70,11 @@ class BP_Akismet {
|
|
69 |
Â
* This function lifted with love from the Akismet WordPress plugin's
|
70 |
Â
* akismet_comment_row_action() function. Thanks!
|
71 |
Â
*
|
72 |
-
* @since BuddyPress (1.6)
|
73 |
Â
*
|
74 |
-
* @param array $actions
|
75 |
Â
* @param array $activity The activity for the current row being processed.
|
Â
|
|
76 |
Â
* @return array The hover links.
|
77 |
Â
*/
|
78 |
Â
function comment_row_action( $actions, $activity ) {
|
@@ -129,9 +131,9 @@ class BP_Akismet {
|
|
129 |
Â
* the reply form of each activity item. The nonces are, in turn, used
|
130 |
Â
* by Akismet to help detect spam activity.
|
131 |
Â
*
|
132 |
-
* @since BuddyPress (1.6)
|
133 |
Â
*
|
134 |
-
* @see
|
135 |
Â
*/
|
136 |
Â
public function add_activity_stream_nonce() {
|
137 |
Â
$form_id = '_bp_as_nonce';
|
@@ -158,13 +160,13 @@ class BP_Akismet {
|
|
158 |
Â
* This can't be done in BP_Akismet::check_activity() due to the
|
159 |
Â
* default AJAX implementation; see bp_dtheme_post_update().
|
160 |
Â
*
|
161 |
-
* @since BuddyPress (1.6)
|
162 |
Â
*
|
163 |
Â
* @see bp_dtheme_post_update()
|
164 |
Â
*
|
165 |
-
* @param string $content
|
166 |
-
* @param int
|
167 |
-
* @param int
|
168 |
Â
*/
|
169 |
Â
public function check_member_activity_update( $content, $user_id, $activity_id ) {
|
170 |
Â
// By default, only handle activity updates and activity comments.
|
@@ -184,7 +186,7 @@ class BP_Akismet {
|
|
184 |
Â
*
|
185 |
Â
* This function is intended to be used inside the activity stream loop.
|
186 |
Â
*
|
187 |
-
* @since BuddyPress (1.6)
|
188 |
Â
*/
|
189 |
Â
public function add_activity_spam_button() {
|
190 |
Â
if ( !bp_activity_user_can_mark_spam() )
|
@@ -212,7 +214,7 @@ class BP_Akismet {
|
|
212 |
Â
*
|
213 |
Â
* This function is intended to be used inside the activity stream loop.
|
214 |
Â
*
|
215 |
-
* @since BuddyPress (1.6)
|
216 |
Â
*/
|
217 |
Â
public function add_activity_comment_spam_button() {
|
218 |
Â
if ( !bp_activity_user_can_mark_spam() )
|
@@ -239,7 +241,7 @@ class BP_Akismet {
|
|
239 |
Â
/**
|
240 |
Â
* Get a filterable list of activity types that Akismet should automatically check for spam.
|
241 |
Â
*
|
242 |
-
* @since BuddyPress (1.6)
|
243 |
Â
*
|
244 |
Â
* @static
|
245 |
Â
*
|
@@ -260,10 +262,12 @@ class BP_Akismet {
|
|
260 |
Â
/**
|
261 |
Â
* Mark activity item as spam.
|
262 |
Â
*
|
263 |
-
* @since BuddyPress (1.6)
|
264 |
Â
*
|
265 |
-
* @param BP_Activity_Activity $activity
|
266 |
-
* @param string
|
Â
|
|
Â
|
|
267 |
Â
*/
|
268 |
Â
public function mark_as_spam( $activity, $source ) {
|
269 |
Â
// Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update()
|
@@ -275,7 +279,10 @@ class BP_Akismet {
|
|
275 |
Â
* @since BuddyPress (1.6.0)
|
276 |
Â
*
|
277 |
Â
* @param BP_Activity_Activity $activity Activity object being marked as spam.
|
278 |
-
* @param string
|
Â
|
|
Â
|
|
Â
|
|
279 |
Â
*/
|
280 |
Â
do_action( 'bp_activity_akismet_mark_as_spam', $activity, $source );
|
281 |
Â
}
|
@@ -283,10 +290,12 @@ class BP_Akismet {
|
|
283 |
Â
/**
|
284 |
Â
* Mark activity item as ham.
|
285 |
Â
*
|
286 |
-
* @since BuddyPress (1.6)
|
287 |
Â
*
|
288 |
-
* @param BP_Activity_Activity $activity
|
289 |
-
* @param string
|
Â
|
|
Â
|
|
290 |
Â
*/
|
291 |
Â
public function mark_as_ham( $activity, $source ) {
|
292 |
Â
// If the activity was, originally, automatically marked as spam by Akismet, run the @mentions filter as it would have been skipped.
|
@@ -299,7 +308,10 @@ class BP_Akismet {
|
|
299 |
Â
* @since BuddyPress (1.6.0)
|
300 |
Â
*
|
301 |
Â
* @param BP_Activity_Activity $activity Activity object being marked as ham.
|
302 |
-
* @param string
|
Â
|
|
Â
|
|
Â
|
|
303 |
Â
*/
|
304 |
Â
do_action( 'bp_activity_akismet_mark_as_ham', $activity, $source );
|
305 |
Â
}
|
@@ -307,12 +319,14 @@ class BP_Akismet {
|
|
307 |
Â
/**
|
308 |
Â
* Build a data package for the Akismet service to inspect.
|
309 |
Â
*
|
310 |
-
* @since BuddyPress (1.6)
|
311 |
Â
*
|
312 |
Â
* @see http://akismet.com/development/api/#comment-check
|
313 |
Â
* @static
|
314 |
Â
*
|
315 |
Â
* @param BP_Activity_Activity $activity Activity item data.
|
Â
|
|
Â
|
|
316 |
Â
*/
|
317 |
Â
public static function build_akismet_data_package( $activity ) {
|
318 |
Â
$userdata = get_userdata( $activity->user_id );
|
@@ -326,7 +340,7 @@ class BP_Akismet {
|
|
326 |
Â
$activity_data['comment_type'] = $activity->type;
|
327 |
Â
$activity_data['permalink'] = bp_activity_get_permalink( $activity->id, $activity );
|
328 |
Â
$activity_data['user_ID'] = $userdata->ID;
|
329 |
-
$activity_data['user_role'] =
|
330 |
Â
|
331 |
Â
/**
|
332 |
Â
* Get the nonce if the new activity was submitted through the "what's up, Paul?" form.
|
@@ -347,8 +361,8 @@ class BP_Akismet {
|
|
347 |
Â
*
|
348 |
Â
* @since BuddyPress (1.6.0)
|
349 |
Â
*
|
350 |
-
* @param array
|
351 |
-
* @param BP_Activity_Activity $activity
|
352 |
Â
*/
|
353 |
Â
return apply_filters( 'bp_akismet_build_akismet_data_package', $activity_data, $activity );
|
354 |
Â
}
|
@@ -356,7 +370,7 @@ class BP_Akismet {
|
|
356 |
Â
/**
|
357 |
Â
* Check if the activity item is spam or ham.
|
358 |
Â
*
|
359 |
-
* @since BuddyPress (1.6)
|
360 |
Â
*
|
361 |
Â
* @see http://akismet.com/development/api/
|
362 |
Â
* @todo Spam counter?
|
@@ -391,8 +405,9 @@ class BP_Akismet {
|
|
391 |
Â
*
|
392 |
Â
* @since BuddyPress (1.6.0)
|
393 |
Â
*
|
394 |
-
* @param BP_Activity_Activity $activity
|
395 |
-
* @param array
|
Â
|
|
396 |
Â
*/
|
397 |
Â
do_action_ref_array( 'bp_activity_akismet_spam_caught', array( &$activity, $activity_data ) );
|
398 |
Â
|
@@ -407,7 +422,7 @@ class BP_Akismet {
|
|
407 |
Â
/**
|
408 |
Â
* Update activity meta after a manual spam change (user-initiated).
|
409 |
Â
*
|
410 |
-
* @since BuddyPress (1.6)
|
411 |
Â
*
|
412 |
Â
* @param BP_Activity_Activity $activity The activity to check.
|
413 |
Â
*/
|
@@ -424,7 +439,7 @@ class BP_Akismet {
|
|
424 |
Â
/**
|
425 |
Â
* Update activity meta after a manual ham change (user-initiated).
|
426 |
Â
*
|
427 |
-
* @since BuddyPress (1.6)
|
428 |
Â
*
|
429 |
Â
* @param BP_Activity_Activity $activity The activity to check.
|
430 |
Â
*/
|
@@ -441,7 +456,7 @@ class BP_Akismet {
|
|
441 |
Â
/**
|
442 |
Â
* Update activity meta after an automatic spam check (not user-initiated).
|
443 |
Â
*
|
444 |
-
* @since BuddyPress (1.6)
|
445 |
Â
*
|
446 |
Â
* @param BP_Activity_Activity $activity The activity to check.
|
447 |
Â
*/
|
@@ -479,23 +494,15 @@ class BP_Akismet {
|
|
479 |
Â
*
|
480 |
Â
* Props to WordPress core Akismet plugin for a lot of this.
|
481 |
Â
*
|
482 |
-
* @since BuddyPress (1.6)
|
483 |
Â
*
|
484 |
-
* @
|
485 |
-
* @
|
Â
|
|
486 |
Â
*
|
487 |
-
* @param array $activity_data Packet of information to submit to Akismet.
|
488 |
-
* @param string $check "check" or "submit".
|
489 |
-
* @param string $spam "spam" or "ham".
|
490 |
Â
* @return array $activity_data Activity data, with Akismet data added.
|
491 |
Â
*/
|
492 |
Â
public function send_akismet_request( $activity_data, $check = 'check', $spam = 'spam' ) {
|
493 |
-
global $akismet_api_host, $akismet_api_port;
|
494 |
-
|
495 |
-
// Check that host and port are set, if not, set them
|
496 |
-
if ( function_exists( 'akismet_init' ) && ( empty( $akismet_api_host ) || empty( $akismet_api_port ) ) )
|
497 |
-
akismet_init();
|
498 |
-
|
499 |
Â
$query_string = $path = '';
|
500 |
Â
|
501 |
Â
$activity_data['blog'] = bp_get_option( 'home' );
|
@@ -505,7 +512,7 @@ class BP_Akismet {
|
|
505 |
Â
$activity_data['user_agent'] = bp_core_current_user_ua();
|
506 |
Â
$activity_data['user_ip'] = bp_core_current_user_ip();
|
507 |
Â
|
508 |
-
if (
|
509 |
Â
$activity_data['is_test'] = 'true';
|
510 |
Â
|
511 |
Â
// Loop through _POST args and rekey strings
|
@@ -533,13 +540,13 @@ class BP_Akismet {
|
|
533 |
Â
$query_string .= $key . '=' . urlencode( stripslashes( $data ) ) . '&';
|
534 |
Â
|
535 |
Â
if ( 'check' == $check )
|
536 |
-
$path = '
|
537 |
Â
elseif ( 'submit' == $check )
|
538 |
-
$path = '
|
539 |
Â
|
540 |
Â
// Send to Akismet
|
541 |
Â
add_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
|
542 |
-
$response =
|
543 |
Â
remove_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
|
544 |
Â
|
545 |
Â
// Get the response
|
@@ -558,9 +565,10 @@ class BP_Akismet {
|
|
558 |
Â
/**
|
559 |
Â
* Filters user agent when sending to Akismet to add BuddyPress info.
|
560 |
Â
*
|
561 |
-
* @since BuddyPress (1.6)
|
562 |
Â
*
|
563 |
Â
* @param string $user_agent User agent string, as generated by Akismet.
|
Â
|
|
564 |
Â
* @return string $user_agent Modified user agent string.
|
565 |
Â
*/
|
566 |
Â
public function buddypress_ua( $user_agent ) {
|
@@ -571,7 +579,7 @@ class BP_Akismet {
|
|
571 |
Â
/**
|
572 |
Â
* Adds a "History" meta box to the activity edit screen.
|
573 |
Â
*
|
574 |
-
* @since BuddyPress (1.6)
|
575 |
Â
*
|
576 |
Â
* @param string $screen_action The type of screen that has been requested.
|
577 |
Â
*/
|
@@ -587,9 +595,9 @@ class BP_Akismet {
|
|
587 |
Â
/**
|
588 |
Â
* History meta box for the Activity admin edit screen.
|
589 |
Â
*
|
590 |
-
* @since BuddyPress (1.6)
|
591 |
Â
*
|
592 |
-
* @see
|
593 |
Â
* @todo Update activity meta to allow >1 record with the same key (iterate through $history).
|
594 |
Â
*
|
595 |
Â
* @param object $item Activity item.
|
@@ -608,17 +616,17 @@ class BP_Akismet {
|
|
608 |
Â
/**
|
609 |
Â
* Update an activity item's Akismet history.
|
610 |
Â
*
|
611 |
-
* @since BuddyPress (1.6)
|
612 |
Â
*
|
613 |
-
* @param int
|
614 |
-
* @param string $message
|
615 |
-
* @param string $event
|
616 |
Â
*/
|
617 |
Â
public function update_activity_history( $activity_id = 0, $message = '', $event = '' ) {
|
618 |
Â
$event = array(
|
619 |
Â
'event' => $event,
|
620 |
Â
'message' => $message,
|
621 |
-
'time' =>
|
622 |
Â
'user' => bp_loggedin_user_id(),
|
623 |
Â
);
|
624 |
Â
|
@@ -629,9 +637,10 @@ class BP_Akismet {
|
|
629 |
Â
/**
|
630 |
Â
* Get an activity item's Akismet history.
|
631 |
Â
*
|
632 |
-
* @since BuddyPress (1.6)
|
633 |
Â
*
|
634 |
Â
* @param int $activity_id Activity item ID.
|
Â
|
|
635 |
Â
* @return array The activity item's Akismet history.
|
636 |
Â
*/
|
637 |
Â
public function get_activity_history( $activity_id = 0 ) {
|
@@ -647,18 +656,19 @@ class BP_Akismet {
|
|
647 |
Â
}
|
648 |
Â
|
649 |
Â
/**
|
650 |
-
* Delete old spam activity meta data
|
651 |
Â
*
|
652 |
Â
* This is done as a clean-up mechanism, as _bp_akismet_submission meta can
|
653 |
Â
* grow to be quite large.
|
654 |
Â
*
|
655 |
-
* @since BuddyPress (1.6)
|
656 |
Â
*
|
657 |
-
* @global object $bp BuddyPress global settings.
|
658 |
Â
* @global wpdb $wpdb WordPress database object.
|
659 |
Â
*/
|
660 |
Â
function bp_activity_akismet_delete_old_metadata() {
|
661 |
-
global $
|
Â
|
|
Â
|
|
662 |
Â
|
663 |
Â
/**
|
664 |
Â
* Filters the threshold for how many days old Akismet metadata needs to be before being automatically deleted.
|
3 |
Â
* Akismet support for BuddyPress' Activity Stream.
|
4 |
Â
*
|
5 |
Â
* @package BuddyPress
|
6 |
+
* @since BuddyPress (1.6.0)
|
7 |
Â
* @subpackage Activity
|
8 |
Â
*/
|
9 |
Â
|
13 |
Â
/**
|
14 |
Â
* Akismet support for the Activity component.
|
15 |
Â
*
|
16 |
+
* @since BuddyPress (1.6.0)
|
17 |
+
* @since BuddyPress (2.3.0) We only support Akismet 3+.
|
18 |
Â
*/
|
19 |
Â
class BP_Akismet {
|
20 |
Â
/**
|
22 |
Â
*
|
23 |
Â
* @access protected
|
24 |
Â
* @var BP_Activity_Activity
|
25 |
+
* @since BuddyPress (1.6.0)
|
26 |
Â
*/
|
27 |
Â
protected $last_activity = null;
|
28 |
Â
|
29 |
Â
/**
|
30 |
Â
* Constructor.
|
31 |
Â
*
|
32 |
+
* @since BuddyPress (1.6.0)
|
33 |
Â
*/
|
34 |
Â
public function __construct() {
|
35 |
Â
$this->setup_actions();
|
38 |
Â
/**
|
39 |
Â
* Hook Akismet into the activity stream.
|
40 |
Â
*
|
41 |
+
* @since BuddyPress (1.6.0)
|
42 |
Â
*/
|
43 |
Â
protected function setup_actions() {
|
44 |
Â
// Add nonces to activity stream lists
|
70 |
Â
* This function lifted with love from the Akismet WordPress plugin's
|
71 |
Â
* akismet_comment_row_action() function. Thanks!
|
72 |
Â
*
|
73 |
+
* @since BuddyPress (1.6.0)
|
74 |
Â
*
|
75 |
+
* @param array $actions The hover links.
|
76 |
Â
* @param array $activity The activity for the current row being processed.
|
77 |
+
*
|
78 |
Â
* @return array The hover links.
|
79 |
Â
*/
|
80 |
Â
function comment_row_action( $actions, $activity ) {
|
131 |
Â
* the reply form of each activity item. The nonces are, in turn, used
|
132 |
Â
* by Akismet to help detect spam activity.
|
133 |
Â
*
|
134 |
+
* @since BuddyPress (1.6.0)
|
135 |
Â
*
|
136 |
+
* @see https://plugins.trac.wordpress.org/ticket/1232
|
137 |
Â
*/
|
138 |
Â
public function add_activity_stream_nonce() {
|
139 |
Â
$form_id = '_bp_as_nonce';
|
160 |
Â
* This can't be done in BP_Akismet::check_activity() due to the
|
161 |
Â
* default AJAX implementation; see bp_dtheme_post_update().
|
162 |
Â
*
|
163 |
+
* @since BuddyPress (1.6.0)
|
164 |
Â
*
|
165 |
Â
* @see bp_dtheme_post_update()
|
166 |
Â
*
|
167 |
+
* @param string $content Activity update text.
|
168 |
+
* @param int $user_id User ID.
|
169 |
+
* @param int $activity_id Activity ID.
|
170 |
Â
*/
|
171 |
Â
public function check_member_activity_update( $content, $user_id, $activity_id ) {
|
172 |
Â
// By default, only handle activity updates and activity comments.
|
186 |
Â
*
|
187 |
Â
* This function is intended to be used inside the activity stream loop.
|
188 |
Â
*
|
189 |
+
* @since BuddyPress (1.6.0)
|
190 |
Â
*/
|
191 |
Â
public function add_activity_spam_button() {
|
192 |
Â
if ( !bp_activity_user_can_mark_spam() )
|
214 |
Â
*
|
215 |
Â
* This function is intended to be used inside the activity stream loop.
|
216 |
Â
*
|
217 |
+
* @since BuddyPress (1.6.0)
|
218 |
Â
*/
|
219 |
Â
public function add_activity_comment_spam_button() {
|
220 |
Â
if ( !bp_activity_user_can_mark_spam() )
|
241 |
Â
/**
|
242 |
Â
* Get a filterable list of activity types that Akismet should automatically check for spam.
|
243 |
Â
*
|
244 |
+
* @since BuddyPress (1.6.0)
|
245 |
Â
*
|
246 |
Â
* @static
|
247 |
Â
*
|
262 |
Â
/**
|
263 |
Â
* Mark activity item as spam.
|
264 |
Â
*
|
265 |
+
* @since BuddyPress (1.6.0)
|
266 |
Â
*
|
267 |
+
* @param BP_Activity_Activity $activity Activity item being spammed.
|
268 |
+
* @param string $source Either "by_a_person" (e.g. a person has
|
269 |
+
* manually marked the activity as spam) or
|
270 |
+
* "by_akismet" (automatically spammed).
|
271 |
Â
*/
|
272 |
Â
public function mark_as_spam( $activity, $source ) {
|
273 |
Â
// Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update()
|
279 |
Â
* @since BuddyPress (1.6.0)
|
280 |
Â
*
|
281 |
Â
* @param BP_Activity_Activity $activity Activity object being marked as spam.
|
282 |
+
* @param string $source Source of the whom marked as spam.
|
283 |
+
* Either "by_a_person" (e.g. a person has
|
284 |
+
* manually marked the activity as spam)
|
285 |
+
* or "by_akismet".
|
286 |
Â
*/
|
287 |
Â
do_action( 'bp_activity_akismet_mark_as_spam', $activity, $source );
|
288 |
Â
}
|
290 |
Â
/**
|
291 |
Â
* Mark activity item as ham.
|
292 |
Â
*
|
293 |
+
* @since BuddyPress (1.6.0)
|
294 |
Â
*
|
295 |
+
* @param BP_Activity_Activity $activity Activity item being hammed.
|
296 |
+
* @param string $source Either "by_a_person" (e.g. a person has
|
297 |
+
* manually marked the activity as ham) or
|
298 |
+
* "by_akismet" (automatically hammed).
|
299 |
Â
*/
|
300 |
Â
public function mark_as_ham( $activity, $source ) {
|
301 |
Â
// If the activity was, originally, automatically marked as spam by Akismet, run the @mentions filter as it would have been skipped.
|
308 |
Â
* @since BuddyPress (1.6.0)
|
309 |
Â
*
|
310 |
Â
* @param BP_Activity_Activity $activity Activity object being marked as ham.
|
311 |
+
* @param string $source Source of the whom marked as ham.
|
312 |
+
* Either "by_a_person" (e.g. a person has
|
313 |
+
* manually marked the activity as ham) or
|
314 |
+
* "by_akismet" (automatically hammed).
|
315 |
Â
*/
|
316 |
Â
do_action( 'bp_activity_akismet_mark_as_ham', $activity, $source );
|
317 |
Â
}
|
319 |
Â
/**
|
320 |
Â
* Build a data package for the Akismet service to inspect.
|
321 |
Â
*
|
322 |
+
* @since BuddyPress (1.6.0)
|
323 |
Â
*
|
324 |
Â
* @see http://akismet.com/development/api/#comment-check
|
325 |
Â
* @static
|
326 |
Â
*
|
327 |
Â
* @param BP_Activity_Activity $activity Activity item data.
|
328 |
+
*
|
329 |
+
* @return array
|
330 |
Â
*/
|
331 |
Â
public static function build_akismet_data_package( $activity ) {
|
332 |
Â
$userdata = get_userdata( $activity->user_id );
|
340 |
Â
$activity_data['comment_type'] = $activity->type;
|
341 |
Â
$activity_data['permalink'] = bp_activity_get_permalink( $activity->id, $activity );
|
342 |
Â
$activity_data['user_ID'] = $userdata->ID;
|
343 |
+
$activity_data['user_role'] = Akismet::get_user_roles( $userdata->ID );
|
344 |
Â
|
345 |
Â
/**
|
346 |
Â
* Get the nonce if the new activity was submitted through the "what's up, Paul?" form.
|
361 |
Â
*
|
362 |
Â
* @since BuddyPress (1.6.0)
|
363 |
Â
*
|
364 |
+
* @param array $activity_data Array of activity data for Akismet to inspect.
|
365 |
+
* @param BP_Activity_Activity $activity Activity item data.
|
366 |
Â
*/
|
367 |
Â
return apply_filters( 'bp_akismet_build_akismet_data_package', $activity_data, $activity );
|
368 |
Â
}
|
370 |
Â
/**
|
371 |
Â
* Check if the activity item is spam or ham.
|
372 |
Â
*
|
373 |
+
* @since BuddyPress (1.6.0)
|
374 |
Â
*
|
375 |
Â
* @see http://akismet.com/development/api/
|
376 |
Â
* @todo Spam counter?
|
405 |
Â
*
|
406 |
Â
* @since BuddyPress (1.6.0)
|
407 |
Â
*
|
408 |
+
* @param BP_Activity_Activity $activity The activity item proven to be spam.
|
409 |
+
* @param array $activity_data Array of activity data for item including
|
410 |
+
* Akismet check results data.
|
411 |
Â
*/
|
412 |
Â
do_action_ref_array( 'bp_activity_akismet_spam_caught', array( &$activity, $activity_data ) );
|
413 |
Â
|
422 |
Â
/**
|
423 |
Â
* Update activity meta after a manual spam change (user-initiated).
|
424 |
Â
*
|
425 |
+
* @since BuddyPress (1.6.0)
|
426 |
Â
*
|
427 |
Â
* @param BP_Activity_Activity $activity The activity to check.
|
428 |
Â
*/
|
439 |
Â
/**
|
440 |
Â
* Update activity meta after a manual ham change (user-initiated).
|
441 |
Â
*
|
442 |
+
* @since BuddyPress (1.6.0)
|
443 |
Â
*
|
444 |
Â
* @param BP_Activity_Activity $activity The activity to check.
|
445 |
Â
*/
|
456 |
Â
/**
|
457 |
Â
* Update activity meta after an automatic spam check (not user-initiated).
|
458 |
Â
*
|
459 |
+
* @since BuddyPress (1.6.0)
|
460 |
Â
*
|
461 |
Â
* @param BP_Activity_Activity $activity The activity to check.
|
462 |
Â
*/
|
494 |
Â
*
|
495 |
Â
* Props to WordPress core Akismet plugin for a lot of this.
|
496 |
Â
*
|
497 |
+
* @since BuddyPress (1.6.0)
|
498 |
Â
*
|
499 |
+
* @param array $activity_data Packet of information to submit to Akismet.
|
500 |
+
* @param string $check "check" or "submit".
|
501 |
+
* @param string $spam "spam" or "ham".
|
502 |
Â
*
|
Â
|
|
Â
|
|
Â
|
|
503 |
Â
* @return array $activity_data Activity data, with Akismet data added.
|
504 |
Â
*/
|
505 |
Â
public function send_akismet_request( $activity_data, $check = 'check', $spam = 'spam' ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
506 |
Â
$query_string = $path = '';
|
507 |
Â
|
508 |
Â
$activity_data['blog'] = bp_get_option( 'home' );
|
512 |
Â
$activity_data['user_agent'] = bp_core_current_user_ua();
|
513 |
Â
$activity_data['user_ip'] = bp_core_current_user_ip();
|
514 |
Â
|
515 |
+
if ( Akismet::is_test_mode() )
|
516 |
Â
$activity_data['is_test'] = 'true';
|
517 |
Â
|
518 |
Â
// Loop through _POST args and rekey strings
|
540 |
Â
$query_string .= $key . '=' . urlencode( stripslashes( $data ) ) . '&';
|
541 |
Â
|
542 |
Â
if ( 'check' == $check )
|
543 |
+
$path = 'comment-check';
|
544 |
Â
elseif ( 'submit' == $check )
|
545 |
+
$path = 'submit-' . $spam;
|
546 |
Â
|
547 |
Â
// Send to Akismet
|
548 |
Â
add_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
|
549 |
+
$response = Akismet::http_post( $query_string, $path );
|
550 |
Â
remove_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
|
551 |
Â
|
552 |
Â
// Get the response
|
565 |
Â
/**
|
566 |
Â
* Filters user agent when sending to Akismet to add BuddyPress info.
|
567 |
Â
*
|
568 |
+
* @since BuddyPress (1.6.0)
|
569 |
Â
*
|
570 |
Â
* @param string $user_agent User agent string, as generated by Akismet.
|
571 |
+
*
|
572 |
Â
* @return string $user_agent Modified user agent string.
|
573 |
Â
*/
|
574 |
Â
public function buddypress_ua( $user_agent ) {
|
579 |
Â
/**
|
580 |
Â
* Adds a "History" meta box to the activity edit screen.
|
581 |
Â
*
|
582 |
+
* @since BuddyPress (1.6.0)
|
583 |
Â
*
|
584 |
Â
* @param string $screen_action The type of screen that has been requested.
|
585 |
Â
*/
|
595 |
Â
/**
|
596 |
Â
* History meta box for the Activity admin edit screen.
|
597 |
Â
*
|
598 |
+
* @since BuddyPress (1.6.0)
|
599 |
Â
*
|
600 |
+
* @see https://buddypress.trac.wordpress.org/ticket/3907
|
601 |
Â
* @todo Update activity meta to allow >1 record with the same key (iterate through $history).
|
602 |
Â
*
|
603 |
Â
* @param object $item Activity item.
|
616 |
Â
/**
|
617 |
Â
* Update an activity item's Akismet history.
|
618 |
Â
*
|
619 |
+
* @since BuddyPress (1.6.0)
|
620 |
Â
*
|
621 |
+
* @param int $activity_id Activity item ID.
|
622 |
+
* @param string $message Human-readable description of what's changed.
|
623 |
+
* @param string $event The type of check we were carrying out.
|
624 |
Â
*/
|
625 |
Â
public function update_activity_history( $activity_id = 0, $message = '', $event = '' ) {
|
626 |
Â
$event = array(
|
627 |
Â
'event' => $event,
|
628 |
Â
'message' => $message,
|
629 |
+
'time' => Akismet::_get_microtime(),
|
630 |
Â
'user' => bp_loggedin_user_id(),
|
631 |
Â
);
|
632 |
Â
|
637 |
Â
/**
|
638 |
Â
* Get an activity item's Akismet history.
|
639 |
Â
*
|
640 |
+
* @since BuddyPress (1.6.0)
|
641 |
Â
*
|
642 |
Â
* @param int $activity_id Activity item ID.
|
643 |
+
*
|
644 |
Â
* @return array The activity item's Akismet history.
|
645 |
Â
*/
|
646 |
Â
public function get_activity_history( $activity_id = 0 ) {
|
656 |
Â
}
|
657 |
Â
|
658 |
Â
/**
|
659 |
+
* Delete old spam activity meta data.
|
660 |
Â
*
|
661 |
Â
* This is done as a clean-up mechanism, as _bp_akismet_submission meta can
|
662 |
Â
* grow to be quite large.
|
663 |
Â
*
|
664 |
+
* @since BuddyPress (1.6.0)
|
665 |
Â
*
|
Â
|
|
666 |
Â
* @global wpdb $wpdb WordPress database object.
|
667 |
Â
*/
|
668 |
Â
function bp_activity_akismet_delete_old_metadata() {
|
669 |
+
global $wpdb;
|
670 |
+
|
671 |
+
$bp = buddypress();
|
672 |
Â
|
673 |
Â
/**
|
674 |
Â
* Filters the threshold for how many days old Akismet metadata needs to be before being automatically deleted.
|
bp-activity/bp-activity-cache.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Â
/**
|
4 |
Â
* Functions related to the BuddyPress Activity component and the WP Cache.
|
5 |
Â
*
|
6 |
-
* @since BuddyPress (1.6)
|
7 |
Â
*/
|
8 |
Â
|
9 |
Â
// Exit if accessed directly
|
@@ -16,11 +16,11 @@ defined( 'ABSPATH' ) || exit;
|
|
16 |
Â
* in $activity_ids and adds it to the WP cache. This improves efficiency when
|
17 |
Â
* using querying activitymeta inline.
|
18 |
Â
*
|
19 |
-
* @param int|
|
20 |
-
*
|
21 |
Â
*/
|
22 |
Â
function bp_activity_update_meta_cache( $activity_ids = false ) {
|
23 |
-
|
24 |
Â
|
25 |
Â
$cache_args = array(
|
26 |
Â
'object_ids' => $activity_ids,
|
@@ -37,7 +37,7 @@ function bp_activity_update_meta_cache( $activity_ids = false ) {
|
|
37 |
Â
/**
|
38 |
Â
* Clear a cached activity item when that item is updated.
|
39 |
Â
*
|
40 |
-
* @since 2.0
|
41 |
Â
*
|
42 |
Â
* @param BP_Activity_Activity $activity
|
43 |
Â
*/
|
@@ -50,7 +50,7 @@ add_action( 'bp_activity_after_save', 'bp_activity_clear_cache_for_activity' );
|
|
50 |
Â
/**
|
51 |
Â
* Clear cached data for deleted activity items.
|
52 |
Â
*
|
53 |
-
* @since 2.0
|
54 |
Â
*
|
55 |
Â
* @param array $deleted_ids IDs of deleted activity items.
|
56 |
Â
*/
|
3 |
Â
/**
|
4 |
Â
* Functions related to the BuddyPress Activity component and the WP Cache.
|
5 |
Â
*
|
6 |
+
* @since BuddyPress (1.6.0)
|
7 |
Â
*/
|
8 |
Â
|
9 |
Â
// Exit if accessed directly
|
16 |
Â
* in $activity_ids and adds it to the WP cache. This improves efficiency when
|
17 |
Â
* using querying activitymeta inline.
|
18 |
Â
*
|
19 |
+
* @param int|string|array|bool $activity_ids Accepts a single activity ID, or a comma-
|
20 |
+
* separated list or array of activity ids
|
21 |
Â
*/
|
22 |
Â
function bp_activity_update_meta_cache( $activity_ids = false ) {
|
23 |
+
$bp = buddypress();
|
24 |
Â
|
25 |
Â
$cache_args = array(
|
26 |
Â
'object_ids' => $activity_ids,
|
37 |
Â
/**
|
38 |
Â
* Clear a cached activity item when that item is updated.
|
39 |
Â
*
|
40 |
+
* @since BuddyPress (2.0.0)
|
41 |
Â
*
|
42 |
Â
* @param BP_Activity_Activity $activity
|
43 |
Â
*/
|
50 |
Â
/**
|
51 |
Â
* Clear cached data for deleted activity items.
|
52 |
Â
*
|
53 |
+
* @since BuddyPress (2.0.0)
|
54 |
Â
*
|
55 |
Â
* @param array $deleted_ids IDs of deleted activity items.
|
56 |
Â
*/
|
bp-activity/bp-activity-classes.php
CHANGED
@@ -9,2382 +9,6 @@
|
|
9 |
Â
// Exit if accessed directly
|
10 |
Â
defined( 'ABSPATH' ) || exit;
|
11 |
Â
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
* Instance methods are available for creating/editing an activity,
|
16 |
-
* static methods for querying activities.
|
17 |
-
*
|
18 |
-
* @since BuddyPress (1.0)
|
19 |
-
*/
|
20 |
-
class BP_Activity_Activity {
|
21 |
-
|
22 |
-
/** Properties ************************************************************/
|
23 |
-
|
24 |
-
/**
|
25 |
-
* ID of the activity item.
|
26 |
-
*
|
27 |
-
* @var int
|
28 |
-
*/
|
29 |
-
var $id;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* ID of the associated item.
|
33 |
-
*
|
34 |
-
* @var int
|
35 |
-
*/
|
36 |
-
var $item_id;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* ID of the associated secondary item.
|
40 |
-
*
|
41 |
-
* @var int
|
42 |
-
*/
|
43 |
-
var $secondary_item_id;
|
44 |
-
|
45 |
-
/**
|
46 |
-
* ID of user associated with the activity item.
|
47 |
-
*
|
48 |
-
* @var int
|
49 |
-
*/
|
50 |
-
var $user_id;
|
51 |
-
|
52 |
-
/**
|
53 |
-
* The primary URL for the activity in RSS feeds.
|
54 |
-
*
|
55 |
-
* @var string
|
56 |
-
*/
|
57 |
-
var $primary_link;
|
58 |
-
|
59 |
-
/**
|
60 |
-
* BuddyPress component the activity item relates to.
|
61 |
-
*
|
62 |
-
* @var string
|
63 |
-
*/
|
64 |
-
var $component;
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Activity type, eg 'new_blog_post'.
|
68 |
-
*
|
69 |
-
* @var string
|
70 |
-
*/
|
71 |
-
var $type;
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Description of the activity, eg 'Alex updated his profile.'
|
75 |
-
*
|
76 |
-
* @var string
|
77 |
-
*/
|
78 |
-
var $action;
|
79 |
-
|
80 |
-
/**
|
81 |
-
* The content of the activity item.
|
82 |
-
*
|
83 |
-
* @var string
|
84 |
-
*/
|
85 |
-
var $content;
|
86 |
-
|
87 |
-
/**
|
88 |
-
* The date the activity item was recorded, in 'Y-m-d h:i:s' format.
|
89 |
-
*
|
90 |
-
* @var string
|
91 |
-
*/
|
92 |
-
var $date_recorded;
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Whether the item should be hidden in sitewide streams.
|
96 |
-
*
|
97 |
-
* @var int
|
98 |
-
*/
|
99 |
-
var $hide_sitewide = false;
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Node boundary start for activity or activity comment.
|
103 |
-
*
|
104 |
-
* @var int
|
105 |
-
*/
|
106 |
-
var $mptt_left;
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Node boundary end for activity or activity comment.
|
110 |
-
*
|
111 |
-
* @var int
|
112 |
-
*/
|
113 |
-
var $mptt_right;
|
114 |
-
|
115 |
-
/**
|
116 |
-
* Whether this item is marked as spam.
|
117 |
-
*
|
118 |
-
* @var int
|
119 |
-
*/
|
120 |
-
var $is_spam;
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Constructor method.
|
124 |
-
*
|
125 |
-
* @param int $id Optional. The ID of a specific activity item.
|
126 |
-
*/
|
127 |
-
public function __construct( $id = false ) {
|
128 |
-
if ( !empty( $id ) ) {
|
129 |
-
$this->id = $id;
|
130 |
-
$this->populate();
|
131 |
-
}
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Populate the object with data about the specific activity item.
|
136 |
-
*/
|
137 |
-
public function populate() {
|
138 |
-
global $wpdb;
|
139 |
-
|
140 |
-
$row = wp_cache_get( $this->id, 'bp_activity' );
|
141 |
-
|
142 |
-
if ( false === $row ) {
|
143 |
-
$bp = buddypress();
|
144 |
-
$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) );
|
145 |
-
|
146 |
-
wp_cache_set( $this->id, $row, 'bp_activity' );
|
147 |
-
}
|
148 |
-
|
149 |
-
if ( ! empty( $row ) ) {
|
150 |
-
$this->id = (int) $row->id;
|
151 |
-
$this->item_id = (int) $row->item_id;
|
152 |
-
$this->secondary_item_id = (int) $row->secondary_item_id;
|
153 |
-
$this->user_id = (int) $row->user_id;
|
154 |
-
$this->primary_link = $row->primary_link;
|
155 |
-
$this->component = $row->component;
|
156 |
-
$this->type = $row->type;
|
157 |
-
$this->action = $row->action;
|
158 |
-
$this->content = $row->content;
|
159 |
-
$this->date_recorded = $row->date_recorded;
|
160 |
-
$this->hide_sitewide = $row->hide_sitewide;
|
161 |
-
$this->mptt_left = (int) $row->mptt_left;
|
162 |
-
$this->mptt_right = (int) $row->mptt_right;
|
163 |
-
$this->is_spam = $row->is_spam;
|
164 |
-
}
|
165 |
-
|
166 |
-
// Generate dynamic 'action' when possible
|
167 |
-
$action = bp_activity_generate_action_string( $this );
|
168 |
-
if ( false !== $action ) {
|
169 |
-
$this->action = $action;
|
170 |
-
|
171 |
-
// If no callback is available, use the literal string from
|
172 |
-
// the database row
|
173 |
-
} elseif ( ! empty( $row->action ) ) {
|
174 |
-
$this->action = $row->action;
|
175 |
-
|
176 |
-
// Provide a fallback to avoid PHP notices
|
177 |
-
} else {
|
178 |
-
$this->action = '';
|
179 |
-
}
|
180 |
-
}
|
181 |
-
|
182 |
-
/**
|
183 |
-
* Save the activity item to the database.
|
184 |
-
*
|
185 |
-
* @return bool True on success.
|
186 |
-
*/
|
187 |
-
public function save() {
|
188 |
-
global $wpdb;
|
189 |
-
|
190 |
-
$bp = buddypress();
|
191 |
-
|
192 |
-
$this->id = apply_filters_ref_array( 'bp_activity_id_before_save', array( $this->id, &$this ) );
|
193 |
-
$this->item_id = apply_filters_ref_array( 'bp_activity_item_id_before_save', array( $this->item_id, &$this ) );
|
194 |
-
$this->secondary_item_id = apply_filters_ref_array( 'bp_activity_secondary_item_id_before_save', array( $this->secondary_item_id, &$this ) );
|
195 |
-
$this->user_id = apply_filters_ref_array( 'bp_activity_user_id_before_save', array( $this->user_id, &$this ) );
|
196 |
-
$this->primary_link = apply_filters_ref_array( 'bp_activity_primary_link_before_save', array( $this->primary_link, &$this ) );
|
197 |
-
$this->component = apply_filters_ref_array( 'bp_activity_component_before_save', array( $this->component, &$this ) );
|
198 |
-
$this->type = apply_filters_ref_array( 'bp_activity_type_before_save', array( $this->type, &$this ) );
|
199 |
-
$this->action = apply_filters_ref_array( 'bp_activity_action_before_save', array( $this->action, &$this ) );
|
200 |
-
$this->content = apply_filters_ref_array( 'bp_activity_content_before_save', array( $this->content, &$this ) );
|
201 |
-
$this->date_recorded = apply_filters_ref_array( 'bp_activity_date_recorded_before_save', array( $this->date_recorded, &$this ) );
|
202 |
-
$this->hide_sitewide = apply_filters_ref_array( 'bp_activity_hide_sitewide_before_save', array( $this->hide_sitewide, &$this ) );
|
203 |
-
$this->mptt_left = apply_filters_ref_array( 'bp_activity_mptt_left_before_save', array( $this->mptt_left, &$this ) );
|
204 |
-
$this->mptt_right = apply_filters_ref_array( 'bp_activity_mptt_right_before_save', array( $this->mptt_right, &$this ) );
|
205 |
-
$this->is_spam = apply_filters_ref_array( 'bp_activity_is_spam_before_save', array( $this->is_spam, &$this ) );
|
206 |
-
|
207 |
-
/**
|
208 |
-
* Fires before the current activity item gets saved.
|
209 |
-
*
|
210 |
-
* Please use this hook to filter the properties above. Each part will be passed in.
|
211 |
-
*
|
212 |
-
* @since BuddyPress (1.0.0)
|
213 |
-
*
|
214 |
-
* @param BP_Activity_Activity Current instance of the activity item being saved.
|
215 |
-
*/
|
216 |
-
do_action_ref_array( 'bp_activity_before_save', array( &$this ) );
|
217 |
-
|
218 |
-
if ( empty( $this->component ) || empty( $this->type ) ) {
|
219 |
-
return false;
|
220 |
-
}
|
221 |
-
|
222 |
-
if ( empty( $this->primary_link ) ) {
|
223 |
-
$this->primary_link = bp_loggedin_user_domain();
|
224 |
-
}
|
225 |
-
|
226 |
-
// If we have an existing ID, update the activity item, otherwise insert it.
|
227 |
-
if ( ! empty( $this->id ) ) {
|
228 |
-
$q = $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET user_id = %d, component = %s, type = %s, action = %s, content = %s, primary_link = %s, date_recorded = %s, item_id = %d, secondary_item_id = %d, hide_sitewide = %d, is_spam = %d WHERE id = %d", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam, $this->id );
|
229 |
-
} else {
|
230 |
-
$q = $wpdb->prepare( "INSERT INTO {$bp->activity->table_name} ( user_id, component, type, action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide, is_spam ) VALUES ( %d, %s, %s, %s, %s, %s, %s, %d, %d, %d, %d )", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam );
|
231 |
-
}
|
232 |
-
|
233 |
-
if ( false === $wpdb->query( $q ) ) {
|
234 |
-
return false;
|
235 |
-
}
|
236 |
-
|
237 |
-
// If this is a new activity item, set the $id property
|
238 |
-
if ( empty( $this->id ) ) {
|
239 |
-
$this->id = $wpdb->insert_id;
|
240 |
-
|
241 |
-
// If an existing activity item, prevent any changes to the content generating new @mention notifications.
|
242 |
-
} else {
|
243 |
-
add_filter( 'bp_activity_at_name_do_notifications', '__return_false' );
|
244 |
-
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* Fires after an activity item has been saved to the database.
|
248 |
-
*
|
249 |
-
* @since BuddyPress (1.0.0)
|
250 |
-
*
|
251 |
-
* @param BP_Activity_Activity Reference to current instance of activity being saved.
|
252 |
-
*/
|
253 |
-
do_action_ref_array( 'bp_activity_after_save', array( &$this ) );
|
254 |
-
|
255 |
-
return true;
|
256 |
-
}
|
257 |
-
|
258 |
-
/** Static Methods ***************************************************/
|
259 |
-
|
260 |
-
/**
|
261 |
-
* Get activity items, as specified by parameters
|
262 |
-
*
|
263 |
-
* @see BP_Activity_Activity::get_filter_sql() for a description of the
|
264 |
-
* 'filter' parameter.
|
265 |
-
* @see WP_Meta_Query::queries for a description of the 'meta_query'
|
266 |
-
* parameter format.
|
267 |
-
*
|
268 |
-
* @param array $args {
|
269 |
-
* An array of arguments. All items are optional.
|
270 |
-
*
|
271 |
-
* @type int $page Which page of results to fetch. Using page=1 without per_page will result
|
272 |
-
* in no pagination. Default: 1.
|
273 |
-
* @type int|bool $per_page Number of results per page. Default: 25.
|
274 |
-
* @type int|bool $max Maximum number of results to return. Default: false (unlimited).
|
275 |
-
* @type string $sort ASC or DESC. Default: 'DESC'.
|
276 |
-
* @type array $exclude Array of activity IDs to exclude. Default: false.
|
277 |
-
* @type array $in Array of ids to limit query by (IN). Default: false.
|
278 |
-
* @type array $meta_query Array of meta_query conditions. See WP_Meta_Query::queries.
|
279 |
-
* @type array $date_query Array of date_query conditions. See first parameter of
|
280 |
-
* WP_Date_Query::__construct().
|
281 |
-
* @type array $filter_query Array of advanced query conditions. See BP_Activity_Query::__construct().
|
282 |
-
* @type string|array $scope Pre-determined set of activity arguments.
|
283 |
-
* @type array $filter See BP_Activity_Activity::get_filter_sql().
|
284 |
-
* @type string $search_terms Limit results by a search term. Default: false.
|
285 |
-
* @type bool $display_comments Whether to include activity comments. Default: false.
|
286 |
-
* @type bool $show_hidden Whether to show items marked hide_sitewide. Default: false.
|
287 |
-
* @type string $spam Spam status. Default: 'ham_only'.
|
288 |
-
* @type bool $update_meta_cache Whether to pre-fetch metadata for queried activity items. Default: true.
|
289 |
-
* @type string|bool $count_total If true, an additional DB query is run to count the total activity items
|
290 |
-
* for the query. Default: false.
|
291 |
-
* }
|
292 |
-
* @return array The array returned has two keys:
|
293 |
-
* - 'total' is the count of located activities
|
294 |
-
* - 'activities' is an array of the located activities
|
295 |
-
*/
|
296 |
-
public static function get( $args = array() ) {
|
297 |
-
global $wpdb;
|
298 |
-
|
299 |
-
// Backward compatibility with old method of passing arguments
|
300 |
-
if ( !is_array( $args ) || func_num_args() > 1 ) {
|
301 |
-
_deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
|
302 |
-
|
303 |
-
$old_args_keys = array(
|
304 |
-
0 => 'max',
|
305 |
-
1 => 'page',
|
306 |
-
2 => 'per_page',
|
307 |
-
3 => 'sort',
|
308 |
-
4 => 'search_terms',
|
309 |
-
5 => 'filter',
|
310 |
-
6 => 'display_comments',
|
311 |
-
7 => 'show_hidden',
|
312 |
-
8 => 'exclude',
|
313 |
-
9 => 'in',
|
314 |
-
10 => 'spam'
|
315 |
-
);
|
316 |
-
|
317 |
-
$func_args = func_get_args();
|
318 |
-
$args = bp_core_parse_args_array( $old_args_keys, $func_args );
|
319 |
-
}
|
320 |
-
|
321 |
-
$bp = buddypress();
|
322 |
-
$r = wp_parse_args( $args, array(
|
323 |
-
'page' => 1, // The current page
|
324 |
-
'per_page' => 25, // Activity items per page
|
325 |
-
'max' => false, // Max number of items to return
|
326 |
-
'sort' => 'DESC', // ASC or DESC
|
327 |
-
'exclude' => false, // Array of ids to exclude
|
328 |
-
'in' => false, // Array of ids to limit query by (IN)
|
329 |
-
'meta_query' => false, // Filter by activitymeta
|
330 |
-
'date_query' => false, // Filter by date
|
331 |
-
'filter_query' => false, // Advanced filtering - see BP_Activity_Query
|
332 |
-
'filter' => false, // See self::get_filter_sql()
|
333 |
-
'scope' => false, // Preset activity arguments
|
334 |
-
'search_terms' => false, // Terms to search by
|
335 |
-
'display_comments' => false, // Whether to include activity comments
|
336 |
-
'show_hidden' => false, // Show items marked hide_sitewide
|
337 |
-
'spam' => 'ham_only', // Spam status
|
338 |
-
'update_meta_cache' => true,
|
339 |
-
'count_total' => false,
|
340 |
-
) );
|
341 |
-
|
342 |
-
// Select conditions
|
343 |
-
$select_sql = "SELECT DISTINCT a.id";
|
344 |
-
|
345 |
-
$from_sql = " FROM {$bp->activity->table_name} a";
|
346 |
-
|
347 |
-
$join_sql = '';
|
348 |
-
|
349 |
-
// Where conditions
|
350 |
-
$where_conditions = array();
|
351 |
-
|
352 |
-
// Excluded types
|
353 |
-
$excluded_types = array();
|
354 |
-
|
355 |
-
// Scope takes precedence
|
356 |
-
if ( ! empty( $r['scope'] ) ) {
|
357 |
-
$scope_query = self::get_scope_query_sql( $r['scope'], $r );
|
358 |
-
|
359 |
-
// Add our SQL conditions if matches were found
|
360 |
-
if ( ! empty( $scope_query['sql'] ) ) {
|
361 |
-
$where_conditions['scope_query_sql'] = $scope_query['sql'];
|
362 |
-
}
|
363 |
-
|
364 |
-
// override some arguments if needed
|
365 |
-
if ( ! empty( $scope_query['override'] ) ) {
|
366 |
-
$r = self::array_replace_recursive( $r, $scope_query['override'] );
|
367 |
-
}
|
368 |
-
|
369 |
-
// Advanced filtering
|
370 |
-
} elseif ( ! empty( $r['filter_query'] ) ) {
|
371 |
-
$filter_query = new BP_Activity_Query( $r['filter_query'] );
|
372 |
-
$sql = $filter_query->get_sql();
|
373 |
-
if ( ! empty( $sql ) ) {
|
374 |
-
$where_conditions['filter_query_sql'] = $sql;
|
375 |
-
}
|
376 |
-
}
|
377 |
-
|
378 |
-
// Regular filtering
|
379 |
-
if ( $r['filter'] && $filter_sql = BP_Activity_Activity::get_filter_sql( $r['filter'] ) ) {
|
380 |
-
$where_conditions['filter_sql'] = $filter_sql;
|
381 |
-
}
|
382 |
-
|
383 |
-
// Spam
|
384 |
-
if ( 'ham_only' == $r['spam'] ) {
|
385 |
-
$where_conditions['spam_sql'] = 'a.is_spam = 0';
|
386 |
-
} elseif ( 'spam_only' == $r['spam'] ) {
|
387 |
-
$where_conditions['spam_sql'] = 'a.is_spam = 1';
|
388 |
-
}
|
389 |
-
|
390 |
-
// Searching
|
391 |
-
if ( $r['search_terms'] ) {
|
392 |
-
$search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
|
393 |
-
$where_conditions['search_sql'] = $wpdb->prepare( 'a.content LIKE %s', $search_terms_like );
|
394 |
-
}
|
395 |
-
|
396 |
-
// Sorting
|
397 |
-
$sort = $r['sort'];
|
398 |
-
if ( $sort != 'ASC' && $sort != 'DESC' ) {
|
399 |
-
$sort = 'DESC';
|
400 |
-
}
|
401 |
-
|
402 |
-
// Hide Hidden Items?
|
403 |
-
if ( ! $r['show_hidden'] ) {
|
404 |
-
$where_conditions['hidden_sql'] = "a.hide_sitewide = 0";
|
405 |
-
}
|
406 |
-
|
407 |
-
// Exclude specified items
|
408 |
-
if ( ! empty( $r['exclude'] ) ) {
|
409 |
-
$exclude = implode( ',', wp_parse_id_list( $r['exclude'] ) );
|
410 |
-
$where_conditions['exclude'] = "a.id NOT IN ({$exclude})";
|
411 |
-
}
|
412 |
-
|
413 |
-
// The specific ids to which you want to limit the query
|
414 |
-
if ( ! empty( $r['in'] ) ) {
|
415 |
-
$in = implode( ',', wp_parse_id_list( $r['in'] ) );
|
416 |
-
$where_conditions['in'] = "a.id IN ({$in})";
|
417 |
-
}
|
418 |
-
|
419 |
-
// Process meta_query into SQL
|
420 |
-
$meta_query_sql = self::get_meta_query_sql( $r['meta_query'] );
|
421 |
-
|
422 |
-
if ( ! empty( $meta_query_sql['join'] ) ) {
|
423 |
-
$join_sql .= $meta_query_sql['join'];
|
424 |
-
}
|
425 |
-
|
426 |
-
if ( ! empty( $meta_query_sql['where'] ) ) {
|
427 |
-
$where_conditions[] = $meta_query_sql['where'];
|
428 |
-
}
|
429 |
-
|
430 |
-
// Process date_query into SQL
|
431 |
-
$date_query_sql = self::get_date_query_sql( $r['date_query'] );
|
432 |
-
|
433 |
-
if ( ! empty( $date_query_sql ) ) {
|
434 |
-
$where_conditions['date'] = $date_query_sql;
|
435 |
-
}
|
436 |
-
|
437 |
-
// Alter the query based on whether we want to show activity item
|
438 |
-
// comments in the stream like normal comments or threaded below
|
439 |
-
// the activity.
|
440 |
-
if ( false === $r['display_comments'] || 'threaded' === $r['display_comments'] ) {
|
441 |
-
$excluded_types[] = 'activity_comment';
|
442 |
-
}
|
443 |
-
|
444 |
-
// Exclude 'last_activity' items unless the 'action' filter has
|
445 |
-
// been explicitly set
|
446 |
-
if ( empty( $r['filter']['object'] ) ) {
|
447 |
-
$excluded_types[] = 'last_activity';
|
448 |
-
}
|
449 |
-
|
450 |
-
// Build the excluded type sql part
|
451 |
-
if ( ! empty( $excluded_types ) ) {
|
452 |
-
$not_in = "'" . implode( "', '", esc_sql( $excluded_types ) ) . "'";
|
453 |
-
$where_conditions['excluded_types'] = "a.type NOT IN ({$not_in})";
|
454 |
-
}
|
455 |
-
|
456 |
-
/**
|
457 |
-
* Filters the MySQL WHERE conditions for the Activity items get method.
|
458 |
-
*
|
459 |
-
* @since BuddyPress (1.9.0)
|
460 |
-
*
|
461 |
-
* @param array $where_conditions Current conditions for MySQL WHERE statement.
|
462 |
-
* @param array $r Parsed arguments passed into method.
|
463 |
-
* @param string $select_sql Current SELECT MySQL statement at point of execution.
|
464 |
-
* @param string $from_sql Current FROM MySQL statement at point of execution.
|
465 |
-
* @param string $join_sql Current INNER JOIN MySQL statement at point of execution.
|
466 |
-
*/
|
467 |
-
$where_conditions = apply_filters( 'bp_activity_get_where_conditions', $where_conditions, $r, $select_sql, $from_sql, $join_sql );
|
468 |
-
|
469 |
-
// Join the where conditions together
|
470 |
-
$where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
|
471 |
-
|
472 |
-
/**
|
473 |
-
* Filters the preferred order of indexes for activity item.
|
474 |
-
*
|
475 |
-
* @since BuddyPress (1.6.0)
|
476 |
-
*
|
477 |
-
* @param array Array of indexes in preferred order.
|
478 |
-
*/
|
479 |
-
$indexes = apply_filters( 'bp_activity_preferred_index_order', array( 'user_id', 'item_id', 'secondary_item_id', 'date_recorded', 'component', 'type', 'hide_sitewide', 'is_spam' ) );
|
480 |
-
|
481 |
-
foreach( $indexes as $key => $index ) {
|
482 |
-
if ( false !== strpos( $where_sql, $index ) ) {
|
483 |
-
$the_index = $index;
|
484 |
-
break; // Take the first one we find
|
485 |
-
}
|
486 |
-
}
|
487 |
-
|
488 |
-
if ( !empty( $the_index ) ) {
|
489 |
-
$index_hint_sql = "USE INDEX ({$the_index})";
|
490 |
-
} else {
|
491 |
-
$index_hint_sql = '';
|
492 |
-
}
|
493 |
-
|
494 |
-
// Sanitize page and per_page parameters
|
495 |
-
$page = absint( $r['page'] );
|
496 |
-
$per_page = absint( $r['per_page'] );
|
497 |
-
|
498 |
-
$retval = array(
|
499 |
-
'activities' => null,
|
500 |
-
'total' => null,
|
501 |
-
'has_more_items' => null,
|
502 |
-
);
|
503 |
-
|
504 |
-
/**
|
505 |
-
* Filters if BuddyPress should use legacy query structure over current structure for version 2.0+.
|
506 |
-
*
|
507 |
-
* It is not recommended to use the legacy structure, but allowed to if needed.
|
508 |
-
*
|
509 |
-
* @since BuddyPress (2.0.0)
|
510 |
-
*
|
511 |
-
* @param bool Whether to use legacy structure or not.
|
512 |
-
* @param BP_Activity_Activity Current method being called.
|
513 |
-
* @param array $r Parsed arguments passed into method.
|
514 |
-
*/
|
515 |
-
if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) {
|
516 |
-
|
517 |
-
// Legacy queries joined against the user table
|
518 |
-
$select_sql = "SELECT DISTINCT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
|
519 |
-
$from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
|
520 |
-
|
521 |
-
if ( ! empty( $page ) && ! empty( $per_page ) ) {
|
522 |
-
$pag_sql = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
|
523 |
-
|
524 |
-
/** this filter is documented in bp-activity/bp-activity-classes.php */
|
525 |
-
$activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
|
526 |
-
} else {
|
527 |
-
$pag_sql = '';
|
528 |
-
|
529 |
-
/**
|
530 |
-
* Filters the legacy MySQL query statement so plugins can alter before results are fetched.
|
531 |
-
*
|
532 |
-
* @since BuddyPress (1.5.0)
|
533 |
-
*
|
534 |
-
* @param string Concatenated MySQL statement pieces to be query results with for legacy query.
|
535 |
-
* @param string $select_sql Final SELECT MySQL statement portion for legacy query.
|
536 |
-
* @param string $from_sql Final FROM MySQL statement portion for legacy query.
|
537 |
-
* @param string $where_sql Final WHERE MySQL statement portion for legacy query.
|
538 |
-
* @param string $sort Final sort direction for legacy query.
|
539 |
-
*/
|
540 |
-
$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}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
|
541 |
-
}
|
542 |
-
|
543 |
-
} else {
|
544 |
-
// Query first for activity IDs
|
545 |
-
$activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
|
546 |
-
|
547 |
-
if ( ! empty( $per_page ) && ! empty( $page ) ) {
|
548 |
-
// We query for $per_page + 1 items in order to
|
549 |
-
// populate the has_more_items flag
|
550 |
-
$activity_ids_sql .= $wpdb->prepare( " LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page + 1 );
|
551 |
-
}
|
552 |
-
|
553 |
-
/**
|
554 |
-
* Filters the paged activities MySQL statement.
|
555 |
-
*
|
556 |
-
* @since BuddyPress (2.0.0)
|
557 |
-
*
|
558 |
-
* @param string $activity_ids_sql MySQL statement used to query for Activity IDs.
|
559 |
-
* @param array $r Array of arguments passed into method.
|
560 |
-
*/
|
561 |
-
$activity_ids_sql = apply_filters( 'bp_activity_paged_activities_sql', $activity_ids_sql, $r );
|
562 |
-
|
563 |
-
$activity_ids = $wpdb->get_col( $activity_ids_sql );
|
564 |
-
|
565 |
-
$retval['has_more_items'] = ! empty( $per_page ) && count( $activity_ids ) > $per_page;
|
566 |
-
|
567 |
-
// If we've fetched more than the $per_page value, we
|
568 |
-
// can discard the extra now
|
569 |
-
if ( ! empty( $per_page ) && count( $activity_ids ) === $per_page + 1 ) {
|
570 |
-
array_pop( $activity_ids );
|
571 |
-
}
|
572 |
-
|
573 |
-
$activities = self::get_activity_data( $activity_ids );
|
574 |
-
}
|
575 |
-
|
576 |
-
// Get the fullnames of users so we don't have to query in the loop
|
577 |
-
$activities = self::append_user_fullnames( $activities );
|
578 |
-
|
579 |
-
// Get activity meta
|
580 |
-
$activity_ids = array();
|
581 |
-
foreach ( (array) $activities as $activity ) {
|
582 |
-
$activity_ids[] = $activity->id;
|
583 |
-
}
|
584 |
-
|
585 |
-
if ( ! empty( $activity_ids ) && $r['update_meta_cache'] ) {
|
586 |
-
bp_activity_update_meta_cache( $activity_ids );
|
587 |
-
}
|
588 |
-
|
589 |
-
if ( $activities && $r['display_comments'] ) {
|
590 |
-
$activities = BP_Activity_Activity::append_comments( $activities, $r['spam'] );
|
591 |
-
}
|
592 |
-
|
593 |
-
// Pre-fetch data associated with activity users and other objects
|
594 |
-
BP_Activity_Activity::prefetch_object_data( $activities );
|
595 |
-
|
596 |
-
// Generate action strings
|
597 |
-
$activities = BP_Activity_Activity::generate_action_strings( $activities );
|
598 |
-
|
599 |
-
$retval['activities'] = $activities;
|
600 |
-
|
601 |
-
// If $max is set, only return up to the max results
|
602 |
-
if ( ! empty( $r['count_total'] ) ) {
|
603 |
-
|
604 |
-
/**
|
605 |
-
* Filters the total activities MySQL statement.
|
606 |
-
*
|
607 |
-
* @since BuddyPress (1.5.0)
|
608 |
-
*
|
609 |
-
* @param string MySQL statement used to query for total activities.
|
610 |
-
* @param string $where_sql MySQL WHERE statement portion.
|
611 |
-
* @param string $sort sort direction for query.
|
612 |
-
*/
|
613 |
-
$total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort );
|
614 |
-
$total_activities = $wpdb->get_var( $total_activities_sql );
|
615 |
-
|
616 |
-
if ( !empty( $r['max'] ) ) {
|
617 |
-
if ( (int) $total_activities > (int) $r['max'] ) {
|
618 |
-
$total_activities = $r['max'];
|
619 |
-
}
|
620 |
-
}
|
621 |
-
|
622 |
-
$retval['total'] = $total_activities;
|
623 |
-
}
|
624 |
-
|
625 |
-
return $retval;
|
626 |
-
}
|
627 |
-
|
628 |
-
/**
|
629 |
-
* Convert activity IDs to activity objects, as expected in template loop.
|
630 |
-
*
|
631 |
-
* @since 2.0
|
632 |
-
*
|
633 |
-
* @param array $activity_ids Array of activity IDs.
|
634 |
-
* @return array
|
635 |
-
*/
|
636 |
-
protected static function get_activity_data( $activity_ids = array() ) {
|
637 |
-
global $wpdb;
|
638 |
-
|
639 |
-
// Bail if no activity ID's passed
|
640 |
-
if ( empty( $activity_ids ) ) {
|
641 |
-
return array();
|
642 |
-
}
|
643 |
-
|
644 |
-
// Get BuddyPress
|
645 |
-
$bp = buddypress();
|
646 |
-
|
647 |
-
$activities = array();
|
648 |
-
$uncached_ids = bp_get_non_cached_ids( $activity_ids, 'bp_activity' );
|
649 |
-
|
650 |
-
// Prime caches as necessary
|
651 |
-
if ( ! empty( $uncached_ids ) ) {
|
652 |
-
// Format the activity ID's for use in the query below
|
653 |
-
$uncached_ids_sql = implode( ',', wp_parse_id_list( $uncached_ids ) );
|
654 |
-
|
655 |
-
// Fetch data from activity table, preserving order
|
656 |
-
$queried_adata = $wpdb->get_results( "SELECT * FROM {$bp->activity->table_name} WHERE id IN ({$uncached_ids_sql})");
|
657 |
-
|
658 |
-
// Put that data into the placeholders created earlier,
|
659 |
-
// and add it to the cache
|
660 |
-
foreach ( (array) $queried_adata as $adata ) {
|
661 |
-
wp_cache_set( $adata->id, $adata, 'bp_activity' );
|
662 |
-
}
|
663 |
-
}
|
664 |
-
|
665 |
-
// Now fetch data from the cache
|
666 |
-
foreach ( $activity_ids as $activity_id ) {
|
667 |
-
$activities[] = wp_cache_get( $activity_id, 'bp_activity' );
|
668 |
-
}
|
669 |
-
|
670 |
-
// Then fetch user data
|
671 |
-
$user_query = new BP_User_Query( array(
|
672 |
-
'user_ids' => wp_list_pluck( $activities, 'user_id' ),
|
673 |
-
'populate_extras' => false,
|
674 |
-
) );
|
675 |
-
|
676 |
-
// Associated located user data with activity items
|
677 |
-
foreach ( $activities as $a_index => $a_item ) {
|
678 |
-
$a_user_id = intval( $a_item->user_id );
|
679 |
-
$a_user = isset( $user_query->results[ $a_user_id ] ) ? $user_query->results[ $a_user_id ] : '';
|
680 |
-
|
681 |
-
if ( !empty( $a_user ) ) {
|
682 |
-
$activities[ $a_index ]->user_email = $a_user->user_email;
|
683 |
-
$activities[ $a_index ]->user_nicename = $a_user->user_nicename;
|
684 |
-
$activities[ $a_index ]->user_login = $a_user->user_login;
|
685 |
-
$activities[ $a_index ]->display_name = $a_user->display_name;
|
686 |
-
}
|
687 |
-
}
|
688 |
-
|
689 |
-
return $activities;
|
690 |
-
}
|
691 |
-
|
692 |
-
/**
|
693 |
-
* Append xProfile fullnames to an activity array.
|
694 |
-
*
|
695 |
-
* @since BuddyPress (2.0.0)
|
696 |
-
*
|
697 |
-
* @param array $activities Activities array.
|
698 |
-
* @return array
|
699 |
-
*/
|
700 |
-
protected static function append_user_fullnames( $activities ) {
|
701 |
-
|
702 |
-
if ( bp_is_active( 'xprofile' ) && ! empty( $activities ) ) {
|
703 |
-
$activity_user_ids = wp_list_pluck( $activities, 'user_id' );
|
704 |
-
|
705 |
-
if ( ! empty( $activity_user_ids ) ) {
|
706 |
-
$fullnames = bp_core_get_user_displaynames( $activity_user_ids );
|
707 |
-
if ( ! empty( $fullnames ) ) {
|
708 |
-
foreach ( (array) $activities as $i => $activity ) {
|
709 |
-
if ( ! empty( $fullnames[ $activity->user_id ] ) ) {
|
710 |
-
$activities[ $i ]->user_fullname = $fullnames[ $activity->user_id ];
|
711 |
-
}
|
712 |
-
}
|
713 |
-
}
|
714 |
-
}
|
715 |
-
}
|
716 |
-
|
717 |
-
return $activities;
|
718 |
-
}
|
719 |
-
|
720 |
-
/**
|
721 |
-
* Pre-fetch data for objects associated with activity items.
|
722 |
-
*
|
723 |
-
* Activity items are associated with users, and often with other
|
724 |
-
* BuddyPress data objects. Here, we pre-fetch data about these
|
725 |
-
* associated objects, so that inline lookups - done primarily when
|
726 |
-
* building action strings - do not result in excess database queries.
|
727 |
-
*
|
728 |
-
* The only object data required for activity component activity types
|
729 |
-
* (activity_update and activity_comment) is related to users, and that
|
730 |
-
* info is fetched separately in BP_Activity_Activity::get_activity_data().
|
731 |
-
* So this method contains nothing but a filter that allows other
|
732 |
-
* components, such as bp-friends and bp-groups, to hook in and prime
|
733 |
-
* their own caches at the beginning of an activity loop.
|
734 |
-
*
|
735 |
-
* @since BuddyPress (2.0.0)
|
736 |
-
*
|
737 |
-
* @param array $activities Array of activities.
|
738 |
-
*/
|
739 |
-
protected static function prefetch_object_data( $activities ) {
|
740 |
-
|
741 |
-
/**
|
742 |
-
* Filters inside prefetch_object_data method to aid in pre-fetching object data associated with activity item.
|
743 |
-
*
|
744 |
-
* @since BuddyPress (2.0.0)
|
745 |
-
*
|
746 |
-
* @param array $activities Array of activities.
|
747 |
-
*/
|
748 |
-
return apply_filters( 'bp_activity_prefetch_object_data', $activities );
|
749 |
-
}
|
750 |
-
|
751 |
-
/**
|
752 |
-
* Generate action strings for the activities located in BP_Activity_Activity::get().
|
753 |
-
*
|
754 |
-
* If no string can be dynamically generated for a given item
|
755 |
-
* (typically because the activity type has not been properly
|
756 |
-
* registered), the static 'action' value pulled from the database will
|
757 |
-
* be left in place.
|
758 |
-
*
|
759 |
-
* @since BuddyPress (2.0.0)
|
760 |
-
*
|
761 |
-
* @param array $activities Array of activities.
|
762 |
-
* @return array
|
763 |
-
*/
|
764 |
-
protected static function generate_action_strings( $activities ) {
|
765 |
-
foreach ( $activities as $key => $activity ) {
|
766 |
-
$generated_action = bp_activity_generate_action_string( $activity );
|
767 |
-
if ( false !== $generated_action ) {
|
768 |
-
$activity->action = $generated_action;
|
769 |
-
}
|
770 |
-
|
771 |
-
$activities[ $key ] = $activity;
|
772 |
-
}
|
773 |
-
|
774 |
-
return $activities;
|
775 |
-
}
|
776 |
-
|
777 |
-
/**
|
778 |
-
* Get the SQL for the 'meta_query' param in BP_Activity_Activity::get().
|
779 |
-
*
|
780 |
-
* We use WP_Meta_Query to do the heavy lifting of parsing the
|
781 |
-
* meta_query array and creating the necessary SQL clauses. However,
|
782 |
-
* since BP_Activity_Activity::get() builds its SQL differently than
|
783 |
-
* WP_Query, we have to alter the return value (stripping the leading
|
784 |
-
* AND keyword from the 'where' clause).
|
785 |
-
*
|
786 |
-
* @since BuddyPress (1.8)
|
787 |
-
*
|
788 |
-
* @param array $meta_query An array of meta_query filters. See the
|
789 |
-
* documentation for WP_Meta_Query for details.
|
790 |
-
* @return array $sql_array 'join' and 'where' clauses.
|
791 |
-
*/
|
792 |
-
public static function get_meta_query_sql( $meta_query = array() ) {
|
793 |
-
global $wpdb;
|
794 |
-
|
795 |
-
$sql_array = array(
|
796 |
-
'join' => '',
|
797 |
-
'where' => '',
|
798 |
-
);
|
799 |
-
|
800 |
-
if ( ! empty( $meta_query ) ) {
|
801 |
-
$activity_meta_query = new WP_Meta_Query( $meta_query );
|
802 |
-
|
803 |
-
// WP_Meta_Query expects the table name at
|
804 |
-
// $wpdb->activitymeta
|
805 |
-
$wpdb->activitymeta = buddypress()->activity->table_name_meta;
|
806 |
-
|
807 |
-
$meta_sql = $activity_meta_query->get_sql( 'activity', 'a', 'id' );
|
808 |
-
|
809 |
-
// Strip the leading AND - BP handles it in get()
|
810 |
-
$sql_array['where'] = preg_replace( '/^\sAND/', '', $meta_sql['where'] );
|
811 |
-
$sql_array['join'] = $meta_sql['join'];
|
812 |
-
}
|
813 |
-
|
814 |
-
return $sql_array;
|
815 |
-
}
|
816 |
-
|
817 |
-
/**
|
818 |
-
* Get the SQL for the 'date_query' param in BP_Activity_Activity::get().
|
819 |
-
*
|
820 |
-
* We use BP_Date_Query, which extends WP_Date_Query, to do the heavy lifting
|
821 |
-
* of parsing the date_query array and creating the necessary SQL clauses.
|
822 |
-
* However, since BP_Activity_Activity::get() builds its SQL differently than
|
823 |
-
* WP_Query, we have to alter the return value (stripping the leading AND
|
824 |
-
* keyword from the query).
|
825 |
-
*
|
826 |
-
* @since BuddyPress (2.1.0)
|
827 |
-
*
|
828 |
-
* @param array $date_query An array of date_query parameters. See the
|
829 |
-
* documentation for the first parameter of WP_Date_Query.
|
830 |
-
* @return string
|
831 |
-
*/
|
832 |
-
public static function get_date_query_sql( $date_query = array() ) {
|
833 |
-
$sql = '';
|
834 |
-
|
835 |
-
// Date query
|
836 |
-
if ( ! empty( $date_query ) && is_array( $date_query ) && class_exists( 'BP_Date_Query' ) ) {
|
837 |
-
$date_query = new BP_Date_Query( $date_query, 'date_recorded' );
|
838 |
-
$sql = preg_replace( '/^\sAND/', '', $date_query->get_sql() );
|
839 |
-
}
|
840 |
-
|
841 |
-
return $sql;
|
842 |
-
}
|
843 |
-
|
844 |
-
/**
|
845 |
-
* Get the SQL for the 'scope' param in BP_Activity_Activity::get().
|
846 |
-
*
|
847 |
-
* A scope is a predetermined set of activity arguments. This method is used
|
848 |
-
* to grab these activity arguments and override any existing args if needed.
|
849 |
-
*
|
850 |
-
* Can handle multiple scopes.
|
851 |
-
*
|
852 |
-
* @since BuddyPress (2.2.0)
|
853 |
-
*
|
854 |
-
* @param mixed $scope The activity scope. Accepts string or array of scopes
|
855 |
-
* @param array $r Current activity arguments. Same as those of BP_Activity_Activity::get(),
|
856 |
-
* but merged with defaults.
|
857 |
-
* @return array 'sql' WHERE SQL string and 'override' activity args
|
858 |
-
*/
|
859 |
-
public static function get_scope_query_sql( $scope = false, $r = array() ) {
|
860 |
-
|
861 |
-
// Define arrays for future use
|
862 |
-
$query_args = array();
|
863 |
-
$override = array();
|
864 |
-
$retval = array();
|
865 |
-
|
866 |
-
// Check for array of scopes
|
867 |
-
if ( is_array( $scope ) ) {
|
868 |
-
$scopes = $scope;
|
869 |
-
|
870 |
-
// Explode a comma separated string of scopes
|
871 |
-
} elseif ( is_string( $scope ) ) {
|
872 |
-
$scopes = explode( ',', $scope );
|
873 |
-
}
|
874 |
-
|
875 |
-
// Bail if no scope passed
|
876 |
-
if ( empty( $scopes ) ) {
|
877 |
-
return false;
|
878 |
-
}
|
879 |
-
|
880 |
-
// Helper to easily grab the 'user_id'
|
881 |
-
if ( ! empty( $r['filter']['user_id'] ) ) {
|
882 |
-
$r['user_id'] = $r['filter']['user_id'];
|
883 |
-
}
|
884 |
-
|
885 |
-
// parse each scope; yes! we handle multiples!
|
886 |
-
foreach ( $scopes as $scope ) {
|
887 |
-
$scope_args = array();
|
888 |
-
|
889 |
-
/**
|
890 |
-
* Plugins can hook here to set their activity arguments for custom scopes.
|
891 |
-
*
|
892 |
-
* This is a dynamic filter based on the activity scope. eg:
|
893 |
-
* - 'bp_activity_set_groups_scope_args'
|
894 |
-
* - 'bp_activity_set_friends_scope_args'
|
895 |
-
*
|
896 |
-
* To see how this filter is used, plugin devs should check out:
|
897 |
-
* - bp_groups_filter_activity_scope() - used for 'groups' scope
|
898 |
-
* - bp_friends_filter_activity_scope() - used for 'friends' scope
|
899 |
-
*
|
900 |
-
* @since BuddyPress (2.2.0)
|
901 |
-
*
|
902 |
-
* @param array {
|
903 |
-
* Activity query clauses.
|
904 |
-
*
|
905 |
-
* @type array {
|
906 |
-
* Activity arguments for your custom scope.
|
907 |
-
* See {@link BP_Activity_Query::_construct()} for more details.
|
908 |
-
* }
|
909 |
-
* @type array $override Optional. Override existing activity arguments passed by $r.
|
910 |
-
* }
|
911 |
-
* @param array $r Current activity arguments passed in BP_Activity_Activity::get()
|
912 |
-
*/
|
913 |
-
$scope_args = apply_filters( "bp_activity_set_{$scope}_scope_args", array(), $r );
|
914 |
-
|
915 |
-
if ( ! empty( $scope_args ) ) {
|
916 |
-
// merge override properties from other scopes
|
917 |
-
// this might be a problem...
|
918 |
-
if ( ! empty( $scope_args['override'] ) ) {
|
919 |
-
$override = array_merge( $override, $scope_args['override'] );
|
920 |
-
unset( $scope_args['override'] );
|
921 |
-
}
|
922 |
-
|
923 |
-
// save scope args
|
924 |
-
if ( ! empty( $scope_args ) ) {
|
925 |
-
$query_args[] = $scope_args;
|
926 |
-
}
|
927 |
-
}
|
928 |
-
}
|
929 |
-
|
930 |
-
if ( ! empty( $query_args ) ) {
|
931 |
-
// set relation to OR
|
932 |
-
$query_args['relation'] = 'OR';
|
933 |
-
|
934 |
-
$query = new BP_Activity_Query( $query_args );
|
935 |
-
$sql = $query->get_sql();
|
936 |
-
if ( ! empty( $sql ) ) {
|
937 |
-
$retval['sql'] = $sql;
|
938 |
-
}
|
939 |
-
}
|
940 |
-
|
941 |
-
if ( ! empty( $override ) ) {
|
942 |
-
$retval['override'] = $override;
|
943 |
-
}
|
944 |
-
|
945 |
-
return $retval;
|
946 |
-
}
|
947 |
-
|
948 |
-
/**
|
949 |
-
* In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
|
950 |
-
*
|
951 |
-
* As of 1.5.x, use BP_Activity_Activity::get() with an 'in' parameter instead.
|
952 |
-
*
|
953 |
-
* @since BuddyPress (1.2)
|
954 |
-
*
|
955 |
-
* @deprecated 1.5
|
956 |
-
* @deprecated Use BP_Activity_Activity::get() with an 'in' parameter instead.
|
957 |
-
*
|
958 |
-
* @param mixed $activity_ids Array or comma-separated string of activity IDs to retrieve
|
959 |
-
* @param int $max Maximum number of results to return. (Optional; default is no maximum)
|
960 |
-
* @param int $page The set of results that the user is viewing. Used in pagination. (Optional; default is 1)
|
961 |
-
* @param int $per_page Specifies how many results per page. Used in pagination. (Optional; default is 25)
|
962 |
-
* @param string MySQL column sort; ASC or DESC. (Optional; default is DESC)
|
963 |
-
* @param bool $display_comments Retrieve an activity item's associated comments or not. (Optional; default is false)
|
964 |
-
* @return array
|
965 |
-
*/
|
966 |
-
public static function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) {
|
967 |
-
_deprecated_function( __FUNCTION__, '1.5', 'Use BP_Activity_Activity::get() with the "in" parameter instead.' );
|
968 |
-
return BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, false, false, $activity_ids );
|
969 |
-
}
|
970 |
-
|
971 |
-
/**
|
972 |
-
* Get the first activity ID that matches a set of criteria.
|
973 |
-
*
|
974 |
-
* @param int $user_id User ID to filter by
|
975 |
-
* @param string $component Component to filter by
|
976 |
-
* @param string $type Activity type to filter by
|
977 |
-
* @param int $item_id Associated item to filter by
|
978 |
-
* @param int $secondary_item_id Secondary associated item to filter by
|
979 |
-
* @param string $action Action to filter by
|
980 |
-
* @param string $content Content to filter by
|
981 |
-
* @param string $date_recorded Date to filter by
|
982 |
-
*
|
983 |
-
* @todo Should parameters be optional?
|
984 |
-
*
|
985 |
-
* @return int|bool Activity ID on success, false if none is found.
|
986 |
-
*/
|
987 |
-
public static function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded ) {
|
988 |
-
global $wpdb;
|
989 |
-
|
990 |
-
$bp = buddypress();
|
991 |
-
|
992 |
-
$where_args = false;
|
993 |
-
|
994 |
-
if ( ! empty( $user_id ) ) {
|
995 |
-
$where_args[] = $wpdb->prepare( "user_id = %d", $user_id );
|
996 |
-
}
|
997 |
-
|
998 |
-
if ( ! empty( $component ) ) {
|
999 |
-
$where_args[] = $wpdb->prepare( "component = %s", $component );
|
1000 |
-
}
|
1001 |
-
|
1002 |
-
if ( ! empty( $type ) ) {
|
1003 |
-
$where_args[] = $wpdb->prepare( "type = %s", $type );
|
1004 |
-
}
|
1005 |
-
|
1006 |
-
if ( ! empty( $item_id ) ) {
|
1007 |
-
$where_args[] = $wpdb->prepare( "item_id = %d", $item_id );
|
1008 |
-
}
|
1009 |
-
|
1010 |
-
if ( ! empty( $secondary_item_id ) ) {
|
1011 |
-
$where_args[] = $wpdb->prepare( "secondary_item_id = %d", $secondary_item_id );
|
1012 |
-
}
|
1013 |
-
|
1014 |
-
if ( ! empty( $action ) ) {
|
1015 |
-
$where_args[] = $wpdb->prepare( "action = %s", $action );
|
1016 |
-
}
|
1017 |
-
|
1018 |
-
if ( ! empty( $content ) ) {
|
1019 |
-
$where_args[] = $wpdb->prepare( "content = %s", $content );
|
1020 |
-
}
|
1021 |
-
|
1022 |
-
if ( ! empty( $date_recorded ) ) {
|
1023 |
-
$where_args[] = $wpdb->prepare( "date_recorded = %s", $date_recorded );
|
1024 |
-
}
|
1025 |
-
|
1026 |
-
if ( ! empty( $where_args ) ) {
|
1027 |
-
$where_sql = 'WHERE ' . join( ' AND ', $where_args );
|
1028 |
-
return $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
|
1029 |
-
}
|
1030 |
-
|
1031 |
-
return false;
|
1032 |
-
}
|
1033 |
-
|
1034 |
-
/**
|
1035 |
-
* Delete activity items from the database.
|
1036 |
-
*
|
1037 |
-
* To delete a specific activity item, pass an 'id' parameter.
|
1038 |
-
* Otherwise use the filters.
|
1039 |
-
*
|
1040 |
-
* @since BuddyPress (1.2)
|
1041 |
-
*
|
1042 |
-
* @param array $args {
|
1043 |
-
* @int $id Optional. The ID of a specific item to delete.
|
1044 |
-
* @string $action Optional. The action to filter by.
|
1045 |
-
* @string $content Optional. The content to filter by.
|
1046 |
-
* @string $component Optional. The component name to filter by.
|
1047 |
-
* @string $type Optional. The activity type to filter by.
|
1048 |
-
* @string $primary_link Optional. The primary URL to filter by.
|
1049 |
-
* @int $user_id Optional. The user ID to filter by.
|
1050 |
-
* @int $item_id Optional. The associated item ID to filter by.
|
1051 |
-
* @int $secondary_item_id Optional. The secondary associated item ID to filter by.
|
1052 |
-
* @string $date_recorded Optional. The date to filter by.
|
1053 |
-
* @int $hide_sitewide Optional. Default: false.
|
1054 |
-
* }
|
1055 |
-
* @return array|bool An array of deleted activity IDs on success, false on failure.
|
1056 |
-
*/
|
1057 |
-
public static function delete( $args = array() ) {
|
1058 |
-
global $wpdb;
|
1059 |
-
|
1060 |
-
$bp = buddypress();
|
1061 |
-
|
1062 |
-
$defaults = array(
|
1063 |
-
'id' => false,
|
1064 |
-
'action' => false,
|
1065 |
-
'content' => false,
|
1066 |
-
'component' => false,
|
1067 |
-
'type' => false,
|
1068 |
-
'primary_link' => false,
|
1069 |
-
'user_id' => false,
|
1070 |
-
'item_id' => false,
|
1071 |
-
'secondary_item_id' => false,
|
1072 |
-
'date_recorded' => false,
|
1073 |
-
'hide_sitewide' => false
|
1074 |
-
);
|
1075 |
-
$params = wp_parse_args( $args, $defaults );
|
1076 |
-
extract( $params );
|
1077 |
-
|
1078 |
-
$where_args = false;
|
1079 |
-
|
1080 |
-
if ( !empty( $id ) )
|
1081 |
-
$where_args[] = $wpdb->prepare( "id = %d", $id );
|
1082 |
-
|
1083 |
-
if ( !empty( $user_id ) )
|
1084 |
-
$where_args[] = $wpdb->prepare( "user_id = %d", $user_id );
|
1085 |
-
|
1086 |
-
if ( !empty( $action ) )
|
1087 |
-
$where_args[] = $wpdb->prepare( "action = %s", $action );
|
1088 |
-
|
1089 |
-
if ( !empty( $content ) )
|
1090 |
-
$where_args[] = $wpdb->prepare( "content = %s", $content );
|
1091 |
-
|
1092 |
-
if ( !empty( $component ) )
|
1093 |
-
$where_args[] = $wpdb->prepare( "component = %s", $component );
|
1094 |
-
|
1095 |
-
if ( !empty( $type ) )
|
1096 |
-
$where_args[] = $wpdb->prepare( "type = %s", $type );
|
1097 |
-
|
1098 |
-
if ( !empty( $primary_link ) )
|
1099 |
-
$where_args[] = $wpdb->prepare( "primary_link = %s", $primary_link );
|
1100 |
-
|
1101 |
-
if ( !empty( $item_id ) )
|
1102 |
-
$where_args[] = $wpdb->prepare( "item_id = %d", $item_id );
|
1103 |
-
|
1104 |
-
if ( !empty( $secondary_item_id ) )
|
1105 |
-
$where_args[] = $wpdb->prepare( "secondary_item_id = %d", $secondary_item_id );
|
1106 |
-
|
1107 |
-
if ( !empty( $date_recorded ) )
|
1108 |
-
$where_args[] = $wpdb->prepare( "date_recorded = %s", $date_recorded );
|
1109 |
-
|
1110 |
-
if ( !empty( $hide_sitewide ) )
|
1111 |
-
$where_args[] = $wpdb->prepare( "hide_sitewide = %d", $hide_sitewide );
|
1112 |
-
|
1113 |
-
if ( !empty( $where_args ) )
|
1114 |
-
$where_sql = 'WHERE ' . join( ' AND ', $where_args );
|
1115 |
-
else
|
1116 |
-
return false;
|
1117 |
-
|
1118 |
-
// Fetch the activity IDs so we can delete any comments for this activity item
|
1119 |
-
$activity_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
|
1120 |
-
|
1121 |
-
if ( ! $wpdb->query( "DELETE FROM {$bp->activity->table_name} {$where_sql}" ) ) {
|
1122 |
-
return false;
|
1123 |
-
}
|
1124 |
-
|
1125 |
-
// Handle accompanying activity comments and meta deletion
|
1126 |
-
if ( $activity_ids ) {
|
1127 |
-
$activity_ids_comma = implode( ',', wp_parse_id_list( $activity_ids ) );
|
1128 |
-
$activity_comments_where_sql = "WHERE type = 'activity_comment' AND item_id IN ({$activity_ids_comma})";
|
1129 |
-
|
1130 |
-
// Fetch the activity comment IDs for our deleted activity items
|
1131 |
-
$activity_comment_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} {$activity_comments_where_sql}" );
|
1132 |
-
|
1133 |
-
// We have activity comments!
|
1134 |
-
if ( ! empty( $activity_comment_ids ) ) {
|
1135 |
-
// Delete activity comments
|
1136 |
-
$wpdb->query( "DELETE FROM {$bp->activity->table_name} {$activity_comments_where_sql}" );
|
1137 |
-
|
1138 |
-
// Merge activity IDs with activity comment IDs
|
1139 |
-
$activity_ids = array_merge( $activity_ids, $activity_comment_ids );
|
1140 |
-
}
|
1141 |
-
|
1142 |
-
// Delete all activity meta entries for activity items and activity comments
|
1143 |
-
BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
|
1144 |
-
}
|
1145 |
-
|
1146 |
-
return $activity_ids;
|
1147 |
-
}
|
1148 |
-
|
1149 |
-
/**
|
1150 |
-
* Delete the comments associated with a set of activity items.
|
1151 |
-
*
|
1152 |
-
* @since BuddyPress (1.2)
|
1153 |
-
*
|
1154 |
-
* @todo Mark as deprecated? Method is no longer used internally.
|
1155 |
-
*
|
1156 |
-
* @param array $activity_ids Activity IDs whose comments should be deleted.
|
1157 |
-
* @param bool $delete_meta Should we delete the activity meta items for these comments?
|
1158 |
-
* @return bool True on success.
|
1159 |
-
*/
|
1160 |
-
public static function delete_activity_item_comments( $activity_ids = array(), $delete_meta = true ) {
|
1161 |
-
global $wpdb;
|
1162 |
-
|
1163 |
-
$bp = buddypress();
|
1164 |
-
|
1165 |
-
$delete_meta = (bool) $delete_meta;
|
1166 |
-
$activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) );
|
1167 |
-
|
1168 |
-
if ( $delete_meta ) {
|
1169 |
-
// Fetch the activity comment IDs for our deleted activity items
|
1170 |
-
$activity_comment_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
|
1171 |
-
|
1172 |
-
if ( ! empty( $activity_comment_ids ) ) {
|
1173 |
-
self::delete_activity_meta_entries( $activity_comment_ids );
|
1174 |
-
}
|
1175 |
-
}
|
1176 |
-
|
1177 |
-
return $wpdb->query( "DELETE FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
|
1178 |
-
}
|
1179 |
-
|
1180 |
-
/**
|
1181 |
-
* Delete the meta entries associated with a set of activity items.
|
1182 |
-
*
|
1183 |
-
* @since BuddyPress (1.2)
|
1184 |
-
*
|
1185 |
-
* @param array $activity_ids Activity IDs whose meta should be deleted.
|
1186 |
-
* @return bool True on success.
|
1187 |
-
*/
|
1188 |
-
public static function delete_activity_meta_entries( $activity_ids = array() ) {
|
1189 |
-
$activity_ids = wp_parse_id_list( $activity_ids );
|
1190 |
-
|
1191 |
-
foreach ( $activity_ids as $activity_id ) {
|
1192 |
-
bp_activity_delete_meta( $activity_id );
|
1193 |
-
}
|
1194 |
-
|
1195 |
-
return true;
|
1196 |
-
}
|
1197 |
-
|
1198 |
-
/**
|
1199 |
-
* Append activity comments to their associated activity items.
|
1200 |
-
*
|
1201 |
-
* @since BuddyPress (1.2)
|
1202 |
-
*
|
1203 |
-
* @global wpdb $wpdb WordPress database object
|
1204 |
-
*
|
1205 |
-
* @param array $activities Activities to fetch comments for.
|
1206 |
-
* @param bool $spam Optional. 'ham_only' (default), 'spam_only' or 'all'.
|
1207 |
-
* @return array The updated activities with nested comments.
|
1208 |
-
*/
|
1209 |
-
public static function append_comments( $activities, $spam = 'ham_only' ) {
|
1210 |
-
$activity_comments = array();
|
1211 |
-
|
1212 |
-
// Now fetch the activity comments and parse them into the correct position in the activities array.
|
1213 |
-
foreach ( (array) $activities as $activity ) {
|
1214 |
-
$top_level_parent_id = 'activity_comment' == $activity->type ? $activity->item_id : 0;
|
1215 |
-
$activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $spam, $top_level_parent_id );
|
1216 |
-
}
|
1217 |
-
|
1218 |
-
// Merge the comments with the activity items
|
1219 |
-
foreach ( (array) $activities as $key => $activity ) {
|
1220 |
-
if ( isset( $activity_comments[$activity->id] ) ) {
|
1221 |
-
$activities[$key]->children = $activity_comments[$activity->id];
|
1222 |
-
}
|
1223 |
-
}
|
1224 |
-
|
1225 |
-
return $activities;
|
1226 |
-
}
|
1227 |
-
|
1228 |
-
/**
|
1229 |
-
* Get activity comments that are associated with a specific activity ID.
|
1230 |
-
*
|
1231 |
-
* @since BuddyPress (1.2)
|
1232 |
-
*
|
1233 |
-
* @global wpdb $wpdb WordPress database object.
|
1234 |
-
*
|
1235 |
-
* @param int $activity_id Activity ID to fetch comments for.
|
1236 |
-
* @param int $left Left-most node boundary.
|
1237 |
-
* @param into $right Right-most node boundary.
|
1238 |
-
* @param bool $spam Optional. 'ham_only' (default), 'spam_only' or 'all'.
|
1239 |
-
* @param int $top_level_parent_id Optional. The id of the root-level parent activity item.
|
1240 |
-
* @return array The updated activities with nested comments.
|
1241 |
-
*/
|
1242 |
-
public static function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
|
1243 |
-
global $wpdb;
|
1244 |
-
|
1245 |
-
if ( empty( $top_level_parent_id ) ) {
|
1246 |
-
$top_level_parent_id = $activity_id;
|
1247 |
-
}
|
1248 |
-
|
1249 |
-
$comments = wp_cache_get( $activity_id, 'bp_activity_comments' );
|
1250 |
-
|
1251 |
-
// We store the string 'none' to cache the fact that the
|
1252 |
-
// activity item has no comments
|
1253 |
-
if ( 'none' === $comments ) {
|
1254 |
-
$comments = false;
|
1255 |
-
|
1256 |
-
// A true cache miss
|
1257 |
-
} elseif ( empty( $comments ) ) {
|
1258 |
-
|
1259 |
-
$bp = buddypress();
|
1260 |
-
|
1261 |
-
// Select the user's fullname with the query
|
1262 |
-
if ( bp_is_active( 'xprofile' ) ) {
|
1263 |
-
$fullname_select = ", pd.value as user_fullname";
|
1264 |
-
$fullname_from = ", {$bp->profile->table_name_data} pd ";
|
1265 |
-
$fullname_where = "AND pd.user_id = a.user_id AND pd.field_id = 1";
|
1266 |
-
|
1267 |
-
// Prevent debug errors
|
1268 |
-
} else {
|
1269 |
-
$fullname_select = $fullname_from = $fullname_where = '';
|
1270 |
-
}
|
1271 |
-
|
1272 |
-
// Don't retrieve activity comments marked as spam
|
1273 |
-
if ( 'ham_only' == $spam ) {
|
1274 |
-
$spam_sql = 'AND a.is_spam = 0';
|
1275 |
-
} elseif ( 'spam_only' == $spam ) {
|
1276 |
-
$spam_sql = 'AND a.is_spam = 1';
|
1277 |
-
} else {
|
1278 |
-
$spam_sql = '';
|
1279 |
-
}
|
1280 |
-
|
1281 |
-
// Legacy query - not recommended
|
1282 |
-
$func_args = func_get_args();
|
1283 |
-
|
1284 |
-
/**
|
1285 |
-
* Filters if BuddyPress should use the legacy activity query.
|
1286 |
-
*
|
1287 |
-
* @since BuddyPress (2.0.0)
|
1288 |
-
*
|
1289 |
-
* @param bool Whether or not to use the legacy query.
|
1290 |
-
* @param BP_Activity_Activity Magic method referring to currently called method.
|
1291 |
-
* @param array $func_args Array of the method's argument list.
|
1292 |
-
*/
|
1293 |
-
if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $func_args ) ) {
|
1294 |
-
|
1295 |
-
/**
|
1296 |
-
* Filters the MySQL prepared statement for the legacy activity query.
|
1297 |
-
*
|
1298 |
-
* @since BuddyPress (1.5.0)
|
1299 |
-
*
|
1300 |
-
* @param string Prepared statement for the activity query.
|
1301 |
-
* @param int $activity_id Activity ID to fetch comments for.
|
1302 |
-
* @param int $left Left-most node boundary.
|
1303 |
-
* @param int $right Right-most node boundary.
|
1304 |
-
* @param string $spam_sql SQL Statement portion to differentiate between ham or spam.
|
1305 |
-
*/
|
1306 |
-
$sql = apply_filters( 'bp_activity_comments_user_join_filter', $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' {$spam_sql} AND a.item_id = %d AND a.mptt_left > %d AND a.mptt_left < %d ORDER BY a.date_recorded ASC", $top_level_parent_id, $left, $right ), $activity_id, $left, $right, $spam_sql );
|
1307 |
-
|
1308 |
-
$descendants = $wpdb->get_results( $sql );
|
1309 |
-
|
1310 |
-
// We use the mptt BETWEEN clause to limit returned
|
1311 |
-
// descendants to the correct part of the tree.
|
1312 |
-
} else {
|
1313 |
-
$sql = $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} a WHERE a.type = 'activity_comment' {$spam_sql} AND a.item_id = %d and a.mptt_left > %d AND a.mptt_left < %d ORDER BY a.date_recorded ASC", $top_level_parent_id, $left, $right );
|
1314 |
-
|
1315 |
-
$descendant_ids = $wpdb->get_col( $sql );
|
1316 |
-
$descendants = self::get_activity_data( $descendant_ids );
|
1317 |
-
$descendants = self::append_user_fullnames( $descendants );
|
1318 |
-
}
|
1319 |
-
|
1320 |
-
$ref = array();
|
1321 |
-
|
1322 |
-
// Loop descendants and build an assoc array
|
1323 |
-
foreach ( (array) $descendants as $d ) {
|
1324 |
-
$d->children = array();
|
1325 |
-
|
1326 |
-
// If we have a reference on the parent
|
1327 |
-
if ( isset( $ref[ $d->secondary_item_id ] ) ) {
|
1328 |
-
$ref[ $d->secondary_item_id ]->children[ $d->id ] = $d;
|
1329 |
-
$ref[ $d->id ] =& $ref[ $d->secondary_item_id ]->children[ $d->id ];
|
1330 |
-
|
1331 |
-
// If we don't have a reference on the parent, put in the root level
|
1332 |
-
} else {
|
1333 |
-
$comments[ $d->id ] = $d;
|
1334 |
-
$ref[ $d->id ] =& $comments[ $d->id ];
|
1335 |
-
}
|
1336 |
-
}
|
1337 |
-
|
1338 |
-
// Calculate depth for each item
|
1339 |
-
foreach ( $ref as &$r ) {
|
1340 |
-
$depth = 1;
|
1341 |
-
$parent_id = $r->secondary_item_id;
|
1342 |
-
while ( $parent_id !== $r->item_id ) {
|
1343 |
-
$depth++;
|
1344 |
-
|
1345 |
-
// When display_comments=stream, the
|
1346 |
-
// parent comment may not be part of
|
1347 |
-
// the returned results, so we manually
|
1348 |
-
// fetch it
|
1349 |
-
if ( empty( $ref[ $parent_id ] ) ) {
|
1350 |
-
$direct_parent = new BP_Activity_Activity( $parent_id );
|
1351 |
-
if ( isset( $direct_parent->secondary_item_id ) ) {
|
1352 |
-
$parent_id = $direct_parent->secondary_item_id;
|
1353 |
-
} else {
|
1354 |
-
// Something went wrong
|
1355 |
-
// Short-circuit the
|
1356 |
-
// depth calculation
|
1357 |
-
$parent_id = $r->item_id;
|
1358 |
-
}
|
1359 |
-
} else {
|
1360 |
-
$parent_id = $ref[ $parent_id ]->secondary_item_id;
|
1361 |
-
}
|
1362 |
-
}
|
1363 |
-
$r->depth = $depth;
|
1364 |
-
}
|
1365 |
-
|
1366 |
-
// If we cache a value of false, it'll count as a cache
|
1367 |
-
// miss the next time the activity comments are fetched.
|
1368 |
-
// Storing the string 'none' is a hack workaround to
|
1369 |
-
// avoid unnecessary queries.
|
1370 |
-
if ( false === $comments ) {
|
1371 |
-
$cache_value = 'none';
|
1372 |
-
} else {
|
1373 |
-
$cache_value = $comments;
|
1374 |
-
}
|
1375 |
-
|
1376 |
-
wp_cache_set( $activity_id, $cache_value, 'bp_activity_comments' );
|
1377 |
-
}
|
1378 |
-
|
1379 |
-
return $comments;
|
1380 |
-
}
|
1381 |
-
|
1382 |
-
/**
|
1383 |
-
* Rebuild nested comment tree under an activity or activity comment.
|
1384 |
-
*
|
1385 |
-
* @since BuddyPress (1.2)
|
1386 |
-
*
|
1387 |
-
* @global wpdb $wpdb WordPress database object
|
1388 |
-
*
|
1389 |
-
* @param int $parent_id ID of an activity or activity comment
|
1390 |
-
* @param int $left Node boundary start for activity or activity comment
|
1391 |
-
* @return int Right Node boundary of activity or activity comment
|
1392 |
-
*/
|
1393 |
-
public static function rebuild_activity_comment_tree( $parent_id, $left = 1 ) {
|
1394 |
-
global $wpdb;
|
1395 |
-
|
1396 |
-
$bp = buddypress();
|
1397 |
-
|
1398 |
-
// The right value of this node is the left value + 1
|
1399 |
-
$right = intval( $left + 1 );
|
1400 |
-
|
1401 |
-
// Get all descendants of this node
|
1402 |
-
$comments = BP_Activity_Activity::get_child_comments( $parent_id );
|
1403 |
-
$descendants = wp_list_pluck( $comments, 'id' );
|
1404 |
-
|
1405 |
-
// Loop the descendants and recalculate the left and right values
|
1406 |
-
foreach ( (array) $descendants as $descendant_id ) {
|
1407 |
-
$right = BP_Activity_Activity::rebuild_activity_comment_tree( $descendant_id, $right );
|
1408 |
-
}
|
1409 |
-
|
1410 |
-
// We've got the left value, and now that we've processed the children
|
1411 |
-
// of this node we also know the right value
|
1412 |
-
if ( 1 === $left ) {
|
1413 |
-
$wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE id = %d", $left, $right, $parent_id ) );
|
1414 |
-
} else {
|
1415 |
-
$wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE type = 'activity_comment' AND id = %d", $left, $right, $parent_id ) );
|
1416 |
-
}
|
1417 |
-
|
1418 |
-
// Return the right value of this node + 1
|
1419 |
-
return intval( $right + 1 );
|
1420 |
-
}
|
1421 |
-
|
1422 |
-
/**
|
1423 |
-
* Get child comments of an activity or activity comment.
|
1424 |
-
*
|
1425 |
-
* @since BuddyPress (1.2)
|
1426 |
-
*
|
1427 |
-
* @global wpdb $wpdb WordPress database object.
|
1428 |
-
*
|
1429 |
-
* @param int $parent_id ID of an activity or activity comment.
|
1430 |
-
* @return object Numerically indexed array of child comments.
|
1431 |
-
*/
|
1432 |
-
public static function get_child_comments( $parent_id ) {
|
1433 |
-
global $wpdb;
|
1434 |
-
|
1435 |
-
$bp = buddypress();
|
1436 |
-
|
1437 |
-
return $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND secondary_item_id = %d", $parent_id ) );
|
1438 |
-
}
|
1439 |
-
|
1440 |
-
/**
|
1441 |
-
* Get a list of components that have recorded activity associated with them.
|
1442 |
-
*
|
1443 |
-
* @param bool $skip_last_activity If true, components will not be
|
1444 |
-
* included if the only activity type associated with them is
|
1445 |
-
* 'last_activity'. (Since 2.0.0, 'last_activity' is stored in
|
1446 |
-
* the activity table, but these items are not full-fledged
|
1447 |
-
* activity items.) Default: true.
|
1448 |
-
* @return array List of component names.
|
1449 |
-
*/
|
1450 |
-
public static function get_recorded_components( $skip_last_activity = true ) {
|
1451 |
-
global $wpdb;
|
1452 |
-
|
1453 |
-
$bp = buddypress();
|
1454 |
-
|
1455 |
-
if ( true === $skip_last_activity ) {
|
1456 |
-
$components = $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} WHERE action != '' AND action != 'last_activity' ORDER BY component ASC" );
|
1457 |
-
} else {
|
1458 |
-
$components = $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} ORDER BY component ASC" );
|
1459 |
-
}
|
1460 |
-
|
1461 |
-
return $components;
|
1462 |
-
}
|
1463 |
-
|
1464 |
-
/**
|
1465 |
-
* Get sitewide activity items for use in an RSS feed.
|
1466 |
-
*
|
1467 |
-
* @param int $limit Optional. Number of items to fetch. Default: 35.
|
1468 |
-
* @return array $activity_feed List of activity items, with RSS data added.
|
1469 |
-
*/
|
1470 |
-
public static function get_sitewide_items_for_feed( $limit = 35 ) {
|
1471 |
-
$activities = bp_activity_get_sitewide( array( 'max' => $limit ) );
|
1472 |
-
$activity_feed = array();
|
1473 |
-
|
1474 |
-
for ( $i = 0, $count = count( $activities ); $i < $count; ++$i ) {
|
1475 |
-
$title = explode( '<span', $activities[$i]['content'] );
|
1476 |
-
$activity_feed[$i]['title'] = trim( strip_tags( $title[0] ) );
|
1477 |
-
$activity_feed[$i]['link'] = $activities[$i]['primary_link'];
|
1478 |
-
$activity_feed[$i]['description'] = @sprintf( $activities[$i]['content'], '' );
|
1479 |
-
$activity_feed[$i]['pubdate'] = $activities[$i]['date_recorded'];
|
1480 |
-
}
|
1481 |
-
|
1482 |
-
return $activity_feed;
|
1483 |
-
}
|
1484 |
-
|
1485 |
-
/**
|
1486 |
-
* Create SQL IN clause for filter queries.
|
1487 |
-
*
|
1488 |
-
* @since BuddyPress (1.5)
|
1489 |
-
*
|
1490 |
-
* @see BP_Activity_Activity::get_filter_sql()
|
1491 |
-
*
|
1492 |
-
* @param string $field The database field.
|
1493 |
-
* @param array|bool $items The values for the IN clause, or false when none are found.
|
1494 |
-
*/
|
1495 |
-
public static function get_in_operator_sql( $field, $items ) {
|
1496 |
-
global $wpdb;
|
1497 |
-
|
1498 |
-
// split items at the comma
|
1499 |
-
if ( ! is_array( $items ) ) {
|
1500 |
-
$items = explode( ',', $items );
|
1501 |
-
}
|
1502 |
-
|
1503 |
-
// array of prepared integers or quoted strings
|
1504 |
-
$items_prepared = array();
|
1505 |
-
|
1506 |
-
// clean up and format each item
|
1507 |
-
foreach ( $items as $item ) {
|
1508 |
-
// clean up the string
|
1509 |
-
$item = trim( $item );
|
1510 |
-
// pass everything through prepare for security and to safely quote strings
|
1511 |
-
$items_prepared[] = ( is_numeric( $item ) ) ? $wpdb->prepare( '%d', $item ) : $wpdb->prepare( '%s', $item );
|
1512 |
-
}
|
1513 |
-
|
1514 |
-
// build IN operator sql syntax
|
1515 |
-
if ( count( $items_prepared ) )
|
1516 |
-
return sprintf( '%s IN ( %s )', trim( $field ), implode( ',', $items_prepared ) );
|
1517 |
-
else
|
1518 |
-
return false;
|
1519 |
-
}
|
1520 |
-
|
1521 |
-
/**
|
1522 |
-
* Create filter SQL clauses.
|
1523 |
-
*
|
1524 |
-
* @since BuddyPress (1.5.0)
|
1525 |
-
*
|
1526 |
-
* @param array $filter_array {
|
1527 |
-
* Fields and values to filter by.
|
1528 |
-
* @type array|string|id $user_id User ID(s).
|
1529 |
-
* @type array|string $object Corresponds to the 'component'
|
1530 |
-
* column in the database.
|
1531 |
-
* @type array|string $action Corresponds to the 'type' column
|
1532 |
-
* in the database.
|
1533 |
-
* @type array|string|int $primary_id Corresponds to the 'item_id'
|
1534 |
-
* column in the database.
|
1535 |
-
* @type array|string|int $secondary_id Corresponds to the
|
1536 |
-
* 'secondary_item_id' column in the database.
|
1537 |
-
* @type int $offset Return only those items with an ID greater
|
1538 |
-
* than the offset value.
|
1539 |
-
* @type string $since Return only those items that have a
|
1540 |
-
* date_recorded value greater than a given MySQL-formatted
|
1541 |
-
* date.
|
1542 |
-
* }
|
1543 |
-
* @return string The filter clause, for use in a SQL query.
|
1544 |
-
*/
|
1545 |
-
public static function get_filter_sql( $filter_array ) {
|
1546 |
-
|
1547 |
-
$filter_sql = array();
|
1548 |
-
|
1549 |
-
if ( !empty( $filter_array['user_id'] ) ) {
|
1550 |
-
$user_sql = BP_Activity_Activity::get_in_operator_sql( 'a.user_id', $filter_array['user_id'] );
|
1551 |
-
if ( !empty( $user_sql ) )
|
1552 |
-
$filter_sql[] = $user_sql;
|
1553 |
-
}
|
1554 |
-
|
1555 |
-
if ( !empty( $filter_array['object'] ) ) {
|
1556 |
-
$object_sql = BP_Activity_Activity::get_in_operator_sql( 'a.component', $filter_array['object'] );
|
1557 |
-
if ( !empty( $object_sql ) )
|
1558 |
-
$filter_sql[] = $object_sql;
|
1559 |
-
}
|
1560 |
-
|
1561 |
-
if ( !empty( $filter_array['action'] ) ) {
|
1562 |
-
$action_sql = BP_Activity_Activity::get_in_operator_sql( 'a.type', $filter_array['action'] );
|
1563 |
-
if ( ! empty( $action_sql ) )
|
1564 |
-
$filter_sql[] = $action_sql;
|
1565 |
-
}
|
1566 |
-
|
1567 |
-
if ( !empty( $filter_array['primary_id'] ) ) {
|
1568 |
-
$pid_sql = BP_Activity_Activity::get_in_operator_sql( 'a.item_id', $filter_array['primary_id'] );
|
1569 |
-
if ( !empty( $pid_sql ) )
|
1570 |
-
$filter_sql[] = $pid_sql;
|
1571 |
-
}
|
1572 |
-
|
1573 |
-
if ( !empty( $filter_array['secondary_id'] ) ) {
|
1574 |
-
$sid_sql = BP_Activity_Activity::get_in_operator_sql( 'a.secondary_item_id', $filter_array['secondary_id'] );
|
1575 |
-
if ( !empty( $sid_sql ) )
|
1576 |
-
$filter_sql[] = $sid_sql;
|
1577 |
-
}
|
1578 |
-
|
1579 |
-
if ( ! empty( $filter_array['offset'] ) ) {
|
1580 |
-
$sid_sql = absint( $filter_array['offset'] );
|
1581 |
-
$filter_sql[] = "a.id >= {$sid_sql}";
|
1582 |
-
}
|
1583 |
-
|
1584 |
-
if ( ! empty( $filter_array['since'] ) ) {
|
1585 |
-
// Validate that this is a proper Y-m-d H:i:s date
|
1586 |
-
// Trick: parse to UNIX date then translate back
|
1587 |
-
$translated_date = date( 'Y-m-d H:i:s', strtotime( $filter_array['since'] ) );
|
1588 |
-
if ( $translated_date === $filter_array['since'] ) {
|
1589 |
-
$filter_sql[] = "a.date_recorded > '{$translated_date}'";
|
1590 |
-
}
|
1591 |
-
}
|
1592 |
-
|
1593 |
-
if ( empty( $filter_sql ) )
|
1594 |
-
return false;
|
1595 |
-
|
1596 |
-
return join( ' AND ', $filter_sql );
|
1597 |
-
}
|
1598 |
-
|
1599 |
-
/**
|
1600 |
-
* Get the date/time of last recorded activity.
|
1601 |
-
*
|
1602 |
-
* @since BuddyPress (1.2)
|
1603 |
-
*
|
1604 |
-
* @return string ISO timestamp.
|
1605 |
-
*/
|
1606 |
-
public static function get_last_updated() {
|
1607 |
-
global $wpdb;
|
1608 |
-
|
1609 |
-
$bp = buddypress();
|
1610 |
-
|
1611 |
-
return $wpdb->get_var( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded DESC LIMIT 1" );
|
1612 |
-
}
|
1613 |
-
|
1614 |
-
/**
|
1615 |
-
* Get favorite count for a given user.
|
1616 |
-
*
|
1617 |
-
* @since BuddyPress (1.2)
|
1618 |
-
*
|
1619 |
-
* @param int The ID of the user whose favorites you're counting.
|
1620 |
-
* @return int A count of the user's favorites.
|
1621 |
-
*/
|
1622 |
-
public static function total_favorite_count( $user_id ) {
|
1623 |
-
|
1624 |
-
// Get activities from user meta
|
1625 |
-
$favorite_activity_entries = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
|
1626 |
-
if ( ! empty( $favorite_activity_entries ) ) {
|
1627 |
-
return count( maybe_unserialize( $favorite_activity_entries ) );
|
1628 |
-
}
|
1629 |
-
|
1630 |
-
// No favorites
|
1631 |
-
return 0;
|
1632 |
-
}
|
1633 |
-
|
1634 |
-
/**
|
1635 |
-
* Check whether an activity item exists with a given string content.
|
1636 |
-
*
|
1637 |
-
* @param string $content The content to filter by.
|
1638 |
-
* @return int|bool The ID of the first matching item if found, otherwise false.
|
1639 |
-
*/
|
1640 |
-
public static function check_exists_by_content( $content ) {
|
1641 |
-
global $wpdb;
|
1642 |
-
|
1643 |
-
$bp = buddypress();
|
1644 |
-
|
1645 |
-
return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE content = %s", $content ) );
|
1646 |
-
}
|
1647 |
-
|
1648 |
-
/**
|
1649 |
-
* Hide all activity for a given user.
|
1650 |
-
*
|
1651 |
-
* @param int $user_id The ID of the user whose activity you want to mark hidden.
|
1652 |
-
* @param int
|
1653 |
-
*/
|
1654 |
-
public static function hide_all_for_user( $user_id ) {
|
1655 |
-
global $wpdb;
|
1656 |
-
|
1657 |
-
$bp = buddypress();
|
1658 |
-
|
1659 |
-
return $wpdb->get_var( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET hide_sitewide = 1 WHERE user_id = %d", $user_id ) );
|
1660 |
-
}
|
1661 |
-
|
1662 |
-
/**
|
1663 |
-
* PHP-agnostic version of {@link array_replace_recursive()}.
|
1664 |
-
*
|
1665 |
-
* array_replace_recursive() is a PHP 5.3 function. BuddyPress (and
|
1666 |
-
* WordPress) currently supports down to PHP 5.2, so this method is a workaround
|
1667 |
-
* for PHP 5.2.
|
1668 |
-
*
|
1669 |
-
* Note: array_replace_recursive() supports infinite arguments, but for our use-
|
1670 |
-
* case, we only need to support two arguments.
|
1671 |
-
*
|
1672 |
-
* Subject to removal once WordPress makes PHP 5.3.0 the minimum requirement.
|
1673 |
-
*
|
1674 |
-
* @since BuddyPress (2.2.0)
|
1675 |
-
*
|
1676 |
-
* @see http://php.net/manual/en/function.array-replace-recursive.php#109390
|
1677 |
-
*
|
1678 |
-
* @param array $base Array with keys needing to be replaced
|
1679 |
-
* @param array $replacements Array with the replaced keys
|
1680 |
-
* @return array
|
1681 |
-
*/
|
1682 |
-
protected static function array_replace_recursive( $base = array(), $replacements = array() ) {
|
1683 |
-
if ( function_exists( 'array_replace_recursive' ) ) {
|
1684 |
-
return array_replace_recursive( $base, $replacements );
|
1685 |
-
}
|
1686 |
-
|
1687 |
-
// PHP 5.2-compatible version
|
1688 |
-
// http://php.net/manual/en/function.array-replace-recursive.php#109390
|
1689 |
-
foreach ( array_slice( func_get_args(), 1 ) as $replacements ) {
|
1690 |
-
$bref_stack = array( &$base );
|
1691 |
-
$head_stack = array( $replacements );
|
1692 |
-
|
1693 |
-
do {
|
1694 |
-
end( $bref_stack );
|
1695 |
-
|
1696 |
-
$bref = &$bref_stack[ key( $bref_stack ) ];
|
1697 |
-
$head = array_pop( $head_stack );
|
1698 |
-
|
1699 |
-
unset( $bref_stack[ key($bref_stack) ] );
|
1700 |
-
|
1701 |
-
foreach ( array_keys( $head ) as $key ) {
|
1702 |
-
if ( isset( $key, $bref ) && is_array( $bref[$key] ) && is_array( $head[$key] ) ) {
|
1703 |
-
$bref_stack[] = &$bref[ $key ];
|
1704 |
-
$head_stack[] = $head[ $key ];
|
1705 |
-
} else {
|
1706 |
-
$bref[ $key ] = $head[ $key ];
|
1707 |
-
}
|
1708 |
-
}
|
1709 |
-
} while( count( $head_stack ) );
|
1710 |
-
}
|
1711 |
-
|
1712 |
-
return $base;
|
1713 |
-
}
|
1714 |
-
}
|
1715 |
-
|
1716 |
-
/**
|
1717 |
-
* Class for generating the WHERE SQL clause for advanced activity fetching.
|
1718 |
-
*
|
1719 |
-
* This is notably used in {@link BP_Activity_Activity::get()} with the
|
1720 |
-
* 'filter_query' parameter.
|
1721 |
-
*
|
1722 |
-
* @since BuddyPress (2.2.0)
|
1723 |
-
*/
|
1724 |
-
class BP_Activity_Query extends BP_Recursive_Query {
|
1725 |
-
/**
|
1726 |
-
* Array of activity queries.
|
1727 |
-
*
|
1728 |
-
* See {@see BP_Activity_Query::__construct()} for information on query arguments.
|
1729 |
-
*
|
1730 |
-
* @since BuddyPress (2.2.0)
|
1731 |
-
* @access public
|
1732 |
-
* @var array
|
1733 |
-
*/
|
1734 |
-
public $queries = array();
|
1735 |
-
|
1736 |
-
/**
|
1737 |
-
* Table alias.
|
1738 |
-
*
|
1739 |
-
* @since BuddyPress (2.2.0)
|
1740 |
-
* @access public
|
1741 |
-
* @var string
|
1742 |
-
*/
|
1743 |
-
public $table_alias = '';
|
1744 |
-
|
1745 |
-
/**
|
1746 |
-
* Supported DB columns.
|
1747 |
-
*
|
1748 |
-
* See the 'wp_bp_activity' DB table schema.
|
1749 |
-
*
|
1750 |
-
* @since BuddyPress (2.2.0)
|
1751 |
-
* @access public
|
1752 |
-
* @var array
|
1753 |
-
*/
|
1754 |
-
public $db_columns = array(
|
1755 |
-
'id', 'user_id', 'component', 'type', 'action', 'content',
|
1756 |
-
'item_id', 'secondary_item_id', 'hide_sitewide', 'is_spam',
|
1757 |
-
);
|
1758 |
-
|
1759 |
-
/**
|
1760 |
-
* Constructor.
|
1761 |
-
*
|
1762 |
-
* @since BuddyPress (2.2.0)
|
1763 |
-
*
|
1764 |
-
* @param array $query {
|
1765 |
-
* Array of query clauses.
|
1766 |
-
*
|
1767 |
-
* @type array {
|
1768 |
-
* @type string $column Required. The column to query against. Basically, any DB column in the main
|
1769 |
-
* 'wp_bp_activity' table.
|
1770 |
-
* @type string $value Required. Value to filter by.
|
1771 |
-
* @type string $compare Optional. The comparison operator. Default '='.
|
1772 |
-
* Accepts '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'LIKE',
|
1773 |
-
* 'NOT LIKE', BETWEEN', 'NOT BETWEEN', 'REGEXP', 'NOT REGEXP', 'RLIKE'
|
1774 |
-
* @type string $relation Optional. The boolean relationship between the activity queries.
|
1775 |
-
* Accepts 'OR', 'AND'. Default 'AND'.
|
1776 |
-
* @type array {
|
1777 |
-
* Optional. Another fully-formed activity query. See parameters above.
|
1778 |
-
* }
|
1779 |
-
* }
|
1780 |
-
* }
|
1781 |
-
*/
|
1782 |
-
public function __construct( $query = array() ) {
|
1783 |
-
if ( ! is_array( $query ) ) {
|
1784 |
-
return;
|
1785 |
-
}
|
1786 |
-
|
1787 |
-
$this->queries = $this->sanitize_query( $query );
|
1788 |
-
}
|
1789 |
-
|
1790 |
-
/**
|
1791 |
-
* Generates WHERE SQL clause to be appended to a main query.
|
1792 |
-
*
|
1793 |
-
* @since BuddyPress (2.2.0)
|
1794 |
-
* @access public
|
1795 |
-
*
|
1796 |
-
* @param string $alias An existing table alias that is compatible with the current query clause.
|
1797 |
-
* Default: 'a'. BP_Activity_Activity::get() uses 'a', so we default to that.
|
1798 |
-
* @return string SQL fragment to append to the main WHERE clause.
|
1799 |
-
*/
|
1800 |
-
public function get_sql( $alias = 'a' ) {
|
1801 |
-
if ( ! empty( $alias ) ) {
|
1802 |
-
$this->table_alias = sanitize_title( $alias );
|
1803 |
-
}
|
1804 |
-
|
1805 |
-
$sql = $this->get_sql_clauses();
|
1806 |
-
|
1807 |
-
// we only need the 'where' clause
|
1808 |
-
//
|
1809 |
-
// also trim trailing "AND" clause from parent BP_Recursive_Query class
|
1810 |
-
// since it's not necessary for our needs
|
1811 |
-
return preg_replace( '/^\sAND/', '', $sql['where'] );
|
1812 |
-
}
|
1813 |
-
|
1814 |
-
/**
|
1815 |
-
* Generate WHERE clauses for a first-order clause.
|
1816 |
-
*
|
1817 |
-
* @since BuddyPress (2.2.0)
|
1818 |
-
* @access protected
|
1819 |
-
*
|
1820 |
-
* @param array $clause Array of arguments belonging to the clause.
|
1821 |
-
* @param array $parent_query Parent query to which the clause belongs.
|
1822 |
-
* @return array {
|
1823 |
-
* @type array $where Array of subclauses for the WHERE statement.
|
1824 |
-
* @type array $join Empty array. Not used.
|
1825 |
-
* }
|
1826 |
-
*/
|
1827 |
-
protected function get_sql_for_clause( $clause, $parent_query ) {
|
1828 |
-
global $wpdb;
|
1829 |
-
|
1830 |
-
$sql_chunks = array(
|
1831 |
-
'where' => array(),
|
1832 |
-
'join' => array(),
|
1833 |
-
);
|
1834 |
-
|
1835 |
-
$column = isset( $clause['column'] ) ? $this->validate_column( $clause['column'] ) : '';
|
1836 |
-
$value = isset( $clause['value'] ) ? $clause['value'] : '';
|
1837 |
-
if ( empty( $column ) || ! isset( $clause['value'] ) ) {
|
1838 |
-
return $sql_chunks;
|
1839 |
-
}
|
1840 |
-
|
1841 |
-
if ( isset( $clause['compare'] ) ) {
|
1842 |
-
$clause['compare'] = strtoupper( $clause['compare'] );
|
1843 |
-
} else {
|
1844 |
-
$clause['compare'] = isset( $clause['value'] ) && is_array( $clause['value'] ) ? 'IN' : '=';
|
1845 |
-
}
|
1846 |
-
|
1847 |
-
// default 'compare' to '=' if no valid operator is found
|
1848 |
-
if ( ! in_array( $clause['compare'], array(
|
1849 |
-
'=', '!=', '>', '>=', '<', '<=',
|
1850 |
-
'LIKE', 'NOT LIKE',
|
1851 |
-
'IN', 'NOT IN',
|
1852 |
-
'BETWEEN', 'NOT BETWEEN',
|
1853 |
-
'REGEXP', 'NOT REGEXP', 'RLIKE'
|
1854 |
-
) ) ) {
|
1855 |
-
$clause['compare'] = '=';
|
1856 |
-
}
|
1857 |
-
|
1858 |
-
$compare = $clause['compare'];
|
1859 |
-
|
1860 |
-
$alias = ! empty( $this->table_alias ) ? "{$this->table_alias}." : '';
|
1861 |
-
|
1862 |
-
// Next, Build the WHERE clause.
|
1863 |
-
$where = '';
|
1864 |
-
|
1865 |
-
// value.
|
1866 |
-
if ( isset( $clause['value'] ) ) {
|
1867 |
-
if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
|
1868 |
-
if ( ! is_array( $value ) ) {
|
1869 |
-
$value = preg_split( '/[,\s]+/', $value );
|
1870 |
-
}
|
1871 |
-
}
|
1872 |
-
|
1873 |
-
// tinyint
|
1874 |
-
if ( ! empty( $column ) && true === in_array( $column, array( 'hide_sitewide', 'is_spam' ) ) ) {
|
1875 |
-
$sql_chunks['where'][] = $wpdb->prepare( "{$alias}{$column} = %d", $value );
|
1876 |
-
|
1877 |
-
} else {
|
1878 |
-
switch ( $compare ) {
|
1879 |
-
// IN uses different syntax
|
1880 |
-
case 'IN' :
|
1881 |
-
case 'NOT IN' :
|
1882 |
-
$in_sql = BP_Activity_Activity::get_in_operator_sql( "{$alias}{$column}", $value );
|
1883 |
-
|
1884 |
-
// 'NOT IN' operator is as easy as a string replace!
|
1885 |
-
if ( 'NOT IN' === $compare ) {
|
1886 |
-
$in_sql = str_replace( 'IN', 'NOT IN', $in_sql );
|
1887 |
-
}
|
1888 |
-
|
1889 |
-
$sql_chunks['where'][] = $in_sql;
|
1890 |
-
break;
|
1891 |
-
|
1892 |
-
case 'BETWEEN' :
|
1893 |
-
case 'NOT BETWEEN' :
|
1894 |
-
$value = array_slice( $value, 0, 2 );
|
1895 |
-
$where = $wpdb->prepare( '%s AND %s', $value );
|
1896 |
-
break;
|
1897 |
-
|
1898 |
-
case 'LIKE' :
|
1899 |
-
case 'NOT LIKE' :
|
1900 |
-
$value = '%' . bp_esc_like( $value ) . '%';
|
1901 |
-
$where = $wpdb->prepare( '%s', $value );
|
1902 |
-
break;
|
1903 |
-
|
1904 |
-
default :
|
1905 |
-
$where = $wpdb->prepare( '%s', $value );
|
1906 |
-
break;
|
1907 |
-
|
1908 |
-
}
|
1909 |
-
}
|
1910 |
-
|
1911 |
-
if ( $where ) {
|
1912 |
-
$sql_chunks['where'][] = "{$alias}{$column} {$compare} {$where}";
|
1913 |
-
}
|
1914 |
-
}
|
1915 |
-
|
1916 |
-
/*
|
1917 |
-
* Multiple WHERE clauses should be joined in parentheses.
|
1918 |
-
*/
|
1919 |
-
if ( 1 < count( $sql_chunks['where'] ) ) {
|
1920 |
-
$sql_chunks['where'] = array( '( ' . implode( ' AND ', $sql_chunks['where'] ) . ' )' );
|
1921 |
-
}
|
1922 |
-
|
1923 |
-
return $sql_chunks;
|
1924 |
-
}
|
1925 |
-
|
1926 |
-
/**
|
1927 |
-
* Determine whether a clause is first-order.
|
1928 |
-
*
|
1929 |
-
* @since BuddyPress (2.2.0)
|
1930 |
-
* @access protected
|
1931 |
-
*
|
1932 |
-
* @param array $query Clause to check.
|
1933 |
-
* @return bool
|
1934 |
-
*/
|
1935 |
-
protected function is_first_order_clause( $query ) {
|
1936 |
-
return isset( $query['column'] ) || isset( $query['value'] );
|
1937 |
-
}
|
1938 |
-
|
1939 |
-
/**
|
1940 |
-
* Validates a column name parameter.
|
1941 |
-
*
|
1942 |
-
* Column names are checked against a whitelist of known tables.
|
1943 |
-
* See {@link BP_Activity_Query::db_tables}.
|
1944 |
-
*
|
1945 |
-
* @since BuddyPress (2.2.0)
|
1946 |
-
* @access public
|
1947 |
-
*
|
1948 |
-
* @param string $column The user-supplied column name.
|
1949 |
-
* @return string A validated column name value.
|
1950 |
-
*/
|
1951 |
-
public function validate_column( $column = '' ) {
|
1952 |
-
if ( in_array( $column, $this->db_columns ) ) {
|
1953 |
-
return $column;
|
1954 |
-
} else {
|
1955 |
-
return '';
|
1956 |
-
}
|
1957 |
-
}
|
1958 |
-
}
|
1959 |
-
|
1960 |
-
/**
|
1961 |
-
* Create a RSS feed using the activity component.
|
1962 |
-
*
|
1963 |
-
* You should only construct a new feed when you've validated that you're on
|
1964 |
-
* the appropriate screen.
|
1965 |
-
*
|
1966 |
-
* See {@link bp_activity_action_sitewide_feed()} as an example.
|
1967 |
-
*
|
1968 |
-
* Accepted parameters:
|
1969 |
-
* id - internal id for the feed; should be alphanumeric only
|
1970 |
-
* (required)
|
1971 |
-
* title - RSS feed title
|
1972 |
-
* link - Relevant link for the RSS feed
|
1973 |
-
* description - RSS feed description
|
1974 |
-
* ttl - Time-to-live (see inline doc in constructor)
|
1975 |
-
* update_period - Part of the syndication module (see inline doc in
|
1976 |
-
* constructor for more info)
|
1977 |
-
* update_frequency - Part of the syndication module (see inline doc in
|
1978 |
-
* constructor for more info)
|
1979 |
-
* max - Number of feed items to display
|
1980 |
-
* activity_args - Arguments passed to {@link bp_has_activities()}
|
1981 |
-
*
|
1982 |
-
* @since BuddyPress (1.8)
|
1983 |
-
*/
|
1984 |
-
class BP_Activity_Feed {
|
1985 |
-
/**
|
1986 |
-
* Holds our custom class properties.
|
1987 |
-
*
|
1988 |
-
* These variables are stored in a protected array that is magically
|
1989 |
-
* updated using PHP 5.2+ methods.
|
1990 |
-
*
|
1991 |
-
* @see BP_Feed::__construct() This is where $data is added
|
1992 |
-
* @var array
|
1993 |
-
*/
|
1994 |
-
protected $data;
|
1995 |
-
|
1996 |
-
/**
|
1997 |
-
* Magic method for checking the existence of a certain data variable.
|
1998 |
-
*
|
1999 |
-
* @param string $key
|
2000 |
-
*/
|
2001 |
-
public function __isset( $key ) { return isset( $this->data[$key] ); }
|
2002 |
-
|
2003 |
-
/**
|
2004 |
-
* Magic method for getting a certain data variable.
|
2005 |
-
*
|
2006 |
-
* @param string $key
|
2007 |
-
*/
|
2008 |
-
public function __get( $key ) { return isset( $this->data[$key] ) ? $this->data[$key] : null; }
|
2009 |
-
|
2010 |
-
/**
|
2011 |
-
* Constructor.
|
2012 |
-
*
|
2013 |
-
* @param array $args Optional
|
2014 |
-
*/
|
2015 |
-
public function __construct( $args = array() ) {
|
2016 |
-
|
2017 |
-
/**
|
2018 |
-
* Filters if BuddyPress should consider feeds enabled. If disabled, it will return early.
|
2019 |
-
*
|
2020 |
-
* @since BuddyPress (1.8.0)
|
2021 |
-
*
|
2022 |
-
* @param bool true Default true aka feeds are enabled.
|
2023 |
-
*/
|
2024 |
-
if ( false === (bool) apply_filters( 'bp_activity_enable_feeds', true ) ) {
|
2025 |
-
global $wp_query;
|
2026 |
-
|
2027 |
-
// set feed flag to false
|
2028 |
-
$wp_query->is_feed = false;
|
2029 |
-
|
2030 |
-
return false;
|
2031 |
-
}
|
2032 |
-
|
2033 |
-
// Setup data
|
2034 |
-
$this->data = wp_parse_args( $args, array(
|
2035 |
-
// Internal identifier for the RSS feed - should be alphanumeric only
|
2036 |
-
'id' => '',
|
2037 |
-
|
2038 |
-
// RSS title - should be plain-text
|
2039 |
-
'title' => '',
|
2040 |
-
|
2041 |
-
// relevant link for the RSS feed
|
2042 |
-
'link' => '',
|
2043 |
-
|
2044 |
-
// RSS description - should be plain-text
|
2045 |
-
'description' => '',
|
2046 |
-
|
2047 |
-
// Time-to-live - number of minutes to cache the data before an aggregator
|
2048 |
-
// requests it again. This is only acknowledged if the RSS client supports it
|
2049 |
-
//
|
2050 |
-
// See: http://www.rssboard.org/rss-profile#element-channel-ttl
|
2051 |
-
// http://www.kbcafe.com/rss/rssfeedstate.html#ttl
|
2052 |
-
'ttl' => '30',
|
2053 |
-
|
2054 |
-
// Syndication module - similar to ttl, but not really supported by RSS
|
2055 |
-
// clients
|
2056 |
-
//
|
2057 |
-
// See: http://web.resource.org/rss/1.0/modules/syndication/#description
|
2058 |
-
// http://www.kbcafe.com/rss/rssfeedstate.html#syndicationmodule
|
2059 |
-
'update_period' => 'hourly',
|
2060 |
-
'update_frequency' => 2,
|
2061 |
-
|
2062 |
-
// Number of items to display
|
2063 |
-
'max' => 50,
|
2064 |
-
|
2065 |
-
// Activity arguments passed to bp_has_activities()
|
2066 |
-
'activity_args' => array()
|
2067 |
-
) );
|
2068 |
-
|
2069 |
-
/**
|
2070 |
-
* Fires before the feed is setup so plugins can modify.
|
2071 |
-
*
|
2072 |
-
* @since BuddyPress (1.8.0)
|
2073 |
-
*
|
2074 |
-
* @param BP_Activity_Feed Reference to current instance of activity feed.
|
2075 |
-
*/
|
2076 |
-
do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) );
|
2077 |
-
|
2078 |
-
// Setup class properties
|
2079 |
-
$this->setup_properties();
|
2080 |
-
|
2081 |
-
// Check if id is valid
|
2082 |
-
if ( empty( $this->id ) ) {
|
2083 |
-
_doing_it_wrong( 'BP_Activity_Feed', __( "RSS feed 'id' must be defined", 'buddypress' ), 'BP 1.8' );
|
2084 |
-
return false;
|
2085 |
-
}
|
2086 |
-
|
2087 |
-
/**
|
2088 |
-
* Fires after the feed is setup so plugins can modify.
|
2089 |
-
*
|
2090 |
-
* @since BuddyPress (1.8.0)
|
2091 |
-
*
|
2092 |
-
* @param BP_Activity_Feed Reference to current instance of activity feed.
|
2093 |
-
*/
|
2094 |
-
do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) );
|
2095 |
-
|
2096 |
-
// Setup feed hooks
|
2097 |
-
$this->setup_hooks();
|
2098 |
-
|
2099 |
-
// Output the feed
|
2100 |
-
$this->output();
|
2101 |
-
|
2102 |
-
// Kill the rest of the output
|
2103 |
-
die();
|
2104 |
-
}
|
2105 |
-
|
2106 |
-
/** SETUP ****************************************************************/
|
2107 |
-
|
2108 |
-
/**
|
2109 |
-
* Setup and validate the class properties.
|
2110 |
-
*
|
2111 |
-
* @access protected
|
2112 |
-
*/
|
2113 |
-
protected function setup_properties() {
|
2114 |
-
$this->id = sanitize_title( $this->id );
|
2115 |
-
$this->title = strip_tags( $this->title );
|
2116 |
-
$this->link = esc_url_raw( $this->link );
|
2117 |
-
$this->description = strip_tags( $this->description );
|
2118 |
-
$this->ttl = (int) $this->ttl;
|
2119 |
-
$this->update_period = strip_tags( $this->update_period );
|
2120 |
-
$this->update_frequency = (int) $this->update_frequency;
|
2121 |
-
|
2122 |
-
$this->activity_args = wp_parse_args( $this->activity_args, array(
|
2123 |
-
'max' => $this->max,
|
2124 |
-
'per_page' => $this->max,
|
2125 |
-
'display_comments' => 'stream'
|
2126 |
-
) );
|
2127 |
-
|
2128 |
-
}
|
2129 |
-
|
2130 |
-
/**
|
2131 |
-
* Setup some hooks that are used in the feed.
|
2132 |
-
*
|
2133 |
-
* Currently, these hooks are used to maintain backwards compatibility with
|
2134 |
-
* the RSS feeds previous to BP 1.8.
|
2135 |
-
*
|
2136 |
-
* @access protected
|
2137 |
-
*/
|
2138 |
-
protected function setup_hooks() {
|
2139 |
-
add_action( 'bp_activity_feed_rss_attributes', array( $this, 'backpat_rss_attributes' ) );
|
2140 |
-
add_action( 'bp_activity_feed_channel_elements', array( $this, 'backpat_channel_elements' ) );
|
2141 |
-
add_action( 'bp_activity_feed_item_elements', array( $this, 'backpat_item_elements' ) );
|
2142 |
-
}
|
2143 |
-
|
2144 |
-
/** BACKPAT HOOKS ********************************************************/
|
2145 |
-
|
2146 |
-
/**
|
2147 |
-
* Fire a hook to ensure backward compatibility for RSS attributes.
|
2148 |
-
*/
|
2149 |
-
public function backpat_rss_attributes() {
|
2150 |
-
|
2151 |
-
/**
|
2152 |
-
* Fires inside backpat_rss_attributes method for backwards compatibility related to RSS attributes.
|
2153 |
-
*
|
2154 |
-
* This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
|
2155 |
-
*
|
2156 |
-
* @since BuddyPress (1.0.0)
|
2157 |
-
*/
|
2158 |
-
do_action( 'bp_activity_' . $this->id . '_feed' );
|
2159 |
-
}
|
2160 |
-
|
2161 |
-
/**
|
2162 |
-
* Fire a hook to ensure backward compatibility for channel elements.
|
2163 |
-
*/
|
2164 |
-
public function backpat_channel_elements() {
|
2165 |
-
|
2166 |
-
/**
|
2167 |
-
* Fires inside backpat_channel_elements method for backwards compatibility related to RSS channel elements.
|
2168 |
-
*
|
2169 |
-
* This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
|
2170 |
-
*
|
2171 |
-
* @since BuddyPress (1.0.0)
|
2172 |
-
*/
|
2173 |
-
do_action( 'bp_activity_' . $this->id . '_feed_head' );
|
2174 |
-
}
|
2175 |
-
|
2176 |
-
/**
|
2177 |
-
* Fire a hook to ensure backward compatibility for item elements.
|
2178 |
-
*/
|
2179 |
-
public function backpat_item_elements() {
|
2180 |
-
switch ( $this->id ) {
|
2181 |
-
|
2182 |
-
// sitewide and friends feeds use the 'personal' hook
|
2183 |
-
case 'sitewide' :
|
2184 |
-
case 'friends' :
|
2185 |
-
$id = 'personal';
|
2186 |
-
|
2187 |
-
break;
|
2188 |
-
|
2189 |
-
default :
|
2190 |
-
$id = $this->id;
|
2191 |
-
|
2192 |
-
break;
|
2193 |
-
}
|
2194 |
-
|
2195 |
-
/**
|
2196 |
-
* Fires inside backpat_item_elements method for backwards compatibility related to RSS item elements.
|
2197 |
-
*
|
2198 |
-
* This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
|
2199 |
-
*
|
2200 |
-
* @since BuddyPress (1.0.0)
|
2201 |
-
*/
|
2202 |
-
do_action( 'bp_activity_' . $id . '_feed_item' );
|
2203 |
-
}
|
2204 |
-
|
2205 |
-
/** HELPERS **************************************************************/
|
2206 |
-
|
2207 |
-
/**
|
2208 |
-
* Output the feed's item content.
|
2209 |
-
*
|
2210 |
-
* @access protected
|
2211 |
-
*/
|
2212 |
-
protected function feed_content() {
|
2213 |
-
bp_activity_content_body();
|
2214 |
-
|
2215 |
-
switch ( $this->id ) {
|
2216 |
-
|
2217 |
-
// also output parent activity item if we're on a specific feed
|
2218 |
-
case 'favorites' :
|
2219 |
-
case 'friends' :
|
2220 |
-
case 'mentions' :
|
2221 |
-
case 'personal' :
|
2222 |
-
|
2223 |
-
if ( 'activity_comment' == bp_get_activity_action_name() ) :
|
2224 |
-
?>
|
2225 |
-
<strong><?php _e( 'In reply to', 'buddypress' ) ?></strong> -
|
2226 |
-
<?php bp_activity_parent_content() ?>
|
2227 |
-
<?php
|
2228 |
-
endif;
|
2229 |
-
|
2230 |
-
break;
|
2231 |
-
}
|
2232 |
-
}
|
2233 |
-
|
2234 |
-
/**
|
2235 |
-
* Sets various HTTP headers related to Content-Type and browser caching.
|
2236 |
-
*
|
2237 |
-
* Most of this class method is derived from {@link WP::send_headers()}.
|
2238 |
-
*
|
2239 |
-
* @since BuddyPress (1.9.0)
|
2240 |
-
*
|
2241 |
-
* @access protected
|
2242 |
-
*/
|
2243 |
-
protected function http_headers() {
|
2244 |
-
// set up some additional headers if not on a directory page
|
2245 |
-
// this is done b/c BP uses pseudo-pages
|
2246 |
-
if ( ! bp_is_directory() ) {
|
2247 |
-
global $wp_query;
|
2248 |
-
|
2249 |
-
$wp_query->is_404 = false;
|
2250 |
-
status_header( 200 );
|
2251 |
-
}
|
2252 |
-
|
2253 |
-
// Set content-type
|
2254 |
-
@header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
|
2255 |
-
send_nosniff_header();
|
2256 |
-
|
2257 |
-
// Cache-related variables
|
2258 |
-
$last_modified = mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false );
|
2259 |
-
$modified_timestamp = strtotime( $last_modified );
|
2260 |
-
$etag = md5( $last_modified );
|
2261 |
-
|
2262 |
-
// Set cache-related headers
|
2263 |
-
@header( 'Last-Modified: ' . $last_modified );
|
2264 |
-
@header( 'Pragma: no-cache' );
|
2265 |
-
@header( 'ETag: ' . '"' . $etag . '"' );
|
2266 |
-
|
2267 |
-
// First commit of BuddyPress! (Easter egg)
|
2268 |
-
@header( 'Expires: Tue, 25 Mar 2008 17:13:55 GMT');
|
2269 |
-
|
2270 |
-
// Get ETag from supported user agents
|
2271 |
-
if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) {
|
2272 |
-
$client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] );
|
2273 |
-
|
2274 |
-
// Remove quotes from ETag
|
2275 |
-
$client_etag = trim( $client_etag, '"' );
|
2276 |
-
|
2277 |
-
// Strip suffixes from ETag if they exist (eg. "-gzip")
|
2278 |
-
$etag_suffix_pos = strpos( $client_etag, '-' );
|
2279 |
-
if ( ! empty( $etag_suffix_pos ) ) {
|
2280 |
-
$client_etag = substr( $client_etag, 0, $etag_suffix_pos );
|
2281 |
-
}
|
2282 |
-
|
2283 |
-
// No ETag found
|
2284 |
-
} else {
|
2285 |
-
$client_etag = false;
|
2286 |
-
}
|
2287 |
-
|
2288 |
-
// Get client last modified timestamp from supported user agents
|
2289 |
-
$client_last_modified = empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? '' : trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
|
2290 |
-
$client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
|
2291 |
-
|
2292 |
-
// Set 304 status if feed hasn't been updated since last fetch
|
2293 |
-
if ( ( $client_last_modified && $client_etag ) ?
|
2294 |
-
( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) ) :
|
2295 |
-
( ( $client_modified_timestamp >= $modified_timestamp ) || ( $client_etag == $etag ) ) ) {
|
2296 |
-
$status = 304;
|
2297 |
-
} else {
|
2298 |
-
$status = false;
|
2299 |
-
}
|
2300 |
-
|
2301 |
-
// If feed hasn't changed as reported by the user agent, set 304 status header
|
2302 |
-
if ( ! empty( $status ) ) {
|
2303 |
-
status_header( $status );
|
2304 |
-
|
2305 |
-
// cached response, so stop now!
|
2306 |
-
if ( $status == 304 ) {
|
2307 |
-
exit();
|
2308 |
-
}
|
2309 |
-
}
|
2310 |
-
}
|
2311 |
-
|
2312 |
-
/** OUTPUT ***************************************************************/
|
2313 |
-
|
2314 |
-
/**
|
2315 |
-
* Output the RSS feed.
|
2316 |
-
*
|
2317 |
-
* @access protected
|
2318 |
-
*/
|
2319 |
-
protected function output() {
|
2320 |
-
$this->http_headers();
|
2321 |
-
echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?'.'>';
|
2322 |
-
?>
|
2323 |
-
|
2324 |
-
<rss version="2.0"
|
2325 |
-
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
2326 |
-
xmlns:atom="http://www.w3.org/2005/Atom"
|
2327 |
-
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
|
2328 |
-
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
|
2329 |
-
<?php
|
2330 |
-
|
2331 |
-
/**
|
2332 |
-
* Fires at the end of the opening RSS tag for feed output so plugins can add extra attributes.
|
2333 |
-
*
|
2334 |
-
* @since BuddyPress (1.8.0)
|
2335 |
-
*/
|
2336 |
-
do_action( 'bp_activity_feed_rss_attributes' ); ?>
|
2337 |
-
>
|
2338 |
-
|
2339 |
-
<channel>
|
2340 |
-
<title><?php echo $this->title; ?></title>
|
2341 |
-
<link><?php echo $this->link; ?></link>
|
2342 |
-
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
2343 |
-
<description><?php echo $this->description ?></description>
|
2344 |
-
<lastBuildDate><?php echo mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false ); ?></lastBuildDate>
|
2345 |
-
<generator>http://buddypress.org/?v=<?php bp_version(); ?></generator>
|
2346 |
-
<language><?php bloginfo_rss( 'language' ); ?></language>
|
2347 |
-
<ttl><?php echo $this->ttl; ?></ttl>
|
2348 |
-
<sy:updatePeriod><?php echo $this->update_period; ?></sy:updatePeriod>
|
2349 |
-
<sy:updateFrequency><?php echo $this->update_frequency; ?></sy:updateFrequency>
|
2350 |
-
<?php
|
2351 |
-
|
2352 |
-
/**
|
2353 |
-
* Fires at the end of channel elements list in RSS feed so plugins can add extra channel elements.
|
2354 |
-
*
|
2355 |
-
* @since BuddyPress (1.8.0)
|
2356 |
-
*/
|
2357 |
-
do_action( 'bp_activity_feed_channel_elements' ); ?>
|
2358 |
-
|
2359 |
-
<?php if ( bp_has_activities( $this->activity_args ) ) : ?>
|
2360 |
-
<?php while ( bp_activities() ) : bp_the_activity(); ?>
|
2361 |
-
<item>
|
2362 |
-
<guid isPermaLink="false"><?php bp_activity_feed_item_guid(); ?></guid>
|
2363 |
-
<title><?php echo stripslashes( bp_get_activity_feed_item_title() ); ?></title>
|
2364 |
-
<link><?php bp_activity_thread_permalink() ?></link>
|
2365 |
-
<pubDate><?php echo mysql2date( 'D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false ); ?></pubDate>
|
2366 |
-
|
2367 |
-
<?php if ( bp_get_activity_feed_item_description() ) : ?>
|
2368 |
-
<content:encoded><![CDATA[<?php $this->feed_content(); ?>]]></content:encoded>
|
2369 |
-
<?php endif; ?>
|
2370 |
-
|
2371 |
-
<?php if ( bp_activity_can_comment() ) : ?>
|
2372 |
-
<slash:comments><?php bp_activity_comment_count(); ?></slash:comments>
|
2373 |
-
<?php endif; ?>
|
2374 |
-
|
2375 |
-
<?php
|
2376 |
-
|
2377 |
-
/**
|
2378 |
-
* Fires at the end of the individual RSS Item list in RSS feed so plugins can add extra item elements.
|
2379 |
-
*
|
2380 |
-
* @since BuddyPress (1.8.0)
|
2381 |
-
*/
|
2382 |
-
do_action( 'bp_activity_feed_item_elements' ); ?>
|
2383 |
-
</item>
|
2384 |
-
<?php endwhile; ?>
|
2385 |
-
|
2386 |
-
<?php endif; ?>
|
2387 |
-
</channel>
|
2388 |
-
</rss><?php
|
2389 |
-
}
|
2390 |
-
}
|
9 |
Â
// Exit if accessed directly
|
10 |
Â
defined( 'ABSPATH' ) || exit;
|
11 |
Â
|
12 |
+
require dirname( __FILE__ ) . '/classes/class-bp-activity-activity.php';
|
13 |
+
require dirname( __FILE__ ) . '/classes/class-bp-activity-feed.php';
|
14 |
+
require dirname( __FILE__ ) . '/classes/class-bp-activity-query.php';
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
bp-activity/bp-activity-cssjs.php
CHANGED
@@ -8,12 +8,12 @@
|
|
8 |
Â
*/
|
9 |
Â
|
10 |
Â
// Exit if accessed directly
|
11 |
-
|
12 |
Â
|
13 |
Â
/**
|
14 |
Â
* Enqueue @mentions JS.
|
15 |
Â
*
|
16 |
-
* @since BuddyPress (2.1)
|
17 |
Â
*/
|
18 |
Â
function bp_activity_mentions_script() {
|
19 |
Â
if ( ! bp_activity_maybe_load_mentions_scripts() ) {
|
@@ -41,6 +41,9 @@ function bp_activity_mentions_script() {
|
|
41 |
Â
wp_style_add_data( 'bp-mentions-css', 'suffix', $min );
|
42 |
Â
}
|
43 |
Â
|
Â
|
|
Â
|
|
Â
|
|
44 |
Â
/**
|
45 |
Â
* Fires at the end of the Activity Mentions script.
|
46 |
Â
*
|
@@ -53,3 +56,22 @@ function bp_activity_mentions_script() {
|
|
53 |
Â
}
|
54 |
Â
add_action( 'bp_enqueue_scripts', 'bp_activity_mentions_script' );
|
55 |
Â
add_action( 'bp_admin_enqueue_scripts', 'bp_activity_mentions_script' );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
8 |
Â
*/
|
9 |
Â
|
10 |
Â
// Exit if accessed directly
|
11 |
+
defined( 'ABSPATH' ) || exit;
|
12 |
Â
|
13 |
Â
/**
|
14 |
Â
* Enqueue @mentions JS.
|
15 |
Â
*
|
16 |
+
* @since BuddyPress (2.1.0)
|
17 |
Â
*/
|
18 |
Â
function bp_activity_mentions_script() {
|
19 |
Â
if ( ! bp_activity_maybe_load_mentions_scripts() ) {
|
41 |
Â
wp_style_add_data( 'bp-mentions-css', 'suffix', $min );
|
42 |
Â
}
|
43 |
Â
|
44 |
+
// If the script has been enqueued, let's attach our mentions TinyMCE init callback.
|
45 |
+
add_filter( 'tiny_mce_before_init', 'bp_add_mentions_on_tinymce_init', 10, 2 );
|
46 |
+
|
47 |
Â
/**
|
48 |
Â
* Fires at the end of the Activity Mentions script.
|
49 |
Â
*
|
56 |
Â
}
|
57 |
Â
add_action( 'bp_enqueue_scripts', 'bp_activity_mentions_script' );
|
58 |
Â
add_action( 'bp_admin_enqueue_scripts', 'bp_activity_mentions_script' );
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Bind the mentions listener to a wp_editor instance when TinyMCE initializes.
|
62 |
+
*
|
63 |
+
* @since BuddyPress (2.3.3)
|
64 |
+
*
|
65 |
+
* @param array $settings An array with TinyMCE config.
|
66 |
+
* @param string $editor_id Unique editor identifier, e.g. 'content'.
|
67 |
+
*
|
68 |
+
* @return array $mceInit An array with TinyMCE config.
|
69 |
+
*/
|
70 |
+
function bp_add_mentions_on_tinymce_init( $settings, $editor_id ) {
|
71 |
+
// We only apply the mentions init to the visual post editor in the WP dashboard.
|
72 |
+
if ( 'content' === $editor_id ) {
|
73 |
+
$settings['init_instance_callback'] = 'window.bp.mentions.tinyMCEinit';
|
74 |
+
}
|
75 |
+
|
76 |
+
return $settings;
|
77 |
+
}
|
bp-activity/bp-activity-filters.php
CHANGED
@@ -179,6 +179,7 @@ function bp_activity_check_blacklist_keys( $activity ) {
|
|
179 |
Â
* @uses wp_kses()
|
180 |
Â
*
|
181 |
Â
* @param string $content The activity content.
|
Â
|
|
182 |
Â
* @return string $content Filtered activity content.
|
183 |
Â
*/
|
184 |
Â
function bp_activity_filter_kses( $content ) {
|
@@ -209,7 +210,7 @@ function bp_activity_filter_kses( $content ) {
|
|
209 |
Â
*
|
210 |
Â
* @since BuddyPress (1.2.0)
|
211 |
Â
*
|
212 |
-
* @param array Array of allowed HTML tags and attributes.
|
213 |
Â
*/
|
214 |
Â
$activity_allowedtags = apply_filters( 'bp_activity_allowed_tags', $activity_allowedtags );
|
215 |
Â
return wp_kses( $content, $activity_allowedtags );
|
@@ -220,8 +221,9 @@ function bp_activity_filter_kses( $content ) {
|
|
220 |
Â
*
|
221 |
Â
* @since BuddyPress (1.2.0)
|
222 |
Â
*
|
223 |
-
* @param string $content
|
224 |
-
* @param int
|
Â
|
|
225 |
Â
* @return string $content Content filtered for mentions.
|
226 |
Â
*/
|
227 |
Â
function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
|
@@ -318,7 +320,7 @@ function bp_activity_at_name_filter_updates( $activity ) {
|
|
318 |
Â
* @uses bp_activity_at_message_notification()
|
319 |
Â
* @uses bp_activity_update_mention_count_for_user()
|
320 |
Â
*
|
321 |
-
* @param BP_Activity_Activity $activity The BP_Activity_Activity object
|
322 |
Â
*/
|
323 |
Â
function bp_activity_at_name_send_emails( $activity ) {
|
324 |
Â
// Are mentions disabled?
|
@@ -338,12 +340,13 @@ function bp_activity_at_name_send_emails( $activity ) {
|
|
338 |
Â
|
339 |
Â
// Send @mentions and setup BP notifications
|
340 |
Â
foreach( (array) $usernames as $user_id => $username ) {
|
Â
|
|
341 |
Â
/**
|
342 |
Â
* Filters BuddyPress' ability to send email notifications for @mentions.
|
343 |
Â
*
|
344 |
Â
* @since BuddyPress (1.6.0)
|
345 |
Â
*
|
346 |
-
* @param bool Whether or not BuddyPress should send a notification to the mentioned users.
|
347 |
Â
* @param array $usernames Array of users potentially notified.
|
348 |
Â
*/
|
349 |
Â
if ( apply_filters( 'bp_activity_at_name_do_notifications', true, $usernames ) ) {
|
@@ -361,6 +364,7 @@ function bp_activity_at_name_send_emails( $activity ) {
|
|
361 |
Â
* @since BuddyPress (1.2.0)
|
362 |
Â
*
|
363 |
Â
* @param string $text Activity text.
|
Â
|
|
364 |
Â
* @return string $text Text with rel=nofollow added to any links.
|
365 |
Â
*/
|
366 |
Â
function bp_activity_make_nofollow_filter( $text ) {
|
@@ -372,10 +376,9 @@ function bp_activity_make_nofollow_filter( $text ) {
|
|
372 |
Â
*
|
373 |
Â
* @since BuddyPress (1.2.0)
|
374 |
Â
*
|
375 |
-
* @param array $matches
|
376 |
-
*
|
377 |
Â
* @param array $matches Items matched by preg_replace_callback() in bp_activity_make_nofollow_filter().
|
378 |
-
*
|
Â
|
|
379 |
Â
*/
|
380 |
Â
function bp_activity_make_nofollow_filter_callback( $matches ) {
|
381 |
Â
$text = $matches[1];
|
@@ -386,6 +389,8 @@ function bp_activity_make_nofollow_filter( $text ) {
|
|
386 |
Â
/**
|
387 |
Â
* Truncate long activity entries when viewed in activity streams.
|
388 |
Â
*
|
Â
|
|
Â
|
|
389 |
Â
* @since BuddyPress (1.5.0)
|
390 |
Â
*
|
391 |
Â
* @uses bp_is_single_activity()
|
@@ -397,21 +402,35 @@ function bp_activity_make_nofollow_filter( $text ) {
|
|
397 |
Â
* @uses apply_filters() To call the 'bp_activity_truncate_entry' hook.
|
398 |
Â
*
|
399 |
Â
* @param string $text The original activity entry text.
|
Â
|
|
400 |
Â
* @return string $excerpt The truncated text.
|
401 |
Â
*/
|
402 |
Â
function bp_activity_truncate_entry( $text ) {
|
403 |
Â
global $activities_template;
|
404 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
405 |
Â
// The full text of the activity update should always show on the single activity screen
|
406 |
-
if ( bp_is_single_activity() )
|
407 |
Â
return $text;
|
Â
|
|
408 |
Â
|
409 |
Â
/**
|
410 |
Â
* Filters the appended text for the activity excerpt.
|
411 |
Â
*
|
412 |
Â
* @since BuddyPress (1.5.0)
|
413 |
Â
*
|
414 |
-
* @param string $
|
415 |
Â
*/
|
416 |
Â
$append_text = apply_filters( 'bp_activity_excerpt_append_text', __( '[Read more]', 'buddypress' ) );
|
417 |
Â
|
@@ -420,7 +439,7 @@ function bp_activity_truncate_entry( $text ) {
|
|
420 |
Â
*
|
421 |
Â
* @since BuddyPress (1.5.0)
|
422 |
Â
*
|
423 |
-
* @param int $
|
424 |
Â
*/
|
425 |
Â
$excerpt_length = apply_filters( 'bp_activity_excerpt_length', 358 );
|
426 |
Â
|
@@ -442,21 +461,22 @@ function bp_activity_truncate_entry( $text ) {
|
|
442 |
Â
*
|
443 |
Â
* @since BuddyPress (1.5.0)
|
444 |
Â
*
|
445 |
-
* @param string $excerpt
|
446 |
-
* @param string $text
|
447 |
Â
* @param string $append_text The final append text applied.
|
448 |
Â
*/
|
449 |
Â
return apply_filters( 'bp_activity_truncate_entry', $excerpt, $text, $append_text );
|
450 |
Â
}
|
451 |
Â
|
452 |
Â
/**
|
453 |
-
* Include extra
|
454 |
Â
*
|
455 |
Â
* @since BuddyPress (2.0.0)
|
456 |
Â
*
|
457 |
Â
* @uses bp_activity_do_heartbeat() to check if heartbeat is required.
|
458 |
Â
*
|
459 |
Â
* @param array $js_handles The original dependencies.
|
Â
|
|
460 |
Â
* @return array $js_handles The new dependencies.
|
461 |
Â
*/
|
462 |
Â
function bp_activity_get_js_dependencies( $js_handles = array() ) {
|
@@ -477,6 +497,7 @@ add_filter( 'bp_core_get_js_dependencies', 'bp_activity_get_js_dependencies', 10
|
|
477 |
Â
* @since BuddyPress (2.0.0)
|
478 |
Â
*
|
479 |
Â
* @param string $classes
|
Â
|
|
480 |
Â
* @return string $classes
|
481 |
Â
*/
|
482 |
Â
function bp_activity_newest_class( $classes = '' ) {
|
@@ -496,6 +517,7 @@ function bp_activity_newest_class( $classes = '' ) {
|
|
496 |
Â
* @since BuddyPress (2.0.0)
|
497 |
Â
*
|
498 |
Â
* @param string $classes
|
Â
|
|
499 |
Â
* @return string $classes
|
500 |
Â
*/
|
501 |
Â
function bp_activity_timestamp_class( $classes = '' ) {
|
@@ -521,10 +543,11 @@ add_filter( 'bp_get_activity_css_class', 'bp_activity_timestamp_class', 9, 1 );
|
|
521 |
Â
*
|
522 |
Â
* @since BuddyPress (2.0.0)
|
523 |
Â
*
|
524 |
-
* @uses bp_activity_get_last_updated() to get the recorded date of the last activity
|
525 |
Â
*
|
526 |
Â
* @param array $response
|
527 |
Â
* @param array $data
|
Â
|
|
528 |
Â
* @return array $response
|
529 |
Â
*/
|
530 |
Â
function bp_activity_heartbeat_last_recorded( $response = array(), $data = array() ) {
|
@@ -586,6 +609,7 @@ add_filter( 'heartbeat_nopriv_received', 'bp_activity_heartbeat_last_recorded',
|
|
586 |
Â
* @since BuddyPress (2.0.0)
|
587 |
Â
*
|
588 |
Â
* @param array $strings Localized strings.
|
Â
|
|
589 |
Â
* @return array $strings
|
590 |
Â
*/
|
591 |
Â
function bp_activity_heartbeat_strings( $strings = array() ) {
|
@@ -601,7 +625,7 @@ function bp_activity_heartbeat_strings( $strings = array() ) {
|
|
601 |
Â
*
|
602 |
Â
* @since BuddyPress (2.0.0)
|
603 |
Â
*
|
604 |
-
* @param array $
|
605 |
Â
*/
|
606 |
Â
$heartbeat_settings = apply_filters( 'heartbeat_settings', array() );
|
607 |
Â
if ( ! empty( $heartbeat_settings['interval'] ) ) {
|
@@ -614,7 +638,7 @@ function bp_activity_heartbeat_strings( $strings = array() ) {
|
|
614 |
Â
*
|
615 |
Â
* @since BuddyPress (2.0.0)
|
616 |
Â
*
|
617 |
-
* @param int $
|
618 |
Â
*/
|
619 |
Â
$bp_activity_pulse = apply_filters( 'bp_activity_heartbeat_pulse', 15 );
|
620 |
Â
|
@@ -646,8 +670,9 @@ add_filter( 'bp_core_get_js_strings', 'bp_activity_heartbeat_strings', 10, 1 );
|
|
646 |
Â
*
|
647 |
Â
* @since BuddyPress (2.2.0)
|
648 |
Â
*
|
649 |
-
* @param array $retval Empty array by default
|
650 |
-
* @param array $filter Current activity arguments
|
Â
|
|
651 |
Â
* @return array
|
652 |
Â
*/
|
653 |
Â
function bp_activity_filter_just_me_scope( $retval = array(), $filter = array() ) {
|
@@ -695,8 +720,9 @@ add_filter( 'bp_activity_set_just-me_scope_args', 'bp_activity_filter_just_me_sc
|
|
695 |
Â
*
|
696 |
Â
* @since BuddyPress (2.2.0)
|
697 |
Â
*
|
698 |
-
* @param array $retval Empty array by default
|
699 |
-
* @param array $filter Current activity arguments
|
Â
|
|
700 |
Â
* @return array
|
701 |
Â
*/
|
702 |
Â
function bp_activity_filter_favorites_scope( $retval = array(), $filter = array() ) {
|
@@ -752,8 +778,9 @@ add_filter( 'bp_activity_set_favorites_scope_args', 'bp_activity_filter_favorite
|
|
752 |
Â
*
|
753 |
Â
* @since BuddyPress (2.2.0)
|
754 |
Â
*
|
755 |
-
* @param array $retval Empty array by default
|
756 |
-
* @param array $filter Current activity arguments
|
Â
|
|
757 |
Â
* @return array
|
758 |
Â
*/
|
759 |
Â
function bp_activity_filter_mentions_scope( $retval = array(), $filter = array() ) {
|
179 |
Â
* @uses wp_kses()
|
180 |
Â
*
|
181 |
Â
* @param string $content The activity content.
|
182 |
+
*
|
183 |
Â
* @return string $content Filtered activity content.
|
184 |
Â
*/
|
185 |
Â
function bp_activity_filter_kses( $content ) {
|
210 |
Â
*
|
211 |
Â
* @since BuddyPress (1.2.0)
|
212 |
Â
*
|
213 |
+
* @param array $value Array of allowed HTML tags and attributes.
|
214 |
Â
*/
|
215 |
Â
$activity_allowedtags = apply_filters( 'bp_activity_allowed_tags', $activity_allowedtags );
|
216 |
Â
return wp_kses( $content, $activity_allowedtags );
|
221 |
Â
*
|
222 |
Â
* @since BuddyPress (1.2.0)
|
223 |
Â
*
|
224 |
+
* @param string $content The contents of a given item.
|
225 |
+
* @param int $activity_id The activity id. Deprecated.
|
226 |
+
*
|
227 |
Â
* @return string $content Content filtered for mentions.
|
228 |
Â
*/
|
229 |
Â
function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
|
320 |
Â
* @uses bp_activity_at_message_notification()
|
321 |
Â
* @uses bp_activity_update_mention_count_for_user()
|
322 |
Â
*
|
323 |
+
* @param BP_Activity_Activity $activity The BP_Activity_Activity object.
|
324 |
Â
*/
|
325 |
Â
function bp_activity_at_name_send_emails( $activity ) {
|
326 |
Â
// Are mentions disabled?
|
340 |
Â
|
341 |
Â
// Send @mentions and setup BP notifications
|
342 |
Â
foreach( (array) $usernames as $user_id => $username ) {
|
343 |
+
|
344 |
Â
/**
|
345 |
Â
* Filters BuddyPress' ability to send email notifications for @mentions.
|
346 |
Â
*
|
347 |
Â
* @since BuddyPress (1.6.0)
|
348 |
Â
*
|
349 |
+
* @param bool $value Whether or not BuddyPress should send a notification to the mentioned users.
|
350 |
Â
* @param array $usernames Array of users potentially notified.
|
351 |
Â
*/
|
352 |
Â
if ( apply_filters( 'bp_activity_at_name_do_notifications', true, $usernames ) ) {
|
364 |
Â
* @since BuddyPress (1.2.0)
|
365 |
Â
*
|
366 |
Â
* @param string $text Activity text.
|
367 |
+
*
|
368 |
Â
* @return string $text Text with rel=nofollow added to any links.
|
369 |
Â
*/
|
370 |
Â
function bp_activity_make_nofollow_filter( $text ) {
|
376 |
Â
*
|
377 |
Â
* @since BuddyPress (1.2.0)
|
378 |
Â
*
|
Â
|
|
Â
|
|
379 |
Â
* @param array $matches Items matched by preg_replace_callback() in bp_activity_make_nofollow_filter().
|
380 |
+
*
|
381 |
+
* @return string $text Link with rel=nofollow added.
|
382 |
Â
*/
|
383 |
Â
function bp_activity_make_nofollow_filter_callback( $matches ) {
|
384 |
Â
$text = $matches[1];
|
389 |
Â
/**
|
390 |
Â
* Truncate long activity entries when viewed in activity streams.
|
391 |
Â
*
|
392 |
+
* This method can only be used inside the Activity loop.
|
393 |
+
*
|
394 |
Â
* @since BuddyPress (1.5.0)
|
395 |
Â
*
|
396 |
Â
* @uses bp_is_single_activity()
|
402 |
Â
* @uses apply_filters() To call the 'bp_activity_truncate_entry' hook.
|
403 |
Â
*
|
404 |
Â
* @param string $text The original activity entry text.
|
405 |
+
*
|
406 |
Â
* @return string $excerpt The truncated text.
|
407 |
Â
*/
|
408 |
Â
function bp_activity_truncate_entry( $text ) {
|
409 |
Â
global $activities_template;
|
410 |
Â
|
411 |
+
/**
|
412 |
+
* Provides a filter that lets you choose whether to skip this filter on a per-activity basis.
|
413 |
+
*
|
414 |
+
* @since BuddyPress (2.3.0)
|
415 |
+
*
|
416 |
+
* @param bool $value If true, text should be checked to see if it needs truncating.
|
417 |
+
*/
|
418 |
+
$maybe_truncate_text = apply_filters(
|
419 |
+
'bp_activity_maybe_truncate_entry',
|
420 |
+
isset( $activities_template->activity->type ) && ! in_array( $activities_template->activity->type, array( 'new_blog_post', ), true )
|
421 |
+
);
|
422 |
+
|
423 |
Â
// The full text of the activity update should always show on the single activity screen
|
424 |
+
if ( ! $maybe_truncate_text || bp_is_single_activity() ) {
|
425 |
Â
return $text;
|
426 |
+
}
|
427 |
Â
|
428 |
Â
/**
|
429 |
Â
* Filters the appended text for the activity excerpt.
|
430 |
Â
*
|
431 |
Â
* @since BuddyPress (1.5.0)
|
432 |
Â
*
|
433 |
+
* @param string $value Internationalized "Read more" text.
|
434 |
Â
*/
|
435 |
Â
$append_text = apply_filters( 'bp_activity_excerpt_append_text', __( '[Read more]', 'buddypress' ) );
|
436 |
Â
|
439 |
Â
*
|
440 |
Â
* @since BuddyPress (1.5.0)
|
441 |
Â
*
|
442 |
+
* @param int $value Number indicating how many words to trim the excerpt down to.
|
443 |
Â
*/
|
444 |
Â
$excerpt_length = apply_filters( 'bp_activity_excerpt_length', 358 );
|
445 |
Â
|
461 |
Â
*
|
462 |
Â
* @since BuddyPress (1.5.0)
|
463 |
Â
*
|
464 |
+
* @param string $excerpt Excerpt text and markup to be displayed.
|
465 |
+
* @param string $text The original activity entry text.
|
466 |
Â
* @param string $append_text The final append text applied.
|
467 |
Â
*/
|
468 |
Â
return apply_filters( 'bp_activity_truncate_entry', $excerpt, $text, $append_text );
|
469 |
Â
}
|
470 |
Â
|
471 |
Â
/**
|
472 |
+
* Include extra JavaScript dependencies for activity component.
|
473 |
Â
*
|
474 |
Â
* @since BuddyPress (2.0.0)
|
475 |
Â
*
|
476 |
Â
* @uses bp_activity_do_heartbeat() to check if heartbeat is required.
|
477 |
Â
*
|
478 |
Â
* @param array $js_handles The original dependencies.
|
479 |
+
*
|
480 |
Â
* @return array $js_handles The new dependencies.
|
481 |
Â
*/
|
482 |
Â
function bp_activity_get_js_dependencies( $js_handles = array() ) {
|
497 |
Â
* @since BuddyPress (2.0.0)
|
498 |
Â
*
|
499 |
Â
* @param string $classes
|
500 |
+
*
|
501 |
Â
* @return string $classes
|
502 |
Â
*/
|
503 |
Â
function bp_activity_newest_class( $classes = '' ) {
|
517 |
Â
* @since BuddyPress (2.0.0)
|
518 |
Â
*
|
519 |
Â
* @param string $classes
|
520 |
+
*
|
521 |
Â
* @return string $classes
|
522 |
Â
*/
|
523 |
Â
function bp_activity_timestamp_class( $classes = '' ) {
|
543 |
Â
*
|
544 |
Â
* @since BuddyPress (2.0.0)
|
545 |
Â
*
|
546 |
+
* @uses bp_activity_get_last_updated() to get the recorded date of the last activity.
|
547 |
Â
*
|
548 |
Â
* @param array $response
|
549 |
Â
* @param array $data
|
550 |
+
*
|
551 |
Â
* @return array $response
|
552 |
Â
*/
|
553 |
Â
function bp_activity_heartbeat_last_recorded( $response = array(), $data = array() ) {
|
609 |
Â
* @since BuddyPress (2.0.0)
|
610 |
Â
*
|
611 |
Â
* @param array $strings Localized strings.
|
612 |
+
*
|
613 |
Â
* @return array $strings
|
614 |
Â
*/
|
615 |
Â
function bp_activity_heartbeat_strings( $strings = array() ) {
|
625 |
Â
*
|
626 |
Â
* @since BuddyPress (2.0.0)
|
627 |
Â
*
|
628 |
+
* @param array $value Heartbeat settings array.
|
629 |
Â
*/
|
630 |
Â
$heartbeat_settings = apply_filters( 'heartbeat_settings', array() );
|
631 |
Â
if ( ! empty( $heartbeat_settings['interval'] ) ) {
|
638 |
Â
*
|
639 |
Â
* @since BuddyPress (2.0.0)
|
640 |
Â
*
|
641 |
+
* @param int $value The frequency in seconds between pulses.
|
642 |
Â
*/
|
643 |
Â
$bp_activity_pulse = apply_filters( 'bp_activity_heartbeat_pulse', 15 );
|
644 |
Â
|
670 |
Â
*
|
671 |
Â
* @since BuddyPress (2.2.0)
|
672 |
Â
*
|
673 |
+
* @param array $retval Empty array by default.
|
674 |
+
* @param array $filter Current activity arguments.
|
675 |
+
*
|
676 |
Â
* @return array
|
677 |
Â
*/
|
678 |
Â
function bp_activity_filter_just_me_scope( $retval = array(), $filter = array() ) {
|
720 |
Â
*
|
721 |
Â
* @since BuddyPress (2.2.0)
|
722 |
Â
*
|
723 |
+
* @param array $retval Empty array by default.
|
724 |
+
* @param array $filter Current activity arguments.
|
725 |
+
*
|
726 |
Â
* @return array
|
727 |
Â
*/
|
728 |
Â
function bp_activity_filter_favorites_scope( $retval = array(), $filter = array() ) {
|
778 |
Â
*
|
779 |
Â
* @since BuddyPress (2.2.0)
|
780 |
Â
*
|
781 |
+
* @param array $retval Empty array by default.
|
782 |
+
* @param array $filter Current activity arguments.
|
783 |
+
*
|
784 |
Â
* @return array
|
785 |
Â
*/
|
786 |
Â
function bp_activity_filter_mentions_scope( $retval = array(), $filter = array() ) {
|
bp-activity/bp-activity-functions.php
CHANGED
@@ -28,10 +28,10 @@ function bp_activity_has_directory() {
|
|
28 |
Â
*
|
29 |
Â
* The Mentions feature does a number of things, all of which will be turned
|
30 |
Â
* off if you disable mentions:
|
31 |
-
* - Detecting and auto-linking @username in all BP/WP content
|
32 |
Â
* - Sending BP notifications and emails to users when they are mentioned
|
33 |
-
* using the @username syntax
|
34 |
-
* - The Public Message button on user profiles
|
35 |
Â
*
|
36 |
Â
* Mentions are enabled by default. To disable, put the following line in
|
37 |
Â
* bp-custom.php or your theme's functions.php file:
|
@@ -60,8 +60,9 @@ function bp_activity_do_mentions() {
|
|
60 |
Â
* Should BuddyPress load the mentions scripts and related assets, including results to prime the
|
61 |
Â
* mentions suggestions?
|
62 |
Â
*
|
63 |
-
* @return bool True if mentions scripts should be loaded.
|
64 |
Â
* @since BuddyPress (2.1.0)
|
Â
|
|
Â
|
|
65 |
Â
*/
|
66 |
Â
function bp_activity_maybe_load_mentions_scripts() {
|
67 |
Â
$mentions_enabled = bp_activity_do_mentions() && bp_is_user_active();
|
@@ -72,7 +73,7 @@ function bp_activity_maybe_load_mentions_scripts() {
|
|
72 |
Â
*
|
73 |
Â
* @since BuddyPress (2.1.0)
|
74 |
Â
*
|
75 |
-
* @param bool $load_mentions
|
76 |
Â
* @param bool $mentions_enabled True if mentions are enabled.
|
77 |
Â
*/
|
78 |
Â
return (bool) apply_filters( 'bp_activity_maybe_load_mentions_scripts', $load_mentions, $mentions_enabled );
|
@@ -84,9 +85,10 @@ function bp_activity_maybe_load_mentions_scripts() {
|
|
84 |
Â
* @since BuddyPress (1.5.0)
|
85 |
Â
*
|
86 |
Â
* @param string $content The content of the activity, usually found in
|
87 |
-
*
|
Â
|
|
88 |
Â
* @return array|bool Associative array with user ID as key and username as
|
89 |
-
*
|
90 |
Â
*/
|
91 |
Â
function bp_activity_find_mentions( $content ) {
|
92 |
Â
|
@@ -147,8 +149,10 @@ function bp_activity_clear_new_mentions( $user_id ) {
|
|
147 |
Â
* @uses bp_activity_find_mentions()
|
148 |
Â
* @uses bp_activity_update_mention_count_for_user()
|
149 |
Â
*
|
150 |
-
* @param int
|
151 |
-
* @param string $action
|
Â
|
|
Â
|
|
152 |
Â
*/
|
153 |
Â
function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
|
154 |
Â
|
@@ -185,9 +189,10 @@ function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
|
|
185 |
Â
* @uses bp_get_user_meta()
|
186 |
Â
* @uses bp_update_user_meta()
|
187 |
Â
*
|
188 |
-
* @param int
|
189 |
-
* @param int
|
190 |
-
* @param string $action
|
Â
|
|
191 |
Â
* @return bool
|
192 |
Â
*/
|
193 |
Â
function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action = 'add' ) {
|
@@ -239,6 +244,8 @@ function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $act
|
|
239 |
Â
*
|
240 |
Â
* @since BuddyPress (1.9.0)
|
241 |
Â
*
|
Â
|
|
Â
|
|
242 |
Â
* @return string User name appropriate for @-mentions.
|
243 |
Â
*/
|
244 |
Â
function bp_activity_get_user_mentionname( $user_id ) {
|
@@ -262,6 +269,8 @@ function bp_activity_get_user_mentionname( $user_id ) {
|
|
262 |
Â
*
|
263 |
Â
* @since BuddyPress (1.9.0)
|
264 |
Â
*
|
Â
|
|
Â
|
|
265 |
Â
* @return int|bool ID of the user, if one is found. Otherwise false.
|
266 |
Â
*/
|
267 |
Â
function bp_activity_get_userid_from_mentionname( $mentionname ) {
|
@@ -315,14 +324,15 @@ function bp_activity_get_userid_from_mentionname( $mentionname ) {
|
|
315 |
Â
*
|
316 |
Â
* @since BuddyPress (1.1.0)
|
317 |
Â
*
|
318 |
-
* @param string
|
319 |
-
* @param string
|
320 |
-
* @param string
|
321 |
-
* @param callable $format_callback Callback for formatting the action string.
|
322 |
-
* @param string $label String to describe this action in the activity stream filter dropdown.
|
323 |
-
* @param array
|
324 |
-
*
|
325 |
-
* @param int
|
Â
|
|
326 |
Â
* @return bool False if any param is empty, otherwise true.
|
327 |
Â
*/
|
328 |
Â
function bp_activity_set_action( $component_id, $type, $description, $format_callback = false, $label = false, $context = array(), $position = 0 ) {
|
@@ -352,14 +362,14 @@ function bp_activity_set_action( $component_id, $type, $description, $format_cal
|
|
352 |
Â
*
|
353 |
Â
* @since BuddyPress (1.1.0)
|
354 |
Â
*
|
355 |
-
* @param array $array
|
356 |
-
* @param string $component_id
|
357 |
-
* @param string $type
|
358 |
-
* @param string $description
|
359 |
Â
* @param callable $format_callback Callback for formatting the action string.
|
360 |
-
* @param string $label
|
361 |
-
* @param array $context
|
362 |
-
*
|
363 |
Â
*/
|
364 |
Â
$bp->activity->actions->{$component_id}->{$type} = apply_filters( 'bp_activity_set_action', array(
|
365 |
Â
'key' => $type,
|
@@ -398,17 +408,18 @@ function bp_activity_set_action( $component_id, $type, $description, $format_cal
|
|
398 |
Â
* @type callable $format_callback Callback for formatting the activity action string.
|
399 |
Â
* Default: 'bp_activity_format_activity_action_custom_post_type_post'.
|
400 |
Â
* @type array $contexts The directory contexts in which the filter will show.
|
401 |
-
* Default: array( 'activity' )
|
402 |
Â
* @type array $position Position of the item in filter dropdowns.
|
403 |
Â
* @type string $singular Singular, translatable name of the post type item. If no value is
|
404 |
Â
* provided, it's pulled from the 'singular_name' of the post type.
|
405 |
Â
* @type bool $activity_comment Whether to allow comments on the activity items. Defaults to true if
|
406 |
Â
* the post type does not natively support comments, otherwise false.
|
407 |
Â
* }
|
Â
|
|
Â
|
|
408 |
Â
*/
|
409 |
Â
function bp_activity_set_post_type_tracking_args( $post_type = '', $args = array() ) {
|
410 |
Â
global $wp_post_types;
|
411 |
-
$bp = buddypress();
|
412 |
Â
|
413 |
Â
if ( empty( $wp_post_types[ $post_type ] ) || ! post_type_supports( $post_type, 'buddypress-activity' ) || ! is_array( $args ) ) {
|
414 |
Â
return false;
|
@@ -433,7 +444,8 @@ function bp_activity_set_post_type_tracking_args( $post_type = '', $args = array
|
|
433 |
Â
*
|
434 |
Â
* @since BuddyPress (2.2.0)
|
435 |
Â
*
|
436 |
-
* @param string $post_type Name of the post type
|
Â
|
|
437 |
Â
* @return object The tracking arguments of the post type.
|
438 |
Â
*/
|
439 |
Â
function bp_activity_get_post_type_tracking_args( $post_type ) {
|
@@ -490,7 +502,7 @@ function bp_activity_get_post_type_tracking_args( $post_type ) {
|
|
490 |
Â
* @since BuddyPress (2.2.0)
|
491 |
Â
*
|
492 |
Â
* @param object $post_type_activity The tracking arguments of the post type.
|
493 |
-
* @param string $post_type
|
494 |
Â
*/
|
495 |
Â
return apply_filters( 'bp_activity_get_post_type_tracking_args', $post_type_activity, $post_type );
|
496 |
Â
}
|
@@ -533,7 +545,7 @@ function bp_activity_get_post_types_tracking_args() {
|
|
533 |
Â
*
|
534 |
Â
* @since BuddyPress (2.2.0)
|
535 |
Â
*
|
536 |
-
* @return object
|
537 |
Â
*/
|
538 |
Â
function bp_activity_get_actions() {
|
539 |
Â
$bp = buddypress();
|
@@ -582,7 +594,8 @@ function bp_activity_get_actions() {
|
|
582 |
Â
* @uses apply_filters() To call the 'bp_activity_get_action' hook.
|
583 |
Â
*
|
584 |
Â
* @param string $component_id The unique string ID of the component.
|
585 |
-
* @param string $key
|
Â
|
|
586 |
Â
* @return string|bool Action value if found, otherwise false.
|
587 |
Â
*/
|
588 |
Â
function bp_activity_get_action( $component_id, $key ) {
|
@@ -592,10 +605,9 @@ function bp_activity_get_action( $component_id, $key ) {
|
|
592 |
Â
return false;
|
593 |
Â
}
|
594 |
Â
|
595 |
-
$bp = buddypress();
|
596 |
Â
$actions = bp_activity_get_actions();
|
Â
|
|
597 |
Â
|
598 |
-
$retval = false;
|
599 |
Â
if ( isset( $actions->{$component_id}->{$key} ) ) {
|
600 |
Â
$retval = $actions->{$component_id}->{$key};
|
601 |
Â
}
|
@@ -655,6 +667,7 @@ function bp_activity_get_types() {
|
|
655 |
Â
* @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook.
|
656 |
Â
*
|
657 |
Â
* @param int $user_id ID of the user whose favorites are being queried.
|
Â
|
|
658 |
Â
* @return array IDs of the user's favorite activity items.
|
659 |
Â
*/
|
660 |
Â
function bp_activity_get_user_favorites( $user_id = 0 ) {
|
@@ -691,7 +704,8 @@ function bp_activity_get_user_favorites( $user_id = 0 ) {
|
|
691 |
Â
* @uses do_action() To call the 'bp_activity_add_user_favorite_fail' hook.
|
692 |
Â
*
|
693 |
Â
* @param int $activity_id ID of the activity item being favorited.
|
694 |
-
* @param int $user_id
|
Â
|
|
695 |
Â
* @return bool True on success, false on failure.
|
696 |
Â
*/
|
697 |
Â
function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
|
@@ -735,7 +749,7 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
|
|
735 |
Â
* @since BuddyPress (1.2.1)
|
736 |
Â
*
|
737 |
Â
* @param int $activity_id ID of the activity item being favorited.
|
738 |
-
* @param int $user_id
|
739 |
Â
*/
|
740 |
Â
do_action( 'bp_activity_add_user_favorite', $activity_id, $user_id );
|
741 |
Â
|
@@ -751,7 +765,7 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
|
|
751 |
Â
* @since BuddyPress (1.5.0)
|
752 |
Â
*
|
753 |
Â
* @param int $activity_id ID of the activity item being favorited.
|
754 |
-
* @param int $user_id
|
755 |
Â
*/
|
756 |
Â
do_action( 'bp_activity_add_user_favorite_fail', $activity_id, $user_id );
|
757 |
Â
|
@@ -772,7 +786,8 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
|
|
772 |
Â
* @uses do_action() To call the 'bp_activity_remove_user_favorite' hook.
|
773 |
Â
*
|
774 |
Â
* @param int $activity_id ID of the activity item being unfavorited.
|
775 |
-
* @param int $user_id
|
Â
|
|
776 |
Â
* @return bool True on success, false on failure.
|
777 |
Â
*/
|
778 |
Â
function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
|
@@ -815,7 +830,7 @@ function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
|
|
815 |
Â
* @since BuddyPress (1.2.1)
|
816 |
Â
*
|
817 |
Â
* @param int $activity_id ID of the activity item being unfavorited.
|
818 |
-
* @param int $user_id
|
819 |
Â
*/
|
820 |
Â
do_action( 'bp_activity_remove_user_favorite', $activity_id, $user_id );
|
821 |
Â
|
@@ -847,6 +862,7 @@ function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
|
|
847 |
Â
* @uses apply_filters() To call the 'bp_activity_check_exists_by_content' hook.
|
848 |
Â
*
|
849 |
Â
* @param string $content The content to filter by.
|
Â
|
|
850 |
Â
* @return int|null The ID of the located activity item. Null if none is found.
|
851 |
Â
*/
|
852 |
Â
function bp_activity_check_exists_by_content( $content ) {
|
@@ -891,6 +907,7 @@ function bp_activity_get_last_updated() {
|
|
891 |
Â
* @uses BP_Activity_Activity::total_favorite_count() {@link BP_Activity_Activity}
|
892 |
Â
*
|
893 |
Â
* @param int $user_id ID of the user whose favorite count is being requested.
|
Â
|
|
894 |
Â
* @return int Total favorite count for the user.
|
895 |
Â
*/
|
896 |
Â
function bp_activity_total_favorites_for_user( $user_id = 0 ) {
|
@@ -911,18 +928,18 @@ function bp_activity_total_favorites_for_user( $user_id = 0 ) {
|
|
911 |
Â
* @since BuddyPress (1.2.0)
|
912 |
Â
*
|
913 |
Â
* @global object $wpdb WordPress database access object.
|
914 |
-
*
|
915 |
-
*
|
916 |
-
* @param
|
917 |
-
*
|
918 |
-
*
|
919 |
-
*
|
920 |
-
*
|
921 |
-
*
|
922 |
-
*
|
923 |
-
*
|
924 |
-
*
|
925 |
-
*
|
926 |
Â
* @return bool True on success, false on failure.
|
927 |
Â
*/
|
928 |
Â
function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '', $delete_all = false ) {
|
@@ -956,13 +973,14 @@ function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = ''
|
|
956 |
Â
*
|
957 |
Â
* @uses apply_filters() To call the 'bp_activity_get_meta' hook.
|
958 |
Â
*
|
959 |
-
* @param int
|
960 |
-
* @param string $meta_key
|
961 |
-
*
|
962 |
-
*
|
963 |
-
* @param bool
|
964 |
-
*
|
965 |
-
*
|
Â
|
|
966 |
Â
* @return mixed The meta value(s) being requested.
|
967 |
Â
*/
|
968 |
Â
function bp_activity_get_meta( $activity_id = 0, $meta_key = '', $single = true ) {
|
@@ -975,10 +993,10 @@ function bp_activity_get_meta( $activity_id = 0, $meta_key = '', $single = true
|
|
975 |
Â
*
|
976 |
Â
* @since BuddyPress (1.5.0)
|
977 |
Â
*
|
978 |
-
* @param mixed $retval
|
979 |
Â
* @param int $activity_id ID of the activity item.
|
980 |
-
* @param string $meta_key
|
981 |
-
* @param bool $single
|
982 |
Â
*/
|
983 |
Â
return apply_filters( 'bp_activity_get_meta', $retval, $activity_id, $meta_key, $single );
|
984 |
Â
}
|
@@ -988,16 +1006,15 @@ function bp_activity_get_meta( $activity_id = 0, $meta_key = '', $single = true
|
|
988 |
Â
*
|
989 |
Â
* @since BuddyPress (1.2.0)
|
990 |
Â
*
|
991 |
-
* @param int
|
992 |
-
*
|
993 |
-
* @param
|
994 |
-
* @param mixed
|
995 |
-
*
|
996 |
-
*
|
997 |
-
* entries.
|
998 |
Â
* @return bool|int Returns false on failure. On successful update of existing
|
999 |
-
*
|
1000 |
-
*
|
1001 |
Â
*/
|
1002 |
Â
function bp_activity_update_meta( $activity_id, $meta_key, $meta_value, $prev_value = '' ) {
|
1003 |
Â
add_filter( 'query', 'bp_filter_metaid_column_name' );
|
@@ -1012,12 +1029,13 @@ function bp_activity_update_meta( $activity_id, $meta_key, $meta_value, $prev_va
|
|
1012 |
Â
*
|
1013 |
Â
* @since BuddyPress (2.0.0)
|
1014 |
Â
*
|
1015 |
-
* @param int
|
1016 |
-
* @param string $meta_key
|
1017 |
-
* @param mixed
|
1018 |
-
* @param bool
|
1019 |
-
*
|
1020 |
-
*
|
Â
|
|
1021 |
Â
* @return int|bool The meta ID on successful update, false on failure.
|
1022 |
Â
*/
|
1023 |
Â
function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = false ) {
|
@@ -1042,6 +1060,8 @@ function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = f
|
|
1042 |
Â
* @uses do_action() To call the 'bp_activity_remove_all_user_data' hook.
|
1043 |
Â
*
|
1044 |
Â
* @param int $user_id ID of the user whose activity is being deleted.
|
Â
|
|
Â
|
|
1045 |
Â
*/
|
1046 |
Â
function bp_activity_remove_all_user_data( $user_id = 0 ) {
|
1047 |
Â
|
@@ -1078,9 +1098,10 @@ add_action( 'delete_user', 'bp_activity_remove_all_user_data' );
|
|
1078 |
Â
* @since BuddyPress (1.6.0)
|
1079 |
Â
*
|
1080 |
Â
* @global object $wpdb WordPress database access object.
|
1081 |
-
* @global object $bp BuddyPress global settings.
|
1082 |
Â
*
|
1083 |
Â
* @param int $user_id ID of the user whose activity is being spammed.
|
Â
|
|
Â
|
|
1084 |
Â
*/
|
1085 |
Â
function bp_activity_spam_all_user_data( $user_id = 0 ) {
|
1086 |
Â
global $wpdb;
|
@@ -1134,7 +1155,7 @@ function bp_activity_spam_all_user_data( $user_id = 0 ) {
|
|
1134 |
Â
*
|
1135 |
Â
* @since BuddyPress (1.6.0)
|
1136 |
Â
*
|
1137 |
-
* @param int $user_id
|
1138 |
Â
* @param array $activities Array of activity items being marked as spam.
|
1139 |
Â
*/
|
1140 |
Â
do_action( 'bp_activity_spam_all_user_data', $user_id, $activities['activities'] );
|
@@ -1147,9 +1168,10 @@ add_action( 'bp_make_spam_user', 'bp_activity_spam_all_user_data' );
|
|
1147 |
Â
* @since BuddyPress (1.6.0)
|
1148 |
Â
*
|
1149 |
Â
* @global object $wpdb WordPress database access object.
|
1150 |
-
* @global object $bp BuddyPress global settings.
|
1151 |
Â
*
|
1152 |
Â
* @param int $user_id ID of the user whose activity is being hammed.
|
Â
|
|
Â
|
|
1153 |
Â
*/
|
1154 |
Â
function bp_activity_ham_all_user_data( $user_id = 0 ) {
|
1155 |
Â
global $wpdb;
|
@@ -1204,7 +1226,7 @@ function bp_activity_ham_all_user_data( $user_id = 0 ) {
|
|
1204 |
Â
*
|
1205 |
Â
* @since BuddyPress (1.6.0)
|
1206 |
Â
*
|
1207 |
-
* @param int $user_id
|
1208 |
Â
* @param array $activities Array of activity items being marked as ham.
|
1209 |
Â
*/
|
1210 |
Â
do_action( 'bp_activity_ham_all_user_data', $user_id, $activities['activities'] );
|
@@ -1212,7 +1234,7 @@ function bp_activity_ham_all_user_data( $user_id = 0 ) {
|
|
1212 |
Â
add_action( 'bp_make_ham_user', 'bp_activity_ham_all_user_data' );
|
1213 |
Â
|
1214 |
Â
/**
|
1215 |
-
* Register the activity stream actions for updates
|
1216 |
Â
*
|
1217 |
Â
* @since BuddyPress (1.6.0)
|
1218 |
Â
*/
|
@@ -1254,8 +1276,9 @@ add_action( 'bp_register_activity_actions', 'bp_activity_register_activity_actio
|
|
1254 |
Â
* Generate an activity action string for an activity item.
|
1255 |
Â
*
|
1256 |
Â
* @param object $activity Activity data object.
|
Â
|
|
1257 |
Â
* @return string|bool Returns false if no callback is found, otherwise returns
|
1258 |
-
*
|
1259 |
Â
*/
|
1260 |
Â
function bp_activity_generate_action_string( $activity ) {
|
1261 |
Â
|
@@ -1278,7 +1301,7 @@ function bp_activity_generate_action_string( $activity ) {
|
|
1278 |
Â
*
|
1279 |
Â
* @since BuddyPress (2.0.0)
|
1280 |
Â
*
|
1281 |
-
* @param BP_Activity_Activity $action
|
1282 |
Â
* @param BP_Activity_Activity $activity Activity item object.
|
1283 |
Â
*/
|
1284 |
Â
$action = apply_filters( 'bp_activity_generate_action_string', $activity->action, $activity );
|
@@ -1294,8 +1317,9 @@ function bp_activity_generate_action_string( $activity ) {
|
|
1294 |
Â
*
|
1295 |
Â
* @since BuddyPress (2.0.0)
|
1296 |
Â
*
|
1297 |
-
* @param string $action
|
1298 |
Â
* @param object $activity Activity data object.
|
Â
|
|
1299 |
Â
* @return string
|
1300 |
Â
*/
|
1301 |
Â
function bp_activity_format_activity_action_activity_update( $action, $activity ) {
|
@@ -1306,7 +1330,7 @@ function bp_activity_format_activity_action_activity_update( $action, $activity
|
|
1306 |
Â
*
|
1307 |
Â
* @since BuddyPress (1.2.0)
|
1308 |
Â
*
|
1309 |
-
* @param string $action
|
1310 |
Â
* @param BP_Activity_Activity $activity Activity item object.
|
1311 |
Â
*/
|
1312 |
Â
return apply_filters( 'bp_activity_new_update_action', $action, $activity );
|
@@ -1317,8 +1341,9 @@ function bp_activity_format_activity_action_activity_update( $action, $activity
|
|
1317 |
Â
*
|
1318 |
Â
* @since BuddyPress (2.0.0)
|
1319 |
Â
*
|
1320 |
-
* @param string $action
|
1321 |
Â
* @param object $activity Activity data object.
|
Â
|
|
1322 |
Â
* @return string
|
1323 |
Â
*/
|
1324 |
Â
function bp_activity_format_activity_action_activity_comment( $action, $activity ) {
|
@@ -1329,7 +1354,7 @@ function bp_activity_format_activity_action_activity_comment( $action, $activity
|
|
1329 |
Â
*
|
1330 |
Â
* @since BuddyPress (1.2.0)
|
1331 |
Â
*
|
1332 |
-
* @param string $action
|
1333 |
Â
* @param BP_Activity_Activity $activity Activity item object.
|
1334 |
Â
*/
|
1335 |
Â
return apply_filters( 'bp_activity_comment_action', $action, $activity );
|
@@ -1342,6 +1367,7 @@ function bp_activity_format_activity_action_activity_comment( $action, $activity
|
|
1342 |
Â
*
|
1343 |
Â
* @param string $action Static activity action.
|
1344 |
Â
* @param object $activity Activity data object.
|
Â
|
|
1345 |
Â
* @return string
|
1346 |
Â
*/
|
1347 |
Â
function bp_activity_format_activity_action_custom_post_type_post( $action, $activity ) {
|
@@ -1386,7 +1412,7 @@ function bp_activity_format_activity_action_custom_post_type_post( $action, $act
|
|
1386 |
Â
*
|
1387 |
Â
* @since BuddyPress (2.2.0)
|
1388 |
Â
*
|
1389 |
-
* @param string $action
|
1390 |
Â
* @param BP_Activity_Activity $activity Activity item object.
|
1391 |
Â
*/
|
1392 |
Â
return apply_filters( 'bp_activity_custom_post_type_post_action', $action, $activity );
|
@@ -1418,7 +1444,8 @@ function bp_activity_format_activity_action_custom_post_type_post( $action, $act
|
|
1418 |
Â
* @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
|
1419 |
Â
* @uses apply_filters_ref_array() To call the 'bp_activity_get' hook.
|
1420 |
Â
*
|
1421 |
-
* @param array $args See BP_Activity_Activity::get() for description.
|
Â
|
|
1422 |
Â
* @return array $activity See BP_Activity_Activity::get() for description.
|
1423 |
Â
*/
|
1424 |
Â
function bp_activity_get( $args = '' ) {
|
@@ -1509,7 +1536,7 @@ function bp_activity_get( $args = '' ) {
|
|
1509 |
Â
* @since BuddyPress (1.2.0)
|
1510 |
Â
*
|
1511 |
Â
* @param BP_Activity_Activity $activity Requested activity object.
|
1512 |
-
* @param array $r
|
1513 |
Â
*/
|
1514 |
Â
return apply_filters_ref_array( 'bp_activity_get', array( &$activity, &$r ) );
|
1515 |
Â
}
|
@@ -1519,12 +1546,12 @@ function bp_activity_get( $args = '' ) {
|
|
1519 |
Â
*
|
1520 |
Â
* @since BuddyPress (1.2.0)
|
1521 |
Â
*
|
1522 |
-
* @see BP_Activity_Activity::get() For more information on accepted arguments
|
1523 |
Â
* @uses wp_parse_args()
|
1524 |
-
* @uses apply_filters() To call the 'bp_activity_get_specific' hook
|
1525 |
Â
* @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
|
1526 |
Â
*
|
1527 |
-
* @param array $args {
|
1528 |
Â
* All arguments and defaults are shared with BP_Activity_Activity::get(),
|
1529 |
Â
* except for the following:
|
1530 |
Â
* @type string|int|array Single activity ID, comma-separated list of IDs,
|
@@ -1564,7 +1591,7 @@ function bp_activity_get_specific( $args = '' ) {
|
|
1564 |
Â
* @since BuddyPress (1.2.0)
|
1565 |
Â
*
|
1566 |
Â
* @param BP_Activity_Activity $activity Requested activity object.
|
1567 |
-
* @param array $args
|
1568 |
Â
* @param array $get_args Constructed arguments used with request.
|
1569 |
Â
*/
|
1570 |
Â
return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $get_args ), $args, $get_args );
|
@@ -1579,38 +1606,38 @@ function bp_activity_get_specific( $args = '' ) {
|
|
1579 |
Â
* @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
|
1580 |
Â
* @uses BP_Activity_Activity::rebuild_activity_comment_tree() {@link BP_Activity_Activity}
|
1581 |
Â
* @uses wp_cache_delete()
|
1582 |
-
* @uses do_action() To call the 'bp_activity_add' hook
|
1583 |
Â
*
|
1584 |
-
* @param array $args {
|
1585 |
Â
* An array of arguments.
|
1586 |
-
* @type int|bool $id
|
1587 |
-
*
|
1588 |
-
* @type string
|
1589 |
-
*
|
1590 |
-
*
|
1591 |
-
*
|
1592 |
-
*
|
1593 |
-
*
|
1594 |
-
*
|
1595 |
-
*
|
1596 |
-
* @type string
|
1597 |
-
* @type string
|
1598 |
-
*
|
1599 |
-
* @type string
|
1600 |
-
*
|
1601 |
-
* @type string
|
1602 |
-
*
|
1603 |
-
*
|
1604 |
-
*
|
1605 |
-
*
|
1606 |
-
*
|
1607 |
-
* @type int
|
1608 |
-
*
|
1609 |
-
* @type string
|
1610 |
-
*
|
1611 |
-
* @type bool
|
1612 |
-
*
|
1613 |
-
* @type bool
|
1614 |
Â
* }
|
1615 |
Â
* @return int|bool The ID of the activity on success. False on error.
|
1616 |
Â
*/
|
@@ -1629,7 +1656,7 @@ function bp_activity_add( $args = '' ) {
|
|
1629 |
Â
'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded
|
1630 |
Â
'hide_sitewide' => false, // Should this be hidden on the sitewide activity stream?
|
1631 |
Â
'is_spam' => false, // Is this activity item to be marked as spam?
|
1632 |
-
) );
|
1633 |
Â
|
1634 |
Â
// Make sure we are backwards compatible
|
1635 |
Â
if ( empty( $r['component'] ) && !empty( $r['component_name'] ) ) {
|
@@ -1698,11 +1725,11 @@ function bp_activity_add( $args = '' ) {
|
|
1698 |
Â
* @uses wp_filter_kses()
|
1699 |
Â
* @uses do_action() To call the 'bp_activity_posted_update' hook.
|
1700 |
Â
*
|
1701 |
-
* @param array $args {
|
1702 |
Â
* @type string $content The content of the activity update.
|
1703 |
-
* @type int
|
1704 |
Â
* }
|
1705 |
-
* @return int $activity_id The activity id
|
1706 |
Â
*/
|
1707 |
Â
function bp_activity_post_update( $args = '' ) {
|
1708 |
Â
|
@@ -1755,7 +1782,7 @@ function bp_activity_post_update( $args = '' ) {
|
|
1755 |
Â
*
|
1756 |
Â
* @since BuddyPress (1.6.0)
|
1757 |
Â
*
|
1758 |
-
* @param string $r
|
1759 |
Â
* @param string $activity_content Content of the activity update.
|
1760 |
Â
*/
|
1761 |
Â
$activity_content = apply_filters( 'bp_activity_latest_update_content', $r['content'], $activity_content );
|
@@ -1771,8 +1798,8 @@ function bp_activity_post_update( $args = '' ) {
|
|
1771 |
Â
*
|
1772 |
Â
* @since BuddyPress (1.2.0)
|
1773 |
Â
*
|
1774 |
-
* @param string $content
|
1775 |
-
* @param int $user_id
|
1776 |
Â
* @param int $activity_id ID of the activity item being updated.
|
1777 |
Â
*/
|
1778 |
Â
do_action( 'bp_activity_posted_update', $r['content'], $r['user_id'], $activity_id );
|
@@ -1788,10 +1815,10 @@ function bp_activity_post_update( $args = '' ) {
|
|
1788 |
Â
* @param int $post_id ID of the new post.
|
1789 |
Â
* @param WP_Post $post Post object.
|
1790 |
Â
* @param int $user_id ID of the post author.
|
Â
|
|
1791 |
Â
* @return int|bool The ID of the activity on success. False on error.
|
1792 |
Â
*/
|
1793 |
Â
function bp_activity_post_type_publish( $post_id = 0, $post = null, $user_id = 0 ) {
|
1794 |
-
$bp = buddypress();
|
1795 |
Â
|
1796 |
Â
if ( ! is_a( $post, 'WP_Post' ) ) {
|
1797 |
Â
return;
|
@@ -1872,20 +1899,15 @@ function bp_activity_post_type_publish( $post_id = 0, $post = null, $user_id = 0
|
|
1872 |
Â
'recorded_time' => $post->post_date_gmt,
|
1873 |
Â
);
|
1874 |
Â
|
1875 |
-
// Remove large images and replace them with just one image thumbnail.
|
1876 |
-
if ( ! empty( $activity_args['content'] ) ) {
|
1877 |
-
$activity_args['content'] = bp_activity_thumbnail_content_images( $activity_args['content'], $activity_args['primary_link'], $activity_args );
|
1878 |
-
}
|
1879 |
-
|
1880 |
Â
if ( ! empty( $activity_args['content'] ) ) {
|
1881 |
Â
// Create the excerpt.
|
1882 |
-
$
|
1883 |
Â
|
1884 |
Â
// Backward compatibility filter for blog posts.
|
1885 |
Â
if ( 'blogs' == $activity_post_object->component_id ) {
|
1886 |
-
$activity_args['content'] = apply_filters( 'bp_blogs_record_activity_content', $
|
1887 |
Â
} else {
|
1888 |
-
$activity_args['content'] = $
|
1889 |
Â
}
|
1890 |
Â
}
|
1891 |
Â
|
@@ -1929,10 +1951,10 @@ function bp_activity_post_type_publish( $post_id = 0, $post = null, $user_id = 0
|
|
1929 |
Â
* @since BuddyPress (2.2.0)
|
1930 |
Â
*
|
1931 |
Â
* @param WP_Post $post Post item.
|
Â
|
|
1932 |
Â
* @return bool True on success, false on failure.
|
1933 |
Â
*/
|
1934 |
Â
function bp_activity_post_type_update( $post = null ) {
|
1935 |
-
$bp = buddypress();
|
1936 |
Â
|
1937 |
Â
if ( ! is_a( $post, 'WP_Post' ) ) {
|
1938 |
Â
return;
|
@@ -1966,17 +1988,13 @@ function bp_activity_post_type_update( $post = null ) {
|
|
1966 |
Â
$activity = new BP_Activity_Activity( $activity_id );
|
1967 |
Â
|
1968 |
Â
if ( ! empty( $post->post_content ) ) {
|
1969 |
-
|
1970 |
-
$post_content = bp_activity_thumbnail_content_images( $post->post_content, $activity->primary_link, (array) $activity );
|
1971 |
-
|
1972 |
-
// Generate an excerpt.
|
1973 |
-
$activity_excerpt = bp_create_excerpt( $post_content );
|
1974 |
Â
|
1975 |
Â
// Backward compatibility filter for the blogs component.
|
1976 |
Â
if ( 'blogs' == $activity_post_object->component_id ) {
|
1977 |
-
$activity->content = apply_filters( 'bp_blogs_record_activity_content', $
|
1978 |
Â
} else {
|
1979 |
-
$activity->content = $
|
1980 |
Â
}
|
1981 |
Â
}
|
1982 |
Â
|
@@ -1988,7 +2006,7 @@ function bp_activity_post_type_update( $post = null ) {
|
|
1988 |
Â
*
|
1989 |
Â
* @since BuddyPress (2.2.0)
|
1990 |
Â
*
|
1991 |
-
* @param WP_Post $post
|
1992 |
Â
* @param BP_Activity_Activity $activity Activity object.
|
1993 |
Â
*/
|
1994 |
Â
do_action( 'bp_activity_post_type_updated', $post, $activity );
|
@@ -2003,10 +2021,10 @@ function bp_activity_post_type_update( $post = null ) {
|
|
2003 |
Â
*
|
2004 |
Â
* @param int $post_id ID of the post being unpublished.
|
2005 |
Â
* @param WP_Post $post Post object.
|
Â
|
|
2006 |
Â
* @return bool True on success, false on failure.
|
2007 |
Â
*/
|
2008 |
Â
function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
|
2009 |
-
$bp = buddypress();
|
2010 |
Â
|
2011 |
Â
if ( ! is_a( $post, 'WP_Post' ) ) {
|
2012 |
Â
return;
|
@@ -2040,8 +2058,7 @@ function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
|
|
2040 |
Â
*
|
2041 |
Â
* @param array $delete_activity_args Array of arguments for activity deletion.
|
2042 |
Â
* @param WP_Post $post Post object.
|
2043 |
-
* @param bool $activity Whether or not the activity
|
2044 |
-
* was successfully deleted.
|
2045 |
Â
*/
|
2046 |
Â
do_action( 'bp_activity_post_type_unpublished', $delete_activity_args, $post, $deleted );
|
2047 |
Â
|
@@ -2053,7 +2070,6 @@ function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
|
|
2053 |
Â
*
|
2054 |
Â
* @since BuddyPress (1.2.0)
|
2055 |
Â
*
|
2056 |
-
* @global object $bp BuddyPress global settings.
|
2057 |
Â
* @uses wp_parse_args()
|
2058 |
Â
* @uses bp_activity_add()
|
2059 |
Â
* @uses apply_filters() To call the 'bp_activity_comment_action' hook.
|
@@ -2061,16 +2077,16 @@ function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
|
|
2061 |
Â
* @uses wp_cache_delete()
|
2062 |
Â
* @uses do_action() To call the 'bp_activity_comment_posted' hook.
|
2063 |
Â
*
|
2064 |
-
* @param array $args {
|
2065 |
-
* @type int
|
2066 |
-
* @type string $content
|
2067 |
-
* @type int
|
2068 |
-
*
|
2069 |
-
* @type int
|
2070 |
-
*
|
2071 |
-
* @type int
|
2072 |
-
*
|
2073 |
-
*
|
2074 |
Â
* }
|
2075 |
Â
* @return int|bool The ID of the comment on success, otherwise false.
|
2076 |
Â
*/
|
@@ -2159,8 +2175,8 @@ function bp_activity_new_comment( $args = '' ) {
|
|
2159 |
Â
* @since BuddyPress (1.2.0)
|
2160 |
Â
*
|
2161 |
Â
* @param int $comment_id ID of the newly posted activity comment.
|
2162 |
-
* @param array $r
|
2163 |
-
* @param int $activity
|
2164 |
Â
*/
|
2165 |
Â
do_action( 'bp_activity_comment_posted', $comment_id, $r, $activity );
|
2166 |
Â
|
@@ -2182,7 +2198,8 @@ function bp_activity_new_comment( $args = '' ) {
|
|
2182 |
Â
* @uses apply_filters() To call the 'bp_activity_get_activity_id' hook.
|
2183 |
Â
* @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
|
2184 |
Â
*
|
2185 |
-
* @param array $args See BP_Activity_Activity::get() for description.
|
Â
|
|
2186 |
Â
* @return int $activity_id The ID of the activity item found.
|
2187 |
Â
*/
|
2188 |
Â
function bp_activity_get_activity_id( $args = '' ) {
|
@@ -2203,7 +2220,7 @@ function bp_activity_get_activity_id( $args = '' ) {
|
|
2203 |
Â
*
|
2204 |
Â
* @since BuddyPress (1.2.0)
|
2205 |
Â
*
|
2206 |
-
* @param BP_Activity_Activity ID returned by BP_Activity_Activity get_id() method with provided arguments.
|
2207 |
Â
*/
|
2208 |
Â
return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id(
|
2209 |
Â
$r['user_id'],
|
@@ -2243,10 +2260,12 @@ function bp_activity_get_activity_id( $args = '' ) {
|
|
2243 |
Â
* @uses do_action() To call the 'bp_activity_deleted_activities' hook.
|
2244 |
Â
* @uses wp_cache_delete()
|
2245 |
Â
*
|
2246 |
-
* @param array $args To delete specific activity items, use
|
2247 |
-
*
|
2248 |
-
*
|
2249 |
-
*
|
Â
|
|
Â
|
|
2250 |
Â
* @return bool True on success, false on failure.
|
2251 |
Â
*/
|
2252 |
Â
function bp_activity_delete( $args = '' ) {
|
@@ -2329,8 +2348,8 @@ function bp_activity_delete( $args = '' ) {
|
|
2329 |
Â
* @uses wp_parse_args()
|
2330 |
Â
* @uses bp_activity_delete()
|
2331 |
Â
*
|
2332 |
-
* @param array $args See BP_Activity_Activity::get for a
|
2333 |
-
*
|
2334 |
Â
*
|
2335 |
Â
* @return bool True on success, false on failure.
|
2336 |
Â
*/
|
@@ -2354,7 +2373,8 @@ function bp_activity_delete( $args = '' ) {
|
|
2354 |
Â
*
|
2355 |
Â
* @uses bp_activity_delete()
|
2356 |
Â
*
|
2357 |
-
* @param int ID of the activity item to be deleted.
|
Â
|
|
2358 |
Â
* @return bool True on success, false on failure.
|
2359 |
Â
*/
|
2360 |
Â
function bp_activity_delete_by_activity_id( $activity_id ) {
|
@@ -2371,10 +2391,11 @@ function bp_activity_delete( $args = '' ) {
|
|
2371 |
Â
*
|
2372 |
Â
* @uses bp_activity_delete()
|
2373 |
Â
*
|
2374 |
-
* @param int
|
2375 |
-
* @param string $content
|
2376 |
Â
* @param string $component The activity component.
|
2377 |
-
* @param string $type
|
Â
|
|
2378 |
Â
* @return bool True on success, false on failure.
|
2379 |
Â
*/
|
2380 |
Â
function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
|
@@ -2396,8 +2417,9 @@ function bp_activity_delete( $args = '' ) {
|
|
2396 |
Â
*
|
2397 |
Â
* @uses bp_activity_delete()
|
2398 |
Â
*
|
2399 |
-
* @param int
|
2400 |
Â
* @param string $component The activity component.
|
Â
|
|
2401 |
Â
* @return bool True on success, false on failure.
|
2402 |
Â
*/
|
2403 |
Â
function bp_activity_delete_for_user_by_component( $user_id, $component ) {
|
@@ -2424,8 +2446,9 @@ function bp_activity_delete( $args = '' ) {
|
|
2424 |
Â
*
|
2425 |
Â
* @param int $activity_id The ID of the "root" activity, ie the comment's
|
2426 |
Â
* oldest ancestor.
|
2427 |
-
* @param int $comment_id
|
2428 |
-
*
|
Â
|
|
2429 |
Â
*/
|
2430 |
Â
function bp_activity_delete_comment( $activity_id, $comment_id ) {
|
2431 |
Â
|
@@ -2437,9 +2460,9 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
|
|
2437 |
Â
*
|
2438 |
Â
* @since BuddyPress (1.2.0)
|
2439 |
Â
*
|
2440 |
-
* @param bool $value
|
2441 |
Â
* @param int $activity_id ID of the root activity item being deleted.
|
2442 |
-
* @param int $comment_id
|
2443 |
Â
*/
|
2444 |
Â
if ( ! apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) ) {
|
2445 |
Â
return false;
|
@@ -2465,7 +2488,7 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
|
|
2465 |
Â
* @since BuddyPress (1.2.0)
|
2466 |
Â
*
|
2467 |
Â
* @param int $activity_id ID of the activity that has had a comment deleted from.
|
2468 |
-
* @param int $comment_id
|
2469 |
Â
*/
|
2470 |
Â
do_action( 'bp_activity_delete_comment', $activity_id, $comment_id );
|
2471 |
Â
|
@@ -2482,8 +2505,8 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
|
|
2482 |
Â
* @uses bp_activity_delete()
|
2483 |
Â
*
|
2484 |
Â
* @param int $activity_id The ID of the "root" activity, ie the
|
2485 |
-
*
|
2486 |
-
* @param int $comment_id
|
2487 |
Â
*/
|
2488 |
Â
function bp_activity_delete_children( $activity_id, $comment_id ) {
|
2489 |
Â
|
@@ -2519,8 +2542,9 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
|
|
2519 |
Â
* @uses bp_get_activity_root_slug()
|
2520 |
Â
* @uses apply_filters_ref_array() To call the 'bp_activity_get_permalink' hook.
|
2521 |
Â
*
|
2522 |
-
* @param int
|
2523 |
-
* @param object $activity_obj Optional. The activity object.
|
Â
|
|
2524 |
Â
* @return string $link Permalink for the activity item.
|
2525 |
Â
*/
|
2526 |
Â
function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
|
@@ -2573,6 +2597,7 @@ function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
|
|
2573 |
Â
* @uses BP_Activity_Activity::hide_all_for_user() {@link BP_Activity_Activity}
|
2574 |
Â
*
|
2575 |
Â
* @param int $user_id The ID of the user whose activity is being hidden.
|
Â
|
|
2576 |
Â
* @return bool True on success, false on failure.
|
2577 |
Â
*/
|
2578 |
Â
function bp_activity_hide_user_activity( $user_id ) {
|
@@ -2589,18 +2614,21 @@ function bp_activity_hide_user_activity( $user_id ) {
|
|
2589 |
Â
* through the content, grabs the first image and converts it to a thumbnail,
|
2590 |
Â
* and removes the rest of the images from the string.
|
2591 |
Â
*
|
Â
|
|
Â
|
|
2592 |
Â
* @since BuddyPress (1.2.0)
|
2593 |
Â
*
|
2594 |
Â
* @uses esc_attr()
|
2595 |
-
* @uses apply_filters() To call the 'bp_activity_thumbnail_content_images' hook
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2596 |
Â
*
|
2597 |
-
* @param string $content The content of the activity item.
|
2598 |
-
* @param string $link Optional. The unescaped URL that the image should link
|
2599 |
-
* to. If absent, the image will not be a link.
|
2600 |
-
* @param array $args Optional. The args passed to the activity
|
2601 |
-
* creation function (eg bp_blogs_record_activity()).
|
2602 |
Â
* @return string $content The content with images stripped and replaced with a
|
2603 |
-
*
|
2604 |
Â
*/
|
2605 |
Â
function bp_activity_thumbnail_content_images( $content, $link = false, $args = false ) {
|
2606 |
Â
|
@@ -2618,10 +2646,16 @@ function bp_activity_thumbnail_content_images( $content, $link = false, $args =
|
|
2618 |
Â
preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height );
|
2619 |
Â
preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width );
|
2620 |
Â
|
2621 |
-
if ( !empty( $src ) ) {
|
2622 |
-
$src
|
2623 |
-
|
2624 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2625 |
Â
|
2626 |
Â
if ( empty( $width ) || empty( $height ) ) {
|
2627 |
Â
$width = 100;
|
@@ -2648,11 +2682,173 @@ function bp_activity_thumbnail_content_images( $content, $link = false, $args =
|
|
2648 |
Â
*
|
2649 |
Â
* @param string $content Activity content that had images replaced in.
|
2650 |
Â
* @param array $matches Array of all image tags found in the posted content.
|
2651 |
-
* @param array $args
|
2652 |
Â
*/
|
2653 |
Â
return apply_filters( 'bp_activity_thumbnail_content_images', $content, $matches, $args );
|
2654 |
Â
}
|
2655 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2656 |
Â
/**
|
2657 |
Â
* Fetch whether the current user is allowed to mark items as spam.
|
2658 |
Â
*
|
@@ -2678,9 +2874,9 @@ function bp_activity_user_can_mark_spam() {
|
|
2678 |
Â
* @since BuddyPress (1.6.0)
|
2679 |
Â
*
|
2680 |
Â
* @param BP_Activity_Activity $activity The activity item to be spammed.
|
2681 |
-
* @param string
|
2682 |
-
*
|
2683 |
-
*
|
2684 |
Â
*/
|
2685 |
Â
function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
|
2686 |
Â
$bp = buddypress();
|
@@ -2713,8 +2909,8 @@ function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
|
|
2713 |
Â
* @since BuddyPress (1.6.0)
|
2714 |
Â
*
|
2715 |
Â
* @param BP_Activity_Activity $activity Activity item being marked as spam.
|
2716 |
-
* @param string $source
|
2717 |
-
*
|
2718 |
Â
*/
|
2719 |
Â
do_action( 'bp_activity_mark_as_spam', $activity, $source );
|
2720 |
Â
}
|
@@ -2724,10 +2920,10 @@ function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
|
|
2724 |
Â
*
|
2725 |
Â
* @since BuddyPress (1.6.0)
|
2726 |
Â
*
|
2727 |
-
* @param BP_Activity_Activity $activity The activity item to be hammed.
|
2728 |
-
* @param string
|
2729 |
-
*
|
2730 |
-
*
|
2731 |
Â
*/
|
2732 |
Â
function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
|
2733 |
Â
$bp = buddypress();
|
@@ -2760,8 +2956,8 @@ function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
|
|
2760 |
Â
* @since BuddyPress (1.6.0)
|
2761 |
Â
*
|
2762 |
Â
* @param BP_Activity_Activity $activity Activity item being marked as ham.
|
2763 |
-
* @param string $source
|
2764 |
-
*
|
2765 |
Â
*/
|
2766 |
Â
do_action( 'bp_activity_mark_as_ham', $activity, $source );
|
2767 |
Â
}
|
@@ -2784,6 +2980,7 @@ function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
|
|
2784 |
Â
* @see BP_Embed
|
2785 |
Â
* @see bp_embed_activity_cache()
|
2786 |
Â
* @see bp_embed_activity_save_cache()
|
Â
|
|
2787 |
Â
* @uses add_filter() To attach 'bp_get_activity_id' to 'embed_post_id'.
|
2788 |
Â
* @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'.
|
2789 |
Â
* @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'.
|
@@ -2808,6 +3005,7 @@ add_action( 'activity_loop_start', 'bp_activity_embed' );
|
|
2808 |
Â
* @see BP_Embed
|
2809 |
Â
* @see bp_embed_activity_cache()
|
2810 |
Â
* @see bp_embed_activity_save_cache()
|
Â
|
|
2811 |
Â
* @uses add_filter() To attach 'bp_get_activity_comment_id' to 'embed_post_id'.
|
2812 |
Â
* @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'.
|
2813 |
Â
* @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'.
|
@@ -2867,10 +3065,11 @@ add_action( 'bp_after_activity_comment', 'bp_activity_comment_embed_after_recurs
|
|
2867 |
Â
* @see BP_Embed::parse_oembed()
|
2868 |
Â
* @uses bp_activity_get_meta()
|
2869 |
Â
*
|
2870 |
-
* @param string $cache
|
2871 |
-
*
|
2872 |
-
* @param int
|
2873 |
Â
* @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
|
Â
|
|
2874 |
Â
* @return mixed The cached embeds for this activity item.
|
2875 |
Â
*/
|
2876 |
Â
function bp_embed_activity_cache( $cache, $id, $cachekey ) {
|
@@ -2887,10 +3086,11 @@ function bp_embed_activity_cache( $cache, $id, $cachekey ) {
|
|
2887 |
Â
* @see BP_Embed::parse_oembed()
|
2888 |
Â
* @uses bp_activity_update_meta()
|
2889 |
Â
*
|
2890 |
-
* @param string $cache
|
2891 |
-
*
|
2892 |
Â
* @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
|
2893 |
-
* @param int
|
Â
|
|
2894 |
Â
* @return bool True on success, false on failure.
|
2895 |
Â
*/
|
2896 |
Â
function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
|
28 |
Â
*
|
29 |
Â
* The Mentions feature does a number of things, all of which will be turned
|
30 |
Â
* off if you disable mentions:
|
31 |
+
* - Detecting and auto-linking @username in all BP/WP content.
|
32 |
Â
* - Sending BP notifications and emails to users when they are mentioned
|
33 |
+
* using the @username syntax.
|
34 |
+
* - The Public Message button on user profiles.
|
35 |
Â
*
|
36 |
Â
* Mentions are enabled by default. To disable, put the following line in
|
37 |
Â
* bp-custom.php or your theme's functions.php file:
|
60 |
Â
* Should BuddyPress load the mentions scripts and related assets, including results to prime the
|
61 |
Â
* mentions suggestions?
|
62 |
Â
*
|
Â
|
|
63 |
Â
* @since BuddyPress (2.1.0)
|
64 |
+
*
|
65 |
+
* @return bool True if mentions scripts should be loaded.
|
66 |
Â
*/
|
67 |
Â
function bp_activity_maybe_load_mentions_scripts() {
|
68 |
Â
$mentions_enabled = bp_activity_do_mentions() && bp_is_user_active();
|
73 |
Â
*
|
74 |
Â
* @since BuddyPress (2.1.0)
|
75 |
Â
*
|
76 |
+
* @param bool $load_mentions True to load mentions assets, false otherwise.
|
77 |
Â
* @param bool $mentions_enabled True if mentions are enabled.
|
78 |
Â
*/
|
79 |
Â
return (bool) apply_filters( 'bp_activity_maybe_load_mentions_scripts', $load_mentions, $mentions_enabled );
|
85 |
Â
* @since BuddyPress (1.5.0)
|
86 |
Â
*
|
87 |
Â
* @param string $content The content of the activity, usually found in
|
88 |
+
* $activity->content.
|
89 |
+
*
|
90 |
Â
* @return array|bool Associative array with user ID as key and username as
|
91 |
+
* value. Boolean false if no mentions found.
|
92 |
Â
*/
|
93 |
Â
function bp_activity_find_mentions( $content ) {
|
94 |
Â
|
149 |
Â
* @uses bp_activity_find_mentions()
|
150 |
Â
* @uses bp_activity_update_mention_count_for_user()
|
151 |
Â
*
|
152 |
+
* @param int $activity_id The unique id for the activity item.
|
153 |
+
* @param string $action Can be 'delete' or 'add'. Defaults to 'add'.
|
154 |
+
*
|
155 |
+
* @return bool
|
156 |
Â
*/
|
157 |
Â
function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
|
158 |
Â
|
189 |
Â
* @uses bp_get_user_meta()
|
190 |
Â
* @uses bp_update_user_meta()
|
191 |
Â
*
|
192 |
+
* @param int $user_id The user ID.
|
193 |
+
* @param int $activity_id The unique ID for the activity item.
|
194 |
+
* @param string $action 'delete' or 'add'. Default: 'add'.
|
195 |
+
*
|
196 |
Â
* @return bool
|
197 |
Â
*/
|
198 |
Â
function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action = 'add' ) {
|
244 |
Â
*
|
245 |
Â
* @since BuddyPress (1.9.0)
|
246 |
Â
*
|
247 |
+
* @param int|string $user_id ID of the user to get @-mention name for.
|
248 |
+
*
|
249 |
Â
* @return string User name appropriate for @-mentions.
|
250 |
Â
*/
|
251 |
Â
function bp_activity_get_user_mentionname( $user_id ) {
|
269 |
Â
*
|
270 |
Â
* @since BuddyPress (1.9.0)
|
271 |
Â
*
|
272 |
+
* @param string $mentionname Username of user in @-mentions.
|
273 |
+
*
|
274 |
Â
* @return int|bool ID of the user, if one is found. Otherwise false.
|
275 |
Â
*/
|
276 |
Â
function bp_activity_get_userid_from_mentionname( $mentionname ) {
|
324 |
Â
*
|
325 |
Â
* @since BuddyPress (1.1.0)
|
326 |
Â
*
|
327 |
+
* @param string $component_id The unique string ID of the component.
|
328 |
+
* @param string $type The action type.
|
329 |
+
* @param string $description The action description.
|
330 |
+
* @param callable|bool $format_callback Callback for formatting the action string.
|
331 |
+
* @param string|bool $label String to describe this action in the activity stream filter dropdown.
|
332 |
+
* @param array $context Optional. Activity stream contexts where the filter should appear.
|
333 |
+
* Values: 'activity', 'member', 'member_groups', 'group'.
|
334 |
+
* @param int $position Optional. The position of the action when listed in dropdowns.
|
335 |
+
*
|
336 |
Â
* @return bool False if any param is empty, otherwise true.
|
337 |
Â
*/
|
338 |
Â
function bp_activity_set_action( $component_id, $type, $description, $format_callback = false, $label = false, $context = array(), $position = 0 ) {
|
362 |
Â
*
|
363 |
Â
* @since BuddyPress (1.1.0)
|
364 |
Â
*
|
365 |
+
* @param array $array Array of arguments for action type being set.
|
366 |
+
* @param string $component_id ID of the current component being set.
|
367 |
+
* @param string $type Action type being set.
|
368 |
+
* @param string $description Action description for action being set.
|
369 |
Â
* @param callable $format_callback Callback for formatting the action string.
|
370 |
+
* @param string $label String to describe this action in the activity stream filter dropdown.
|
371 |
+
* @param array $context Activity stream contexts where the filter should appear. 'activity', 'member',
|
372 |
+
* 'member_groups', 'group'.
|
373 |
Â
*/
|
374 |
Â
$bp->activity->actions->{$component_id}->{$type} = apply_filters( 'bp_activity_set_action', array(
|
375 |
Â
'key' => $type,
|
408 |
Â
* @type callable $format_callback Callback for formatting the activity action string.
|
409 |
Â
* Default: 'bp_activity_format_activity_action_custom_post_type_post'.
|
410 |
Â
* @type array $contexts The directory contexts in which the filter will show.
|
411 |
+
* Default: array( 'activity' ).
|
412 |
Â
* @type array $position Position of the item in filter dropdowns.
|
413 |
Â
* @type string $singular Singular, translatable name of the post type item. If no value is
|
414 |
Â
* provided, it's pulled from the 'singular_name' of the post type.
|
415 |
Â
* @type bool $activity_comment Whether to allow comments on the activity items. Defaults to true if
|
416 |
Â
* the post type does not natively support comments, otherwise false.
|
417 |
Â
* }
|
418 |
+
*
|
419 |
+
* @return bool
|
420 |
Â
*/
|
421 |
Â
function bp_activity_set_post_type_tracking_args( $post_type = '', $args = array() ) {
|
422 |
Â
global $wp_post_types;
|
Â
|
|
423 |
Â
|
424 |
Â
if ( empty( $wp_post_types[ $post_type ] ) || ! post_type_supports( $post_type, 'buddypress-activity' ) || ! is_array( $args ) ) {
|
425 |
Â
return false;
|
444 |
Â
*
|
445 |
Â
* @since BuddyPress (2.2.0)
|
446 |
Â
*
|
447 |
+
* @param string $post_type Name of the post type.
|
448 |
+
*
|
449 |
Â
* @return object The tracking arguments of the post type.
|
450 |
Â
*/
|
451 |
Â
function bp_activity_get_post_type_tracking_args( $post_type ) {
|
502 |
Â
* @since BuddyPress (2.2.0)
|
503 |
Â
*
|
504 |
Â
* @param object $post_type_activity The tracking arguments of the post type.
|
505 |
+
* @param string $post_type Name of the post type.
|
506 |
Â
*/
|
507 |
Â
return apply_filters( 'bp_activity_get_post_type_tracking_args', $post_type_activity, $post_type );
|
508 |
Â
}
|
545 |
Â
*
|
546 |
Â
* @since BuddyPress (2.2.0)
|
547 |
Â
*
|
548 |
+
* @return object Actions ordered by their position.
|
549 |
Â
*/
|
550 |
Â
function bp_activity_get_actions() {
|
551 |
Â
$bp = buddypress();
|
594 |
Â
* @uses apply_filters() To call the 'bp_activity_get_action' hook.
|
595 |
Â
*
|
596 |
Â
* @param string $component_id The unique string ID of the component.
|
597 |
+
* @param string $key The action key.
|
598 |
+
*
|
599 |
Â
* @return string|bool Action value if found, otherwise false.
|
600 |
Â
*/
|
601 |
Â
function bp_activity_get_action( $component_id, $key ) {
|
605 |
Â
return false;
|
606 |
Â
}
|
607 |
Â
|
Â
|
|
608 |
Â
$actions = bp_activity_get_actions();
|
609 |
+
$retval = false;
|
610 |
Â
|
Â
|
|
611 |
Â
if ( isset( $actions->{$component_id}->{$key} ) ) {
|
612 |
Â
$retval = $actions->{$component_id}->{$key};
|
613 |
Â
}
|
667 |
Â
* @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook.
|
668 |
Â
*
|
669 |
Â
* @param int $user_id ID of the user whose favorites are being queried.
|
670 |
+
*
|
671 |
Â
* @return array IDs of the user's favorite activity items.
|
672 |
Â
*/
|
673 |
Â
function bp_activity_get_user_favorites( $user_id = 0 ) {
|
704 |
Â
* @uses do_action() To call the 'bp_activity_add_user_favorite_fail' hook.
|
705 |
Â
*
|
706 |
Â
* @param int $activity_id ID of the activity item being favorited.
|
707 |
+
* @param int $user_id ID of the user favoriting the activity item.
|
708 |
+
*
|
709 |
Â
* @return bool True on success, false on failure.
|
710 |
Â
*/
|
711 |
Â
function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
|
749 |
Â
* @since BuddyPress (1.2.1)
|
750 |
Â
*
|
751 |
Â
* @param int $activity_id ID of the activity item being favorited.
|
752 |
+
* @param int $user_id ID of the user doing the favoriting.
|
753 |
Â
*/
|
754 |
Â
do_action( 'bp_activity_add_user_favorite', $activity_id, $user_id );
|
755 |
Â
|
765 |
Â
* @since BuddyPress (1.5.0)
|
766 |
Â
*
|
767 |
Â
* @param int $activity_id ID of the activity item being favorited.
|
768 |
+
* @param int $user_id ID of the user doing the favoriting.
|
769 |
Â
*/
|
770 |
Â
do_action( 'bp_activity_add_user_favorite_fail', $activity_id, $user_id );
|
771 |
Â
|
786 |
Â
* @uses do_action() To call the 'bp_activity_remove_user_favorite' hook.
|
787 |
Â
*
|
788 |
Â
* @param int $activity_id ID of the activity item being unfavorited.
|
789 |
+
* @param int $user_id ID of the user unfavoriting the activity item.
|
790 |
+
*
|
791 |
Â
* @return bool True on success, false on failure.
|
792 |
Â
*/
|
793 |
Â
function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
|
830 |
Â
* @since BuddyPress (1.2.1)
|
831 |
Â
*
|
832 |
Â
* @param int $activity_id ID of the activity item being unfavorited.
|
833 |
+
* @param int $user_id ID of the user doing the unfavoriting.
|
834 |
Â
*/
|
835 |
Â
do_action( 'bp_activity_remove_user_favorite', $activity_id, $user_id );
|
836 |
Â
|
862 |
Â
* @uses apply_filters() To call the 'bp_activity_check_exists_by_content' hook.
|
863 |
Â
*
|
864 |
Â
* @param string $content The content to filter by.
|
865 |
+
*
|
866 |
Â
* @return int|null The ID of the located activity item. Null if none is found.
|
867 |
Â
*/
|
868 |
Â
function bp_activity_check_exists_by_content( $content ) {
|
907 |
Â
* @uses BP_Activity_Activity::total_favorite_count() {@link BP_Activity_Activity}
|
908 |
Â
*
|
909 |
Â
* @param int $user_id ID of the user whose favorite count is being requested.
|
910 |
+
*
|
911 |
Â
* @return int Total favorite count for the user.
|
912 |
Â
*/
|
913 |
Â
function bp_activity_total_favorites_for_user( $user_id = 0 ) {
|
928 |
Â
* @since BuddyPress (1.2.0)
|
929 |
Â
*
|
930 |
Â
* @global object $wpdb WordPress database access object.
|
931 |
+
*
|
932 |
+
* @param int $activity_id ID of the activity item whose metadata is being deleted.
|
933 |
+
* @param string $meta_key Optional. The key of the metadata being deleted. If
|
934 |
+
* omitted, all metadata associated with the activity
|
935 |
+
* item will be deleted.
|
936 |
+
* @param string $meta_value Optional. If present, the metadata will only be
|
937 |
+
* deleted if the meta_value matches this parameter.
|
938 |
+
* @param bool $delete_all Optional. If true, delete matching metadata entries
|
939 |
+
* for all objects, ignoring the specified object_id. Otherwise,
|
940 |
+
* only delete matching metadata entries for the specified
|
941 |
+
* activity item. Default: false.
|
942 |
+
*
|
943 |
Â
* @return bool True on success, false on failure.
|
944 |
Â
*/
|
945 |
Â
function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '', $delete_all = false ) {
|
973 |
Â
*
|
974 |
Â
* @uses apply_filters() To call the 'bp_activity_get_meta' hook.
|
975 |
Â
*
|
976 |
+
* @param int $activity_id ID of the activity item whose metadata is being requested.
|
977 |
+
* @param string $meta_key Optional. If present, only the metadata matching
|
978 |
+
* that meta key will be returned. Otherwise, all metadata for the
|
979 |
+
* activity item will be fetched.
|
980 |
+
* @param bool $single Optional. If true, return only the first value of the
|
981 |
+
* specified meta_key. This parameter has no effect if meta_key is not
|
982 |
+
* specified. Default: true.
|
983 |
+
*
|
984 |
Â
* @return mixed The meta value(s) being requested.
|
985 |
Â
*/
|
986 |
Â
function bp_activity_get_meta( $activity_id = 0, $meta_key = '', $single = true ) {
|
993 |
Â
*
|
994 |
Â
* @since BuddyPress (1.5.0)
|
995 |
Â
*
|
996 |
+
* @param mixed $retval The meta values for the activity item.
|
997 |
Â
* @param int $activity_id ID of the activity item.
|
998 |
+
* @param string $meta_key Meta key for the value being requested.
|
999 |
+
* @param bool $single Whether to return one matched meta key row or all.
|
1000 |
Â
*/
|
1001 |
Â
return apply_filters( 'bp_activity_get_meta', $retval, $activity_id, $meta_key, $single );
|
1002 |
Â
}
|
1006 |
Â
*
|
1007 |
Â
* @since BuddyPress (1.2.0)
|
1008 |
Â
*
|
1009 |
+
* @param int $activity_id ID of the activity item whose metadata is being updated.
|
1010 |
+
* @param string $meta_key Key of the metadata being updated.
|
1011 |
+
* @param mixed $meta_value Value to be set.
|
1012 |
+
* @param mixed $prev_value Optional. If specified, only update existing metadata entries
|
1013 |
+
* with the specified value. Otherwise, update all entries.
|
1014 |
+
*
|
Â
|
|
1015 |
Â
* @return bool|int Returns false on failure. On successful update of existing
|
1016 |
+
* metadata, returns true. On successful creation of new metadata,
|
1017 |
+
* returns the integer ID of the new metadata row.
|
1018 |
Â
*/
|
1019 |
Â
function bp_activity_update_meta( $activity_id, $meta_key, $meta_value, $prev_value = '' ) {
|
1020 |
Â
add_filter( 'query', 'bp_filter_metaid_column_name' );
|
1029 |
Â
*
|
1030 |
Â
* @since BuddyPress (2.0.0)
|
1031 |
Â
*
|
1032 |
+
* @param int $activity_id ID of the activity item.
|
1033 |
+
* @param string $meta_key Metadata key.
|
1034 |
+
* @param mixed $meta_value Metadata value.
|
1035 |
+
* @param bool $unique Optional. Whether to enforce a single metadata value for the
|
1036 |
+
* given key. If true, and the object already has a value for
|
1037 |
+
* the key, no change will be made. Default: false.
|
1038 |
+
*
|
1039 |
Â
* @return int|bool The meta ID on successful update, false on failure.
|
1040 |
Â
*/
|
1041 |
Â
function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = false ) {
|
1060 |
Â
* @uses do_action() To call the 'bp_activity_remove_all_user_data' hook.
|
1061 |
Â
*
|
1062 |
Â
* @param int $user_id ID of the user whose activity is being deleted.
|
1063 |
+
*
|
1064 |
+
* @return bool
|
1065 |
Â
*/
|
1066 |
Â
function bp_activity_remove_all_user_data( $user_id = 0 ) {
|
1067 |
Â
|
1098 |
Â
* @since BuddyPress (1.6.0)
|
1099 |
Â
*
|
1100 |
Â
* @global object $wpdb WordPress database access object.
|
Â
|
|
1101 |
Â
*
|
1102 |
Â
* @param int $user_id ID of the user whose activity is being spammed.
|
1103 |
+
*
|
1104 |
+
* @return bool
|
1105 |
Â
*/
|
1106 |
Â
function bp_activity_spam_all_user_data( $user_id = 0 ) {
|
1107 |
Â
global $wpdb;
|
1155 |
Â
*
|
1156 |
Â
* @since BuddyPress (1.6.0)
|
1157 |
Â
*
|
1158 |
+
* @param int $user_id ID of the user whose activity is being marked as spam.
|
1159 |
Â
* @param array $activities Array of activity items being marked as spam.
|
1160 |
Â
*/
|
1161 |
Â
do_action( 'bp_activity_spam_all_user_data', $user_id, $activities['activities'] );
|
1168 |
Â
* @since BuddyPress (1.6.0)
|
1169 |
Â
*
|
1170 |
Â
* @global object $wpdb WordPress database access object.
|
Â
|
|
1171 |
Â
*
|
1172 |
Â
* @param int $user_id ID of the user whose activity is being hammed.
|
1173 |
+
*
|
1174 |
+
* @return bool
|
1175 |
Â
*/
|
1176 |
Â
function bp_activity_ham_all_user_data( $user_id = 0 ) {
|
1177 |
Â
global $wpdb;
|
1226 |
Â
*
|
1227 |
Â
* @since BuddyPress (1.6.0)
|
1228 |
Â
*
|
1229 |
+
* @param int $user_id ID of the user whose activity is being marked as ham.
|
1230 |
Â
* @param array $activities Array of activity items being marked as ham.
|
1231 |
Â
*/
|
1232 |
Â
do_action( 'bp_activity_ham_all_user_data', $user_id, $activities['activities'] );
|
1234 |
Â
add_action( 'bp_make_ham_user', 'bp_activity_ham_all_user_data' );
|
1235 |
Â
|
1236 |
Â
/**
|
1237 |
+
* Register the activity stream actions for updates.
|
1238 |
Â
*
|
1239 |
Â
* @since BuddyPress (1.6.0)
|
1240 |
Â
*/
|
1276 |
Â
* Generate an activity action string for an activity item.
|
1277 |
Â
*
|
1278 |
Â
* @param object $activity Activity data object.
|
1279 |
+
*
|
1280 |
Â
* @return string|bool Returns false if no callback is found, otherwise returns
|
1281 |
+
* the formatted action string.
|
1282 |
Â
*/
|
1283 |
Â
function bp_activity_generate_action_string( $activity ) {
|
1284 |
Â
|
1301 |
Â
*
|
1302 |
Â
* @since BuddyPress (2.0.0)
|
1303 |
Â
*
|
1304 |
+
* @param BP_Activity_Activity $action Action string being requested.
|
1305 |
Â
* @param BP_Activity_Activity $activity Activity item object.
|
1306 |
Â
*/
|
1307 |
Â
$action = apply_filters( 'bp_activity_generate_action_string', $activity->action, $activity );
|
1317 |
Â
*
|
1318 |
Â
* @since BuddyPress (2.0.0)
|
1319 |
Â
*
|
1320 |
+
* @param string $action Static activity action.
|
1321 |
Â
* @param object $activity Activity data object.
|
1322 |
+
*
|
1323 |
Â
* @return string
|
1324 |
Â
*/
|
1325 |
Â
function bp_activity_format_activity_action_activity_update( $action, $activity ) {
|
1330 |
Â
*
|
1331 |
Â
* @since BuddyPress (1.2.0)
|
1332 |
Â
*
|
1333 |
+
* @param string $action Activity action string value.
|
1334 |
Â
* @param BP_Activity_Activity $activity Activity item object.
|
1335 |
Â
*/
|
1336 |
Â
return apply_filters( 'bp_activity_new_update_action', $action, $activity );
|
1341 |
Â
*
|
1342 |
Â
* @since BuddyPress (2.0.0)
|
1343 |
Â
*
|
1344 |
+
* @param string $action Static activity action.
|
1345 |
Â
* @param object $activity Activity data object.
|
1346 |
+
*
|
1347 |
Â
* @return string
|
1348 |
Â
*/
|
1349 |
Â
function bp_activity_format_activity_action_activity_comment( $action, $activity ) {
|
1354 |
Â
*
|
1355 |
Â
* @since BuddyPress (1.2.0)
|
1356 |
Â
*
|
1357 |
+
* @param string $action Activity action string value.
|
1358 |
Â
* @param BP_Activity_Activity $activity Activity item object.
|
1359 |
Â
*/
|
1360 |
Â
return apply_filters( 'bp_activity_comment_action', $action, $activity );
|
1367 |
Â
*
|
1368 |
Â
* @param string $action Static activity action.
|
1369 |
Â
* @param object $activity Activity data object.
|
1370 |
+
*
|
1371 |
Â
* @return string
|
1372 |
Â
*/
|
1373 |
Â
function bp_activity_format_activity_action_custom_post_type_post( $action, $activity ) {
|
1412 |
Â
*
|
1413 |
Â
* @since BuddyPress (2.2.0)
|
1414 |
Â
*
|
1415 |
+
* @param string $action Activity action string value.
|
1416 |
Â
* @param BP_Activity_Activity $activity Activity item object.
|
1417 |
Â
*/
|
1418 |
Â
return apply_filters( 'bp_activity_custom_post_type_post_action', $action, $activity );
|
1444 |
Â
* @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
|
1445 |
Â
* @uses apply_filters_ref_array() To call the 'bp_activity_get' hook.
|
1446 |
Â
*
|
1447 |
+
* @param array|string $args See BP_Activity_Activity::get() for description.
|
1448 |
+
*
|
1449 |
Â
* @return array $activity See BP_Activity_Activity::get() for description.
|
1450 |
Â
*/
|
1451 |
Â
function bp_activity_get( $args = '' ) {
|
1536 |
Â
* @since BuddyPress (1.2.0)
|
1537 |
Â
*
|
1538 |
Â
* @param BP_Activity_Activity $activity Requested activity object.
|
1539 |
+
* @param array $r Arguments used for the activity query.
|
1540 |
Â
*/
|
1541 |
Â
return apply_filters_ref_array( 'bp_activity_get', array( &$activity, &$r ) );
|
1542 |
Â
}
|
1546 |
Â
*
|
1547 |
Â
* @since BuddyPress (1.2.0)
|
1548 |
Â
*
|
1549 |
+
* @see BP_Activity_Activity::get() For more information on accepted arguments.
|
1550 |
Â
* @uses wp_parse_args()
|
1551 |
+
* @uses apply_filters() To call the 'bp_activity_get_specific' hook.
|
1552 |
Â
* @uses BP_Activity_Activity::get() {@link BP_Activity_Activity}
|
1553 |
Â
*
|
1554 |
+
* @param array|string $args {
|
1555 |
Â
* All arguments and defaults are shared with BP_Activity_Activity::get(),
|
1556 |
Â
* except for the following:
|
1557 |
Â
* @type string|int|array Single activity ID, comma-separated list of IDs,
|
1591 |
Â
* @since BuddyPress (1.2.0)
|
1592 |
Â
*
|
1593 |
Â
* @param BP_Activity_Activity $activity Requested activity object.
|
1594 |
+
* @param array $args Original passed in arguments.
|
1595 |
Â
* @param array $get_args Constructed arguments used with request.
|
1596 |
Â
*/
|
1597 |
Â
return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $get_args ), $args, $get_args );
|
1606 |
Â
* @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
|
1607 |
Â
* @uses BP_Activity_Activity::rebuild_activity_comment_tree() {@link BP_Activity_Activity}
|
1608 |
Â
* @uses wp_cache_delete()
|
1609 |
+
* @uses do_action() To call the 'bp_activity_add' hook.
|
1610 |
Â
*
|
1611 |
+
* @param array|string $args {
|
1612 |
Â
* An array of arguments.
|
1613 |
+
* @type int|bool $id Pass an activity ID to update an existing item, or
|
1614 |
+
* false to create a new item. Default: false.
|
1615 |
+
* @type string $action Optional. The activity action/description, typically
|
1616 |
+
* something like "Joe posted an update". Values passed to this param
|
1617 |
+
* will be stored in the database and used as a fallback for when the
|
1618 |
+
* activity item's format_callback cannot be found (eg, when the
|
1619 |
+
* component is disabled). As long as you have registered a
|
1620 |
+
* format_callback for your $type, it is unnecessary to include this
|
1621 |
+
* argument - BP will generate it automatically.
|
1622 |
+
* See {@link bp_activity_set_action()}.
|
1623 |
+
* @type string $content Optional. The content of the activity item.
|
1624 |
+
* @type string $component The unique name of the component associated with
|
1625 |
+
* the activity item - 'groups', 'profile', etc.
|
1626 |
+
* @type string $type The specific activity type, used for directory
|
1627 |
+
* filtering. 'new_blog_post', 'activity_update', etc.
|
1628 |
+
* @type string $primary_link Optional. The URL for this item, as used in
|
1629 |
+
* RSS feeds. Defaults to the URL for this activity
|
1630 |
+
* item's permalink page.
|
1631 |
+
* @type int|bool $user_id Optional. The ID of the user associated with the activity
|
1632 |
+
* item. May be set to false or 0 if the item is not related
|
1633 |
+
* to any user. Default: the ID of the currently logged-in user.
|
1634 |
+
* @type int $item_id Optional. The ID of the associated item.
|
1635 |
+
* @type int $secondary_item_id Optional. The ID of a secondary associated item.
|
1636 |
+
* @type string $date_recorded Optional. The GMT time, in Y-m-d h:i:s format, when
|
1637 |
+
* the item was recorded. Defaults to the current time.
|
1638 |
+
* @type bool $hide_sitewide Should the item be hidden on sitewide streams?
|
1639 |
+
* Default: false.
|
1640 |
+
* @type bool $is_spam Should the item be marked as spam? Default: false.
|
1641 |
Â
* }
|
1642 |
Â
* @return int|bool The ID of the activity on success. False on error.
|
1643 |
Â
*/
|
1656 |
Â
'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded
|
1657 |
Â
'hide_sitewide' => false, // Should this be hidden on the sitewide activity stream?
|
1658 |
Â
'is_spam' => false, // Is this activity item to be marked as spam?
|
1659 |
+
), 'activity_add' );
|
1660 |
Â
|
1661 |
Â
// Make sure we are backwards compatible
|
1662 |
Â
if ( empty( $r['component'] ) && !empty( $r['component_name'] ) ) {
|
1725 |
Â
* @uses wp_filter_kses()
|
1726 |
Â
* @uses do_action() To call the 'bp_activity_posted_update' hook.
|
1727 |
Â
*
|
1728 |
+
* @param array|string $args {
|
1729 |
Â
* @type string $content The content of the activity update.
|
1730 |
+
* @type int $user_id Optional. Defaults to the logged-in user.
|
1731 |
Â
* }
|
1732 |
+
* @return int $activity_id The activity id.
|
1733 |
Â
*/
|
1734 |
Â
function bp_activity_post_update( $args = '' ) {
|
1735 |
Â
|
1782 |
Â
*
|
1783 |
Â
* @since BuddyPress (1.6.0)
|
1784 |
Â
*
|
1785 |
+
* @param string $r Content of the activity update.
|
1786 |
Â
* @param string $activity_content Content of the activity update.
|
1787 |
Â
*/
|
1788 |
Â
$activity_content = apply_filters( 'bp_activity_latest_update_content', $r['content'], $activity_content );
|
1798 |
Â
*
|
1799 |
Â
* @since BuddyPress (1.2.0)
|
1800 |
Â
*
|
1801 |
+
* @param string $content Content of the activity post update.
|
1802 |
+
* @param int $user_id ID of the user posting the activity update.
|
1803 |
Â
* @param int $activity_id ID of the activity item being updated.
|
1804 |
Â
*/
|
1805 |
Â
do_action( 'bp_activity_posted_update', $r['content'], $r['user_id'], $activity_id );
|
1815 |
Â
* @param int $post_id ID of the new post.
|
1816 |
Â
* @param WP_Post $post Post object.
|
1817 |
Â
* @param int $user_id ID of the post author.
|
1818 |
+
*
|
1819 |
Â
* @return int|bool The ID of the activity on success. False on error.
|
1820 |
Â
*/
|
1821 |
Â
function bp_activity_post_type_publish( $post_id = 0, $post = null, $user_id = 0 ) {
|
Â
|
|
1822 |
Â
|
1823 |
Â
if ( ! is_a( $post, 'WP_Post' ) ) {
|
1824 |
Â
return;
|
1899 |
Â
'recorded_time' => $post->post_date_gmt,
|
1900 |
Â
);
|
1901 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1902 |
Â
if ( ! empty( $activity_args['content'] ) ) {
|
1903 |
Â
// Create the excerpt.
|
1904 |
+
$activity_summary = bp_activity_create_summary( $activity_args['content'], $activity_args );
|
1905 |
Â
|
1906 |
Â
// Backward compatibility filter for blog posts.
|
1907 |
Â
if ( 'blogs' == $activity_post_object->component_id ) {
|
1908 |
+
$activity_args['content'] = apply_filters( 'bp_blogs_record_activity_content', $activity_summary, $activity_args['content'], $activity_args, $post->post_type );
|
1909 |
Â
} else {
|
1910 |
+
$activity_args['content'] = $activity_summary;
|
1911 |
Â
}
|
1912 |
Â
}
|
1913 |
Â
|
1951 |
Â
* @since BuddyPress (2.2.0)
|
1952 |
Â
*
|
1953 |
Â
* @param WP_Post $post Post item.
|
1954 |
+
*
|
1955 |
Â
* @return bool True on success, false on failure.
|
1956 |
Â
*/
|
1957 |
Â
function bp_activity_post_type_update( $post = null ) {
|
Â
|
|
1958 |
Â
|
1959 |
Â
if ( ! is_a( $post, 'WP_Post' ) ) {
|
1960 |
Â
return;
|
1988 |
Â
$activity = new BP_Activity_Activity( $activity_id );
|
1989 |
Â
|
1990 |
Â
if ( ! empty( $post->post_content ) ) {
|
1991 |
+
$activity_summary = bp_activity_create_summary( $post->post_content, (array) $activity );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1992 |
Â
|
1993 |
Â
// Backward compatibility filter for the blogs component.
|
1994 |
Â
if ( 'blogs' == $activity_post_object->component_id ) {
|
1995 |
+
$activity->content = apply_filters( 'bp_blogs_record_activity_content', $activity_summary, $post->post_content, (array) $activity, $post->post_type );
|
1996 |
Â
} else {
|
1997 |
+
$activity->content = $activity_summary;
|
1998 |
Â
}
|
1999 |
Â
}
|
2000 |
Â
|
2006 |
Â
*
|
2007 |
Â
* @since BuddyPress (2.2.0)
|
2008 |
Â
*
|
2009 |
+
* @param WP_Post $post Post object.
|
2010 |
Â
* @param BP_Activity_Activity $activity Activity object.
|
2011 |
Â
*/
|
2012 |
Â
do_action( 'bp_activity_post_type_updated', $post, $activity );
|
2021 |
Â
*
|
2022 |
Â
* @param int $post_id ID of the post being unpublished.
|
2023 |
Â
* @param WP_Post $post Post object.
|
2024 |
+
*
|
2025 |
Â
* @return bool True on success, false on failure.
|
2026 |
Â
*/
|
2027 |
Â
function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
|
Â
|
|
2028 |
Â
|
2029 |
Â
if ( ! is_a( $post, 'WP_Post' ) ) {
|
2030 |
Â
return;
|
2058 |
Â
*
|
2059 |
Â
* @param array $delete_activity_args Array of arguments for activity deletion.
|
2060 |
Â
* @param WP_Post $post Post object.
|
2061 |
+
* @param bool $activity Whether or not the activity was successfully deleted.
|
Â
|
|
2062 |
Â
*/
|
2063 |
Â
do_action( 'bp_activity_post_type_unpublished', $delete_activity_args, $post, $deleted );
|
2064 |
Â
|
2070 |
Â
*
|
2071 |
Â
* @since BuddyPress (1.2.0)
|
2072 |
Â
*
|
Â
|
|
2073 |
Â
* @uses wp_parse_args()
|
2074 |
Â
* @uses bp_activity_add()
|
2075 |
Â
* @uses apply_filters() To call the 'bp_activity_comment_action' hook.
|
2077 |
Â
* @uses wp_cache_delete()
|
2078 |
Â
* @uses do_action() To call the 'bp_activity_comment_posted' hook.
|
2079 |
Â
*
|
2080 |
+
* @param array|string $args {
|
2081 |
+
* @type int $id Optional. Pass an ID to update an existing comment.
|
2082 |
+
* @type string $content The content of the comment.
|
2083 |
+
* @type int $user_id Optional. The ID of the user making the comment.
|
2084 |
+
* Defaults to the ID of the logged-in user.
|
2085 |
+
* @type int $activity_id The ID of the "root" activity item, ie the oldest
|
2086 |
+
* ancestor of the comment.
|
2087 |
+
* @type int $parent_id Optional. The ID of the parent activity item, ie the item to
|
2088 |
+
* which the comment is an immediate reply. If not provided,
|
2089 |
+
* this value defaults to the $activity_id.
|
2090 |
Â
* }
|
2091 |
Â
* @return int|bool The ID of the comment on success, otherwise false.
|
2092 |
Â
*/
|
2175 |
Â
* @since BuddyPress (1.2.0)
|
2176 |
Â
*
|
2177 |
Â
* @param int $comment_id ID of the newly posted activity comment.
|
2178 |
+
* @param array $r Array of parsed comment arguments.
|
2179 |
+
* @param int $activity ID of the activity item being commented on.
|
2180 |
Â
*/
|
2181 |
Â
do_action( 'bp_activity_comment_posted', $comment_id, $r, $activity );
|
2182 |
Â
|
2198 |
Â
* @uses apply_filters() To call the 'bp_activity_get_activity_id' hook.
|
2199 |
Â
* @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
|
2200 |
Â
*
|
2201 |
+
* @param array|string $args See BP_Activity_Activity::get() for description.
|
2202 |
+
*
|
2203 |
Â
* @return int $activity_id The ID of the activity item found.
|
2204 |
Â
*/
|
2205 |
Â
function bp_activity_get_activity_id( $args = '' ) {
|
2220 |
Â
*
|
2221 |
Â
* @since BuddyPress (1.2.0)
|
2222 |
Â
*
|
2223 |
+
* @param BP_Activity_Activity $value ID returned by BP_Activity_Activity get_id() method with provided arguments.
|
2224 |
Â
*/
|
2225 |
Â
return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id(
|
2226 |
Â
$r['user_id'],
|
2260 |
Â
* @uses do_action() To call the 'bp_activity_deleted_activities' hook.
|
2261 |
Â
* @uses wp_cache_delete()
|
2262 |
Â
*
|
2263 |
+
* @param array|string $args To delete specific activity items, use
|
2264 |
+
* $args = array( 'id' => $ids ); Otherwise, to use
|
2265 |
+
* filters for item deletion, the argument format is
|
2266 |
+
* the same as BP_Activity_Activity::get().
|
2267 |
+
* See that method for a description.
|
2268 |
+
*
|
2269 |
Â
* @return bool True on success, false on failure.
|
2270 |
Â
*/
|
2271 |
Â
function bp_activity_delete( $args = '' ) {
|
2348 |
Â
* @uses wp_parse_args()
|
2349 |
Â
* @uses bp_activity_delete()
|
2350 |
Â
*
|
2351 |
+
* @param array|string $args See BP_Activity_Activity::get for a
|
2352 |
+
* description of accepted arguments.
|
2353 |
Â
*
|
2354 |
Â
* @return bool True on success, false on failure.
|
2355 |
Â
*/
|
2373 |
Â
*
|
2374 |
Â
* @uses bp_activity_delete()
|
2375 |
Â
*
|
2376 |
+
* @param int $activity_id ID of the activity item to be deleted.
|
2377 |
+
*
|
2378 |
Â
* @return bool True on success, false on failure.
|
2379 |
Â
*/
|
2380 |
Â
function bp_activity_delete_by_activity_id( $activity_id ) {
|
2391 |
Â
*
|
2392 |
Â
* @uses bp_activity_delete()
|
2393 |
Â
*
|
2394 |
+
* @param int $user_id The user id.
|
2395 |
+
* @param string $content The activity id.
|
2396 |
Â
* @param string $component The activity component.
|
2397 |
+
* @param string $type The activity type.
|
2398 |
+
*
|
2399 |
Â
* @return bool True on success, false on failure.
|
2400 |
Â
*/
|
2401 |
Â
function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
|
2417 |
Â
*
|
2418 |
Â
* @uses bp_activity_delete()
|
2419 |
Â
*
|
2420 |
+
* @param int $user_id The user id.
|
2421 |
Â
* @param string $component The activity component.
|
2422 |
+
*
|
2423 |
Â
* @return bool True on success, false on failure.
|
2424 |
Â
*/
|
2425 |
Â
function bp_activity_delete_for_user_by_component( $user_id, $component ) {
|
2446 |
Â
*
|
2447 |
Â
* @param int $activity_id The ID of the "root" activity, ie the comment's
|
2448 |
Â
* oldest ancestor.
|
2449 |
+
* @param int $comment_id The ID of the comment to be deleted.
|
2450 |
+
*
|
2451 |
+
* @return bool True on success, false on failure.
|
2452 |
Â
*/
|
2453 |
Â
function bp_activity_delete_comment( $activity_id, $comment_id ) {
|
2454 |
Â
|
2460 |
Â
*
|
2461 |
Â
* @since BuddyPress (1.2.0)
|
2462 |
Â
*
|
2463 |
+
* @param bool $value Whether BuddyPress should continue or not.
|
2464 |
Â
* @param int $activity_id ID of the root activity item being deleted.
|
2465 |
+
* @param int $comment_id ID of the comment being deleted.
|
2466 |
Â
*/
|
2467 |
Â
if ( ! apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) ) {
|
2468 |
Â
return false;
|
2488 |
Â
* @since BuddyPress (1.2.0)
|
2489 |
Â
*
|
2490 |
Â
* @param int $activity_id ID of the activity that has had a comment deleted from.
|
2491 |
+
* @param int $comment_id ID of the comment that was deleted.
|
2492 |
Â
*/
|
2493 |
Â
do_action( 'bp_activity_delete_comment', $activity_id, $comment_id );
|
2494 |
Â
|
2505 |
Â
* @uses bp_activity_delete()
|
2506 |
Â
*
|
2507 |
Â
* @param int $activity_id The ID of the "root" activity, ie the
|
2508 |
+
* comment's oldest ancestor.
|
2509 |
+
* @param int $comment_id The ID of the comment to be deleted.
|
2510 |
Â
*/
|
2511 |
Â
function bp_activity_delete_children( $activity_id, $comment_id ) {
|
2512 |
Â
|
2542 |
Â
* @uses bp_get_activity_root_slug()
|
2543 |
Â
* @uses apply_filters_ref_array() To call the 'bp_activity_get_permalink' hook.
|
2544 |
Â
*
|
2545 |
+
* @param int $activity_id The unique id of the activity object.
|
2546 |
+
* @param object|bool $activity_obj Optional. The activity object.
|
2547 |
+
*
|
2548 |
Â
* @return string $link Permalink for the activity item.
|
2549 |
Â
*/
|
2550 |
Â
function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
|
2597 |
Â
* @uses BP_Activity_Activity::hide_all_for_user() {@link BP_Activity_Activity}
|
2598 |
Â
*
|
2599 |
Â
* @param int $user_id The ID of the user whose activity is being hidden.
|
2600 |
+
*
|
2601 |
Â
* @return bool True on success, false on failure.
|
2602 |
Â
*/
|
2603 |
Â
function bp_activity_hide_user_activity( $user_id ) {
|
2614 |
Â
* through the content, grabs the first image and converts it to a thumbnail,
|
2615 |
Â
* and removes the rest of the images from the string.
|
2616 |
Â
*
|
2617 |
+
* As of BuddyPress 2.3, this function is no longer in use.
|
2618 |
+
*
|
2619 |
Â
* @since BuddyPress (1.2.0)
|
2620 |
Â
*
|
2621 |
Â
* @uses esc_attr()
|
2622 |
+
* @uses apply_filters() To call the 'bp_activity_thumbnail_content_images' hook.
|
2623 |
+
*
|
2624 |
+
* @param string $content The content of the activity item.
|
2625 |
+
* @param string|bool $link Optional. The unescaped URL that the image should link
|
2626 |
+
* to. If absent, the image will not be a link.
|
2627 |
+
* @param array|bool $args Optional. The args passed to the activity
|
2628 |
+
* creation function (eg bp_blogs_record_activity()).
|
2629 |
Â
*
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2630 |
Â
* @return string $content The content with images stripped and replaced with a
|
2631 |
+
* single thumb.
|
2632 |
Â
*/
|
2633 |
Â
function bp_activity_thumbnail_content_images( $content, $link = false, $args = false ) {
|
2634 |
Â
|
2646 |
Â
preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height );
|
2647 |
Â
preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width );
|
2648 |
Â
|
2649 |
+
if ( ! empty( $src ) ) {
|
2650 |
+
$src = substr( substr( str_replace( 'src=', '', $src[1] ), 0, -1 ), 1 );
|
2651 |
+
|
2652 |
+
if ( isset( $width[1] ) ) {
|
2653 |
+
$width = substr( substr( str_replace( 'width=', '', $width[1] ), 0, -1 ), 1 );
|
2654 |
+
}
|
2655 |
+
|
2656 |
+
if ( isset( $height[1] ) ) {
|
2657 |
+
$height = substr( substr( str_replace( 'height=', '', $height[1] ), 0, -1 ), 1 );
|
2658 |
+
}
|
2659 |
Â
|
2660 |
Â
if ( empty( $width ) || empty( $height ) ) {
|
2661 |
Â
$width = 100;
|
2682 |
Â
*
|
2683 |
Â
* @param string $content Activity content that had images replaced in.
|
2684 |
Â
* @param array $matches Array of all image tags found in the posted content.
|
2685 |
+
* @param array $args Arguments passed into function creating the activity update.
|
2686 |
Â
*/
|
2687 |
Â
return apply_filters( 'bp_activity_thumbnail_content_images', $content, $matches, $args );
|
2688 |
Â
}
|
2689 |
Â
|
2690 |
+
/**
|
2691 |
+
* Create a rich summary of an activity item for the activity stream.
|
2692 |
+
*
|
2693 |
+
* More than just a simple excerpt, the summary could contain oEmbeds and other types of media.
|
2694 |
+
* Currently, it's only used for blog post items, but it will probably be used for all types of
|
2695 |
+
* activity in the future.
|
2696 |
+
*
|
2697 |
+
* @since BuddyPress (2.3.0)
|
2698 |
+
*
|
2699 |
+
* @param string $content The content of the activity item.
|
2700 |
+
* @param array $activity The data passed to bp_activity_add() or the values
|
2701 |
+
* from an Activity obj.
|
2702 |
+
*
|
2703 |
+
* @return string
|
2704 |
+
*/
|
2705 |
+
function bp_activity_create_summary( $content, $activity ) {
|
2706 |
+
$args = array(
|
2707 |
+
'width' => isset( $GLOBALS['content_width'] ) ? (int) $GLOBALS['content_width'] : 'medium',
|
2708 |
+
);
|
2709 |
+
|
2710 |
+
// Get the WP_Post object if this activity type is a blog post.
|
2711 |
+
if ( $activity['type'] === 'new_blog_post' ) {
|
2712 |
+
$content = get_post( $activity['secondary_item_id'] );
|
2713 |
+
}
|
2714 |
+
|
2715 |
+
/**
|
2716 |
+
* Filter the class name of the media extractor when creating an Activity summary.
|
2717 |
+
*
|
2718 |
+
* Use this filter to change the media extractor used to extract media info for the activity item.
|
2719 |
+
*
|
2720 |
+
* @since BuddyPress (2.3.0)
|
2721 |
+
*
|
2722 |
+
* @param string $extractor Class name.
|
2723 |
+
* @param string $content The content of the activity item.
|
2724 |
+
* @param array $activity The data passed to bp_activity_add() or the values from an Activity obj.
|
2725 |
+
*/
|
2726 |
+
$extractor = apply_filters( 'bp_activity_create_summary_extractor_class', 'BP_Media_Extractor', $content, $activity );
|
2727 |
+
$extractor = new $extractor;
|
2728 |
+
|
2729 |
+
/**
|
2730 |
+
* Filter the arguments passed to the media extractor when creating an Activity summary.
|
2731 |
+
*
|
2732 |
+
* @since BuddyPress (2.3.0)
|
2733 |
+
*
|
2734 |
+
* @param array $args Array of bespoke data for the media extractor.
|
2735 |
+
* @param string $content The content of the activity item.
|
2736 |
+
* @param array $activity The data passed to bp_activity_add() or the values from an Activity obj.
|
2737 |
+
* @param BP_Media_Extractor $extractor The media extractor object.
|
2738 |
+
*/
|
2739 |
+
$args = apply_filters( 'bp_activity_create_summary_extractor_args', $args, $content, $activity, $extractor );
|
2740 |
+
|
2741 |
+
|
2742 |
+
// Extract media information from the $content.
|
2743 |
+
$media = $extractor->extract( $content, BP_Media_Extractor::ALL, $args );
|
2744 |
+
|
2745 |
+
// If we converted $content to an object earlier, flip it back to a string.
|
2746 |
+
if ( is_a( $content, 'WP_Post' ) ) {
|
2747 |
+
$content = $content->post_content;
|
2748 |
+
}
|
2749 |
+
|
2750 |
+
$para_count = substr_count( strtolower( wpautop( $content ) ), '<p>' );
|
2751 |
+
$has_audio = ! empty( $media['has']['audio'] ) && $media['has']['audio'];
|
2752 |
+
$has_videos = ! empty( $media['has']['videos'] ) && $media['has']['videos'];
|
2753 |
+
$has_feat_image = ! empty( $media['has']['featured_images'] ) && $media['has']['featured_images'];
|
2754 |
+
$has_galleries = ! empty( $media['has']['galleries'] ) && $media['has']['galleries'];
|
2755 |
+
$has_images = ! empty( $media['has']['images'] ) && $media['has']['images'];
|
2756 |
+
$has_embeds = false;
|
2757 |
+
|
2758 |
+
// Embeds must be subtracted from the paragraph count.
|
2759 |
+
if ( ! empty( $media['has']['embeds'] ) ) {
|
2760 |
+
$has_embeds = $media['has']['embeds'] > 0;
|
2761 |
+
$para_count -= count( $media['has']['embeds'] );
|
2762 |
+
}
|
2763 |
+
|
2764 |
+
$extracted_media = array();
|
2765 |
+
$use_media_type = '';
|
2766 |
+
$image_source = '';
|
2767 |
+
|
2768 |
+
// If it's a short article and there's an embed/audio/video, use it.
|
2769 |
+
if ( $para_count <= 3 ) {
|
2770 |
+
if ( $has_embeds ) {
|
2771 |
+
$use_media_type = 'embeds';
|
2772 |
+
} elseif ( $has_audio ) {
|
2773 |
+
$use_media_type = 'audio';
|
2774 |
+
} elseif ( $has_videos ) {
|
2775 |
+
$use_media_type = 'videos';
|
2776 |
+
}
|
2777 |
+
}
|
2778 |
+
|
2779 |
+
// If not, or in any other situation, try to use an image.
|
2780 |
+
if ( ! $use_media_type && $has_images ) {
|
2781 |
+
$use_media_type = 'images';
|
2782 |
+
$image_source = 'html';
|
2783 |
+
|
2784 |
+
// Featured Image > Galleries > inline <img>.
|
2785 |
+
if ( $has_feat_image ) {
|
2786 |
+
$image_source = 'featured_images';
|
2787 |
+
|
2788 |
+
} elseif ( $has_galleries ) {
|
2789 |
+
$image_source = 'galleries';
|
2790 |
+
}
|
2791 |
+
}
|
2792 |
+
|
2793 |
+
// Extract an item from the $media results.
|
2794 |
+
if ( $use_media_type ) {
|
2795 |
+
if ( $use_media_type === 'images' ) {
|
2796 |
+
$extracted_media = wp_list_filter( $media[ $use_media_type ], array( 'source' => $image_source ) );
|
2797 |
+
$extracted_media = array_shift( $extracted_media );
|
2798 |
+
} else {
|
2799 |
+
$extracted_media = array_shift( $media[ $use_media_type ] );
|
2800 |
+
}
|
2801 |
+
|
2802 |
+
/**
|
2803 |
+
* Filter the results of the media extractor when creating an Activity summary.
|
2804 |
+
*
|
2805 |
+
* @since BuddyPress (2.3.0)
|
2806 |
+
*
|
2807 |
+
* @param array $extracted_media Extracted media item. See {@link BP_Media_Extractor::extract()} for format.
|
2808 |
+
* @param string $content Content of the activity item.
|
2809 |
+
* @param array $activity The data passed to bp_activity_add() or the values from an Activity obj.
|
2810 |
+
* @param array $media All results from the media extraction.
|
2811 |
+
* See {@link BP_Media_Extractor::extract()} for format.
|
2812 |
+
* @param string $use_media_type The kind of media item that was preferentially extracted.
|
2813 |
+
* @param string $image_source If $use_media_type was "images", the preferential source of the image.
|
2814 |
+
* Otherwise empty.
|
2815 |
+
*/
|
2816 |
+
$extracted_media = apply_filters(
|
2817 |
+
'bp_activity_create_summary_extractor_result',
|
2818 |
+
$extracted_media,
|
2819 |
+
$content,
|
2820 |
+
$activity,
|
2821 |
+
$media,
|
2822 |
+
$use_media_type,
|
2823 |
+
$image_source
|
2824 |
+
);
|
2825 |
+
}
|
2826 |
+
|
2827 |
+
// Generate a text excerpt for this activity item (and remove any oEmbeds URLs).
|
2828 |
+
$summary = strip_shortcodes( html_entity_decode( strip_tags( $content ) ) );
|
2829 |
+
$summary = bp_create_excerpt( preg_replace( '#^\s*(https?://[^\s"]+)\s*$#im', '', $summary ) );
|
2830 |
+
|
2831 |
+
if ( $use_media_type === 'embeds' ) {
|
2832 |
+
$summary .= PHP_EOL . PHP_EOL . $extracted_media['url'];
|
2833 |
+
} elseif ( $use_media_type === 'images' ) {
|
2834 |
+
$summary .= sprintf( ' <img src="%s">', esc_url( $extracted_media['url'] ) );
|
2835 |
+
} elseif ( in_array( $use_media_type, array( 'audio', 'videos' ), true ) ) {
|
2836 |
+
$summary .= PHP_EOL . PHP_EOL . $extracted_media['original']; // Full shortcode.
|
2837 |
+
}
|
2838 |
+
|
2839 |
+
/**
|
2840 |
+
* Filters the newly-generated summary for the activity item.
|
2841 |
+
*
|
2842 |
+
* @since BuddyPress (2.3.0)
|
2843 |
+
*
|
2844 |
+
* @param string $summary Activity summary HTML.
|
2845 |
+
* @param string $content Content of the activity item.
|
2846 |
+
* @param array $activity The data passed to bp_activity_add() or the values from an Activity obj.
|
2847 |
+
* @param array $extracted_media Media item extracted. See {@link BP_Media_Extractor::extract()} for format.
|
2848 |
+
*/
|
2849 |
+
return apply_filters( 'bp_activity_create_summary', $summary, $content, $activity, $extracted_media );
|
2850 |
+
}
|
2851 |
+
|
2852 |
Â
/**
|
2853 |
Â
* Fetch whether the current user is allowed to mark items as spam.
|
2854 |
Â
*
|
2874 |
Â
* @since BuddyPress (1.6.0)
|
2875 |
Â
*
|
2876 |
Â
* @param BP_Activity_Activity $activity The activity item to be spammed.
|
2877 |
+
* @param string $source Optional. Default is "by_a_person" (ie, a person has
|
2878 |
+
* manually marked the activity as spam). BP core also
|
2879 |
+
* accepts 'by_akismet'.
|
2880 |
Â
*/
|
2881 |
Â
function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
|
2882 |
Â
$bp = buddypress();
|
2909 |
Â
* @since BuddyPress (1.6.0)
|
2910 |
Â
*
|
2911 |
Â
* @param BP_Activity_Activity $activity Activity item being marked as spam.
|
2912 |
+
* @param string $source Source of determination of spam status. For example
|
2913 |
+
* "by_a_person" or "by_akismet".
|
2914 |
Â
*/
|
2915 |
Â
do_action( 'bp_activity_mark_as_spam', $activity, $source );
|
2916 |
Â
}
|
2920 |
Â
*
|
2921 |
Â
* @since BuddyPress (1.6.0)
|
2922 |
Â
*
|
2923 |
+
* @param BP_Activity_Activity $activity The activity item to be hammed. Passed by reference.
|
2924 |
+
* @param string $source Optional. Default is "by_a_person" (ie, a person has
|
2925 |
+
* manually marked the activity as spam). BP core also accepts
|
2926 |
+
* 'by_akismet'.
|
2927 |
Â
*/
|
2928 |
Â
function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
|
2929 |
Â
$bp = buddypress();
|
2956 |
Â
* @since BuddyPress (1.6.0)
|
2957 |
Â
*
|
2958 |
Â
* @param BP_Activity_Activity $activity Activity item being marked as ham.
|
2959 |
+
* @param string $source Source of determination of ham status. For example
|
2960 |
+
* "by_a_person" or "by_akismet".
|
2961 |
Â
*/
|
2962 |
Â
do_action( 'bp_activity_mark_as_ham', $activity, $source );
|
2963 |
Â
}
|
2980 |
Â
* @see BP_Embed
|
2981 |
Â
* @see bp_embed_activity_cache()
|
2982 |
Â
* @see bp_embed_activity_save_cache()
|
2983 |
+
*
|
2984 |
Â
* @uses add_filter() To attach 'bp_get_activity_id' to 'embed_post_id'.
|
2985 |
Â
* @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'.
|
2986 |
Â
* @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'.
|
3005 |
Â
* @see BP_Embed
|
3006 |
Â
* @see bp_embed_activity_cache()
|
3007 |
Â
* @see bp_embed_activity_save_cache()
|
3008 |
+
*
|
3009 |
Â
* @uses add_filter() To attach 'bp_get_activity_comment_id' to 'embed_post_id'.
|
3010 |
Â
* @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'.
|
3011 |
Â
* @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'.
|
3065 |
Â
* @see BP_Embed::parse_oembed()
|
3066 |
Â
* @uses bp_activity_get_meta()
|
3067 |
Â
*
|
3068 |
+
* @param string $cache An empty string passed by BP_Embed::parse_oembed() for
|
3069 |
+
* functions like this one to filter.
|
3070 |
+
* @param int $id The ID of the activity item.
|
3071 |
Â
* @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
|
3072 |
+
*
|
3073 |
Â
* @return mixed The cached embeds for this activity item.
|
3074 |
Â
*/
|
3075 |
Â
function bp_embed_activity_cache( $cache, $id, $cachekey ) {
|
3086 |
Â
* @see BP_Embed::parse_oembed()
|
3087 |
Â
* @uses bp_activity_update_meta()
|
3088 |
Â
*
|
3089 |
+
* @param string $cache An empty string passed by BP_Embed::parse_oembed() for
|
3090 |
+
* functions like this one to filter.
|
3091 |
Â
* @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
|
3092 |
+
* @param int $id The ID of the activity item.
|
3093 |
+
*
|
3094 |
Â
* @return bool True on success, false on failure.
|
3095 |
Â
*/
|
3096 |
Â
function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
|
bp-activity/bp-activity-loader.php
CHANGED
@@ -15,14 +15,14 @@ defined( 'ABSPATH' ) || exit;
|
|
15 |
Â
/**
|
16 |
Â
* Main Activity Class.
|
17 |
Â
*
|
18 |
-
* @since BuddyPress (1.5)
|
19 |
Â
*/
|
20 |
Â
class BP_Activity_Component extends BP_Component {
|
21 |
Â
|
22 |
Â
/**
|
23 |
Â
* Start the activity component setup process.
|
24 |
Â
*
|
25 |
-
* @since BuddyPress (1.5)
|
26 |
Â
*/
|
27 |
Â
public function __construct() {
|
28 |
Â
parent::start(
|
@@ -38,7 +38,7 @@ class BP_Activity_Component extends BP_Component {
|
|
38 |
Â
/**
|
39 |
Â
* Include component files.
|
40 |
Â
*
|
41 |
-
* @since BuddyPress (1.5)
|
42 |
Â
*
|
43 |
Â
* @see BP_Component::includes() for a description of arguments.
|
44 |
Â
*
|
@@ -62,7 +62,7 @@ class BP_Activity_Component extends BP_Component {
|
|
62 |
Â
$akismet_key = bp_get_option( 'wordpress_api_key' );
|
63 |
Â
|
64 |
Â
/** This filter is documented in bp-activity/bp-activity-actions.php */
|
65 |
-
if ( defined( 'AKISMET_VERSION' ) && ( !empty( $akismet_key ) || defined( 'WPCOM_API_KEY' ) ) && apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) ) {
|
66 |
Â
$includes[] = 'akismet';
|
67 |
Â
}
|
68 |
Â
|
@@ -79,7 +79,7 @@ class BP_Activity_Component extends BP_Component {
|
|
79 |
Â
* The BP_ACTIVITY_SLUG constant is deprecated, and only used here for
|
80 |
Â
* backwards compatibility.
|
81 |
Â
*
|
82 |
-
* @since BuddyPress (1.5)
|
83 |
Â
*
|
84 |
Â
* @see BP_Component::setup_globals() for a description of arguments.
|
85 |
Â
*
|
@@ -122,7 +122,7 @@ class BP_Activity_Component extends BP_Component {
|
|
122 |
Â
/**
|
123 |
Â
* Set up component navigation.
|
124 |
Â
*
|
125 |
-
* @since BuddyPress (1.5)
|
126 |
Â
*
|
127 |
Â
* @see BP_Component::setup_nav() for a description of arguments.
|
128 |
Â
* @uses bp_is_active()
|
@@ -130,10 +130,8 @@ class BP_Activity_Component extends BP_Component {
|
|
130 |
Â
* @uses bp_get_friends_slug()
|
131 |
Â
* @uses bp_get_groups_slug()
|
132 |
Â
*
|
133 |
-
* @param array $main_nav Optional. See BP_Component::setup_nav() for
|
134 |
-
*
|
135 |
-
* @param array $sub_nav Optional. See BP_Component::setup_nav() for
|
136 |
-
* description.
|
137 |
Â
*/
|
138 |
Â
public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
|
139 |
Â
|
@@ -187,15 +185,17 @@ class BP_Activity_Component extends BP_Component {
|
|
187 |
Â
}
|
188 |
Â
|
189 |
Â
// Favorite activity items
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
Â
|
|
Â
|
|
199 |
Â
|
200 |
Â
// Additional menu if friends is active
|
201 |
Â
if ( bp_is_active( 'friends' ) ) {
|
@@ -229,7 +229,7 @@ class BP_Activity_Component extends BP_Component {
|
|
229 |
Â
/**
|
230 |
Â
* Set up the component entries in the WordPress Admin Bar.
|
231 |
Â
*
|
232 |
-
* @since BuddyPress (1.5)
|
233 |
Â
*
|
234 |
Â
* @see BP_Component::setup_nav() for a description of the $wp_admin_nav
|
235 |
Â
* parameter array.
|
@@ -291,12 +291,15 @@ class BP_Activity_Component extends BP_Component {
|
|
291 |
Â
}
|
292 |
Â
|
293 |
Â
// Favorites
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
Â
|
|
Â
|
|
Â
|
|
300 |
Â
|
301 |
Â
// Friends?
|
302 |
Â
if ( bp_is_active( 'friends' ) ) {
|
@@ -325,7 +328,7 @@ class BP_Activity_Component extends BP_Component {
|
|
325 |
Â
/**
|
326 |
Â
* Set up the title for pages and <title>.
|
327 |
Â
*
|
328 |
-
* @since BuddyPress (1.5)
|
329 |
Â
*
|
330 |
Â
* @uses bp_is_activity_component()
|
331 |
Â
* @uses bp_is_my_profile()
|
@@ -354,7 +357,7 @@ class BP_Activity_Component extends BP_Component {
|
|
354 |
Â
/**
|
355 |
Â
* Set up actions necessary for the component.
|
356 |
Â
*
|
357 |
-
* @since BuddyPress (1.6)
|
358 |
Â
*/
|
359 |
Â
public function setup_actions() {
|
360 |
Â
// Spam prevention
|
@@ -364,7 +367,7 @@ class BP_Activity_Component extends BP_Component {
|
|
364 |
Â
}
|
365 |
Â
|
366 |
Â
/**
|
367 |
-
* Setup cache groups
|
368 |
Â
*
|
369 |
Â
* @since BuddyPress (2.2.0)
|
370 |
Â
*/
|
15 |
Â
/**
|
16 |
Â
* Main Activity Class.
|
17 |
Â
*
|
18 |
+
* @since BuddyPress (1.5.0)
|
19 |
Â
*/
|
20 |
Â
class BP_Activity_Component extends BP_Component {
|
21 |
Â
|
22 |
Â
/**
|
23 |
Â
* Start the activity component setup process.
|
24 |
Â
*
|
25 |
+
* @since BuddyPress (1.5.0)
|
26 |
Â
*/
|
27 |
Â
public function __construct() {
|
28 |
Â
parent::start(
|
38 |
Â
/**
|
39 |
Â
* Include component files.
|
40 |
Â
*
|
41 |
+
* @since BuddyPress (1.5.0)
|
42 |
Â
*
|
43 |
Â
* @see BP_Component::includes() for a description of arguments.
|
44 |
Â
*
|
62 |
Â
$akismet_key = bp_get_option( 'wordpress_api_key' );
|
63 |
Â
|
64 |
Â
/** This filter is documented in bp-activity/bp-activity-actions.php */
|
65 |
+
if ( defined( 'AKISMET_VERSION' ) && class_exists( 'Akismet' ) && ( ! empty( $akismet_key ) || defined( 'WPCOM_API_KEY' ) ) && apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) ) {
|
66 |
Â
$includes[] = 'akismet';
|
67 |
Â
}
|
68 |
Â
|
79 |
Â
* The BP_ACTIVITY_SLUG constant is deprecated, and only used here for
|
80 |
Â
* backwards compatibility.
|
81 |
Â
*
|
82 |
+
* @since BuddyPress (1.5.0)
|
83 |
Â
*
|
84 |
Â
* @see BP_Component::setup_globals() for a description of arguments.
|
85 |
Â
*
|
122 |
Â
/**
|
123 |
Â
* Set up component navigation.
|
124 |
Â
*
|
125 |
+
* @since BuddyPress (1.5.0)
|
126 |
Â
*
|
127 |
Â
* @see BP_Component::setup_nav() for a description of arguments.
|
128 |
Â
* @uses bp_is_active()
|
130 |
Â
* @uses bp_get_friends_slug()
|
131 |
Â
* @uses bp_get_groups_slug()
|
132 |
Â
*
|
133 |
+
* @param array $main_nav Optional. See BP_Component::setup_nav() for description.
|
134 |
+
* @param array $sub_nav Optional. See BP_Component::setup_nav() for description.
|
Â
|
|
Â
|
|
135 |
Â
*/
|
136 |
Â
public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
|
137 |
Â
|
185 |
Â
}
|
186 |
Â
|
187 |
Â
// Favorite activity items
|
188 |
+
if ( bp_activity_can_favorite() ) {
|
189 |
+
$sub_nav[] = array(
|
190 |
+
'name' => _x( 'Favorites', 'Profile activity screen sub nav', 'buddypress' ),
|
191 |
+
'slug' => 'favorites',
|
192 |
+
'parent_url' => $activity_link,
|
193 |
+
'parent_slug' => $this->slug,
|
194 |
+
'screen_function' => 'bp_activity_screen_favorites',
|
195 |
+
'position' => 30,
|
196 |
+
'item_css_id' => 'activity-favs'
|
197 |
+
);
|
198 |
+
}
|
199 |
Â
|
200 |
Â
// Additional menu if friends is active
|
201 |
Â
if ( bp_is_active( 'friends' ) ) {
|
229 |
Â
/**
|
230 |
Â
* Set up the component entries in the WordPress Admin Bar.
|
231 |
Â
*
|
232 |
+
* @since BuddyPress (1.5.0)
|
233 |
Â
*
|
234 |
Â
* @see BP_Component::setup_nav() for a description of the $wp_admin_nav
|
235 |
Â
* parameter array.
|
291 |
Â
}
|
292 |
Â
|
293 |
Â
// Favorites
|
294 |
+
// Favorite activity items
|
295 |
+
if ( bp_activity_can_favorite() ) {
|
296 |
+
$wp_admin_nav[] = array(
|
297 |
+
'parent' => 'my-account-' . $this->id,
|
298 |
+
'id' => 'my-account-' . $this->id . '-favorites',
|
299 |
+
'title' => _x( 'Favorites', 'My Account Activity sub nav', 'buddypress' ),
|
300 |
+
'href' => trailingslashit( $activity_link . 'favorites' )
|
301 |
+
);
|
302 |
+
}
|
303 |
Â
|
304 |
Â
// Friends?
|
305 |
Â
if ( bp_is_active( 'friends' ) ) {
|
328 |
Â
/**
|
329 |
Â
* Set up the title for pages and <title>.
|
330 |
Â
*
|
331 |
+
* @since BuddyPress (1.5.0)
|
332 |
Â
*
|
333 |
Â
* @uses bp_is_activity_component()
|
334 |
Â
* @uses bp_is_my_profile()
|
357 |
Â
/**
|
358 |
Â
* Set up actions necessary for the component.
|
359 |
Â
*
|
360 |
+
* @since BuddyPress (1.6.0)
|
361 |
Â
*/
|
362 |
Â
public function setup_actions() {
|
363 |
Â
// Spam prevention
|
367 |
Â
}
|
368 |
Â
|
369 |
Â
/**
|
370 |
+
* Setup cache groups.
|
371 |
Â
*
|
372 |
Â
* @since BuddyPress (2.2.0)
|
373 |
Â
*/
|
bp-activity/bp-activity-notifications.php
CHANGED
@@ -34,9 +34,9 @@ defined( 'ABSPATH' ) || exit;
|
|
34 |
Â
* @uses apply_filters() To call the 'bp_activity_at_message_notification_subject' hook.
|
35 |
Â
* @uses apply_filters() To call the 'bp_activity_at_message_notification_message' hook.
|
36 |
Â
* @uses wp_mail()
|
37 |
-
* @uses do_action() To call the 'bp_activity_sent_mention_email' hook
|
38 |
Â
*
|
39 |
-
* @param int $activity_id
|
40 |
Â
* @param int $receiver_user_id The ID of the user who is receiving the update.
|
41 |
Â
*/
|
42 |
Â
function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) {
|
@@ -113,7 +113,7 @@ To view and respond to the message, log in and visit: %3$s
|
|
113 |
Â
*
|
114 |
Â
* @since BuddyPress (1.2.0)
|
115 |
Â
*
|
116 |
-
* @param string $subject
|
117 |
Â
* @param string $poster_name Name of the person who made the @mention.
|
118 |
Â
*/
|
119 |
Â
$subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name );
|
@@ -123,10 +123,10 @@ To view and respond to the message, log in and visit: %3$s
|
|
123 |
Â
*
|
124 |
Â
* @since BuddyPress (1.2.0)
|
125 |
Â
*
|
126 |
-
* @param string $message
|
127 |
-
* @param string $poster_name
|
128 |
-
* @param string $content
|
129 |
-
* @param string $message_link
|
130 |
Â
* @param string $settings_link URL permalink for the user's notification settings area.
|
131 |
Â
*/
|
132 |
Â
$message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link );
|
@@ -139,10 +139,10 @@ To view and respond to the message, log in and visit: %3$s
|
|
139 |
Â
*
|
140 |
Â
* @since BuddyPress (1.5.0)
|
141 |
Â
*
|
142 |
-
* @param BP_Activity_Activity $activity
|
143 |
-
* @param string $subject
|
144 |
-
* @param string $message
|
145 |
-
* @param string $content
|
146 |
Â
* @param int $receiver_user_id The ID of the user who is receiving the update.
|
147 |
Â
*/
|
148 |
Â
do_action( 'bp_activity_sent_mention_email', $activity, $subject, $message, $content, $receiver_user_id );
|
@@ -163,19 +163,21 @@ To view and respond to the message, log in and visit: %3$s
|
|
163 |
Â
* @uses wp_specialchars_decode()
|
164 |
Â
* @uses get_blog_option()
|
165 |
Â
* @uses bp_get_root_blog_id()
|
166 |
-
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_to' hook
|
167 |
-
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_subject' hook
|
168 |
-
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_message' hook
|
169 |
Â
* @uses wp_mail()
|
170 |
-
* @uses do_action() To call the 'bp_activity_sent_reply_to_update_email' hook
|
171 |
-
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_to' hook
|
172 |
-
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_subject' hook
|
173 |
-
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_message' hook
|
174 |
-
* @uses do_action() To call the 'bp_activity_sent_reply_to_reply_email' hook
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
175 |
Â
*
|
176 |
-
* @
|
177 |
-
* @param int $commenter_id The ID of the user who posted the comment.
|
178 |
-
* @param array $params {@link bp_activity_new_comment()}
|
179 |
Â
*/
|
180 |
Â
function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 0, $params = array() ) {
|
181 |
Â
|
@@ -229,7 +231,7 @@ To view your original update and all comments, log in and visit: %3$s
|
|
229 |
Â
*
|
230 |
Â
* @since BuddyPress (1.2.0)
|
231 |
Â
*
|
232 |
-
* @param string $subject
|
233 |
Â
* @param string $poster_name Name of the person who made the comment.
|
234 |
Â
*/
|
235 |
Â
$subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject, $poster_name );
|
@@ -239,10 +241,10 @@ To view your original update and all comments, log in and visit: %3$s
|
|
239 |
Â
*
|
240 |
Â
* @since BuddyPress (1.2.0)
|
241 |
Â
*
|
242 |
-
* @param string $message
|
243 |
-
* @param string $poster_name
|
244 |
-
* @param string $content
|
245 |
-
* @param string $thread_link
|
246 |
Â
* @param string $settings_link URL permalink for the user's notification settings area.
|
247 |
Â
*/
|
248 |
Â
$message = apply_filters( 'bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link );
|
@@ -254,12 +256,12 @@ To view your original update and all comments, log in and visit: %3$s
|
|
254 |
Â
*
|
255 |
Â
* @since BuddyPress (1.5.0)
|
256 |
Â
*
|
257 |
-
* @param int $user_id
|
258 |
-
* @param string $subject
|
259 |
-
* @param string $message
|
260 |
-
* @param int $comment_id
|
261 |
Â
* @param int $commenter_id ID of the user who made the comment.
|
262 |
-
* @param array $params
|
263 |
Â
*/
|
264 |
Â
do_action( 'bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
|
265 |
Â
}
|
@@ -317,7 +319,7 @@ To view the original activity, your comment and all replies, log in and visit: %
|
|
317 |
Â
*
|
318 |
Â
* @since BuddyPress (1.2.0)
|
319 |
Â
*
|
320 |
-
* @param string $subject
|
321 |
Â
* @param string $poster_name Name of the person who made the comment reply.
|
322 |
Â
*/
|
323 |
Â
$subject = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name );
|
@@ -327,11 +329,11 @@ To view the original activity, your comment and all replies, log in and visit: %
|
|
327 |
Â
*
|
328 |
Â
* @since BuddyPress (1.2.0)
|
329 |
Â
*
|
330 |
-
* @param string $message
|
331 |
-
* @param string $poster_name
|
332 |
-
* @param string $content
|
333 |
Â
* @param string $settings_link URL permalink for the user's notification settings area.
|
334 |
-
* @param string $thread_link
|
335 |
Â
*/
|
336 |
Â
$message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link );
|
337 |
Â
|
@@ -342,22 +344,23 @@ To view the original activity, your comment and all replies, log in and visit: %
|
|
342 |
Â
*
|
343 |
Â
* @since BuddyPress (1.5.0)
|
344 |
Â
*
|
345 |
-
* @param int $user_id
|
346 |
-
* @param string $subject
|
347 |
-
* @param string $message
|
348 |
-
* @param int $comment_id
|
349 |
Â
* @param int $commenter_id ID of the user who made the comment.
|
350 |
-
* @param array $params
|
351 |
Â
*/
|
352 |
-
do_action( 'bp_activity_sent_reply_to_reply_email', $
|
353 |
Â
}
|
354 |
Â
}
|
355 |
Â
|
356 |
Â
/**
|
357 |
-
* Helper method to map action arguments to function parameters
|
358 |
Â
*
|
359 |
Â
* @since BuddyPress (1.9.0)
|
360 |
-
*
|
Â
|
|
361 |
Â
* @param array $params
|
362 |
Â
*/
|
363 |
Â
function bp_activity_new_comment_notification_helper( $comment_id, $params ) {
|
@@ -379,11 +382,12 @@ add_action( 'bp_activity_comment_posted', 'bp_activity_new_comment_notification_
|
|
379 |
Â
* @uses apply_filters() To call the 'bp_activity_single_at_mentions_notification' hook.
|
380 |
Â
* @uses do_action() To call 'activity_format_notifications' hook.
|
381 |
Â
*
|
382 |
-
* @param string $action
|
383 |
-
* @param int
|
384 |
-
* @param int
|
385 |
-
* @param int
|
386 |
-
* @param string $format
|
Â
|
|
387 |
Â
* @return string $return Formatted @mention notification.
|
388 |
Â
*/
|
389 |
Â
function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
|
@@ -417,11 +421,11 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
|
|
417 |
Â
*
|
418 |
Â
* @since BuddyPress (1.5.0)
|
419 |
Â
*
|
420 |
-
* @param string $string
|
421 |
Â
* @param string $at_mention_link The permalink for the mention.
|
422 |
-
* @param int $total_items
|
423 |
-
* @param int $activity_id
|
424 |
-
* @param int $poster_user_id
|
425 |
Â
*/
|
426 |
Â
$return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', '<a href="' . esc_url( $at_mention_link ) . '" title="' . esc_attr( $at_mention_title ) . '">' . esc_html( $text ) . '</a>', $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );
|
427 |
Â
} else {
|
@@ -435,11 +439,11 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
|
|
435 |
Â
*
|
436 |
Â
* @since BuddyPress (1.5.0)
|
437 |
Â
*
|
438 |
-
* @param array $array
|
439 |
Â
* @param string $at_mention_link The permalink for the mention.
|
440 |
-
* @param int $total_items
|
441 |
-
* @param int $activity_id
|
442 |
-
* @param int $poster_user_id
|
443 |
Â
*/
|
444 |
Â
$return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', array(
|
445 |
Â
'text' => $text,
|
@@ -452,10 +456,10 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
|
|
452 |
Â
*
|
453 |
Â
* @since BuddyPress (1.2.0)
|
454 |
Â
*
|
455 |
-
* @param string $action
|
456 |
-
* @param int $item_id
|
457 |
Â
* @param int $secondary_item_id @mention mentioner ID.
|
458 |
-
* @param int $total_items
|
459 |
Â
*/
|
460 |
Â
do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
|
461 |
Â
|
@@ -472,11 +476,11 @@ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id
|
|
472 |
Â
*
|
473 |
Â
* @since BuddyPress (1.9.0)
|
474 |
Â
*
|
475 |
-
* @param
|
476 |
Â
* @param string $subject (not used)
|
477 |
Â
* @param string $message (not used)
|
478 |
Â
* @param string $content (not used)
|
479 |
-
* @param int
|
480 |
Â
*/
|
481 |
Â
function bp_activity_at_mention_add_notification( $activity, $subject, $message, $content, $receiver_user_id ) {
|
482 |
Â
if ( bp_is_active( 'notifications' ) ) {
|
@@ -518,6 +522,8 @@ add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notificati
|
|
518 |
Â
* Mark at-mention notification as read when user visits the activity with the mention.
|
519 |
Â
*
|
520 |
Â
* @since BuddyPress (2.0.0)
|
Â
|
|
Â
|
|
521 |
Â
*/
|
522 |
Â
function bp_activity_remove_screen_notifications_single_activity_permalink( $activity ) {
|
523 |
Â
if ( ! bp_is_active( 'notifications' ) ) {
|
34 |
Â
* @uses apply_filters() To call the 'bp_activity_at_message_notification_subject' hook.
|
35 |
Â
* @uses apply_filters() To call the 'bp_activity_at_message_notification_message' hook.
|
36 |
Â
* @uses wp_mail()
|
37 |
+
* @uses do_action() To call the 'bp_activity_sent_mention_email' hook.
|
38 |
Â
*
|
39 |
+
* @param int $activity_id The ID of the activity update.
|
40 |
Â
* @param int $receiver_user_id The ID of the user who is receiving the update.
|
41 |
Â
*/
|
42 |
Â
function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) {
|
113 |
Â
*
|
114 |
Â
* @since BuddyPress (1.2.0)
|
115 |
Â
*
|
116 |
+
* @param string $subject Email notification subject text.
|
117 |
Â
* @param string $poster_name Name of the person who made the @mention.
|
118 |
Â
*/
|
119 |
Â
$subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name );
|
123 |
Â
*
|
124 |
Â
* @since BuddyPress (1.2.0)
|
125 |
Â
*
|
126 |
+
* @param string $message Email notification message text.
|
127 |
+
* @param string $poster_name Name of the person who made the @mention.
|
128 |
+
* @param string $content Content of the @mention.
|
129 |
+
* @param string $message_link URL permalink for the activity message.
|
130 |
Â
* @param string $settings_link URL permalink for the user's notification settings area.
|
131 |
Â
*/
|
132 |
Â
$message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link );
|
139 |
Â
*
|
140 |
Â
* @since BuddyPress (1.5.0)
|
141 |
Â
*
|
142 |
+
* @param BP_Activity_Activity $activity Activity Item object.
|
143 |
+
* @param string $subject Email notification subject text.
|
144 |
+
* @param string $message Email notification message text.
|
145 |
+
* @param string $content Content of the @mention.
|
146 |
Â
* @param int $receiver_user_id The ID of the user who is receiving the update.
|
147 |
Â
*/
|
148 |
Â
do_action( 'bp_activity_sent_mention_email', $activity, $subject, $message, $content, $receiver_user_id );
|
163 |
Â
* @uses wp_specialchars_decode()
|
164 |
Â
* @uses get_blog_option()
|
165 |
Â
* @uses bp_get_root_blog_id()
|
166 |
+
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_to' hook.
|
167 |
+
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_subject' hook.
|
168 |
+
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_message' hook.
|
169 |
Â
* @uses wp_mail()
|
170 |
+
* @uses do_action() To call the 'bp_activity_sent_reply_to_update_email' hook.
|
171 |
+
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_to' hook.
|
172 |
+
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_subject' hook.
|
173 |
+
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_message' hook.
|
174 |
+
* @uses do_action() To call the 'bp_activity_sent_reply_to_reply_email' hook.
|
175 |
+
*
|
176 |
+
* @param int $comment_id The comment id.
|
177 |
+
* @param int $commenter_id The ID of the user who posted the comment.
|
178 |
+
* @param array $params {@link bp_activity_new_comment()}
|
179 |
Â
*
|
180 |
+
* @return bool
|
Â
|
|
Â
|
|
181 |
Â
*/
|
182 |
Â
function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 0, $params = array() ) {
|
183 |
Â
|
231 |
Â
*
|
232 |
Â
* @since BuddyPress (1.2.0)
|
233 |
Â
*
|
234 |
+
* @param string $subject Email notification subject text.
|
235 |
Â
* @param string $poster_name Name of the person who made the comment.
|
236 |
Â
*/
|
237 |
Â
$subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject, $poster_name );
|
241 |
Â
*
|
242 |
Â
* @since BuddyPress (1.2.0)
|
243 |
Â
*
|
244 |
+
* @param string $message Email notification message text.
|
245 |
+
* @param string $poster_name Name of the person who made the comment.
|
246 |
+
* @param string $content Content of the comment.
|
247 |
+
* @param string $thread_link URL permalink for the activity thread.
|
248 |
Â
* @param string $settings_link URL permalink for the user's notification settings area.
|
249 |
Â
*/
|
250 |
Â
$message = apply_filters( 'bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link );
|
256 |
Â
*
|
257 |
Â
* @since BuddyPress (1.5.0)
|
258 |
Â
*
|
259 |
+
* @param int $user_id ID of the original activity item author.
|
260 |
+
* @param string $subject Email notification subject text.
|
261 |
+
* @param string $message Email notification message text.
|
262 |
+
* @param int $comment_id ID for the newly received comment.
|
263 |
Â
* @param int $commenter_id ID of the user who made the comment.
|
264 |
+
* @param array $params Arguments used with the original activity comment.
|
265 |
Â
*/
|
266 |
Â
do_action( 'bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
|
267 |
Â
}
|
319 |
Â
*
|
320 |
Â
* @since BuddyPress (1.2.0)
|
321 |
Â
*
|
322 |
+
* @param string $subject Email notification subject text.
|
323 |
Â
* @param string $poster_name Name of the person who made the comment reply.
|
324 |
Â
*/
|
325 |
Â
$subject = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name );
|
329 |
Â
*
|
330 |
Â
* @since BuddyPress (1.2.0)
|
331 |
Â
*
|
332 |
+
* @param string $message Email notification message text.
|
333 |
+
* @param string $poster_name Name of the person who made the comment reply.
|
334 |
+
* @param string $content Content of the comment reply.
|
335 |
Â
* @param string $settings_link URL permalink for the user's notification settings area.
|
336 |
+
* @param string $thread_link URL permalink for the activity thread.
|
337 |
Â
*/
|
338 |
Â
$message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link );
|
339 |
Â
|
344 |
Â
*
|
345 |
Â
* @since BuddyPress (1.5.0)
|
346 |
Â
*
|
347 |
+
* @param int $user_id ID of the parent activity item author.
|
348 |
+
* @param string $subject Email notification subject text.
|
349 |
+
* @param string $message Email notification message text.
|
350 |
+
* @param int $comment_id ID for the newly received comment.
|
351 |
Â
* @param int $commenter_id ID of the user who made the comment.
|
352 |
+
* @param array $params Arguments used with the original activity comment.
|
353 |
Â
*/
|
354 |
+
do_action( 'bp_activity_sent_reply_to_reply_email', $parent_comment->user_id, $subject, $message, $comment_id, $commenter_id, $params );
|
355 |
Â
}
|
356 |
Â
}
|
357 |
Â
|
358 |
Â
/**
|
359 |
+
* Helper method to map action arguments to function parameters.
|
360 |
Â
*
|
361 |
Â
* @since BuddyPress (1.9.0)
|
362 |
+
*
|
363 |
+
* @param int $comment_id
|
364 |
Â
* @param array $params
|
365 |
Â
*/
|
366 |
Â
function bp_activity_new_comment_notification_helper( $comment_id, $params ) {
|
382 |
Â
* @uses apply_filters() To call the 'bp_activity_single_at_mentions_notification' hook.
|
383 |
Â
* @uses do_action() To call 'activity_format_notifications' hook.
|
384 |
Â
*
|
385 |
+
* @param string $action The type of activity item. Just 'new_at_mention' for now.
|
386 |
+
* @param int $item_id The activity ID.
|
387 |
+
* @param int $secondary_item_id In the case of at-mentions, this is the mentioner's ID.
|
388 |
+
* @param int $total_items The total number of notifications to format.
|
389 |
+
* @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise.
|
390 |
+
*
|
391 |
Â
* @return string $return Formatted @mention notification.
|
392 |
Â
*/
|
393 |
Â
function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
|
421 |
Â
*
|
422 |
Â
* @since BuddyPress (1.5.0)
|
423 |
Â
*
|
424 |
+
* @param string $string HTML anchor tag for the mention.
|
425 |
Â
* @param string $at_mention_link The permalink for the mention.
|
426 |
+
* @param int $total_items How many items being notified about.
|
427 |
+
* @param int $activity_id ID of the activity item being formatted.
|
428 |
+
* @param int $poster_user_id ID of the user posting the mention.
|
429 |
Â
*/
|
430 |
Â
$return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', '<a href="' . esc_url( $at_mention_link ) . '" title="' . esc_attr( $at_mention_title ) . '">' . esc_html( $text ) . '</a>', $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );
|
431 |
Â
} else {
|
439 |
Â
*
|
440 |
Â
* @since BuddyPress (1.5.0)
|
441 |
Â
*
|
442 |
+
* @param array $array Array holding the content and permalink for the mention notification.
|
443 |
Â
* @param string $at_mention_link The permalink for the mention.
|
444 |
+
* @param int $total_items How many items being notified about.
|
445 |
+
* @param int $activity_id ID of the activity item being formatted.
|
446 |
+
* @param int $poster_user_id ID of the user posting the mention.
|
447 |
Â
*/
|
448 |
Â
$return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', array(
|
449 |
Â
'text' => $text,
|
456 |
Â
*
|
457 |
Â
* @since BuddyPress (1.2.0)
|
458 |
Â
*
|
459 |
+
* @param string $action The type of activity item.
|
460 |
+
* @param int $item_id The activity ID.
|
461 |
Â
* @param int $secondary_item_id @mention mentioner ID.
|
462 |
+
* @param int $total_items Total amount of items to format.
|
463 |
Â
*/
|
464 |
Â
do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
|
465 |
Â
|
476 |
Â
*
|
477 |
Â
* @since BuddyPress (1.9.0)
|
478 |
Â
*
|
479 |
+
* @param object $activity
|
480 |
Â
* @param string $subject (not used)
|
481 |
Â
* @param string $message (not used)
|
482 |
Â
* @param string $content (not used)
|
483 |
+
* @param int $receiver_user_id
|
484 |
Â
*/
|
485 |
Â
function bp_activity_at_mention_add_notification( $activity, $subject, $message, $content, $receiver_user_id ) {
|
486 |
Â
if ( bp_is_active( 'notifications' ) ) {
|
522 |
Â
* Mark at-mention notification as read when user visits the activity with the mention.
|
523 |
Â
*
|
524 |
Â
* @since BuddyPress (2.0.0)
|
525 |
+
*
|
526 |
+
* @param object BP_Activity_Activity
|
527 |
Â
*/
|
528 |
Â
function bp_activity_remove_screen_notifications_single_activity_permalink( $activity ) {
|
529 |
Â
if ( ! bp_is_active( 'notifications' ) ) {
|
bp-activity/bp-activity-screens.php
CHANGED
@@ -121,9 +121,9 @@ function bp_activity_screen_friends() {
|
|
121 |
Â
* @uses bp_is_active()
|
122 |
Â
* @uses bp_update_is_item_admin()
|
123 |
Â
* @uses bp_current_user_can()
|
124 |
-
* @uses do_action() To call the 'bp_activity_screen_groups' hook
|
125 |
Â
* @uses bp_core_load_template()
|
126 |
-
* @uses apply_filters() To call the 'bp_activity_template_groups_activity' hook
|
127 |
Â
*/
|
128 |
Â
function bp_activity_screen_groups() {
|
129 |
Â
if ( !bp_is_active( 'groups' ) )
|
@@ -155,9 +155,9 @@ function bp_activity_screen_groups() {
|
|
155 |
Â
*
|
156 |
Â
* @uses bp_update_is_item_admin()
|
157 |
Â
* @uses bp_current_user_can()
|
158 |
-
* @uses do_action() To call the 'bp_activity_screen_favorites' hook
|
159 |
Â
* @uses bp_core_load_template()
|
160 |
-
* @uses apply_filters() To call the 'bp_activity_template_favorite_activity' hook
|
161 |
Â
*/
|
162 |
Â
function bp_activity_screen_favorites() {
|
163 |
Â
bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
|
@@ -186,9 +186,9 @@ function bp_activity_screen_favorites() {
|
|
186 |
Â
*
|
187 |
Â
* @uses bp_update_is_item_admin()
|
188 |
Â
* @uses bp_current_user_can()
|
189 |
-
* @uses do_action() To call the 'bp_activity_screen_mentions' hook
|
190 |
Â
* @uses bp_core_load_template()
|
191 |
-
* @uses apply_filters() To call the 'bp_activity_template_mention_activity' hook
|
192 |
Â
*/
|
193 |
Â
function bp_activity_screen_mentions() {
|
194 |
Â
bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
|
@@ -230,7 +230,6 @@ add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' )
|
|
230 |
Â
*
|
231 |
Â
* @since BuddyPress (1.2.0)
|
232 |
Â
*
|
233 |
-
* @global object $bp BuddyPress global settings
|
234 |
Â
* @uses bp_is_activity_component()
|
235 |
Â
* @uses bp_activity_get_specific()
|
236 |
Â
* @uses bp_current_action()
|
@@ -239,8 +238,8 @@ add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' )
|
|
239 |
Â
* @uses bp_is_active()
|
240 |
Â
* @uses groups_get_group()
|
241 |
Â
* @uses groups_is_user_member()
|
242 |
-
* @uses apply_filters_ref_array() To call the 'bp_activity_permalink_access' hook
|
243 |
-
* @uses do_action() To call the 'bp_activity_screen_single_activity_permalink' hook
|
244 |
Â
* @uses bp_core_add_message()
|
245 |
Â
* @uses is_user_logged_in()
|
246 |
Â
* @uses bp_core_redirect()
|
@@ -249,10 +248,10 @@ add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' )
|
|
249 |
Â
* @uses bp_get_root_domain()
|
250 |
Â
* @uses bp_get_activity_root_slug()
|
251 |
Â
* @uses bp_core_load_template()
|
252 |
-
* @uses apply_filters() To call the 'bp_activity_template_profile_activity_permalink' hook
|
253 |
Â
*/
|
254 |
Â
function bp_activity_screen_single_activity_permalink() {
|
255 |
-
|
256 |
Â
|
257 |
Â
// No displayed user or not viewing activity component
|
258 |
Â
if ( !bp_is_activity_component() )
|
@@ -314,8 +313,8 @@ function bp_activity_screen_single_activity_permalink() {
|
|
314 |
Â
*
|
315 |
Â
* @since BuddyPress (1.2.0)
|
316 |
Â
*
|
317 |
-
* @param BP_Activity_Activity $activity
|
318 |
-
* @param bool
|
319 |
Â
*/
|
320 |
Â
do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access );
|
321 |
Â
|
@@ -476,6 +475,7 @@ class BP_Activity_Theme_Compat {
|
|
476 |
Â
* @since BuddyPress (1.8.0)
|
477 |
Â
*
|
478 |
Â
* @param string $templates The templates from bp_get_theme_compat_templates().
|
Â
|
|
479 |
Â
* @return array $templates Array of custom templates to look for.
|
480 |
Â
*/
|
481 |
Â
public function directory_template_hierarchy( $templates ) {
|
@@ -536,6 +536,7 @@ class BP_Activity_Theme_Compat {
|
|
536 |
Â
* @since BuddyPress (1.8.0)
|
537 |
Â
*
|
538 |
Â
* @param string $templates The templates from bp_get_theme_compat_templates().
|
Â
|
|
539 |
Â
* @return array $templates Array of custom templates to look for.
|
540 |
Â
*/
|
541 |
Â
public function single_template_hierarchy( $templates ) {
|
121 |
Â
* @uses bp_is_active()
|
122 |
Â
* @uses bp_update_is_item_admin()
|
123 |
Â
* @uses bp_current_user_can()
|
124 |
+
* @uses do_action() To call the 'bp_activity_screen_groups' hook.
|
125 |
Â
* @uses bp_core_load_template()
|
126 |
+
* @uses apply_filters() To call the 'bp_activity_template_groups_activity' hook.
|
127 |
Â
*/
|
128 |
Â
function bp_activity_screen_groups() {
|
129 |
Â
if ( !bp_is_active( 'groups' ) )
|
155 |
Â
*
|
156 |
Â
* @uses bp_update_is_item_admin()
|
157 |
Â
* @uses bp_current_user_can()
|
158 |
+
* @uses do_action() To call the 'bp_activity_screen_favorites' hook.
|
159 |
Â
* @uses bp_core_load_template()
|
160 |
+
* @uses apply_filters() To call the 'bp_activity_template_favorite_activity' hook.
|
161 |
Â
*/
|
162 |
Â
function bp_activity_screen_favorites() {
|
163 |
Â
bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
|
186 |
Â
*
|
187 |
Â
* @uses bp_update_is_item_admin()
|
188 |
Â
* @uses bp_current_user_can()
|
189 |
+
* @uses do_action() To call the 'bp_activity_screen_mentions' hook.
|
190 |
Â
* @uses bp_core_load_template()
|
191 |
+
* @uses apply_filters() To call the 'bp_activity_template_mention_activity' hook.
|
192 |
Â
*/
|
193 |
Â
function bp_activity_screen_mentions() {
|
194 |
Â
bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
|
230 |
Â
*
|
231 |
Â
* @since BuddyPress (1.2.0)
|
232 |
Â
*
|
Â
|
|
233 |
Â
* @uses bp_is_activity_component()
|
234 |
Â
* @uses bp_activity_get_specific()
|
235 |
Â
* @uses bp_current_action()
|
238 |
Â
* @uses bp_is_active()
|
239 |
Â
* @uses groups_get_group()
|
240 |
Â
* @uses groups_is_user_member()
|
241 |
+
* @uses apply_filters_ref_array() To call the 'bp_activity_permalink_access' hook.
|
242 |
+
* @uses do_action() To call the 'bp_activity_screen_single_activity_permalink' hook.
|
243 |
Â
* @uses bp_core_add_message()
|
244 |
Â
* @uses is_user_logged_in()
|
245 |
Â
* @uses bp_core_redirect()
|
248 |
Â
* @uses bp_get_root_domain()
|
249 |
Â
* @uses bp_get_activity_root_slug()
|
250 |
Â
* @uses bp_core_load_template()
|
251 |
+
* @uses apply_filters() To call the 'bp_activity_template_profile_activity_permalink' hook.
|
252 |
Â
*/
|
253 |
Â
function bp_activity_screen_single_activity_permalink() {
|
254 |
+
$bp = buddypress();
|
255 |
Â
|
256 |
Â
// No displayed user or not viewing activity component
|
257 |
Â
if ( !bp_is_activity_component() )
|
313 |
Â
*
|
314 |
Â
* @since BuddyPress (1.2.0)
|
315 |
Â
*
|
316 |
+
* @param BP_Activity_Activity $activity Object representing the current activity item being displayed.
|
317 |
+
* @param bool $has_access Whether or not the current user has access to view activity.
|
318 |
Â
*/
|
319 |
Â
do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access );
|
320 |
Â
|
475 |
Â
* @since BuddyPress (1.8.0)
|
476 |
Â
*
|
477 |
Â
* @param string $templates The templates from bp_get_theme_compat_templates().
|
478 |
+
*
|
479 |
Â
* @return array $templates Array of custom templates to look for.
|
480 |
Â
*/
|
481 |
Â
public function directory_template_hierarchy( $templates ) {
|
536 |
Â
* @since BuddyPress (1.8.0)
|
537 |
Â
*
|
538 |
Â
* @param string $templates The templates from bp_get_theme_compat_templates().
|
539 |
+
*
|
540 |
Â
* @return array $templates Array of custom templates to look for.
|
541 |
Â
*/
|
542 |
Â
public function single_template_hierarchy( $templates ) {
|
bp-activity/bp-activity-template.php
CHANGED
@@ -80,10 +80,10 @@ function bp_activity_root_slug() {
|
|
80 |
Â
* @uses bp_get_activity_directory_permalink()
|
81 |
Â
*/
|
82 |
Â
function bp_activity_directory_permalink() {
|
83 |
-
echo bp_get_activity_directory_permalink();
|
84 |
Â
}
|
85 |
Â
/**
|
86 |
-
* Return activity directory permalink
|
87 |
Â
*
|
88 |
Â
* @since BuddyPress (1.5.0)
|
89 |
Â
*
|
@@ -114,13 +114,59 @@ function bp_activity_directory_permalink() {
|
|
114 |
Â
* @since BuddyPress (1.0.0)
|
115 |
Â
*/
|
116 |
Â
class BP_Activity_Template {
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
Â
|
|
Â
|
|
Â
|
|
122 |
Â
|
123 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
124 |
Â
|
125 |
Â
/**
|
126 |
Â
* URL parameter key for activity pagination. Default: 'acpage'.
|
@@ -128,13 +174,43 @@ class BP_Activity_Template {
|
|
128 |
Â
* @since BuddyPress (2.1.0)
|
129 |
Â
* @var string
|
130 |
Â
*/
|
131 |
-
|
132 |
Â
|
133 |
-
|
134 |
-
|
135 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
136 |
Â
|
137 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
138 |
Â
|
139 |
Â
/**
|
140 |
Â
* Constructor method.
|
@@ -150,21 +226,21 @@ class BP_Activity_Template {
|
|
150 |
Â
* BP_Activity_Activity::get(), as well as 'page_arg' and
|
151 |
Â
* 'include'. Default values for 'per_page' and 'display_comments'
|
152 |
Â
* differ from the originating function, and are described below.
|
153 |
-
* @type string
|
154 |
-
*
|
155 |
-
* @type array|bool
|
156 |
-
*
|
157 |
-
*
|
158 |
-
*
|
159 |
-
*
|
160 |
-
*
|
161 |
-
*
|
162 |
-
* @type int|bool
|
163 |
Â
* @type string|bool $display_comments Default: 'threaded'.
|
164 |
Â
* }
|
165 |
Â
*/
|
166 |
-
function __construct( $args ) {
|
167 |
-
|
168 |
Â
|
169 |
Â
// Backward compatibility with old method of passing arguments
|
170 |
Â
if ( !is_array( $args ) || func_num_args() > 1 ) {
|
@@ -219,7 +295,7 @@ class BP_Activity_Template {
|
|
219 |
Â
$this->pag_num = bp_sanitize_pagination_arg( 'num', $r['per_page'] );
|
220 |
Â
|
221 |
Â
// Check if blog/forum replies are disabled
|
222 |
-
$this->disable_blogforum_replies =
|
223 |
Â
|
224 |
Â
// Get an array of the logged in user's favorite activities
|
225 |
Â
$this->my_favs = maybe_unserialize( bp_get_user_meta( bp_loggedin_user_id(), 'bp_favorite_activities', true ) );
|
@@ -290,18 +366,21 @@ class BP_Activity_Template {
|
|
290 |
Â
|
291 |
Â
// Fetch parent content for activity comments so we do not have to query in the loop
|
292 |
Â
foreach ( (array) $this->activities as $activity ) {
|
293 |
-
if ( 'activity_comment' != $activity->type )
|
294 |
Â
continue;
|
Â
|
|
295 |
Â
|
296 |
Â
$parent_ids[] = $activity->item_id;
|
297 |
Â
}
|
298 |
Â
|
299 |
-
if ( !empty( $parent_ids ) )
|
300 |
Â
$activity_parents = bp_activity_get_specific( array( 'activity_ids' => $parent_ids ) );
|
Â
|
|
301 |
Â
|
302 |
Â
if ( !empty( $activity_parents['activities'] ) ) {
|
303 |
-
foreach( $activity_parents['activities'] as $parent )
|
304 |
Â
$this->activity_parents[$parent->id] = $parent;
|
Â
|
|
305 |
Â
|
306 |
Â
unset( $activity_parents );
|
307 |
Â
}
|
@@ -328,8 +407,9 @@ class BP_Activity_Template {
|
|
328 |
Â
* @return bool True if there are items in the loop, otherwise false.
|
329 |
Â
*/
|
330 |
Â
function has_activities() {
|
331 |
-
if ( $this->activity_count )
|
332 |
Â
return true;
|
Â
|
|
333 |
Â
|
334 |
Â
return false;
|
335 |
Â
}
|
@@ -339,9 +419,9 @@ class BP_Activity_Template {
|
|
339 |
Â
*
|
340 |
Â
* @return object The next activity item to iterate over.
|
341 |
Â
*/
|
342 |
-
function next_activity() {
|
343 |
Â
$this->current_activity++;
|
344 |
-
$this->activity = $this->activities[$this->current_activity];
|
345 |
Â
|
346 |
Â
return $this->activity;
|
347 |
Â
}
|
@@ -349,7 +429,7 @@ class BP_Activity_Template {
|
|
349 |
Â
/**
|
350 |
Â
* Rewind the posts and reset post index.
|
351 |
Â
*/
|
352 |
-
function rewind_activities() {
|
353 |
Â
$this->current_activity = -1;
|
354 |
Â
if ( $this->activity_count > 0 ) {
|
355 |
Â
$this->activity = $this->activities[0];
|
@@ -368,10 +448,10 @@ class BP_Activity_Template {
|
|
368 |
Â
* @return bool True if there are more activity items to show,
|
369 |
Â
* otherwise false.
|
370 |
Â
*/
|
371 |
-
function user_activities() {
|
372 |
-
if ( $this->current_activity + 1 < $this->activity_count ) {
|
373 |
Â
return true;
|
374 |
-
} elseif ( $this->current_activity + 1 == $this->activity_count ) {
|
375 |
Â
|
376 |
Â
/**
|
377 |
Â
* Fires right before the rewinding of activity posts.
|
@@ -379,11 +459,13 @@ class BP_Activity_Template {
|
|
379 |
Â
* @since BuddyPress (1.1.0)
|
380 |
Â
*/
|
381 |
Â
do_action( 'activity_loop_end' );
|
Â
|
|
382 |
Â
// Do some cleaning up after the loop
|
383 |
Â
$this->rewind_activities();
|
384 |
Â
}
|
385 |
Â
|
386 |
Â
$this->in_the_loop = false;
|
Â
|
|
387 |
Â
return false;
|
388 |
Â
}
|
389 |
Â
|
@@ -396,15 +478,17 @@ class BP_Activity_Template {
|
|
396 |
Â
*
|
397 |
Â
* @see bp_the_activity()
|
398 |
Â
*/
|
399 |
-
function the_activity() {
|
400 |
Â
|
401 |
Â
$this->in_the_loop = true;
|
402 |
Â
$this->activity = $this->next_activity();
|
403 |
Â
|
404 |
-
if ( is_array( $this->activity ) )
|
405 |
Â
$this->activity = (object) $this->activity;
|
Â
|
|
406 |
Â
|
407 |
-
|
Â
|
|
408 |
Â
|
409 |
Â
/**
|
410 |
Â
* Fires if the current activity item is the first in the activity loop.
|
@@ -426,7 +510,6 @@ class BP_Activity_Template {
|
|
426 |
Â
* @since BuddyPress (1.0.0)
|
427 |
Â
*
|
428 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
429 |
-
* @global object $bp BuddyPress global settings.
|
430 |
Â
* @uses groups_is_user_member()
|
431 |
Â
* @uses bp_current_action()
|
432 |
Â
* @uses bp_is_current_action()
|
@@ -439,7 +522,7 @@ class BP_Activity_Template {
|
|
439 |
Â
* @uses bp_activity_get_user_favorites()
|
440 |
Â
* @uses apply_filters() To call the 'bp_has_activities' hook.
|
441 |
Â
*
|
442 |
-
* @param array $args {
|
443 |
Â
* Arguments for limiting the contents of the activity loop. Most arguments
|
444 |
Â
* are in the same format as {@link BP_Activity_Activity::get()}. However,
|
445 |
Â
* because the format of the arguments accepted here differs in a number of
|
@@ -472,11 +555,11 @@ class BP_Activity_Template {
|
|
472 |
Â
* @type string $search_terms Limit results by a search term. Default: false.
|
473 |
Â
* @type string $scope Use a BuddyPress pre-built filter.
|
474 |
Â
* - 'just-me' retrieves items belonging only to a user; this is equivalent
|
475 |
-
* to passing a 'user_id' argument
|
476 |
-
* - 'friends' retrieves items belonging to the friends of a user
|
477 |
-
* - 'groups' retrieves items belonging to groups to which a user belongs to
|
478 |
-
* - 'favorites' retrieves a user's favorited activity items
|
479 |
-
* - 'mentions' retrieves items where a user has received an @-mention
|
480 |
Â
* The default value of 'scope' is set to one of the above if that value
|
481 |
Â
* appears in the appropriate place in the URL; eg, 'scope' will be 'groups'
|
482 |
Â
* when visiting http://example.com/members/joe/activity/groups/. Otherwise
|
@@ -508,16 +591,16 @@ class BP_Activity_Template {
|
|
508 |
Â
* Note that providing an offset will disable pagination. Default: false.
|
509 |
Â
* @type string|bool $display_comments How to handle activity comments. Possible values:
|
510 |
Â
* - 'threaded' - comments appear in a threaded tree, under their parent
|
511 |
-
* items
|
512 |
Â
* - 'stream' - the activity stream is presented in a flat manner, with
|
513 |
-
* comments sorted in chronological order alongside other activity items
|
514 |
-
* - false - don't fetch activity comments at all
|
515 |
Â
* Default: 'threaded'.
|
516 |
Â
* @type bool $show_hidden Whether to show items marked hide_sitewide. Defaults to false, except in
|
517 |
Â
* the following cases:
|
518 |
-
* - User is viewing his own activity stream
|
519 |
Â
* - User is viewing the activity stream of a non-public group of which he
|
520 |
-
* is a member
|
521 |
Â
* @type string|bool $spam Spam status. 'ham_only', 'spam_only', or false to show all activity
|
522 |
Â
* regardless of spam status. Default: 'ham_only'.
|
523 |
Â
* @type bool $populate_extras Whether to pre-fetch the activity metadata for the queried items.
|
@@ -526,62 +609,57 @@ class BP_Activity_Template {
|
|
526 |
Â
* @return bool Returns true when activities are found, otherwise false.
|
527 |
Â
*/
|
528 |
Â
function bp_has_activities( $args = '' ) {
|
529 |
-
global $activities_template
|
530 |
Â
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
*/
|
536 |
-
$user_id = false;
|
537 |
-
$include = false;
|
538 |
-
$exclude = false;
|
539 |
-
$in = false;
|
540 |
-
$show_hidden = false;
|
541 |
-
$object = false;
|
542 |
-
$primary_id = false;
|
543 |
Â
|
544 |
Â
// User filtering
|
545 |
-
|
546 |
-
|
Â
|
|
547 |
Â
|
548 |
Â
// Group filtering
|
549 |
-
if (
|
550 |
-
$object
|
551 |
-
$primary_id
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
Â
|
|
556 |
Â
}
|
557 |
Â
|
558 |
Â
// The default scope should recognize custom slugs
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
else
|
563 |
-
$scope = bp_current_action();
|
564 |
Â
|
565 |
Â
// Support for permalinks on single item pages: /groups/my-group/activity/124/
|
566 |
-
|
567 |
-
|
Â
|
|
Â
|
|
Â
|
|
568 |
Â
|
569 |
-
// Note: any params used for filtering can be a single value, or multiple
|
570 |
-
|
Â
|
|
571 |
Â
'display_comments' => 'threaded', // false for none, stream/threaded - show comments in the stream or threaded under items
|
572 |
Â
'include' => $include, // pass an activity_id or string of IDs comma-separated
|
573 |
-
'exclude' =>
|
574 |
-
'in' =>
|
575 |
Â
'sort' => 'DESC', // sort DESC or ASC
|
576 |
Â
'page' => 1, // which page to load
|
577 |
Â
'per_page' => 20, // number of items per page
|
Â
|
|
578 |
Â
'max' => false, // max number to return
|
579 |
Â
'count_total' => false,
|
580 |
Â
'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide?
|
581 |
Â
'spam' => 'ham_only', // Hide spammed items
|
582 |
Â
|
583 |
-
'page_arg' => 'acpage', // See https://buddypress.trac.wordpress.org/ticket/3679
|
584 |
-
|
585 |
Â
// Scope - pre-built activity filters for a user (friends/groups/favorites/mentions)
|
586 |
Â
'scope' => $scope,
|
587 |
Â
|
@@ -601,30 +679,31 @@ function bp_has_activities( $args = '' ) {
|
|
601 |
Â
// Searching
|
602 |
Â
'search_terms' => false, // specify terms to search on
|
603 |
Â
'update_meta_cache' => true,
|
604 |
-
);
|
605 |
Â
|
606 |
-
|
607 |
-
extract( $r );
|
608 |
Â
|
609 |
Â
// Translate various values for 'display_comments'
|
610 |
Â
// This allows disabling comments via ?display_comments=0
|
611 |
Â
// or =none or =false. Final true is a strict type check. See #5029
|
612 |
-
if ( in_array( $display_comments, array( 0, '0', 'none', 'false' ), true ) ) {
|
613 |
-
$display_comments = false;
|
614 |
Â
}
|
615 |
Â
|
616 |
Â
// Ignore pagination if an offset is passed
|
617 |
-
if ( ! empty( $offset ) ) {
|
618 |
-
$page = 0;
|
619 |
Â
}
|
620 |
Â
|
621 |
Â
// Search terms
|
622 |
-
if ( empty( $
|
623 |
-
$search_terms = $_REQUEST['s'];
|
Â
|
|
624 |
Â
|
625 |
Â
// Do not exceed the maximum per page
|
626 |
-
if ( !empty( $max ) && ( (int) $per_page > (int) $max ) )
|
627 |
-
$per_page = $max;
|
Â
|
|
628 |
Â
|
629 |
Â
/**
|
630 |
Â
* Filters whether BuddyPress should enable afilter support.
|
@@ -637,51 +716,44 @@ function bp_has_activities( $args = '' ) {
|
|
637 |
Â
*
|
638 |
Â
* @param bool $value True if BuddyPress should enable afilter support.
|
639 |
Â
*/
|
640 |
-
if ( isset( $_GET['afilter'] ) && apply_filters( 'bp_activity_enable_afilter_support', false ) )
|
641 |
-
$filter = array(
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
$filter =
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
'
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
'
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
'display_comments' => $display_comments,
|
668 |
-
'show_hidden' => $show_hidden,
|
669 |
-
'spam' => $spam,
|
670 |
-
'update_meta_cache' => $update_meta_cache,
|
671 |
-
);
|
672 |
-
|
673 |
-
$activities_template = new BP_Activity_Template( $template_args );
|
674 |
Â
|
675 |
Â
/**
|
676 |
Â
* Filters whether or not there are activity items to display.
|
677 |
Â
*
|
678 |
Â
* @since BuddyPress (1.1.0)
|
679 |
Â
*
|
680 |
-
* @param bool $
|
681 |
Â
* @param string $activities_template Current activities template being used.
|
682 |
-
* @param array $
|
683 |
Â
*/
|
684 |
-
return apply_filters( 'bp_has_activities', $activities_template->has_activities(), $activities_template, $
|
685 |
Â
}
|
686 |
Â
|
687 |
Â
/**
|
@@ -723,7 +795,7 @@ function bp_activity_load_more_link() {
|
|
723 |
Â
echo esc_url( bp_get_activity_load_more_link() );
|
724 |
Â
}
|
725 |
Â
/**
|
726 |
-
* Get the URL for the Load More link
|
727 |
Â
*
|
728 |
Â
* @since BuddyPress (2.1.0)
|
729 |
Â
*/
|
@@ -738,9 +810,9 @@ function bp_activity_load_more_link() {
|
|
738 |
Â
*
|
739 |
Â
* @since BuddyPress (2.1.0)
|
740 |
Â
*
|
741 |
-
* @param string $link The "Load More" link URL with appropriate query args
|
742 |
-
* @param string $url The original URL
|
743 |
-
* @param object $activities_template The activity template loop global
|
744 |
Â
*/
|
745 |
Â
return apply_filters( 'bp_get_activity_load_more_link', $link, $url, $activities_template );
|
746 |
Â
}
|
@@ -775,7 +847,13 @@ function bp_activity_pagination_count() {
|
|
775 |
Â
$to_num = bp_core_number_format( ( $start_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $start_num + ( $activities_template->pag_num - 1 ) );
|
776 |
Â
$total = bp_core_number_format( $activities_template->total_activity_count );
|
777 |
Â
|
778 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
779 |
Â
}
|
780 |
Â
|
781 |
Â
/**
|
@@ -969,7 +1047,7 @@ function bp_activities_no_activity() {
|
|
969 |
Â
* @since BuddyPress (1.0.0)
|
970 |
Â
*
|
971 |
Â
* @global string $bp_activity_no_activity
|
972 |
-
* @uses apply_filters() To call the 'bp_get_activities_no_activity' hook
|
973 |
Â
* @todo Deprecate.
|
974 |
Â
*
|
975 |
Â
* @return string
|
@@ -1124,7 +1202,7 @@ function bp_activity_date_recorded() {
|
|
1124 |
Â
}
|
1125 |
Â
|
1126 |
Â
/**
|
1127 |
-
* Output the display name of the member who posted the activity
|
1128 |
Â
*
|
1129 |
Â
* @since BuddyPress (2.1.0)
|
1130 |
Â
*
|
@@ -1135,7 +1213,7 @@ function bp_activity_member_display_name() {
|
|
1135 |
Â
}
|
1136 |
Â
|
1137 |
Â
/**
|
1138 |
-
* Return the display name of the member who posted the activity
|
1139 |
Â
*
|
1140 |
Â
* @since BuddyPress (2.1.0)
|
1141 |
Â
*
|
@@ -1343,7 +1421,7 @@ function bp_activity_user_link() {
|
|
1343 |
Â
* @see bp_get_activity_avatar() for description of arguments.
|
1344 |
Â
* @uses bp_get_activity_avatar()
|
1345 |
Â
*
|
1346 |
-
* @param array $args See {@link bp_get_activity_avatar()} for description.
|
1347 |
Â
*/
|
1348 |
Â
function bp_activity_avatar( $args = '' ) {
|
1349 |
Â
echo bp_get_activity_avatar( $args );
|
@@ -1355,26 +1433,25 @@ function bp_activity_avatar( $args = '' ) {
|
|
1355 |
Â
*
|
1356 |
Â
* @see bp_core_fetch_avatar() For a description of the arguments.
|
1357 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
1358 |
-
* @global object $bp BuddyPress global settings
|
1359 |
Â
* @uses bp_is_single_activity()
|
1360 |
Â
* @uses wp_parse_args()
|
1361 |
-
* @uses apply_filters() To call the 'bp_get_activity_avatar_object_' . $current_activity_item->component hook
|
1362 |
-
* @uses apply_filters() To call the 'bp_get_activity_avatar_item_id' hook
|
1363 |
Â
* @uses bp_core_fetch_avatar()
|
1364 |
-
* @uses apply_filters() To call the 'bp_get_activity_avatar' hook
|
1365 |
Â
*
|
1366 |
-
* @param array $args {
|
1367 |
Â
* Arguments are listed here with an explanation of their defaults.
|
1368 |
Â
* For more information about the arguments, see
|
1369 |
Â
* {@link bp_core_fetch_avatar()}.
|
1370 |
-
* @type string
|
1371 |
-
*
|
1372 |
-
* @type string
|
1373 |
-
* @type string|bool $email
|
1374 |
-
*
|
1375 |
-
* @type string
|
1376 |
-
*
|
1377 |
-
* @type int|bool
|
1378 |
Â
* }
|
1379 |
Â
* @return string User avatar string.
|
1380 |
Â
*/
|
@@ -1448,8 +1525,9 @@ function bp_activity_avatar( $args = '' ) {
|
|
1448 |
Â
$item_id = apply_filters( 'bp_get_activity_avatar_item_id', $item_id );
|
1449 |
Â
|
1450 |
Â
// If this is a user object pass the users' email address for Gravatar so we don't have to prefetch it.
|
1451 |
-
if ( 'user' == $object && empty( $user_id ) && empty( $email ) && isset( $current_activity_item->user_email ) )
|
1452 |
Â
$email = $current_activity_item->user_email;
|
Â
|
|
1453 |
Â
|
1454 |
Â
/**
|
1455 |
Â
* Filters the value returned by bp_core_fetch_avatar.
|
@@ -1478,14 +1556,14 @@ function bp_activity_avatar( $args = '' ) {
|
|
1478 |
Â
* @see bp_get_activity_secondary_avatar() for description of arguments.
|
1479 |
Â
* @uses bp_get_activity_secondary_avatar()
|
1480 |
Â
*
|
1481 |
-
* @param array $args See {@link bp_get_activity_secondary_avatar} for description.
|
1482 |
Â
*/
|
1483 |
Â
function bp_activity_secondary_avatar( $args = '' ) {
|
1484 |
Â
echo bp_get_activity_secondary_avatar( $args );
|
1485 |
Â
}
|
1486 |
Â
|
1487 |
Â
/**
|
1488 |
-
* Return the avatar of the object that action was performed on
|
1489 |
Â
*
|
1490 |
Â
* @since BuddyPress (1.2.0)
|
1491 |
Â
*
|
@@ -1498,15 +1576,15 @@ function bp_activity_secondary_avatar( $args = '' ) {
|
|
1498 |
Â
* @uses bp_core_fetch_avatar()
|
1499 |
Â
* @uses apply_filters() To call the 'bp_get_activity_secondary_avatar' hook.
|
1500 |
Â
*
|
1501 |
-
* @param array $args {
|
1502 |
Â
* For a complete description of arguments, see {@link bp_core_fetch_avatar()}.
|
1503 |
-
* @type string
|
1504 |
-
*
|
1505 |
-
* @type string
|
1506 |
-
*
|
1507 |
-
* @type string
|
1508 |
-
* @type string|bool $email
|
1509 |
-
* @type int|bool
|
1510 |
Â
* }
|
1511 |
Â
* @return string The secondary avatar
|
1512 |
Â
*/
|
@@ -1528,6 +1606,10 @@ function bp_activity_secondary_avatar( $args = '' ) {
|
|
1528 |
Â
// Set item_id and object (default to user)
|
1529 |
Â
switch ( $activities_template->activity->component ) {
|
1530 |
Â
case 'groups' :
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1531 |
Â
$object = 'group';
|
1532 |
Â
$item_id = $activities_template->activity->item_id;
|
1533 |
Â
$link = '';
|
@@ -1632,7 +1714,7 @@ function bp_activity_secondary_avatar( $args = '' ) {
|
|
1632 |
Â
*
|
1633 |
Â
* @since BuddyPress (1.7.0)
|
1634 |
Â
*
|
1635 |
-
* @param string $link
|
1636 |
Â
* @param string $component Activity component being acted on.
|
1637 |
Â
*/
|
1638 |
Â
$link = apply_filters( 'bp_get_activity_secondary_avatar_link', $link, $activities_template->activity->component );
|
@@ -1642,7 +1724,7 @@ function bp_activity_secondary_avatar( $args = '' ) {
|
|
1642 |
Â
*
|
1643 |
Â
* @since BuddyPress (1.2.10)
|
1644 |
Â
*
|
1645 |
-
* @param string Formatted HTML <img> element, or raw avatar URL.
|
1646 |
Â
*/
|
1647 |
Â
$avatar = apply_filters( 'bp_get_activity_secondary_avatar', $avatar );
|
1648 |
Â
|
@@ -1658,7 +1740,7 @@ function bp_activity_secondary_avatar( $args = '' ) {
|
|
1658 |
Â
}
|
1659 |
Â
|
1660 |
Â
/**
|
1661 |
-
* Output the activity action
|
1662 |
Â
*
|
1663 |
Â
* @since BuddyPress (1.2.0)
|
1664 |
Â
*
|
@@ -1670,32 +1752,28 @@ function bp_activity_action( $args = array() ) {
|
|
1670 |
Â
}
|
1671 |
Â
|
1672 |
Â
/**
|
1673 |
-
* Return the activity action
|
1674 |
Â
*
|
1675 |
Â
* @since BuddyPress (1.2.0)
|
1676 |
Â
*
|
1677 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
1678 |
Â
* @param array $args Only parameter is "no_timestamp". If true, timestamp is shown in output.
|
1679 |
-
* @uses apply_filters_ref_array() To call the 'bp_get_activity_action_pre_meta' hook
|
1680 |
Â
* @uses bp_insert_activity_meta()
|
1681 |
Â
* @uses apply_filters_ref_array() To call the 'bp_get_activity_action' hook.
|
1682 |
Â
*
|
1683 |
Â
* @param array $args {
|
1684 |
Â
* @type bool $no_timestamp Whether to exclude the timestamp.
|
1685 |
Â
* }
|
Â
|
|
1686 |
Â
* @return string The activity action.
|
1687 |
Â
*/
|
1688 |
Â
function bp_get_activity_action( $args = array() ) {
|
1689 |
Â
global $activities_template;
|
1690 |
Â
|
1691 |
-
$
|
1692 |
Â
'no_timestamp' => false,
|
1693 |
-
);
|
1694 |
-
|
1695 |
-
$args = wp_parse_args( $args, $defaults );
|
1696 |
-
extract( $args, EXTR_SKIP );
|
1697 |
-
|
1698 |
-
$action = $activities_template->activity->action;
|
1699 |
Â
|
1700 |
Â
/**
|
1701 |
Â
* Filters the activity action before the action is inserted as meta.
|
@@ -1704,10 +1782,16 @@ function bp_activity_action( $args = array() ) {
|
|
1704 |
Â
*
|
1705 |
Â
* @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
|
1706 |
Â
*/
|
1707 |
-
$action = apply_filters_ref_array( 'bp_get_activity_action_pre_meta', array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1708 |
Â
|
1709 |
-
|
Â
|
|
1710 |
Â
$action = bp_insert_activity_meta( $action );
|
Â
|
|
1711 |
Â
|
1712 |
Â
/**
|
1713 |
Â
* Filters the activity action after the action has been inserted as meta.
|
@@ -1716,11 +1800,15 @@ function bp_activity_action( $args = array() ) {
|
|
1716 |
Â
*
|
1717 |
Â
* @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
|
1718 |
Â
*/
|
1719 |
-
return apply_filters_ref_array( 'bp_get_activity_action', array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1720 |
Â
}
|
1721 |
Â
|
1722 |
Â
/**
|
1723 |
-
* Output the activity content body
|
1724 |
Â
*
|
1725 |
Â
* @since BuddyPress (1.2.0)
|
1726 |
Â
*
|
@@ -1731,7 +1819,7 @@ function bp_activity_content_body() {
|
|
1731 |
Â
}
|
1732 |
Â
|
1733 |
Â
/**
|
1734 |
-
* Return the activity content body
|
1735 |
Â
*
|
1736 |
Â
* @since BuddyPress (1.2.0)
|
1737 |
Â
*
|
@@ -1745,8 +1833,9 @@ function bp_activity_content_body() {
|
|
1745 |
Â
global $activities_template;
|
1746 |
Â
|
1747 |
Â
// Backwards compatibility if action is not being used
|
1748 |
-
if ( empty( $activities_template->activity->action ) && !empty( $activities_template->activity->content ) )
|
1749 |
Â
$activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content );
|
Â
|
|
1750 |
Â
|
1751 |
Â
/**
|
1752 |
Â
* Filters the activity content body.
|
@@ -1770,8 +1859,9 @@ function bp_activity_content_body() {
|
|
1770 |
Â
function bp_activity_has_content() {
|
1771 |
Â
global $activities_template;
|
1772 |
Â
|
1773 |
-
if ( !empty( $activities_template->activity->content ) )
|
1774 |
Â
return true;
|
Â
|
|
1775 |
Â
|
1776 |
Â
return false;
|
1777 |
Â
}
|
@@ -1808,7 +1898,7 @@ function bp_activity_content() {
|
|
1808 |
Â
|
1809 |
Â
/**
|
1810 |
Â
* If you want to filter activity update content, please use
|
1811 |
-
* the filter 'bp_get_activity_content_body'
|
1812 |
Â
*
|
1813 |
Â
* This function is mainly for backwards compatibility.
|
1814 |
Â
*/
|
@@ -1834,13 +1924,17 @@ function bp_activity_content() {
|
|
1834 |
Â
* @uses apply_filters() To call the 'bp_insert_activity_meta' hook.
|
1835 |
Â
*
|
1836 |
Â
* @param string $content The activity content.
|
Â
|
|
1837 |
Â
* @return string The activity content with the metadata string attached.
|
1838 |
Â
*/
|
1839 |
-
function bp_insert_activity_meta( $content ) {
|
1840 |
Â
global $activities_template;
|
1841 |
Â
|
1842 |
Â
// Strip any legacy time since placeholders from BP 1.0-1.1
|
1843 |
-
$
|
Â
|
|
Â
|
|
Â
|
|
1844 |
Â
|
1845 |
Â
/**
|
1846 |
Â
* Filters the activity item time since markup.
|
@@ -1849,10 +1943,22 @@ function bp_insert_activity_meta( $content ) {
|
|
1849 |
Â
*
|
1850 |
Â
* @param array $value Array containing the time since markup and the current activity component.
|
1851 |
Â
*/
|
1852 |
-
$time_since = apply_filters_ref_array( 'bp_activity_time_since', array(
|
Â
|
|
Â
|
|
Â
|
|
1853 |
Â
|
1854 |
Â
// Insert the permalink
|
1855 |
-
if ( !bp_is_single_activity() ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1856 |
Â
|
1857 |
Â
/**
|
1858 |
Â
* Filters the activity permalink to be added to the activity content.
|
@@ -1861,9 +1967,12 @@ function bp_insert_activity_meta( $content ) {
|
|
1861 |
Â
*
|
1862 |
Â
* @param array $value Array containing the html markup for the activity permalink, after being parsed by sprintf and current activity component.
|
1863 |
Â
*/
|
1864 |
-
$
|
Â
|
|
Â
|
|
Â
|
|
1865 |
Â
} else {
|
1866 |
-
$
|
1867 |
Â
}
|
1868 |
Â
|
1869 |
Â
/**
|
@@ -1873,7 +1982,7 @@ function bp_insert_activity_meta( $content ) {
|
|
1873 |
Â
*
|
1874 |
Â
* @param string $content Activity content with the activity metadata added.
|
1875 |
Â
*/
|
1876 |
-
return apply_filters( 'bp_insert_activity_meta', $content );
|
1877 |
Â
}
|
1878 |
Â
|
1879 |
Â
/**
|
@@ -1882,9 +1991,10 @@ function bp_insert_activity_meta( $content ) {
|
|
1882 |
Â
* @since BuddyPress (1.2.0)
|
1883 |
Â
*
|
1884 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
1885 |
-
* @uses apply_filters() To call the 'bp_activity_user_can_delete' hook
|
Â
|
|
Â
|
|
1886 |
Â
*
|
1887 |
-
* @param object $activity Optional. Falls back on the current item in the loop.
|
1888 |
Â
* @return bool True if can delete, false otherwise.
|
1889 |
Â
*/
|
1890 |
Â
function bp_activity_user_can_delete( $activity = false ) {
|
@@ -1930,7 +2040,7 @@ function bp_activity_user_can_delete( $activity = false ) {
|
|
1930 |
Â
* @since BuddyPress (1.5.0)
|
1931 |
Â
*
|
1932 |
Â
* @param bool $can_delete Whether the user can delete the item.
|
1933 |
-
* @param object $activity
|
1934 |
Â
*/
|
1935 |
Â
return (bool) apply_filters( 'bp_activity_user_can_delete', $can_delete, $activity );
|
1936 |
Â
}
|
@@ -1943,7 +2053,7 @@ function bp_activity_user_can_delete( $activity = false ) {
|
|
1943 |
Â
* @see bp_get_activity_parent_content() for a description of arguments.
|
1944 |
Â
* @uses bp_get_activity_parent_content()
|
1945 |
Â
*
|
1946 |
-
* @param array $args See {@link bp_get_activity_parent_content} for description.
|
1947 |
Â
*/
|
1948 |
Â
function bp_activity_parent_content( $args = '' ) {
|
1949 |
Â
echo bp_get_activity_parent_content($args);
|
@@ -1955,43 +2065,40 @@ function bp_activity_parent_content( $args = '' ) {
|
|
1955 |
Â
* @since BuddyPress (1.2.0)
|
1956 |
Â
*
|
1957 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
1958 |
-
* @uses wp_parse_args()
|
1959 |
Â
* @uses apply_filters() To call the 'bp_get_activity_parent_content' hook.
|
1960 |
Â
*
|
1961 |
-
* @param
|
1962 |
-
*
|
1963 |
-
*
|
1964 |
-
* }
|
1965 |
-
* @return mixed False on failure, otherwise the activity parent content
|
1966 |
Â
*/
|
1967 |
Â
function bp_get_activity_parent_content( $args = '' ) {
|
1968 |
Â
global $activities_template;
|
1969 |
Â
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
$r = wp_parse_args( $args, $defaults );
|
1975 |
-
extract( $r, EXTR_SKIP );
|
1976 |
Â
|
1977 |
Â
// Get the ID of the parent activity content
|
1978 |
-
|
1979 |
-
return false;
|
1980 |
Â
|
1981 |
Â
// Bail if no parent content
|
1982 |
-
if ( empty( $activities_template->activity_parents[$parent_id] ) )
|
1983 |
Â
return false;
|
Â
|
|
1984 |
Â
|
1985 |
Â
// Bail if no action
|
1986 |
-
if ( empty( $activities_template->activity_parents[$parent_id]->action ) )
|
1987 |
Â
return false;
|
Â
|
|
1988 |
Â
|
1989 |
Â
// Content always includes action
|
1990 |
-
$content = $activities_template->activity_parents[$parent_id]->action;
|
1991 |
Â
|
1992 |
Â
// Maybe append activity content, if it exists
|
1993 |
-
if ( ! empty( $activities_template->activity_parents[$parent_id]->content ) )
|
1994 |
-
$content .= ' ' . $activities_template->activity_parents[$parent_id]->content;
|
Â
|
|
1995 |
Â
|
1996 |
Â
// Remove the time since content for backwards compatibility
|
1997 |
Â
$content = str_replace( '<span class="time-since">%s</span>', '', $content );
|
@@ -2026,28 +2133,30 @@ function bp_activity_parent_user_id() {
|
|
2026 |
Â
* @global BP_Activity_Template $activities_template
|
2027 |
Â
*
|
2028 |
Â
* @return bool|int False if parent activity can't be found, otherwise
|
2029 |
-
*
|
2030 |
Â
*/
|
2031 |
Â
function bp_get_activity_parent_user_id() {
|
2032 |
Â
global $activities_template;
|
2033 |
Â
|
2034 |
Â
// Bail if no activity on no item ID
|
2035 |
-
if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) )
|
2036 |
Â
return false;
|
Â
|
|
2037 |
Â
|
2038 |
Â
// Get the ID of the parent activity content
|
2039 |
-
|
2040 |
-
return false;
|
2041 |
Â
|
2042 |
Â
// Bail if no parent item
|
2043 |
-
if ( empty( $activities_template->activity_parents[$parent_id] ) )
|
2044 |
Â
return false;
|
Â
|
|
2045 |
Â
|
2046 |
Â
// Bail if no parent user ID
|
2047 |
-
if ( empty( $activities_template->activity_parents[$parent_id]->user_id ) )
|
2048 |
Â
return false;
|
Â
|
|
2049 |
Â
|
2050 |
-
$retval = $activities_template->activity_parents[$parent_id]->user_id;
|
2051 |
Â
|
2052 |
Â
/**
|
2053 |
Â
* Filters the activity parent item's user ID.
|
@@ -2100,7 +2209,7 @@ function bp_activity_is_favorite() {
|
|
2100 |
Â
*
|
2101 |
Â
* @todo deprecate $args param
|
2102 |
Â
*
|
2103 |
-
* @param string $args
|
2104 |
Â
*/
|
2105 |
Â
function bp_activity_comments( $args = '' ) {
|
2106 |
Â
echo bp_activity_get_comments( $args );
|
@@ -2116,41 +2225,48 @@ function bp_activity_comments( $args = '' ) {
|
|
2116 |
Â
* @todo Given that checks for children already happen in bp_activity_recurse_comments(),
|
2117 |
Â
* this function can probably be streamlined or removed.
|
2118 |
Â
*
|
2119 |
-
* @param string $args Unused.
|
2120 |
Â
*
|
2121 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
2122 |
Â
* @uses bp_activity_recurse_comments()
|
Â
|
|
Â
|
|
2123 |
Â
*/
|
2124 |
Â
function bp_activity_get_comments( $args = '' ) {
|
2125 |
Â
global $activities_template;
|
2126 |
Â
|
2127 |
-
if (
|
2128 |
Â
return false;
|
Â
|
|
2129 |
Â
|
2130 |
Â
bp_activity_recurse_comments( $activities_template->activity );
|
2131 |
Â
}
|
2132 |
Â
|
2133 |
Â
/**
|
2134 |
-
* Loops through a level of activity comments and loads the template for each
|
2135 |
Â
*
|
2136 |
Â
* Note: The recursion itself used to happen entirely in this function. Now it is
|
2137 |
Â
* split between here and the comment.php template.
|
2138 |
Â
*
|
2139 |
Â
* @since BuddyPress (1.2.0)
|
2140 |
Â
*
|
2141 |
-
* @param object $comment The activity object currently being recursed
|
2142 |
Â
*
|
2143 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
2144 |
Â
* @uses locate_template()
|
Â
|
|
Â
|
|
2145 |
Â
*/
|
2146 |
Â
function bp_activity_recurse_comments( $comment ) {
|
2147 |
Â
global $activities_template;
|
2148 |
Â
|
2149 |
-
if ( empty( $comment ) )
|
2150 |
Â
return false;
|
Â
|
|
2151 |
Â
|
2152 |
-
if ( empty( $comment->children ) )
|
2153 |
Â
return false;
|
Â
|
|
2154 |
Â
|
2155 |
Â
/**
|
2156 |
Â
* Filters the opening tag for the template that lists activity comments.
|
@@ -2159,8 +2275,9 @@ function bp_activity_comments( $args = '' ) {
|
|
2159 |
Â
*
|
2160 |
Â
* @param string $value Opening tag for the HTML markup to use.
|
2161 |
Â
*/
|
2162 |
-
echo apply_filters( 'bp_activity_recurse_comments_start_ul', '<ul>');
|
2163 |
Â
foreach ( (array) $comment->children as $comment_child ) {
|
Â
|
|
2164 |
Â
// Put the comment into the global so it's available to filters
|
2165 |
Â
$activities_template->activity->current_comment = $comment_child;
|
2166 |
Â
|
@@ -2186,7 +2303,7 @@ function bp_activity_comments( $args = '' ) {
|
|
2186 |
Â
*
|
2187 |
Â
* @param string $value Closing tag for the HTML markup to use.
|
2188 |
Â
*/
|
2189 |
-
echo apply_filters( 'bp_activity_recurse_comments_end_ul', '</ul>');
|
2190 |
Â
}
|
2191 |
Â
|
2192 |
Â
/**
|
@@ -2198,12 +2315,14 @@ function bp_activity_comments( $args = '' ) {
|
|
2198 |
Â
* @uses apply_filters() To call the 'bp_activity_current_comment' hook.
|
2199 |
Â
*
|
2200 |
Â
* @return object|bool $current_comment The activity comment currently being
|
2201 |
-
*
|
2202 |
Â
*/
|
2203 |
Â
function bp_activity_current_comment() {
|
2204 |
Â
global $activities_template;
|
2205 |
Â
|
2206 |
-
$current_comment = !empty( $activities_template->activity->current_comment )
|
Â
|
|
Â
|
|
2207 |
Â
|
2208 |
Â
/**
|
2209 |
Â
* Filters the current comment being recursed.
|
@@ -2235,8 +2354,8 @@ function bp_activity_comment_id() {
|
|
2235 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
2236 |
Â
* @uses apply_filters() To call the 'bp_activity_comment_id' hook.
|
2237 |
Â
*
|
2238 |
-
* @return int|bool $comment_id The ID of the activity comment
|
2239 |
-
*
|
2240 |
Â
*/
|
2241 |
Â
function bp_get_activity_comment_id() {
|
2242 |
Â
global $activities_template;
|
@@ -2273,7 +2392,7 @@ function bp_activity_comment_user_id() {
|
|
2273 |
Â
* @uses apply_filters() To call the 'bp_activity_comment_user_id' hook.
|
2274 |
Â
*
|
2275 |
Â
* @return int|bool $user_id The user_id of the author of the displayed
|
2276 |
-
*
|
2277 |
Â
*/
|
2278 |
Â
function bp_get_activity_comment_user_id() {
|
2279 |
Â
global $activities_template;
|
@@ -2308,7 +2427,7 @@ function bp_activity_comment_user_link() {
|
|
2308 |
Â
*
|
2309 |
Â
* @uses bp_core_get_user_domain()
|
2310 |
Â
* @uses bp_get_activity_comment_user_id()
|
2311 |
-
* @uses apply_filters() To call the 'bp_activity_comment_user_link' hook
|
2312 |
Â
*
|
2313 |
Â
* @return string $user_link The URL of the activity comment author's profile.
|
2314 |
Â
*/
|
@@ -2371,7 +2490,7 @@ function bp_activity_comment_name() {
|
|
2371 |
Â
}
|
2372 |
Â
|
2373 |
Â
/**
|
2374 |
-
* Output the date_recorded of the activity comment currently being displayed.
|
2375 |
Â
*
|
2376 |
Â
* @since BuddyPress (1.5.0)
|
2377 |
Â
*
|
@@ -2382,24 +2501,17 @@ function bp_activity_comment_date_recorded() {
|
|
2382 |
Â
}
|
2383 |
Â
|
2384 |
Â
/**
|
2385 |
-
* Return the date_recorded for the activity comment currently being displayed.
|
2386 |
Â
*
|
2387 |
Â
* @since BuddyPress (1.5.0)
|
2388 |
Â
*
|
2389 |
-
* @global object $activities_template {@link BP_Activity_Template}
|
2390 |
Â
* @uses bp_core_time_since()
|
2391 |
-
* @uses apply_filters() To call the 'bp_activity_comment_date_recorded' hook
|
2392 |
Â
*
|
2393 |
Â
* @return string|bool $date_recorded Time since the activity was recorded,
|
2394 |
-
*
|
2395 |
Â
*/
|
2396 |
Â
function bp_get_activity_comment_date_recorded() {
|
2397 |
-
global $activities_template;
|
2398 |
-
|
2399 |
-
if ( empty( $activities_template->activity->current_comment->date_recorded ) )
|
2400 |
-
return false;
|
2401 |
-
|
2402 |
-
$date_recorded = bp_core_time_since( $activities_template->activity->current_comment->date_recorded );
|
2403 |
Â
|
2404 |
Â
/**
|
2405 |
Â
* Filters the recorded date of the activity comment currently being displayed.
|
@@ -2408,7 +2520,43 @@ function bp_activity_comment_date_recorded() {
|
|
2408 |
Â
*
|
2409 |
Â
* @param string|bool Date for the activity comment currently being displayed.
|
2410 |
Â
*/
|
2411 |
-
return apply_filters( 'bp_activity_comment_date_recorded',
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2412 |
Â
}
|
2413 |
Â
|
2414 |
Â
/**
|
@@ -2423,7 +2571,7 @@ function bp_activity_comment_delete_link() {
|
|
2423 |
Â
}
|
2424 |
Â
|
2425 |
Â
/**
|
2426 |
-
* Gets the 'delete' URL for the activity comment currently being displayed
|
2427 |
Â
*
|
2428 |
Â
* @since BuddyPress (1.5.0)
|
2429 |
Â
*
|
@@ -2434,7 +2582,7 @@ function bp_activity_comment_delete_link() {
|
|
2434 |
Â
* @uses apply_filters() To call the 'bp_activity_comment_delete_link' hook.
|
2435 |
Â
*
|
2436 |
Â
* @return string $link The nonced URL for deleting the current
|
2437 |
-
*
|
2438 |
Â
*/
|
2439 |
Â
function bp_get_activity_comment_delete_link() {
|
2440 |
Â
$link = wp_nonce_url( bp_get_root_domain() . '/' . bp_get_activity_slug() . '/delete/' . bp_get_activity_comment_id() . '?cid=' . bp_get_activity_comment_id(), 'bp_activity_delete_link' );
|
@@ -2548,10 +2696,10 @@ function bp_activity_comment_count() {
|
|
2548 |
Â
* @since BuddyPress (1.2.0)
|
2549 |
Â
*
|
2550 |
Â
* @uses bp_activity_recurse_comment_count()
|
2551 |
-
* @uses apply_filters() To call the 'bp_activity_recurse_comment_count' hook
|
2552 |
Â
*
|
2553 |
Â
* @param object $comment Activity comment object.
|
2554 |
-
* @param int
|
2555 |
Â
*
|
2556 |
Â
* @return int $count The activity comment count.
|
2557 |
Â
*/
|
@@ -2574,8 +2722,8 @@ function bp_activity_comment_count() {
|
|
2574 |
Â
* @since BuddyPress (2.1.0)
|
2575 |
Â
*
|
2576 |
Â
* @param int $new_count New total count for the current comment.
|
2577 |
-
* @param object $comment
|
2578 |
-
* @param int $count
|
2579 |
Â
*/
|
2580 |
Â
return apply_filters( 'bp_activity_recurse_comment_count', $new_count, $comment, $count );
|
2581 |
Â
}
|
@@ -2593,7 +2741,7 @@ function bp_activity_comment_depth() {
|
|
2593 |
Â
*
|
2594 |
Â
* @since BuddyPress (2.0.0)
|
2595 |
Â
*
|
2596 |
-
* @return int $depth Depth for the current activity comment
|
2597 |
Â
*/
|
2598 |
Â
function bp_activity_get_comment_depth() {
|
2599 |
Â
global $activities_template;
|
@@ -2643,7 +2791,7 @@ function bp_activity_comment_link() {
|
|
2643 |
Â
}
|
2644 |
Â
|
2645 |
Â
/**
|
2646 |
-
* Output the activity comment form no
|
2647 |
Â
*
|
2648 |
Â
* @since BuddyPress (1.2.0)
|
2649 |
Â
*
|
@@ -2654,19 +2802,21 @@ function bp_activity_comment_form_nojs_display() {
|
|
2654 |
Â
}
|
2655 |
Â
|
2656 |
Â
/**
|
2657 |
-
* Return the activity comment form no
|
2658 |
Â
*
|
2659 |
Â
* @since BuddyPress (1.2.0)
|
2660 |
Â
*
|
2661 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
2662 |
Â
*
|
2663 |
-
* @return string|bool The activity comment form no
|
2664 |
-
*
|
2665 |
Â
*/
|
2666 |
Â
function bp_get_activity_comment_form_nojs_display() {
|
2667 |
Â
global $activities_template;
|
2668 |
-
|
Â
|
|
2669 |
Â
return 'style="display: block"';
|
Â
|
|
2670 |
Â
|
2671 |
Â
return false;
|
2672 |
Â
}
|
@@ -2814,7 +2964,7 @@ function bp_activity_comment_permalink() {
|
|
2814 |
Â
*
|
2815 |
Â
* @since BuddyPress (1.8.0)
|
2816 |
Â
*
|
2817 |
-
* @param string $link
|
2818 |
Â
* @param int $comment_id ID for the current activity comment.
|
2819 |
Â
*/
|
2820 |
Â
return apply_filters( 'bp_get_activity_comment_permalink', $link, $comment_id );
|
@@ -2840,7 +2990,7 @@ function bp_activity_favorite_link() {
|
|
2840 |
Â
* @uses wp_nonce_url()
|
2841 |
Â
* @uses home_url()
|
2842 |
Â
* @uses bp_get_activity_root_slug()
|
2843 |
-
* @uses apply_filters() To call the 'bp_get_activity_favorite_link' hook
|
2844 |
Â
*
|
2845 |
Â
* @return string The activity favorite link.
|
2846 |
Â
*/
|
@@ -2939,11 +3089,13 @@ function bp_activity_css_class() {
|
|
2939 |
Â
|
2940 |
Â
$class = ' activity-item';
|
2941 |
Â
|
2942 |
-
if ( in_array( $activities_template->activity->type, (array) $mini_activity_actions ) || empty( $activities_template->activity->content ) )
|
2943 |
Â
$class .= ' mini';
|
Â
|
|
2944 |
Â
|
2945 |
-
if ( bp_activity_get_comment_count() && bp_activity_can_comment() )
|
2946 |
Â
$class .= ' has-comments';
|
Â
|
|
2947 |
Â
|
2948 |
Â
/**
|
2949 |
Â
* Filters the determined classes to add to the HTML element.
|
@@ -2981,7 +3133,7 @@ function bp_activity_delete_link() {
|
|
2981 |
Â
* @uses apply_filters() To call the 'bp_get_activity_delete_link' hook.
|
2982 |
Â
*
|
2983 |
Â
* @return string $link Activity delete link. Contains $redirect_to arg
|
2984 |
-
*
|
2985 |
Â
*/
|
2986 |
Â
function bp_get_activity_delete_link() {
|
2987 |
Â
|
@@ -3006,7 +3158,7 @@ function bp_activity_delete_link() {
|
|
3006 |
Â
}
|
3007 |
Â
|
3008 |
Â
/**
|
3009 |
-
* Output the URL to delete a single activity stream item
|
3010 |
Â
*
|
3011 |
Â
* @since BuddyPress (2.1.0)
|
3012 |
Â
*
|
@@ -3016,7 +3168,7 @@ function bp_activity_delete_url() {
|
|
3016 |
Â
echo esc_url( bp_get_activity_delete_url() );
|
3017 |
Â
}
|
3018 |
Â
/**
|
3019 |
-
* Return the URL to delete a single activity item
|
3020 |
Â
*
|
3021 |
Â
* @since BuddyPress (2.1.0)
|
3022 |
Â
*
|
@@ -3031,7 +3183,7 @@ function bp_activity_delete_url() {
|
|
3031 |
Â
* @uses apply_filters() To call the 'bp_get_activity_delete_link' hook.
|
3032 |
Â
*
|
3033 |
Â
* @return string $link Activity delete link. Contains $redirect_to arg
|
3034 |
-
*
|
3035 |
Â
*/
|
3036 |
Â
function bp_get_activity_delete_url() {
|
3037 |
Â
global $activities_template;
|
@@ -3077,26 +3229,30 @@ function bp_activity_latest_update( $user_id = 0 ) {
|
|
3077 |
Â
* @uses bp_is_user_inactive()
|
3078 |
Â
* @uses bp_core_is_user_deleted()
|
3079 |
Â
* @uses bp_get_user_meta()
|
3080 |
-
* @uses apply_filters() To call the 'bp_get_activity_latest_update_excerpt' hook
|
3081 |
Â
* @uses bp_create_excerpt()
|
3082 |
Â
* @uses bp_get_root_domain()
|
3083 |
Â
* @uses bp_get_activity_root_slug()
|
3084 |
-
* @uses apply_filters() To call the 'bp_get_activity_latest_update' hook
|
3085 |
Â
*
|
3086 |
Â
* @param int $user_id If empty, will fall back on displayed user.
|
Â
|
|
3087 |
Â
* @return string|bool $latest_update The activity latest update link.
|
3088 |
-
*
|
3089 |
Â
*/
|
3090 |
Â
function bp_get_activity_latest_update( $user_id = 0 ) {
|
3091 |
Â
|
3092 |
-
if ( empty( $user_id ) )
|
3093 |
Â
$user_id = bp_displayed_user_id();
|
Â
|
|
3094 |
Â
|
3095 |
-
if ( bp_is_user_inactive( $user_id ) )
|
3096 |
Â
return false;
|
Â
|
|
3097 |
Â
|
3098 |
-
if ( !$update = bp_get_user_meta( $user_id, 'bp_latest_update', true ) )
|
3099 |
Â
return false;
|
Â
|
|
3100 |
Â
|
3101 |
Â
/**
|
3102 |
Â
* Filters the latest update excerpt.
|
@@ -3132,7 +3288,7 @@ function bp_activity_latest_update( $user_id = 0 ) {
|
|
3132 |
Â
* @see bp_get_activity_filter_links() for description of parameters.
|
3133 |
Â
* @uses bp_get_activity_filter_links()
|
3134 |
Â
*
|
3135 |
-
* @param array $args See {@link bp_get_activity_filter_links()} for description.
|
3136 |
Â
*/
|
3137 |
Â
function bp_activity_filter_links( $args = false ) {
|
3138 |
Â
echo bp_get_activity_filter_links( $args );
|
@@ -3151,21 +3307,18 @@ function bp_activity_filter_links( $args = false ) {
|
|
3151 |
Â
* @uses apply_filters() To call the 'bp_get_activity_filter_link_href' hook.
|
3152 |
Â
* @uses apply_filters() To call the 'bp_get_activity_filter_links' hook.
|
3153 |
Â
*
|
3154 |
-
* @param array $args {
|
3155 |
Â
* @type string $style The type of markup to use for the links.
|
3156 |
-
*
|
3157 |
Â
* }
|
3158 |
Â
* @return string|bool $component_links The activity filter links.
|
3159 |
Â
* False on failure.
|
3160 |
Â
*/
|
3161 |
Â
function bp_get_activity_filter_links( $args = false ) {
|
3162 |
Â
|
3163 |
-
$
|
3164 |
Â
'style' => 'list'
|
3165 |
-
);
|
3166 |
-
|
3167 |
-
$r = wp_parse_args( $args, $defaults );
|
3168 |
-
extract( $r, EXTR_SKIP );
|
3169 |
Â
|
3170 |
Â
// Define local variable
|
3171 |
Â
$component_links = array();
|
@@ -3173,23 +3326,26 @@ function bp_activity_filter_links( $args = false ) {
|
|
3173 |
Â
// Fetch the names of components that have activity recorded in the DB
|
3174 |
Â
$components = BP_Activity_Activity::get_recorded_components();
|
3175 |
Â
|
3176 |
-
if ( empty( $components ) )
|
3177 |
Â
return false;
|
Â
|
|
3178 |
Â
|
3179 |
Â
foreach ( (array) $components as $component ) {
|
3180 |
Â
|
3181 |
Â
// Skip the activity comment filter
|
3182 |
-
if ( 'activity' == $component )
|
3183 |
Â
continue;
|
Â
|
|
3184 |
Â
|
3185 |
-
if ( isset( $_GET['afilter'] ) && $component == $_GET['afilter'] )
|
3186 |
Â
$selected = ' class="selected"';
|
3187 |
-
else
|
3188 |
-
|
Â
|
|
3189 |
Â
|
3190 |
Â
$component = esc_attr( $component );
|
3191 |
Â
|
3192 |
-
switch ( $style ) {
|
3193 |
Â
case 'list':
|
3194 |
Â
$tag = 'li';
|
3195 |
Â
$before = '<li id="afilter-' . $component . '"' . $selected . '>';
|
@@ -3215,7 +3371,7 @@ function bp_activity_filter_links( $args = false ) {
|
|
3215 |
Â
*
|
3216 |
Â
* @since BuddyPress (1.1.0)
|
3217 |
Â
*
|
3218 |
-
* @param string $link
|
3219 |
Â
* @param string $component The current component getting links constructed for.
|
3220 |
Â
*/
|
3221 |
Â
$link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component );
|
@@ -3225,8 +3381,9 @@ function bp_activity_filter_links( $args = false ) {
|
|
3225 |
Â
|
3226 |
Â
$link = remove_query_arg( 'afilter' , $link );
|
3227 |
Â
|
3228 |
-
if ( isset( $_GET['afilter'] ) )
|
3229 |
Â
$component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . esc_url( $link ) . '">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
|
Â
|
|
3230 |
Â
|
3231 |
Â
/**
|
3232 |
Â
* Filters all of the constructed filter links.
|
@@ -3291,7 +3448,7 @@ function bp_activity_can_comment() {
|
|
3291 |
Â
*
|
3292 |
Â
* @since BuddyPress (1.5.0)
|
3293 |
Â
*
|
3294 |
-
* @param bool $can_comment
|
3295 |
Â
* @param string $activity_action Current activity action being checked on.
|
3296 |
Â
*/
|
3297 |
Â
return apply_filters( 'bp_activity_can_comment', $can_comment, $activity_action );
|
@@ -3302,11 +3459,11 @@ function bp_activity_can_comment() {
|
|
3302 |
Â
*
|
3303 |
Â
* @since BuddyPress (1.5.0)
|
3304 |
Â
*
|
3305 |
-
* @param
|
3306 |
-
* @return bool
|
3307 |
-
*
|
3308 |
Â
*/
|
3309 |
-
function bp_activity_can_comment_reply( $comment =
|
3310 |
Â
|
3311 |
Â
// Assume activity can be commented on
|
3312 |
Â
$can_comment = true;
|
@@ -3339,7 +3496,7 @@ function bp_activity_can_comment_reply( $comment = '' ) {
|
|
3339 |
Â
* @since BuddyPress (1.5.0)
|
3340 |
Â
*
|
3341 |
Â
* @param bool $can_comment Status on if activity reply can be commented on.
|
3342 |
-
* @param string $comment
|
3343 |
Â
*/
|
3344 |
Â
return (bool) apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
|
3345 |
Â
}
|
@@ -3387,22 +3544,26 @@ function bp_total_favorite_count_for_user( $user_id = 0 ) {
|
|
3387 |
Â
* @since BuddyPress (1.2.0)
|
3388 |
Â
*
|
3389 |
Â
* @uses bp_activity_total_favorites_for_user()
|
3390 |
-
* @uses apply_filters() To call the 'bp_get_total_favorite_count_for_user' hook
|
3391 |
Â
*
|
3392 |
Â
* @param int $user_id ID of user being queried. Default: displayed user ID.
|
Â
|
|
3393 |
Â
* @return int The total favorite count for the specified user.
|
3394 |
Â
*/
|
3395 |
Â
function bp_get_total_favorite_count_for_user( $user_id = 0 ) {
|
Â
|
|
3396 |
Â
|
3397 |
-
|
3398 |
-
|
3399 |
-
|
3400 |
-
|
Â
|
|
3401 |
Â
|
3402 |
-
|
3403 |
-
|
3404 |
-
|
3405 |
-
|
Â
|
|
3406 |
Â
|
3407 |
Â
/**
|
3408 |
Â
* Filters the total favorite count for a user.
|
@@ -3438,6 +3599,7 @@ function bp_total_mention_count_for_user( $user_id = 0 ) {
|
|
3438 |
Â
* @uses apply_filters() To call the 'bp_get_total_mention_count_for_user' hook.
|
3439 |
Â
*
|
3440 |
Â
* @param int $user_id ID of user being queried. Default: displayed user ID.
|
Â
|
|
3441 |
Â
* @return int The total mention count for the specified user.
|
3442 |
Â
*/
|
3443 |
Â
function bp_get_total_mention_count_for_user( $user_id = 0 ) {
|
@@ -3483,7 +3645,7 @@ function bp_send_public_message_link() {
|
|
3483 |
Â
* @uses bp_is_user()
|
3484 |
Â
* @uses wp_nonce_url()
|
3485 |
Â
* @uses bp_get_activity_directory_permalink()
|
3486 |
-
* @uses apply_filters() To call the 'bp_get_send_public_message_link' hook
|
3487 |
Â
*
|
3488 |
Â
* @return string The public message link for the displayed user.
|
3489 |
Â
*/
|
@@ -3515,6 +3677,7 @@ function bp_send_public_message_link() {
|
|
3515 |
Â
*
|
3516 |
Â
* @param array $activity Array of activities generated from {@link bp_activity_get()}.
|
3517 |
Â
* @param array $activity_ids Used for recursion purposes in this function.
|
Â
|
|
3518 |
Â
* @return array
|
3519 |
Â
*/
|
3520 |
Â
function bp_activity_recurse_comments_activity_ids( $activity = array(), $activity_ids = array() ) {
|
@@ -3543,21 +3706,22 @@ function bp_activity_recurse_comments_activity_ids( $activity = array(), $activi
|
|
3543 |
Â
* @see bp_get_mentioned_user_display_name() for description of parameters.
|
3544 |
Â
* @uses bp_get_mentioned_user_display_name()
|
3545 |
Â
*
|
3546 |
-
* @param int|string $user_id_or_username See {@link bp_get_mentioned_user_display_name()}.
|
3547 |
Â
*/
|
3548 |
Â
function bp_mentioned_user_display_name( $user_id_or_username = false ) {
|
3549 |
Â
echo bp_get_mentioned_user_display_name( $user_id_or_username );
|
3550 |
Â
}
|
3551 |
Â
|
3552 |
Â
/**
|
3553 |
-
* Returns the mentioned user display name
|
3554 |
Â
*
|
3555 |
Â
* @since BuddyPress (1.2.0)
|
3556 |
Â
*
|
3557 |
Â
* @uses bp_core_get_user_displayname()
|
3558 |
Â
* @uses apply_filters() To call the 'bp_get_mentioned_user_display_name' hook.
|
3559 |
Â
*
|
3560 |
-
* @param int|string User ID or username.
|
Â
|
|
3561 |
Â
* @return string The mentioned user's display name.
|
3562 |
Â
*/
|
3563 |
Â
function bp_get_mentioned_user_display_name( $user_id_or_username = false ) {
|
@@ -3575,7 +3739,7 @@ function bp_mentioned_user_display_name( $user_id_or_username = false ) {
|
|
3575 |
Â
*
|
3576 |
Â
* @since BuddyPress (1.2.0)
|
3577 |
Â
*
|
3578 |
-
* @param string $name
|
3579 |
Â
* @param int|string $user_id_or_username User ID or username use for query.
|
3580 |
Â
*/
|
3581 |
Â
return apply_filters( 'bp_get_mentioned_user_display_name', $name, $user_id_or_username );
|
@@ -3589,7 +3753,7 @@ function bp_mentioned_user_display_name( $user_id_or_username = false ) {
|
|
3589 |
Â
* @see bp_get_send_public_message_button() for description of parameters.
|
3590 |
Â
* @uses bp_get_send_public_message_button()
|
3591 |
Â
*
|
3592 |
-
* @param array $args See {@link bp_get_send_public_message_button()}.
|
3593 |
Â
*/
|
3594 |
Â
function bp_send_public_message_button( $args = '' ) {
|
3595 |
Â
echo bp_get_send_public_message_button( $args );
|
@@ -3605,20 +3769,20 @@ function bp_send_public_message_button( $args = '' ) {
|
|
3605 |
Â
* @uses bp_get_button()
|
3606 |
Â
* @uses apply_filters() To call the 'bp_get_send_public_message_button' hook.
|
3607 |
Â
*
|
3608 |
-
* @param array $args {
|
3609 |
Â
* All arguments are optional. See {@link BP_Button} for complete
|
3610 |
Â
* descriptions.
|
3611 |
-
* @type string $id
|
3612 |
-
* @type string $component
|
3613 |
-
* @type bool
|
3614 |
-
* @type bool
|
3615 |
-
* @type string $wrapper_id
|
3616 |
-
* @type string $link_href
|
3617 |
-
*
|
3618 |
-
* @type string $link_title
|
3619 |
-
*
|
3620 |
-
* @type string $link_text
|
3621 |
-
* @type string $link_class
|
3622 |
Â
* }
|
3623 |
Â
* @return string The button for sending a public message.
|
3624 |
Â
*/
|
@@ -3746,7 +3910,7 @@ function bp_activity_comments_user_avatars( $args = array() ) {
|
|
3746 |
Â
* @since BuddyPress (1.7.0)
|
3747 |
Â
*
|
3748 |
Â
* @param string $retval HTML markup for the list of avatars.
|
3749 |
-
* @param array $r
|
3750 |
Â
* @param array $output Array of each avatar found, before imploded into single string.
|
3751 |
Â
*/
|
3752 |
Â
echo apply_filters( 'bp_activity_comments_user_avatars', $retval, $r, $output );
|
@@ -3782,6 +3946,7 @@ function bp_activity_get_comments_user_ids() {
|
|
3782 |
Â
* @since BuddyPress (1.7.0)
|
3783 |
Â
*
|
3784 |
Â
* @param array $comments Array of {@link BP_Activity_Activity} items.
|
Â
|
|
3785 |
Â
* @return array Array of user IDs.
|
3786 |
Â
*/
|
3787 |
Â
function bp_activity_recurse_comments_user_ids( array $comments = array() ) {
|
@@ -3852,13 +4017,13 @@ function bp_displayed_user_mentionname() {
|
|
3852 |
Â
*
|
3853 |
Â
* @since BuddyPress (1.7.0)
|
3854 |
Â
*
|
3855 |
-
* @param string
|
3856 |
-
* @param array $args {
|
3857 |
Â
* Optional extra arguments.
|
3858 |
-
* @type string
|
3859 |
-
*
|
3860 |
-
* @type array|string $selected
|
3861 |
-
*
|
3862 |
Â
* }
|
3863 |
Â
*/
|
3864 |
Â
function bp_activity_types_list( $output = 'select', $args = '' ) {
|
@@ -3896,8 +4061,8 @@ function bp_activity_types_list( $output = 'select', $args = '' ) {
|
|
3896 |
Â
*
|
3897 |
Â
* @since BuddyPress (1.7.0)
|
3898 |
Â
*
|
3899 |
-
* @param array $args
|
3900 |
-
* @param string $type
|
3901 |
Â
* @param string $description Description of the activity type being rendered.
|
3902 |
Â
*/
|
3903 |
Â
do_action( 'bp_activity_types_list_' . $output, $args, $type, $description );
|
@@ -4128,7 +4293,7 @@ function bp_activity_feed_item_title() {
|
|
4128 |
Â
}
|
4129 |
Â
|
4130 |
Â
/**
|
4131 |
-
* Output the activity feed item link
|
4132 |
Â
*
|
4133 |
Â
* @since BuddyPress (1.0.0)
|
4134 |
Â
*
|
@@ -4139,7 +4304,7 @@ function bp_activity_feed_item_link() {
|
|
4139 |
Â
}
|
4140 |
Â
|
4141 |
Â
/**
|
4142 |
-
* Return the activity feed item link
|
4143 |
Â
*
|
4144 |
Â
* @since BuddyPress (1.0.0)
|
4145 |
Â
*
|
@@ -4272,7 +4437,7 @@ add_action( 'bp_head', 'bp_activity_sitewide_feed' );
|
|
4272 |
Â
* @since BuddyPress (2.1.0)
|
4273 |
Â
*
|
4274 |
Â
* @param string $context The current context. 'activity', 'member',
|
4275 |
-
*
|
4276 |
Â
* @uses bp_get_activity_show_filters()
|
4277 |
Â
*/
|
4278 |
Â
function bp_activity_show_filters( $context = '' ) {
|
@@ -4284,7 +4449,8 @@ function bp_activity_show_filters( $context = '' ) {
|
|
4284 |
Â
* @since BuddyPress (2.1.0)
|
4285 |
Â
*
|
4286 |
Â
* @param string $context The current context. 'activity', 'member',
|
4287 |
-
*
|
Â
|
|
4288 |
Â
* @return string HTML for <option> values.
|
4289 |
Â
*/
|
4290 |
Â
function bp_get_activity_show_filters( $context = '' ) {
|
@@ -4334,7 +4500,7 @@ function bp_activity_show_filters( $context = '' ) {
|
|
4334 |
Â
*
|
4335 |
Â
* @since BuddyPress (2.2.0)
|
4336 |
Â
*
|
4337 |
-
* @param array
|
4338 |
Â
* @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
|
4339 |
Â
*/
|
4340 |
Â
$filters = apply_filters( 'bp_get_activity_show_filters_options', $filters, $context );
|
@@ -4353,7 +4519,7 @@ function bp_activity_show_filters( $context = '' ) {
|
|
4353 |
Â
*
|
4354 |
Â
* @since BuddyPress (2.1.0)
|
4355 |
Â
*
|
4356 |
-
* @param string $output
|
4357 |
Â
* @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
|
4358 |
Â
* @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
|
4359 |
Â
*/
|
80 |
Â
* @uses bp_get_activity_directory_permalink()
|
81 |
Â
*/
|
82 |
Â
function bp_activity_directory_permalink() {
|
83 |
+
echo esc_url( bp_get_activity_directory_permalink() );
|
84 |
Â
}
|
85 |
Â
/**
|
86 |
+
* Return activity directory permalink.
|
87 |
Â
*
|
88 |
Â
* @since BuddyPress (1.5.0)
|
89 |
Â
*
|
114 |
Â
* @since BuddyPress (1.0.0)
|
115 |
Â
*/
|
116 |
Â
class BP_Activity_Template {
|
117 |
+
/**
|
118 |
+
* The loop iterator.
|
119 |
+
*
|
120 |
+
* @since BuddyPress (1.5.0)
|
121 |
+
* @access public
|
122 |
+
* @var int
|
123 |
+
*/
|
124 |
+
public $current_activity = -1;
|
125 |
Â
|
126 |
+
/**
|
127 |
+
* The activity count.
|
128 |
+
*
|
129 |
+
* @since BuddyPress (1.5.0)
|
130 |
+
* @access public
|
131 |
+
* @var int
|
132 |
+
*/
|
133 |
+
public $activity_count;
|
134 |
+
|
135 |
+
/**
|
136 |
+
* The total activity count.
|
137 |
+
*
|
138 |
+
* @since BuddyPress (1.5.0)
|
139 |
+
* @access public
|
140 |
+
* @var int
|
141 |
+
*/
|
142 |
+
public $total_activity_count;
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Array of activities located by the query.
|
146 |
+
*
|
147 |
+
* @since BuddyPress (1.5.0)
|
148 |
+
* @access public
|
149 |
+
* @var array
|
150 |
+
*/
|
151 |
+
public $activities;
|
152 |
+
|
153 |
+
/**
|
154 |
+
* The activity object currently being iterated on.
|
155 |
+
*
|
156 |
+
* @since BuddyPress (1.5.0)
|
157 |
+
* @access public
|
158 |
+
* @var object
|
159 |
+
*/
|
160 |
+
public $activity;
|
161 |
+
|
162 |
+
/**
|
163 |
+
* A flag for whether the loop is currently being iterated.
|
164 |
+
*
|
165 |
+
* @since BuddyPress (1.5.0)
|
166 |
+
* @access public
|
167 |
+
* @var bool
|
168 |
+
*/
|
169 |
+
public $in_the_loop;
|
170 |
Â
|
171 |
Â
/**
|
172 |
Â
* URL parameter key for activity pagination. Default: 'acpage'.
|
174 |
Â
* @since BuddyPress (2.1.0)
|
175 |
Â
* @var string
|
176 |
Â
*/
|
177 |
+
public $pag_arg;
|
178 |
Â
|
179 |
+
/**
|
180 |
+
* The page number being requested.
|
181 |
+
*
|
182 |
+
* @since BuddyPress (1.5.0)
|
183 |
+
* @access public
|
184 |
+
* @var int
|
185 |
+
*/
|
186 |
+
public $pag_page;
|
187 |
Â
|
188 |
+
/**
|
189 |
+
* The number of items being requested per page.
|
190 |
+
*
|
191 |
+
* @since BuddyPress (1.5.0)
|
192 |
+
* @access public
|
193 |
+
* @var int
|
194 |
+
*/
|
195 |
+
public $pag_num;
|
196 |
+
|
197 |
+
/**
|
198 |
+
* An HTML string containing pagination links.
|
199 |
+
*
|
200 |
+
* @since BuddyPress (1.5.0)
|
201 |
+
* @access public
|
202 |
+
* @var string
|
203 |
+
*/
|
204 |
+
public $pag_links;
|
205 |
+
|
206 |
+
/**
|
207 |
+
* The displayed user's full name.
|
208 |
+
*
|
209 |
+
* @since BuddyPress (1.5.0)
|
210 |
+
* @access public
|
211 |
+
* @var string
|
212 |
+
*/
|
213 |
+
public $full_name;
|
214 |
Â
|
215 |
Â
/**
|
216 |
Â
* Constructor method.
|
226 |
Â
* BP_Activity_Activity::get(), as well as 'page_arg' and
|
227 |
Â
* 'include'. Default values for 'per_page' and 'display_comments'
|
228 |
Â
* differ from the originating function, and are described below.
|
229 |
+
* @type string $page_arg The string used as a query parameter in
|
230 |
+
* pagination links. Default: 'acpage'.
|
231 |
+
* @type array|bool $include Pass an array of activity IDs to
|
232 |
+
* retrieve only those items, or false to noop the 'include'
|
233 |
+
* parameter. 'include' differs from 'in' in that 'in' forms
|
234 |
+
* an IN clause that works in conjunction with other filters
|
235 |
+
* passed to the function, while 'include' is interpreted as
|
236 |
+
* an exact list of items to retrieve, which skips all other
|
237 |
+
* filter-related parameters. Default: false.
|
238 |
+
* @type int|bool $per_page Default: 20.
|
239 |
Â
* @type string|bool $display_comments Default: 'threaded'.
|
240 |
Â
* }
|
241 |
Â
*/
|
242 |
+
public function __construct( $args ) {
|
243 |
+
$bp = buddypress();
|
244 |
Â
|
245 |
Â
// Backward compatibility with old method of passing arguments
|
246 |
Â
if ( !is_array( $args ) || func_num_args() > 1 ) {
|
295 |
Â
$this->pag_num = bp_sanitize_pagination_arg( 'num', $r['per_page'] );
|
296 |
Â
|
297 |
Â
// Check if blog/forum replies are disabled
|
298 |
+
$this->disable_blogforum_replies = (bool) bp_core_get_root_option( 'bp-disable-blogforum-comments' );
|
299 |
Â
|
300 |
Â
// Get an array of the logged in user's favorite activities
|
301 |
Â
$this->my_favs = maybe_unserialize( bp_get_user_meta( bp_loggedin_user_id(), 'bp_favorite_activities', true ) );
|
366 |
Â
|
367 |
Â
// Fetch parent content for activity comments so we do not have to query in the loop
|
368 |
Â
foreach ( (array) $this->activities as $activity ) {
|
369 |
+
if ( 'activity_comment' != $activity->type ) {
|
370 |
Â
continue;
|
371 |
+
}
|
372 |
Â
|
373 |
Â
$parent_ids[] = $activity->item_id;
|
374 |
Â
}
|
375 |
Â
|
376 |
+
if ( !empty( $parent_ids ) ) {
|
377 |
Â
$activity_parents = bp_activity_get_specific( array( 'activity_ids' => $parent_ids ) );
|
378 |
+
}
|
379 |
Â
|
380 |
Â
if ( !empty( $activity_parents['activities'] ) ) {
|
381 |
+
foreach( $activity_parents['activities'] as $parent ) {
|
382 |
Â
$this->activity_parents[$parent->id] = $parent;
|
383 |
+
}
|
384 |
Â
|
385 |
Â
unset( $activity_parents );
|
386 |
Â
}
|
407 |
Â
* @return bool True if there are items in the loop, otherwise false.
|
408 |
Â
*/
|
409 |
Â
function has_activities() {
|
410 |
+
if ( $this->activity_count ) {
|
411 |
Â
return true;
|
412 |
+
}
|
413 |
Â
|
414 |
Â
return false;
|
415 |
Â
}
|
419 |
Â
*
|
420 |
Â
* @return object The next activity item to iterate over.
|
421 |
Â
*/
|
422 |
+
public function next_activity() {
|
423 |
Â
$this->current_activity++;
|
424 |
+
$this->activity = $this->activities[ $this->current_activity ];
|
425 |
Â
|
426 |
Â
return $this->activity;
|
427 |
Â
}
|
429 |
Â
/**
|
430 |
Â
* Rewind the posts and reset post index.
|
431 |
Â
*/
|
432 |
+
public function rewind_activities() {
|
433 |
Â
$this->current_activity = -1;
|
434 |
Â
if ( $this->activity_count > 0 ) {
|
435 |
Â
$this->activity = $this->activities[0];
|
448 |
Â
* @return bool True if there are more activity items to show,
|
449 |
Â
* otherwise false.
|
450 |
Â
*/
|
451 |
+
public function user_activities() {
|
452 |
+
if ( ( $this->current_activity + 1 ) < $this->activity_count ) {
|
453 |
Â
return true;
|
454 |
+
} elseif ( ( $this->current_activity + 1 ) == $this->activity_count ) {
|
455 |
Â
|
456 |
Â
/**
|
457 |
Â
* Fires right before the rewinding of activity posts.
|
459 |
Â
* @since BuddyPress (1.1.0)
|
460 |
Â
*/
|
461 |
Â
do_action( 'activity_loop_end' );
|
462 |
+
|
463 |
Â
// Do some cleaning up after the loop
|
464 |
Â
$this->rewind_activities();
|
465 |
Â
}
|
466 |
Â
|
467 |
Â
$this->in_the_loop = false;
|
468 |
+
|
469 |
Â
return false;
|
470 |
Â
}
|
471 |
Â
|
478 |
Â
*
|
479 |
Â
* @see bp_the_activity()
|
480 |
Â
*/
|
481 |
+
public function the_activity() {
|
482 |
Â
|
483 |
Â
$this->in_the_loop = true;
|
484 |
Â
$this->activity = $this->next_activity();
|
485 |
Â
|
486 |
+
if ( is_array( $this->activity ) ) {
|
487 |
Â
$this->activity = (object) $this->activity;
|
488 |
+
}
|
489 |
Â
|
490 |
+
// loop has just started
|
491 |
+
if ( $this->current_activity == 0 ) {
|
492 |
Â
|
493 |
Â
/**
|
494 |
Â
* Fires if the current activity item is the first in the activity loop.
|
510 |
Â
* @since BuddyPress (1.0.0)
|
511 |
Â
*
|
512 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
Â
|
|
513 |
Â
* @uses groups_is_user_member()
|
514 |
Â
* @uses bp_current_action()
|
515 |
Â
* @uses bp_is_current_action()
|
522 |
Â
* @uses bp_activity_get_user_favorites()
|
523 |
Â
* @uses apply_filters() To call the 'bp_has_activities' hook.
|
524 |
Â
*
|
525 |
+
* @param array|string $args {
|
526 |
Â
* Arguments for limiting the contents of the activity loop. Most arguments
|
527 |
Â
* are in the same format as {@link BP_Activity_Activity::get()}. However,
|
528 |
Â
* because the format of the arguments accepted here differs in a number of
|
555 |
Â
* @type string $search_terms Limit results by a search term. Default: false.
|
556 |
Â
* @type string $scope Use a BuddyPress pre-built filter.
|
557 |
Â
* - 'just-me' retrieves items belonging only to a user; this is equivalent
|
558 |
+
* to passing a 'user_id' argument.
|
559 |
+
* - 'friends' retrieves items belonging to the friends of a user.
|
560 |
+
* - 'groups' retrieves items belonging to groups to which a user belongs to.
|
561 |
+
* - 'favorites' retrieves a user's favorited activity items.
|
562 |
+
* - 'mentions' retrieves items where a user has received an @-mention.
|
563 |
Â
* The default value of 'scope' is set to one of the above if that value
|
564 |
Â
* appears in the appropriate place in the URL; eg, 'scope' will be 'groups'
|
565 |
Â
* when visiting http://example.com/members/joe/activity/groups/. Otherwise
|
591 |
Â
* Note that providing an offset will disable pagination. Default: false.
|
592 |
Â
* @type string|bool $display_comments How to handle activity comments. Possible values:
|
593 |
Â
* - 'threaded' - comments appear in a threaded tree, under their parent
|
594 |
+
* items.
|
595 |
Â
* - 'stream' - the activity stream is presented in a flat manner, with
|
596 |
+
* comments sorted in chronological order alongside other activity items.
|
597 |
+
* - false - don't fetch activity comments at all.
|
598 |
Â
* Default: 'threaded'.
|
599 |
Â
* @type bool $show_hidden Whether to show items marked hide_sitewide. Defaults to false, except in
|
600 |
Â
* the following cases:
|
601 |
+
* - User is viewing his own activity stream.
|
602 |
Â
* - User is viewing the activity stream of a non-public group of which he
|
603 |
+
* is a member.
|
604 |
Â
* @type string|bool $spam Spam status. 'ham_only', 'spam_only', or false to show all activity
|
605 |
Â
* regardless of spam status. Default: 'ham_only'.
|
606 |
Â
* @type bool $populate_extras Whether to pre-fetch the activity metadata for the queried items.
|
609 |
Â
* @return bool Returns true when activities are found, otherwise false.
|
610 |
Â
*/
|
611 |
Â
function bp_has_activities( $args = '' ) {
|
612 |
+
global $activities_template;
|
613 |
Â
|
614 |
+
// Get BuddyPress
|
615 |
+
$bp = buddypress();
|
616 |
+
|
617 |
+
/** Smart Defaults ********************************************************/
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
618 |
Â
|
619 |
Â
// User filtering
|
620 |
+
$user_id = bp_displayed_user_id()
|
621 |
+
? bp_displayed_user_id()
|
622 |
+
: false;
|
623 |
Â
|
624 |
Â
// Group filtering
|
625 |
+
if ( bp_is_group() ) {
|
626 |
+
$object = $bp->groups->id;
|
627 |
+
$primary_id = bp_get_current_group_id();
|
628 |
+
$show_hidden = (bool) ( groups_is_user_member( bp_loggedin_user_id(), $primary_id ) || bp_current_user_can( 'bp_moderate' ) );
|
629 |
+
} else {
|
630 |
+
$object = false;
|
631 |
+
$primary_id = false;
|
632 |
+
$show_hidden = false;
|
633 |
Â
}
|
634 |
Â
|
635 |
Â
// The default scope should recognize custom slugs
|
636 |
+
$scope = array_key_exists( bp_current_action(), (array) $bp->loaded_components )
|
637 |
+
? $bp->loaded_components[ bp_current_action() ]
|
638 |
+
: bp_current_action();
|
Â
|
|
Â
|
|
639 |
Â
|
640 |
Â
// Support for permalinks on single item pages: /groups/my-group/activity/124/
|
641 |
+
$include = bp_is_current_action( bp_get_activity_slug() )
|
642 |
+
? bp_action_variable( 0 )
|
643 |
+
: false;
|
644 |
+
|
645 |
+
/** Parse Args ************************************************************/
|
646 |
Â
|
647 |
+
// Note: any params used for filtering can be a single value, or multiple
|
648 |
+
// values comma separated.
|
649 |
+
$r = bp_parse_args( $args, array(
|
650 |
Â
'display_comments' => 'threaded', // false for none, stream/threaded - show comments in the stream or threaded under items
|
651 |
Â
'include' => $include, // pass an activity_id or string of IDs comma-separated
|
652 |
+
'exclude' => false, // pass an activity_id or string of IDs comma-separated
|
653 |
+
'in' => false, // comma-separated list or array of activity IDs among which to search
|
654 |
Â
'sort' => 'DESC', // sort DESC or ASC
|
655 |
Â
'page' => 1, // which page to load
|
656 |
Â
'per_page' => 20, // number of items per page
|
657 |
+
'page_arg' => 'acpage', // See https://buddypress.trac.wordpress.org/ticket/3679
|
658 |
Â
'max' => false, // max number to return
|
659 |
Â
'count_total' => false,
|
660 |
Â
'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide?
|
661 |
Â
'spam' => 'ham_only', // Hide spammed items
|
662 |
Â
|
Â
|
|
Â
|
|
663 |
Â
// Scope - pre-built activity filters for a user (friends/groups/favorites/mentions)
|
664 |
Â
'scope' => $scope,
|
665 |
Â
|
679 |
Â
// Searching
|
680 |
Â
'search_terms' => false, // specify terms to search on
|
681 |
Â
'update_meta_cache' => true,
|
682 |
+
), 'has_activities' );
|
683 |
Â
|
684 |
+
/** Smart Overrides *******************************************************/
|
Â
|
|
685 |
Â
|
686 |
Â
// Translate various values for 'display_comments'
|
687 |
Â
// This allows disabling comments via ?display_comments=0
|
688 |
Â
// or =none or =false. Final true is a strict type check. See #5029
|
689 |
+
if ( in_array( $r['display_comments'], array( 0, '0', 'none', 'false' ), true ) ) {
|
690 |
+
$r['display_comments'] = false;
|
691 |
Â
}
|
692 |
Â
|
693 |
Â
// Ignore pagination if an offset is passed
|
694 |
+
if ( ! empty( $r['offset'] ) ) {
|
695 |
+
$r['page'] = 0;
|
696 |
Â
}
|
697 |
Â
|
698 |
Â
// Search terms
|
699 |
+
if ( ! empty( $_REQUEST['s'] ) && empty( $r['search_terms'] ) ) {
|
700 |
+
$r['search_terms'] = $_REQUEST['s'];
|
701 |
+
}
|
702 |
Â
|
703 |
Â
// Do not exceed the maximum per page
|
704 |
+
if ( ! empty( $r['max'] ) && ( (int) $r['per_page'] > (int) $r['max'] ) ) {
|
705 |
+
$r['per_page'] = $r['max'];
|
706 |
+
}
|
707 |
Â
|
708 |
Â
/**
|
709 |
Â
* Filters whether BuddyPress should enable afilter support.
|
716 |
Â
*
|
717 |
Â
* @param bool $value True if BuddyPress should enable afilter support.
|
718 |
Â
*/
|
719 |
+
if ( isset( $_GET['afilter'] ) && apply_filters( 'bp_activity_enable_afilter_support', false ) ) {
|
720 |
+
$r['filter'] = array(
|
721 |
+
'object' => $_GET['afilter']
|
722 |
+
);
|
723 |
+
} elseif ( ! empty( $r['user_id'] ) || ! empty( $r['object'] ) || ! empty( $r['action'] ) || ! empty( $r['primary_id'] ) || ! empty( $r['secondary_id'] ) || ! empty( $r['offset'] ) || ! empty( $r['since'] ) ) {
|
724 |
+
$r['filter'] = array(
|
725 |
+
'user_id' => $r['user_id'],
|
726 |
+
'object' => $r['object'],
|
727 |
+
'action' => $r['action'],
|
728 |
+
'primary_id' => $r['primary_id'],
|
729 |
+
'secondary_id' => $r['secondary_id'],
|
730 |
+
'offset' => $r['offset'],
|
731 |
+
'since' => $r['since']
|
732 |
+
);
|
733 |
+
} else {
|
734 |
+
$r['filter'] = false;
|
735 |
+
}
|
736 |
+
|
737 |
+
// If specific activity items have been requested, override the $hide_spam
|
738 |
+
// argument. This prevents backpat errors with AJAX.
|
739 |
+
if ( ! empty( $r['include'] ) && ( 'ham_only' === $r['spam'] ) ) {
|
740 |
+
$r['spam'] = 'all';
|
741 |
+
}
|
742 |
+
|
743 |
+
/** Query *****************************************************************/
|
744 |
+
|
745 |
+
$activities_template = new BP_Activity_Template( $r );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
746 |
Â
|
747 |
Â
/**
|
748 |
Â
* Filters whether or not there are activity items to display.
|
749 |
Â
*
|
750 |
Â
* @since BuddyPress (1.1.0)
|
751 |
Â
*
|
752 |
+
* @param bool $value Whether or not there are activity items to display.
|
753 |
Â
* @param string $activities_template Current activities template being used.
|
754 |
+
* @param array $r Array of arguments passed into the BP_Activity_Template class.
|
755 |
Â
*/
|
756 |
+
return apply_filters( 'bp_has_activities', $activities_template->has_activities(), $activities_template, $r );
|
757 |
Â
}
|
758 |
Â
|
759 |
Â
/**
|
795 |
Â
echo esc_url( bp_get_activity_load_more_link() );
|
796 |
Â
}
|
797 |
Â
/**
|
798 |
+
* Get the URL for the Load More link.
|
799 |
Â
*
|
800 |
Â
* @since BuddyPress (2.1.0)
|
801 |
Â
*/
|
810 |
Â
*
|
811 |
Â
* @since BuddyPress (2.1.0)
|
812 |
Â
*
|
813 |
+
* @param string $link The "Load More" link URL with appropriate query args.
|
814 |
+
* @param string $url The original URL.
|
815 |
+
* @param object $activities_template The activity template loop global.
|
816 |
Â
*/
|
817 |
Â
return apply_filters( 'bp_get_activity_load_more_link', $link, $url, $activities_template );
|
818 |
Â
}
|
847 |
Â
$to_num = bp_core_number_format( ( $start_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $start_num + ( $activities_template->pag_num - 1 ) );
|
848 |
Â
$total = bp_core_number_format( $activities_template->total_activity_count );
|
849 |
Â
|
850 |
+
if ( 1 == $activities_template->total_activity_count ) {
|
851 |
+
$message = __( 'Viewing 1 item', 'buddypress' );
|
852 |
+
} else {
|
853 |
+
$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 );
|
854 |
+
}
|
855 |
+
|
856 |
+
return $message;
|
857 |
Â
}
|
858 |
Â
|
859 |
Â
/**
|
1047 |
Â
* @since BuddyPress (1.0.0)
|
1048 |
Â
*
|
1049 |
Â
* @global string $bp_activity_no_activity
|
1050 |
+
* @uses apply_filters() To call the 'bp_get_activities_no_activity' hook.
|
1051 |
Â
* @todo Deprecate.
|
1052 |
Â
*
|
1053 |
Â
* @return string
|
1202 |
Â
}
|
1203 |
Â
|
1204 |
Â
/**
|
1205 |
+
* Output the display name of the member who posted the activity.
|
1206 |
Â
*
|
1207 |
Â
* @since BuddyPress (2.1.0)
|
1208 |
Â
*
|
1213 |
Â
}
|
1214 |
Â
|
1215 |
Â
/**
|
1216 |
+
* Return the display name of the member who posted the activity.
|
1217 |
Â
*
|
1218 |
Â
* @since BuddyPress (2.1.0)
|
1219 |
Â
*
|
1421 |
Â
* @see bp_get_activity_avatar() for description of arguments.
|
1422 |
Â
* @uses bp_get_activity_avatar()
|
1423 |
Â
*
|
1424 |
+
* @param array|string $args See {@link bp_get_activity_avatar()} for description.
|
1425 |
Â
*/
|
1426 |
Â
function bp_activity_avatar( $args = '' ) {
|
1427 |
Â
echo bp_get_activity_avatar( $args );
|
1433 |
Â
*
|
1434 |
Â
* @see bp_core_fetch_avatar() For a description of the arguments.
|
1435 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
Â
|
|
1436 |
Â
* @uses bp_is_single_activity()
|
1437 |
Â
* @uses wp_parse_args()
|
1438 |
+
* @uses apply_filters() To call the 'bp_get_activity_avatar_object_' . $current_activity_item->component hook.
|
1439 |
+
* @uses apply_filters() To call the 'bp_get_activity_avatar_item_id' hook.
|
1440 |
Â
* @uses bp_core_fetch_avatar()
|
1441 |
+
* @uses apply_filters() To call the 'bp_get_activity_avatar' hook.
|
1442 |
Â
*
|
1443 |
+
* @param array|string $args {
|
1444 |
Â
* Arguments are listed here with an explanation of their defaults.
|
1445 |
Â
* For more information about the arguments, see
|
1446 |
Â
* {@link bp_core_fetch_avatar()}.
|
1447 |
+
* @type string $alt Default: 'Profile picture of [user name]' if
|
1448 |
+
* activity user name is available, otherwise 'Profile picture'.
|
1449 |
+
* @type string $class Default: 'avatar'.
|
1450 |
+
* @type string|bool $email Default: Email of the activity's
|
1451 |
+
* associated user, if available. Otherwise false.
|
1452 |
+
* @type string $type Default: 'full' when viewing a single activity
|
1453 |
+
* permalink page, otherwise 'thumb'.
|
1454 |
+
* @type int|bool $user_id Default: ID of the activity's user.
|
1455 |
Â
* }
|
1456 |
Â
* @return string User avatar string.
|
1457 |
Â
*/
|
1525 |
Â
$item_id = apply_filters( 'bp_get_activity_avatar_item_id', $item_id );
|
1526 |
Â
|
1527 |
Â
// If this is a user object pass the users' email address for Gravatar so we don't have to prefetch it.
|
1528 |
+
if ( 'user' == $object && empty( $user_id ) && empty( $email ) && isset( $current_activity_item->user_email ) ) {
|
1529 |
Â
$email = $current_activity_item->user_email;
|
1530 |
+
}
|
1531 |
Â
|
1532 |
Â
/**
|
1533 |
Â
* Filters the value returned by bp_core_fetch_avatar.
|
1556 |
Â
* @see bp_get_activity_secondary_avatar() for description of arguments.
|
1557 |
Â
* @uses bp_get_activity_secondary_avatar()
|
1558 |
Â
*
|
1559 |
+
* @param array|string $args See {@link bp_get_activity_secondary_avatar} for description.
|
1560 |
Â
*/
|
1561 |
Â
function bp_activity_secondary_avatar( $args = '' ) {
|
1562 |
Â
echo bp_get_activity_secondary_avatar( $args );
|
1563 |
Â
}
|
1564 |
Â
|
1565 |
Â
/**
|
1566 |
+
* Return the avatar of the object that action was performed on.
|
1567 |
Â
*
|
1568 |
Â
* @since BuddyPress (1.2.0)
|
1569 |
Â
*
|
1576 |
Â
* @uses bp_core_fetch_avatar()
|
1577 |
Â
* @uses apply_filters() To call the 'bp_get_activity_secondary_avatar' hook.
|
1578 |
Â
*
|
1579 |
+
* @param array|string $args {
|
1580 |
Â
* For a complete description of arguments, see {@link bp_core_fetch_avatar()}.
|
1581 |
+
* @type string $alt Default value varies based on current activity
|
1582 |
+
* item component.
|
1583 |
+
* @type string $type Default: 'full' when viewing a single activity
|
1584 |
+
* permalink page, otherwise 'thumb'.
|
1585 |
+
* @type string $class Default: 'avatar'.
|
1586 |
+
* @type string|bool $email Default: email of the activity's user.
|
1587 |
+
* @type int|bool $user_id Default: ID of the activity's user.
|
1588 |
Â
* }
|
1589 |
Â
* @return string The secondary avatar
|
1590 |
Â
*/
|
1606 |
Â
// Set item_id and object (default to user)
|
1607 |
Â
switch ( $activities_template->activity->component ) {
|
1608 |
Â
case 'groups' :
|
1609 |
+
if ( bp_disable_group_avatar_uploads() ) {
|
1610 |
+
return false;
|
1611 |
+
}
|
1612 |
+
|
1613 |
Â
$object = 'group';
|
1614 |
Â
$item_id = $activities_template->activity->item_id;
|
1615 |
Â
$link = '';
|
1714 |
Â
*
|
1715 |
Â
* @since BuddyPress (1.7.0)
|
1716 |
Â
*
|
1717 |
+
* @param string $link Link to wrap the avatar image in.
|
1718 |
Â
* @param string $component Activity component being acted on.
|
1719 |
Â
*/
|
1720 |
Â
$link = apply_filters( 'bp_get_activity_secondary_avatar_link', $link, $activities_template->activity->component );
|
1724 |
Â
*
|
1725 |
Â
* @since BuddyPress (1.2.10)
|
1726 |
Â
*
|
1727 |
+
* @param string $avatar Formatted HTML <img> element, or raw avatar URL.
|
1728 |
Â
*/
|
1729 |
Â
$avatar = apply_filters( 'bp_get_activity_secondary_avatar', $avatar );
|
1730 |
Â
|
1740 |
Â
}
|
1741 |
Â
|
1742 |
Â
/**
|
1743 |
+
* Output the activity action.
|
1744 |
Â
*
|
1745 |
Â
* @since BuddyPress (1.2.0)
|
1746 |
Â
*
|
1752 |
Â
}
|
1753 |
Â
|
1754 |
Â
/**
|
1755 |
+
* Return the activity action.
|
1756 |
Â
*
|
1757 |
Â
* @since BuddyPress (1.2.0)
|
1758 |
Â
*
|
1759 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
1760 |
Â
* @param array $args Only parameter is "no_timestamp". If true, timestamp is shown in output.
|
1761 |
+
* @uses apply_filters_ref_array() To call the 'bp_get_activity_action_pre_meta' hook.
|
1762 |
Â
* @uses bp_insert_activity_meta()
|
1763 |
Â
* @uses apply_filters_ref_array() To call the 'bp_get_activity_action' hook.
|
1764 |
Â
*
|
1765 |
Â
* @param array $args {
|
1766 |
Â
* @type bool $no_timestamp Whether to exclude the timestamp.
|
1767 |
Â
* }
|
1768 |
+
*
|
1769 |
Â
* @return string The activity action.
|
1770 |
Â
*/
|
1771 |
Â
function bp_get_activity_action( $args = array() ) {
|
1772 |
Â
global $activities_template;
|
1773 |
Â
|
1774 |
+
$r = wp_parse_args( $args, array(
|
1775 |
Â
'no_timestamp' => false,
|
1776 |
+
) );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1777 |
Â
|
1778 |
Â
/**
|
1779 |
Â
* Filters the activity action before the action is inserted as meta.
|
1782 |
Â
*
|
1783 |
Â
* @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
|
1784 |
Â
*/
|
1785 |
+
$action = apply_filters_ref_array( 'bp_get_activity_action_pre_meta', array(
|
1786 |
+
$activities_template->activity->action,
|
1787 |
+
&$activities_template->activity,
|
1788 |
+
$r
|
1789 |
+
) );
|
1790 |
Â
|
1791 |
+
// Prepend the activity action meta (link, time since, etc...)
|
1792 |
+
if ( ! empty( $action ) && empty( $r['no_timestamp'] ) ) {
|
1793 |
Â
$action = bp_insert_activity_meta( $action );
|
1794 |
+
}
|
1795 |
Â
|
1796 |
Â
/**
|
1797 |
Â
* Filters the activity action after the action has been inserted as meta.
|
1800 |
Â
*
|
1801 |
Â
* @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
|
1802 |
Â
*/
|
1803 |
+
return apply_filters_ref_array( 'bp_get_activity_action', array(
|
1804 |
+
$action,
|
1805 |
+
&$activities_template->activity,
|
1806 |
+
$r
|
1807 |
+
) );
|
1808 |
Â
}
|
1809 |
Â
|
1810 |
Â
/**
|
1811 |
+
* Output the activity content body.
|
1812 |
Â
*
|
1813 |
Â
* @since BuddyPress (1.2.0)
|
1814 |
Â
*
|
1819 |
Â
}
|
1820 |
Â
|
1821 |
Â
/**
|
1822 |
+
* Return the activity content body.
|
1823 |
Â
*
|
1824 |
Â
* @since BuddyPress (1.2.0)
|
1825 |
Â
*
|
1833 |
Â
global $activities_template;
|
1834 |
Â
|
1835 |
Â
// Backwards compatibility if action is not being used
|
1836 |
+
if ( empty( $activities_template->activity->action ) && ! empty( $activities_template->activity->content ) ) {
|
1837 |
Â
$activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content );
|
1838 |
+
}
|
1839 |
Â
|
1840 |
Â
/**
|
1841 |
Â
* Filters the activity content body.
|
1859 |
Â
function bp_activity_has_content() {
|
1860 |
Â
global $activities_template;
|
1861 |
Â
|
1862 |
+
if ( ! empty( $activities_template->activity->content ) ) {
|
1863 |
Â
return true;
|
1864 |
+
}
|
1865 |
Â
|
1866 |
Â
return false;
|
1867 |
Â
}
|
1898 |
Â
|
1899 |
Â
/**
|
1900 |
Â
* If you want to filter activity update content, please use
|
1901 |
+
* the filter 'bp_get_activity_content_body'.
|
1902 |
Â
*
|
1903 |
Â
* This function is mainly for backwards compatibility.
|
1904 |
Â
*/
|
1924 |
Â
* @uses apply_filters() To call the 'bp_insert_activity_meta' hook.
|
1925 |
Â
*
|
1926 |
Â
* @param string $content The activity content.
|
1927 |
+
*
|
1928 |
Â
* @return string The activity content with the metadata string attached.
|
1929 |
Â
*/
|
1930 |
+
function bp_insert_activity_meta( $content = '' ) {
|
1931 |
Â
global $activities_template;
|
1932 |
Â
|
1933 |
Â
// Strip any legacy time since placeholders from BP 1.0-1.1
|
1934 |
+
$new_content = str_replace( '<span class="time-since">%s</span>', '', $content );
|
1935 |
+
|
1936 |
+
// Get the time since this activity was recorded
|
1937 |
+
$date_recorded = bp_core_time_since( $activities_template->activity->date_recorded );
|
1938 |
Â
|
1939 |
Â
/**
|
1940 |
Â
* Filters the activity item time since markup.
|
1943 |
Â
*
|
1944 |
Â
* @param array $value Array containing the time since markup and the current activity component.
|
1945 |
Â
*/
|
1946 |
+
$time_since = apply_filters_ref_array( 'bp_activity_time_since', array(
|
1947 |
+
'<span class="time-since">' . $date_recorded . '</span>',
|
1948 |
+
&$activities_template->activity
|
1949 |
+
) );
|
1950 |
Â
|
1951 |
Â
// Insert the permalink
|
1952 |
+
if ( ! bp_is_single_activity() ) {
|
1953 |
+
|
1954 |
+
// Setup variables for activity meta
|
1955 |
+
$activity_permalink = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity );
|
1956 |
+
$activity_meta = sprintf( '%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>',
|
1957 |
+
$new_content,
|
1958 |
+
$activity_permalink,
|
1959 |
+
esc_attr__( 'View Discussion', 'buddypress' ),
|
1960 |
+
$time_since
|
1961 |
+
);
|
1962 |
Â
|
1963 |
Â
/**
|
1964 |
Â
* Filters the activity permalink to be added to the activity content.
|
1967 |
Â
*
|
1968 |
Â
* @param array $value Array containing the html markup for the activity permalink, after being parsed by sprintf and current activity component.
|
1969 |
Â
*/
|
1970 |
+
$new_content = apply_filters_ref_array( 'bp_activity_permalink', array(
|
1971 |
+
$activity_meta,
|
1972 |
+
&$activities_template->activity
|
1973 |
+
) );
|
1974 |
Â
} else {
|
1975 |
+
$new_content .= str_pad( $time_since, strlen( $time_since ) + 2, ' ', STR_PAD_BOTH );
|
1976 |
Â
}
|
1977 |
Â
|
1978 |
Â
/**
|
1982 |
Â
*
|
1983 |
Â
* @param string $content Activity content with the activity metadata added.
|
1984 |
Â
*/
|
1985 |
+
return apply_filters( 'bp_insert_activity_meta', $new_content, $content );
|
1986 |
Â
}
|
1987 |
Â
|
1988 |
Â
/**
|
1991 |
Â
* @since BuddyPress (1.2.0)
|
1992 |
Â
*
|
1993 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
1994 |
+
* @uses apply_filters() To call the 'bp_activity_user_can_delete' hook.
|
1995 |
+
*
|
1996 |
+
* @param object|bool $activity Optional. Falls back on the current item in the loop.
|
1997 |
Â
*
|
Â
|
|
1998 |
Â
* @return bool True if can delete, false otherwise.
|
1999 |
Â
*/
|
2000 |
Â
function bp_activity_user_can_delete( $activity = false ) {
|
2040 |
Â
* @since BuddyPress (1.5.0)
|
2041 |
Â
*
|
2042 |
Â
* @param bool $can_delete Whether the user can delete the item.
|
2043 |
+
* @param object $activity Current activity item object.
|
2044 |
Â
*/
|
2045 |
Â
return (bool) apply_filters( 'bp_activity_user_can_delete', $can_delete, $activity );
|
2046 |
Â
}
|
2053 |
Â
* @see bp_get_activity_parent_content() for a description of arguments.
|
2054 |
Â
* @uses bp_get_activity_parent_content()
|
2055 |
Â
*
|
2056 |
+
* @param array|string $args See {@link bp_get_activity_parent_content} for description.
|
2057 |
Â
*/
|
2058 |
Â
function bp_activity_parent_content( $args = '' ) {
|
2059 |
Â
echo bp_get_activity_parent_content($args);
|
2065 |
Â
* @since BuddyPress (1.2.0)
|
2066 |
Â
*
|
2067 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
Â
|
|
2068 |
Â
* @uses apply_filters() To call the 'bp_get_activity_parent_content' hook.
|
2069 |
Â
*
|
2070 |
+
* @param string $args Unused. Left over from an earlier implementation.
|
2071 |
+
*
|
2072 |
+
* @return mixed False on failure, otherwise the activity parent content.
|
Â
|
|
Â
|
|
2073 |
Â
*/
|
2074 |
Â
function bp_get_activity_parent_content( $args = '' ) {
|
2075 |
Â
global $activities_template;
|
2076 |
Â
|
2077 |
+
// Bail if no activity on no item ID
|
2078 |
+
if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
|
2079 |
+
return false;
|
2080 |
+
}
|
Â
|
|
Â
|
|
2081 |
Â
|
2082 |
Â
// Get the ID of the parent activity content
|
2083 |
+
$parent_id = (int) $activities_template->activity->item_id;
|
Â
|
|
2084 |
Â
|
2085 |
Â
// Bail if no parent content
|
2086 |
+
if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
|
2087 |
Â
return false;
|
2088 |
+
}
|
2089 |
Â
|
2090 |
Â
// Bail if no action
|
2091 |
+
if ( empty( $activities_template->activity_parents[ $parent_id ]->action ) ) {
|
2092 |
Â
return false;
|
2093 |
+
}
|
2094 |
Â
|
2095 |
Â
// Content always includes action
|
2096 |
+
$content = $activities_template->activity_parents[ $parent_id ]->action;
|
2097 |
Â
|
2098 |
Â
// Maybe append activity content, if it exists
|
2099 |
+
if ( ! empty( $activities_template->activity_parents[ $parent_id ]->content ) ) {
|
2100 |
+
$content .= ' ' . $activities_template->activity_parents[ $parent_id ]->content;
|
2101 |
+
}
|
2102 |
Â
|
2103 |
Â
// Remove the time since content for backwards compatibility
|
2104 |
Â
$content = str_replace( '<span class="time-since">%s</span>', '', $content );
|
2133 |
Â
* @global BP_Activity_Template $activities_template
|
2134 |
Â
*
|
2135 |
Â
* @return bool|int False if parent activity can't be found, otherwise
|
2136 |
+
* the parent activity's user ID.
|
2137 |
Â
*/
|
2138 |
Â
function bp_get_activity_parent_user_id() {
|
2139 |
Â
global $activities_template;
|
2140 |
Â
|
2141 |
Â
// Bail if no activity on no item ID
|
2142 |
+
if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
|
2143 |
Â
return false;
|
2144 |
+
}
|
2145 |
Â
|
2146 |
Â
// Get the ID of the parent activity content
|
2147 |
+
$parent_id = (int) $activities_template->activity->item_id;
|
Â
|
|
2148 |
Â
|
2149 |
Â
// Bail if no parent item
|
2150 |
+
if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
|
2151 |
Â
return false;
|
2152 |
+
}
|
2153 |
Â
|
2154 |
Â
// Bail if no parent user ID
|
2155 |
+
if ( empty( $activities_template->activity_parents[ $parent_id ]->user_id ) ) {
|
2156 |
Â
return false;
|
2157 |
+
}
|
2158 |
Â
|
2159 |
+
$retval = $activities_template->activity_parents[ $parent_id ]->user_id;
|
2160 |
Â
|
2161 |
Â
/**
|
2162 |
Â
* Filters the activity parent item's user ID.
|
2209 |
Â
*
|
2210 |
Â
* @todo deprecate $args param
|
2211 |
Â
*
|
2212 |
+
* @param array|string $args See {@link bp_activity_get_comments} for description.
|
2213 |
Â
*/
|
2214 |
Â
function bp_activity_comments( $args = '' ) {
|
2215 |
Â
echo bp_activity_get_comments( $args );
|
2225 |
Â
* @todo Given that checks for children already happen in bp_activity_recurse_comments(),
|
2226 |
Â
* this function can probably be streamlined or removed.
|
2227 |
Â
*
|
2228 |
+
* @param string $args Unused. Left over from an earlier implementation.
|
2229 |
Â
*
|
2230 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
2231 |
Â
* @uses bp_activity_recurse_comments()
|
2232 |
+
*
|
2233 |
+
* @return bool
|
2234 |
Â
*/
|
2235 |
Â
function bp_activity_get_comments( $args = '' ) {
|
2236 |
Â
global $activities_template;
|
2237 |
Â
|
2238 |
+
if ( empty( $activities_template->activity->children ) ) {
|
2239 |
Â
return false;
|
2240 |
+
}
|
2241 |
Â
|
2242 |
Â
bp_activity_recurse_comments( $activities_template->activity );
|
2243 |
Â
}
|
2244 |
Â
|
2245 |
Â
/**
|
2246 |
+
* Loops through a level of activity comments and loads the template for each.
|
2247 |
Â
*
|
2248 |
Â
* Note: The recursion itself used to happen entirely in this function. Now it is
|
2249 |
Â
* split between here and the comment.php template.
|
2250 |
Â
*
|
2251 |
Â
* @since BuddyPress (1.2.0)
|
2252 |
Â
*
|
2253 |
+
* @param object $comment The activity object currently being recursed.
|
2254 |
Â
*
|
2255 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
2256 |
Â
* @uses locate_template()
|
2257 |
+
*
|
2258 |
+
* @return bool|string
|
2259 |
Â
*/
|
2260 |
Â
function bp_activity_recurse_comments( $comment ) {
|
2261 |
Â
global $activities_template;
|
2262 |
Â
|
2263 |
+
if ( empty( $comment ) ) {
|
2264 |
Â
return false;
|
2265 |
+
}
|
2266 |
Â
|
2267 |
+
if ( empty( $comment->children ) ) {
|
2268 |
Â
return false;
|
2269 |
+
}
|
2270 |
Â
|
2271 |
Â
/**
|
2272 |
Â
* Filters the opening tag for the template that lists activity comments.
|
2275 |
Â
*
|
2276 |
Â
* @param string $value Opening tag for the HTML markup to use.
|
2277 |
Â
*/
|
2278 |
+
echo apply_filters( 'bp_activity_recurse_comments_start_ul', '<ul>' );
|
2279 |
Â
foreach ( (array) $comment->children as $comment_child ) {
|
2280 |
+
|
2281 |
Â
// Put the comment into the global so it's available to filters
|
2282 |
Â
$activities_template->activity->current_comment = $comment_child;
|
2283 |
Â
|
2303 |
Â
*
|
2304 |
Â
* @param string $value Closing tag for the HTML markup to use.
|
2305 |
Â
*/
|
2306 |
+
echo apply_filters( 'bp_activity_recurse_comments_end_ul', '</ul>' );
|
2307 |
Â
}
|
2308 |
Â
|
2309 |
Â
/**
|
2315 |
Â
* @uses apply_filters() To call the 'bp_activity_current_comment' hook.
|
2316 |
Â
*
|
2317 |
Â
* @return object|bool $current_comment The activity comment currently being
|
2318 |
+
* displayed. False on failure.
|
2319 |
Â
*/
|
2320 |
Â
function bp_activity_current_comment() {
|
2321 |
Â
global $activities_template;
|
2322 |
Â
|
2323 |
+
$current_comment = !empty( $activities_template->activity->current_comment )
|
2324 |
+
? $activities_template->activity->current_comment
|
2325 |
+
: false;
|
2326 |
Â
|
2327 |
Â
/**
|
2328 |
Â
* Filters the current comment being recursed.
|
2354 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
2355 |
Â
* @uses apply_filters() To call the 'bp_activity_comment_id' hook.
|
2356 |
Â
*
|
2357 |
+
* @return int|bool $comment_id The ID of the activity comment currently
|
2358 |
+
* being displayed, false if none is found.
|
2359 |
Â
*/
|
2360 |
Â
function bp_get_activity_comment_id() {
|
2361 |
Â
global $activities_template;
|
2392 |
Â
* @uses apply_filters() To call the 'bp_activity_comment_user_id' hook.
|
2393 |
Â
*
|
2394 |
Â
* @return int|bool $user_id The user_id of the author of the displayed
|
2395 |
+
* activity comment. False on failure.
|
2396 |
Â
*/
|
2397 |
Â
function bp_get_activity_comment_user_id() {
|
2398 |
Â
global $activities_template;
|
2427 |
Â
*
|
2428 |
Â
* @uses bp_core_get_user_domain()
|
2429 |
Â
* @uses bp_get_activity_comment_user_id()
|
2430 |
+
* @uses apply_filters() To call the 'bp_activity_comment_user_link' hook.
|
2431 |
Â
*
|
2432 |
Â
* @return string $user_link The URL of the activity comment author's profile.
|
2433 |
Â
*/
|
2490 |
Â
}
|
2491 |
Â
|
2492 |
Â
/**
|
2493 |
+
* Output the formatted date_recorded of the activity comment currently being displayed.
|
2494 |
Â
*
|
2495 |
Â
* @since BuddyPress (1.5.0)
|
2496 |
Â
*
|
2501 |
Â
}
|
2502 |
Â
|
2503 |
Â
/**
|
2504 |
+
* Return the formatted date_recorded for the activity comment currently being displayed.
|
2505 |
Â
*
|
2506 |
Â
* @since BuddyPress (1.5.0)
|
2507 |
Â
*
|
Â
|
|
2508 |
Â
* @uses bp_core_time_since()
|
2509 |
+
* @uses apply_filters() To call the 'bp_activity_comment_date_recorded' hook.
|
2510 |
Â
*
|
2511 |
Â
* @return string|bool $date_recorded Time since the activity was recorded,
|
2512 |
+
* in the form "%s ago". False on failure.
|
2513 |
Â
*/
|
2514 |
Â
function bp_get_activity_comment_date_recorded() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2515 |
Â
|
2516 |
Â
/**
|
2517 |
Â
* Filters the recorded date of the activity comment currently being displayed.
|
2520 |
Â
*
|
2521 |
Â
* @param string|bool Date for the activity comment currently being displayed.
|
2522 |
Â
*/
|
2523 |
+
return apply_filters( 'bp_activity_comment_date_recorded', bp_core_time_since( bp_get_activity_comment_date_recorded_raw() ) );
|
2524 |
+
}
|
2525 |
+
|
2526 |
+
/**
|
2527 |
+
* Output the date_recorded of the activity comment currently being displayed.
|
2528 |
+
*
|
2529 |
+
* @since BuddyPress (2.3.0)
|
2530 |
+
*
|
2531 |
+
* @uses bp_get_activity_comment_date_recorded()
|
2532 |
+
*/
|
2533 |
+
function bp_activity_comment_date_recorded_raw() {
|
2534 |
+
echo bp_get_activity_comment_date_recorded_raw();
|
2535 |
+
}
|
2536 |
+
|
2537 |
+
/**
|
2538 |
+
* Return the date_recorded for the activity comment currently being displayed.
|
2539 |
+
*
|
2540 |
+
* @since BuddyPress (2.3.0)
|
2541 |
+
*
|
2542 |
+
* @global object $activities_template {@link BP_Activity_Template}
|
2543 |
+
* @uses bp_core_time_since()
|
2544 |
+
* @uses apply_filters() To call the 'bp_activity_comment_date_recorded' hook.
|
2545 |
+
*
|
2546 |
+
* @return string|bool $date_recorded Time since the activity was recorded,
|
2547 |
+
* in the form "%s ago". False on failure.
|
2548 |
+
*/
|
2549 |
+
function bp_get_activity_comment_date_recorded_raw() {
|
2550 |
+
global $activities_template;
|
2551 |
+
|
2552 |
+
/**
|
2553 |
+
* Filters the raw recorded date of the activity comment currently being displayed.
|
2554 |
+
*
|
2555 |
+
* @since BuddyPress (2.3.0)
|
2556 |
+
*
|
2557 |
+
* @param string|bool Raw date for the activity comment currently being displayed.
|
2558 |
+
*/
|
2559 |
+
return apply_filters( 'bp_activity_comment_date_recorded', $activities_template->activity->current_comment->date_recorded );
|
2560 |
Â
}
|
2561 |
Â
|
2562 |
Â
/**
|
2571 |
Â
}
|
2572 |
Â
|
2573 |
Â
/**
|
2574 |
+
* Gets the 'delete' URL for the activity comment currently being displayed.
|
2575 |
Â
*
|
2576 |
Â
* @since BuddyPress (1.5.0)
|
2577 |
Â
*
|
2582 |
Â
* @uses apply_filters() To call the 'bp_activity_comment_delete_link' hook.
|
2583 |
Â
*
|
2584 |
Â
* @return string $link The nonced URL for deleting the current
|
2585 |
+
* activity comment.
|
2586 |
Â
*/
|
2587 |
Â
function bp_get_activity_comment_delete_link() {
|
2588 |
Â
$link = wp_nonce_url( bp_get_root_domain() . '/' . bp_get_activity_slug() . '/delete/' . bp_get_activity_comment_id() . '?cid=' . bp_get_activity_comment_id(), 'bp_activity_delete_link' );
|
2696 |
Â
* @since BuddyPress (1.2.0)
|
2697 |
Â
*
|
2698 |
Â
* @uses bp_activity_recurse_comment_count()
|
2699 |
+
* @uses apply_filters() To call the 'bp_activity_recurse_comment_count' hook.
|
2700 |
Â
*
|
2701 |
Â
* @param object $comment Activity comment object.
|
2702 |
+
* @param int $count The current iteration count.
|
2703 |
Â
*
|
2704 |
Â
* @return int $count The activity comment count.
|
2705 |
Â
*/
|
2722 |
Â
* @since BuddyPress (2.1.0)
|
2723 |
Â
*
|
2724 |
Â
* @param int $new_count New total count for the current comment.
|
2725 |
+
* @param object $comment Activity comment object.
|
2726 |
+
* @param int $count Current iteration count for the current comment.
|
2727 |
Â
*/
|
2728 |
Â
return apply_filters( 'bp_activity_recurse_comment_count', $new_count, $comment, $count );
|
2729 |
Â
}
|
2741 |
Â
*
|
2742 |
Â
* @since BuddyPress (2.0.0)
|
2743 |
Â
*
|
2744 |
+
* @return int $depth Depth for the current activity comment.
|
2745 |
Â
*/
|
2746 |
Â
function bp_activity_get_comment_depth() {
|
2747 |
Â
global $activities_template;
|
2791 |
Â
}
|
2792 |
Â
|
2793 |
Â
/**
|
2794 |
+
* Output the activity comment form no JavaScript display CSS.
|
2795 |
Â
*
|
2796 |
Â
* @since BuddyPress (1.2.0)
|
2797 |
Â
*
|
2802 |
Â
}
|
2803 |
Â
|
2804 |
Â
/**
|
2805 |
+
* Return the activity comment form no JavaScript display CSS.
|
2806 |
Â
*
|
2807 |
Â
* @since BuddyPress (1.2.0)
|
2808 |
Â
*
|
2809 |
Â
* @global object $activities_template {@link BP_Activity_Template}
|
2810 |
Â
*
|
2811 |
+
* @return string|bool The activity comment form no JavaScript
|
2812 |
+
* display CSS. False on failure.
|
2813 |
Â
*/
|
2814 |
Â
function bp_get_activity_comment_form_nojs_display() {
|
2815 |
Â
global $activities_template;
|
2816 |
+
|
2817 |
+
if ( isset( $_GET['ac'] ) && ( $_GET['ac'] === ( $activities_template->activity->id . '/' ) ) ) {
|
2818 |
Â
return 'style="display: block"';
|
2819 |
+
}
|
2820 |
Â
|
2821 |
Â
return false;
|
2822 |
Â
}
|
2964 |
Â
*
|
2965 |
Â
* @since BuddyPress (1.8.0)
|
2966 |
Â
*
|
2967 |
+
* @param string $link Activity comment permalink.
|
2968 |
Â
* @param int $comment_id ID for the current activity comment.
|
2969 |
Â
*/
|
2970 |
Â
return apply_filters( 'bp_get_activity_comment_permalink', $link, $comment_id );
|
2990 |
Â
* @uses wp_nonce_url()
|
2991 |
Â
* @uses home_url()
|
2992 |
Â
* @uses bp_get_activity_root_slug()
|
2993 |
+
* @uses apply_filters() To call the 'bp_get_activity_favorite_link' hook.
|
2994 |
Â
*
|
2995 |
Â
* @return string The activity favorite link.
|
2996 |
Â
*/
|
3089 |
Â
|
3090 |
Â
$class = ' activity-item';
|
3091 |
Â
|
3092 |
+
if ( in_array( $activities_template->activity->type, (array) $mini_activity_actions ) || empty( $activities_template->activity->content ) ) {
|
3093 |
Â
$class .= ' mini';
|
3094 |
+
}
|
3095 |
Â
|
3096 |
+
if ( bp_activity_get_comment_count() && bp_activity_can_comment() ) {
|
3097 |
Â
$class .= ' has-comments';
|
3098 |
+
}
|
3099 |
Â
|
3100 |
Â
/**
|
3101 |
Â
* Filters the determined classes to add to the HTML element.
|
3133 |
Â
* @uses apply_filters() To call the 'bp_get_activity_delete_link' hook.
|
3134 |
Â
*
|
3135 |
Â
* @return string $link Activity delete link. Contains $redirect_to arg
|
3136 |
+
* if on single activity page.
|
3137 |
Â
*/
|
3138 |
Â
function bp_get_activity_delete_link() {
|
3139 |
Â
|
3158 |
Â
}
|
3159 |
Â
|
3160 |
Â
/**
|
3161 |
+
* Output the URL to delete a single activity stream item.
|
3162 |
Â
*
|
3163 |
Â
* @since BuddyPress (2.1.0)
|
3164 |
Â
*
|
3168 |
Â
echo esc_url( bp_get_activity_delete_url() );
|
3169 |
Â
}
|
3170 |
Â
/**
|
3171 |
+
* Return the URL to delete a single activity item.
|
3172 |
Â
*
|
3173 |
Â
* @since BuddyPress (2.1.0)
|
3174 |
Â
*
|
3183 |
Â
* @uses apply_filters() To call the 'bp_get_activity_delete_link' hook.
|
3184 |
Â
*
|
3185 |
Â
* @return string $link Activity delete link. Contains $redirect_to arg
|
3186 |
+
* if on single activity page.
|
3187 |
Â
*/
|
3188 |
Â
function bp_get_activity_delete_url() {
|
3189 |
Â
global $activities_template;
|
3229 |
Â
* @uses bp_is_user_inactive()
|
3230 |
Â
* @uses bp_core_is_user_deleted()
|
3231 |
Â
* @uses bp_get_user_meta()
|
3232 |
+
* @uses apply_filters() To call the 'bp_get_activity_latest_update_excerpt' hook.
|
3233 |
Â
* @uses bp_create_excerpt()
|
3234 |
Â
* @uses bp_get_root_domain()
|
3235 |
Â
* @uses bp_get_activity_root_slug()
|
3236 |
+
* @uses apply_filters() To call the 'bp_get_activity_latest_update' hook.
|
3237 |
Â
*
|
3238 |
Â
* @param int $user_id If empty, will fall back on displayed user.
|
3239 |
+
*
|
3240 |
Â
* @return string|bool $latest_update The activity latest update link.
|
3241 |
+
* False on failure.
|
3242 |
Â
*/
|
3243 |
Â
function bp_get_activity_latest_update( $user_id = 0 ) {
|
3244 |
Â
|
3245 |
+
if ( empty( $user_id ) ) {
|
3246 |
Â
$user_id = bp_displayed_user_id();
|
3247 |
+
}
|
3248 |
Â
|
3249 |
+
if ( bp_is_user_inactive( $user_id ) ) {
|
3250 |
Â
return false;
|
3251 |
+
}
|
3252 |
Â
|
3253 |
+
if ( !$update = bp_get_user_meta( $user_id, 'bp_latest_update', true ) ) {
|
3254 |
Â
return false;
|
3255 |
+
}
|
3256 |
Â
|
3257 |
Â
/**
|
3258 |
Â
* Filters the latest update excerpt.
|
3288 |
Â
* @see bp_get_activity_filter_links() for description of parameters.
|
3289 |
Â
* @uses bp_get_activity_filter_links()
|
3290 |
Â
*
|
3291 |
+
* @param array|bool $args See {@link bp_get_activity_filter_links()} for description.
|
3292 |
Â
*/
|
3293 |
Â
function bp_activity_filter_links( $args = false ) {
|
3294 |
Â
echo bp_get_activity_filter_links( $args );
|
3307 |
Â
* @uses apply_filters() To call the 'bp_get_activity_filter_link_href' hook.
|
3308 |
Â
* @uses apply_filters() To call the 'bp_get_activity_filter_links' hook.
|
3309 |
Â
*
|
3310 |
+
* @param array|bool $args {
|
3311 |
Â
* @type string $style The type of markup to use for the links.
|
3312 |
+
* 'list', 'paragraph', or 'span'. Default: 'list'.
|
3313 |
Â
* }
|
3314 |
Â
* @return string|bool $component_links The activity filter links.
|
3315 |
Â
* False on failure.
|
3316 |
Â
*/
|
3317 |
Â
function bp_get_activity_filter_links( $args = false ) {
|
3318 |
Â
|
3319 |
+
$r = wp_parse_args( $args, array(
|
3320 |
Â
'style' => 'list'
|
3321 |
+
) );
|
Â
|
|
Â
|
|
Â
|
|
3322 |
Â
|
3323 |
Â
// Define local variable
|
3324 |
Â
$component_links = array();
|
3326 |
Â
// Fetch the names of components that have activity recorded in the DB
|
3327 |
Â
$components = BP_Activity_Activity::get_recorded_components();
|
3328 |
Â
|
3329 |
+
if ( empty( $components ) ) {
|
3330 |
Â
return false;
|
3331 |
+
}
|
3332 |
Â
|
3333 |
Â
foreach ( (array) $components as $component ) {
|
3334 |
Â
|
3335 |
Â
// Skip the activity comment filter
|
3336 |
+
if ( 'activity' == $component ) {
|
3337 |
Â
continue;
|
3338 |
+
}
|
3339 |
Â
|
3340 |
+
if ( isset( $_GET['afilter'] ) && $component == $_GET['afilter'] ) {
|
3341 |
Â
$selected = ' class="selected"';
|
3342 |
+
} else {
|
3343 |
+
$selected = '';
|
3344 |
+
}
|
3345 |
Â
|
3346 |
Â
$component = esc_attr( $component );
|
3347 |
Â
|
3348 |
+
switch ( $r['style'] ) {
|
3349 |
Â
case 'list':
|
3350 |
Â
$tag = 'li';
|
3351 |
Â
$before = '<li id="afilter-' . $component . '"' . $selected . '>';
|
3371 |
Â
*
|
3372 |
Â
* @since BuddyPress (1.1.0)
|
3373 |
Â
*
|
3374 |
+
* @param string $link The URL for the current component.
|
3375 |
Â
* @param string $component The current component getting links constructed for.
|
3376 |
Â
*/
|
3377 |
Â
$link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component );
|
3381 |
Â
|
3382 |
Â
$link = remove_query_arg( 'afilter' , $link );
|
3383 |
Â
|
3384 |
+
if ( isset( $_GET['afilter'] ) ) {
|
3385 |
Â
$component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . esc_url( $link ) . '">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
|
3386 |
+
}
|
3387 |
Â
|
3388 |
Â
/**
|
3389 |
Â
* Filters all of the constructed filter links.
|
3448 |
Â
*
|
3449 |
Â
* @since BuddyPress (1.5.0)
|
3450 |
Â
*
|
3451 |
+
* @param bool $can_comment Status on if activity can be commented on.
|
3452 |
Â
* @param string $activity_action Current activity action being checked on.
|
3453 |
Â
*/
|
3454 |
Â
return apply_filters( 'bp_activity_can_comment', $can_comment, $activity_action );
|
3459 |
Â
*
|
3460 |
Â
* @since BuddyPress (1.5.0)
|
3461 |
Â
*
|
3462 |
+
* @param bool|object $comment Activity comment.
|
3463 |
+
* @return bool $can_comment True if comment can receive comments,
|
3464 |
+
* otherwise false.
|
3465 |
Â
*/
|
3466 |
+
function bp_activity_can_comment_reply( $comment = false ) {
|
3467 |
Â
|
3468 |
Â
// Assume activity can be commented on
|
3469 |
Â
$can_comment = true;
|
3496 |
Â
* @since BuddyPress (1.5.0)
|
3497 |
Â
*
|
3498 |
Â
* @param bool $can_comment Status on if activity reply can be commented on.
|
3499 |
+
* @param string $comment Current comment being checked on.
|
3500 |
Â
*/
|
3501 |
Â
return (bool) apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
|
3502 |
Â
}
|
3544 |
Â
* @since BuddyPress (1.2.0)
|
3545 |
Â
*
|
3546 |
Â
* @uses bp_activity_total_favorites_for_user()
|
3547 |
+
* @uses apply_filters() To call the 'bp_get_total_favorite_count_for_user' hook.
|
3548 |
Â
*
|
3549 |
Â
* @param int $user_id ID of user being queried. Default: displayed user ID.
|
3550 |
+
*
|
3551 |
Â
* @return int The total favorite count for the specified user.
|
3552 |
Â
*/
|
3553 |
Â
function bp_get_total_favorite_count_for_user( $user_id = 0 ) {
|
3554 |
+
$retval = false;
|
3555 |
Â
|
3556 |
+
if ( bp_activity_can_favorite() ) {
|
3557 |
+
// Default to displayed user if none is passed
|
3558 |
+
$user_id = empty( $user_id )
|
3559 |
+
? bp_displayed_user_id()
|
3560 |
+
: $user_id;
|
3561 |
Â
|
3562 |
+
// Get user meta if user ID exists
|
3563 |
+
if ( ! empty( $user_id ) ) {
|
3564 |
+
$retval = bp_activity_total_favorites_for_user( $user_id );
|
3565 |
+
}
|
3566 |
+
}
|
3567 |
Â
|
3568 |
Â
/**
|
3569 |
Â
* Filters the total favorite count for a user.
|
3599 |
Â
* @uses apply_filters() To call the 'bp_get_total_mention_count_for_user' hook.
|
3600 |
Â
*
|
3601 |
Â
* @param int $user_id ID of user being queried. Default: displayed user ID.
|
3602 |
+
*
|
3603 |
Â
* @return int The total mention count for the specified user.
|
3604 |
Â
*/
|
3605 |
Â
function bp_get_total_mention_count_for_user( $user_id = 0 ) {
|
3645 |
Â
* @uses bp_is_user()
|
3646 |
Â
* @uses wp_nonce_url()
|
3647 |
Â
* @uses bp_get_activity_directory_permalink()
|
3648 |
+
* @uses apply_filters() To call the 'bp_get_send_public_message_link' hook.
|
3649 |
Â
*
|
3650 |
Â
* @return string The public message link for the displayed user.
|
3651 |
Â
*/
|
3677 |
Â
*
|
3678 |
Â
* @param array $activity Array of activities generated from {@link bp_activity_get()}.
|
3679 |
Â
* @param array $activity_ids Used for recursion purposes in this function.
|
3680 |
+
*
|
3681 |
Â
* @return array
|
3682 |
Â
*/
|
3683 |
Â
function bp_activity_recurse_comments_activity_ids( $activity = array(), $activity_ids = array() ) {
|
3706 |
Â
* @see bp_get_mentioned_user_display_name() for description of parameters.
|
3707 |
Â
* @uses bp_get_mentioned_user_display_name()
|
3708 |
Â
*
|
3709 |
+
* @param int|string|bool $user_id_or_username See {@link bp_get_mentioned_user_display_name()}.
|
3710 |
Â
*/
|
3711 |
Â
function bp_mentioned_user_display_name( $user_id_or_username = false ) {
|
3712 |
Â
echo bp_get_mentioned_user_display_name( $user_id_or_username );
|
3713 |
Â
}
|
3714 |
Â
|
3715 |
Â
/**
|
3716 |
+
* Returns the mentioned user display name.
|
3717 |
Â
*
|
3718 |
Â
* @since BuddyPress (1.2.0)
|
3719 |
Â
*
|
3720 |
Â
* @uses bp_core_get_user_displayname()
|
3721 |
Â
* @uses apply_filters() To call the 'bp_get_mentioned_user_display_name' hook.
|
3722 |
Â
*
|
3723 |
+
* @param int|string|bool User ID or username.
|
3724 |
+
*
|
3725 |
Â
* @return string The mentioned user's display name.
|
3726 |
Â
*/
|
3727 |
Â
function bp_get_mentioned_user_display_name( $user_id_or_username = false ) {
|
3739 |
Â
*
|
3740 |
Â
* @since BuddyPress (1.2.0)
|
3741 |
Â
*
|
3742 |
+
* @param string $name Display name for the mentioned user.
|
3743 |
Â
* @param int|string $user_id_or_username User ID or username use for query.
|
3744 |
Â
*/
|
3745 |
Â
return apply_filters( 'bp_get_mentioned_user_display_name', $name, $user_id_or_username );
|
3753 |
Â
* @see bp_get_send_public_message_button() for description of parameters.
|
3754 |
Â
* @uses bp_get_send_public_message_button()
|
3755 |
Â
*
|
3756 |
+
* @param array|string $args See {@link bp_get_send_public_message_button()}.
|
3757 |
Â
*/
|
3758 |
Â
function bp_send_public_message_button( $args = '' ) {
|
3759 |
Â
echo bp_get_send_public_message_button( $args );
|
3769 |
Â
* @uses bp_get_button()
|
3770 |
Â
* @uses apply_filters() To call the 'bp_get_send_public_message_button' hook.
|
3771 |
Â
*
|
3772 |
+
* @param array|string $args {
|
3773 |
Â
* All arguments are optional. See {@link BP_Button} for complete
|
3774 |
Â
* descriptions.
|
3775 |
+
* @type string $id Default: 'public_message'.
|
3776 |
+
* @type string $component Default: 'activity'.
|
3777 |
+
* @type bool $must_be_logged_in Default: true.
|
3778 |
+
* @type bool $block_self Default: true.
|
3779 |
+
* @type string $wrapper_id Default: 'post-mention'.
|
3780 |
+
* @type string $link_href Default: the public message link for
|
3781 |
+
* the current member in the loop.
|
3782 |
+
* @type string $link_title Default: 'Send a public message on your
|
3783 |
+
* activity stream.'.
|
3784 |
+
* @type string $link_text Default: 'Public Message'.
|
3785 |
+
* @type string $link_class Default: 'activity-button mention'.
|
3786 |
Â
* }
|
3787 |
Â
* @return string The button for sending a public message.
|
3788 |
Â
*/
|
3910 |
Â
* @since BuddyPress (1.7.0)
|
3911 |
Â
*
|
3912 |
Â
* @param string $retval HTML markup for the list of avatars.
|
3913 |
+
* @param array $r Array of arguments used for each avatar.
|
3914 |
Â
* @param array $output Array of each avatar found, before imploded into single string.
|
3915 |
Â
*/
|
3916 |
Â
echo apply_filters( 'bp_activity_comments_user_avatars', $retval, $r, $output );
|
3946 |
Â
* @since BuddyPress (1.7.0)
|
3947 |
Â
*
|
3948 |
Â
* @param array $comments Array of {@link BP_Activity_Activity} items.
|
3949 |
+
*
|
3950 |
Â
* @return array Array of user IDs.
|
3951 |
Â
*/
|
3952 |
Â
function bp_activity_recurse_comments_user_ids( array $comments = array() ) {
|
4017 |
Â
*
|
4018 |
Â
* @since BuddyPress (1.7.0)
|
4019 |
Â
*
|
4020 |
+
* @param string $output Optional. Either 'select' or 'checkbox'. Default: 'select'.
|
4021 |
+
* @param array|string $args {
|
4022 |
Â
* Optional extra arguments.
|
4023 |
+
* @type string $checkbox_name When returning checkboxes, sets the 'name'
|
4024 |
+
* attribute.
|
4025 |
+
* @type array|string $selected A list of types that should be checked/
|
4026 |
+
* selected.
|
4027 |
Â
* }
|
4028 |
Â
*/
|
4029 |
Â
function bp_activity_types_list( $output = 'select', $args = '' ) {
|
4061 |
Â
*
|
4062 |
Â
* @since BuddyPress (1.7.0)
|
4063 |
Â
*
|
4064 |
+
* @param array $args Array of arguments passed into function.
|
4065 |
+
* @param string $type Activity type being rendered in the output.
|
4066 |
Â
* @param string $description Description of the activity type being rendered.
|
4067 |
Â
*/
|
4068 |
Â
do_action( 'bp_activity_types_list_' . $output, $args, $type, $description );
|
4293 |
Â
}
|
4294 |
Â
|
4295 |
Â
/**
|
4296 |
+
* Output the activity feed item link.
|
4297 |
Â
*
|
4298 |
Â
* @since BuddyPress (1.0.0)
|
4299 |
Â
*
|
4304 |
Â
}
|
4305 |
Â
|
4306 |
Â
/**
|
4307 |
+
* Return the activity feed item link.
|
4308 |
Â
*
|
4309 |
Â
* @since BuddyPress (1.0.0)
|
4310 |
Â
*
|
4437 |
Â
* @since BuddyPress (2.1.0)
|
4438 |
Â
*
|
4439 |
Â
* @param string $context The current context. 'activity', 'member',
|
4440 |
+
* 'member_groups', 'group'.
|
4441 |
Â
* @uses bp_get_activity_show_filters()
|
4442 |
Â
*/
|
4443 |
Â
function bp_activity_show_filters( $context = '' ) {
|
4449 |
Â
* @since BuddyPress (2.1.0)
|
4450 |
Â
*
|
4451 |
Â
* @param string $context The current context. 'activity', 'member',
|
4452 |
+
* 'member_groups', 'group'.
|
4453 |
+
*
|
4454 |
Â
* @return string HTML for <option> values.
|
4455 |
Â
*/
|
4456 |
Â
function bp_get_activity_show_filters( $context = '' ) {
|
4500 |
Â
*
|
4501 |
Â
* @since BuddyPress (2.2.0)
|
4502 |
Â
*
|
4503 |
+
* @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
|
4504 |
Â
* @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
|
4505 |
Â
*/
|
4506 |
Â
$filters = apply_filters( 'bp_get_activity_show_filters_options', $filters, $context );
|
4519 |
Â
*
|
4520 |
Â
* @since BuddyPress (2.1.0)
|
4521 |
Â
*
|
4522 |
+
* @param string $output HTML output for the activity filter dropdown.
|
4523 |
Â
* @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
|
4524 |
Â
* @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
|
4525 |
Â
*/
|
bp-activity/classes/class-bp-activity-activity.php
ADDED
@@ -0,0 +1,1800 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* BuddyPress Activity Classes
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
* @subpackage Activity
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Exit if accessed directly
|
10 |
+
defined( 'ABSPATH' ) || exit;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Database interaction class for the BuddyPress activity component.
|
14 |
+
*
|
15 |
+
* Instance methods are available for creating/editing an activity,
|
16 |
+
* static methods for querying activities.
|
17 |
+
*
|
18 |
+
* @since BuddyPress (1.0.0)
|
19 |
+
*/
|
20 |
+
class BP_Activity_Activity {
|
21 |
+
|
22 |
+
/** Properties ************************************************************/
|
23 |
+
|
24 |
+
/**
|
25 |
+
* ID of the activity item.
|
26 |
+
*
|
27 |
+
* @var int
|
28 |
+
*/
|
29 |
+
var $id;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* ID of the associated item.
|
33 |
+
*
|
34 |
+
* @var int
|
35 |
+
*/
|
36 |
+
var $item_id;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* ID of the associated secondary item.
|
40 |
+
*
|
41 |
+
* @var int
|
42 |
+
*/
|
43 |
+
var $secondary_item_id;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* ID of user associated with the activity item.
|
47 |
+
*
|
48 |
+
* @var int
|
49 |
+
*/
|
50 |
+
var $user_id;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* The primary URL for the activity in RSS feeds.
|
54 |
+
*
|
55 |
+
* @var string
|
56 |
+
*/
|
57 |
+
var $primary_link;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* BuddyPress component the activity item relates to.
|
61 |
+
*
|
62 |
+
* @var string
|
63 |
+
*/
|
64 |
+
var $component;
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Activity type, eg 'new_blog_post'.
|
68 |
+
*
|
69 |
+
* @var string
|
70 |
+
*/
|
71 |
+
var $type;
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Description of the activity, eg 'Alex updated his profile.'.
|
75 |
+
*
|
76 |
+
* @var string
|
77 |
+
*/
|
78 |
+
var $action;
|
79 |
+
|
80 |
+
/**
|
81 |
+
* The content of the activity item.
|
82 |
+
*
|
83 |
+
* @var string
|
84 |
+
*/
|
85 |
+
var $content;
|
86 |
+
|
87 |
+
/**
|
88 |
+
* The date the activity item was recorded, in 'Y-m-d h:i:s' format.
|
89 |
+
*
|
90 |
+
* @var string
|
91 |
+
*/
|
92 |
+
var $date_recorded;
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Whether the item should be hidden in sitewide streams.
|
96 |
+
*
|
97 |
+
* @var int
|
98 |
+
*/
|
99 |
+
var $hide_sitewide = false;
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Node boundary start for activity or activity comment.
|
103 |
+
*
|
104 |
+
* @var int
|
105 |
+
*/
|
106 |
+
var $mptt_left;
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Node boundary end for activity or activity comment.
|
110 |
+
*
|
111 |
+
* @var int
|
112 |
+
*/
|
113 |
+
var $mptt_right;
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Whether this item is marked as spam.
|
117 |
+
*
|
118 |
+
* @var int
|
119 |
+
*/
|
120 |
+
var $is_spam;
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Constructor method.
|
124 |
+
*
|
125 |
+
* @param int|bool $id Optional. The ID of a specific activity item.
|
126 |
+
*/
|
127 |
+
public function __construct( $id = false ) {
|
128 |
+
if ( !empty( $id ) ) {
|
129 |
+
$this->id = $id;
|
130 |
+
$this->populate();
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Populate the object with data about the specific activity item.
|
136 |
+
*/
|
137 |
+
public function populate() {
|
138 |
+
global $wpdb;
|
139 |
+
|
140 |
+
$row = wp_cache_get( $this->id, 'bp_activity' );
|
141 |
+
|
142 |
+
if ( false === $row ) {
|
143 |
+
$bp = buddypress();
|
144 |
+
$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) );
|
145 |
+
|
146 |
+
wp_cache_set( $this->id, $row, 'bp_activity' );
|
147 |
+
}
|
148 |
+
|
149 |
+
if ( ! empty( $row ) ) {
|
150 |
+
$this->id = (int) $row->id;
|
151 |
+
$this->item_id = (int) $row->item_id;
|
152 |
+
$this->secondary_item_id = (int) $row->secondary_item_id;
|
153 |
+
$this->user_id = (int) $row->user_id;
|
154 |
+
$this->primary_link = $row->primary_link;
|
155 |
+
$this->component = $row->component;
|
156 |
+
$this->type = $row->type;
|
157 |
+
$this->action = $row->action;
|
158 |
+
$this->content = $row->content;
|
159 |
+
$this->date_recorded = $row->date_recorded;
|
160 |
+
$this->hide_sitewide = $row->hide_sitewide;
|
161 |
+
$this->mptt_left = (int) $row->mptt_left;
|
162 |
+
$this->mptt_right = (int) $row->mptt_right;
|
163 |
+
$this->is_spam = $row->is_spam;
|
164 |
+
}
|
165 |
+
|
166 |
+
// Generate dynamic 'action' when possible
|
167 |
+
$action = bp_activity_generate_action_string( $this );
|
168 |
+
if ( false !== $action ) {
|
169 |
+
$this->action = $action;
|
170 |
+
|
171 |
+
// If no callback is available, use the literal string from
|
172 |
+
// the database row
|
173 |
+
} elseif ( ! empty( $row->action ) ) {
|
174 |
+
$this->action = $row->action;
|
175 |
+
|
176 |
+
// Provide a fallback to avoid PHP notices
|
177 |
+
} else {
|
178 |
+
$this->action = '';
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Save the activity item to the database.
|
184 |
+
*
|
185 |
+
* @return bool True on success.
|
186 |
+
*/
|
187 |
+
public function save() {
|
188 |
+
global $wpdb;
|
189 |
+
|
190 |
+
$bp = buddypress();
|
191 |
+
|
192 |
+
$this->id = apply_filters_ref_array( 'bp_activity_id_before_save', array( $this->id, &$this ) );
|
193 |
+
$this->item_id = apply_filters_ref_array( 'bp_activity_item_id_before_save', array( $this->item_id, &$this ) );
|
194 |
+
$this->secondary_item_id = apply_filters_ref_array( 'bp_activity_secondary_item_id_before_save', array( $this->secondary_item_id, &$this ) );
|
195 |
+
$this->user_id = apply_filters_ref_array( 'bp_activity_user_id_before_save', array( $this->user_id, &$this ) );
|
196 |
+
$this->primary_link = apply_filters_ref_array( 'bp_activity_primary_link_before_save', array( $this->primary_link, &$this ) );
|
197 |
+
$this->component = apply_filters_ref_array( 'bp_activity_component_before_save', array( $this->component, &$this ) );
|
198 |
+
$this->type = apply_filters_ref_array( 'bp_activity_type_before_save', array( $this->type, &$this ) );
|
199 |
+
$this->action = apply_filters_ref_array( 'bp_activity_action_before_save', array( $this->action, &$this ) );
|
200 |
+
$this->content = apply_filters_ref_array( 'bp_activity_content_before_save', array( $this->content, &$this ) );
|
201 |
+
$this->date_recorded = apply_filters_ref_array( 'bp_activity_date_recorded_before_save', array( $this->date_recorded, &$this ) );
|
202 |
+
$this->hide_sitewide = apply_filters_ref_array( 'bp_activity_hide_sitewide_before_save', array( $this->hide_sitewide, &$this ) );
|
203 |
+
$this->mptt_left = apply_filters_ref_array( 'bp_activity_mptt_left_before_save', array( $this->mptt_left, &$this ) );
|
204 |
+
$this->mptt_right = apply_filters_ref_array( 'bp_activity_mptt_right_before_save', array( $this->mptt_right, &$this ) );
|
205 |
+
$this->is_spam = apply_filters_ref_array( 'bp_activity_is_spam_before_save', array( $this->is_spam, &$this ) );
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Fires before the current activity item gets saved.
|
209 |
+
*
|
210 |
+
* Please use this hook to filter the properties above. Each part will be passed in.
|
211 |
+
*
|
212 |
+
* @since BuddyPress (1.0.0)
|
213 |
+
*
|
214 |
+
* @param BP_Activity_Activity $this Current instance of the activity item being saved. Passed by reference.
|
215 |
+
*/
|
216 |
+
do_action_ref_array( 'bp_activity_before_save', array( &$this ) );
|
217 |
+
|
218 |
+
if ( empty( $this->component ) || empty( $this->type ) ) {
|
219 |
+
return false;
|
220 |
+
}
|
221 |
+
|
222 |
+
if ( empty( $this->primary_link ) ) {
|
223 |
+
$this->primary_link = bp_loggedin_user_domain();
|
224 |
+
}
|
225 |
+
|
226 |
+
// If we have an existing ID, update the activity item, otherwise insert it.
|
227 |
+
if ( ! empty( $this->id ) ) {
|
228 |
+
$q = $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET user_id = %d, component = %s, type = %s, action = %s, content = %s, primary_link = %s, date_recorded = %s, item_id = %d, secondary_item_id = %d, hide_sitewide = %d, is_spam = %d WHERE id = %d", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam, $this->id );
|
229 |
+
} else {
|
230 |
+
$q = $wpdb->prepare( "INSERT INTO {$bp->activity->table_name} ( user_id, component, type, action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide, is_spam ) VALUES ( %d, %s, %s, %s, %s, %s, %s, %d, %d, %d, %d )", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam );
|
231 |
+
}
|
232 |
+
|
233 |
+
if ( false === $wpdb->query( $q ) ) {
|
234 |
+
return false;
|
235 |
+
}
|
236 |
+
|
237 |
+
// If this is a new activity item, set the $id property
|
238 |
+
if ( empty( $this->id ) ) {
|
239 |
+
$this->id = $wpdb->insert_id;
|
240 |
+
|
241 |
+
// If an existing activity item, prevent any changes to the content generating new @mention notifications.
|
242 |
+
} else {
|
243 |
+
add_filter( 'bp_activity_at_name_do_notifications', '__return_false' );
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Fires after an activity item has been saved to the database.
|
248 |
+
*
|
249 |
+
* @since BuddyPress (1.0.0)
|
250 |
+
*
|
251 |
+
* @param BP_Activity_Activity $this Current instance of activity item being saved. Passed by reference.
|
252 |
+
*/
|
253 |
+
do_action_ref_array( 'bp_activity_after_save', array( &$this ) );
|
254 |
+
|
255 |
+
return true;
|
256 |
+
}
|
257 |
+
|
258 |
+
/** Static Methods ***************************************************/
|
259 |
+
|
260 |
+
/**
|
261 |
+
* Get activity items, as specified by parameters.
|
262 |
+
*
|
263 |
+
* @see BP_Activity_Activity::get_filter_sql() for a description of the
|
264 |
+
* 'filter' parameter.
|
265 |
+
* @see WP_Meta_Query::queries for a description of the 'meta_query'
|
266 |
+
* parameter format.
|
267 |
+
*
|
268 |
+
* @param array $args {
|
269 |
+
* An array of arguments. All items are optional.
|
270 |
+
*
|
271 |
+
* @type int $page Which page of results to fetch. Using page=1 without per_page will result
|
272 |
+
* in no pagination. Default: 1.
|
273 |
+
* @type int|bool $per_page Number of results per page. Default: 25.
|
274 |
+
* @type int|bool $max Maximum number of results to return. Default: false (unlimited).
|
275 |
+
* @type string $sort ASC or DESC. Default: 'DESC'.
|
276 |
+
* @type array $exclude Array of activity IDs to exclude. Default: false.
|
277 |
+
* @type array $in Array of ids to limit query by (IN). Default: false.
|
278 |
+
* @type array $meta_query Array of meta_query conditions. See WP_Meta_Query::queries.
|
279 |
+
* @type array $date_query Array of date_query conditions. See first parameter of
|
280 |
+
* WP_Date_Query::__construct().
|
281 |
+
* @type array $filter_query Array of advanced query conditions. See BP_Activity_Query::__construct().
|
282 |
+
* @type string|array $scope Pre-determined set of activity arguments.
|
283 |
+
* @type array $filter See BP_Activity_Activity::get_filter_sql().
|
284 |
+
* @type string $search_terms Limit results by a search term. Default: false.
|
285 |
+
* @type bool $display_comments Whether to include activity comments. Default: false.
|
286 |
+
* @type bool $show_hidden Whether to show items marked hide_sitewide. Default: false.
|
287 |
+
* @type string $spam Spam status. Default: 'ham_only'.
|
288 |
+
* @type bool $update_meta_cache Whether to pre-fetch metadata for queried activity items. Default: true.
|
289 |
+
* @type string|bool $count_total If true, an additional DB query is run to count the total activity items
|
290 |
+
* for the query. Default: false.
|
291 |
+
* }
|
292 |
+
* @return array The array returned has two keys:
|
293 |
+
* - 'total' is the count of located activities
|
294 |
+
* - 'activities' is an array of the located activities
|
295 |
+
*/
|
296 |
+
public static function get( $args = array() ) {
|
297 |
+
global $wpdb;
|
298 |
+
|
299 |
+
// Backward compatibility with old method of passing arguments
|
300 |
+
if ( !is_array( $args ) || func_num_args() > 1 ) {
|
301 |
+
_deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
|
302 |
+
|
303 |
+
$old_args_keys = array(
|
304 |
+
0 => 'max',
|
305 |
+
1 => 'page',
|
306 |
+
2 => 'per_page',
|
307 |
+
3 => 'sort',
|
308 |
+
4 => 'search_terms',
|
309 |
+
5 => 'filter',
|
310 |
+
6 => 'display_comments',
|
311 |
+
7 => 'show_hidden',
|
312 |
+
8 => 'exclude',
|
313 |
+
9 => 'in',
|
314 |
+
10 => 'spam'
|
315 |
+
);
|
316 |
+
|
317 |
+
$func_args = func_get_args();
|
318 |
+
$args = bp_core_parse_args_array( $old_args_keys, $func_args );
|
319 |
+
}
|
320 |
+
|
321 |
+
$bp = buddypress();
|
322 |
+
$r = wp_parse_args( $args, array(
|
323 |
+
'page' => 1, // The current page
|
324 |
+
'per_page' => 25, // Activity items per page
|
325 |
+
'max' => false, // Max number of items to return
|
326 |
+
'sort' => 'DESC', // ASC or DESC
|
327 |
+
'exclude' => false, // Array of ids to exclude
|
328 |
+
'in' => false, // Array of ids to limit query by (IN)
|
329 |
+
'meta_query' => false, // Filter by activitymeta
|
330 |
+
'date_query' => false, // Filter by date
|
331 |
+
'filter_query' => false, // Advanced filtering - see BP_Activity_Query
|
332 |
+
'filter' => false, // See self::get_filter_sql()
|
333 |
+
'scope' => false, // Preset activity arguments
|
334 |
+
'search_terms' => false, // Terms to search by
|
335 |
+
'display_comments' => false, // Whether to include activity comments
|
336 |
+
'show_hidden' => false, // Show items marked hide_sitewide
|
337 |
+
'spam' => 'ham_only', // Spam status
|
338 |
+
'update_meta_cache' => true,
|
339 |
+
'count_total' => false,
|
340 |
+
) );
|
341 |
+
|
342 |
+
// Select conditions
|
343 |
+
$select_sql = "SELECT DISTINCT a.id";
|
344 |
+
|
345 |
+
$from_sql = " FROM {$bp->activity->table_name} a";
|
346 |
+
|
347 |
+
$join_sql = '';
|
348 |
+
|
349 |
+
// Where conditions
|
350 |
+
$where_conditions = array();
|
351 |
+
|
352 |
+
// Excluded types
|
353 |
+
$excluded_types = array();
|
354 |
+
|
355 |
+
// Scope takes precedence
|
356 |
+
if ( ! empty( $r['scope'] ) ) {
|
357 |
+
$scope_query = self::get_scope_query_sql( $r['scope'], $r );
|
358 |
+
|
359 |
+
// Add our SQL conditions if matches were found
|
360 |
+
if ( ! empty( $scope_query['sql'] ) ) {
|
361 |
+
$where_conditions['scope_query_sql'] = $scope_query['sql'];
|
362 |
+
}
|
363 |
+
|
364 |
+
// override some arguments if needed
|
365 |
+
if ( ! empty( $scope_query['override'] ) ) {
|
366 |
+
$r = self::array_replace_recursive( $r, $scope_query['override'] );
|
367 |
+
}
|
368 |
+
|
369 |
+
// Advanced filtering
|
370 |
+
} elseif ( ! empty( $r['filter_query'] ) ) {
|
371 |
+
$filter_query = new BP_Activity_Query( $r['filter_query'] );
|
372 |
+
$sql = $filter_query->get_sql();
|
373 |
+
if ( ! empty( $sql ) ) {
|
374 |
+
$where_conditions['filter_query_sql'] = $sql;
|
375 |
+
}
|
376 |
+
}
|
377 |
+
|
378 |
+
// Regular filtering
|
379 |
+
if ( $r['filter'] && $filter_sql = BP_Activity_Activity::get_filter_sql( $r['filter'] ) ) {
|
380 |
+
$where_conditions['filter_sql'] = $filter_sql;
|
381 |
+
}
|
382 |
+
|
383 |
+
// Spam
|
384 |
+
if ( 'ham_only' == $r['spam'] ) {
|
385 |
+
$where_conditions['spam_sql'] = 'a.is_spam = 0';
|
386 |
+
} elseif ( 'spam_only' == $r['spam'] ) {
|
387 |
+
$where_conditions['spam_sql'] = 'a.is_spam = 1';
|
388 |
+
}
|
389 |
+
|
390 |
+
// Searching
|
391 |
+
if ( $r['search_terms'] ) {
|
392 |
+
$search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
|
393 |
+
$where_conditions['search_sql'] = $wpdb->prepare( 'a.content LIKE %s', $search_terms_like );
|
394 |
+
}
|
395 |
+
|
396 |
+
// Sorting
|
397 |
+
$sort = $r['sort'];
|
398 |
+
if ( $sort != 'ASC' && $sort != 'DESC' ) {
|
399 |
+
$sort = 'DESC';
|
400 |
+
}
|
401 |
+
|
402 |
+
// Hide Hidden Items?
|
403 |
+
if ( ! $r['show_hidden'] ) {
|
404 |
+
$where_conditions['hidden_sql'] = "a.hide_sitewide = 0";
|
405 |
+
}
|
406 |
+
|
407 |
+
// Exclude specified items
|
408 |
+
if ( ! empty( $r['exclude'] ) ) {
|
409 |
+
$exclude = implode( ',', wp_parse_id_list( $r['exclude'] ) );
|
410 |
+
$where_conditions['exclude'] = "a.id NOT IN ({$exclude})";
|
411 |
+
}
|
412 |
+
|
413 |
+
// The specific ids to which you want to limit the query
|
414 |
+
if ( ! empty( $r['in'] ) ) {
|
415 |
+
$in = implode( ',', wp_parse_id_list( $r['in'] ) );
|
416 |
+
$where_conditions['in'] = "a.id IN ({$in})";
|
417 |
+
}
|
418 |
+
|
419 |
+
// Process meta_query into SQL
|
420 |
+
$meta_query_sql = self::get_meta_query_sql( $r['meta_query'] );
|
421 |
+
|
422 |
+
if ( ! empty( $meta_query_sql['join'] ) ) {
|
423 |
+
$join_sql .= $meta_query_sql['join'];
|
424 |
+
}
|
425 |
+
|
426 |
+
if ( ! empty( $meta_query_sql['where'] ) ) {
|
427 |
+
$where_conditions[] = $meta_query_sql['where'];
|
428 |
+
}
|
429 |
+
|
430 |
+
// Process date_query into SQL
|
431 |
+
$date_query_sql = self::get_date_query_sql( $r['date_query'] );
|
432 |
+
|
433 |
+
if ( ! empty( $date_query_sql ) ) {
|
434 |
+
$where_conditions['date'] = $date_query_sql;
|
435 |
+
}
|
436 |
+
|
437 |
+
// Alter the query based on whether we want to show activity item
|
438 |
+
// comments in the stream like normal comments or threaded below
|
439 |
+
// the activity.
|
440 |
+
if ( false === $r['display_comments'] || 'threaded' === $r['display_comments'] ) {
|
441 |
+
$excluded_types[] = 'activity_comment';
|
442 |
+
}
|
443 |
+
|
444 |
+
// Exclude 'last_activity' items unless the 'action' filter has
|
445 |
+
// been explicitly set
|
446 |
+
if ( empty( $r['filter']['object'] ) ) {
|
447 |
+
$excluded_types[] = 'last_activity';
|
448 |
+
}
|
449 |
+
|
450 |
+
// Build the excluded type sql part
|
451 |
+
if ( ! empty( $excluded_types ) ) {
|
452 |
+
$not_in = "'" . implode( "', '", esc_sql( $excluded_types ) ) . "'";
|
453 |
+
$where_conditions['excluded_types'] = "a.type NOT IN ({$not_in})";
|
454 |
+
}
|
455 |
+
|
456 |
+
/**
|
457 |
+
* Filters the MySQL WHERE conditions for the Activity items get method.
|
458 |
+
*
|
459 |
+
* @since BuddyPress (1.9.0)
|
460 |
+
*
|
461 |
+
* @param array $where_conditions Current conditions for MySQL WHERE statement.
|
462 |
+
* @param array $r Parsed arguments passed into method.
|
463 |
+
* @param string $select_sql Current SELECT MySQL statement at point of execution.
|
464 |
+
* @param string $from_sql Current FROM MySQL statement at point of execution.
|
465 |
+
* @param string $join_sql Current INNER JOIN MySQL statement at point of execution.
|
466 |
+
*/
|
467 |
+
$where_conditions = apply_filters( 'bp_activity_get_where_conditions', $where_conditions, $r, $select_sql, $from_sql, $join_sql );
|
468 |
+
|
469 |
+
// Join the where conditions together
|
470 |
+
$where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
|
471 |
+
|
472 |
+
/**
|
473 |
+
* Filters the preferred order of indexes for activity item.
|
474 |
+
*
|
475 |
+
* @since BuddyPress (1.6.0)
|
476 |
+
*
|
477 |
+
* @param array Array of indexes in preferred order.
|
478 |
+
*/
|
479 |
+
$indexes = apply_filters( 'bp_activity_preferred_index_order', array( 'user_id', 'item_id', 'secondary_item_id', 'date_recorded', 'component', 'type', 'hide_sitewide', 'is_spam' ) );
|
480 |
+
|
481 |
+
foreach( $indexes as $key => $index ) {
|
482 |
+
if ( false !== strpos( $where_sql, $index ) ) {
|
483 |
+
$the_index = $index;
|
484 |
+
break; // Take the first one we find
|
485 |
+
}
|
486 |
+
}
|
487 |
+
|
488 |
+
if ( !empty( $the_index ) ) {
|
489 |
+
$index_hint_sql = "USE INDEX ({$the_index})";
|
490 |
+
} else {
|
491 |
+
$index_hint_sql = '';
|
492 |
+
}
|
493 |
+
|
494 |
+
// Sanitize page and per_page parameters
|
495 |
+
$page = absint( $r['page'] );
|
496 |
+
$per_page = absint( $r['per_page'] );
|
497 |
+
|
498 |
+
$retval = array(
|
499 |
+
'activities' => null,
|
500 |
+
'total' => null,
|
501 |
+
'has_more_items' => null,
|
502 |
+
);
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Filters if BuddyPress should use legacy query structure over current structure for version 2.0+.
|
506 |
+
*
|
507 |
+
* It is not recommended to use the legacy structure, but allowed to if needed.
|
508 |
+
*
|
509 |
+
* @since BuddyPress (2.0.0)
|
510 |
+
*
|
511 |
+
* @param bool $value Whether to use legacy structure or not.
|
512 |
+
* @param BP_Activity_Activity $value Current method being called.
|
513 |
+
* @param array $r Parsed arguments passed into method.
|
514 |
+
*/
|
515 |
+
if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) {
|
516 |
+
|
517 |
+
// Legacy queries joined against the user table
|
518 |
+
$select_sql = "SELECT DISTINCT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
|
519 |
+
$from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
|
520 |
+
|
521 |
+
if ( ! empty( $page ) && ! empty( $per_page ) ) {
|
522 |
+
$pag_sql = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
|
523 |
+
|
524 |
+
/** this filter is documented in bp-activity/bp-activity-classes.php */
|
525 |
+
$activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
|
526 |
+
} else {
|
527 |
+
$pag_sql = '';
|
528 |
+
|
529 |
+
/**
|
530 |
+
* Filters the legacy MySQL query statement so plugins can alter before results are fetched.
|
531 |
+
*
|
532 |
+
* @since BuddyPress (1.5.0)
|
533 |
+
*
|
534 |
+
* @param string $value Concatenated MySQL statement pieces to be query results with for legacy query.
|
535 |
+
* @param string $select_sql Final SELECT MySQL statement portion for legacy query.
|
536 |
+
* @param string $from_sql Final FROM MySQL statement portion for legacy query.
|
537 |
+
* @param string $where_sql Final WHERE MySQL statement portion for legacy query.
|
538 |
+
* @param string $sort Final sort direction for legacy query.
|
539 |
+
*/
|
540 |
+
$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}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
|
541 |
+
}
|
542 |
+
|
543 |
+
} else {
|
544 |
+
// Query first for activity IDs
|
545 |
+
$activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
|
546 |
+
|
547 |
+
if ( ! empty( $per_page ) && ! empty( $page ) ) {
|
548 |
+
// We query for $per_page + 1 items in order to
|
549 |
+
// populate the has_more_items flag
|
550 |
+
$activity_ids_sql .= $wpdb->prepare( " LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page + 1 );
|
551 |
+
}
|
552 |
+
|
553 |
+
/**
|
554 |
+
* Filters the paged activities MySQL statement.
|
555 |
+
*
|
556 |
+
* @since BuddyPress (2.0.0)
|
557 |
+
*
|
558 |
+
* @param string $activity_ids_sql MySQL statement used to query for Activity IDs.
|
559 |
+
* @param array $r Array of arguments passed into method.
|
560 |
+
*/
|
561 |
+
$activity_ids_sql = apply_filters( 'bp_activity_paged_activities_sql', $activity_ids_sql, $r );
|
562 |
+
|
563 |
+
$activity_ids = $wpdb->get_col( $activity_ids_sql );
|
564 |
+
|
565 |
+
$retval['has_more_items'] = ! empty( $per_page ) && count( $activity_ids ) > $per_page;
|
566 |
+
|
567 |
+
// If we've fetched more than the $per_page value, we
|
568 |
+
// can discard the extra now
|
569 |
+
if ( ! empty( $per_page ) && count( $activity_ids ) === $per_page + 1 ) {
|
570 |
+
array_pop( $activity_ids );
|
571 |
+
}
|
572 |
+
|
573 |
+
$activities = self::get_activity_data( $activity_ids );
|
574 |
+
}
|
575 |
+
|
576 |
+
// Get the fullnames of users so we don't have to query in the loop
|
577 |
+
$activities = self::append_user_fullnames( $activities );
|
578 |
+
|
579 |
+
// Get activity meta
|
580 |
+
$activity_ids = array();
|
581 |
+
foreach ( (array) $activities as $activity ) {
|
582 |
+
$activity_ids[] = $activity->id;
|
583 |
+
}
|
584 |
+
|
585 |
+
if ( ! empty( $activity_ids ) && $r['update_meta_cache'] ) {
|
586 |
+
bp_activity_update_meta_cache( $activity_ids );
|
587 |
+
}
|
588 |
+
|
589 |
+
if ( $activities && $r['display_comments'] ) {
|
590 |
+
$activities = BP_Activity_Activity::append_comments( $activities, $r['spam'] );
|
591 |
+
}
|
592 |
+
|
593 |
+
// Pre-fetch data associated with activity users and other objects
|
594 |
+
BP_Activity_Activity::prefetch_object_data( $activities );
|
595 |
+
|
596 |
+
// Generate action strings
|
597 |
+
$activities = BP_Activity_Activity::generate_action_strings( $activities );
|
598 |
+
|
599 |
+
$retval['activities'] = $activities;
|
600 |
+
|
601 |
+
// If $max is set, only return up to the max results
|
602 |
+
if ( ! empty( $r['count_total'] ) ) {
|
603 |
+
|
604 |
+
/**
|
605 |
+
* Filters the total activities MySQL statement.
|
606 |
+
*
|
607 |
+
* @since BuddyPress (1.5.0)
|
608 |
+
*
|
609 |
+
* @param string $value MySQL statement used to query for total activities.
|
610 |
+
* @param string $where_sql MySQL WHERE statement portion.
|
611 |
+
* @param string $sort Sort direction for query.
|
612 |
+
*/
|
613 |
+
$total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort );
|
614 |
+
$total_activities = $wpdb->get_var( $total_activities_sql );
|
615 |
+
|
616 |
+
if ( !empty( $r['max'] ) ) {
|
617 |
+
if ( (int) $total_activities > (int) $r['max'] ) {
|
618 |
+
$total_activities = $r['max'];
|
619 |
+
}
|
620 |
+
}
|
621 |
+
|
622 |
+
$retval['total'] = $total_activities;
|
623 |
+
}
|
624 |
+
|
625 |
+
return $retval;
|
626 |
+
}
|
627 |
+
|
628 |
+
/**
|
629 |
+
* Convert activity IDs to activity objects, as expected in template loop.
|
630 |
+
*
|
631 |
+
* @since BuddyPress (2.0.0)
|
632 |
+
*
|
633 |
+
* @param array $activity_ids Array of activity IDs.
|
634 |
+
*
|
635 |
+
* @return array
|
636 |
+
*/
|
637 |
+
protected static function get_activity_data( $activity_ids = array() ) {
|
638 |
+
global $wpdb;
|
639 |
+
|
640 |
+
// Bail if no activity ID's passed
|
641 |
+
if ( empty( $activity_ids ) ) {
|
642 |
+
return array();
|
643 |
+
}
|
644 |
+
|
645 |
+
// Get BuddyPress
|
646 |
+
$bp = buddypress();
|
647 |
+
|
648 |
+
$activities = array();
|
649 |
+
$uncached_ids = bp_get_non_cached_ids( $activity_ids, 'bp_activity' );
|
650 |
+
|
651 |
+
// Prime caches as necessary
|
652 |
+
if ( ! empty( $uncached_ids ) ) {
|
653 |
+
// Format the activity ID's for use in the query below
|
654 |
+
$uncached_ids_sql = implode( ',', wp_parse_id_list( $uncached_ids ) );
|
655 |
+
|
656 |
+
// Fetch data from activity table, preserving order
|
657 |
+
$queried_adata = $wpdb->get_results( "SELECT * FROM {$bp->activity->table_name} WHERE id IN ({$uncached_ids_sql})");
|
658 |
+
|
659 |
+
// Put that data into the placeholders created earlier,
|
660 |
+
// and add it to the cache
|
661 |
+
foreach ( (array) $queried_adata as $adata ) {
|
662 |
+
wp_cache_set( $adata->id, $adata, 'bp_activity' );
|
663 |
+
}
|
664 |
+
}
|
665 |
+
|
666 |
+
// Now fetch data from the cache
|
667 |
+
foreach ( $activity_ids as $activity_id ) {
|
668 |
+
$activities[] = wp_cache_get( $activity_id, 'bp_activity' );
|
669 |
+
}
|
670 |
+
|
671 |
+
// Then fetch user data
|
672 |
+
$user_query = new BP_User_Query( array(
|
673 |
+
'user_ids' => wp_list_pluck( $activities, 'user_id' ),
|
674 |
+
'populate_extras' => false,
|
675 |
+
) );
|
676 |
+
|
677 |
+
// Associated located user data with activity items
|
678 |
+
foreach ( $activities as $a_index => $a_item ) {
|
679 |
+
$a_user_id = intval( $a_item->user_id );
|
680 |
+
$a_user = isset( $user_query->results[ $a_user_id ] ) ? $user_query->results[ $a_user_id ] : '';
|
681 |
+
|
682 |
+
if ( !empty( $a_user ) ) {
|
683 |
+
$activities[ $a_index ]->user_email = $a_user->user_email;
|
684 |
+
$activities[ $a_index ]->user_nicename = $a_user->user_nicename;
|
685 |
+
$activities[ $a_index ]->user_login = $a_user->user_login;
|
686 |
+
$activities[ $a_index ]->display_name = $a_user->display_name;
|
687 |
+
}
|
688 |
+
}
|
689 |
+
|
690 |
+
return $activities;
|
691 |
+
}
|
692 |
+
|
693 |
+
/**
|
694 |
+
* Append xProfile fullnames to an activity array.
|
695 |
+
*
|
696 |
+
* @since BuddyPress (2.0.0)
|
697 |
+
*
|
698 |
+
* @param array $activities Activities array.
|
699 |
+
*
|
700 |
+
* @return array
|
701 |
+
*/
|
702 |
+
protected static function append_user_fullnames( $activities ) {
|
703 |
+
|
704 |
+
if ( bp_is_active( 'xprofile' ) && ! empty( $activities ) ) {
|
705 |
+
$activity_user_ids = wp_list_pluck( $activities, 'user_id' );
|
706 |
+
|
707 |
+
if ( ! empty( $activity_user_ids ) ) {
|
708 |
+
$fullnames = bp_core_get_user_displaynames( $activity_user_ids );
|
709 |
+
if ( ! empty( $fullnames ) ) {
|
710 |
+
foreach ( (array) $activities as $i => $activity ) {
|
711 |
+
if ( ! empty( $fullnames[ $activity->user_id ] ) ) {
|
712 |
+
$activities[ $i ]->user_fullname = $fullnames[ $activity->user_id ];
|
713 |
+
}
|
714 |
+
}
|
715 |
+
}
|
716 |
+
}
|
717 |
+
}
|
718 |
+
|
719 |
+
return $activities;
|
720 |
+
}
|
721 |
+
|
722 |
+
/**
|
723 |
+
* Pre-fetch data for objects associated with activity items.
|
724 |
+
*
|
725 |
+
* Activity items are associated with users, and often with other
|
726 |
+
* BuddyPress data objects. Here, we pre-fetch data about these
|
727 |
+
* associated objects, so that inline lookups - done primarily when
|
728 |
+
* building action strings - do not result in excess database queries.
|
729 |
+
*
|
730 |
+
* The only object data required for activity component activity types
|
731 |
+
* (activity_update and activity_comment) is related to users, and that
|
732 |
+
* info is fetched separately in BP_Activity_Activity::get_activity_data().
|
733 |
+
* So this method contains nothing but a filter that allows other
|
734 |
+
* components, such as bp-friends and bp-groups, to hook in and prime
|
735 |
+
* their own caches at the beginning of an activity loop.
|
736 |
+
*
|
737 |
+
* @since BuddyPress (2.0.0)
|
738 |
+
*
|
739 |
+
* @param array $activities Array of activities.
|
740 |
+
*
|
741 |
+
* @return array $activities Array of activities.
|
742 |
+
*/
|
743 |
+
protected static function prefetch_object_data( $activities ) {
|
744 |
+
|
745 |
+
/**
|
746 |
+
* Filters inside prefetch_object_data method to aid in pre-fetching object data associated with activity item.
|
747 |
+
*
|
748 |
+
* @since BuddyPress (2.0.0)
|
749 |
+
*
|
750 |
+
* @param array $activities Array of activities.
|
751 |
+
*/
|
752 |
+
return apply_filters( 'bp_activity_prefetch_object_data', $activities );
|
753 |
+
}
|
754 |
+
|
755 |
+
/**
|
756 |
+
* Generate action strings for the activities located in BP_Activity_Activity::get().
|
757 |
+
*
|
758 |
+
* If no string can be dynamically generated for a given item
|
759 |
+
* (typically because the activity type has not been properly
|
760 |
+
* registered), the static 'action' value pulled from the database will
|
761 |
+
* be left in place.
|
762 |
+
*
|
763 |
+
* @since BuddyPress (2.0.0)
|
764 |
+
*
|
765 |
+
* @param array $activities Array of activities.
|
766 |
+
*
|
767 |
+
* @return array
|
768 |
+
*/
|
769 |
+
protected static function generate_action_strings( $activities ) {
|
770 |
+
foreach ( $activities as $key => $activity ) {
|
771 |
+
$generated_action = bp_activity_generate_action_string( $activity );
|
772 |
+
if ( false !== $generated_action ) {
|
773 |
+
$activity->action = $generated_action;
|
774 |
+
}
|
775 |
+
|
776 |
+
$activities[ $key ] = $activity;
|
777 |
+
}
|
778 |
+
|
779 |
+
return $activities;
|
780 |
+
}
|
781 |
+
|
782 |
+
/**
|
783 |
+
* Get the SQL for the 'meta_query' param in BP_Activity_Activity::get().
|
784 |
+
*
|
785 |
+
* We use WP_Meta_Query to do the heavy lifting of parsing the
|
786 |
+
* meta_query array and creating the necessary SQL clauses. However,
|
787 |
+
* since BP_Activity_Activity::get() builds its SQL differently than
|
788 |
+
* WP_Query, we have to alter the return value (stripping the leading
|
789 |
+
* AND keyword from the 'where' clause).
|
790 |
+
*
|
791 |
+
* @since BuddyPress (1.8.0)
|
792 |
+
*
|
793 |
+
* @param array $meta_query An array of meta_query filters. See the
|
794 |
+
* documentation for WP_Meta_Query for details.
|
795 |
+
*
|
796 |
+
* @return array $sql_array 'join' and 'where' clauses.
|
797 |
+
*/
|
798 |
+
public static function get_meta_query_sql( $meta_query = array() ) {
|
799 |
+
global $wpdb;
|
800 |
+
|
801 |
+
$sql_array = array(
|
802 |
+
'join' => '',
|
803 |
+
'where' => '',
|
804 |
+
);
|
805 |
+
|
806 |
+
if ( ! empty( $meta_query ) ) {
|
807 |
+
$activity_meta_query = new WP_Meta_Query( $meta_query );
|
808 |
+
|
809 |
+
// WP_Meta_Query expects the table name at
|
810 |
+
// $wpdb->activitymeta
|
811 |
+
$wpdb->activitymeta = buddypress()->activity->table_name_meta;
|
812 |
+
|
813 |
+
$meta_sql = $activity_meta_query->get_sql( 'activity', 'a', 'id' );
|
814 |
+
|
815 |
+
// Strip the leading AND - BP handles it in get()
|
816 |
+
$sql_array['where'] = preg_replace( '/^\sAND/', '', $meta_sql['where'] );
|
817 |
+
$sql_array['join'] = $meta_sql['join'];
|
818 |
+
}
|
819 |
+
|
820 |
+
return $sql_array;
|
821 |
+
}
|
822 |
+
|
823 |
+
/**
|
824 |
+
* Get the SQL for the 'date_query' param in BP_Activity_Activity::get().
|
825 |
+
*
|
826 |
+
* We use BP_Date_Query, which extends WP_Date_Query, to do the heavy lifting
|
827 |
+
* of parsing the date_query array and creating the necessary SQL clauses.
|
828 |
+
* However, since BP_Activity_Activity::get() builds its SQL differently than
|
829 |
+
* WP_Query, we have to alter the return value (stripping the leading AND
|
830 |
+
* keyword from the query).
|
831 |
+
*
|
832 |
+
* @since BuddyPress (2.1.0)
|
833 |
+
*
|
834 |
+
* @param array $date_query An array of date_query parameters. See the
|
835 |
+
* documentation for the first parameter of WP_Date_Query.
|
836 |
+
*
|
837 |
+
* @return string
|
838 |
+
*/
|
839 |
+
public static function get_date_query_sql( $date_query = array() ) {
|
840 |
+
$sql = '';
|
841 |
+
|
842 |
+
// Date query
|
843 |
+
if ( ! empty( $date_query ) && is_array( $date_query ) && class_exists( 'BP_Date_Query' ) ) {
|
844 |
+
$date_query = new BP_Date_Query( $date_query, 'date_recorded' );
|
845 |
+
$sql = preg_replace( '/^\sAND/', '', $date_query->get_sql() );
|
846 |
+
}
|
847 |
+
|
848 |
+
return $sql;
|
849 |
+
}
|
850 |
+
|
851 |
+
/**
|
852 |
+
* Get the SQL for the 'scope' param in BP_Activity_Activity::get().
|
853 |
+
*
|
854 |
+
* A scope is a predetermined set of activity arguments. This method is used
|
855 |
+
* to grab these activity arguments and override any existing args if needed.
|
856 |
+
*
|
857 |
+
* Can handle multiple scopes.
|
858 |
+
*
|
859 |
+
* @since BuddyPress (2.2.0)
|
860 |
+
*
|
861 |
+
* @param mixed $scope The activity scope. Accepts string or array of scopes.
|
862 |
+
* @param array $r Current activity arguments. Same as those of BP_Activity_Activity::get(),
|
863 |
+
* but merged with defaults.
|
864 |
+
*
|
865 |
+
* @return array 'sql' WHERE SQL string and 'override' activity args.
|
866 |
+
*/
|
867 |
+
public static function get_scope_query_sql( $scope = false, $r = array() ) {
|
868 |
+
|
869 |
+
// Define arrays for future use
|
870 |
+
$query_args = array();
|
871 |
+
$override = array();
|
872 |
+
$retval = array();
|
873 |
+
|
874 |
+
// Check for array of scopes
|
875 |
+
if ( is_array( $scope ) ) {
|
876 |
+
$scopes = $scope;
|
877 |
+
|
878 |
+
// Explode a comma separated string of scopes
|
879 |
+
} elseif ( is_string( $scope ) ) {
|
880 |
+
$scopes = explode( ',', $scope );
|
881 |
+
}
|
882 |
+
|
883 |
+
// Bail if no scope passed
|
884 |
+
if ( empty( $scopes ) ) {
|
885 |
+
return false;
|
886 |
+
}
|
887 |
+
|
888 |
+
// Helper to easily grab the 'user_id'
|
889 |
+
if ( ! empty( $r['filter']['user_id'] ) ) {
|
890 |
+
$r['user_id'] = $r['filter']['user_id'];
|
891 |
+
}
|
892 |
+
|
893 |
+
// parse each scope; yes! we handle multiples!
|
894 |
+
foreach ( $scopes as $scope ) {
|
895 |
+
$scope_args = array();
|
896 |
+
|
897 |
+
/**
|
898 |
+
* Plugins can hook here to set their activity arguments for custom scopes.
|
899 |
+
*
|
900 |
+
* This is a dynamic filter based on the activity scope. eg:
|
901 |
+
* - 'bp_activity_set_groups_scope_args'
|
902 |
+
* - 'bp_activity_set_friends_scope_args'
|
903 |
+
*
|
904 |
+
* To see how this filter is used, plugin devs should check out:
|
905 |
+
* - bp_groups_filter_activity_scope() - used for 'groups' scope
|
906 |
+
* - bp_friends_filter_activity_scope() - used for 'friends' scope
|
907 |
+
*
|
908 |
+
* @since BuddyPress (2.2.0)
|
909 |
+
*
|
910 |
+
* @param array {
|
911 |
+
* Activity query clauses.
|
912 |
+
*
|
913 |
+
* @type array {
|
914 |
+
* Activity arguments for your custom scope.
|
915 |
+
* See {@link BP_Activity_Query::_construct()} for more details.
|
916 |
+
* }
|
917 |
+
* @type array $override Optional. Override existing activity arguments passed by $r.
|
918 |
+
* }
|
919 |
+
* @param array $r Current activity arguments passed in BP_Activity_Activity::get().
|
920 |
+
*/
|
921 |
+
$scope_args = apply_filters( "bp_activity_set_{$scope}_scope_args", array(), $r );
|
922 |
+
|
923 |
+
if ( ! empty( $scope_args ) ) {
|
924 |
+
// merge override properties from other scopes
|
925 |
+
// this might be a problem...
|
926 |
+
if ( ! empty( $scope_args['override'] ) ) {
|
927 |
+
$override = array_merge( $override, $scope_args['override'] );
|
928 |
+
unset( $scope_args['override'] );
|
929 |
+
}
|
930 |
+
|
931 |
+
// save scope args
|
932 |
+
if ( ! empty( $scope_args ) ) {
|
933 |
+
$query_args[] = $scope_args;
|
934 |
+
}
|
935 |
+
}
|
936 |
+
}
|
937 |
+
|
938 |
+
if ( ! empty( $query_args ) ) {
|
939 |
+
// set relation to OR
|
940 |
+
$query_args['relation'] = 'OR';
|
941 |
+
|
942 |
+
$query = new BP_Activity_Query( $query_args );
|
943 |
+
$sql = $query->get_sql();
|
944 |
+
if ( ! empty( $sql ) ) {
|
945 |
+
$retval['sql'] = $sql;
|
946 |
+
}
|
947 |
+
}
|
948 |
+
|
949 |
+
if ( ! empty( $override ) ) {
|
950 |
+
$retval['override'] = $override;
|
951 |
+
}
|
952 |
+
|
953 |
+
return $retval;
|
954 |
+
}
|
955 |
+
|
956 |
+
/**
|
957 |
+
* In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
|
958 |
+
*
|
959 |
+
* As of 1.5.x, use BP_Activity_Activity::get() with an 'in' parameter instead.
|
960 |
+
*
|
961 |
+
* @since BuddyPress (1.2.0)
|
962 |
+
*
|
963 |
+
* @deprecated 1.5
|
964 |
+
* @deprecated Use BP_Activity_Activity::get() with an 'in' parameter instead.
|
965 |
+
*
|
966 |
+
* @param mixed $activity_ids Array or comma-separated string of activity IDs to retrieve.
|
967 |
+
* @param int|bool $max Maximum number of results to return. (Optional; default is no maximum).
|
968 |
+
* @param int $page The set of results that the user is viewing. Used in pagination. (Optional; default is 1).
|
969 |
+
* @param int $per_page Specifies how many results per page. Used in pagination. (Optional; default is 25).
|
970 |
+
* @param string $sort MySQL column sort; ASC or DESC. (Optional; default is DESC).
|
971 |
+
* @param bool $display_comments Retrieve an activity item's associated comments or not. (Optional; default is false).
|
972 |
+
*
|
973 |
+
* @return array
|
974 |
+
*/
|
975 |
+
public static function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) {
|
976 |
+
_deprecated_function( __FUNCTION__, '1.5', 'Use BP_Activity_Activity::get() with the "in" parameter instead.' );
|
977 |
+
return BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, false, false, $activity_ids );
|
978 |
+
}
|
979 |
+
|
980 |
+
/**
|
981 |
+
* Get the first activity ID that matches a set of criteria.
|
982 |
+
*
|
983 |
+
* @param int $user_id User ID to filter by.
|
984 |
+
* @param string $component Component to filter by.
|
985 |
+
* @param string $type Activity type to filter by.
|
986 |
+
* @param int $item_id Associated item to filter by.
|
987 |
+
* @param int $secondary_item_id Secondary associated item to filter by.
|
988 |
+
* @param string $action Action to filter by.
|
989 |
+
* @param string $content Content to filter by.
|
990 |
+
* @param string $date_recorded Date to filter by.
|
991 |
+
*
|
992 |
+
* @todo Should parameters be optional?
|
993 |
+
*
|
994 |
+
* @return int|bool Activity ID on success, false if none is found.
|
995 |
+
*/
|
996 |
+
public static function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded ) {
|
997 |
+
global $wpdb;
|
998 |
+
|
999 |
+
$bp = buddypress();
|
1000 |
+
|
1001 |
+
$where_args = false;
|
1002 |
+
|
1003 |
+
if ( ! empty( $user_id ) ) {
|
1004 |
+
$where_args[] = $wpdb->prepare( "user_id = %d", $user_id );
|
1005 |
+
}
|
1006 |
+
|
1007 |
+
if ( ! empty( $component ) ) {
|
1008 |
+
$where_args[] = $wpdb->prepare( "component = %s", $component );
|
1009 |
+
}
|
1010 |
+
|
1011 |
+
if ( ! empty( $type ) ) {
|
1012 |
+
$where_args[] = $wpdb->prepare( "type = %s", $type );
|
1013 |
+
}
|
1014 |
+
|
1015 |
+
if ( ! empty( $item_id ) ) {
|
1016 |
+
$where_args[] = $wpdb->prepare( "item_id = %d", $item_id );
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
if ( ! empty( $secondary_item_id ) ) {
|
1020 |
+
$where_args[] = $wpdb->prepare( "secondary_item_id = %d", $secondary_item_id );
|
1021 |
+
}
|
1022 |
+
|
1023 |
+
if ( ! empty( $action ) ) {
|
1024 |
+
$where_args[] = $wpdb->prepare( "action = %s", $action );
|
1025 |
+
}
|
1026 |
+
|
1027 |
+
if ( ! empty( $content ) ) {
|
1028 |
+
$where_args[] = $wpdb->prepare( "content = %s", $content );
|
1029 |
+
}
|
1030 |
+
|
1031 |
+
if ( ! empty( $date_recorded ) ) {
|
1032 |
+
$where_args[] = $wpdb->prepare( "date_recorded = %s", $date_recorded );
|
1033 |
+
}
|
1034 |
+
|
1035 |
+
if ( ! empty( $where_args ) ) {
|
1036 |
+
$where_sql = 'WHERE ' . join( ' AND ', $where_args );
|
1037 |
+
return $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
|
1038 |
+
}
|
1039 |
+
|
1040 |
+
return false;
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
/**
|
1044 |
+
* Delete activity items from the database.
|
1045 |
+
*
|
1046 |
+
* To delete a specific activity item, pass an 'id' parameter.
|
1047 |
+
* Otherwise use the filters.
|
1048 |
+
*
|
1049 |
+
* @since BuddyPress (1.2.0)
|
1050 |
+
*
|
1051 |
+
* @param array $args {
|
1052 |
+
* @int $id Optional. The ID of a specific item to delete.
|
1053 |
+
* @string $action Optional. The action to filter by.
|
1054 |
+
* @string $content Optional. The content to filter by.
|
1055 |
+
* @string $component Optional. The component name to filter by.
|
1056 |
+
* @string $type Optional. The activity type to filter by.
|
1057 |
+
* @string $primary_link Optional. The primary URL to filter by.
|
1058 |
+
* @int $user_id Optional. The user ID to filter by.
|
1059 |
+
* @int $item_id Optional. The associated item ID to filter by.
|
1060 |
+
* @int $secondary_item_id Optional. The secondary associated item ID to filter by.
|
1061 |
+
* @string $date_recorded Optional. The date to filter by.
|
1062 |
+
* @int $hide_sitewide Optional. Default: false.
|
1063 |
+
* }
|
1064 |
+
*
|
1065 |
+
* @return array|bool An array of deleted activity IDs on success, false on failure.
|
1066 |
+
*/
|
1067 |
+
public static function delete( $args = array() ) {
|
1068 |
+
global $wpdb;
|
1069 |
+
|
1070 |
+
$bp = buddypress();
|
1071 |
+
$r = wp_parse_args( $args, array(
|
1072 |
+
'id' => false,
|
1073 |
+
'action' => false,
|
1074 |
+
'content' => false,
|
1075 |
+
'component' => false,
|
1076 |
+
'type' => false,
|
1077 |
+
'primary_link' => false,
|
1078 |
+
'user_id' => false,
|
1079 |
+
'item_id' => false,
|
1080 |
+
'secondary_item_id' => false,
|
1081 |
+
'date_recorded' => false,
|
1082 |
+
'hide_sitewide' => false
|
1083 |
+
) );
|
1084 |
+
|
1085 |
+
// Setup empty array from where query arguments
|
1086 |
+
$where_args = array();
|
1087 |
+
|
1088 |
+
// ID
|
1089 |
+
if ( ! empty( $r['id'] ) ) {
|
1090 |
+
$where_args[] = $wpdb->prepare( "id = %d", $r['id'] );
|
1091 |
+
}
|
1092 |
+
|
1093 |
+
// User ID
|
1094 |
+
if ( ! empty( $r['user_id'] ) ) {
|
1095 |
+
$where_args[] = $wpdb->prepare( "user_id = %d", $r['user_id'] );
|
1096 |
+
}
|
1097 |
+
|
1098 |
+
// Action
|
1099 |
+
if ( ! empty( $r['action'] ) ) {
|
1100 |
+
$where_args[] = $wpdb->prepare( "action = %s", $r['action'] );
|
1101 |
+
}
|
1102 |
+
|
1103 |
+
// Content
|
1104 |
+
if ( ! empty( $r['content'] ) ) {
|
1105 |
+
$where_args[] = $wpdb->prepare( "content = %s", $r['content'] );
|
1106 |
+
}
|
1107 |
+
|
1108 |
+
// Component
|
1109 |
+
if ( ! empty( $r['component'] ) ) {
|
1110 |
+
$where_args[] = $wpdb->prepare( "component = %s", $r['component'] );
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
// Type
|
1114 |
+
if ( ! empty( $r['type'] ) ) {
|
1115 |
+
$where_args[] = $wpdb->prepare( "type = %s", $r['type'] );
|
1116 |
+
}
|
1117 |
+
|
1118 |
+
// Primary Link
|
1119 |
+
if ( ! empty( $r['primary_link'] ) ) {
|
1120 |
+
$where_args[] = $wpdb->prepare( "primary_link = %s", $r['primary_link'] );
|
1121 |
+
}
|
1122 |
+
|
1123 |
+
// Item ID
|
1124 |
+
if ( ! empty( $r['item_id'] ) ) {
|
1125 |
+
$where_args[] = $wpdb->prepare( "item_id = %d", $r['item_id'] );
|
1126 |
+
}
|
1127 |
+
|
1128 |
+
// Secondary item ID
|
1129 |
+
if ( ! empty( $r['secondary_item_id'] ) ) {
|
1130 |
+
$where_args[] = $wpdb->prepare( "secondary_item_id = %d", $r['secondary_item_id'] );
|
1131 |
+
}
|
1132 |
+
|
1133 |
+
// Date Recorded
|
1134 |
+
if ( ! empty( $r['date_recorded'] ) ) {
|
1135 |
+
$where_args[] = $wpdb->prepare( "date_recorded = %s", $r['date_recorded'] );
|
1136 |
+
}
|
1137 |
+
|
1138 |
+
// Hidden sitewide
|
1139 |
+
if ( ! empty( $r['hide_sitewide'] ) ) {
|
1140 |
+
$where_args[] = $wpdb->prepare( "hide_sitewide = %d", $r['hide_sitewide'] );
|
1141 |
+
}
|
1142 |
+
|
1143 |
+
// Bail if no where arguments
|
1144 |
+
if ( empty( $where_args ) ) {
|
1145 |
+
return false;
|
1146 |
+
}
|
1147 |
+
|
1148 |
+
// Join the where arguments for querying
|
1149 |
+
$where_sql = 'WHERE ' . join( ' AND ', $where_args );
|
1150 |
+
|
1151 |
+
// Fetch all activities being deleted so we can perform more actions
|
1152 |
+
$activities = $wpdb->get_results( "SELECT * FROM {$bp->activity->table_name} {$where_sql}" );
|
1153 |
+
|
1154 |
+
/**
|
1155 |
+
* Action to allow intercepting activity items to be deleted.
|
1156 |
+
*
|
1157 |
+
* @since BuddyPress (2.3.0)
|
1158 |
+
*
|
1159 |
+
* @param array $activities Array of activities.
|
1160 |
+
* @param array $r Array of parsed arguments.
|
1161 |
+
*/
|
1162 |
+
do_action_ref_array( 'bp_activity_before_delete', array( $activities, $r ) );
|
1163 |
+
|
1164 |
+
// Attempt to delete activities from the database
|
1165 |
+
$deleted = $wpdb->query( "DELETE FROM {$bp->activity->table_name} {$where_sql}" );
|
1166 |
+
|
1167 |
+
// Bail if nothing was deleted
|
1168 |
+
if ( empty( $deleted ) ) {
|
1169 |
+
return false;
|
1170 |
+
}
|
1171 |
+
|
1172 |
+
/**
|
1173 |
+
* Action to allow intercepting activity items just deleted.
|
1174 |
+
*
|
1175 |
+
* @since BuddyPress (2.3.0)
|
1176 |
+
*
|
1177 |
+
* @param array $activities Array of activities.
|
1178 |
+
* @param array $r Array of parsed arguments.
|
1179 |
+
*/
|
1180 |
+
do_action_ref_array( 'bp_activity_after_delete', array( $activities, $r ) );
|
1181 |
+
|
1182 |
+
// Pluck the activity IDs out of the $activities array
|
1183 |
+
$activity_ids = wp_parse_id_list( wp_list_pluck( $activities, 'id' ) );
|
1184 |
+
|
1185 |
+
// Handle accompanying activity comments and meta deletion
|
1186 |
+
if ( ! empty( $activity_ids ) ) {
|
1187 |
+
|
1188 |
+
// Delete all activity meta entries for activity items
|
1189 |
+
BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
|
1190 |
+
|
1191 |
+
// Setup empty array for comments
|
1192 |
+
$comment_ids = array();
|
1193 |
+
|
1194 |
+
// Loop through activity ids and attempt to delete comments
|
1195 |
+
foreach ( $activity_ids as $activity_id ) {
|
1196 |
+
|
1197 |
+
// Attempt to delete comments
|
1198 |
+
$comments = BP_Activity_Activity::delete( array(
|
1199 |
+
'type' => 'activity_comment',
|
1200 |
+
'item_id' => $activity_id
|
1201 |
+
) );
|
1202 |
+
|
1203 |
+
// Merge IDs together
|
1204 |
+
if ( ! empty( $comments ) ) {
|
1205 |
+
$comment_ids = array_merge( $comment_ids, $comments );
|
1206 |
+
}
|
1207 |
+
}
|
1208 |
+
|
1209 |
+
// Merge activity IDs with any deleted comment IDs
|
1210 |
+
if ( ! empty( $comment_ids ) ) {
|
1211 |
+
$activity_ids = array_unique( array_merge( $activity_ids, $comment_ids ) );
|
1212 |
+
}
|
1213 |
+
}
|
1214 |
+
|
1215 |
+
return $activity_ids;
|
1216 |
+
}
|
1217 |
+
|
1218 |
+
/**
|
1219 |
+
* Delete the comments associated with a set of activity items.
|
1220 |
+
*
|
1221 |
+
* This method is no longer used by BuddyPress, and it is recommended not to
|
1222 |
+
* use it going forward, and use BP_Activity_Activity::delete() instead.
|
1223 |
+
*
|
1224 |
+
* @since BuddyPress (1.2.0)
|
1225 |
+
* @deprecated BuddyPress (2.3.0)
|
1226 |
+
*
|
1227 |
+
* @param array $activity_ids Activity IDs whose comments should be deleted.
|
1228 |
+
* @param bool $delete_meta Should we delete the activity meta items for these comments?
|
1229 |
+
*
|
1230 |
+
* @return bool True on success.
|
1231 |
+
*/
|
1232 |
+
public static function delete_activity_item_comments( $activity_ids = array(), $delete_meta = true ) {
|
1233 |
+
global $wpdb;
|
1234 |
+
|
1235 |
+
$bp = buddypress();
|
1236 |
+
|
1237 |
+
$delete_meta = (bool) $delete_meta;
|
1238 |
+
$activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) );
|
1239 |
+
|
1240 |
+
if ( $delete_meta ) {
|
1241 |
+
// Fetch the activity comment IDs for our deleted activity items
|
1242 |
+
$activity_comment_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
|
1243 |
+
|
1244 |
+
if ( ! empty( $activity_comment_ids ) ) {
|
1245 |
+
self::delete_activity_meta_entries( $activity_comment_ids );
|
1246 |
+
}
|
1247 |
+
}
|
1248 |
+
|
1249 |
+
return $wpdb->query( "DELETE FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
|
1250 |
+
}
|
1251 |
+
|
1252 |
+
/**
|
1253 |
+
* Delete the meta entries associated with a set of activity items.
|
1254 |
+
*
|
1255 |
+
* @since BuddyPress (1.2.0)
|
1256 |
+
*
|
1257 |
+
* @param array $activity_ids Activity IDs whose meta should be deleted.
|
1258 |
+
*
|
1259 |
+
* @return bool True on success.
|
1260 |
+
*/
|
1261 |
+
public static function delete_activity_meta_entries( $activity_ids = array() ) {
|
1262 |
+
$activity_ids = wp_parse_id_list( $activity_ids );
|
1263 |
+
|
1264 |
+
foreach ( $activity_ids as $activity_id ) {
|
1265 |
+
bp_activity_delete_meta( $activity_id );
|
1266 |
+
}
|
1267 |
+
|
1268 |
+
return true;
|
1269 |
+
}
|
1270 |
+
|
1271 |
+
/**
|
1272 |
+
* Append activity comments to their associated activity items.
|
1273 |
+
*
|
1274 |
+
* @since BuddyPress (1.2.0)
|
1275 |
+
*
|
1276 |
+
* @global wpdb $wpdb WordPress database object.
|
1277 |
+
*
|
1278 |
+
* @param array $activities Activities to fetch comments for.
|
1279 |
+
* @param string $spam Optional. 'ham_only' (default), 'spam_only' or 'all'.
|
1280 |
+
*
|
1281 |
+
* @return array The updated activities with nested comments.
|
1282 |
+
*/
|
1283 |
+
public static function append_comments( $activities, $spam = 'ham_only' ) {
|
1284 |
+
$activity_comments = array();
|
1285 |
+
|
1286 |
+
// Now fetch the activity comments and parse them into the correct position in the activities array.
|
1287 |
+
foreach ( (array) $activities as $activity ) {
|
1288 |
+
$top_level_parent_id = 'activity_comment' == $activity->type ? $activity->item_id : 0;
|
1289 |
+
$activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $spam, $top_level_parent_id );
|
1290 |
+
}
|
1291 |
+
|
1292 |
+
// Merge the comments with the activity items
|
1293 |
+
foreach ( (array) $activities as $key => $activity ) {
|
1294 |
+
if ( isset( $activity_comments[$activity->id] ) ) {
|
1295 |
+
$activities[$key]->children = $activity_comments[$activity->id];
|
1296 |
+
}
|
1297 |
+
}
|
1298 |
+
|
1299 |
+
return $activities;
|
1300 |
+
}
|
1301 |
+
|
1302 |
+
/**
|
1303 |
+
* Get activity comments that are associated with a specific activity ID.
|
1304 |
+
*
|
1305 |
+
* @since BuddyPress (1.2.0)
|
1306 |
+
*
|
1307 |
+
* @global wpdb $wpdb WordPress database object.
|
1308 |
+
*
|
1309 |
+
* @param int $activity_id Activity ID to fetch comments for.
|
1310 |
+
* @param int $left Left-most node boundary.
|
1311 |
+
* @param int $right Right-most node boundary.
|
1312 |
+
* @param string $spam Optional. 'ham_only' (default), 'spam_only' or 'all'.
|
1313 |
+
* @param int $top_level_parent_id Optional. The id of the root-level parent activity item.
|
1314 |
+
*
|
1315 |
+
* @return array The updated activities with nested comments.
|
1316 |
+
*/
|
1317 |
+
public static function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
|
1318 |
+
global $wpdb;
|
1319 |
+
|
1320 |
+
if ( empty( $top_level_parent_id ) ) {
|
1321 |
+
$top_level_parent_id = $activity_id;
|
1322 |
+
}
|
1323 |
+
|
1324 |
+
$comments = wp_cache_get( $activity_id, 'bp_activity_comments' );
|
1325 |
+
|
1326 |
+
// We store the string 'none' to cache the fact that the
|
1327 |
+
// activity item has no comments
|
1328 |
+
if ( 'none' === $comments ) {
|
1329 |
+
$comments = false;
|
1330 |
+
|
1331 |
+
// A true cache miss
|
1332 |
+
} elseif ( empty( $comments ) ) {
|
1333 |
+
|
1334 |
+
$bp = buddypress();
|
1335 |
+
|
1336 |
+
// Select the user's fullname with the query
|
1337 |
+
if ( bp_is_active( 'xprofile' ) ) {
|
1338 |
+
$fullname_select = ", pd.value as user_fullname";
|
1339 |
+
$fullname_from = ", {$bp->profile->table_name_data} pd ";
|
1340 |
+
$fullname_where = "AND pd.user_id = a.user_id AND pd.field_id = 1";
|
1341 |
+
|
1342 |
+
// Prevent debug errors
|
1343 |
+
} else {
|
1344 |
+
$fullname_select = $fullname_from = $fullname_where = '';
|
1345 |
+
}
|
1346 |
+
|
1347 |
+
// Don't retrieve activity comments marked as spam
|
1348 |
+
if ( 'ham_only' == $spam ) {
|
1349 |
+
$spam_sql = 'AND a.is_spam = 0';
|
1350 |
+
} elseif ( 'spam_only' == $spam ) {
|
1351 |
+
$spam_sql = 'AND a.is_spam = 1';
|
1352 |
+
} else {
|
1353 |
+
$spam_sql = '';
|
1354 |
+
}
|
1355 |
+
|
1356 |
+
// Legacy query - not recommended
|
1357 |
+
$func_args = func_get_args();
|
1358 |
+
|
1359 |
+
/**
|
1360 |
+
* Filters if BuddyPress should use the legacy activity query.
|
1361 |
+
*
|
1362 |
+
* @since BuddyPress (2.0.0)
|
1363 |
+
*
|
1364 |
+
* @param bool $value Whether or not to use the legacy query.
|
1365 |
+
* @param BP_Activity_Activity $value Magic method referring to currently called method.
|
1366 |
+
* @param array $func_args Array of the method's argument list.
|
1367 |
+
*/
|
1368 |
+
if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $func_args ) ) {
|
1369 |
+
|
1370 |
+
/**
|
1371 |
+
* Filters the MySQL prepared statement for the legacy activity query.
|
1372 |
+
*
|
1373 |
+
* @since BuddyPress (1.5.0)
|
1374 |
+
*
|
1375 |
+
* @param string $value Prepared statement for the activity query.
|
1376 |
+
* @param int $activity_id Activity ID to fetch comments for.
|
1377 |
+
* @param int $left Left-most node boundary.
|
1378 |
+
* @param int $right Right-most node boundary.
|
1379 |
+
* @param string $spam_sql SQL Statement portion to differentiate between ham or spam.
|
1380 |
+
*/
|
1381 |
+
$sql = apply_filters( 'bp_activity_comments_user_join_filter', $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' {$spam_sql} AND a.item_id = %d AND a.mptt_left > %d AND a.mptt_left < %d ORDER BY a.date_recorded ASC", $top_level_parent_id, $left, $right ), $activity_id, $left, $right, $spam_sql );
|
1382 |
+
|
1383 |
+
$descendants = $wpdb->get_results( $sql );
|
1384 |
+
|
1385 |
+
// We use the mptt BETWEEN clause to limit returned
|
1386 |
+
// descendants to the correct part of the tree.
|
1387 |
+
} else {
|
1388 |
+
$sql = $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} a WHERE a.type = 'activity_comment' {$spam_sql} AND a.item_id = %d and a.mptt_left > %d AND a.mptt_left < %d ORDER BY a.date_recorded ASC", $top_level_parent_id, $left, $right );
|
1389 |
+
|
1390 |
+
$descendant_ids = $wpdb->get_col( $sql );
|
1391 |
+
$descendants = self::get_activity_data( $descendant_ids );
|
1392 |
+
$descendants = self::append_user_fullnames( $descendants );
|
1393 |
+
}
|
1394 |
+
|
1395 |
+
$ref = array();
|
1396 |
+
|
1397 |
+
// Loop descendants and build an assoc array
|
1398 |
+
foreach ( (array) $descendants as $d ) {
|
1399 |
+
$d->children = array();
|
1400 |
+
|
1401 |
+
// If we have a reference on the parent
|
1402 |
+
if ( isset( $ref[ $d->secondary_item_id ] ) ) {
|
1403 |
+
$ref[ $d->secondary_item_id ]->children[ $d->id ] = $d;
|
1404 |
+
$ref[ $d->id ] =& $ref[ $d->secondary_item_id ]->children[ $d->id ];
|
1405 |
+
|
1406 |
+
// If we don't have a reference on the parent, put in the root level
|
1407 |
+
} else {
|
1408 |
+
$comments[ $d->id ] = $d;
|
1409 |
+
$ref[ $d->id ] =& $comments[ $d->id ];
|
1410 |
+
}
|
1411 |
+
}
|
1412 |
+
|
1413 |
+
// Calculate depth for each item
|
1414 |
+
foreach ( $ref as &$r ) {
|
1415 |
+
$depth = 1;
|
1416 |
+
$parent_id = $r->secondary_item_id;
|
1417 |
+
while ( $parent_id !== $r->item_id ) {
|
1418 |
+
$depth++;
|
1419 |
+
|
1420 |
+
// When display_comments=stream, the
|
1421 |
+
// parent comment may not be part of
|
1422 |
+
// the returned results, so we manually
|
1423 |
+
// fetch it
|
1424 |
+
if ( empty( $ref[ $parent_id ] ) ) {
|
1425 |
+
$direct_parent = new BP_Activity_Activity( $parent_id );
|
1426 |
+
if ( isset( $direct_parent->secondary_item_id ) ) {
|
1427 |
+
$parent_id = $direct_parent->secondary_item_id;
|
1428 |
+
} else {
|
1429 |
+
// Something went wrong
|
1430 |
+
// Short-circuit the
|
1431 |
+
// depth calculation
|
1432 |
+
$parent_id = $r->item_id;
|
1433 |
+
}
|
1434 |
+
} else {
|
1435 |
+
$parent_id = $ref[ $parent_id ]->secondary_item_id;
|
1436 |
+
}
|
1437 |
+
}
|
1438 |
+
$r->depth = $depth;
|
1439 |
+
}
|
1440 |
+
|
1441 |
+
// If we cache a value of false, it'll count as a cache
|
1442 |
+
// miss the next time the activity comments are fetched.
|
1443 |
+
// Storing the string 'none' is a hack workaround to
|
1444 |
+
// avoid unnecessary queries.
|
1445 |
+
if ( false === $comments ) {
|
1446 |
+
$cache_value = 'none';
|
1447 |
+
} else {
|
1448 |
+
$cache_value = $comments;
|
1449 |
+
}
|
1450 |
+
|
1451 |
+
wp_cache_set( $activity_id, $cache_value, 'bp_activity_comments' );
|
1452 |
+
}
|
1453 |
+
|
1454 |
+
return $comments;
|
1455 |
+
}
|
1456 |
+
|
1457 |
+
/**
|
1458 |
+
* Rebuild nested comment tree under an activity or activity comment.
|
1459 |
+
*
|
1460 |
+
* @since BuddyPress (1.2.0)
|
1461 |
+
*
|
1462 |
+
* @global wpdb $wpdb WordPress database object.
|
1463 |
+
*
|
1464 |
+
* @param int $parent_id ID of an activity or activity comment.
|
1465 |
+
* @param int $left Node boundary start for activity or activity comment.
|
1466 |
+
* @return int Right Node boundary of activity or activity comment.
|
1467 |
+
*/
|
1468 |
+
public static function rebuild_activity_comment_tree( $parent_id, $left = 1 ) {
|
1469 |
+
global $wpdb;
|
1470 |
+
|
1471 |
+
$bp = buddypress();
|
1472 |
+
|
1473 |
+
// The right value of this node is the left value + 1
|
1474 |
+
$right = intval( $left + 1 );
|
1475 |
+
|
1476 |
+
// Get all descendants of this node
|
1477 |
+
$comments = BP_Activity_Activity::get_child_comments( $parent_id );
|
1478 |
+
$descendants = wp_list_pluck( $comments, 'id' );
|
1479 |
+
|
1480 |
+
// Loop the descendants and recalculate the left and right values
|
1481 |
+
foreach ( (array) $descendants as $descendant_id ) {
|
1482 |
+
$right = BP_Activity_Activity::rebuild_activity_comment_tree( $descendant_id, $right );
|
1483 |
+
}
|
1484 |
+
|
1485 |
+
// We've got the left value, and now that we've processed the children
|
1486 |
+
// of this node we also know the right value
|
1487 |
+
if ( 1 === $left ) {
|
1488 |
+
$wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE id = %d", $left, $right, $parent_id ) );
|
1489 |
+
} else {
|
1490 |
+
$wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE type = 'activity_comment' AND id = %d", $left, $right, $parent_id ) );
|
1491 |
+
}
|
1492 |
+
|
1493 |
+
// Return the right value of this node + 1
|
1494 |
+
return intval( $right + 1 );
|
1495 |
+
}
|
1496 |
+
|
1497 |
+
/**
|
1498 |
+
* Get child comments of an activity or activity comment.
|
1499 |
+
*
|
1500 |
+
* @since BuddyPress (1.2.0)
|
1501 |
+
*
|
1502 |
+
* @global wpdb $wpdb WordPress database object.
|
1503 |
+
*
|
1504 |
+
* @param int $parent_id ID of an activity or activity comment.
|
1505 |
+
*
|
1506 |
+
* @return object Numerically indexed array of child comments.
|
1507 |
+
*/
|
1508 |
+
public static function get_child_comments( $parent_id ) {
|
1509 |
+
global $wpdb;
|
1510 |
+
|
1511 |
+
$bp = buddypress();
|
1512 |
+
|
1513 |
+
return $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND secondary_item_id = %d", $parent_id ) );
|
1514 |
+
}
|
1515 |
+
|
1516 |
+
/**
|
1517 |
+
* Get a list of components that have recorded activity associated with them.
|
1518 |
+
*
|
1519 |
+
* @param bool $skip_last_activity If true, components will not be
|
1520 |
+
* included if the only activity type associated with them is
|
1521 |
+
* 'last_activity'. (Since 2.0.0, 'last_activity' is stored in
|
1522 |
+
* the activity table, but these items are not full-fledged
|
1523 |
+
* activity items.) Default: true.
|
1524 |
+
*
|
1525 |
+
* @return array List of component names.
|
1526 |
+
*/
|
1527 |
+
public static function get_recorded_components( $skip_last_activity = true ) {
|
1528 |
+
global $wpdb;
|
1529 |
+
|
1530 |
+
$bp = buddypress();
|
1531 |
+
|
1532 |
+
if ( true === $skip_last_activity ) {
|
1533 |
+
$components = $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} WHERE action != '' AND action != 'last_activity' ORDER BY component ASC" );
|
1534 |
+
} else {
|
1535 |
+
$components = $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} ORDER BY component ASC" );
|
1536 |
+
}
|
1537 |
+
|
1538 |
+
return $components;
|
1539 |
+
}
|
1540 |
+
|
1541 |
+
/**
|
1542 |
+
* Get sitewide activity items for use in an RSS feed.
|
1543 |
+
*
|
1544 |
+
* @param int $limit Optional. Number of items to fetch. Default: 35.
|
1545 |
+
*
|
1546 |
+
* @return array $activity_feed List of activity items, with RSS data added.
|
1547 |
+
*/
|
1548 |
+
public static function get_sitewide_items_for_feed( $limit = 35 ) {
|
1549 |
+
$activities = bp_activity_get_sitewide( array( 'max' => $limit ) );
|
1550 |
+
$activity_feed = array();
|
1551 |
+
|
1552 |
+
for ( $i = 0, $count = count( $activities ); $i < $count; ++$i ) {
|
1553 |
+
$title = explode( '<span', $activities[$i]['content'] );
|
1554 |
+
$activity_feed[$i]['title'] = trim( strip_tags( $title[0] ) );
|
1555 |
+
$activity_feed[$i]['link'] = $activities[$i]['primary_link'];
|
1556 |
+
$activity_feed[$i]['description'] = @sprintf( $activities[$i]['content'], '' );
|
1557 |
+
$activity_feed[$i]['pubdate'] = $activities[$i]['date_recorded'];
|
1558 |
+
}
|
1559 |
+
|
1560 |
+
return $activity_feed;
|
1561 |
+
}
|
1562 |
+
|
1563 |
+
/**
|
1564 |
+
* Create SQL IN clause for filter queries.
|
1565 |
+
*
|
1566 |
+
* @since BuddyPress (1.5.0)
|
1567 |
+
*
|
1568 |
+
* @see BP_Activity_Activity::get_filter_sql()
|
1569 |
+
*
|
1570 |
+
* @param string $field The database field.
|
1571 |
+
* @param array|bool $items The values for the IN clause, or false when none are found.
|
1572 |
+
*
|
1573 |
+
* @return string|bool.
|
1574 |
+
*/
|
1575 |
+
public static function get_in_operator_sql( $field, $items ) {
|
1576 |
+
global $wpdb;
|
1577 |
+
|
1578 |
+
// split items at the comma
|
1579 |
+
if ( ! is_array( $items ) ) {
|
1580 |
+
$items = explode( ',', $items );
|
1581 |
+
}
|
1582 |
+
|
1583 |
+
// array of prepared integers or quoted strings
|
1584 |
+
$items_prepared = array();
|
1585 |
+
|
1586 |
+
// clean up and format each item
|
1587 |
+
foreach ( $items as $item ) {
|
1588 |
+
// clean up the string
|
1589 |
+
$item = trim( $item );
|
1590 |
+
// pass everything through prepare for security and to safely quote strings
|
1591 |
+
$items_prepared[] = ( is_numeric( $item ) ) ? $wpdb->prepare( '%d', $item ) : $wpdb->prepare( '%s', $item );
|
1592 |
+
}
|
1593 |
+
|
1594 |
+
// build IN operator sql syntax
|
1595 |
+
if ( count( $items_prepared ) )
|
1596 |
+
return sprintf( '%s IN ( %s )', trim( $field ), implode( ',', $items_prepared ) );
|
1597 |
+
else
|
1598 |
+
return false;
|
1599 |
+
}
|
1600 |
+
|
1601 |
+
/**
|
1602 |
+
* Create filter SQL clauses.
|
1603 |
+
*
|
1604 |
+
* @since BuddyPress (1.5.0)
|
1605 |
+
*
|
1606 |
+
* @param array $filter_array {
|
1607 |
+
* Fields and values to filter by.
|
1608 |
+
*
|
1609 |
+
* @type array|string|int $user_id User ID(s).
|
1610 |
+
* @type array|string $object Corresponds to the 'component'
|
1611 |
+
* column in the database.
|
1612 |
+
* @type array|string $action Corresponds to the 'type' column
|
1613 |
+
* in the database.
|
1614 |
+
* @type array|string|int $primary_id Corresponds to the 'item_id'
|
1615 |
+
* column in the database.
|
1616 |
+
* @type array|string|int $secondary_id Corresponds to the
|
1617 |
+
* 'secondary_item_id' column in the database.
|
1618 |
+
* @type int $offset Return only those items with an ID greater
|
1619 |
+
* than the offset value.
|
1620 |
+
* @type string $since Return only those items that have a
|
1621 |
+
* date_recorded value greater than a
|
1622 |
+
* given MySQL-formatted date.
|
1623 |
+
* }
|
1624 |
+
*
|
1625 |
+
* @return string The filter clause, for use in a SQL query.
|
1626 |
+
*/
|
1627 |
+
public static function get_filter_sql( $filter_array ) {
|
1628 |
+
|
1629 |
+
$filter_sql = array();
|
1630 |
+
|
1631 |
+
if ( !empty( $filter_array['user_id'] ) ) {
|
1632 |
+
$user_sql = BP_Activity_Activity::get_in_operator_sql( 'a.user_id', $filter_array['user_id'] );
|
1633 |
+
if ( !empty( $user_sql ) )
|
1634 |
+
$filter_sql[] = $user_sql;
|
1635 |
+
}
|
1636 |
+
|
1637 |
+
if ( !empty( $filter_array['object'] ) ) {
|
1638 |
+
$object_sql = BP_Activity_Activity::get_in_operator_sql( 'a.component', $filter_array['object'] );
|
1639 |
+
if ( !empty( $object_sql ) )
|
1640 |
+
$filter_sql[] = $object_sql;
|
1641 |
+
}
|
1642 |
+
|
1643 |
+
if ( !empty( $filter_array['action'] ) ) {
|
1644 |
+
$action_sql = BP_Activity_Activity::get_in_operator_sql( 'a.type', $filter_array['action'] );
|
1645 |
+
if ( ! empty( $action_sql ) )
|
1646 |
+
$filter_sql[] = $action_sql;
|
1647 |
+
}
|
1648 |
+
|
1649 |
+
if ( !empty( $filter_array['primary_id'] ) ) {
|
1650 |
+
$pid_sql = BP_Activity_Activity::get_in_operator_sql( 'a.item_id', $filter_array['primary_id'] );
|
1651 |
+
if ( !empty( $pid_sql ) )
|
1652 |
+
$filter_sql[] = $pid_sql;
|
1653 |
+
}
|
1654 |
+
|
1655 |
+
if ( !empty( $filter_array['secondary_id'] ) ) {
|
1656 |
+
$sid_sql = BP_Activity_Activity::get_in_operator_sql( 'a.secondary_item_id', $filter_array['secondary_id'] );
|
1657 |
+
if ( !empty( $sid_sql ) )
|
1658 |
+
$filter_sql[] = $sid_sql;
|
1659 |
+
}
|
1660 |
+
|
1661 |
+
if ( ! empty( $filter_array['offset'] ) ) {
|
1662 |
+
$sid_sql = absint( $filter_array['offset'] );
|
1663 |
+
$filter_sql[] = "a.id >= {$sid_sql}";
|
1664 |
+
}
|
1665 |
+
|
1666 |
+
if ( ! empty( $filter_array['since'] ) ) {
|
1667 |
+
// Validate that this is a proper Y-m-d H:i:s date
|
1668 |
+
// Trick: parse to UNIX date then translate back
|
1669 |
+
$translated_date = date( 'Y-m-d H:i:s', strtotime( $filter_array['since'] ) );
|
1670 |
+
if ( $translated_date === $filter_array['since'] ) {
|
1671 |
+
$filter_sql[] = "a.date_recorded > '{$translated_date}'";
|
1672 |
+
}
|
1673 |
+
}
|
1674 |
+
|
1675 |
+
if ( empty( $filter_sql ) )
|
1676 |
+
return false;
|
1677 |
+
|
1678 |
+
return join( ' AND ', $filter_sql );
|
1679 |
+
}
|
1680 |
+
|
1681 |
+
/**
|
1682 |
+
* Get the date/time of last recorded activity.
|
1683 |
+
*
|
1684 |
+
* @since BuddyPress (1.2.0)
|
1685 |
+
*
|
1686 |
+
* @return string ISO timestamp.
|
1687 |
+
*/
|
1688 |
+
public static function get_last_updated() {
|
1689 |
+
global $wpdb;
|
1690 |
+
|
1691 |
+
$bp = buddypress();
|
1692 |
+
|
1693 |
+
return $wpdb->get_var( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded DESC LIMIT 1" );
|
1694 |
+
}
|
1695 |
+
|
1696 |
+
/**
|
1697 |
+
* Get favorite count for a given user.
|
1698 |
+
*
|
1699 |
+
* @since BuddyPress (1.2.0)
|
1700 |
+
*
|
1701 |
+
* @param int $user_id The ID of the user whose favorites you're counting.
|
1702 |
+
*
|
1703 |
+
* @return int $value A count of the user's favorites.
|
1704 |
+
*/
|
1705 |
+
public static function total_favorite_count( $user_id ) {
|
1706 |
+
|
1707 |
+
// Get activities from user meta
|
1708 |
+
$favorite_activity_entries = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
|
1709 |
+
if ( ! empty( $favorite_activity_entries ) ) {
|
1710 |
+
return count( maybe_unserialize( $favorite_activity_entries ) );
|
1711 |
+
}
|
1712 |
+
|
1713 |
+
// No favorites
|
1714 |
+
return 0;
|
1715 |
+
}
|
1716 |
+
|
1717 |
+
/**
|
1718 |
+
* Check whether an activity item exists with a given string content.
|
1719 |
+
*
|
1720 |
+
* @param string $content The content to filter by.
|
1721 |
+
*
|
1722 |
+
* @return int|bool The ID of the first matching item if found, otherwise false.
|
1723 |
+
*/
|
1724 |
+
public static function check_exists_by_content( $content ) {
|
1725 |
+
global $wpdb;
|
1726 |
+
|
1727 |
+
$bp = buddypress();
|
1728 |
+
|
1729 |
+
return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE content = %s", $content ) );
|
1730 |
+
}
|
1731 |
+
|
1732 |
+
/**
|
1733 |
+
* Hide all activity for a given user.
|
1734 |
+
*
|
1735 |
+
* @param int $user_id The ID of the user whose activity you want to mark hidden.
|
1736 |
+
*
|
1737 |
+
* @return mixed
|
1738 |
+
*/
|
1739 |
+
public static function hide_all_for_user( $user_id ) {
|
1740 |
+
global $wpdb;
|
1741 |
+
|
1742 |
+
$bp = buddypress();
|
1743 |
+
|
1744 |
+
return $wpdb->get_var( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET hide_sitewide = 1 WHERE user_id = %d", $user_id ) );
|
1745 |
+
}
|
1746 |
+
|
1747 |
+
/**
|
1748 |
+
* PHP-agnostic version of {@link array_replace_recursive()}.
|
1749 |
+
*
|
1750 |
+
* array_replace_recursive() is a PHP 5.3 function. BuddyPress (and
|
1751 |
+
* WordPress) currently supports down to PHP 5.2, so this method is a workaround
|
1752 |
+
* for PHP 5.2.
|
1753 |
+
*
|
1754 |
+
* Note: array_replace_recursive() supports infinite arguments, but for our use-
|
1755 |
+
* case, we only need to support two arguments.
|
1756 |
+
*
|
1757 |
+
* Subject to removal once WordPress makes PHP 5.3.0 the minimum requirement.
|
1758 |
+
*
|
1759 |
+
* @since BuddyPress (2.2.0)
|
1760 |
+
*
|
1761 |
+
* @see http://php.net/manual/en/function.array-replace-recursive.php#109390
|
1762 |
+
*
|
1763 |
+
* @param array $base Array with keys needing to be replaced.
|
1764 |
+
* @param array $replacements Array with the replaced keys.
|
1765 |
+
*
|
1766 |
+
* @return array
|
1767 |
+
*/
|
1768 |
+
protected static function array_replace_recursive( $base = array(), $replacements = array() ) {
|
1769 |
+
if ( function_exists( 'array_replace_recursive' ) ) {
|
1770 |
+
return array_replace_recursive( $base, $replacements );
|
1771 |
+
}
|
1772 |
+
|
1773 |
+
// PHP 5.2-compatible version
|
1774 |
+
// http://php.net/manual/en/function.array-replace-recursive.php#109390
|
1775 |
+
foreach ( array_slice( func_get_args(), 1 ) as $replacements ) {
|
1776 |
+
$bref_stack = array( &$base );
|
1777 |
+
$head_stack = array( $replacements );
|
1778 |
+
|
1779 |
+
do {
|
1780 |
+
end( $bref_stack );
|
1781 |
+
|
1782 |
+
$bref = &$bref_stack[ key( $bref_stack ) ];
|
1783 |
+
$head = array_pop( $head_stack );
|
1784 |
+
|
1785 |
+
unset( $bref_stack[ key($bref_stack) ] );
|
1786 |
+
|
1787 |
+
foreach ( array_keys( $head ) as $key ) {
|
1788 |
+
if ( isset( $key, $bref ) && is_array( $bref[$key] ) && is_array( $head[$key] ) ) {
|
1789 |
+
$bref_stack[] = &$bref[ $key ];
|
1790 |
+
$head_stack[] = $head[ $key ];
|
1791 |
+
} else {
|
1792 |
+
$bref[ $key ] = $head[ $key ];
|
1793 |
+
}
|
1794 |
+
}
|
1795 |
+
} while( count( $head_stack ) );
|
1796 |
+
}
|
1797 |
+
|
1798 |
+
return $base;
|
1799 |
+
}
|
1800 |
+
}
|
bp-activity/classes/class-bp-activity-feed.php
ADDED
@@ -0,0 +1,446 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* BuddyPress Activity Classes
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
* @subpackage Activity
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Exit if accessed directly
|
10 |
+
defined( 'ABSPATH' ) || exit;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Create a RSS feed using the activity component.
|
14 |
+
*
|
15 |
+
* You should only construct a new feed when you've validated that you're on
|
16 |
+
* the appropriate screen.
|
17 |
+
*
|
18 |
+
* See {@link bp_activity_action_sitewide_feed()} as an example.
|
19 |
+
*
|
20 |
+
* @param array $args {
|
21 |
+
* @type string $id Required. Internal id for the feed; should be alphanumeric only.
|
22 |
+
* @type string $title Optional. RSS feed title.
|
23 |
+
* @type string $link Optional. Relevant link for the RSS feed.
|
24 |
+
* @type string $description Optional. RSS feed description.
|
25 |
+
* @type string $ttl Optional. Time-to-live. (see inline doc in constructor)
|
26 |
+
* @type string $update_period Optional. Part of the syndication module.
|
27 |
+
* (see inline doc in constructor for more info)
|
28 |
+
* @type string $update_frequency Optional. Part of the syndication module.
|
29 |
+
* (see inline doc in constructor for more info)
|
30 |
+
* @type string $max Optional. Number of feed items to display.
|
31 |
+
* @type array $activity_args Optional. Arguments passed to {@link bp_has_activities()}
|
32 |
+
* }
|
33 |
+
* @since BuddyPress (1.8.0)
|
34 |
+
*/
|
35 |
+
class BP_Activity_Feed {
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Holds our custom class properties.
|
39 |
+
*
|
40 |
+
* These variables are stored in a protected array that is magically
|
41 |
+
* updated using PHP 5.2+ methods.
|
42 |
+
*
|
43 |
+
* @see BP_Feed::__construct() This is where $data is added.
|
44 |
+
* @var array
|
45 |
+
*/
|
46 |
+
protected $data;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Magic method for checking the existence of a certain data variable.
|
50 |
+
*
|
51 |
+
* @param string $key
|
52 |
+
*
|
53 |
+
* @return bool Whether or not data variable exists.
|
54 |
+
*/
|
55 |
+
public function __isset( $key ) { return isset( $this->data[$key] ); }
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Magic method for getting a certain data variable.
|
59 |
+
*
|
60 |
+
* @param string $key
|
61 |
+
*
|
62 |
+
* @return mixed Data in variable if available or null.
|
63 |
+
*/
|
64 |
+
public function __get( $key ) { return isset( $this->data[$key] ) ? $this->data[$key] : null; }
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Constructor.
|
68 |
+
*
|
69 |
+
* @param array $args Optional.
|
70 |
+
*/
|
71 |
+
public function __construct( $args = array() ) {
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Filters if BuddyPress should consider feeds enabled. If disabled, it will return early.
|
75 |
+
*
|
76 |
+
* @since BuddyPress (1.8.0)
|
77 |
+
*
|
78 |
+
* @param bool true Default true aka feeds are enabled.
|
79 |
+
*/
|
80 |
+
if ( false === (bool) apply_filters( 'bp_activity_enable_feeds', true ) ) {
|
81 |
+
global $wp_query;
|
82 |
+
|
83 |
+
// set feed flag to false
|
84 |
+
$wp_query->is_feed = false;
|
85 |
+
|
86 |
+
return false;
|
87 |
+
}
|
88 |
+
|
89 |
+
// Setup data
|
90 |
+
$this->data = wp_parse_args( $args, array(
|
91 |
+
// Internal identifier for the RSS feed - should be alphanumeric only
|
92 |
+
'id' => '',
|
93 |
+
|
94 |
+
// RSS title - should be plain-text
|
95 |
+
'title' => '',
|
96 |
+
|
97 |
+
// relevant link for the RSS feed
|
98 |
+
'link' => '',
|
99 |
+
|
100 |
+
// RSS description - should be plain-text
|
101 |
+
'description' => '',
|
102 |
+
|
103 |
+
// Time-to-live - number of minutes to cache the data before an aggregator
|
104 |
+
// requests it again. This is only acknowledged if the RSS client supports it
|
105 |
+
//
|
106 |
+
// See: http://www.rssboard.org/rss-profile#element-channel-ttl
|
107 |
+
// http://www.kbcafe.com/rss/rssfeedstate.html#ttl
|
108 |
+
'ttl' => '30',
|
109 |
+
|
110 |
+
// Syndication module - similar to ttl, but not really supported by RSS
|
111 |
+
// clients
|
112 |
+
//
|
113 |
+
// See: http://web.resource.org/rss/1.0/modules/syndication/#description
|
114 |
+
// http://www.kbcafe.com/rss/rssfeedstate.html#syndicationmodule
|
115 |
+
'update_period' => 'hourly',
|
116 |
+
'update_frequency' => 2,
|
117 |
+
|
118 |
+
// Number of items to display
|
119 |
+
'max' => 50,
|
120 |
+
|
121 |
+
// Activity arguments passed to bp_has_activities()
|
122 |
+
'activity_args' => array()
|
123 |
+
) );
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Fires before the feed is setup so plugins can modify.
|
127 |
+
*
|
128 |
+
* @since BuddyPress (1.8.0)
|
129 |
+
*
|
130 |
+
* @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
|
131 |
+
*/
|
132 |
+
do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) );
|
133 |
+
|
134 |
+
// Setup class properties
|
135 |
+
$this->setup_properties();
|
136 |
+
|
137 |
+
// Check if id is valid
|
138 |
+
if ( empty( $this->id ) ) {
|
139 |
+
_doing_it_wrong( 'BP_Activity_Feed', __( "RSS feed 'id' must be defined", 'buddypress' ), 'BP 1.8' );
|
140 |
+
return false;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Fires after the feed is setup so plugins can modify.
|
145 |
+
*
|
146 |
+
* @since BuddyPress (1.8.0)
|
147 |
+
*
|
148 |
+
* @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
|
149 |
+
*/
|
150 |
+
do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) );
|
151 |
+
|
152 |
+
// Setup feed hooks
|
153 |
+
$this->setup_hooks();
|
154 |
+
|
155 |
+
// Output the feed
|
156 |
+
$this->output();
|
157 |
+
|
158 |
+
// Kill the rest of the output
|
159 |
+
die();
|
160 |
+
}
|
161 |
+
|
162 |
+
/** SETUP ****************************************************************/
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Setup and validate the class properties.
|
166 |
+
*
|
167 |
+
* @access protected
|
168 |
+
*/
|
169 |
+
protected function setup_properties() {
|
170 |
+
$this->id = sanitize_title( $this->id );
|
171 |
+
$this->title = strip_tags( $this->title );
|
172 |
+
$this->link = esc_url_raw( $this->link );
|
173 |
+
$this->description = strip_tags( $this->description );
|
174 |
+
$this->ttl = (int) $this->ttl;
|
175 |
+
$this->update_period = strip_tags( $this->update_period );
|
176 |
+
$this->update_frequency = (int) $this->update_frequency;
|
177 |
+
|
178 |
+
$this->activity_args = wp_parse_args( $this->activity_args, array(
|
179 |
+
'max' => $this->max,
|
180 |
+
'per_page' => $this->max,
|
181 |
+
'display_comments' => 'stream'
|
182 |
+
) );
|
183 |
+
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Setup some hooks that are used in the feed.
|
188 |
+
*
|
189 |
+
* Currently, these hooks are used to maintain backwards compatibility with
|
190 |
+
* the RSS feeds previous to BP 1.8.
|
191 |
+
*
|
192 |
+
* @access protected
|
193 |
+
*/
|
194 |
+
protected function setup_hooks() {
|
195 |
+
add_action( 'bp_activity_feed_rss_attributes', array( $this, 'backpat_rss_attributes' ) );
|
196 |
+
add_action( 'bp_activity_feed_channel_elements', array( $this, 'backpat_channel_elements' ) );
|
197 |
+
add_action( 'bp_activity_feed_item_elements', array( $this, 'backpat_item_elements' ) );
|
198 |
+
}
|
199 |
+
|
200 |
+
/** BACKPAT HOOKS ********************************************************/
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Fire a hook to ensure backward compatibility for RSS attributes.
|
204 |
+
*/
|
205 |
+
public function backpat_rss_attributes() {
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Fires inside backpat_rss_attributes method for backwards compatibility related to RSS attributes.
|
209 |
+
*
|
210 |
+
* This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
|
211 |
+
*
|
212 |
+
* @since BuddyPress (1.0.0)
|
213 |
+
*/
|
214 |
+
do_action( 'bp_activity_' . $this->id . '_feed' );
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Fire a hook to ensure backward compatibility for channel elements.
|
219 |
+
*/
|
220 |
+
public function backpat_channel_elements() {
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Fires inside backpat_channel_elements method for backwards compatibility related to RSS channel elements.
|
224 |
+
*
|
225 |
+
* This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
|
226 |
+
*
|
227 |
+
* @since BuddyPress (1.0.0)
|
228 |
+
*/
|
229 |
+
do_action( 'bp_activity_' . $this->id . '_feed_head' );
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Fire a hook to ensure backward compatibility for item elements.
|
234 |
+
*/
|
235 |
+
public function backpat_item_elements() {
|
236 |
+
switch ( $this->id ) {
|
237 |
+
|
238 |
+
// sitewide and friends feeds use the 'personal' hook
|
239 |
+
case 'sitewide' :
|
240 |
+
case 'friends' :
|
241 |
+
$id = 'personal';
|
242 |
+
|
243 |
+
break;
|
244 |
+
|
245 |
+
default :
|
246 |
+
$id = $this->id;
|
247 |
+
|
248 |
+
break;
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Fires inside backpat_item_elements method for backwards compatibility related to RSS item elements.
|
253 |
+
*
|
254 |
+
* This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
|
255 |
+
*
|
256 |
+
* @since BuddyPress (1.0.0)
|
257 |
+
*/
|
258 |
+
do_action( 'bp_activity_' . $id . '_feed_item' );
|
259 |
+
}
|
260 |
+
|
261 |
+
/** HELPERS **************************************************************/
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Output the feed's item content.
|
265 |
+
*
|
266 |
+
* @access protected
|
267 |
+
*/
|
268 |
+
protected function feed_content() {
|
269 |
+
bp_activity_content_body();
|
270 |
+
|
271 |
+
switch ( $this->id ) {
|
272 |
+
|
273 |
+
// also output parent activity item if we're on a specific feed
|
274 |
+
case 'favorites' :
|
275 |
+
case 'friends' :
|
276 |
+
case 'mentions' :
|
277 |
+
case 'personal' :
|
278 |
+
|
279 |
+
if ( 'activity_comment' == bp_get_activity_action_name() ) :
|
280 |
+
?>
|
281 |
+
<strong><?php _e( 'In reply to', 'buddypress' ) ?></strong> -
|
282 |
+
<?php bp_activity_parent_content() ?>
|
283 |
+
<?php
|
284 |
+
endif;
|
285 |
+
|
286 |
+
break;
|
287 |
+
}
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Sets various HTTP headers related to Content-Type and browser caching.
|
292 |
+
*
|
293 |
+
* Most of this class method is derived from {@link WP::send_headers()}.
|
294 |
+
*
|
295 |
+
* @since BuddyPress (1.9.0)
|
296 |
+
*
|
297 |
+
* @access protected
|
298 |
+
*/
|
299 |
+
protected function http_headers() {
|
300 |
+
// set up some additional headers if not on a directory page
|
301 |
+
// this is done b/c BP uses pseudo-pages
|
302 |
+
if ( ! bp_is_directory() ) {
|
303 |
+
global $wp_query;
|
304 |
+
|
305 |
+
$wp_query->is_404 = false;
|
306 |
+
status_header( 200 );
|
307 |
+
}
|
308 |
+
|
309 |
+
// Set content-type
|
310 |
+
@header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
|
311 |
+
send_nosniff_header();
|
312 |
+
|
313 |
+
// Cache-related variables
|
314 |
+
$last_modified = mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false );
|
315 |
+
$modified_timestamp = strtotime( $last_modified );
|
316 |
+
$etag = md5( $last_modified );
|
317 |
+
|
318 |
+
// Set cache-related headers
|
319 |
+
@header( 'Last-Modified: ' . $last_modified );
|
320 |
+
@header( 'Pragma: no-cache' );
|
321 |
+
@header( 'ETag: ' . '"' . $etag . '"' );
|
322 |
+
|
323 |
+
// First commit of BuddyPress! (Easter egg)
|
324 |
+
@header( 'Expires: Tue, 25 Mar 2008 17:13:55 GMT');
|
325 |
+
|
326 |
+
// Get ETag from supported user agents
|
327 |
+
if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) {
|
328 |
+
$client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] );
|
329 |
+
|
330 |
+
// Remove quotes from ETag
|
331 |
+
$client_etag = trim( $client_etag, '"' );
|
332 |
+
|
333 |
+
// Strip suffixes from ETag if they exist (eg. "-gzip")
|
334 |
+
$etag_suffix_pos = strpos( $client_etag, '-' );
|
335 |
+
if ( ! empty( $etag_suffix_pos ) ) {
|
336 |
+
$client_etag = substr( $client_etag, 0, $etag_suffix_pos );
|
337 |
+
}
|
338 |
+
|
339 |
+
// No ETag found
|
340 |
+
} else {
|
341 |
+
$client_etag = false;
|
342 |
+
}
|
343 |
+
|
344 |
+
// Get client last modified timestamp from supported user agents
|
345 |
+
$client_last_modified = empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? '' : trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
|
346 |
+
$client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
|
347 |
+
|
348 |
+
// Set 304 status if feed hasn't been updated since last fetch
|
349 |
+
if ( ( $client_last_modified && $client_etag ) ?
|
350 |
+
( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) ) :
|
351 |
+
( ( $client_modified_timestamp >= $modified_timestamp ) || ( $client_etag == $etag ) ) ) {
|
352 |
+
$status = 304;
|
353 |
+
} else {
|
354 |
+
$status = false;
|
355 |
+
}
|
356 |
+
|
357 |
+
// If feed hasn't changed as reported by the user agent, set 304 status header
|
358 |
+
if ( ! empty( $status ) ) {
|
359 |
+
status_header( $status );
|
360 |
+
|
361 |
+
// cached response, so stop now!
|
362 |
+
if ( $status == 304 ) {
|
363 |
+
exit();
|
364 |
+
}
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
/** OUTPUT ***************************************************************/
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Output the RSS feed.
|
372 |
+
*
|
373 |
+
* @access protected
|
374 |
+
*/
|
375 |
+
protected function output() {
|
376 |
+
$this->http_headers();
|
377 |
+
echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?'.'>';
|
378 |
+
?>
|
379 |
+
|
380 |
+
<rss version="2.0"
|
381 |
+
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
382 |
+
xmlns:atom="http://www.w3.org/2005/Atom"
|
383 |
+
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
|
384 |
+
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
|
385 |
+
<?php
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Fires at the end of the opening RSS tag for feed output so plugins can add extra attributes.
|
389 |
+
*
|
390 |
+
* @since BuddyPress (1.8.0)
|
391 |
+
*/
|
392 |
+
do_action( 'bp_activity_feed_rss_attributes' ); ?>
|
393 |
+
>
|
394 |
+
|
395 |
+
<channel>
|
396 |
+
<title><?php echo $this->title; ?></title>
|
397 |
+
<link><?php echo $this->link; ?></link>
|
398 |
+
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
399 |
+
<description><?php echo $this->description ?></description>
|
400 |
+
<lastBuildDate><?php echo mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false ); ?></lastBuildDate>
|
401 |
+
<generator>https://buddypress.org/?v=<?php bp_version(); ?></generator>
|
402 |
+
<language><?php bloginfo_rss( 'language' ); ?></language>
|
403 |
+
<ttl><?php echo $this->ttl; ?></ttl>
|
404 |
+
<sy:updatePeriod><?php echo $this->update_period; ?></sy:updatePeriod>
|
405 |
+
<sy:updateFrequency><?php echo $this->update_frequency; ?></sy:updateFrequency>
|
406 |
+
<?php
|
407 |
+
|
408 |
+
/**
|
409 |
+
* Fires at the end of channel elements list in RSS feed so plugins can add extra channel elements.
|
410 |
+
*
|
411 |
+
* @since BuddyPress (1.8.0)
|
412 |
+
*/
|
413 |
+
do_action( 'bp_activity_feed_channel_elements' ); ?>
|
414 |
+
|
415 |
+
<?php if ( bp_has_activities( $this->activity_args ) ) : ?>
|
416 |
+
<?php while ( bp_activities() ) : bp_the_activity(); ?>
|
417 |
+
<item>
|
418 |
+
<guid isPermaLink="false"><?php bp_activity_feed_item_guid(); ?></guid>
|
419 |
+
<title><?php echo stripslashes( bp_get_activity_feed_item_title() ); ?></title>
|
420 |
+
<link><?php bp_activity_thread_permalink() ?></link>
|
421 |
+
<pubDate><?php echo mysql2date( 'D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false ); ?></pubDate>
|
422 |
+
|
423 |
+
<?php if ( bp_get_activity_feed_item_description() ) : ?>
|
424 |
+
<content:encoded><![CDATA[<?php $this->feed_content(); ?>]]></content:encoded>
|
425 |
+
<?php endif; ?>
|
426 |
+
|
427 |
+
<?php if ( bp_activity_can_comment() ) : ?>
|
428 |
+
<slash:comments><?php bp_activity_comment_count(); ?></slash:comments>
|
429 |
+
<?php endif; ?>
|
430 |
+
|
431 |
+
<?php
|
432 |
+
|
433 |
+
/**
|
434 |
+
* Fires at the end of the individual RSS Item list in RSS feed so plugins can add extra item elements.
|
435 |
+
*
|
436 |
+
* @since BuddyPress (1.8.0)
|
437 |
+
*/
|
438 |
+
do_action( 'bp_activity_feed_item_elements' ); ?>
|
439 |
+
</item>
|
440 |
+
<?php endwhile; ?>
|
441 |
+
|
442 |
+
<?php endif; ?>
|
443 |
+
</channel>
|
444 |
+
</rss><?php
|
445 |
+
}
|
446 |
+
}
|
bp-activity/classes/class-bp-activity-query.php
ADDED
@@ -0,0 +1,258 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* BuddyPress Activity Classes
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
* @subpackage Activity
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Exit if accessed directly
|
10 |
+
defined( 'ABSPATH' ) || exit;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class for generating the WHERE SQL clause for advanced activity fetching.
|
14 |
+
*
|
15 |
+
* This is notably used in {@link BP_Activity_Activity::get()} with the
|
16 |
+
* 'filter_query' parameter.
|
17 |
+
*
|
18 |
+
* @since BuddyPress (2.2.0)
|
19 |
+
*/
|
20 |
+
class BP_Activity_Query extends BP_Recursive_Query {
|
21 |
+
/**
|
22 |
+
* Array of activity queries.
|
23 |
+
*
|
24 |
+
* See {@see BP_Activity_Query::__construct()} for information on query arguments.
|
25 |
+
*
|
26 |
+
* @since BuddyPress (2.2.0)
|
27 |
+
* @access public
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
public $queries = array();
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Table alias.
|
34 |
+
*
|
35 |
+
* @since BuddyPress (2.2.0)
|
36 |
+
* @access public
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
public $table_alias = '';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Supported DB columns.
|
43 |
+
*
|
44 |
+
* See the 'wp_bp_activity' DB table schema.
|
45 |
+
*
|
46 |
+
* @since BuddyPress (2.2.0)
|
47 |
+
* @access public
|
48 |
+
* @var array
|
49 |
+
*/
|
50 |
+
public $db_columns = array(
|
51 |
+
'id', 'user_id', 'component', 'type', 'action', 'content',
|
52 |
+
'item_id', 'secondary_item_id', 'hide_sitewide', 'is_spam',
|
53 |
+
);
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Constructor.
|
57 |
+
*
|
58 |
+
* @since BuddyPress (2.2.0)
|
59 |
+
*
|
60 |
+
* @param array $query {
|
61 |
+
* Array of query clauses.
|
62 |
+
*
|
63 |
+
* @type array {
|
64 |
+
* @type string $column Required. The column to query against. Basically, any DB column in the main
|
65 |
+
* 'wp_bp_activity' table.
|
66 |
+
* @type string $value Required. Value to filter by.
|
67 |
+
* @type string $compare Optional. The comparison operator. Default '='.
|
68 |
+
* Accepts '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'LIKE',
|
69 |
+
* 'NOT LIKE', BETWEEN', 'NOT BETWEEN', 'REGEXP', 'NOT REGEXP', 'RLIKE'.
|
70 |
+
* @type string $relation Optional. The boolean relationship between the activity queries.
|
71 |
+
* Accepts 'OR', 'AND'. Default 'AND'.
|
72 |
+
* @type array {
|
73 |
+
* Optional. Another fully-formed activity query. See parameters above.
|
74 |
+
* }
|
75 |
+
* }
|
76 |
+
* }
|
77 |
+
*/
|
78 |
+
public function __construct( $query = array() ) {
|
79 |
+
if ( ! is_array( $query ) ) {
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
|
83 |
+
$this->queries = $this->sanitize_query( $query );
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Generates WHERE SQL clause to be appended to a main query.
|
88 |
+
*
|
89 |
+
* @since BuddyPress (2.2.0)
|
90 |
+
* @access public
|
91 |
+
*
|
92 |
+
* @param string $alias An existing table alias that is compatible with the current query clause.
|
93 |
+
* Default: 'a'. BP_Activity_Activity::get() uses 'a', so we default to that.
|
94 |
+
*
|
95 |
+
* @return string SQL fragment to append to the main WHERE clause.
|
96 |
+
*/
|
97 |
+
public function get_sql( $alias = 'a' ) {
|
98 |
+
if ( ! empty( $alias ) ) {
|
99 |
+
$this->table_alias = sanitize_title( $alias );
|
100 |
+
}
|
101 |
+
|
102 |
+
$sql = $this->get_sql_clauses();
|
103 |
+
|
104 |
+
// we only need the 'where' clause
|
105 |
+
//
|
106 |
+
// also trim trailing "AND" clause from parent BP_Recursive_Query class
|
107 |
+
// since it's not necessary for our needs
|
108 |
+
return preg_replace( '/^\sAND/', '', $sql['where'] );
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Generate WHERE clauses for a first-order clause.
|
113 |
+
*
|
114 |
+
* @since BuddyPress (2.2.0)
|
115 |
+
* @access protected
|
116 |
+
*
|
117 |
+
* @param array $clause Array of arguments belonging to the clause.
|
118 |
+
* @param array $parent_query Parent query to which the clause belongs.
|
119 |
+
*
|
120 |
+
* @return array {
|
121 |
+
* @type array $where Array of subclauses for the WHERE statement.
|
122 |
+
* @type array $join Empty array. Not used.
|
123 |
+
* }
|
124 |
+
*/
|
125 |
+
protected function get_sql_for_clause( $clause, $parent_query ) {
|
126 |
+
global $wpdb;
|
127 |
+
|
128 |
+
$sql_chunks = array(
|
129 |
+
'where' => array(),
|
130 |
+
'join' => array(),
|
131 |
+
);
|
132 |
+
|
133 |
+
$column = isset( $clause['column'] ) ? $this->validate_column( $clause['column'] ) : '';
|
134 |
+
$value = isset( $clause['value'] ) ? $clause['value'] : '';
|
135 |
+
if ( empty( $column ) || ! isset( $clause['value'] ) ) {
|
136 |
+
return $sql_chunks;
|
137 |
+
}
|
138 |
+
|
139 |
+
if ( isset( $clause['compare'] ) ) {
|
140 |
+
$clause['compare'] = strtoupper( $clause['compare'] );
|
141 |
+
} else {
|
142 |
+
$clause['compare'] = isset( $clause['value'] ) && is_array( $clause['value'] ) ? 'IN' : '=';
|
143 |
+
}
|
144 |
+
|
145 |
+
// default 'compare' to '=' if no valid operator is found
|
146 |
+
if ( ! in_array( $clause['compare'], array(
|
147 |
+
'=', '!=', '>', '>=', '<', '<=',
|
148 |
+
'LIKE', 'NOT LIKE',
|
149 |
+
'IN', 'NOT IN',
|
150 |
+
'BETWEEN', 'NOT BETWEEN',
|
151 |
+
'REGEXP', 'NOT REGEXP', 'RLIKE'
|
152 |
+
) ) ) {
|
153 |
+
$clause['compare'] = '=';
|
154 |
+
}
|
155 |
+
|
156 |
+
$compare = $clause['compare'];
|
157 |
+
|
158 |
+
$alias = ! empty( $this->table_alias ) ? "{$this->table_alias}." : '';
|
159 |
+
|
160 |
+
// Next, Build the WHERE clause.
|
161 |
+
$where = '';
|
162 |
+
|
163 |
+
// value.
|
164 |
+
if ( isset( $clause['value'] ) ) {
|
165 |
+
if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
|
166 |
+
if ( ! is_array( $value ) ) {
|
167 |
+
$value = preg_split( '/[,\s]+/', $value );
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
// tinyint
|
172 |
+
if ( ! empty( $column ) && true === in_array( $column, array( 'hide_sitewide', 'is_spam' ) ) ) {
|
173 |
+
$sql_chunks['where'][] = $wpdb->prepare( "{$alias}{$column} = %d", $value );
|
174 |
+
|
175 |
+
} else {
|
176 |
+
switch ( $compare ) {
|
177 |
+
// IN uses different syntax
|
178 |
+
case 'IN' :
|
179 |
+
case 'NOT IN' :
|
180 |
+
$in_sql = BP_Activity_Activity::get_in_operator_sql( "{$alias}{$column}", $value );
|
181 |
+
|
182 |
+
// 'NOT IN' operator is as easy as a string replace!
|
183 |
+
if ( 'NOT IN' === $compare ) {
|
184 |
+
$in_sql = str_replace( 'IN', 'NOT IN', $in_sql );
|
185 |
+
}
|
186 |
+
|
187 |
+
$sql_chunks['where'][] = $in_sql;
|
188 |
+
break;
|
189 |
+
|
190 |
+
case 'BETWEEN' :
|
191 |
+
case 'NOT BETWEEN' :
|
192 |
+
$value = array_slice( $value, 0, 2 );
|
193 |
+
$where = $wpdb->prepare( '%s AND %s', $value );
|
194 |
+
break;
|
195 |
+
|
196 |
+
case 'LIKE' :
|
197 |
+
case 'NOT LIKE' :
|
198 |
+
$value = '%' . bp_esc_like( $value ) . '%';
|
199 |
+
$where = $wpdb->prepare( '%s', $value );
|
200 |
+
break;
|
201 |
+
|
202 |
+
default :
|
203 |
+
$where = $wpdb->prepare( '%s', $value );
|
204 |
+
break;
|
205 |
+
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
if ( $where ) {
|
210 |
+
$sql_chunks['where'][] = "{$alias}{$column} {$compare} {$where}";
|
211 |
+
}
|
212 |
+
}
|
213 |
+
|
214 |
+
/*
|
215 |
+
* Multiple WHERE clauses should be joined in parentheses.
|
216 |
+
*/
|
217 |
+
if ( 1 < count( $sql_chunks['where'] ) ) {
|
218 |
+
$sql_chunks['where'] = array( '( ' . implode( ' AND ', $sql_chunks['where'] ) . ' )' );
|
219 |
+
}
|
220 |
+
|
221 |
+
return $sql_chunks;
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Determine whether a clause is first-order.
|
226 |
+
*
|
227 |
+
* @since BuddyPress (2.2.0)
|
228 |
+
* @access protected
|
229 |
+
*
|
230 |
+
* @param array $query Clause to check.
|
231 |
+
*
|
232 |
+
* @return bool
|
233 |
+
*/
|
234 |
+
protected function is_first_order_clause( $query ) {
|
235 |
+
return isset( $query['column'] ) || isset( $query['value'] );
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Validates a column name parameter.
|
240 |
+
*
|
241 |
+
* Column names are checked against a whitelist of known tables.
|
242 |
+
* See {@link BP_Activity_Query::db_tables}.
|
243 |
+
*
|
244 |
+
* @since BuddyPress (2.2.0)
|
245 |
+
* @access public
|
246 |
+
*
|
247 |
+
* @param string $column The user-supplied column name.
|
248 |
+
*
|
249 |
+
* @return string A validated column name value.
|
250 |
+
*/
|
251 |
+
public function validate_column( $column = '' ) {
|
252 |
+
if ( in_array( $column, $this->db_columns ) ) {
|
253 |
+
return $column;
|
254 |
+
} else {
|
255 |
+
return '';
|
256 |
+
}
|
257 |
+
}
|
258 |
+
}
|
bp-activity/js/mentions.js
CHANGED
@@ -1,7 +1,18 @@
|
|
1 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2 |
Â
var mentionsQueryCache = [],
|
3 |
Â
mentionsItem;
|
4 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Adds BuddyPress @mentions to form inputs.
|
7 |
Â
*
|
@@ -228,34 +239,17 @@
|
|
228 |
Â
};
|
229 |
Â
|
230 |
Â
$( document ).ready(function() {
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
if ( typeof window.BP_Suggestions === 'object' ) {
|
236 |
-
users = window.BP_Suggestions.friends || users;
|
237 |
-
}
|
238 |
-
|
239 |
-
// Dashboard post 'visual' editor.
|
240 |
-
loadMentionsInTinyMCE = function() {
|
241 |
-
if ( loadAttempts < 4 || ! $( 'body' ).hasClass( 'wp-admin' ) ) {
|
242 |
-
loadAttempts++;
|
243 |
-
|
244 |
-
if ( typeof window.tinyMCE === 'undefined' || window.tinyMCE.activeEditor === null || typeof window.tinyMCE.activeEditor === 'undefined' ) {
|
245 |
-
setTimeout( loadMentionsInTinyMCE, 500 );
|
246 |
-
return;
|
247 |
-
}
|
248 |
-
}
|
249 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
250 |
Â
$( window.tinyMCE.activeEditor.contentDocument.activeElement )
|
251 |
Â
.atwho( 'setIframe', $( '#content_ifr' )[0] )
|
252 |
-
.bp_mentions( users );
|
253 |
-
}
|
254 |
-
|
255 |
-
|
256 |
-
$( '.bp-suggestions, #comments form textarea, .wp-editor-area' ).bp_mentions( users );
|
257 |
-
|
258 |
-
// Dashboard post 'visual' editor.
|
259 |
-
loadMentionsInTinyMCE();
|
260 |
-
});
|
261 |
-
})( jQuery );
|
1 |
+
/* global bp */
|
2 |
+
|
3 |
+
window.bp = window.bp || {};
|
4 |
+
|
5 |
+
( function( bp, $, undefined ) {
|
6 |
Â
var mentionsQueryCache = [],
|
7 |
Â
mentionsItem;
|
8 |
Â
|
9 |
+
bp.mentions = bp.mentions || {};
|
10 |
+
bp.mentions.users = window.bp.mentions.users || [];
|
11 |
+
|
12 |
+
if ( typeof window.BP_Suggestions === 'object' ) {
|
13 |
+
bp.mentions.users = window.BP_Suggestions.friends || bp.mentions.users;
|
14 |
+
}
|
15 |
+
|
16 |
Â
/**
|
17 |
Â
* Adds BuddyPress @mentions to form inputs.
|
18 |
Â
*
|
239 |
Â
};
|
240 |
Â
|
241 |
Â
$( document ).ready(function() {
|
242 |
+
// Activity/reply, post comments, dashboard post 'text' editor.
|
243 |
+
$( '.bp-suggestions, #comments form textarea, .wp-editor-area' ).bp_mentions( bp.mentions.users );
|
244 |
+
});
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
245 |
Â
|
246 |
+
bp.mentions.tinyMCEinit = function() {
|
247 |
+
if ( typeof window.tinyMCE === 'undefined' || window.tinyMCE.activeEditor === null || typeof window.tinyMCE.activeEditor === 'undefined' ) {
|
248 |
+
return;
|
249 |
+
} else {
|
250 |
Â
$( window.tinyMCE.activeEditor.contentDocument.activeElement )
|
251 |
Â
.atwho( 'setIframe', $( '#content_ifr' )[0] )
|
252 |
+
.bp_mentions( bp.mentions.users );
|
253 |
+
}
|
254 |
+
};
|
255 |
+
})( bp, jQuery );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
bp-activity/js/mentions.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
/*! buddypress - v2.
|
2 |
-
|
1 |
+
/*! buddypress - v2.3.5 - 2015-11-11 5:23:00 AM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
window.bp=window.bp||{},function(a,b){var c,d=[];a.mentions=a.mentions||{},a.mentions.users=window.bp.mentions.users||[],"object"==typeof window.BP_Suggestions&&(a.mentions.users=window.BP_Suggestions.friends||a.mentions.users),b.fn.bp_mentions=function(a){b.isArray(a)&&(a={data:a});var e={delay:200,hide_without_suffix:!0,insert_tpl:"</>${atwho-data-value}</>",limit:10,start_with_space:!1,suffix:"",callbacks:{filter:function(a,b,c){var d,e,f,g=[],h=new RegExp("^"+a+"| "+a,"ig");for(e=0,f=b.length;f>e;e++)d=b[e],d[c].toLowerCase().match(h)&&g.push(d);return g},highlighter:function(a,b){if(!b)return a;var c=new RegExp(">(\\s*|[\\w\\s]*)("+this.at.replace("+","\\+")+"?"+b.replace("+","\\+")+")([\\w ]*)\\s*<","ig");return a.replace(c,function(a,b,c,d){return">"+b+"<strong>"+c+"</strong>"+d+"<"})},before_reposition:function(a){var c,d,e,f,g=b("#atwho-ground-"+this.id+" .atwho-view"),h=b("body"),i=this.$inputor.data("atwho");"undefined"!==i&&"undefined"!==i.iframe&&null!==i.iframe?(c=this.$inputor.caret("offset",{iframe:i.iframe}),e=b(i.iframe).offset(),"undefined"!==e&&(c.left+=e.left,c.top+=e.top)):c=this.$inputor.caret("offset"),c.left>h.width()/2?(g.addClass("right"),f=c.left-a.left-this.view.$el.width()):(g.removeClass("right"),f=c.left-a.left+1),h.width()<=400&&b(document).scrollTop(c.top-6),d=parseInt(this.$inputor.css("line-height").substr(0,this.$inputor.css("line-height").length-2),10),(!d||5>d)&&(d=19),a.top=c.top+d,a.left+=f},inserting_wrapper:function(a,b,c){return""+b+c}}},f={callbacks:{remote_filter:function(a,e){var f=b(this),g={};return c=d[a],"object"==typeof c?void e(c):(f.xhr&&f.xhr.abort(),g={action:"bp_get_suggestions",term:a,type:"members"},b.isNumeric(this.$inputor.data("suggestions-group-id"))&&(g["group-id"]=parseInt(this.$inputor.data("suggestions-group-id"),10)),void(f.xhr=b.getJSON(ajaxurl,g).done(function(c){if(c.success){var f=b.map(c.data,function(a){return a.search=a.search||a.ID+" "+a.name,a});d[a]=f,e(f)}})))}},data:b.map(a.data,function(a){return a.search=a.search||a.ID+" "+a.name,a}),at:"@",search_key:"search",tpl:'<li data-value="@${ID}"><img src="${image}" /><span class="username">@${ID}</span><small>${name}</small></li>'},g=b.extend(!0,{},e,f,a);return b.fn.atwho.call(this,g)},b(document).ready(function(){b(".bp-suggestions, #comments form textarea, .wp-editor-area").bp_mentions(a.mentions.users)}),a.mentions.tinyMCEinit=function(){"undefined"!=typeof window.tinyMCE&&null!==window.tinyMCE.activeEditor&&"undefined"!=typeof window.tinyMCE.activeEditor&&b(window.tinyMCE.activeEditor.contentDocument.activeElement).atwho("setIframe",b("#content_ifr")[0]).bp_mentions(a.mentions.users)}}(bp,jQuery);
|
bp-blogs/bp-blogs-activity.php
CHANGED
@@ -15,12 +15,10 @@ defined( 'ABSPATH' ) || exit;
|
|
15 |
Â
*
|
16 |
Â
* @since BuddyPress (1.0.0)
|
17 |
Â
*
|
18 |
-
* @global object $bp The BuddyPress global settings object.
|
19 |
-
*
|
20 |
Â
* @return bool|null Returns false if activity component is not active.
|
21 |
Â
*/
|
22 |
Â
function bp_blogs_register_activity_actions() {
|
23 |
-
|
24 |
Â
|
25 |
Â
// Bail if activity is not active
|
26 |
Â
if ( ! bp_is_active( 'activity' ) ) {
|
@@ -34,6 +32,7 @@ function bp_blogs_register_activity_actions() {
|
|
34 |
Â
__( 'New site created', 'buddypress' ),
|
35 |
Â
'bp_blogs_format_activity_action_new_blog',
|
36 |
Â
__( 'New Sites', 'buddypress' ),
|
Â
|
|
37 |
Â
0
|
38 |
Â
);
|
39 |
Â
}
|
@@ -321,7 +320,6 @@ add_filter( 'bp_activity_prefetch_object_data', 'bp_blogs_prefetch_activity_obje
|
|
321 |
Â
* @since BuddyPress (1.0.0)
|
322 |
Â
*
|
323 |
Â
* @see bp_activity_add() for description of parameters.
|
324 |
-
* @global object $bp The BuddyPress global settings object.
|
325 |
Â
*
|
326 |
Â
* @param array $args {
|
327 |
Â
* See {@link bp_activity_add()} for complete description of arguments.
|
@@ -332,13 +330,14 @@ add_filter( 'bp_activity_prefetch_object_data', 'bp_blogs_prefetch_activity_obje
|
|
332 |
Â
* @return int|bool On success, returns the activity ID. False on failure.
|
333 |
Â
*/
|
334 |
Â
function bp_blogs_record_activity( $args = '' ) {
|
335 |
-
global $bp;
|
336 |
Â
|
337 |
Â
// Bail if activity is not active
|
338 |
Â
if ( ! bp_is_active( 'activity' ) ) {
|
339 |
Â
return false;
|
340 |
Â
}
|
341 |
Â
|
Â
|
|
Â
|
|
342 |
Â
$defaults = array(
|
343 |
Â
'user_id' => bp_loggedin_user_id(),
|
344 |
Â
'action' => '',
|
@@ -354,11 +353,6 @@ function bp_blogs_record_activity( $args = '' ) {
|
|
354 |
Â
|
355 |
Â
$r = wp_parse_args( $args, $defaults );
|
356 |
Â
|
357 |
-
// Remove large images and replace them with just one image thumbnail
|
358 |
-
if ( ! empty( $r['content'] ) ) {
|
359 |
-
$r['content'] = bp_activity_thumbnail_content_images( $r['content'], $r['primary_link'], $r );
|
360 |
-
}
|
361 |
-
|
362 |
Â
if ( ! empty( $r['action'] ) ) {
|
363 |
Â
|
364 |
Â
/**
|
@@ -378,11 +372,11 @@ function bp_blogs_record_activity( $args = '' ) {
|
|
378 |
Â
*
|
379 |
Â
* @since BuddyPress (1.2.0)
|
380 |
Â
*
|
381 |
-
* @param string $value Generated
|
382 |
Â
* @param string $value Content for the activity stream.
|
383 |
Â
* @param array $r Array of arguments used for the activity stream item.
|
384 |
Â
*/
|
385 |
-
$r['content'] = apply_filters( 'bp_blogs_record_activity_content',
|
386 |
Â
}
|
387 |
Â
|
388 |
Â
// Check for an existing entry and update if one exists.
|
15 |
Â
*
|
16 |
Â
* @since BuddyPress (1.0.0)
|
17 |
Â
*
|
Â
|
|
Â
|
|
18 |
Â
* @return bool|null Returns false if activity component is not active.
|
19 |
Â
*/
|
20 |
Â
function bp_blogs_register_activity_actions() {
|
21 |
+
$bp = buddypress();
|
22 |
Â
|
23 |
Â
// Bail if activity is not active
|
24 |
Â
if ( ! bp_is_active( 'activity' ) ) {
|
32 |
Â
__( 'New site created', 'buddypress' ),
|
33 |
Â
'bp_blogs_format_activity_action_new_blog',
|
34 |
Â
__( 'New Sites', 'buddypress' ),
|
35 |
+
array( 'activity', 'member' ),
|
36 |
Â
0
|
37 |
Â
);
|
38 |
Â
}
|
320 |
Â
* @since BuddyPress (1.0.0)
|
321 |
Â
*
|
322 |
Â
* @see bp_activity_add() for description of parameters.
|
Â
|
|
323 |
Â
*
|
324 |
Â
* @param array $args {
|
325 |
Â
* See {@link bp_activity_add()} for complete description of arguments.
|
330 |
Â
* @return int|bool On success, returns the activity ID. False on failure.
|
331 |
Â
*/
|
332 |
Â
function bp_blogs_record_activity( $args = '' ) {
|
Â
|
|
333 |
Â
|
334 |
Â
// Bail if activity is not active
|
335 |
Â
if ( ! bp_is_active( 'activity' ) ) {
|
336 |
Â
return false;
|
337 |
Â
}
|
338 |
Â
|
339 |
+
$bp = buddypress();
|
340 |
+
|
341 |
Â
$defaults = array(
|
342 |
Â
'user_id' => bp_loggedin_user_id(),
|
343 |
Â
'action' => '',
|
353 |
Â
|
354 |
Â
$r = wp_parse_args( $args, $defaults );
|
355 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
356 |
Â
if ( ! empty( $r['action'] ) ) {
|
357 |
Â
|
358 |
Â
/**
|
372 |
Â
*
|
373 |
Â
* @since BuddyPress (1.2.0)
|
374 |
Â
*
|
375 |
+
* @param string $value Generated summary from content for the activity stream.
|
376 |
Â
* @param string $value Content for the activity stream.
|
377 |
Â
* @param array $r Array of arguments used for the activity stream item.
|
378 |
Â
*/
|
379 |
+
$r['content'] = apply_filters( 'bp_blogs_record_activity_content', bp_activity_create_summary( $r['content'], $r ), $r['content'], $r );
|
380 |
Â
}
|
381 |
Â
|
382 |
Â
// Check for an existing entry and update if one exists.
|
bp-blogs/bp-blogs-classes.php
CHANGED
@@ -10,567 +10,4 @@
|
|
10 |
Â
// Exit if accessed directly
|
11 |
Â
defined( 'ABSPATH' ) || exit;
|
12 |
Â
|
13 |
-
|
14 |
-
* The main BuddyPress blog class.
|
15 |
-
*
|
16 |
-
* A BP_Blogs_Object represents a link between a specific WordPress blog on a
|
17 |
-
* network and a specific user on that blog.
|
18 |
-
*
|
19 |
-
* @since BuddyPress (1.0.0)
|
20 |
-
*/
|
21 |
-
class BP_Blogs_Blog {
|
22 |
-
public $id;
|
23 |
-
public $user_id;
|
24 |
-
public $blog_id;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Constructor method.
|
28 |
-
*
|
29 |
-
* @param int $id Optional. The ID of the blog.
|
30 |
-
*/
|
31 |
-
public function __construct( $id = null ) {
|
32 |
-
if ( !empty( $id ) ) {
|
33 |
-
$this->id = $id;
|
34 |
-
$this->populate();
|
35 |
-
}
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Populate the object with data about the specific activity item.
|
40 |
-
*/
|
41 |
-
public function populate() {
|
42 |
-
global $wpdb, $bp;
|
43 |
-
|
44 |
-
$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name} WHERE id = %d", $this->id ) );
|
45 |
-
|
46 |
-
$this->user_id = $blog->user_id;
|
47 |
-
$this->blog_id = $blog->blog_id;
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Save the BP blog data to the database.
|
52 |
-
*
|
53 |
-
* @return bool True on success, false on failure.
|
54 |
-
*/
|
55 |
-
public function save() {
|
56 |
-
global $wpdb, $bp;
|
57 |
-
|
58 |
-
$this->user_id = apply_filters( 'bp_blogs_blog_user_id_before_save', $this->user_id, $this->id );
|
59 |
-
$this->blog_id = apply_filters( 'bp_blogs_blog_id_before_save', $this->blog_id, $this->id );
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Fires before the current blog item gets saved.
|
63 |
-
*
|
64 |
-
* Please use this hook to filter the properties above. Each part will be passed in.
|
65 |
-
*
|
66 |
-
* @since BuddyPress (1.0.0)
|
67 |
-
*
|
68 |
-
* @param BP_Blogs_Blog Current instance of the blog item being saved. Passed by reference.
|
69 |
-
*/
|
70 |
-
do_action_ref_array( 'bp_blogs_blog_before_save', array( &$this ) );
|
71 |
-
|
72 |
-
// Don't try and save if there is no user ID or blog ID set.
|
73 |
-
if ( !$this->user_id || !$this->blog_id )
|
74 |
-
return false;
|
75 |
-
|
76 |
-
// Don't save if this blog has already been recorded for the user.
|
77 |
-
if ( !$this->id && $this->exists() )
|
78 |
-
return false;
|
79 |
-
|
80 |
-
if ( $this->id ) {
|
81 |
-
// Update
|
82 |
-
$sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name} SET user_id = %d, blog_id = %d WHERE id = %d", $this->user_id, $this->blog_id, $this->id );
|
83 |
-
} else {
|
84 |
-
// Save
|
85 |
-
$sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name} ( user_id, blog_id ) VALUES ( %d, %d )", $this->user_id, $this->blog_id );
|
86 |
-
}
|
87 |
-
|
88 |
-
if ( !$wpdb->query($sql) )
|
89 |
-
return false;
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Fires after the current blog item gets saved.
|
93 |
-
*
|
94 |
-
* Please use this hook to filter the properties above. Each part will be passed in.
|
95 |
-
*
|
96 |
-
* @since BuddyPress (1.0.0)
|
97 |
-
*
|
98 |
-
* @param BP_Blogs_Blog Current instance of the blog item being saved. Passed by reference.
|
99 |
-
*/
|
100 |
-
do_action_ref_array( 'bp_blogs_blog_after_save', array( &$this ) );
|
101 |
-
|
102 |
-
if ( $this->id )
|
103 |
-
return $this->id;
|
104 |
-
else
|
105 |
-
return $wpdb->insert_id;
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Check whether an association between this user and this blog exists.
|
110 |
-
*
|
111 |
-
* @return int The number of associations between the user and blog
|
112 |
-
* saved in the blog component tables.
|
113 |
-
*/
|
114 |
-
public function exists() {
|
115 |
-
global $bp, $wpdb;
|
116 |
-
|
117 |
-
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $this->user_id, $this->blog_id ) );
|
118 |
-
}
|
119 |
-
|
120 |
-
/** Static Methods ***************************************************/
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Retrieve a set of blog-user associations.
|
124 |
-
*
|
125 |
-
* @param string $type The order in which results should be returned.
|
126 |
-
* 'active', 'alphabetical', 'newest', or 'random'.
|
127 |
-
* @param int|bool $limit Optional. The maximum records to return.
|
128 |
-
* Default: false.
|
129 |
-
* @param int|bool $page Optional. The page of records to return.
|
130 |
-
* Default: false (unlimited results).
|
131 |
-
* @param int $user_id Optional. ID of the user whose blogs are being
|
132 |
-
* retrieved. Default: 0.
|
133 |
-
* @param string|bool $search_terms Optional. Search by text stored in
|
134 |
-
* blogmeta (such as the blog name). Default: false.
|
135 |
-
* @param bool $update_meta_cache Whether to pre-fetch metadata for
|
136 |
-
* blogs. Default: true.
|
137 |
-
* @param array $include_blog_ids Array of blog IDs to include.
|
138 |
-
* @return array Multidimensional results array, structured as follows:
|
139 |
-
* 'blogs' - Array of located blog objects
|
140 |
-
* 'total' - A count of the total blogs matching the filter params
|
141 |
-
*/
|
142 |
-
public static function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false, $update_meta_cache = true, $include_blog_ids = false ) {
|
143 |
-
global $bp, $wpdb;
|
144 |
-
|
145 |
-
if ( !is_user_logged_in() || ( !bp_current_user_can( 'bp_moderate' ) && ( $user_id != bp_loggedin_user_id() ) ) )
|
146 |
-
$hidden_sql = "AND wb.public = 1";
|
147 |
-
else
|
148 |
-
$hidden_sql = '';
|
149 |
-
|
150 |
-
$pag_sql = ( $limit && $page ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';
|
151 |
-
|
152 |
-
$user_sql = !empty( $user_id ) ? $wpdb->prepare( " AND b.user_id = %d", $user_id ) : '';
|
153 |
-
|
154 |
-
switch ( $type ) {
|
155 |
-
case 'active': default:
|
156 |
-
$order_sql = "ORDER BY bm.meta_value DESC";
|
157 |
-
break;
|
158 |
-
case 'alphabetical':
|
159 |
-
$order_sql = "ORDER BY bm_name.meta_value ASC";
|
160 |
-
break;
|
161 |
-
case 'newest':
|
162 |
-
$order_sql = "ORDER BY wb.registered DESC";
|
163 |
-
break;
|
164 |
-
case 'random':
|
165 |
-
$order_sql = "ORDER BY RAND()";
|
166 |
-
break;
|
167 |
-
}
|
168 |
-
|
169 |
-
$include_sql = '';
|
170 |
-
$include_blog_ids = array_filter( wp_parse_id_list( $include_blog_ids ) );
|
171 |
-
if ( ! empty( $include_blog_ids ) ) {
|
172 |
-
$blog_ids_sql = implode( ',', $include_blog_ids );
|
173 |
-
$include_sql = " AND b.blog_id IN ({$blog_ids_sql})";
|
174 |
-
}
|
175 |
-
|
176 |
-
if ( ! empty( $search_terms ) ) {
|
177 |
-
$search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
|
178 |
-
$search_terms_sql = $wpdb->prepare( 'AND (bm_name.meta_value LIKE %s OR bm_description.meta_value LIKE %s)', $search_terms_like, $search_terms_like );
|
179 |
-
} else {
|
180 |
-
$search_terms_sql = '';
|
181 |
-
}
|
182 |
-
|
183 |
-
$paged_blogs = $wpdb->get_results( "
|
184 |
-
SELECT b.blog_id, b.user_id as admin_user_id, u.user_email as admin_user_email, wb.domain, wb.path, bm.meta_value as last_activity, bm_name.meta_value as name
|
185 |
-
FROM
|
186 |
-
{$bp->blogs->table_name} b
|
187 |
-
LEFT JOIN {$bp->blogs->table_name_blogmeta} bm ON (b.blog_id = bm.blog_id)
|
188 |
-
LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_name ON (b.blog_id = bm_name.blog_id)
|
189 |
-
LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_description ON (b.blog_id = bm_description.blog_id)
|
190 |
-
LEFT JOIN {$wpdb->base_prefix}blogs wb ON (b.blog_id = wb.blog_id)
|
191 |
-
LEFT JOIN {$wpdb->users} u ON (b.user_id = u.ID)
|
192 |
-
WHERE
|
193 |
-
wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql}
|
194 |
-
AND bm.meta_key = 'last_activity' AND bm_name.meta_key = 'name' AND bm_description.meta_key = 'description'
|
195 |
-
{$search_terms_sql} {$user_sql} {$include_sql}
|
196 |
-
GROUP BY b.blog_id {$order_sql} {$pag_sql}
|
197 |
-
" );
|
198 |
-
|
199 |
-
$total_blogs = $wpdb->get_var( "
|
200 |
-
SELECT COUNT(DISTINCT b.blog_id)
|
201 |
-
FROM
|
202 |
-
{$bp->blogs->table_name} b
|
203 |
-
LEFT JOIN {$wpdb->base_prefix}blogs wb ON (b.blog_id = wb.blog_id)
|
204 |
-
LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_name ON (b.blog_id = bm_name.blog_id)
|
205 |
-
LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_description ON (b.blog_id = bm_description.blog_id)
|
206 |
-
WHERE
|
207 |
-
wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql}
|
208 |
-
AND
|
209 |
-
bm_name.meta_key = 'name' AND bm_description.meta_key = 'description'
|
210 |
-
{$search_terms_sql} {$user_sql} {$include_sql}
|
211 |
-
" );
|
212 |
-
|
213 |
-
$blog_ids = array();
|
214 |
-
foreach ( (array) $paged_blogs as $blog ) {
|
215 |
-
$blog_ids[] = (int) $blog->blog_id;
|
216 |
-
}
|
217 |
-
|
218 |
-
$paged_blogs = BP_Blogs_Blog::get_blog_extras( $paged_blogs, $blog_ids, $type );
|
219 |
-
|
220 |
-
if ( $update_meta_cache ) {
|
221 |
-
bp_blogs_update_meta_cache( $blog_ids );
|
222 |
-
}
|
223 |
-
|
224 |
-
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
225 |
-
}
|
226 |
-
|
227 |
-
/**
|
228 |
-
* Delete the record of a given blog for all users.
|
229 |
-
*
|
230 |
-
* @param int $blog_id The blog being removed from all users.
|
231 |
-
* @return int|bool Number of rows deleted on success, false on failure.
|
232 |
-
*/
|
233 |
-
public static function delete_blog_for_all( $blog_id ) {
|
234 |
-
global $wpdb, $bp;
|
235 |
-
|
236 |
-
bp_blogs_delete_blogmeta( $blog_id );
|
237 |
-
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
|
238 |
-
}
|
239 |
-
|
240 |
-
/**
|
241 |
-
* Delete the record of a given blog for a specific user.
|
242 |
-
*
|
243 |
-
* @param int $blog_id The blog being removed.
|
244 |
-
* @param int $user_id Optional. The ID of the user from whom the blog
|
245 |
-
* is being removed. If absent, defaults to the logged-in user ID.
|
246 |
-
* @return int|bool Number of rows deleted on success, false on failure.
|
247 |
-
*/
|
248 |
-
public static function delete_blog_for_user( $blog_id, $user_id = null ) {
|
249 |
-
global $wpdb, $bp;
|
250 |
-
|
251 |
-
if ( !$user_id )
|
252 |
-
$user_id = bp_loggedin_user_id();
|
253 |
-
|
254 |
-
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) );
|
255 |
-
}
|
256 |
-
|
257 |
-
/**
|
258 |
-
* Delete all of a user's blog associations in the BP tables.
|
259 |
-
*
|
260 |
-
* @param int $user_id Optional. The ID of the user whose blog
|
261 |
-
* associations are being deleted. If absent, defaults to
|
262 |
-
* logged-in user ID.
|
263 |
-
* @return int|bool Number of rows deleted on success, false on failure.
|
264 |
-
*/
|
265 |
-
public static function delete_blogs_for_user( $user_id = null ) {
|
266 |
-
global $wpdb, $bp;
|
267 |
-
|
268 |
-
if ( !$user_id )
|
269 |
-
$user_id = bp_loggedin_user_id();
|
270 |
-
|
271 |
-
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
|
272 |
-
}
|
273 |
-
|
274 |
-
/**
|
275 |
-
* Get all of a user's blogs, as tracked by BuddyPress.
|
276 |
-
*
|
277 |
-
* Note that this is different from the WordPress function
|
278 |
-
* {@link get_blogs_of_user()}; the current method returns only those
|
279 |
-
* blogs that have been recorded by BuddyPress, while the WP function
|
280 |
-
* does a true query of a user's blog capabilities.
|
281 |
-
*
|
282 |
-
* @param int $user_id Optional. ID of the user whose blogs are being
|
283 |
-
* queried. Defaults to logged-in user.
|
284 |
-
* @param bool $show_hidden Optional. Whether to include blogs that are
|
285 |
-
* not marked public. Defaults to true when viewing one's own
|
286 |
-
* profile.
|
287 |
-
* @return array Multidimensional results array, structured as follows:
|
288 |
-
* 'blogs' - Array of located blog objects
|
289 |
-
* 'total' - A count of the total blogs for the user.
|
290 |
-
*/
|
291 |
-
public static function get_blogs_for_user( $user_id = 0, $show_hidden = false ) {
|
292 |
-
global $bp, $wpdb;
|
293 |
-
|
294 |
-
if ( !$user_id )
|
295 |
-
$user_id = bp_displayed_user_id();
|
296 |
-
|
297 |
-
// Show logged in users their hidden blogs.
|
298 |
-
if ( !bp_is_my_profile() && !$show_hidden )
|
299 |
-
$blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ) );
|
300 |
-
else
|
301 |
-
$blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ) );
|
302 |
-
|
303 |
-
$total_blog_count = BP_Blogs_Blog::total_blog_count_for_user( $user_id );
|
304 |
-
|
305 |
-
$user_blogs = array();
|
306 |
-
foreach ( (array) $blogs as $blog ) {
|
307 |
-
$user_blogs[$blog->blog_id] = new stdClass;
|
308 |
-
$user_blogs[$blog->blog_id]->id = $blog->id;
|
309 |
-
$user_blogs[$blog->blog_id]->blog_id = $blog->blog_id;
|
310 |
-
$user_blogs[$blog->blog_id]->siteurl = ( is_ssl() ) ? 'https://' . $blog->domain . $blog->path : 'http://' . $blog->domain . $blog->path;
|
311 |
-
$user_blogs[$blog->blog_id]->name = $blog->name;
|
312 |
-
}
|
313 |
-
|
314 |
-
return array( 'blogs' => $user_blogs, 'count' => $total_blog_count );
|
315 |
-
}
|
316 |
-
|
317 |
-
/**
|
318 |
-
* Get IDs of all of a user's blogs, as tracked by BuddyPress.
|
319 |
-
*
|
320 |
-
* This method always includes hidden blogs.
|
321 |
-
*
|
322 |
-
* @param int $user_id Optional. ID of the user whose blogs are being
|
323 |
-
* queried. Defaults to logged-in user.
|
324 |
-
* @return int The number of blogs associated with the user.
|
325 |
-
*/
|
326 |
-
public static function get_blog_ids_for_user( $user_id = 0 ) {
|
327 |
-
global $bp, $wpdb;
|
328 |
-
|
329 |
-
if ( !$user_id )
|
330 |
-
$user_id = bp_displayed_user_id();
|
331 |
-
|
332 |
-
return $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
|
333 |
-
}
|
334 |
-
|
335 |
-
/**
|
336 |
-
* Check whether a blog has been recorded by BuddyPress.
|
337 |
-
*
|
338 |
-
* @param int $blog_id ID of the blog being queried.
|
339 |
-
* @return int|null The ID of the first located entry in the BP table
|
340 |
-
* on success, otherwise null.
|
341 |
-
*/
|
342 |
-
public static function is_recorded( $blog_id ) {
|
343 |
-
global $bp, $wpdb;
|
344 |
-
|
345 |
-
return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
|
346 |
-
}
|
347 |
-
|
348 |
-
/**
|
349 |
-
* Return a count of associated blogs for a given user.
|
350 |
-
*
|
351 |
-
* Includes hidden blogs when the logged-in user is the same as the
|
352 |
-
* $user_id parameter, or when the logged-in user has the bp_moderate
|
353 |
-
* cap.
|
354 |
-
*
|
355 |
-
* @param int $user_id Optional. ID of the user whose blogs are being
|
356 |
-
* queried. Defaults to logged-in user.
|
357 |
-
* @return int Blog count for the user.
|
358 |
-
*/
|
359 |
-
public static function total_blog_count_for_user( $user_id = null ) {
|
360 |
-
global $bp, $wpdb;
|
361 |
-
|
362 |
-
if ( !$user_id )
|
363 |
-
$user_id = bp_displayed_user_id();
|
364 |
-
|
365 |
-
// If the user is logged in return the blog count including their hidden blogs.
|
366 |
-
if ( ( is_user_logged_in() && $user_id == bp_loggedin_user_id() ) || bp_current_user_can( 'bp_moderate' ) ) {
|
367 |
-
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id ) );
|
368 |
-
} else {
|
369 |
-
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id ) );
|
370 |
-
}
|
371 |
-
}
|
372 |
-
|
373 |
-
/**
|
374 |
-
* Return a list of blogs matching a search term.
|
375 |
-
*
|
376 |
-
* Matches against blog names and descriptions, as stored in the BP
|
377 |
-
* blogmeta table.
|
378 |
-
*
|
379 |
-
* @param string $filter The search term.
|
380 |
-
* @param int $limit Optional. The maximum number of items to return.
|
381 |
-
* Default: null (no limit).
|
382 |
-
* @param int $page Optional. The page of results to return. Default:
|
383 |
-
* null (no limit).
|
384 |
-
* @return array Multidimensional results array, structured as follows:
|
385 |
-
* 'blogs' - Array of located blog objects
|
386 |
-
* 'total' - A count of the total blogs matching the query.
|
387 |
-
*/
|
388 |
-
public static function search_blogs( $filter, $limit = null, $page = null ) {
|
389 |
-
global $wpdb, $bp;
|
390 |
-
|
391 |
-
$search_terms_like = '%' . bp_esc_like( $filter ) . '%';
|
392 |
-
$search_terms_sql = $wpdb->prepare( 'bm.meta_value LIKE %s', $search_terms_like );
|
393 |
-
|
394 |
-
$hidden_sql = '';
|
395 |
-
if ( !bp_current_user_can( 'bp_moderate' ) )
|
396 |
-
$hidden_sql = "AND wb.public = 1";
|
397 |
-
|
398 |
-
$pag_sql = '';
|
399 |
-
if ( $limit && $page ) {
|
400 |
-
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
401 |
-
}
|
402 |
-
|
403 |
-
$paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND {$search_terms_sql} ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC{$pag_sql}" );
|
404 |
-
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND {$search_terms_sql} ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC" );
|
405 |
-
|
406 |
-
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
407 |
-
}
|
408 |
-
|
409 |
-
/**
|
410 |
-
* Retrieve a list of all blogs.
|
411 |
-
*
|
412 |
-
* Query will include hidden blogs if the logged-in user has the
|
413 |
-
* 'bp_moderate' cap.
|
414 |
-
*
|
415 |
-
* @param int $limit Optional. The maximum number of items to return.
|
416 |
-
* Default: null (no limit).
|
417 |
-
* @param int $page Optional. The page of results to return. Default:
|
418 |
-
* null (no limit).
|
419 |
-
* @return array Multidimensional results array, structured as follows:
|
420 |
-
* 'blogs' - Array of located blog objects
|
421 |
-
* 'total' - A count of the total blogs.
|
422 |
-
*/
|
423 |
-
public static function get_all( $limit = null, $page = null ) {
|
424 |
-
global $bp, $wpdb;
|
425 |
-
|
426 |
-
$hidden_sql = !bp_current_user_can( 'bp_moderate' ) ? "AND wb.public = 1" : '';
|
427 |
-
$pag_sql = ( $limit && $page ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';
|
428 |
-
|
429 |
-
$paged_blogs = $wpdb->get_results( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql} {$pag_sql}" );
|
430 |
-
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql}" );
|
431 |
-
|
432 |
-
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
433 |
-
}
|
434 |
-
|
435 |
-
/**
|
436 |
-
* Retrieve a list of blogs whose names start with a given letter.
|
437 |
-
*
|
438 |
-
* Query will include hidden blogs if the logged-in user has the
|
439 |
-
* 'bp_moderate' cap.
|
440 |
-
*
|
441 |
-
* @param string $letter. The letter you're looking for.
|
442 |
-
* @param int $limit Optional. The maximum number of items to return.
|
443 |
-
* Default: null (no limit).
|
444 |
-
* @param int $page Optional. The page of results to return. Default:
|
445 |
-
* null (no limit).
|
446 |
-
* @return array Multidimensional results array, structured as follows:
|
447 |
-
* 'blogs' - Array of located blog objects.
|
448 |
-
* 'total' - A count of the total blogs matching the query.
|
449 |
-
*/
|
450 |
-
public static function get_by_letter( $letter, $limit = null, $page = null ) {
|
451 |
-
global $bp, $wpdb;
|
452 |
-
|
453 |
-
$letter_like = '%' . bp_esc_like( $letter ) . '%';
|
454 |
-
$letter_sql = $wpdb->prepare( 'bm.meta_value LIKE %s', $letter_like );
|
455 |
-
|
456 |
-
$hidden_sql = '';
|
457 |
-
if ( !bp_current_user_can( 'bp_moderate' ) )
|
458 |
-
$hidden_sql = "AND wb.public = 1";
|
459 |
-
|
460 |
-
$pag_sql = '';
|
461 |
-
if ( $limit && $page )
|
462 |
-
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
463 |
-
|
464 |
-
$paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND {$letter_sql} {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC{$pag_sql}" );
|
465 |
-
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND {$letter_sql} {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC" );
|
466 |
-
|
467 |
-
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
468 |
-
}
|
469 |
-
|
470 |
-
/**
|
471 |
-
* Fetch blog data not caught in the main query and append it to results array.
|
472 |
-
*
|
473 |
-
* Gets the following information, which is either unavailable at the
|
474 |
-
* time of the original query, or is more efficient to look up in one
|
475 |
-
* fell swoop:
|
476 |
-
* - The latest post for each blog, include Featured Image data
|
477 |
-
* - The blog description
|
478 |
-
*
|
479 |
-
* @param array $paged_blogs Array of results from the original query.
|
480 |
-
* @param array $blog_ids Array of IDs returned from the original query.
|
481 |
-
* @param string|bool $type Not currently used. Default: false.
|
482 |
-
* @return array $paged_blogs The located blogs array, with the extras added.
|
483 |
-
*/
|
484 |
-
public static function get_blog_extras( &$paged_blogs, &$blog_ids, $type = false ) {
|
485 |
-
global $bp, $wpdb;
|
486 |
-
|
487 |
-
if ( empty( $blog_ids ) )
|
488 |
-
return $paged_blogs;
|
489 |
-
|
490 |
-
$blog_ids = implode( ',', wp_parse_id_list( $blog_ids ) );
|
491 |
-
|
492 |
-
for ( $i = 0, $count = count( $paged_blogs ); $i < $count; ++$i ) {
|
493 |
-
$blog_prefix = $wpdb->get_blog_prefix( $paged_blogs[$i]->blog_id );
|
494 |
-
$paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT ID, post_content, post_title, post_excerpt, guid FROM {$blog_prefix}posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" );
|
495 |
-
$images = array();
|
496 |
-
|
497 |
-
// Add URLs to any Featured Image this post might have
|
498 |
-
if ( ! empty( $paged_blogs[$i]->latest_post ) && has_post_thumbnail( $paged_blogs[$i]->latest_post->ID ) ) {
|
499 |
-
|
500 |
-
// Grab 4 sizes of the image. Thumbnail.
|
501 |
-
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'thumbnail', false );
|
502 |
-
if ( ! empty( $image ) )
|
503 |
-
$images['thumbnail'] = $image[0];
|
504 |
-
|
505 |
-
// Medium
|
506 |
-
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'medium', false );
|
507 |
-
if ( ! empty( $image ) )
|
508 |
-
$images['medium'] = $image[0];
|
509 |
-
|
510 |
-
// Large
|
511 |
-
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'large', false );
|
512 |
-
if ( ! empty( $image ) )
|
513 |
-
$images['large'] = $image[0];
|
514 |
-
|
515 |
-
// Post thumbnail
|
516 |
-
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'post-thumbnail', false );
|
517 |
-
if ( ! empty( $image ) )
|
518 |
-
$images['post-thumbnail'] = $image[0];
|
519 |
-
|
520 |
-
// Add the images to the latest_post object
|
521 |
-
$paged_blogs[$i]->latest_post->images = $images;
|
522 |
-
}
|
523 |
-
}
|
524 |
-
|
525 |
-
/* Fetch the blog description for each blog (as it may be empty we can't fetch it in the main query). */
|
526 |
-
$blog_descs = $wpdb->get_results( "SELECT blog_id, meta_value as description FROM {$bp->blogs->table_name_blogmeta} WHERE meta_key = 'description' AND blog_id IN ( {$blog_ids} )" );
|
527 |
-
|
528 |
-
for ( $i = 0, $count = count( $paged_blogs ); $i < $count; ++$i ) {
|
529 |
-
foreach ( (array) $blog_descs as $desc ) {
|
530 |
-
if ( $desc->blog_id == $paged_blogs[$i]->blog_id )
|
531 |
-
$paged_blogs[$i]->description = $desc->description;
|
532 |
-
}
|
533 |
-
}
|
534 |
-
|
535 |
-
return $paged_blogs;
|
536 |
-
}
|
537 |
-
|
538 |
-
/**
|
539 |
-
* Check whether a given blog is hidden.
|
540 |
-
*
|
541 |
-
* Checks the 'public' column in the wp_blogs table.
|
542 |
-
*
|
543 |
-
* @param int $blog_id The ID of the blog being checked.
|
544 |
-
* @return bool True if hidden (public = 0), false otherwise.
|
545 |
-
*/
|
546 |
-
public static function is_hidden( $blog_id ) {
|
547 |
-
global $wpdb;
|
548 |
-
|
549 |
-
if ( !(int) $wpdb->get_var( $wpdb->prepare( "SELECT public FROM {$wpdb->base_prefix}blogs WHERE blog_id = %d", $blog_id ) ) ) {
|
550 |
-
return true;
|
551 |
-
}
|
552 |
-
|
553 |
-
return false;
|
554 |
-
}
|
555 |
-
|
556 |
-
/**
|
557 |
-
* Get ID of user-blog link.
|
558 |
-
*
|
559 |
-
* @param int $user_id ID of user.
|
560 |
-
* @param int $blog_id ID of blog.
|
561 |
-
* @return int|bool ID of user-blog link, or false if not found.
|
562 |
-
*/
|
563 |
-
public static function get_user_blog( $user_id, $blog_id ) {
|
564 |
-
global $bp, $wpdb;
|
565 |
-
|
566 |
-
$user_blog = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) );
|
567 |
-
|
568 |
-
if ( empty( $user_blog ) ) {
|
569 |
-
$user_blog = false;
|
570 |
-
} else {
|
571 |
-
$user_blog = intval( $user_blog );
|
572 |
-
}
|
573 |
-
|
574 |
-
return $user_blog;
|
575 |
-
}
|
576 |
-
}
|
10 |
Â
// Exit if accessed directly
|
11 |
Â
defined( 'ABSPATH' ) || exit;
|
12 |
Â
|
13 |
+
require dirname( __FILE__ ) . '/classes/class-bp-blogs-blog.php';
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
bp-blogs/bp-blogs-filters.php
CHANGED
@@ -41,7 +41,7 @@ function bp_blogs_creation_location( $url ) {
|
|
41 |
Â
*
|
42 |
Â
* @param string $value URL for the 'Create a new site' signup page.
|
43 |
Â
*/
|
44 |
-
return apply_filters( 'bp_blogs_creation_location', trailingslashit(
|
45 |
Â
}
|
46 |
Â
add_filter( 'wp_signup_location', 'bp_blogs_creation_location' );
|
47 |
Â
|
@@ -86,11 +86,13 @@ function bp_blogs_post_pre_publish( $return = true, $blog_id = 0, $post_id = 0,
|
|
86 |
Â
* Stop infinite loops with WordPress MU Sitewide Tags.
|
87 |
Â
* That plugin changed the way its settings were stored at some point. Thus the dual check.
|
88 |
Â
*/
|
89 |
-
|
90 |
-
|
Â
|
|
91 |
Â
$tags_blog_id = isset( $st_options['tags_blog_id'] ) ? $st_options['tags_blog_id'] : 0;
|
92 |
Â
} else {
|
93 |
-
$tags_blog_id =
|
Â
|
|
94 |
Â
}
|
95 |
Â
|
96 |
Â
/**
|
41 |
Â
*
|
42 |
Â
* @param string $value URL for the 'Create a new site' signup page.
|
43 |
Â
*/
|
44 |
+
return apply_filters( 'bp_blogs_creation_location', trailingslashit( bp_get_blogs_directory_permalink() . 'create' ), $url );
|
45 |
Â
}
|
46 |
Â
add_filter( 'wp_signup_location', 'bp_blogs_creation_location' );
|
47 |
Â
|
86 |
Â
* Stop infinite loops with WordPress MU Sitewide Tags.
|
87 |
Â
* That plugin changed the way its settings were stored at some point. Thus the dual check.
|
88 |
Â
*/
|
89 |
+
$sitewide_tags_blog_settings = bp_core_get_root_option( 'sitewide_tags_blog' );
|
90 |
+
if ( ! empty( $sitewide_tags_blog_settings ) ) {
|
91 |
+
$st_options = maybe_unserialize( $sitewide_tags_blog_settings );
|
92 |
Â
$tags_blog_id = isset( $st_options['tags_blog_id'] ) ? $st_options['tags_blog_id'] : 0;
|
93 |
Â
} else {
|
94 |
+
$tags_blog_id = bp_core_get_root_option( 'sitewide_tags_blog' );
|
95 |
+
$tags_blog_id = intval( $tags_blog_id );
|
96 |
Â
}
|
97 |
Â
|
98 |
Â
/**
|
bp-blogs/bp-blogs-functions.php
CHANGED
@@ -14,12 +14,10 @@ defined( 'ABSPATH' ) || exit;
|
|
14 |
Â
*
|
15 |
Â
* @since BuddyPress (1.5.0)
|
16 |
Â
*
|
17 |
-
* @global BuddyPress $bp The one true BuddyPress instance.
|
18 |
-
*
|
19 |
Â
* @return bool True if set, false if empty.
|
20 |
Â
*/
|
21 |
Â
function bp_blogs_has_directory() {
|
22 |
-
|
23 |
Â
|
24 |
Â
return (bool) !empty( $bp->pages->blogs->id );
|
25 |
Â
}
|
@@ -236,12 +234,12 @@ function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
|
|
236 |
Â
return false;
|
237 |
Â
|
238 |
Â
$name = get_blog_option( $blog_id, 'blogname' );
|
Â
|
|
239 |
Â
|
240 |
Â
if ( empty( $name ) ) {
|
241 |
-
|
242 |
Â
}
|
243 |
Â
|
244 |
-
$url = get_home_url( $blog_id );
|
245 |
Â
$description = get_blog_option( $blog_id, 'blogdescription' );
|
246 |
Â
$close_old_posts = get_blog_option( $blog_id, 'close_comments_for_old_posts' );
|
247 |
Â
$close_days_old = get_blog_option( $blog_id, 'close_comments_days_old' );
|
@@ -410,6 +408,21 @@ function bp_blogs_update_option_thread_comments_depth( $oldvalue, $newvalue ) {
|
|
410 |
Â
}
|
411 |
Â
add_action( 'update_option_thread_comments_depth', 'bp_blogs_update_option_thread_comments_depth', 10, 2 );
|
412 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
413 |
Â
/**
|
414 |
Â
* Record activity metadata about a published blog post.
|
415 |
Â
*
|
@@ -806,7 +819,7 @@ add_action( 'remove_user_from_blog', 'bp_blogs_remove_user_from_blog', 10, 2 );
|
|
806 |
Â
* WordPress catches add-user-to-blog requests at init:10. In some cases, this
|
807 |
Â
* can precede BP's Blogs component. This function bumps the priority of the
|
808 |
Â
* core function, so that we can be sure that the Blogs component is loaded
|
809 |
-
* first. See
|
810 |
Â
*
|
811 |
Â
* @since BuddyPress (1.6.0)
|
812 |
Â
* @access private
|
@@ -826,7 +839,6 @@ add_action( 'init', 'bp_blogs_maybe_add_user_to_blog', 1 );
|
|
826 |
Â
* @param int $blog_id ID of the blog being removed.
|
827 |
Â
*/
|
828 |
Â
function bp_blogs_remove_blog( $blog_id ) {
|
829 |
-
global $bp;
|
830 |
Â
|
831 |
Â
$blog_id = (int) $blog_id;
|
832 |
Â
|
@@ -843,7 +855,11 @@ function bp_blogs_remove_blog( $blog_id ) {
|
|
843 |
Â
BP_Blogs_Blog::delete_blog_for_all( $blog_id );
|
844 |
Â
|
845 |
Â
// Delete activity stream item
|
846 |
-
bp_blogs_delete_activity( array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
847 |
Â
|
848 |
Â
/**
|
849 |
Â
* Fires after a "blog created" item has been removed from blogs
|
@@ -864,7 +880,6 @@ add_action( 'delete_blog', 'bp_blogs_remove_blog' );
|
|
864 |
Â
* @param int $blog_id ID of the blog being removed.
|
865 |
Â
*/
|
866 |
Â
function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
|
867 |
-
global $bp;
|
868 |
Â
|
869 |
Â
$blog_id = (int) $blog_id;
|
870 |
Â
$user_id = (int) $user_id;
|
@@ -884,7 +899,7 @@ function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
|
|
884 |
Â
// Delete activity stream item
|
885 |
Â
bp_blogs_delete_activity( array(
|
886 |
Â
'item_id' => $blog_id,
|
887 |
-
'component' =>
|
888 |
Â
'type' => 'new_blog'
|
889 |
Â
) );
|
890 |
Â
|
@@ -909,7 +924,7 @@ add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 );
|
|
909 |
Â
* is currently unused in the function (but is passed to hooks).
|
910 |
Â
*/
|
911 |
Â
function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
|
912 |
-
global $wpdb
|
913 |
Â
|
914 |
Â
if ( empty( $wpdb->blogid ) )
|
915 |
Â
return false;
|
@@ -934,7 +949,12 @@ function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
|
|
934 |
Â
do_action( 'bp_blogs_before_remove_post', $blog_id, $post_id, $user_id );
|
935 |
Â
|
936 |
Â
// Delete activity stream item
|
937 |
-
bp_blogs_delete_activity( array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
938 |
Â
|
939 |
Â
/**
|
940 |
Â
* Fires after removal of a blog post activity item from the activity stream.
|
@@ -1063,14 +1083,11 @@ function bp_blogs_remove_associated_blog_comments( $activity_ids = array(), $for
|
|
1063 |
Â
*
|
1064 |
Â
* @since BuddyPress (1.6.0)
|
1065 |
Â
*
|
1066 |
-
* @global object $bp BuddyPress global settings.
|
1067 |
-
*
|
1068 |
Â
* @param string $new_status New comment status.
|
1069 |
Â
* @param string $old_status Previous comment status.
|
1070 |
Â
* @param object $comment Comment data.
|
1071 |
Â
*/
|
1072 |
Â
function bp_blogs_transition_activity_status( $new_status, $old_status, $comment ) {
|
1073 |
-
global $bp;
|
1074 |
Â
|
1075 |
Â
// Check the Activity component is active
|
1076 |
Â
if ( ! bp_is_active( 'activity' ) )
|
@@ -1099,7 +1116,12 @@ function bp_blogs_transition_activity_status( $new_status, $old_status, $comment
|
|
1099 |
Â
|
1100 |
Â
// Get the activity
|
1101 |
Â
if ( bp_disable_blogforum_comments() ) {
|
1102 |
-
$activity_id = bp_activity_get_activity_id( array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1103 |
Â
} else {
|
1104 |
Â
$activity_id = get_comment_meta( $comment->comment_ID, 'bp_activity_comment_id', true );
|
1105 |
Â
}
|
@@ -1188,7 +1210,6 @@ function bp_blogs_total_blogs_for_user( $user_id = 0 ) {
|
|
1188 |
Â
* @param int $blog_id The ID of the blog to expunge.
|
1189 |
Â
*/
|
1190 |
Â
function bp_blogs_remove_data_for_blog( $blog_id ) {
|
1191 |
-
global $bp;
|
1192 |
Â
|
1193 |
Â
/**
|
1194 |
Â
* Fires before all data related to a given blog is removed from blogs tracker
|
@@ -1204,7 +1225,11 @@ function bp_blogs_remove_data_for_blog( $blog_id ) {
|
|
1204 |
Â
BP_Blogs_Blog::delete_blog_for_all( $blog_id );
|
1205 |
Â
|
1206 |
Â
// Delete activity stream item
|
1207 |
-
bp_blogs_delete_activity( array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1208 |
Â
|
1209 |
Â
/**
|
1210 |
Â
* Fires after all data related to a given blog has been removed from blogs tracker
|
@@ -1283,7 +1308,6 @@ function bp_blogs_is_blog_hidden( $blog_id ) {
|
|
1283 |
Â
* Delete a metadata from the DB for a blog.
|
1284 |
Â
*
|
1285 |
Â
* @global object $wpdb WordPress database access object.
|
1286 |
-
* @global object $bp BuddyPress global settings.
|
1287 |
Â
*
|
1288 |
Â
* @param int $blog_id ID of the blog whose metadata is being deleted.
|
1289 |
Â
* @param string $meta_key Optional. The key of the metadata being deleted. If
|
@@ -1297,7 +1321,7 @@ function bp_blogs_is_blog_hidden( $blog_id ) {
|
|
1297 |
Â
* @return bool True on success, false on failure.
|
1298 |
Â
*/
|
1299 |
Â
function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false, $delete_all = false ) {
|
1300 |
-
global $wpdb
|
1301 |
Â
|
1302 |
Â
// Legacy - if no meta_key is passed, delete all for the blog_id
|
1303 |
Â
if ( empty( $meta_key ) ) {
|
@@ -1325,7 +1349,6 @@ function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = fa
|
|
1325 |
Â
* @since BuddyPress (1.2.0)
|
1326 |
Â
*
|
1327 |
Â
* @global object $wpdb WordPress database access object.
|
1328 |
-
* @global object $bp BuddyPress global settings.
|
1329 |
Â
*
|
1330 |
Â
* @param int $blog_id ID of the blog whose metadata is being requested.
|
1331 |
Â
* @param string $meta_key Optional. If present, only the metadata matching
|
@@ -1348,7 +1371,6 @@ function bp_blogs_get_blogmeta( $blog_id, $meta_key = '', $single = true ) {
|
|
1348 |
Â
* Update a piece of blog meta.
|
1349 |
Â
*
|
1350 |
Â
* @global object $wpdb WordPress database access object.
|
1351 |
-
* @global object $bp BuddyPress global settings.
|
1352 |
Â
*
|
1353 |
Â
* @param int $blog_id ID of the blog whose metadata is being updated.
|
1354 |
Â
* @param string $meta_key Key of the metadata being updated.
|
14 |
Â
*
|
15 |
Â
* @since BuddyPress (1.5.0)
|
16 |
Â
*
|
Â
|
|
Â
|
|
17 |
Â
* @return bool True if set, false if empty.
|
18 |
Â
*/
|
19 |
Â
function bp_blogs_has_directory() {
|
20 |
+
$bp = buddypress();
|
21 |
Â
|
22 |
Â
return (bool) !empty( $bp->pages->blogs->id );
|
23 |
Â
}
|
234 |
Â
return false;
|
235 |
Â
|
236 |
Â
$name = get_blog_option( $blog_id, 'blogname' );
|
237 |
+
$url = get_home_url( $blog_id );
|
238 |
Â
|
239 |
Â
if ( empty( $name ) ) {
|
240 |
+
$name = $url;
|
241 |
Â
}
|
242 |
Â
|
Â
|
|
243 |
Â
$description = get_blog_option( $blog_id, 'blogdescription' );
|
244 |
Â
$close_old_posts = get_blog_option( $blog_id, 'close_comments_for_old_posts' );
|
245 |
Â
$close_days_old = get_blog_option( $blog_id, 'close_comments_days_old' );
|
408 |
Â
}
|
409 |
Â
add_action( 'update_option_thread_comments_depth', 'bp_blogs_update_option_thread_comments_depth', 10, 2 );
|
410 |
Â
|
411 |
+
/**
|
412 |
+
* Deletes the 'url' blogmeta for a site.
|
413 |
+
*
|
414 |
+
* Hooked to 'refresh_blog_details', which is notably used when editing a site
|
415 |
+
* under "Network Admin > Sites".
|
416 |
+
*
|
417 |
+
* @since BuddyPress (2.3.0)
|
418 |
+
*
|
419 |
+
* @param int $site_id The site ID
|
420 |
+
*/
|
421 |
+
function bp_blogs_delete_url_blogmeta( $site_id = 0 ) {
|
422 |
+
bp_blogs_delete_blogmeta( (int) $site_id, 'url' );
|
423 |
+
}
|
424 |
+
add_action( 'refresh_blog_details', 'bp_blogs_delete_url_blogmeta' );
|
425 |
+
|
426 |
Â
/**
|
427 |
Â
* Record activity metadata about a published blog post.
|
428 |
Â
*
|
819 |
Â
* WordPress catches add-user-to-blog requests at init:10. In some cases, this
|
820 |
Â
* can precede BP's Blogs component. This function bumps the priority of the
|
821 |
Â
* core function, so that we can be sure that the Blogs component is loaded
|
822 |
+
* first. See https://buddypress.trac.wordpress.org/ticket/3916.
|
823 |
Â
*
|
824 |
Â
* @since BuddyPress (1.6.0)
|
825 |
Â
* @access private
|
839 |
Â
* @param int $blog_id ID of the blog being removed.
|
840 |
Â
*/
|
841 |
Â
function bp_blogs_remove_blog( $blog_id ) {
|
Â
|
|
842 |
Â
|
843 |
Â
$blog_id = (int) $blog_id;
|
844 |
Â
|
855 |
Â
BP_Blogs_Blog::delete_blog_for_all( $blog_id );
|
856 |
Â
|
857 |
Â
// Delete activity stream item
|
858 |
+
bp_blogs_delete_activity( array(
|
859 |
+
'item_id' => $blog_id,
|
860 |
+
'component' => buddypress()->blogs->id,
|
861 |
+
'type' => 'new_blog'
|
862 |
+
) );
|
863 |
Â
|
864 |
Â
/**
|
865 |
Â
* Fires after a "blog created" item has been removed from blogs
|
880 |
Â
* @param int $blog_id ID of the blog being removed.
|
881 |
Â
*/
|
882 |
Â
function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
|
Â
|
|
883 |
Â
|
884 |
Â
$blog_id = (int) $blog_id;
|
885 |
Â
$user_id = (int) $user_id;
|
899 |
Â
// Delete activity stream item
|
900 |
Â
bp_blogs_delete_activity( array(
|
901 |
Â
'item_id' => $blog_id,
|
902 |
+
'component' => buddypress()->blogs->id,
|
903 |
Â
'type' => 'new_blog'
|
904 |
Â
) );
|
905 |
Â
|
924 |
Â
* is currently unused in the function (but is passed to hooks).
|
925 |
Â
*/
|
926 |
Â
function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
|
927 |
+
global $wpdb;
|
928 |
Â
|
929 |
Â
if ( empty( $wpdb->blogid ) )
|
930 |
Â
return false;
|
949 |
Â
do_action( 'bp_blogs_before_remove_post', $blog_id, $post_id, $user_id );
|
950 |
Â
|
951 |
Â
// Delete activity stream item
|
952 |
+
bp_blogs_delete_activity( array(
|
953 |
+
'item_id' => $blog_id,
|
954 |
+
'secondary_item_id' => $post_id,
|
955 |
+
'component' => buddypress()->blogs->id,
|
956 |
+
'type' => 'new_blog_post'
|
957 |
+
) );
|
958 |
Â
|
959 |
Â
/**
|
960 |
Â
* Fires after removal of a blog post activity item from the activity stream.
|
1083 |
Â
*
|
1084 |
Â
* @since BuddyPress (1.6.0)
|
1085 |
Â
*
|
Â
|
|
Â
|
|
1086 |
Â
* @param string $new_status New comment status.
|
1087 |
Â
* @param string $old_status Previous comment status.
|
1088 |
Â
* @param object $comment Comment data.
|
1089 |
Â
*/
|
1090 |
Â
function bp_blogs_transition_activity_status( $new_status, $old_status, $comment ) {
|
Â
|
|
1091 |
Â
|
1092 |
Â
// Check the Activity component is active
|
1093 |
Â
if ( ! bp_is_active( 'activity' ) )
|
1116 |
Â
|
1117 |
Â
// Get the activity
|
1118 |
Â
if ( bp_disable_blogforum_comments() ) {
|
1119 |
+
$activity_id = bp_activity_get_activity_id( array(
|
1120 |
+
'component' => buddypress()->blogs->id,
|
1121 |
+
'item_id' => get_current_blog_id(),
|
1122 |
+
'secondary_item_id' => $comment->comment_ID,
|
1123 |
+
'type' => 'new_blog_comment'
|
1124 |
+
) );
|
1125 |
Â
} else {
|
1126 |
Â
$activity_id = get_comment_meta( $comment->comment_ID, 'bp_activity_comment_id', true );
|
1127 |
Â
}
|
1210 |
Â
* @param int $blog_id The ID of the blog to expunge.
|
1211 |
Â
*/
|
1212 |
Â
function bp_blogs_remove_data_for_blog( $blog_id ) {
|
Â
|
|
1213 |
Â
|
1214 |
Â
/**
|
1215 |
Â
* Fires before all data related to a given blog is removed from blogs tracker
|
1225 |
Â
BP_Blogs_Blog::delete_blog_for_all( $blog_id );
|
1226 |
Â
|
1227 |
Â
// Delete activity stream item
|
1228 |
+
bp_blogs_delete_activity( array(
|
1229 |
+
'item_id' => $blog_id,
|
1230 |
+
'component' => buddypress()->blogs->id,
|
1231 |
+
'type' => false
|
1232 |
+
) );
|
1233 |
Â
|
1234 |
Â
/**
|
1235 |
Â
* Fires after all data related to a given blog has been removed from blogs tracker
|
1308 |
Â
* Delete a metadata from the DB for a blog.
|
1309 |
Â
*
|
1310 |
Â
* @global object $wpdb WordPress database access object.
|
Â
|
|
1311 |
Â
*
|
1312 |
Â
* @param int $blog_id ID of the blog whose metadata is being deleted.
|
1313 |
Â
* @param string $meta_key Optional. The key of the metadata being deleted. If
|
1321 |
Â
* @return bool True on success, false on failure.
|
1322 |
Â
*/
|
1323 |
Â
function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false, $delete_all = false ) {
|
1324 |
+
global $wpdb;
|
1325 |
Â
|
1326 |
Â
// Legacy - if no meta_key is passed, delete all for the blog_id
|
1327 |
Â
if ( empty( $meta_key ) ) {
|
1349 |
Â
* @since BuddyPress (1.2.0)
|
1350 |
Â
*
|
1351 |
Â
* @global object $wpdb WordPress database access object.
|
Â
|
|
1352 |
Â
*
|
1353 |
Â
* @param int $blog_id ID of the blog whose metadata is being requested.
|
1354 |
Â
* @param string $meta_key Optional. If present, only the metadata matching
|
1371 |
Â
* Update a piece of blog meta.
|
1372 |
Â
*
|
1373 |
Â
* @global object $wpdb WordPress database access object.
|
Â
|
|
1374 |
Â
*
|
1375 |
Â
* @param int $blog_id ID of the blog whose metadata is being updated.
|
1376 |
Â
* @param string $meta_key Key of the metadata being updated.
|
bp-blogs/bp-blogs-loader.php
CHANGED
@@ -66,6 +66,7 @@ class BP_Blogs_Component extends BP_Component {
|
|
66 |
Â
'slug' => BP_BLOGS_SLUG,
|
67 |
Â
'root_slug' => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG,
|
68 |
Â
'has_directory' => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site
|
Â
|
|
69 |
Â
'notification_callback' => 'bp_blogs_format_notifications',
|
70 |
Â
'search_string' => __( 'Search sites...', 'buddypress' ),
|
71 |
Â
'autocomplete_all' => defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ),
|
@@ -84,9 +85,10 @@ class BP_Blogs_Component extends BP_Component {
|
|
84 |
Â
if ( 0 !== apply_filters( 'bp_is_blog_public', (int) get_option( 'blog_public' ) ) || ! is_multisite() ) {
|
85 |
Â
|
86 |
Â
/**
|
87 |
-
* Filters the post types to track for the
|
88 |
Â
*
|
89 |
Â
* @since BuddyPress (1.5.0)
|
Â
|
|
90 |
Â
*
|
91 |
Â
* @param array $value Array of post types to track.
|
92 |
Â
*/
|
@@ -153,8 +155,11 @@ class BP_Blogs_Component extends BP_Component {
|
|
153 |
Â
}
|
154 |
Â
|
155 |
Â
// Add 'Sites' to the main navigation
|
156 |
-
$
|
157 |
-
|
Â
|
|
Â
|
|
Â
|
|
158 |
Â
'slug' => $this->slug,
|
159 |
Â
'position' => 30,
|
160 |
Â
'screen_function' => 'bp_blogs_screen_my_blogs',
|
@@ -293,8 +298,23 @@ class BP_Blogs_Component extends BP_Component {
|
|
293 |
Â
*
|
294 |
Â
* @see bp_activity_get_post_type_tracking_args() for information on parameters.
|
295 |
Â
*/
|
296 |
-
public function post_tracking_args( $params =
|
297 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
298 |
Â
return $params;
|
299 |
Â
}
|
300 |
Â
|
66 |
Â
'slug' => BP_BLOGS_SLUG,
|
67 |
Â
'root_slug' => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG,
|
68 |
Â
'has_directory' => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site
|
69 |
+
'directory_title' => _x( 'Sites', 'component directory title', 'buddypress' ),
|
70 |
Â
'notification_callback' => 'bp_blogs_format_notifications',
|
71 |
Â
'search_string' => __( 'Search sites...', 'buddypress' ),
|
72 |
Â
'autocomplete_all' => defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ),
|
85 |
Â
if ( 0 !== apply_filters( 'bp_is_blog_public', (int) get_option( 'blog_public' ) ) || ! is_multisite() ) {
|
86 |
Â
|
87 |
Â
/**
|
88 |
+
* Filters the post types to track for the Blogs component.
|
89 |
Â
*
|
90 |
Â
* @since BuddyPress (1.5.0)
|
91 |
+
* @deprecated BuddyPress (2.3.0)
|
92 |
Â
*
|
93 |
Â
* @param array $value Array of post types to track.
|
94 |
Â
*/
|
155 |
Â
}
|
156 |
Â
|
157 |
Â
// Add 'Sites' to the main navigation
|
158 |
+
$count = (int) bp_get_total_blog_count_for_user();
|
159 |
+
$class = ( 0 === $count ) ? 'no-count' : 'count';
|
160 |
+
$nav_text = sprintf( __( 'Sites <span class="%s">%s</span>', 'buddypress' ), esc_attr( $class ), number_format_i18n( $count ) );
|
161 |
+
$main_nav = array(
|
162 |
+
'name' => $nav_text,
|
163 |
Â
'slug' => $this->slug,
|
164 |
Â
'position' => 30,
|
165 |
Â
'screen_function' => 'bp_blogs_screen_my_blogs',
|
298 |
Â
*
|
299 |
Â
* @see bp_activity_get_post_type_tracking_args() for information on parameters.
|
300 |
Â
*/
|
301 |
+
public function post_tracking_args( $params = null, $post_type = 0 ) {
|
302 |
+
/**
|
303 |
+
* Filters the post types to track for the Blogs component.
|
304 |
+
*
|
305 |
+
* @since BuddyPress (1.5.0)
|
306 |
+
* @deprecated BuddyPress (2.3.0)
|
307 |
+
*
|
308 |
+
* Make sure plugins still using 'bp_blogs_record_post_post_types'
|
309 |
+
* to track their post types will generate new_blog_post activities
|
310 |
+
* See https://buddypress.trac.wordpress.org/ticket/6306
|
311 |
+
*
|
312 |
+
* @param array $value Array of post types to track.
|
313 |
+
*/
|
314 |
+
$post_types = apply_filters( 'bp_blogs_record_post_post_types', array( 'post' ) );
|
315 |
+
$post_types_array = array_flip( $post_types );
|
316 |
+
|
317 |
+
if ( ! isset( $post_types_array[ $post_type ] ) ) {
|
318 |
Â
return $params;
|
319 |
Â
}
|
320 |
Â
|
bp-blogs/bp-blogs-template.php
CHANGED
@@ -76,7 +76,7 @@ function bp_blogs_root_slug() {
|
|
76 |
Â
* @uses bp_get_blogs_directory_permalink()
|
77 |
Â
*/
|
78 |
Â
function bp_blogs_directory_permalink() {
|
79 |
-
echo bp_get_blogs_directory_permalink();
|
80 |
Â
}
|
81 |
Â
/**
|
82 |
Â
* Return blog directory permalink.
|
@@ -472,7 +472,13 @@ function bp_blogs_pagination_count() {
|
|
472 |
Â
$to_num = bp_core_number_format( ( $start_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $start_num + ( $blogs_template->pag_num - 1 ) );
|
473 |
Â
$total = bp_core_number_format( $blogs_template->total_blog_count );
|
474 |
Â
|
475 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
476 |
Â
}
|
477 |
Â
|
478 |
Â
/**
|
@@ -706,9 +712,11 @@ function bp_blog_description() {
|
|
706 |
Â
* Output the row class of the current blog in the loop.
|
707 |
Â
*
|
708 |
Â
* @since BuddyPress (1.7.0)
|
Â
|
|
Â
|
|
709 |
Â
*/
|
710 |
-
function bp_blog_class() {
|
711 |
-
echo bp_get_blog_class();
|
712 |
Â
}
|
713 |
Â
/**
|
714 |
Â
* Return the row class of the current blog in the loop.
|
@@ -716,20 +724,22 @@ function bp_blog_class() {
|
|
716 |
Â
* @since BuddyPress (1.7.0)
|
717 |
Â
*
|
718 |
Â
* @global BP_Blogs_Template $blogs_template
|
Â
|
|
719 |
Â
*
|
720 |
Â
* @return string Row class of the site.
|
721 |
Â
*/
|
722 |
-
function bp_get_blog_class() {
|
723 |
Â
global $blogs_template;
|
724 |
Â
|
725 |
-
|
726 |
-
|
Â
|
|
Â
|
|
727 |
Â
|
728 |
-
// If we've only one site in the loop, don't bother with odd and even
|
729 |
-
|
730 |
-
$classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd';
|
731 |
-
else
|
732 |
Â
$classes[] = 'bp-single-blog';
|
Â
|
|
733 |
Â
|
734 |
Â
/**
|
735 |
Â
* Filters the row class of the current blog in the loop.
|
@@ -740,8 +750,8 @@ function bp_blog_class() {
|
|
740 |
Â
*/
|
741 |
Â
$classes = apply_filters( 'bp_get_blog_class', $classes );
|
742 |
Â
$classes = array_merge( $classes, array() );
|
Â
|
|
743 |
Â
|
744 |
-
$retval = 'class="' . join( ' ', $classes ) . '"';
|
745 |
Â
return $retval;
|
746 |
Â
}
|
747 |
Â
|
@@ -1114,9 +1124,11 @@ function bp_total_blog_count_for_user( $user_id = 0 ) {
|
|
1114 |
Â
* @return bool True if blog registration is enabled.
|
1115 |
Â
*/
|
1116 |
Â
function bp_blog_signup_enabled() {
|
1117 |
-
|
1118 |
Â
|
1119 |
-
$active_signup = isset( $bp->site_options['registration'] )
|
Â
|
|
Â
|
|
1120 |
Â
|
1121 |
Â
/**
|
1122 |
Â
* Filters whether or not blog creation is enabled.
|
@@ -1375,18 +1387,25 @@ function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name,
|
|
1375 |
Â
|
1376 |
Â
/**
|
1377 |
Â
* Output a "Create a Site" link for users viewing their own profiles.
|
Â
|
|
Â
|
|
Â
|
|
1378 |
Â
*/
|
1379 |
Â
function bp_create_blog_link() {
|
1380 |
-
if ( bp_is_my_profile() )
|
1381 |
Â
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1390 |
Â
}
|
1391 |
Â
|
1392 |
Â
/**
|
@@ -1397,10 +1416,9 @@ function bp_create_blog_link() {
|
|
1397 |
Â
function bp_blogs_blog_tabs() {
|
1398 |
Â
|
1399 |
Â
// Don't show these tabs on a user's own profile
|
1400 |
-
if ( bp_is_my_profile() )
|
1401 |
Â
return false;
|
1402 |
-
|
1403 |
-
?>
|
1404 |
Â
|
1405 |
Â
<ul class="content-header-nav">
|
1406 |
Â
<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>
|
@@ -1470,7 +1488,7 @@ function bp_blog_create_button() {
|
|
1470 |
Â
'link_text' => __( 'Create a Site', 'buddypress' ),
|
1471 |
Â
'link_title' => __( 'Create a Site', 'buddypress' ),
|
1472 |
Â
'link_class' => 'blog-create no-ajax',
|
1473 |
-
'link_href' => trailingslashit(
|
1474 |
Â
'wrapper' => false,
|
1475 |
Â
'block_self' => false,
|
1476 |
Â
);
|
76 |
Â
* @uses bp_get_blogs_directory_permalink()
|
77 |
Â
*/
|
78 |
Â
function bp_blogs_directory_permalink() {
|
79 |
+
echo esc_url( bp_get_blogs_directory_permalink() );
|
80 |
Â
}
|
81 |
Â
/**
|
82 |
Â
* Return blog directory permalink.
|
472 |
Â
$to_num = bp_core_number_format( ( $start_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $start_num + ( $blogs_template->pag_num - 1 ) );
|
473 |
Â
$total = bp_core_number_format( $blogs_template->total_blog_count );
|
474 |
Â
|
475 |
+
if ( 1 == $blogs_template->total_blog_count ) {
|
476 |
+
$message = __( 'Viewing 1 site', 'buddypress' );
|
477 |
+
} else {
|
478 |
+
$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 );
|
479 |
+
}
|
480 |
+
|
481 |
+
echo $message;
|
482 |
Â
}
|
483 |
Â
|
484 |
Â
/**
|
712 |
Â
* Output the row class of the current blog in the loop.
|
713 |
Â
*
|
714 |
Â
* @since BuddyPress (1.7.0)
|
715 |
+
*
|
716 |
+
* @param array $classes Array of custom classes
|
717 |
Â
*/
|
718 |
+
function bp_blog_class( $classes = array() ) {
|
719 |
+
echo bp_get_blog_class( $classes );
|
720 |
Â
}
|
721 |
Â
/**
|
722 |
Â
* Return the row class of the current blog in the loop.
|
724 |
Â
* @since BuddyPress (1.7.0)
|
725 |
Â
*
|
726 |
Â
* @global BP_Blogs_Template $blogs_template
|
727 |
+
* @param array $classes Array of custom classes
|
728 |
Â
*
|
729 |
Â
* @return string Row class of the site.
|
730 |
Â
*/
|
731 |
+
function bp_get_blog_class( $classes = array() ) {
|
732 |
Â
global $blogs_template;
|
733 |
Â
|
734 |
+
// Add even/odd classes, but only if there's more than 1 group
|
735 |
+
if ( $blogs_template->blog_count > 1 ) {
|
736 |
+
$pos_in_loop = (int) $blogs_template->current_blog;
|
737 |
+
$classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd';
|
738 |
Â
|
739 |
+
// If we've only one site in the loop, don't bother with odd and even
|
740 |
+
} else {
|
Â
|
|
Â
|
|
741 |
Â
$classes[] = 'bp-single-blog';
|
742 |
+
}
|
743 |
Â
|
744 |
Â
/**
|
745 |
Â
* Filters the row class of the current blog in the loop.
|
750 |
Â
*/
|
751 |
Â
$classes = apply_filters( 'bp_get_blog_class', $classes );
|
752 |
Â
$classes = array_merge( $classes, array() );
|
753 |
+
$retval = 'class="' . join( ' ', $classes ) . '"';
|
754 |
Â
|
Â
|
|
755 |
Â
return $retval;
|
756 |
Â
}
|
757 |
Â
|
1124 |
Â
* @return bool True if blog registration is enabled.
|
1125 |
Â
*/
|
1126 |
Â
function bp_blog_signup_enabled() {
|
1127 |
+
$bp = buddypress();
|
1128 |
Â
|
1129 |
+
$active_signup = isset( $bp->site_options['registration'] )
|
1130 |
+
? $bp->site_options['registration']
|
1131 |
+
: 'all';
|
1132 |
Â
|
1133 |
Â
/**
|
1134 |
Â
* Filters whether or not blog creation is enabled.
|
1387 |
Â
|
1388 |
Â
/**
|
1389 |
Â
* Output a "Create a Site" link for users viewing their own profiles.
|
1390 |
+
*
|
1391 |
+
* This function is not used by BuddyPress as of 1.2, but is kept here for older
|
1392 |
+
* themes that may still be using it.
|
1393 |
Â
*/
|
1394 |
Â
function bp_create_blog_link() {
|
Â
|
|
1395 |
Â
|
1396 |
+
// Don't show this link when not on your own profile
|
1397 |
+
if ( ! bp_is_my_profile() ) {
|
1398 |
+
return;
|
1399 |
+
}
|
1400 |
+
|
1401 |
+
/**
|
1402 |
+
* Filters "Create a Site" links for users viewing their own profiles.
|
1403 |
+
*
|
1404 |
+
* @since BuddyPress (1.0.0)
|
1405 |
+
*
|
1406 |
+
* @param string $value HTML link for creating a site.
|
1407 |
+
*/
|
1408 |
+
echo apply_filters( 'bp_create_blog_link', '<a href="' . trailingslashit( bp_get_blogs_directory_permalink() . 'create' ) . '">' . __( 'Create a Site', 'buddypress' ) . '</a>' );
|
1409 |
Â
}
|
1410 |
Â
|
1411 |
Â
/**
|
1416 |
Â
function bp_blogs_blog_tabs() {
|
1417 |
Â
|
1418 |
Â
// Don't show these tabs on a user's own profile
|
1419 |
+
if ( bp_is_my_profile() ) {
|
1420 |
Â
return false;
|
1421 |
+
} ?>
|
Â
|
|
1422 |
Â
|
1423 |
Â
<ul class="content-header-nav">
|
1424 |
Â
<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>
|
1488 |
Â
'link_text' => __( 'Create a Site', 'buddypress' ),
|
1489 |
Â
'link_title' => __( 'Create a Site', 'buddypress' ),
|
1490 |
Â
'link_class' => 'blog-create no-ajax',
|
1491 |
+
'link_href' => trailingslashit( bp_get_blogs_directory_permalink() . 'create' ),
|
1492 |
Â
'wrapper' => false,
|
1493 |
Â
'block_self' => false,
|
1494 |
Â
);
|
bp-blogs/bp-blogs-widgets.php
CHANGED
@@ -16,8 +16,9 @@ defined( 'ABSPATH' ) || exit;
|
|
16 |
Â
function bp_blogs_register_widgets() {
|
17 |
Â
global $wpdb;
|
18 |
Â
|
19 |
-
if ( bp_is_active( 'activity' ) && (
|
20 |
Â
add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Blogs_Recent_Posts_Widget");' ) );
|
Â
|
|
21 |
Â
}
|
22 |
Â
add_action( 'bp_register_widgets', 'bp_blogs_register_widgets' );
|
23 |
Â
|
@@ -29,7 +30,7 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
|
|
29 |
Â
/**
|
30 |
Â
* Constructor method.
|
31 |
Â
*/
|
32 |
-
function __construct() {
|
33 |
Â
$widget_ops = array(
|
34 |
Â
'description' => __( 'A list of recently published posts from across your network.', 'buddypress' ),
|
35 |
Â
'classname' => 'widget_bp_blogs_widget buddypress widget',
|
@@ -45,31 +46,47 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
|
|
45 |
Â
* @param array $args Widget arguments.
|
46 |
Â
* @param array $instance Widget settings, as saved by the user.
|
47 |
Â
*/
|
48 |
-
function widget( $args, $instance ) {
|
49 |
Â
|
50 |
-
$title = ! empty( $instance['title'] )
|
Â
|
|
Â
|
|
51 |
Â
|
52 |
Â
if ( ! empty( $instance['link_title'] ) ) {
|
53 |
-
$title = '<a href="' .
|
54 |
Â
}
|
55 |
Â
|
56 |
Â
/**
|
57 |
Â
* Filters the Blogs Recent Posts widget title.
|
58 |
Â
*
|
59 |
Â
* @since BuddyPress (2.2.0)
|
Â
|
|
60 |
Â
*
|
61 |
-
* @param string $title
|
Â
|
|
Â
|
|
62 |
Â
*/
|
63 |
-
$title = apply_filters( 'widget_title', $
|
64 |
Â
|
65 |
Â
echo $args['before_widget'];
|
66 |
Â
echo $args['before_title'] . $title . $args['after_title'];
|
67 |
Â
|
68 |
-
if ( empty( $instance['max_posts'] ) ||
|
69 |
-
$instance['max_posts'] = 10;
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
70 |
Â
|
71 |
-
<?php
|
72 |
-
<?php if ( bp_has_activities( array( 'action' => 'new_blog_post', 'max' => $instance['max_posts'], 'per_page' => $instance['max_posts'], 'user_id' => 0, 'scope' => false, 'object' => false, 'primary_id' => false ) ) ) : ?>
|
73 |
Â
|
74 |
Â
<ul id="blog-post-list" class="activity-list item-list">
|
75 |
Â
|
@@ -77,15 +94,12 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
|
|
77 |
Â
|
78 |
Â
<li>
|
79 |
Â
<div class="activity-content" style="margin: 0">
|
80 |
-
|
81 |
-
<div class="activity-header">
|
82 |
-
<?php bp_activity_action() ?>
|
83 |
-
</div>
|
84 |
Â
|
85 |
Â
<?php if ( bp_get_activity_content_body() ) : ?>
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
Â
<?php endif; ?>
|
90 |
Â
|
91 |
Â
</div>
|
@@ -96,9 +110,11 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
|
|
96 |
Â
</ul>
|
97 |
Â
|
98 |
Â
<?php else : ?>
|
Â
|
|
99 |
Â
<div id="message" class="info">
|
100 |
-
<p><?php _e( 'Sorry, there were no posts found. Why not write one?', 'buddypress' ) ?></p>
|
101 |
Â
</div>
|
Â
|
|
102 |
Â
<?php endif; ?>
|
103 |
Â
|
104 |
Â
<?php echo $args['after_widget']; ?>
|
@@ -112,10 +128,10 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
|
|
112 |
Â
* @param array $old_instance The old instance options.
|
113 |
Â
* @return array $instance The parsed options to be saved.
|
114 |
Â
*/
|
115 |
-
function update( $new_instance, $old_instance ) {
|
116 |
-
$instance
|
117 |
-
$instance['title']
|
118 |
-
$instance['max_posts']
|
119 |
Â
$instance['link_title'] = (bool) $new_instance['link_title'];
|
120 |
Â
|
121 |
Â
return $instance;
|
@@ -126,22 +142,22 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
|
|
126 |
Â
*
|
127 |
Â
* @param $instance Settings for this widget.
|
128 |
Â
*/
|
129 |
-
function form( $instance ) {
|
130 |
Â
$instance = wp_parse_args( (array) $instance, array(
|
131 |
Â
'title' => __( 'Recent Networkwide Posts', 'buddypress' ),
|
132 |
Â
'max_posts' => 10,
|
133 |
Â
'link_title' => false,
|
134 |
Â
) );
|
135 |
Â
|
136 |
-
$title
|
137 |
-
$max_posts
|
138 |
Â
$link_title = (bool) $instance['link_title'];
|
139 |
Â
|
140 |
Â
?>
|
141 |
Â
|
142 |
-
<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>
|
143 |
-
<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>
|
144 |
-
<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>
|
145 |
Â
<?php
|
146 |
Â
}
|
147 |
Â
}
|
16 |
Â
function bp_blogs_register_widgets() {
|
17 |
Â
global $wpdb;
|
18 |
Â
|
19 |
+
if ( bp_is_active( 'activity' ) && bp_is_root_blog( $wpdb->blogid ) ) {
|
20 |
Â
add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Blogs_Recent_Posts_Widget");' ) );
|
21 |
+
}
|
22 |
Â
}
|
23 |
Â
add_action( 'bp_register_widgets', 'bp_blogs_register_widgets' );
|
24 |
Â
|
30 |
Â
/**
|
31 |
Â
* Constructor method.
|
32 |
Â
*/
|
33 |
+
public function __construct() {
|
34 |
Â
$widget_ops = array(
|
35 |
Â
'description' => __( 'A list of recently published posts from across your network.', 'buddypress' ),
|
36 |
Â
'classname' => 'widget_bp_blogs_widget buddypress widget',
|
46 |
Â
* @param array $args Widget arguments.
|
47 |
Â
* @param array $instance Widget settings, as saved by the user.
|
48 |
Â
*/
|
49 |
+
public function widget( $args, $instance ) {
|
50 |
Â
|
51 |
+
$title = ! empty( $instance['title'] )
|
52 |
+
? esc_html( $instance['title'] )
|
53 |
+
: __( 'Recent Networkwide Posts', 'buddypress' );
|
54 |
Â
|
55 |
Â
if ( ! empty( $instance['link_title'] ) ) {
|
56 |
+
$title = '<a href="' . bp_get_blogs_directory_permalink() . '">' . esc_html( $title ) . '</a>';
|
57 |
Â
}
|
58 |
Â
|
59 |
Â
/**
|
60 |
Â
* Filters the Blogs Recent Posts widget title.
|
61 |
Â
*
|
62 |
Â
* @since BuddyPress (2.2.0)
|
63 |
+
* @since BuddyPress (2.3.0) Added 'instance' and 'id_base' to arguments passed to filter.
|
64 |
Â
*
|
65 |
+
* @param string $title The widget title.
|
66 |
+
* @param array $instance The settings for the particular instance of the widget.
|
67 |
+
* @param string $id_base Root ID for all widgets of this type.
|
68 |
Â
*/
|
69 |
+
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
70 |
Â
|
71 |
Â
echo $args['before_widget'];
|
72 |
Â
echo $args['before_title'] . $title . $args['after_title'];
|
73 |
Â
|
74 |
+
if ( empty( $instance['max_posts'] ) || empty( $instance['max_posts'] ) ) {
|
75 |
+
$instance['max_posts'] = 10;
|
76 |
+
}
|
77 |
+
|
78 |
+
// Override some of the contextually set parameters for bp_has_activities()
|
79 |
+
$args = array(
|
80 |
+
'action' => 'new_blog_post',
|
81 |
+
'max' => $instance['max_posts'],
|
82 |
+
'per_page' => $instance['max_posts'],
|
83 |
+
'user_id' => 0,
|
84 |
+
'scope' => false,
|
85 |
+
'object' => false,
|
86 |
+
'primary_id' => false
|
87 |
+
); ?>
|
88 |
Â
|
89 |
+
<?php if ( bp_has_activities( $args ) ) : ?>
|
Â
|
|
90 |
Â
|
91 |
Â
<ul id="blog-post-list" class="activity-list item-list">
|
92 |
Â
|
94 |
Â
|
95 |
Â
<li>
|
96 |
Â
<div class="activity-content" style="margin: 0">
|
97 |
+
<div class="activity-header"><?php bp_activity_action(); ?></div>
|
Â
|
|
Â
|
|
Â
|
|
98 |
Â
|
99 |
Â
<?php if ( bp_get_activity_content_body() ) : ?>
|
100 |
+
|
101 |
+
<div class="activity-inner"><?php bp_activity_content_body(); ?></div>
|
102 |
+
|
103 |
Â
<?php endif; ?>
|
104 |
Â
|
105 |
Â
</div>
|
110 |
Â
</ul>
|
111 |
Â
|
112 |
Â
<?php else : ?>
|
113 |
+
|
114 |
Â
<div id="message" class="info">
|
115 |
+
<p><?php _e( 'Sorry, there were no posts found. Why not write one?', 'buddypress' ); ?></p>
|
116 |
Â
</div>
|
117 |
+
|
118 |
Â
<?php endif; ?>
|
119 |
Â
|
120 |
Â
<?php echo $args['after_widget']; ?>
|
128 |
Â
* @param array $old_instance The old instance options.
|
129 |
Â
* @return array $instance The parsed options to be saved.
|
130 |
Â
*/
|
131 |
+
public function update( $new_instance, $old_instance ) {
|
132 |
+
$instance = $old_instance;
|
133 |
+
$instance['title'] = strip_tags( $new_instance['title'] );
|
134 |
+
$instance['max_posts'] = strip_tags( $new_instance['max_posts'] );
|
135 |
Â
$instance['link_title'] = (bool) $new_instance['link_title'];
|
136 |
Â
|
137 |
Â
return $instance;
|
142 |
Â
*
|
143 |
Â
* @param $instance Settings for this widget.
|
144 |
Â
*/
|
145 |
+
public function form( $instance ) {
|
146 |
Â
$instance = wp_parse_args( (array) $instance, array(
|
147 |
Â
'title' => __( 'Recent Networkwide Posts', 'buddypress' ),
|
148 |
Â
'max_posts' => 10,
|
149 |
Â
'link_title' => false,
|
150 |
Â
) );
|
151 |
Â
|
152 |
+
$title = strip_tags( $instance['title'] );
|
153 |
+
$max_posts = strip_tags( $instance['max_posts'] );
|
154 |
Â
$link_title = (bool) $instance['link_title'];
|
155 |
Â
|
156 |
Â
?>
|
157 |
Â
|
158 |
+
<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>
|
159 |
+
<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>
|
160 |
+
<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>
|
161 |
Â
<?php
|
162 |
Â
}
|
163 |
Â
}
|
bp-blogs/classes/class-bp-blogs-blog.php
ADDED
@@ -0,0 +1,608 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* BuddyPress Blogs Classes.
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
* @subpackage BlogsClasses
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Exit if accessed directly
|
10 |
+
defined( 'ABSPATH' ) || exit;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* The main BuddyPress blog class.
|
14 |
+
*
|
15 |
+
* A BP_Blogs_Object represents a link between a specific WordPress blog on a
|
16 |
+
* network and a specific user on that blog.
|
17 |
+
*
|
18 |
+
* @since BuddyPress (1.0.0)
|
19 |
+
*/
|
20 |
+
class BP_Blogs_Blog {
|
21 |
+
public $id;
|
22 |
+
public $user_id;
|
23 |
+
public $blog_id;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Constructor method.
|
27 |
+
*
|
28 |
+
* @param int $id Optional. The ID of the blog.
|
29 |
+
*/
|
30 |
+
public function __construct( $id = null ) {
|
31 |
+
if ( !empty( $id ) ) {
|
32 |
+
$this->id = $id;
|
33 |
+
$this->populate();
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Populate the object with data about the specific activity item.
|
39 |
+
*/
|
40 |
+
public function populate() {
|
41 |
+
global $wpdb;
|
42 |
+
|
43 |
+
$bp = buddypress();
|
44 |
+
|
45 |
+
$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name} WHERE id = %d", $this->id ) );
|
46 |
+
|
47 |
+
$this->user_id = $blog->user_id;
|
48 |
+
$this->blog_id = $blog->blog_id;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Save the BP blog data to the database.
|
53 |
+
*
|
54 |
+
* @return bool True on success, false on failure.
|
55 |
+
*/
|
56 |
+
public function save() {
|
57 |
+
global $wpdb;
|
58 |
+
|
59 |
+
$this->user_id = apply_filters( 'bp_blogs_blog_user_id_before_save', $this->user_id, $this->id );
|
60 |
+
$this->blog_id = apply_filters( 'bp_blogs_blog_id_before_save', $this->blog_id, $this->id );
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Fires before the current blog item gets saved.
|
64 |
+
*
|
65 |
+
* Please use this hook to filter the properties above. Each part will be passed in.
|
66 |
+
*
|
67 |
+
* @since BuddyPress (1.0.0)
|
68 |
+
*
|
69 |
+
* @param BP_Blogs_Blog Current instance of the blog item being saved. Passed by reference.
|
70 |
+
*/
|
71 |
+
do_action_ref_array( 'bp_blogs_blog_before_save', array( &$this ) );
|
72 |
+
|
73 |
+
// Don't try and save if there is no user ID or blog ID set.
|
74 |
+
if ( !$this->user_id || !$this->blog_id )
|
75 |
+
return false;
|
76 |
+
|
77 |
+
// Don't save if this blog has already been recorded for the user.
|
78 |
+
if ( !$this->id && $this->exists() )
|
79 |
+
return false;
|
80 |
+
|
81 |
+
$bp = buddypress();
|
82 |
+
|
83 |
+
if ( $this->id ) {
|
84 |
+
// Update
|
85 |
+
$sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name} SET user_id = %d, blog_id = %d WHERE id = %d", $this->user_id, $this->blog_id, $this->id );
|
86 |
+
} else {
|
87 |
+
// Save
|
88 |
+
$sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name} ( user_id, blog_id ) VALUES ( %d, %d )", $this->user_id, $this->blog_id );
|
89 |
+
}
|
90 |
+
|
91 |
+
if ( !$wpdb->query($sql) )
|
92 |
+
return false;
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Fires after the current blog item gets saved.
|
96 |
+
*
|
97 |
+
* Please use this hook to filter the properties above. Each part will be passed in.
|
98 |
+
*
|
99 |
+
* @since BuddyPress (1.0.0)
|
100 |
+
*
|
101 |
+
* @param BP_Blogs_Blog Current instance of the blog item being saved. Passed by reference.
|
102 |
+
*/
|
103 |
+
do_action_ref_array( 'bp_blogs_blog_after_save', array( &$this ) );
|
104 |
+
|
105 |
+
if ( $this->id )
|
106 |
+
return $this->id;
|
107 |
+
else
|
108 |
+
return $wpdb->insert_id;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Check whether an association between this user and this blog exists.
|
113 |
+
*
|
114 |
+
* @return int The number of associations between the user and blog
|
115 |
+
* saved in the blog component tables.
|
116 |
+
*/
|
117 |
+
public function exists() {
|
118 |
+
global $wpdb;
|
119 |
+
|
120 |
+
$bp = buddypress();
|
121 |
+
|
122 |
+
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $this->user_id, $this->blog_id ) );
|
123 |
+
}
|
124 |
+
|
125 |
+
/** Static Methods ***************************************************/
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Retrieve a set of blog-user associations.
|
129 |
+
*
|
130 |
+
* @param string $type The order in which results should be returned.
|
131 |
+
* 'active', 'alphabetical', 'newest', or 'random'.
|
132 |
+
* @param int|bool $limit Optional. The maximum records to return.
|
133 |
+
* Default: false.
|
134 |
+
* @param int|bool $page Optional. The page of records to return.
|
135 |
+
* Default: false (unlimited results).
|
136 |
+
* @param int $user_id Optional. ID of the user whose blogs are being
|
137 |
+
* retrieved. Default: 0.
|
138 |
+
* @param string|bool $search_terms Optional. Search by text stored in
|
139 |
+
* blogmeta (such as the blog name). Default: false.
|
140 |
+
* @param bool $update_meta_cache Whether to pre-fetch metadata for
|
141 |
+
* blogs. Default: true.
|
142 |
+
* @param array $include_blog_ids Array of blog IDs to include.
|
143 |
+
* @return array Multidimensional results array, structured as follows:
|
144 |
+
* 'blogs' - Array of located blog objects
|
145 |
+
* 'total' - A count of the total blogs matching the filter params
|
146 |
+
*/
|
147 |
+
public static function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false, $update_meta_cache = true, $include_blog_ids = false ) {
|
148 |
+
global $wpdb;
|
149 |
+
|
150 |
+
$bp = buddypress();
|
151 |
+
|
152 |
+
if ( !is_user_logged_in() || ( !bp_current_user_can( 'bp_moderate' ) && ( $user_id != bp_loggedin_user_id() ) ) )
|
153 |
+
$hidden_sql = "AND wb.public = 1";
|
154 |
+
else
|
155 |
+
$hidden_sql = '';
|
156 |
+
|
157 |
+
$pag_sql = ( $limit && $page ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';
|
158 |
+
|
159 |
+
$user_sql = !empty( $user_id ) ? $wpdb->prepare( " AND b.user_id = %d", $user_id ) : '';
|
160 |
+
|
161 |
+
switch ( $type ) {
|
162 |
+
case 'active': default:
|
163 |
+
$order_sql = "ORDER BY bm.meta_value DESC";
|
164 |
+
break;
|
165 |
+
case 'alphabetical':
|
166 |
+
$order_sql = "ORDER BY bm_name.meta_value ASC";
|
167 |
+
break;
|
168 |
+
case 'newest':
|
169 |
+
$order_sql = "ORDER BY wb.registered DESC";
|
170 |
+
break;
|
171 |
+
case 'random':
|
172 |
+
$order_sql = "ORDER BY RAND()";
|
173 |
+
break;
|
174 |
+
}
|
175 |
+
|
176 |
+
$include_sql = '';
|
177 |
+
$include_blog_ids = array_filter( wp_parse_id_list( $include_blog_ids ) );
|
178 |
+
if ( ! empty( $include_blog_ids ) ) {
|
179 |
+
$blog_ids_sql = implode( ',', $include_blog_ids );
|
180 |
+
$include_sql = " AND b.blog_id IN ({$blog_ids_sql})";
|
181 |
+
}
|
182 |
+
|
183 |
+
if ( ! empty( $search_terms ) ) {
|
184 |
+
$search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
|
185 |
+
$search_terms_sql = $wpdb->prepare( 'AND (bm_name.meta_value LIKE %s OR bm_description.meta_value LIKE %s)', $search_terms_like, $search_terms_like );
|
186 |
+
} else {
|
187 |
+
$search_terms_sql = '';
|
188 |
+
}
|
189 |
+
|
190 |
+
$paged_blogs = $wpdb->get_results( "
|
191 |
+
SELECT b.blog_id, b.user_id as admin_user_id, u.user_email as admin_user_email, wb.domain, wb.path, bm.meta_value as last_activity, bm_name.meta_value as name
|
192 |
+
FROM
|
193 |
+
{$bp->blogs->table_name} b
|
194 |
+
LEFT JOIN {$bp->blogs->table_name_blogmeta} bm ON (b.blog_id = bm.blog_id)
|
195 |
+
LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_name ON (b.blog_id = bm_name.blog_id)
|
196 |
+
LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_description ON (b.blog_id = bm_description.blog_id)
|
197 |
+
LEFT JOIN {$wpdb->base_prefix}blogs wb ON (b.blog_id = wb.blog_id)
|
198 |
+
LEFT JOIN {$wpdb->users} u ON (b.user_id = u.ID)
|
199 |
+
WHERE
|
200 |
+
wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql}
|
201 |
+
AND bm.meta_key = 'last_activity' AND bm_name.meta_key = 'name' AND bm_description.meta_key = 'description'
|
202 |
+
{$search_terms_sql} {$user_sql} {$include_sql}
|
203 |
+
GROUP BY b.blog_id {$order_sql} {$pag_sql}
|
204 |
+
" );
|
205 |
+
|
206 |
+
$total_blogs = $wpdb->get_var( "
|
207 |
+
SELECT COUNT(DISTINCT b.blog_id)
|
208 |
+
FROM
|
209 |
+
{$bp->blogs->table_name} b
|
210 |
+
LEFT JOIN {$wpdb->base_prefix}blogs wb ON (b.blog_id = wb.blog_id)
|
211 |
+
LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_name ON (b.blog_id = bm_name.blog_id)
|
212 |
+
LEFT JOIN {$bp->blogs->table_name_blogmeta} bm_description ON (b.blog_id = bm_description.blog_id)
|
213 |
+
WHERE
|
214 |
+
wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql}
|
215 |
+
AND
|
216 |
+
bm_name.meta_key = 'name' AND bm_description.meta_key = 'description'
|
217 |
+
{$search_terms_sql} {$user_sql} {$include_sql}
|
218 |
+
" );
|
219 |
+
|
220 |
+
$blog_ids = array();
|
221 |
+
foreach ( (array) $paged_blogs as $blog ) {
|
222 |
+
$blog_ids[] = (int) $blog->blog_id;
|
223 |
+
}
|
224 |
+
|
225 |
+
$paged_blogs = BP_Blogs_Blog::get_blog_extras( $paged_blogs, $blog_ids, $type );
|
226 |
+
|
227 |
+
if ( $update_meta_cache ) {
|
228 |
+
bp_blogs_update_meta_cache( $blog_ids );
|
229 |
+
}
|
230 |
+
|
231 |
+
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Delete the record of a given blog for all users.
|
236 |
+
*
|
237 |
+
* @param int $blog_id The blog being removed from all users.
|
238 |
+
* @return int|bool Number of rows deleted on success, false on failure.
|
239 |
+
*/
|
240 |
+
public static function delete_blog_for_all( $blog_id ) {
|
241 |
+
global $wpdb;
|
242 |
+
|
243 |
+
bp_blogs_delete_blogmeta( $blog_id );
|
244 |
+
|
245 |
+
$bp = buddypress();
|
246 |
+
|
247 |
+
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Delete the record of a given blog for a specific user.
|
252 |
+
*
|
253 |
+
* @param int $blog_id The blog being removed.
|
254 |
+
* @param int $user_id Optional. The ID of the user from whom the blog
|
255 |
+
* is being removed. If absent, defaults to the logged-in user ID.
|
256 |
+
* @return int|bool Number of rows deleted on success, false on failure.
|
257 |
+
*/
|
258 |
+
public static function delete_blog_for_user( $blog_id, $user_id = null ) {
|
259 |
+
global $wpdb;
|
260 |
+
|
261 |
+
if ( !$user_id )
|
262 |
+
$user_id = bp_loggedin_user_id();
|
263 |
+
|
264 |
+
$bp = buddypress();
|
265 |
+
|
266 |
+
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) );
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Delete all of a user's blog associations in the BP tables.
|
271 |
+
*
|
272 |
+
* @param int $user_id Optional. The ID of the user whose blog
|
273 |
+
* associations are being deleted. If absent, defaults to
|
274 |
+
* logged-in user ID.
|
275 |
+
* @return int|bool Number of rows deleted on success, false on failure.
|
276 |
+
*/
|
277 |
+
public static function delete_blogs_for_user( $user_id = null ) {
|
278 |
+
global $wpdb;
|
279 |
+
|
280 |
+
if ( !$user_id )
|
281 |
+
$user_id = bp_loggedin_user_id();
|
282 |
+
|
283 |
+
$bp = buddypress();
|
284 |
+
|
285 |
+
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Get all of a user's blogs, as tracked by BuddyPress.
|
290 |
+
*
|
291 |
+
* Note that this is different from the WordPress function
|
292 |
+
* {@link get_blogs_of_user()}; the current method returns only those
|
293 |
+
* blogs that have been recorded by BuddyPress, while the WP function
|
294 |
+
* does a true query of a user's blog capabilities.
|
295 |
+
*
|
296 |
+
* @param int $user_id Optional. ID of the user whose blogs are being
|
297 |
+
* queried. Defaults to logged-in user.
|
298 |
+
* @param bool $show_hidden Optional. Whether to include blogs that are
|
299 |
+
* not marked public. Defaults to true when viewing one's own
|
300 |
+
* profile.
|
301 |
+
* @return array Multidimensional results array, structured as follows:
|
302 |
+
* 'blogs' - Array of located blog objects
|
303 |
+
* 'total' - A count of the total blogs for the user.
|
304 |
+
*/
|
305 |
+
public static function get_blogs_for_user( $user_id = 0, $show_hidden = false ) {
|
306 |
+
global $wpdb;
|
307 |
+
|
308 |
+
$bp = buddypress();
|
309 |
+
|
310 |
+
if ( !$user_id )
|
311 |
+
$user_id = bp_displayed_user_id();
|
312 |
+
|
313 |
+
// Show logged in users their hidden blogs.
|
314 |
+
if ( !bp_is_my_profile() && !$show_hidden )
|
315 |
+
$blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ) );
|
316 |
+
else
|
317 |
+
$blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ) );
|
318 |
+
|
319 |
+
$total_blog_count = BP_Blogs_Blog::total_blog_count_for_user( $user_id );
|
320 |
+
|
321 |
+
$user_blogs = array();
|
322 |
+
foreach ( (array) $blogs as $blog ) {
|
323 |
+
$user_blogs[$blog->blog_id] = new stdClass;
|
324 |
+
$user_blogs[$blog->blog_id]->id = $blog->id;
|
325 |
+
$user_blogs[$blog->blog_id]->blog_id = $blog->blog_id;
|
326 |
+
$user_blogs[$blog->blog_id]->siteurl = ( is_ssl() ) ? 'https://' . $blog->domain . $blog->path : 'http://' . $blog->domain . $blog->path;
|
327 |
+
$user_blogs[$blog->blog_id]->name = $blog->name;
|
328 |
+
}
|
329 |
+
|
330 |
+
return array( 'blogs' => $user_blogs, 'count' => $total_blog_count );
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Get IDs of all of a user's blogs, as tracked by BuddyPress.
|
335 |
+
*
|
336 |
+
* This method always includes hidden blogs.
|
337 |
+
*
|
338 |
+
* @param int $user_id Optional. ID of the user whose blogs are being
|
339 |
+
* queried. Defaults to logged-in user.
|
340 |
+
* @return int The number of blogs associated with the user.
|
341 |
+
*/
|
342 |
+
public static function get_blog_ids_for_user( $user_id = 0 ) {
|
343 |
+
global $wpdb;
|
344 |
+
|
345 |
+
$bp = buddypress();
|
346 |
+
|
347 |
+
if ( !$user_id )
|
348 |
+
$user_id = bp_displayed_user_id();
|
349 |
+
|
350 |
+
return $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
|
351 |
+
}
|
352 |
+
|
353 |
+
/**
|
354 |
+
* Check whether a blog has been recorded by BuddyPress.
|
355 |
+
*
|
356 |
+
* @param int $blog_id ID of the blog being queried.
|
357 |
+
* @return int|null The ID of the first located entry in the BP table
|
358 |
+
* on success, otherwise null.
|
359 |
+
*/
|
360 |
+
public static function is_recorded( $blog_id ) {
|
361 |
+
global $wpdb;
|
362 |
+
|
363 |
+
$bp = buddypress();
|
364 |
+
|
365 |
+
return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Return a count of associated blogs for a given user.
|
370 |
+
*
|
371 |
+
* Includes hidden blogs when the logged-in user is the same as the
|
372 |
+
* $user_id parameter, or when the logged-in user has the bp_moderate
|
373 |
+
* cap.
|
374 |
+
*
|
375 |
+
* @param int $user_id Optional. ID of the user whose blogs are being
|
376 |
+
* queried. Defaults to logged-in user.
|
377 |
+
* @return int Blog count for the user.
|
378 |
+
*/
|
379 |
+
public static function total_blog_count_for_user( $user_id = null ) {
|
380 |
+
global $wpdb;
|
381 |
+
|
382 |
+
$bp = buddypress();
|
383 |
+
|
384 |
+
if ( !$user_id )
|
385 |
+
$user_id = bp_displayed_user_id();
|
386 |
+
|
387 |
+
// If the user is logged in return the blog count including their hidden blogs.
|
388 |
+
if ( ( is_user_logged_in() && $user_id == bp_loggedin_user_id() ) || bp_current_user_can( 'bp_moderate' ) ) {
|
389 |
+
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id ) );
|
390 |
+
} else {
|
391 |
+
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id ) );
|
392 |
+
}
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* Return a list of blogs matching a search term.
|
397 |
+
*
|
398 |
+
* Matches against blog names and descriptions, as stored in the BP
|
399 |
+
* blogmeta table.
|
400 |
+
*
|
401 |
+
* @param string $filter The search term.
|
402 |
+
* @param int $limit Optional. The maximum number of items to return.
|
403 |
+
* Default: null (no limit).
|
404 |
+
* @param int $page Optional. The page of results to return. Default:
|
405 |
+
* null (no limit).
|
406 |
+
* @return array Multidimensional results array, structured as follows:
|
407 |
+
* 'blogs' - Array of located blog objects
|
408 |
+
* 'total' - A count of the total blogs matching the query.
|
409 |
+
*/
|
410 |
+
public static function search_blogs( $filter, $limit = null, $page = null ) {
|
411 |
+
global $wpdb;
|
412 |
+
|
413 |
+
$search_terms_like = '%' . bp_esc_like( $filter ) . '%';
|
414 |
+
$search_terms_sql = $wpdb->prepare( 'bm.meta_value LIKE %s', $search_terms_like );
|
415 |
+
|
416 |
+
$hidden_sql = '';
|
417 |
+
if ( !bp_current_user_can( 'bp_moderate' ) )
|
418 |
+
$hidden_sql = "AND wb.public = 1";
|
419 |
+
|
420 |
+
$pag_sql = '';
|
421 |
+
if ( $limit && $page ) {
|
422 |
+
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
423 |
+
}
|
424 |
+
|
425 |
+
$bp = buddypress();
|
426 |
+
|
427 |
+
$paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND {$search_terms_sql} ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC{$pag_sql}" );
|
428 |
+
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND {$search_terms_sql} ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC" );
|
429 |
+
|
430 |
+
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
431 |
+
}
|
432 |
+
|
433 |
+
/**
|
434 |
+
* Retrieve a list of all blogs.
|
435 |
+
*
|
436 |
+
* Query will include hidden blogs if the logged-in user has the
|
437 |
+
* 'bp_moderate' cap.
|
438 |
+
*
|
439 |
+
* @param int $limit Optional. The maximum number of items to return.
|
440 |
+
* Default: null (no limit).
|
441 |
+
* @param int $page Optional. The page of results to return. Default:
|
442 |
+
* null (no limit).
|
443 |
+
* @return array Multidimensional results array, structured as follows:
|
444 |
+
* 'blogs' - Array of located blog objects
|
445 |
+
* 'total' - A count of the total blogs.
|
446 |
+
*/
|
447 |
+
public static function get_all( $limit = null, $page = null ) {
|
448 |
+
global $wpdb;
|
449 |
+
|
450 |
+
$bp = buddypress();
|
451 |
+
|
452 |
+
$hidden_sql = !bp_current_user_can( 'bp_moderate' ) ? "AND wb.public = 1" : '';
|
453 |
+
$pag_sql = ( $limit && $page ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';
|
454 |
+
|
455 |
+
$paged_blogs = $wpdb->get_results( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql} {$pag_sql}" );
|
456 |
+
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql}" );
|
457 |
+
|
458 |
+
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* Retrieve a list of blogs whose names start with a given letter.
|
463 |
+
*
|
464 |
+
* Query will include hidden blogs if the logged-in user has the
|
465 |
+
* 'bp_moderate' cap.
|
466 |
+
*
|
467 |
+
* @param string $letter. The letter you're looking for.
|
468 |
+
* @param int $limit Optional. The maximum number of items to return.
|
469 |
+
* Default: null (no limit).
|
470 |
+
* @param int $page Optional. The page of results to return. Default:
|
471 |
+
* null (no limit).
|
472 |
+
* @return array Multidimensional results array, structured as follows:
|
473 |
+
* 'blogs' - Array of located blog objects.
|
474 |
+
* 'total' - A count of the total blogs matching the query.
|
475 |
+
*/
|
476 |
+
public static function get_by_letter( $letter, $limit = null, $page = null ) {
|
477 |
+
global $wpdb;
|
478 |
+
|
479 |
+
$bp = buddypress();
|
480 |
+
|
481 |
+
$letter_like = '%' . bp_esc_like( $letter ) . '%';
|
482 |
+
$letter_sql = $wpdb->prepare( 'bm.meta_value LIKE %s', $letter_like );
|
483 |
+
|
484 |
+
$hidden_sql = '';
|
485 |
+
if ( !bp_current_user_can( 'bp_moderate' ) )
|
486 |
+
$hidden_sql = "AND wb.public = 1";
|
487 |
+
|
488 |
+
$pag_sql = '';
|
489 |
+
if ( $limit && $page )
|
490 |
+
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
491 |
+
|
492 |
+
$paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND {$letter_sql} {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC{$pag_sql}" );
|
493 |
+
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND {$letter_sql} {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC" );
|
494 |
+
|
495 |
+
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
496 |
+
}
|
497 |
+
|
498 |
+
/**
|
499 |
+
* Fetch blog data not caught in the main query and append it to results array.
|
500 |
+
*
|
501 |
+
* Gets the following information, which is either unavailable at the
|
502 |
+
* time of the original query, or is more efficient to look up in one
|
503 |
+
* fell swoop:
|
504 |
+
* - The latest post for each blog, include Featured Image data
|
505 |
+
* - The blog description
|
506 |
+
*
|
507 |
+
* @param array $paged_blogs Array of results from the original query.
|
508 |
+
* @param array $blog_ids Array of IDs returned from the original query.
|
509 |
+
* @param string|bool $type Not currently used. Default: false.
|
510 |
+
* @return array $paged_blogs The located blogs array, with the extras added.
|
511 |
+
*/
|
512 |
+
public static function get_blog_extras( &$paged_blogs, &$blog_ids, $type = false ) {
|
513 |
+
global $wpdb;
|
514 |
+
|
515 |
+
$bp = buddypress();
|
516 |
+
|
517 |
+
if ( empty( $blog_ids ) )
|
518 |
+
return $paged_blogs;
|
519 |
+
|
520 |
+
$blog_ids = implode( ',', wp_parse_id_list( $blog_ids ) );
|
521 |
+
|
522 |
+
for ( $i = 0, $count = count( $paged_blogs ); $i < $count; ++$i ) {
|
523 |
+
$blog_prefix = $wpdb->get_blog_prefix( $paged_blogs[$i]->blog_id );
|
524 |
+
$paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT ID, post_content, post_title, post_excerpt, guid FROM {$blog_prefix}posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" );
|
525 |
+
$images = array();
|
526 |
+
|
527 |
+
// Add URLs to any Featured Image this post might have
|
528 |
+
if ( ! empty( $paged_blogs[$i]->latest_post ) && has_post_thumbnail( $paged_blogs[$i]->latest_post->ID ) ) {
|
529 |
+
|
530 |
+
// Grab 4 sizes of the image. Thumbnail.
|
531 |
+
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'thumbnail', false );
|
532 |
+
if ( ! empty( $image ) )
|
533 |
+
$images['thumbnail'] = $image[0];
|
534 |
+
|
535 |
+
// Medium
|
536 |
+
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'medium', false );
|
537 |
+
if ( ! empty( $image ) )
|
538 |
+
$images['medium'] = $image[0];
|
539 |
+
|
540 |
+
// Large
|
541 |
+
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'large', false );
|
542 |
+
if ( ! empty( $image ) )
|
543 |
+
$images['large'] = $image[0];
|
544 |
+
|
545 |
+
// Post thumbnail
|
546 |
+
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'post-thumbnail', false );
|
547 |
+
if ( ! empty( $image ) )
|
548 |
+
$images['post-thumbnail'] = $image[0];
|
549 |
+
|
550 |
+
// Add the images to the latest_post object
|
551 |
+
$paged_blogs[$i]->latest_post->images = $images;
|
552 |
+
}
|
553 |
+
}
|
554 |
+
|
555 |
+
/* Fetch the blog description for each blog (as it may be empty we can't fetch it in the main query). */
|
556 |
+
$blog_descs = $wpdb->get_results( "SELECT blog_id, meta_value as description FROM {$bp->blogs->table_name_blogmeta} WHERE meta_key = 'description' AND blog_id IN ( {$blog_ids} )" );
|
557 |
+
|
558 |
+
for ( $i = 0, $count = count( $paged_blogs ); $i < $count; ++$i ) {
|
559 |
+
foreach ( (array) $blog_descs as $desc ) {
|
560 |
+
if ( $desc->blog_id == $paged_blogs[$i]->blog_id )
|
561 |
+
$paged_blogs[$i]->description = $desc->description;
|
562 |
+
}
|
563 |
+
}
|
564 |
+
|
565 |
+
return $paged_blogs;
|
566 |
+
}
|
567 |
+
|
568 |
+
/**
|
569 |
+
* Check whether a given blog is hidden.
|
570 |
+
*
|
571 |
+
* Checks the 'public' column in the wp_blogs table.
|
572 |
+
*
|
573 |
+
* @param int $blog_id The ID of the blog being checked.
|
574 |
+
* @return bool True if hidden (public = 0), false otherwise.
|
575 |
+
*/
|
576 |
+
public static function is_hidden( $blog_id ) {
|
577 |
+
global $wpdb;
|
578 |
+
|
579 |
+
if ( !(int) $wpdb->get_var( $wpdb->prepare( "SELECT public FROM {$wpdb->base_prefix}blogs WHERE blog_id = %d", $blog_id ) ) ) {
|
580 |
+
return true;
|
581 |
+
}
|
582 |
+
|
583 |
+
return false;
|
584 |
+
}
|
585 |
+
|
586 |
+
/**
|
587 |
+
* Get ID of user-blog link.
|
588 |
+
*
|
589 |
+
* @param int $user_id ID of user.
|
590 |
+
* @param int $blog_id ID of blog.
|
591 |
+
* @return int|bool ID of user-blog link, or false if not found.
|
592 |
+
*/
|
593 |
+
public static function get_user_blog( $user_id, $blog_id ) {
|
594 |
+
global $wpdb;
|
595 |
+
|
596 |
+
$bp = buddypress();
|
597 |
+
|
598 |
+
$user_blog = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) );
|
599 |
+
|
600 |
+
if ( empty( $user_blog ) ) {
|
601 |
+
$user_blog = false;
|
602 |
+
} else {
|
603 |
+
$user_blog = intval( $user_blog );
|
604 |
+
}
|
605 |
+
|
606 |
+
return $user_blog;
|
607 |
+
}
|
608 |
+
}
|
bp-core/admin/{bp-core-actions.php → bp-core-admin-actions.php}
RENAMED
@@ -1,13 +1,13 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
Â
/**
|
4 |
-
* BuddyPress Admin Actions
|
5 |
Â
*
|
6 |
Â
* This file contains the actions that are used through-out BuddyPress Admin. They
|
7 |
Â
* are consolidated here to make searching for them easier, and to help developers
|
8 |
Â
* understand at a glance the order in which things occur.
|
9 |
Â
*
|
10 |
-
* There are a few common places that additional actions can currently be found
|
11 |
Â
*
|
12 |
Â
* - BuddyPress: In {@link BuddyPress::setup_actions()} in BuddyPress.php
|
13 |
Â
* - Admin: More in {@link bp_Admin::setup_actions()} in admin.php
|
@@ -22,7 +22,7 @@
|
|
22 |
Â
defined( 'ABSPATH' ) || exit;
|
23 |
Â
|
24 |
Â
/**
|
25 |
-
* Attach BuddyPress to WordPress
|
26 |
Â
*
|
27 |
Â
* BuddyPress uses its own internal actions to help aid in third-party plugin
|
28 |
Â
* development, and to limit the amount of potential future code changes when
|
@@ -60,16 +60,16 @@ add_action( 'bp_admin_menu', 'bp_admin_separator' );
|
|
60 |
Â
|
61 |
Â
/**
|
62 |
Â
* When a new site is created in a multisite installation, run the activation
|
63 |
-
* routine on that site
|
64 |
Â
*
|
65 |
-
* @since BuddyPress (1.7)
|
66 |
Â
*
|
67 |
Â
* @param int $blog_id
|
68 |
Â
* @param int $user_id
|
69 |
Â
* @param string $domain
|
70 |
Â
* @param string $path
|
71 |
Â
* @param int $site_id
|
72 |
-
* @param array
|
73 |
Â
*/
|
74 |
Â
function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
|
75 |
Â
|
@@ -80,7 +80,18 @@ function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
|
|
80 |
Â
// Switch to the new blog
|
81 |
Â
switch_to_blog( $blog_id );
|
82 |
Â
|
83 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
84 |
Â
do_action( 'bp_new_site', $blog_id, $user_id, $domain, $path, $site_id, $meta );
|
85 |
Â
|
86 |
Â
// restore original blog
|
@@ -90,42 +101,66 @@ function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
|
|
90 |
Â
/** Sub-Actions ***************************************************************/
|
91 |
Â
|
92 |
Â
/**
|
93 |
-
* Piggy back admin_init action
|
94 |
Â
*
|
95 |
-
* @since BuddyPress (1.7)
|
96 |
-
* @uses do_action() Calls 'bp_admin_init'
|
97 |
Â
*/
|
98 |
Â
function bp_admin_init() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
99 |
Â
do_action( 'bp_admin_init' );
|
100 |
Â
}
|
101 |
Â
|
102 |
Â
/**
|
103 |
-
* Piggy back admin_menu action
|
104 |
Â
*
|
105 |
-
* @since BuddyPress (1.7)
|
106 |
-
* @uses do_action() Calls 'bp_admin_menu'
|
107 |
Â
*/
|
108 |
Â
function bp_admin_menu() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
109 |
Â
do_action( 'bp_admin_menu' );
|
110 |
Â
}
|
111 |
Â
|
112 |
Â
/**
|
113 |
-
* Piggy back admin_head action
|
114 |
Â
*
|
115 |
-
* @since BuddyPress (1.7)
|
116 |
-
* @uses do_action() Calls 'bp_admin_head'
|
117 |
Â
*/
|
118 |
Â
function bp_admin_head() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
119 |
Â
do_action( 'bp_admin_head' );
|
120 |
Â
}
|
121 |
Â
|
122 |
Â
/**
|
123 |
-
* Piggy back admin_notices action
|
124 |
Â
*
|
125 |
-
* @since BuddyPress (1.7)
|
126 |
-
* @uses do_action() Calls 'bp_admin_notices'
|
127 |
Â
*/
|
128 |
Â
function bp_admin_notices() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
129 |
Â
do_action( 'bp_admin_notices' );
|
130 |
Â
}
|
131 |
Â
|
@@ -137,38 +172,66 @@ function bp_admin_notices() {
|
|
137 |
Â
* @uses do_action() Calls 'bp_admin_enqueue_scripts''.
|
138 |
Â
*
|
139 |
Â
* @param string $hook_suffix The current admin page, passed to
|
140 |
-
*
|
141 |
Â
*/
|
142 |
Â
function bp_admin_enqueue_scripts( $hook_suffix = '' ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
143 |
Â
do_action( 'bp_admin_enqueue_scripts', $hook_suffix );
|
144 |
Â
}
|
145 |
Â
|
146 |
Â
/**
|
147 |
-
* Dedicated action to register BuddyPress importers
|
148 |
Â
*
|
149 |
-
* @since BuddyPress (1.7)
|
150 |
-
* @uses do_action() Calls 'bp_admin_notices'
|
151 |
Â
*/
|
152 |
Â
function bp_register_importers() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
153 |
Â
do_action( 'bp_register_importers' );
|
154 |
Â
}
|
155 |
Â
|
156 |
Â
/**
|
157 |
-
* Dedicated action to register admin styles
|
158 |
Â
*
|
159 |
-
* @since BuddyPress (1.7)
|
160 |
-
* @uses do_action() Calls 'bp_admin_notices'
|
161 |
Â
*/
|
162 |
Â
function bp_register_admin_style() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
163 |
Â
do_action( 'bp_register_admin_style' );
|
164 |
Â
}
|
165 |
Â
|
166 |
Â
/**
|
167 |
-
* Dedicated action to register admin settings
|
168 |
Â
*
|
169 |
-
* @since BuddyPress (1.7)
|
170 |
-
* @uses do_action() Calls 'bp_register_admin_settings'
|
171 |
Â
*/
|
172 |
Â
function bp_register_admin_settings() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
173 |
Â
do_action( 'bp_register_admin_settings' );
|
174 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
Â
/**
|
4 |
+
* BuddyPress Admin Actions.
|
5 |
Â
*
|
6 |
Â
* This file contains the actions that are used through-out BuddyPress Admin. They
|
7 |
Â
* are consolidated here to make searching for them easier, and to help developers
|
8 |
Â
* understand at a glance the order in which things occur.
|
9 |
Â
*
|
10 |
+
* There are a few common places that additional actions can currently be found.
|
11 |
Â
*
|
12 |
Â
* - BuddyPress: In {@link BuddyPress::setup_actions()} in BuddyPress.php
|
13 |
Â
* - Admin: More in {@link bp_Admin::setup_actions()} in admin.php
|
22 |
Â
defined( 'ABSPATH' ) || exit;
|
23 |
Â
|
24 |
Â
/**
|
25 |
+
* Attach BuddyPress to WordPress.
|
26 |
Â
*
|
27 |
Â
* BuddyPress uses its own internal actions to help aid in third-party plugin
|
28 |
Â
* development, and to limit the amount of potential future code changes when
|
60 |
Â
|
61 |
Â
/**
|
62 |
Â
* When a new site is created in a multisite installation, run the activation
|
63 |
+
* routine on that site.
|
64 |
Â
*
|
65 |
+
* @since BuddyPress (1.7.0)
|
66 |
Â
*
|
67 |
Â
* @param int $blog_id
|
68 |
Â
* @param int $user_id
|
69 |
Â
* @param string $domain
|
70 |
Â
* @param string $path
|
71 |
Â
* @param int $site_id
|
72 |
+
* @param array $meta
|
73 |
Â
*/
|
74 |
Â
function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
|
75 |
Â
|
80 |
Â
// Switch to the new blog
|
81 |
Â
switch_to_blog( $blog_id );
|
82 |
Â
|
83 |
+
/**
|
84 |
+
* Fires the activation routine for a new site created in a multisite installation.
|
85 |
+
*
|
86 |
+
* @since BuddyPress (1.7.0)
|
87 |
+
*
|
88 |
+
* @param int $blog_id ID of the blog being installed to.
|
89 |
+
* @param int $user_id ID of the user the install is for.
|
90 |
+
* @param string $domain Domain to use with the install.
|
91 |
+
* @param string $path Path to use with the install.
|
92 |
+
* @param int $site_id ID of the site being installed to.
|
93 |
+
* @param array $meta Metadata to use with the site creation.
|
94 |
+
*/
|
95 |
Â
do_action( 'bp_new_site', $blog_id, $user_id, $domain, $path, $site_id, $meta );
|
96 |
Â
|
97 |
Â
// restore original blog
|
101 |
Â
/** Sub-Actions ***************************************************************/
|
102 |
Â
|
103 |
Â
/**
|
104 |
+
* Piggy back admin_init action.
|
105 |
Â
*
|
106 |
+
* @since BuddyPress (1.7.0)
|
107 |
+
* @uses do_action() Calls 'bp_admin_init'.
|
108 |
Â
*/
|
109 |
Â
function bp_admin_init() {
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Fires inside the bp_admin_init function.
|
113 |
+
*
|
114 |
+
* @since BuddyPress (1.6.0)
|
115 |
+
*/
|
116 |
Â
do_action( 'bp_admin_init' );
|
117 |
Â
}
|
118 |
Â
|
119 |
Â
/**
|
120 |
+
* Piggy back admin_menu action.
|
121 |
Â
*
|
122 |
+
* @since BuddyPress (1.7.0)
|
123 |
+
* @uses do_action() Calls 'bp_admin_menu'.
|
124 |
Â
*/
|
125 |
Â
function bp_admin_menu() {
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Fires inside the bp_admin_menu function.
|
129 |
+
*
|
130 |
+
* @since BuddyPress (1.7.0)
|
131 |
+
*/
|
132 |
Â
do_action( 'bp_admin_menu' );
|
133 |
Â
}
|
134 |
Â
|
135 |
Â
/**
|
136 |
+
* Piggy back admin_head action.
|
137 |
Â
*
|
138 |
+
* @since BuddyPress (1.7.0)
|
139 |
+
* @uses do_action() Calls 'bp_admin_head'.
|
140 |
Â
*/
|
141 |
Â
function bp_admin_head() {
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Fires inside the bp_admin_head function.
|
145 |
+
*
|
146 |
+
* @since BuddyPress (1.6.0)
|
147 |
+
*/
|
148 |
Â
do_action( 'bp_admin_head' );
|
149 |
Â
}
|
150 |
Â
|
151 |
Â
/**
|
152 |
+
* Piggy back admin_notices action.
|
153 |
Â
*
|
154 |
+
* @since BuddyPress (1.7.0)
|
155 |
+
* @uses do_action() Calls 'bp_admin_notices'.
|
156 |
Â
*/
|
157 |
Â
function bp_admin_notices() {
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Fires inside the bp_admin_notices function.
|
161 |
+
*
|
162 |
+
* @since BuddyPress (1.5.0)
|
163 |
+
*/
|
164 |
Â
do_action( 'bp_admin_notices' );
|
165 |
Â
}
|
166 |
Â
|
172 |
Â
* @uses do_action() Calls 'bp_admin_enqueue_scripts''.
|
173 |
Â
*
|
174 |
Â
* @param string $hook_suffix The current admin page, passed to
|
175 |
+
* 'admin_enqueue_scripts'.
|
176 |
Â
*/
|
177 |
Â
function bp_admin_enqueue_scripts( $hook_suffix = '' ) {
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Fires inside the bp_admin_enqueue_scripts function.
|
181 |
+
*
|
182 |
+
* @since BuddyPress (1.7.0)
|
183 |
+
*
|
184 |
+
* @param string $hook_suffix The current admin page, passed to admin_enqueue_scripts.
|
185 |
+
*/
|
186 |
Â
do_action( 'bp_admin_enqueue_scripts', $hook_suffix );
|
187 |
Â
}
|
188 |
Â
|
189 |
Â
/**
|
190 |
+
* Dedicated action to register BuddyPress importers.
|
191 |
Â
*
|
192 |
+
* @since BuddyPress (1.7.0)
|
193 |
+
* @uses do_action() Calls 'bp_admin_notices'.
|
194 |
Â
*/
|
195 |
Â
function bp_register_importers() {
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Fires inside the bp_register_importers function.
|
199 |
+
*
|
200 |
+
* Used to register a BuddyPress importer.
|
201 |
+
*
|
202 |
+
* @since BuddyPress (1.7.0)
|
203 |
+
*/
|
204 |
Â
do_action( 'bp_register_importers' );
|
205 |
Â
}
|
206 |
Â
|
207 |
Â
/**
|
208 |
+
* Dedicated action to register admin styles.
|
209 |
Â
*
|
210 |
+
* @since BuddyPress (1.7.0)
|
211 |
+
* @uses do_action() Calls 'bp_admin_notices'.
|
212 |
Â
*/
|
213 |
Â
function bp_register_admin_style() {
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Fires inside the bp_register_admin_style function.
|
217 |
+
*
|
218 |
+
* @since BuddyPress (1.7.0)
|
219 |
+
*/
|
220 |
Â
do_action( 'bp_register_admin_style' );
|
221 |
Â
}
|
222 |
Â
|
223 |
Â
/**
|
224 |
+
* Dedicated action to register admin settings.
|
225 |
Â
*
|
226 |
+
* @since BuddyPress (1.7.0)
|
227 |
+
* @uses do_action() Calls 'bp_register_admin_settings'.
|
228 |
Â
*/
|
229 |
Â
function bp_register_admin_settings() {
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Fires inside the bp_register_admin_settings function.
|
233 |
+
*
|
234 |
+
* @since BuddyPress (1.6.0)
|
235 |
+
*/
|
236 |
Â
do_action( 'bp_register_admin_settings' );
|
237 |
Â
}
|
bp-core/admin/{bp-core-components.php → bp-core-admin-components.php}
RENAMED
@@ -14,7 +14,7 @@ defined( 'ABSPATH' ) || exit;
|
|
14 |
Â
* Renders the Component Setup admin panel.
|
15 |
Â
*
|
16 |
Â
* @package BuddyPress
|
17 |
-
* @since BuddyPress (1.6)
|
18 |
Â
* @uses bp_core_admin_component_options()
|
19 |
Â
*/
|
20 |
Â
function bp_core_admin_components_settings() {
|
@@ -44,13 +44,21 @@ function bp_core_admin_components_settings() {
|
|
44 |
Â
* Creates reusable markup for component setup on the Components and Pages dashboard panel.
|
45 |
Â
*
|
46 |
Â
* @package BuddyPress
|
47 |
-
* @since BuddyPress (1.6)
|
48 |
Â
* @todo Use settings API
|
49 |
Â
*/
|
50 |
Â
function bp_core_admin_components_options() {
|
51 |
Â
|
52 |
Â
// Declare local variables
|
53 |
Â
$deactivated_components = array();
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
54 |
Â
$active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
|
55 |
Â
|
56 |
Â
// The default components (if none are previously selected)
|
@@ -186,11 +194,13 @@ function bp_core_admin_components_options() {
|
|
186 |
Â
|
187 |
Â
<?php endif; ?>
|
188 |
Â
|
189 |
-
<label class="screen-reader-text" for="bp_components[<?php echo esc_attr( $name ); ?>]"><?php sprintf( __( 'Select %s', 'buddypress' ), esc_html( $labels['title'] ) ); ?></label>
|
190 |
Â
</th>
|
191 |
Â
<td class="plugin-title" style="width: 190px;">
|
192 |
Â
<span></span>
|
193 |
-
<
|
Â
|
|
Â
|
|
Â
|
|
194 |
Â
<div class="row-actions-visible">
|
195 |
Â
|
196 |
Â
</div>
|
@@ -227,7 +237,7 @@ function bp_core_admin_components_options() {
|
|
227 |
Â
/**
|
228 |
Â
* Handle saving the Component settings
|
229 |
Â
*
|
230 |
-
* @since BuddyPress (1.6)
|
231 |
Â
* @todo Use settings API when it supports saving network settings
|
232 |
Â
*/
|
233 |
Â
function bp_core_admin_components_settings_handler() {
|
@@ -247,7 +257,7 @@ function bp_core_admin_components_settings_handler() {
|
|
247 |
Â
$bp = buddypress();
|
248 |
Â
|
249 |
Â
// Save settings and upgrade schema
|
250 |
-
require_once( $bp->plugin_dir . '/bp-core/admin/bp-core-schema.php' );
|
251 |
Â
|
252 |
Â
$submitted = stripslashes_deep( $_POST['bp_components'] );
|
253 |
Â
$bp->active_components = bp_core_admin_get_active_components_from_submitted_settings( $submitted );
|
@@ -286,7 +296,7 @@ add_action( 'bp_admin_init', 'bp_core_admin_components_settings_handler' );
|
|
286 |
Â
* is not present, before merging the submitted components with the active
|
287 |
Â
* ones.
|
288 |
Â
*
|
289 |
-
* @since
|
290 |
Â
*
|
291 |
Â
* @param array This is the array of component settings coming from the POST
|
292 |
Â
* global. You should stripslashes_deep() before passing to this function
|
@@ -331,7 +341,7 @@ function bp_core_admin_get_active_components_from_submitted_settings( $submitted
|
|
331 |
Â
* We use this information both to build the markup for the admin screens, as
|
332 |
Â
* well as to do some processing on settings data submitted from those screens.
|
333 |
Â
*
|
334 |
-
* @since
|
335 |
Â
*
|
336 |
Â
* @param string $type 'all', 'optional', 'retired', 'required'
|
337 |
Â
* @return array An array of requested component data
|
@@ -354,7 +364,7 @@ function bp_core_admin_get_components( $type = 'all' ) {
|
|
354 |
Â
$retired_components = array(
|
355 |
Â
'forums' => array(
|
356 |
Â
'title' => __( 'Group Forums', 'buddypress' ),
|
357 |
-
'description' => sprintf( __( 'BuddyPress Forums are retired. Use %s.', 'buddypress' ), '<a href="
|
358 |
Â
),
|
359 |
Â
);
|
360 |
Â
|
@@ -421,5 +431,15 @@ function bp_core_admin_get_components( $type = 'all' ) {
|
|
421 |
Â
|
422 |
Â
}
|
423 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
424 |
Â
return apply_filters( 'bp_core_admin_get_components', $components, $type );
|
425 |
Â
}
|
14 |
Â
* Renders the Component Setup admin panel.
|
15 |
Â
*
|
16 |
Â
* @package BuddyPress
|
17 |
+
* @since BuddyPress (1.6.0)
|
18 |
Â
* @uses bp_core_admin_component_options()
|
19 |
Â
*/
|
20 |
Â
function bp_core_admin_components_settings() {
|
44 |
Â
* Creates reusable markup for component setup on the Components and Pages dashboard panel.
|
45 |
Â
*
|
46 |
Â
* @package BuddyPress
|
47 |
+
* @since BuddyPress (1.6.0)
|
48 |
Â
* @todo Use settings API
|
49 |
Â
*/
|
50 |
Â
function bp_core_admin_components_options() {
|
51 |
Â
|
52 |
Â
// Declare local variables
|
53 |
Â
$deactivated_components = array();
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Filters the array of available components.
|
57 |
+
*
|
58 |
+
* @since BuddyPress (1.5.0)
|
59 |
+
*
|
60 |
+
* @param mixed $value Active components.
|
61 |
+
*/
|
62 |
Â
$active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
|
63 |
Â
|
64 |
Â
// The default components (if none are previously selected)
|
194 |
Â
|
195 |
Â
<?php endif; ?>
|
196 |
Â
|
Â
|
|
197 |
Â
</th>
|
198 |
Â
<td class="plugin-title" style="width: 190px;">
|
199 |
Â
<span></span>
|
200 |
+
<label for="bp_components[<?php echo esc_attr( $name ); ?>]">
|
201 |
+
<strong><?php echo esc_html( $labels['title'] ); ?></strong>
|
202 |
+
</label>
|
203 |
+
|
204 |
Â
<div class="row-actions-visible">
|
205 |
Â
|
206 |
Â
</div>
|
237 |
Â
/**
|
238 |
Â
* Handle saving the Component settings
|
239 |
Â
*
|
240 |
+
* @since BuddyPress (1.6.0)
|
241 |
Â
* @todo Use settings API when it supports saving network settings
|
242 |
Â
*/
|
243 |
Â
function bp_core_admin_components_settings_handler() {
|
257 |
Â
$bp = buddypress();
|
258 |
Â
|
259 |
Â
// Save settings and upgrade schema
|
260 |
+
require_once( $bp->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
|
261 |
Â
|
262 |
Â
$submitted = stripslashes_deep( $_POST['bp_components'] );
|
263 |
Â
$bp->active_components = bp_core_admin_get_active_components_from_submitted_settings( $submitted );
|
296 |
Â
* is not present, before merging the submitted components with the active
|
297 |
Â
* ones.
|
298 |
Â
*
|
299 |
+
* @since BuddyPress (1.7.0)
|
300 |
Â
*
|
301 |
Â
* @param array This is the array of component settings coming from the POST
|
302 |
Â
* global. You should stripslashes_deep() before passing to this function
|
341 |
Â
* We use this information both to build the markup for the admin screens, as
|
342 |
Â
* well as to do some processing on settings data submitted from those screens.
|
343 |
Â
*
|
344 |
+
* @since BuddyPress (1.7.0)
|
345 |
Â
*
|
346 |
Â
* @param string $type 'all', 'optional', 'retired', 'required'
|
347 |
Â
* @return array An array of requested component data
|
364 |
Â
$retired_components = array(
|
365 |
Â
'forums' => array(
|
366 |
Â
'title' => __( 'Group Forums', 'buddypress' ),
|
367 |
+
'description' => sprintf( __( 'BuddyPress Forums are retired. Use %s.', 'buddypress' ), '<a href="https://bbpress.org/">bbPress</a>' )
|
368 |
Â
),
|
369 |
Â
);
|
370 |
Â
|
431 |
Â
|
432 |
Â
}
|
433 |
Â
|
434 |
+
/**
|
435 |
+
* Filters the list of component information.
|
436 |
+
*
|
437 |
+
* @since BuddyPress (2.0.0)
|
438 |
+
*
|
439 |
+
* @param array $components Array of component information.
|
440 |
+
* @param string $type Type of component list requested.
|
441 |
+
* Possible values include 'all', 'optional',
|
442 |
+
* 'retired', 'required'.
|
443 |
+
*/
|
444 |
Â
return apply_filters( 'bp_core_admin_get_components', $components, $type );
|
445 |
Â
}
|
bp-core/admin/{bp-core-functions.php → bp-core-admin-functions.php}
RENAMED
@@ -32,7 +32,7 @@ function bp_core_admin_menu_init() {
|
|
32 |
Â
* @global array $_parent_pages
|
33 |
Â
* @global array $_registered_pages
|
34 |
Â
* @global array $submenu
|
35 |
-
* @since BuddyPress (1.6)
|
36 |
Â
*/
|
37 |
Â
function bp_core_admin_backpat_menu() {
|
38 |
Â
global $_parent_pages, $_registered_pages, $submenu;
|
@@ -71,7 +71,7 @@ add_action( bp_core_admin_hook(), 'bp_core_admin_backpat_menu', 999 );
|
|
71 |
Â
*
|
72 |
Â
* @global string $plugin_page
|
73 |
Â
* @global array $submenu
|
74 |
-
* @since BuddyPress (1.6)
|
75 |
Â
*/
|
76 |
Â
function bp_core_modify_admin_menu_highlight() {
|
77 |
Â
global $plugin_page, $submenu_file;
|
@@ -93,7 +93,7 @@ function bp_core_modify_admin_menu_highlight() {
|
|
93 |
Â
* will never appear.
|
94 |
Â
*
|
95 |
Â
* @see bp_core_admin_backpat_menu()
|
96 |
-
* @since BuddyPress (1.6)
|
97 |
Â
* @todo Add convenience links into the markup once new positions are finalised.
|
98 |
Â
*/
|
99 |
Â
function bp_core_admin_backpat_page() {
|
@@ -105,7 +105,7 @@ function bp_core_admin_backpat_page() {
|
|
105 |
Â
<h2><?php _e( 'Why have all my BuddyPress menus disappeared?', 'buddypress' ); ?></h2>
|
106 |
Â
|
107 |
Â
<p><?php _e( "Don't worry! We've moved the BuddyPress options into more convenient and easier to find locations. You're seeing this page because you are running a legacy BuddyPress plugin which has not been updated.", 'buddypress' ); ?></p>
|
108 |
-
<p><?php printf( __( 'Components, Pages, Settings, and Forums, have been moved to <a href="%s">Settings > BuddyPress</a>. Profile Fields has been moved into the <a href="%s">Users</a> menu.', 'buddypress' ), esc_url( $settings_url ),
|
109 |
Â
</div>
|
110 |
Â
|
111 |
Â
<?php
|
@@ -119,7 +119,7 @@ function bp_core_admin_backpat_page() {
|
|
119 |
Â
* BuddyPress combines all its messages into a single notice, to avoid a preponderance of yellow
|
120 |
Â
* boxes.
|
121 |
Â
*
|
122 |
-
* @since BuddyPress (1.5)
|
123 |
Â
*
|
124 |
Â
* @uses bp_current_user_can() to check current user permissions before showing the notices
|
125 |
Â
* @uses bp_is_root_blog()
|
@@ -164,7 +164,7 @@ add_action( 'network_admin_notices', 'bp_core_print_admin_notices' );
|
|
164 |
Â
* box. It is recommended that you hook this function to admin_init, so that your messages are
|
165 |
Â
* loaded in time.
|
166 |
Â
*
|
167 |
-
* @since BuddyPress (1.5)
|
168 |
Â
*
|
169 |
Â
* @param string $notice The notice you are adding to the queue.
|
170 |
Â
* @param string $type The notice type; optional. Usually either "updated" or "error".
|
@@ -199,7 +199,7 @@ function bp_core_add_admin_notice( $notice = '', $type = 'updated' ) {
|
|
199 |
Â
*
|
200 |
Â
* @global WPDB $wpdb WordPress DB object
|
201 |
Â
* @global WP_Rewrite $wp_rewrite
|
202 |
-
* @since BuddyPress (1.2)
|
203 |
Â
*/
|
204 |
Â
function bp_core_activation_notice() {
|
205 |
Â
global $wp_rewrite, $wpdb;
|
@@ -329,7 +329,7 @@ function bp_core_activation_notice() {
|
|
329 |
Â
/**
|
330 |
Â
* Redirect user to BuddyPress's What's New page on activation
|
331 |
Â
*
|
332 |
-
* @since BuddyPress (1.7)
|
333 |
Â
*
|
334 |
Â
* @internal Used internally to redirect BuddyPress to the about page on activation
|
335 |
Â
*
|
@@ -370,13 +370,21 @@ function bp_do_activation_redirect() {
|
|
370 |
Â
/**
|
371 |
Â
* Output the tabs in the admin area
|
372 |
Â
*
|
373 |
-
* @since BuddyPress (1.5)
|
374 |
Â
* @param string $active_tab Name of the tab that is active. Optional.
|
375 |
Â
*/
|
376 |
Â
function bp_core_admin_tabs( $active_tab = '' ) {
|
377 |
Â
$tabs_html = '';
|
378 |
Â
$idle_class = 'nav-tab';
|
379 |
Â
$active_class = 'nav-tab nav-tab-active';
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
380 |
Â
$tabs = apply_filters( 'bp_core_admin_tabs', bp_core_get_admin_tabs( $active_tab ) );
|
381 |
Â
|
382 |
Â
// Loop through tabs and build navigation
|
@@ -387,6 +395,12 @@ function bp_core_admin_tabs( $active_tab = '' ) {
|
|
387 |
Â
}
|
388 |
Â
|
389 |
Â
echo $tabs_html;
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
390 |
Â
do_action( 'bp_admin_tabs' );
|
391 |
Â
}
|
392 |
Â
|
@@ -428,8 +442,9 @@ function bp_core_get_admin_tabs( $active_tab = '' ) {
|
|
428 |
Â
/**
|
429 |
Â
* Filters the tab data used in our wp-admin screens.
|
430 |
Â
*
|
431 |
-
* @param array $tabs Tab data.
|
432 |
Â
* @since BuddyPress (2.2.0)
|
Â
|
|
Â
|
|
433 |
Â
*/
|
434 |
Â
return apply_filters( 'bp_core_get_admin_tabs', $tabs );
|
435 |
Â
}
|
@@ -439,7 +454,7 @@ function bp_core_get_admin_tabs( $active_tab = '' ) {
|
|
439 |
Â
/**
|
440 |
Â
* adds contextual help to BuddyPress admin pages
|
441 |
Â
*
|
442 |
-
* @since BuddyPress (1.7)
|
443 |
Â
* @todo Make this part of the BP_Component class and split into each component
|
444 |
Â
*/
|
445 |
Â
function bp_core_add_contextual_help( $screen = '' ) {
|
@@ -461,8 +476,8 @@ function bp_core_add_contextual_help( $screen = '' ) {
|
|
461 |
Â
// help panel - sidebar links
|
462 |
Â
$screen->set_help_sidebar(
|
463 |
Â
'<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
|
464 |
-
'<p>' . __( '<a href="
|
465 |
-
'<p>' . __( '<a href="
|
466 |
Â
);
|
467 |
Â
break;
|
468 |
Â
|
@@ -479,8 +494,8 @@ function bp_core_add_contextual_help( $screen = '' ) {
|
|
479 |
Â
// Help panel - sidebar links
|
480 |
Â
$screen->set_help_sidebar(
|
481 |
Â
'<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
|
482 |
-
'<p>' . __( '<a href="
|
483 |
-
'<p>' . __( '<a href="
|
484 |
Â
);
|
485 |
Â
|
486 |
Â
break;
|
@@ -498,8 +513,8 @@ function bp_core_add_contextual_help( $screen = '' ) {
|
|
498 |
Â
// Help panel - sidebar links
|
499 |
Â
$screen->set_help_sidebar(
|
500 |
Â
'<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
|
501 |
-
'<p>' . __( '<a href="
|
502 |
-
'<p>' . __( '<a href="
|
503 |
Â
);
|
504 |
Â
|
505 |
Â
break;
|
@@ -517,8 +532,8 @@ function bp_core_add_contextual_help( $screen = '' ) {
|
|
517 |
Â
// Help panel - sidebar links
|
518 |
Â
$screen->set_help_sidebar(
|
519 |
Â
'<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
|
520 |
-
'<p>' . __( '<a href="
|
521 |
-
'<p>' . __( '<a href="
|
522 |
Â
);
|
523 |
Â
|
524 |
Â
break;
|
@@ -529,7 +544,7 @@ add_action( 'contextual_help', 'bp_core_add_contextual_help' );
|
|
529 |
Â
/**
|
530 |
Â
* renders contextual help content to contextual help tabs
|
531 |
Â
*
|
532 |
-
* @since BuddyPress (1.7)
|
533 |
Â
*/
|
534 |
Â
function bp_core_add_contextual_help_content( $tab = '' ) {
|
535 |
Â
|
@@ -547,7 +562,7 @@ function bp_core_add_contextual_help_content( $tab = '' ) {
|
|
547 |
Â
break;
|
548 |
Â
|
549 |
Â
case 'bp-profile-overview' :
|
550 |
-
$retval = __( 'Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile
|
551 |
Â
break;
|
552 |
Â
|
553 |
Â
default:
|
@@ -568,7 +583,7 @@ function bp_core_add_contextual_help_content( $tab = '' ) {
|
|
568 |
Â
/**
|
569 |
Â
* Add a separator to the WordPress admin menus
|
570 |
Â
*
|
571 |
-
* @since BuddyPress (1.7)
|
572 |
Â
*
|
573 |
Â
* @uses bp_current_user_can() To check users capability on root blog
|
574 |
Â
*/
|
@@ -603,7 +618,7 @@ function bp_admin_separator() {
|
|
603 |
Â
/**
|
604 |
Â
* Tell WordPress we have a custom menu order
|
605 |
Â
*
|
606 |
-
* @since BuddyPress (1.7)
|
607 |
Â
*
|
608 |
Â
* @param bool $menu_order Menu order
|
609 |
Â
* @uses bp_current_user_can() To check users capability on root blog
|
@@ -622,7 +637,7 @@ function bp_admin_custom_menu_order( $menu_order = false ) {
|
|
622 |
Â
/**
|
623 |
Â
* Move our custom separator above our custom post types
|
624 |
Â
*
|
625 |
-
* @since BuddyPress (1.7)
|
626 |
Â
*
|
627 |
Â
* @param array $menu_order Menu Order
|
628 |
Â
* @uses bp_current_user_can() To check users capability on root blog
|
@@ -641,7 +656,13 @@ function bp_admin_menu_order( $menu_order = array() ) {
|
|
641 |
Â
// Menu values
|
642 |
Â
$last_sep = is_network_admin() ? 'separator1' : 'separator2';
|
643 |
Â
|
644 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
645 |
Â
$custom_menus = (array) apply_filters( 'bp_admin_menu_order', array() );
|
646 |
Â
|
647 |
Â
// Bail if no components have top level admin pages
|
@@ -687,7 +708,7 @@ function bp_admin_menu_order( $menu_order = array() ) {
|
|
687 |
Â
* and the inputs have different keys in the $_REQUEST array. This function
|
688 |
Â
* reconciles the two values and returns a single action being performed.
|
689 |
Â
*
|
690 |
-
* @since BuddyPress (1.7)
|
691 |
Â
* @return string
|
692 |
Â
*/
|
693 |
Â
function bp_admin_list_table_current_bulk_action() {
|
@@ -786,7 +807,7 @@ function bp_admin_do_wp_nav_menu_meta_box() {
|
|
786 |
Â
* - URL - This field is automatically generated by BP on output, so this
|
787 |
Â
* field is useless and can cause confusion.
|
788 |
Â
*
|
789 |
-
* Note: These restrictions are only enforced if
|
790 |
Â
*
|
791 |
Â
* @since BuddyPress (1.9.0)
|
792 |
Â
*/
|
@@ -888,7 +909,7 @@ function bp_core_admin_user_manage_spammers() {
|
|
888 |
Â
// Process the user
|
889 |
Â
bp_core_process_spammer_status( $user_id, $status );
|
890 |
Â
|
891 |
-
$redirect = add_query_arg( array( 'updated' => 'marked-' . $status ), $redirect);
|
892 |
Â
|
893 |
Â
wp_redirect( $redirect );
|
894 |
Â
}
|
32 |
Â
* @global array $_parent_pages
|
33 |
Â
* @global array $_registered_pages
|
34 |
Â
* @global array $submenu
|
35 |
+
* @since BuddyPress (1.6.0)
|
36 |
Â
*/
|
37 |
Â
function bp_core_admin_backpat_menu() {
|
38 |
Â
global $_parent_pages, $_registered_pages, $submenu;
|
71 |
Â
*
|
72 |
Â
* @global string $plugin_page
|
73 |
Â
* @global array $submenu
|
74 |
+
* @since BuddyPress (1.6.0)
|
75 |
Â
*/
|
76 |
Â
function bp_core_modify_admin_menu_highlight() {
|
77 |
Â
global $plugin_page, $submenu_file;
|
93 |
Â
* will never appear.
|
94 |
Â
*
|
95 |
Â
* @see bp_core_admin_backpat_menu()
|
96 |
+
* @since BuddyPress (1.6.0)
|
97 |
Â
* @todo Add convenience links into the markup once new positions are finalised.
|
98 |
Â
*/
|
99 |
Â
function bp_core_admin_backpat_page() {
|
105 |
Â
<h2><?php _e( 'Why have all my BuddyPress menus disappeared?', 'buddypress' ); ?></h2>
|
106 |
Â
|
107 |
Â
<p><?php _e( "Don't worry! We've moved the BuddyPress options into more convenient and easier to find locations. You're seeing this page because you are running a legacy BuddyPress plugin which has not been updated.", 'buddypress' ); ?></p>
|
108 |
+
<p><?php printf( __( 'Components, Pages, Settings, and Forums, have been moved to <a href="%s">Settings > 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>
|
109 |
Â
</div>
|
110 |
Â
|
111 |
Â
<?php
|
119 |
Â
* BuddyPress combines all its messages into a single notice, to avoid a preponderance of yellow
|
120 |
Â
* boxes.
|
121 |
Â
*
|
122 |
+
* @since BuddyPress (1.5.0)
|
123 |
Â
*
|
124 |
Â
* @uses bp_current_user_can() to check current user permissions before showing the notices
|
125 |
Â
* @uses bp_is_root_blog()
|
164 |
Â
* box. It is recommended that you hook this function to admin_init, so that your messages are
|
165 |
Â
* loaded in time.
|
166 |
Â
*
|
167 |
+
* @since BuddyPress (1.5.0)
|
168 |
Â
*
|
169 |
Â
* @param string $notice The notice you are adding to the queue.
|
170 |
Â
* @param string $type The notice type; optional. Usually either "updated" or "error".
|
199 |
Â
*
|
200 |
Â
* @global WPDB $wpdb WordPress DB object
|
201 |
Â
* @global WP_Rewrite $wp_rewrite
|
202 |
+
* @since BuddyPress (1.2.0)
|
203 |
Â
*/
|
204 |
Â
function bp_core_activation_notice() {
|
205 |
Â
global $wp_rewrite, $wpdb;
|
329 |
Â
/**
|
330 |
Â
* Redirect user to BuddyPress's What's New page on activation
|
331 |
Â
*
|
332 |
+
* @since BuddyPress (1.7.0)
|
333 |
Â
*
|
334 |
Â
* @internal Used internally to redirect BuddyPress to the about page on activation
|
335 |
Â
*
|
370 |
Â
/**
|
371 |
Â
* Output the tabs in the admin area
|
372 |
Â
*
|
373 |
+
* @since BuddyPress (1.5.0)
|
374 |
Â
* @param string $active_tab Name of the tab that is active. Optional.
|
375 |
Â
*/
|
376 |
Â
function bp_core_admin_tabs( $active_tab = '' ) {
|
377 |
Â
$tabs_html = '';
|
378 |
Â
$idle_class = 'nav-tab';
|
379 |
Â
$active_class = 'nav-tab nav-tab-active';
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Filters the admin tabs to be displayed.
|
383 |
+
*
|
384 |
+
* @since BuddyPress (1.9.0)
|
385 |
+
*
|
386 |
+
* @param array $value Array of tabs to output to the admin area.
|
387 |
+
*/
|
388 |
Â
$tabs = apply_filters( 'bp_core_admin_tabs', bp_core_get_admin_tabs( $active_tab ) );
|
389 |
Â
|
390 |
Â
// Loop through tabs and build navigation
|
395 |
Â
}
|
396 |
Â
|
397 |
Â
echo $tabs_html;
|
398 |
+
|
399 |
+
/**
|
400 |
+
* Fires after the output of tabs for the admin area.
|
401 |
+
*
|
402 |
+
* @since BuddyPress (1.5.0)
|
403 |
+
*/
|
404 |
Â
do_action( 'bp_admin_tabs' );
|
405 |
Â
}
|
406 |
Â
|
442 |
Â
/**
|
443 |
Â
* Filters the tab data used in our wp-admin screens.
|
444 |
Â
*
|
Â
|
|
445 |
Â
* @since BuddyPress (2.2.0)
|
446 |
+
*
|
447 |
+
* @param array $tabs Tab data.
|
448 |
Â
*/
|
449 |
Â
return apply_filters( 'bp_core_get_admin_tabs', $tabs );
|
450 |
Â
}
|
454 |
Â
/**
|
455 |
Â
* adds contextual help to BuddyPress admin pages
|
456 |
Â
*
|
457 |
+
* @since BuddyPress (1.7.0)
|
458 |
Â
* @todo Make this part of the BP_Component class and split into each component
|
459 |
Â
*/
|
460 |
Â
function bp_core_add_contextual_help( $screen = '' ) {
|
476 |
Â
// help panel - sidebar links
|
477 |
Â
$screen->set_help_sidebar(
|
478 |
Â
'<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
|
479 |
+
'<p>' . __( '<a href="https://codex.buddypress.org/getting-started/configure-components/">Managing Components</a>', 'buddypress' ) . '</p>' .
|
480 |
+
'<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
|
481 |
Â
);
|
482 |
Â
break;
|
483 |
Â
|
494 |
Â
// Help panel - sidebar links
|
495 |
Â
$screen->set_help_sidebar(
|
496 |
Â
'<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
|
497 |
+
'<p>' . __( '<a href="https://codex.buddypress.org/getting-started/configure-components/#settings-buddypress-pages">Managing Pages</a>', 'buddypress' ) . '</p>' .
|
498 |
+
'<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
|
499 |
Â
);
|
500 |
Â
|
501 |
Â
break;
|
513 |
Â
// Help panel - sidebar links
|
514 |
Â
$screen->set_help_sidebar(
|
515 |
Â
'<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
|
516 |
+
'<p>' . __( '<a href="https://codex.buddypress.org/getting-started/configure-components/#settings-buddypress-settings">Managing Settings</a>', 'buddypress' ) . '</p>' .
|
517 |
+
'<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
|
518 |
Â
);
|
519 |
Â
|
520 |
Â
break;
|
532 |
Â
// Help panel - sidebar links
|
533 |
Â
$screen->set_help_sidebar(
|
534 |
Â
'<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
|
535 |
+
'<p>' . __( '<a href="https://codex.buddypress.org/administrator-guide/extended-profiles/">Managing Profile Fields</a>', 'buddypress' ) . '</p>' .
|
536 |
+
'<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
|
537 |
Â
);
|
538 |
Â
|
539 |
Â
break;
|
544 |
Â
/**
|
545 |
Â
* renders contextual help content to contextual help tabs
|
546 |
Â
*
|
547 |
+
* @since BuddyPress (1.7.0)
|
548 |
Â
*/
|
549 |
Â
function bp_core_add_contextual_help_content( $tab = '' ) {
|
550 |
Â
|
562 |
Â
break;
|
563 |
Â
|
564 |
Â
case 'bp-profile-overview' :
|
565 |
+
$retval = __( 'Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile.<br /><br />Note: Any fields in the first group will appear on the signup page.', 'buddypress' );
|
566 |
Â
break;
|
567 |
Â
|
568 |
Â
default:
|
583 |
Â
/**
|
584 |
Â
* Add a separator to the WordPress admin menus
|
585 |
Â
*
|
586 |
+
* @since BuddyPress (1.7.0)
|
587 |
Â
*
|
588 |
Â
* @uses bp_current_user_can() To check users capability on root blog
|
589 |
Â
*/
|
618 |
Â
/**
|
619 |
Â
* Tell WordPress we have a custom menu order
|
620 |
Â
*
|
621 |
+
* @since BuddyPress (1.7.0)
|
622 |
Â
*
|
623 |
Â
* @param bool $menu_order Menu order
|
624 |
Â
* @uses bp_current_user_can() To check users capability on root blog
|
637 |
Â
/**
|
638 |
Â
* Move our custom separator above our custom post types
|
639 |
Â
*
|
640 |
+
* @since BuddyPress (1.7.0)
|
641 |
Â
*
|
642 |
Â
* @param array $menu_order Menu Order
|
643 |
Â
* @uses bp_current_user_can() To check users capability on root blog
|
656 |
Â
// Menu values
|
657 |
Â
$last_sep = is_network_admin() ? 'separator1' : 'separator2';
|
658 |
Â
|
659 |
+
/**
|
660 |
+
* Filters the custom admin menus.
|
661 |
+
*
|
662 |
+
* @since BuddyPress (1.7.0)
|
663 |
+
*
|
664 |
+
* @param array $value Empty array.
|
665 |
+
*/
|
666 |
Â
$custom_menus = (array) apply_filters( 'bp_admin_menu_order', array() );
|
667 |
Â
|
668 |
Â
// Bail if no components have top level admin pages
|
708 |
Â
* and the inputs have different keys in the $_REQUEST array. This function
|
709 |
Â
* reconciles the two values and returns a single action being performed.
|
710 |
Â
*
|
711 |
+
* @since BuddyPress (1.7.0)
|
712 |
Â
* @return string
|
713 |
Â
*/
|
714 |
Â
function bp_admin_list_table_current_bulk_action() {
|
807 |
Â
* - URL - This field is automatically generated by BP on output, so this
|
808 |
Â
* field is useless and can cause confusion.
|
809 |
Â
*
|
810 |
+
* Note: These restrictions are only enforced if JavaScript is enabled.
|
811 |
Â
*
|
812 |
Â
* @since BuddyPress (1.9.0)
|
813 |
Â
*/
|
909 |
Â
// Process the user
|
910 |
Â
bp_core_process_spammer_status( $user_id, $status );
|
911 |
Â
|
912 |
+
$redirect = add_query_arg( array( 'updated' => 'marked-' . $status ), $redirect );
|
913 |
Â
|
914 |
Â
wp_redirect( $redirect );
|
915 |
Â
}
|
bp-core/admin/{bp-core-schema.php → bp-core-admin-schema.php}
RENAMED
@@ -38,8 +38,12 @@ function bp_core_set_charset() {
|
|
38 |
Â
*/
|
39 |
Â
function bp_core_install( $active_components = false ) {
|
40 |
Â
|
Â
|
|
Â
|
|
41 |
Â
// If no components passed, get all the active components from the main site
|
42 |
Â
if ( empty( $active_components ) ) {
|
Â
|
|
Â
|
|
43 |
Â
$active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
|
44 |
Â
}
|
45 |
Â
|
@@ -112,6 +116,15 @@ function bp_core_install_notifications() {
|
|
112 |
Â
KEY useritem (user_id,is_new)
|
113 |
Â
) {$charset_collate};";
|
114 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
115 |
Â
dbDelta( $sql );
|
116 |
Â
}
|
117 |
Â
|
@@ -162,7 +175,7 @@ function bp_core_install_activity_streams() {
|
|
162 |
Â
meta_key varchar(255) DEFAULT NULL,
|
163 |
Â
meta_value longtext DEFAULT NULL,
|
164 |
Â
KEY activity_id (activity_id),
|
165 |
-
KEY meta_key (meta_key)
|
166 |
Â
) {$charset_collate};";
|
167 |
Â
|
168 |
Â
dbDelta( $sql );
|
@@ -250,7 +263,7 @@ function bp_core_install_groups() {
|
|
250 |
Â
meta_key varchar(255) DEFAULT NULL,
|
251 |
Â
meta_value longtext DEFAULT NULL,
|
252 |
Â
KEY group_id (group_id),
|
253 |
-
KEY meta_key (meta_key)
|
254 |
Â
) {$charset_collate};";
|
255 |
Â
|
256 |
Â
dbDelta( $sql );
|
@@ -310,7 +323,7 @@ function bp_core_install_private_messaging() {
|
|
310 |
Â
meta_key varchar(255) DEFAULT NULL,
|
311 |
Â
meta_value longtext DEFAULT NULL,
|
312 |
Â
KEY message_id (message_id),
|
313 |
-
KEY meta_key (meta_key)
|
314 |
Â
) {$charset_collate};";
|
315 |
Â
|
316 |
Â
dbDelta( $sql );
|
@@ -387,7 +400,7 @@ function bp_core_install_extended_profiles() {
|
|
387 |
Â
meta_key varchar(255) DEFAULT NULL,
|
388 |
Â
meta_value longtext DEFAULT NULL,
|
389 |
Â
KEY object_id (object_id),
|
390 |
-
KEY meta_key (meta_key)
|
391 |
Â
) {$charset_collate};";
|
392 |
Â
|
393 |
Â
dbDelta( $sql );
|
@@ -434,7 +447,7 @@ function bp_core_install_blog_tracking() {
|
|
434 |
Â
meta_key varchar(255) DEFAULT NULL,
|
435 |
Â
meta_value longtext DEFAULT NULL,
|
436 |
Â
KEY blog_id (blog_id),
|
437 |
-
KEY meta_key (meta_key)
|
438 |
Â
) {$charset_collate};";
|
439 |
Â
|
440 |
Â
dbDelta( $sql );
|
@@ -454,7 +467,7 @@ function bp_core_install_signups() {
|
|
454 |
Â
global $wpdb;
|
455 |
Â
|
456 |
Â
// Signups is not there and we need it so let's create it
|
457 |
-
require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-schema.php' );
|
458 |
Â
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
459 |
Â
|
460 |
Â
// Never use bp_core_get_table_prefix() for any global users tables
|
38 |
Â
*/
|
39 |
Â
function bp_core_install( $active_components = false ) {
|
40 |
Â
|
41 |
+
bp_pre_schema_upgrade();
|
42 |
+
|
43 |
Â
// If no components passed, get all the active components from the main site
|
44 |
Â
if ( empty( $active_components ) ) {
|
45 |
+
|
46 |
+
/** This filter is documented in bp-core/admin/bp-core-admin-components.php */
|
47 |
Â
$active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
|
48 |
Â
}
|
49 |
Â
|
116 |
Â
KEY useritem (user_id,is_new)
|
117 |
Â
) {$charset_collate};";
|
118 |
Â
|
119 |
+
$sql[] = "CREATE TABLE {$bp_prefix}bp_notifications_meta (
|
120 |
+
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
121 |
+
notification_id bigint(20) NOT NULL,
|
122 |
+
meta_key varchar(255) DEFAULT NULL,
|
123 |
+
meta_value longtext DEFAULT NULL,
|
124 |
+
KEY notification_id (notification_id),
|
125 |
+
KEY meta_key (meta_key(191))
|
126 |
+
) {$charset_collate};";
|
127 |
+
|
128 |
Â
dbDelta( $sql );
|
129 |
Â
}
|
130 |
Â
|
175 |
Â
meta_key varchar(255) DEFAULT NULL,
|
176 |
Â
meta_value longtext DEFAULT NULL,
|
177 |
Â
KEY activity_id (activity_id),
|
178 |
+
KEY meta_key (meta_key(191))
|
179 |
Â
) {$charset_collate};";
|
180 |
Â
|
181 |
Â
dbDelta( $sql );
|
263 |
Â
meta_key varchar(255) DEFAULT NULL,
|
264 |
Â
meta_value longtext DEFAULT NULL,
|
265 |
Â
KEY group_id (group_id),
|
266 |
+
KEY meta_key (meta_key(191))
|
267 |
Â
) {$charset_collate};";
|
268 |
Â
|
269 |
Â
dbDelta( $sql );
|
323 |
Â
meta_key varchar(255) DEFAULT NULL,
|
324 |
Â
meta_value longtext DEFAULT NULL,
|
325 |
Â
KEY message_id (message_id),
|
326 |
+
KEY meta_key (meta_key(191))
|
327 |
Â
) {$charset_collate};";
|
328 |
Â
|
329 |
Â
dbDelta( $sql );
|
400 |
Â
meta_key varchar(255) DEFAULT NULL,
|
401 |
Â
meta_value longtext DEFAULT NULL,
|
402 |
Â
KEY object_id (object_id),
|
403 |
+
KEY meta_key (meta_key(191))
|
404 |
Â
) {$charset_collate};";
|
405 |
Â
|
406 |
Â
dbDelta( $sql );
|
447 |
Â
meta_key varchar(255) DEFAULT NULL,
|
448 |
Â
meta_value longtext DEFAULT NULL,
|
449 |
Â
KEY blog_id (blog_id),
|
450 |
+
KEY meta_key (meta_key(191))
|
451 |
Â
) {$charset_collate};";
|
452 |
Â
|
453 |
Â
dbDelta( $sql );
|
467 |
Â
global $wpdb;
|
468 |
Â
|
469 |
Â
// Signups is not there and we need it so let's create it
|
470 |
+
require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
|
471 |
Â
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
472 |
Â
|
473 |
Â
// Never use bp_core_get_table_prefix() for any global users tables
|
bp-core/admin/{bp-core-settings.php → bp-core-admin-settings.php}
RENAMED
@@ -13,14 +13,14 @@ defined( 'ABSPATH' ) || exit;
|
|
13 |
Â
/**
|
14 |
Â
* Main settings section description for the settings page
|
15 |
Â
*
|
16 |
-
* @since BuddyPress (1.6)
|
17 |
Â
*/
|
18 |
Â
function bp_admin_setting_callback_main_section() { }
|
19 |
Â
|
20 |
Â
/**
|
21 |
Â
* Admin bar for logged out users setting field
|
22 |
Â
*
|
23 |
-
* @since BuddyPress (1.6)
|
24 |
Â
*
|
25 |
Â
* @uses bp_form_option() To output the option value
|
26 |
Â
*/
|
@@ -36,7 +36,7 @@ function bp_admin_setting_callback_admin_bar() {
|
|
36 |
Â
/**
|
37 |
Â
* Allow members to delete their accounts setting field
|
38 |
Â
*
|
39 |
-
* @since BuddyPress (1.6)
|
40 |
Â
*
|
41 |
Â
* @uses checked() To display the checked attribute
|
42 |
Â
*/
|
@@ -54,14 +54,14 @@ function bp_admin_setting_callback_account_deletion() {
|
|
54 |
Â
/**
|
55 |
Â
* Groups settings section description for the settings page
|
56 |
Â
*
|
57 |
-
* @since BuddyPress (1.6)
|
58 |
Â
*/
|
59 |
Â
function bp_admin_setting_callback_activity_section() { }
|
60 |
Â
|
61 |
Â
/**
|
62 |
Â
* Allow Akismet setting field
|
63 |
Â
*
|
64 |
-
* @since BuddyPress (1.6)
|
65 |
Â
*
|
66 |
Â
* @uses checked() To display the checked attribute
|
67 |
Â
*/
|
@@ -77,7 +77,7 @@ function bp_admin_setting_callback_activity_akismet() {
|
|
77 |
Â
/**
|
78 |
Â
* Allow activity comments on blog posts and forum posts
|
79 |
Â
*
|
80 |
-
* @since BuddyPress (1.6)
|
81 |
Â
*/
|
82 |
Â
function bp_admin_setting_callback_blogforum_comments() {
|
83 |
Â
?>
|
@@ -109,7 +109,7 @@ function bp_admin_setting_callback_heartbeat() {
|
|
109 |
Â
* legacy reasons, the option that we store is 1 if these comments are *disabled*. So we use this
|
110 |
Â
* function to flip the boolean before saving the intval.
|
111 |
Â
*
|
112 |
-
* @since BuddyPress (1.6)
|
113 |
Â
*/
|
114 |
Â
function bp_admin_sanitize_callback_blogforum_comments( $value = false ) {
|
115 |
Â
return $value ? 0 : 1;
|
@@ -120,14 +120,14 @@ function bp_admin_sanitize_callback_blogforum_comments( $value = false ) {
|
|
120 |
Â
/**
|
121 |
Â
* Profile settings section description for the settings page
|
122 |
Â
*
|
123 |
-
* @since BuddyPress (1.6)
|
124 |
Â
*/
|
125 |
Â
function bp_admin_setting_callback_xprofile_section() { }
|
126 |
Â
|
127 |
Â
/**
|
128 |
Â
* Enable BP->WP profile syncing field
|
129 |
Â
*
|
130 |
-
* @since BuddyPress (1.6)
|
131 |
Â
*
|
132 |
Â
* @uses bp_form_option() To output the option value
|
133 |
Â
*/
|
@@ -143,7 +143,7 @@ function bp_admin_setting_callback_profile_sync() {
|
|
143 |
Â
/**
|
144 |
Â
* Allow members to upload avatars field
|
145 |
Â
*
|
146 |
-
* @since BuddyPress (1.6)
|
147 |
Â
*
|
148 |
Â
* @uses checked() To display the checked attribute
|
149 |
Â
*/
|
@@ -161,14 +161,14 @@ function bp_admin_setting_callback_avatar_uploads() {
|
|
161 |
Â
/**
|
162 |
Â
* Groups settings section description for the settings page
|
163 |
Â
*
|
164 |
-
* @since BuddyPress (1.6)
|
165 |
Â
*/
|
166 |
Â
function bp_admin_setting_callback_groups_section() { }
|
167 |
Â
|
168 |
Â
/**
|
169 |
Â
* Allow all users to create groups field
|
170 |
Â
*
|
171 |
-
* @since BuddyPress (1.6)
|
172 |
Â
*
|
173 |
Â
* @uses checked() To display the checked attribute
|
174 |
Â
*/
|
@@ -182,19 +182,31 @@ function bp_admin_setting_callback_group_creation() {
|
|
182 |
Â
<?php
|
183 |
Â
}
|
184 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
185 |
Â
/** Forums Section ************************************************************/
|
186 |
Â
|
187 |
Â
/**
|
188 |
Â
* Forums settings section description for the settings page
|
189 |
Â
*
|
190 |
-
* @since BuddyPress (1.6)
|
191 |
Â
*/
|
192 |
Â
function bp_admin_setting_callback_bbpress_section() { }
|
193 |
Â
|
194 |
Â
/**
|
195 |
Â
* bb-config.php location field
|
196 |
Â
*
|
197 |
-
* @since BuddyPress (1.6)
|
198 |
Â
* @uses checked() To display the checked attribute
|
199 |
Â
* @uses bp_get_option() To get the config location
|
200 |
Â
* @uses bp_form_option() To get the sanitized form option
|
@@ -223,7 +235,7 @@ function bp_admin_setting_callback_bbpress_configuration() {
|
|
223 |
Â
/**
|
224 |
Â
* The main settings page
|
225 |
Â
*
|
226 |
-
* @since BuddyPress (1.6)
|
227 |
Â
*
|
228 |
Â
* @uses screen_icon() To display the screen icon
|
229 |
Â
* @uses settings_fields() To output the hidden fields for the form
|
@@ -242,7 +254,7 @@ function bp_core_admin_settings() {
|
|
242 |
Â
|
243 |
Â
<h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Settings', 'buddypress' ) ); ?></h2>
|
244 |
Â
|
245 |
-
<form action="<?php echo esc_url( $form_action )
|
246 |
Â
|
247 |
Â
<?php settings_fields( 'buddypress' ); ?>
|
248 |
Â
|
@@ -260,7 +272,7 @@ function bp_core_admin_settings() {
|
|
260 |
Â
/**
|
261 |
Â
* Save our settings
|
262 |
Â
*
|
263 |
-
* @since BuddyPress (1.6)
|
264 |
Â
*/
|
265 |
Â
function bp_core_admin_settings_save() {
|
266 |
Â
global $wp_settings_fields;
|
@@ -280,10 +292,11 @@ function bp_core_admin_settings_save() {
|
|
280 |
Â
}
|
281 |
Â
}
|
282 |
Â
|
283 |
-
// Some legacy options are not registered with the Settings API
|
284 |
Â
$legacy_options = array(
|
285 |
Â
'bp-disable-account-deletion',
|
286 |
Â
'bp-disable-avatar-uploads',
|
Â
|
|
287 |
Â
'bp_disable_blogforum_comments',
|
288 |
Â
'bp-disable-profile-sync',
|
289 |
Â
'bp_restrict_group_creation',
|
@@ -306,7 +319,7 @@ add_action( 'bp_admin_init', 'bp_core_admin_settings_save', 100 );
|
|
306 |
Â
/**
|
307 |
Â
* Output settings API option
|
308 |
Â
*
|
309 |
-
* @since BuddyPress (1.6)
|
310 |
Â
*
|
311 |
Â
* @uses bp_get_bp_form_option()
|
312 |
Â
*
|
@@ -320,7 +333,7 @@ function bp_form_option( $option, $default = '' , $slug = false ) {
|
|
320 |
Â
/**
|
321 |
Â
* Return settings API option
|
322 |
Â
*
|
323 |
-
* @since BuddyPress (1.6)
|
324 |
Â
*
|
325 |
Â
* @uses bp_get_option()
|
326 |
Â
* @uses esc_attr()
|
@@ -336,17 +349,31 @@ function bp_form_option( $option, $default = '' , $slug = false ) {
|
|
336 |
Â
$value = bp_get_option( $option, $default );
|
337 |
Â
|
338 |
Â
// Slug?
|
339 |
-
if ( true === $slug )
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
340 |
Â
$value = esc_attr( apply_filters( 'editable_slug', $value ) );
|
341 |
-
|
342 |
-
// Not a slug
|
343 |
-
else
|
344 |
Â
$value = esc_attr( $value );
|
Â
|
|
345 |
Â
|
346 |
Â
// Fallback to default
|
347 |
Â
if ( empty( $value ) )
|
348 |
Â
$value = $default;
|
349 |
Â
|
350 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
351 |
Â
return apply_filters( 'bp_get_form_option', $value, $option );
|
352 |
Â
}
|
13 |
Â
/**
|
14 |
Â
* Main settings section description for the settings page
|
15 |
Â
*
|
16 |
+
* @since BuddyPress (1.6.0)
|
17 |
Â
*/
|
18 |
Â
function bp_admin_setting_callback_main_section() { }
|
19 |
Â
|
20 |
Â
/**
|
21 |
Â
* Admin bar for logged out users setting field
|
22 |
Â
*
|
23 |
+
* @since BuddyPress (1.6.0)
|
24 |
Â
*
|
25 |
Â
* @uses bp_form_option() To output the option value
|
26 |
Â
*/
|
36 |
Â
/**
|
37 |
Â
* Allow members to delete their accounts setting field
|
38 |
Â
*
|
39 |
+
* @since BuddyPress (1.6.0)
|
40 |
Â
*
|
41 |
Â
* @uses checked() To display the checked attribute
|
42 |
Â
*/
|
54 |
Â
/**
|
55 |
Â
* Groups settings section description for the settings page
|
56 |
Â
*
|
57 |
+
* @since BuddyPress (1.6.0)
|
58 |
Â
*/
|
59 |
Â
function bp_admin_setting_callback_activity_section() { }
|
60 |
Â
|
61 |
Â
/**
|
62 |
Â
* Allow Akismet setting field
|
63 |
Â
*
|
64 |
+
* @since BuddyPress (1.6.0)
|
65 |
Â
*
|
66 |
Â
* @uses checked() To display the checked attribute
|
67 |
Â
*/
|
77 |
Â
/**
|
78 |
Â
* Allow activity comments on blog posts and forum posts
|
79 |
Â
*
|
80 |
+
* @since BuddyPress (1.6.0)
|
81 |
Â
*/
|
82 |
Â
function bp_admin_setting_callback_blogforum_comments() {
|
83 |
Â
?>
|
109 |
Â
* legacy reasons, the option that we store is 1 if these comments are *disabled*. So we use this
|
110 |
Â
* function to flip the boolean before saving the intval.
|
111 |
Â
*
|
112 |
+
* @since BuddyPress (1.6.0)
|
113 |
Â
*/
|
114 |
Â
function bp_admin_sanitize_callback_blogforum_comments( $value = false ) {
|
115 |
Â
return $value ? 0 : 1;
|
120 |
Â
/**
|
121 |
Â
* Profile settings section description for the settings page
|
122 |
Â
*
|
123 |
+
* @since BuddyPress (1.6.0)
|
124 |
Â
*/
|
125 |
Â
function bp_admin_setting_callback_xprofile_section() { }
|
126 |
Â
|
127 |
Â
/**
|
128 |
Â
* Enable BP->WP profile syncing field
|
129 |
Â
*
|
130 |
+
* @since BuddyPress (1.6.0)
|
131 |
Â
*
|
132 |
Â
* @uses bp_form_option() To output the option value
|
133 |
Â
*/
|
143 |
Â
/**
|
144 |
Â
* Allow members to upload avatars field
|
145 |
Â
*
|
146 |
+
* @since BuddyPress (1.6.0)
|
147 |
Â
*
|
148 |
Â
* @uses checked() To display the checked attribute
|
149 |
Â
*/
|
161 |
Â
/**
|
162 |
Â
* Groups settings section description for the settings page
|
163 |
Â
*
|
164 |
+
* @since BuddyPress (1.6.0)
|
165 |
Â
*/
|
166 |
Â
function bp_admin_setting_callback_groups_section() { }
|
167 |
Â
|
168 |
Â
/**
|
169 |
Â
* Allow all users to create groups field
|
170 |
Â
*
|
171 |
+
* @since BuddyPress (1.6.0)
|
172 |
Â
*
|
173 |
Â
* @uses checked() To display the checked attribute
|
174 |
Â
*/
|
182 |
Â
<?php
|
183 |
Â
}
|
184 |
Â
|
185 |
+
/**
|
186 |
+
* 'Enable group avatars' field markup.
|
187 |
+
*
|
188 |
+
* @since BuddyPress (2.3.0)
|
189 |
+
*/
|
190 |
+
function bp_admin_setting_callback_group_avatar_uploads() {
|
191 |
+
?>
|
192 |
+
<input id="bp-disable-group-avatar-uploads" name="bp-disable-group-avatar-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_group_avatar_uploads() ); ?> />
|
193 |
+
<label for="bp-disable-group-avatar-uploads"><?php _e( 'Allow customizable avatars for groups', 'buddypress' ); ?></label>
|
194 |
+
<?php
|
195 |
+
}
|
196 |
+
|
197 |
Â
/** Forums Section ************************************************************/
|
198 |
Â
|
199 |
Â
/**
|
200 |
Â
* Forums settings section description for the settings page
|
201 |
Â
*
|
202 |
+
* @since BuddyPress (1.6.0)
|
203 |
Â
*/
|
204 |
Â
function bp_admin_setting_callback_bbpress_section() { }
|
205 |
Â
|
206 |
Â
/**
|
207 |
Â
* bb-config.php location field
|
208 |
Â
*
|
209 |
+
* @since BuddyPress (1.6.0)
|
210 |
Â
* @uses checked() To display the checked attribute
|
211 |
Â
* @uses bp_get_option() To get the config location
|
212 |
Â
* @uses bp_form_option() To get the sanitized form option
|
235 |
Â
/**
|
236 |
Â
* The main settings page
|
237 |
Â
*
|
238 |
+
* @since BuddyPress (1.6.0)
|
239 |
Â
*
|
240 |
Â
* @uses screen_icon() To display the screen icon
|
241 |
Â
* @uses settings_fields() To output the hidden fields for the form
|
254 |
Â
|
255 |
Â
<h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Settings', 'buddypress' ) ); ?></h2>
|
256 |
Â
|
257 |
+
<form action="<?php echo esc_url( $form_action ) ?>" method="post">
|
258 |
Â
|
259 |
Â
<?php settings_fields( 'buddypress' ); ?>
|
260 |
Â
|
272 |
Â
/**
|
273 |
Â
* Save our settings
|
274 |
Â
*
|
275 |
+
* @since BuddyPress (1.6.0)
|
276 |
Â
*/
|
277 |
Â
function bp_core_admin_settings_save() {
|
278 |
Â
global $wp_settings_fields;
|
292 |
Â
}
|
293 |
Â
}
|
294 |
Â
|
295 |
+
// Some legacy options are not registered with the Settings API, or are reversed in the UI.
|
296 |
Â
$legacy_options = array(
|
297 |
Â
'bp-disable-account-deletion',
|
298 |
Â
'bp-disable-avatar-uploads',
|
299 |
+
'bp-disable-group-avatar-uploads',
|
300 |
Â
'bp_disable_blogforum_comments',
|
301 |
Â
'bp-disable-profile-sync',
|
302 |
Â
'bp_restrict_group_creation',
|
319 |
Â
/**
|
320 |
Â
* Output settings API option
|
321 |
Â
*
|
322 |
+
* @since BuddyPress (1.6.0)
|
323 |
Â
*
|
324 |
Â
* @uses bp_get_bp_form_option()
|
325 |
Â
*
|
333 |
Â
/**
|
334 |
Â
* Return settings API option
|
335 |
Â
*
|
336 |
+
* @since BuddyPress (1.6.0)
|
337 |
Â
*
|
338 |
Â
* @uses bp_get_option()
|
339 |
Â
* @uses esc_attr()
|
349 |
Â
$value = bp_get_option( $option, $default );
|
350 |
Â
|
351 |
Â
// Slug?
|
352 |
+
if ( true === $slug ) {
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Filters the slug value in the form field.
|
356 |
+
*
|
357 |
+
* @since BuddyPress (1.6.0)
|
358 |
+
*
|
359 |
+
* @param string $value Value being returned for the requested option.
|
360 |
+
*/
|
361 |
Â
$value = esc_attr( apply_filters( 'editable_slug', $value ) );
|
362 |
+
} else { // Not a slug
|
Â
|
|
Â
|
|
363 |
Â
$value = esc_attr( $value );
|
364 |
+
}
|
365 |
Â
|
366 |
Â
// Fallback to default
|
367 |
Â
if ( empty( $value ) )
|
368 |
Â
$value = $default;
|
369 |
Â
|
370 |
+
/**
|
371 |
+
* Filters the settings API option.
|
372 |
+
*
|
373 |
+
* @since BuddyPress (1.6.0)
|
374 |
+
*
|
375 |
+
* @param string $value Value being returned for the requested option.
|
376 |
+
* @param string $option Option whose value is being requested.
|
377 |
+
*/
|
378 |
Â
return apply_filters( 'bp_get_form_option', $value, $option );
|
379 |
Â
}
|
bp-core/admin/{bp-core-slugs.php → bp-core-admin-slugs.php}
RENAMED
@@ -13,7 +13,7 @@ defined( 'ABSPATH' ) || exit;
|
|
13 |
Â
/**
|
14 |
Â
* Renders the page mapping admin panel.
|
15 |
Â
*
|
16 |
-
* @since BuddyPress (1.6)
|
17 |
Â
* @todo Use settings API
|
18 |
Â
* @uses bp_core_admin_component_options()
|
19 |
Â
*/
|
@@ -44,11 +44,11 @@ function bp_core_admin_slugs_settings() {
|
|
44 |
Â
* Creates reusable markup for page setup on the Components and Pages dashboard panel.
|
45 |
Â
*
|
46 |
Â
* @package BuddyPress
|
47 |
-
* @since BuddyPress (1.6)
|
48 |
Â
* @todo Use settings API
|
49 |
Â
*/
|
50 |
Â
function bp_core_admin_slugs_options() {
|
51 |
-
|
52 |
Â
|
53 |
Â
// Get the existing WP pages
|
54 |
Â
$existing_pages = bp_core_get_directory_page_ids();
|
@@ -72,6 +72,13 @@ function bp_core_admin_slugs_options() {
|
|
72 |
Â
|
73 |
Â
/** Directory Display *****************************************************/
|
74 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
75 |
Â
$directory_pages = apply_filters( 'bp_directory_pages', $directory_pages );
|
76 |
Â
|
77 |
Â
if ( !empty( $directory_pages ) ) : ?>
|
@@ -115,7 +122,16 @@ function bp_core_admin_slugs_options() {
|
|
115 |
Â
|
116 |
Â
<?php endforeach ?>
|
117 |
Â
|
118 |
-
<?php
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
119 |
Â
|
120 |
Â
</tbody>
|
121 |
Â
</table>
|
@@ -132,6 +148,13 @@ function bp_core_admin_slugs_options() {
|
|
132 |
Â
'activate' => __( 'Activate', 'buddypress' ),
|
133 |
Â
);
|
134 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
135 |
Â
$static_pages = apply_filters( 'bp_static_pages', $static_pages );
|
136 |
Â
|
137 |
Â
if ( !empty( $static_pages ) ) : ?>
|
@@ -174,7 +197,14 @@ function bp_core_admin_slugs_options() {
|
|
174 |
Â
|
175 |
Â
<?php endforeach ?>
|
176 |
Â
|
177 |
-
<?php
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
178 |
Â
|
179 |
Â
</tbody>
|
180 |
Â
</table>
|
@@ -186,7 +216,7 @@ function bp_core_admin_slugs_options() {
|
|
186 |
Â
/**
|
187 |
Â
* Handle saving of the BuddyPress slugs
|
188 |
Â
*
|
189 |
-
* @since BuddyPress (1.6)
|
190 |
Â
* @todo Use settings API
|
191 |
Â
*/
|
192 |
Â
function bp_core_admin_slugs_setup_handler() {
|
13 |
Â
/**
|
14 |
Â
* Renders the page mapping admin panel.
|
15 |
Â
*
|
16 |
+
* @since BuddyPress (1.6.0)
|
17 |
Â
* @todo Use settings API
|
18 |
Â
* @uses bp_core_admin_component_options()
|
19 |
Â
*/
|
44 |
Â
* Creates reusable markup for page setup on the Components and Pages dashboard panel.
|
45 |
Â
*
|
46 |
Â
* @package BuddyPress
|
47 |
+
* @since BuddyPress (1.6.0)
|
48 |
Â
* @todo Use settings API
|
49 |
Â
*/
|
50 |
Â
function bp_core_admin_slugs_options() {
|
51 |
+
$bp = buddypress();
|
52 |
Â
|
53 |
Â
// Get the existing WP pages
|
54 |
Â
$existing_pages = bp_core_get_directory_page_ids();
|
72 |
Â
|
73 |
Â
/** Directory Display *****************************************************/
|
74 |
Â
|
75 |
+
/**
|
76 |
+
* Filters the loaded components needing directory page association to a WordPress page.
|
77 |
+
*
|
78 |
+
* @since BuddyPress (1.5.0)
|
79 |
+
*
|
80 |
+
* @param array $directory_pages Array of available components to set associations for.
|
81 |
+
*/
|
82 |
Â
$directory_pages = apply_filters( 'bp_directory_pages', $directory_pages );
|
83 |
Â
|
84 |
Â
if ( !empty( $directory_pages ) ) : ?>
|
122 |
Â
|
123 |
Â
<?php endforeach ?>
|
124 |
Â
|
125 |
+
<?php
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Fires after the display of default directories.
|
129 |
+
*
|
130 |
+
* Allows plugins to add their own directory associations.
|
131 |
+
*
|
132 |
+
* @since BuddyPress (1.5.0)
|
133 |
+
*/
|
134 |
+
do_action( 'bp_active_external_directories' ); ?>
|
135 |
Â
|
136 |
Â
</tbody>
|
137 |
Â
</table>
|
148 |
Â
'activate' => __( 'Activate', 'buddypress' ),
|
149 |
Â
);
|
150 |
Â
|
151 |
+
/**
|
152 |
+
* Filters the default static pages for BuddyPress setup.
|
153 |
+
*
|
154 |
+
* @since BuddyPress (1.6.0)
|
155 |
+
*
|
156 |
+
* @param array $static_pages Array of static default static pages.
|
157 |
+
*/
|
158 |
Â
$static_pages = apply_filters( 'bp_static_pages', $static_pages );
|
159 |
Â
|
160 |
Â
if ( !empty( $static_pages ) ) : ?>
|
197 |
Â
|
198 |
Â
<?php endforeach ?>
|
199 |
Â
|
200 |
+
<?php
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Fires after the display of default static pages for BuddyPress setup.
|
204 |
+
*
|
205 |
+
* @since BuddyPress (1.5.0)
|
206 |
+
*/
|
207 |
+
do_action( 'bp_active_external_pages' ); ?>
|
208 |
Â
|
209 |
Â
</tbody>
|
210 |
Â
</table>
|
216 |
Â
/**
|
217 |
Â
* Handle saving of the BuddyPress slugs
|
218 |
Â
*
|
219 |
+
* @since BuddyPress (1.6.0)
|
220 |
Â
* @todo Use settings API
|
221 |
Â
*/
|
222 |
Â
function bp_core_admin_slugs_setup_handler() {
|
bp-core/admin/{bp-core-tools.php → bp-core-admin-tools.php}
RENAMED
@@ -144,6 +144,13 @@ function bp_admin_repair_list() {
|
|
144 |
Â
|
145 |
Â
ksort( $repair_list );
|
146 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
147 |
Â
return (array) apply_filters( 'bp_repair_list', $repair_list );
|
148 |
Â
}
|
149 |
Â
|
@@ -155,7 +162,7 @@ function bp_admin_repair_list() {
|
|
155 |
Â
* @return array
|
156 |
Â
*/
|
157 |
Â
function bp_admin_repair_friend_count() {
|
158 |
-
global $wpdb
|
159 |
Â
|
160 |
Â
if ( ! bp_is_active( 'friends' ) ) {
|
161 |
Â
return;
|
@@ -169,6 +176,8 @@ function bp_admin_repair_friend_count() {
|
|
169 |
Â
return array( 1, sprintf( $statement, $result ) );
|
170 |
Â
}
|
171 |
Â
|
Â
|
|
Â
|
|
172 |
Â
// Walk through all users on the site
|
173 |
Â
$total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c;
|
174 |
Â
|
@@ -211,7 +220,7 @@ function bp_admin_repair_friend_count() {
|
|
211 |
Â
* @return array
|
212 |
Â
*/
|
213 |
Â
function bp_admin_repair_group_count() {
|
214 |
-
global $wpdb
|
215 |
Â
|
216 |
Â
if ( ! bp_is_active( 'groups' ) ) {
|
217 |
Â
return;
|
@@ -225,6 +234,8 @@ function bp_admin_repair_group_count() {
|
|
225 |
Â
return array( 1, sprintf( $statement, $result ) );
|
226 |
Â
}
|
227 |
Â
|
Â
|
|
Â
|
|
228 |
Â
// Walk through all users on the site
|
229 |
Â
$total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c;
|
230 |
Â
|
@@ -360,7 +371,14 @@ function bp_core_admin_available_tools_page() {
|
|
360 |
Â
<div class="wrap">
|
361 |
Â
<h2><?php esc_attr_e( 'Tools', 'buddypress' ) ?></h2>
|
362 |
Â
|
363 |
-
<?php
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
364 |
Â
|
365 |
Â
</div>
|
366 |
Â
<?php
|
@@ -379,8 +397,8 @@ function bp_core_admin_available_tools_intro() {
|
|
379 |
Â
$page = bp_core_do_network_admin() ? 'admin.php' : 'tools.php' ;
|
380 |
Â
$url = add_query_arg( $query_arg, bp_get_admin_url( $page ) );
|
381 |
Â
?>
|
382 |
-
<div class="tool-box">
|
383 |
-
<h3
|
384 |
Â
<p>
|
385 |
Â
<?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' ); ?>
|
386 |
Â
<?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>' ); ?>
|
144 |
Â
|
145 |
Â
ksort( $repair_list );
|
146 |
Â
|
147 |
+
/**
|
148 |
+
* Filters the array of the repair list.
|
149 |
+
*
|
150 |
+
* @since BuddyPress (2.0.0)
|
151 |
+
*
|
152 |
+
* @param array $repair_list Array of values for the Repair list options.
|
153 |
+
*/
|
154 |
Â
return (array) apply_filters( 'bp_repair_list', $repair_list );
|
155 |
Â
}
|
156 |
Â
|
162 |
Â
* @return array
|
163 |
Â
*/
|
164 |
Â
function bp_admin_repair_friend_count() {
|
165 |
+
global $wpdb;
|
166 |
Â
|
167 |
Â
if ( ! bp_is_active( 'friends' ) ) {
|
168 |
Â
return;
|
176 |
Â
return array( 1, sprintf( $statement, $result ) );
|
177 |
Â
}
|
178 |
Â
|
179 |
+
$bp = buddypress();
|
180 |
+
|
181 |
Â
// Walk through all users on the site
|
182 |
Â
$total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c;
|
183 |
Â
|
220 |
Â
* @return array
|
221 |
Â
*/
|
222 |
Â
function bp_admin_repair_group_count() {
|
223 |
+
global $wpdb;
|
224 |
Â
|
225 |
Â
if ( ! bp_is_active( 'groups' ) ) {
|
226 |
Â
return;
|
234 |
Â
return array( 1, sprintf( $statement, $result ) );
|
235 |
Â
}
|
236 |
Â
|
237 |
+
$bp = buddypress();
|
238 |
+
|
239 |
Â
// Walk through all users on the site
|
240 |
Â
$total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c;
|
241 |
Â
|
371 |
Â
<div class="wrap">
|
372 |
Â
<h2><?php esc_attr_e( 'Tools', 'buddypress' ) ?></h2>
|
373 |
Â
|
374 |
+
<?php
|
375 |
+
|
376 |
+
/**
|
377 |
+
* Fires inside the markup used to display the Available Tools page.
|
378 |
+
*
|
379 |
+
* @since BuddyPress (2.0.0)
|
380 |
+
*/
|
381 |
+
do_action( 'bp_network_tool_box' ); ?>
|
382 |
Â
|
383 |
Â
</div>
|
384 |
Â
<?php
|
397 |
Â
$page = bp_core_do_network_admin() ? 'admin.php' : 'tools.php' ;
|
398 |
Â
$url = add_query_arg( $query_arg, bp_get_admin_url( $page ) );
|
399 |
Â
?>
|
400 |
+
<div class="card tool-box">
|
401 |
+
<h3><?php esc_html_e( 'BuddyPress Tools', 'buddypress' ) ?></h3>
|
402 |
Â
<p>
|
403 |
Â
<?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' ); ?>
|
404 |
Â
<?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>' ); ?>
|
bp-core/admin/css/common-rtl.css
CHANGED
@@ -24,6 +24,48 @@ body.index_page_bp-about span.dashicons {
|
|
24 |
Â
text-align: center;
|
25 |
Â
}
|
26 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
27 |
Â
/* User's Lists
|
28 |
Â
------------------------------------------------------------------------------*/
|
29 |
Â
|
@@ -417,6 +459,17 @@ body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title sp
|
|
417 |
Â
left: 0;
|
418 |
Â
}
|
419 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
420 |
Â
/* HiDPI
|
421 |
Â
------------------------------------------------------------------------------*/
|
422 |
Â
|
24 |
Â
text-align: center;
|
25 |
Â
}
|
26 |
Â
|
27 |
+
/* About Page - since 2.3.3 (WP 4.3) */
|
28 |
+
|
29 |
+
.about-wrap .two-col > div {
|
30 |
+
position: relative;
|
31 |
+
width: 47.6%;
|
32 |
+
margin-left: 4.799999999%;
|
33 |
+
float: right;
|
34 |
+
}
|
35 |
+
|
36 |
+
.about-wrap [class$=col] .last-feature {
|
37 |
+
margin-left: 0;
|
38 |
+
}
|
39 |
+
|
40 |
+
.about-wrap .feature-list.finer-points h4,
|
41 |
+
.about-wrap .feature-list.finer-points p {
|
42 |
+
margin-right: 115px;
|
43 |
+
}
|
44 |
+
|
45 |
+
@media screen and ( max-width: 782px ) {
|
46 |
+
.about-wrap .two-col > div {
|
47 |
+
width: 100%;
|
48 |
+
margin: 30px 0 0;
|
49 |
+
padding: 0 0 30px;
|
50 |
+
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
51 |
+
}
|
52 |
+
body.dashboard_page_bp-about span.dashicons,
|
53 |
+
body.index_page_bp-about span.dashicons {
|
54 |
+
font-size: 55px;
|
55 |
+
line-height: 70px;
|
56 |
+
height: 70px;
|
57 |
+
width: 70px;
|
58 |
+
}
|
59 |
+
.about-wrap .feature-list h2 {
|
60 |
+
margin: 30px 0 0;
|
61 |
+
text-align: center;
|
62 |
+
}
|
63 |
+
.about-wrap .feature-list.finer-points h4,
|
64 |
+
.about-wrap .feature-list.finer-points p {
|
65 |
+
margin-right: 90px;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
Â
/* User's Lists
|
70 |
Â
------------------------------------------------------------------------------*/
|
71 |
Â
|
459 |
Â
left: 0;
|
460 |
Â
}
|
461 |
Â
|
462 |
+
/* About Page - since 2.3.3 (WP 4.3) */
|
463 |
+
|
464 |
+
@media only screen and (max-width: 500px) {
|
465 |
+
.about-wrap .bp-badge {
|
466 |
+
position: relative;
|
467 |
+
margin: 10px auto;
|
468 |
+
top: auto;
|
469 |
+
left: auto;
|
470 |
+
}
|
471 |
+
}
|
472 |
+
|
473 |
Â
/* HiDPI
|
474 |
Â
------------------------------------------------------------------------------*/
|
475 |
Â
|
bp-core/admin/css/common-rtl.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{float:right;clear:right;margin:15px 0 0 15px;height:90px;width:90px;background-color:#ccc;-webkit-border-radius:50%;border-radius:50%;border:1px solid #c1c1c1;font-size:65px;line-height:90px;color:#999;text-align:center}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}body.branch-3-6 div#icon-buddypress,body.branch-3-7 div#icon-buddypress{background:url(../images/icons32.png) -370px -6px no-repeat}body.branch-3-6 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-activity{background:url(../images/icons32.png) -10px -6px no-repeat}body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress-groups{background:url(../images/icons32.png) -250px -6px no-repeat}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{background-image:url(../images/menu.png)!important;background-position:-178px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image{background-position:-178px -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image{background-image:url(../images/menu.png);background-position:0 -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image{background-position:0 -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu.png);background-position:-61px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image{background-position:-61px -2px}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}body.branch-3-6 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-6 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-7 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:""}.settings_page_bp-components td.plugin-title span{float:right;width:18px;height:18px;margin-left:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.forums td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:""}body.branch-3-6.settings_page_bp-components td.plugin-title span,body.branch-3-7.settings_page_bp-components td.plugin-title span{background-image:url(../images/menu.png);background-position:-4px -40px;background-repeat:no-repeat}body.branch-3-6.settings_page_bp-components tr.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.active td.plugin-title span{background-position-y:-7px}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span{background-position:-4px -40px}body.branch-3-6.settings_page_bp-components tr.activity.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity.active td.plugin-title span{background-position:-4px -7px}body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-305px -40px}body.branch-3-6.settings_page_bp-components tr.xprofile.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile.active td.plugin-title span{background-position:-305px -7px}body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-334px -40px}body.branch-3-6.settings_page_bp-components tr.settings.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings.active td.plugin-title span{background-position:-334px -7px}body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span{background-position:-66px -40px}body.branch-3-6.settings_page_bp-components tr.groups.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups.active td.plugin-title span{background-position:-66px -7px}body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span{background-position:-154px -40px}body.branch-3-6.settings_page_bp-components tr.messages.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages.active td.plugin-title span{background-position:-154px -7px}body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.forums.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums.active td.plugin-title span{background-position:-36px -7px}body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span{background-position:-125px -40px}body.branch-3-6.settings_page_bp-components tr.blogs.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs.active td.plugin-title span{background-position:-125px -7px}body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span{background-position:-95px -40px}body.branch-3-6.settings_page_bp-components tr.friends.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends.active td.plugin-title span{background-position:-95px -7px}body.branch-3-6.settings_page_bp-components tr.core td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core td.plugin-title span{background-position:-184px -40px}body.branch-3-6.settings_page_bp-components tr.core.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core.active td.plugin-title span{background-position:-184px -7px}body.branch-3-6.settings_page_bp-components tr.members td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members td.plugin-title span{background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.members.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title span{background-position:-36px -7px}#bp-admin-component-form .widefat th{display:table-cell;vertical-align:top}.bp-badge{font:400 150px/1 dashicons!important;color:#D84800;display:inline-block}.bp-badge:before{content:"\f448"}.about-wrap .bp-badge{position:absolute;top:0;left:0}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body.branch-3-6 div#icon-buddypress,body.branch-3-6 div#icon-buddypress-activity,body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress,body.branch-3-7 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-groups{background-image:url(../images/icons64.png);background-size:419px 45px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu-2x.png)!important;background-size:209px 64px}}
|
1 |
+
body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{float:right;clear:right;margin:15px 0 0 15px;height:90px;width:90px;background-color:#ccc;-webkit-border-radius:50%;border-radius:50%;border:1px solid #c1c1c1;font-size:65px;line-height:90px;color:#999;text-align:center}.about-wrap .two-col>div{position:relative;width:47.6%;margin-left:4.799999999%;float:right}.about-wrap [class$=col] .last-feature{margin-left:0}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-right:115px}@media screen and (max-width:782px){.about-wrap .two-col>div{width:100%;margin:30px 0 0;padding:0 0 30px;border-bottom:1px solid rgba(0,0,0,.1)}body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{font-size:55px;line-height:70px;height:70px;width:70px}.about-wrap .feature-list h2{margin:30px 0 0;text-align:center}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-right:90px}}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}body.branch-3-6 div#icon-buddypress,body.branch-3-7 div#icon-buddypress{background:url(../images/icons32.png) -370px -6px no-repeat}body.branch-3-6 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-activity{background:url(../images/icons32.png) -10px -6px no-repeat}body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress-groups{background:url(../images/icons32.png) -250px -6px no-repeat}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{background-image:url(../images/menu.png)!important;background-position:-178px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image{background-position:-178px -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image{background-image:url(../images/menu.png);background-position:0 -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image{background-position:0 -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu.png);background-position:-61px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image{background-position:-61px -2px}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}body.branch-3-6 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-6 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-7 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:""}.settings_page_bp-components td.plugin-title span{float:right;width:18px;height:18px;margin-left:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.forums td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:""}body.branch-3-6.settings_page_bp-components td.plugin-title span,body.branch-3-7.settings_page_bp-components td.plugin-title span{background-image:url(../images/menu.png);background-position:-4px -40px;background-repeat:no-repeat}body.branch-3-6.settings_page_bp-components tr.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.active td.plugin-title span{background-position-y:-7px}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span{background-position:-4px -40px}body.branch-3-6.settings_page_bp-components tr.activity.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity.active td.plugin-title span{background-position:-4px -7px}body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-305px -40px}body.branch-3-6.settings_page_bp-components tr.xprofile.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile.active td.plugin-title span{background-position:-305px -7px}body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-334px -40px}body.branch-3-6.settings_page_bp-components tr.settings.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings.active td.plugin-title span{background-position:-334px -7px}body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span{background-position:-66px -40px}body.branch-3-6.settings_page_bp-components tr.groups.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups.active td.plugin-title span{background-position:-66px -7px}body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span{background-position:-154px -40px}body.branch-3-6.settings_page_bp-components tr.messages.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages.active td.plugin-title span{background-position:-154px -7px}body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.forums.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums.active td.plugin-title span{background-position:-36px -7px}body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span{background-position:-125px -40px}body.branch-3-6.settings_page_bp-components tr.blogs.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs.active td.plugin-title span{background-position:-125px -7px}body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span{background-position:-95px -40px}body.branch-3-6.settings_page_bp-components tr.friends.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends.active td.plugin-title span{background-position:-95px -7px}body.branch-3-6.settings_page_bp-components tr.core td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core td.plugin-title span{background-position:-184px -40px}body.branch-3-6.settings_page_bp-components tr.core.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core.active td.plugin-title span{background-position:-184px -7px}body.branch-3-6.settings_page_bp-components tr.members td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members td.plugin-title span{background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.members.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title span{background-position:-36px -7px}#bp-admin-component-form .widefat th{display:table-cell;vertical-align:top}.bp-badge{font:400 150px/1 dashicons!important;color:#D84800;display:inline-block}.bp-badge:before{content:"\f448"}.about-wrap .bp-badge{position:absolute;top:0;left:0}@media only screen and (max-width:500px){.about-wrap .bp-badge{position:relative;margin:10px auto;top:auto;left:auto}}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body.branch-3-6 div#icon-buddypress,body.branch-3-6 div#icon-buddypress-activity,body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress,body.branch-3-7 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-groups{background-image:url(../images/icons64.png);background-size:419px 45px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu-2x.png)!important;background-size:209px 64px}}
|
bp-core/admin/css/common.css
CHANGED
@@ -24,6 +24,48 @@ body.index_page_bp-about span.dashicons {
|
|
24 |
Â
text-align: center;
|
25 |
Â
}
|
26 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
27 |
Â
/* User's Lists
|
28 |
Â
------------------------------------------------------------------------------*/
|
29 |
Â
|
@@ -417,6 +459,17 @@ body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title sp
|
|
417 |
Â
right: 0;
|
418 |
Â
}
|
419 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
420 |
Â
/* HiDPI
|
421 |
Â
------------------------------------------------------------------------------*/
|
422 |
Â
|
24 |
Â
text-align: center;
|
25 |
Â
}
|
26 |
Â
|
27 |
+
/* About Page - since 2.3.3 (WP 4.3) */
|
28 |
+
|
29 |
+
.about-wrap .two-col > div {
|
30 |
+
position: relative;
|
31 |
+
width: 47.6%;
|
32 |
+
margin-right: 4.799999999%;
|
33 |
+
float: left;
|
34 |
+
}
|
35 |
+
|
36 |
+
.about-wrap [class$=col] .last-feature {
|
37 |
+
margin-right: 0;
|
38 |
+
}
|
39 |
+
|
40 |
+
.about-wrap .feature-list.finer-points h4,
|
41 |
+
.about-wrap .feature-list.finer-points p {
|
42 |
+
margin-left: 115px;
|
43 |
+
}
|
44 |
+
|
45 |
+
@media screen and ( max-width: 782px ) {
|
46 |
+
.about-wrap .two-col > div {
|
47 |
+
width: 100%;
|
48 |
+
margin: 30px 0 0;
|
49 |
+
padding: 0 0 30px;
|
50 |
+
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
51 |
+
}
|
52 |
+
body.dashboard_page_bp-about span.dashicons,
|
53 |
+
body.index_page_bp-about span.dashicons {
|
54 |
+
font-size: 55px;
|
55 |
+
line-height: 70px;
|
56 |
+
height: 70px;
|
57 |
+
width: 70px;
|
58 |
+
}
|
59 |
+
.about-wrap .feature-list h2 {
|
60 |
+
margin: 30px 0 0;
|
61 |
+
text-align: center;
|
62 |
+
}
|
63 |
+
.about-wrap .feature-list.finer-points h4,
|
64 |
+
.about-wrap .feature-list.finer-points p {
|
65 |
+
margin-left: 90px;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
Â
/* User's Lists
|
70 |
Â
------------------------------------------------------------------------------*/
|
71 |
Â
|
459 |
Â
right: 0;
|
460 |
Â
}
|
461 |
Â
|
462 |
+
/* About Page - since 2.3.3 (WP 4.3) */
|
463 |
+
|
464 |
+
@media only screen and (max-width: 500px) {
|
465 |
+
.about-wrap .bp-badge {
|
466 |
+
position: relative;
|
467 |
+
margin: 10px auto;
|
468 |
+
top: auto;
|
469 |
+
right: auto;
|
470 |
+
}
|
471 |
+
}
|
472 |
+
|
473 |
Â
/* HiDPI
|
474 |
Â
------------------------------------------------------------------------------*/
|
475 |
Â
|
bp-core/admin/css/common.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{float:left;clear:left;margin:15px 15px 0 0;height:90px;width:90px;background-color:#ccc;-webkit-border-radius:50%;border-radius:50%;border:1px solid #c1c1c1;font-size:65px;line-height:90px;color:#999;text-align:center}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}body.branch-3-6 div#icon-buddypress,body.branch-3-7 div#icon-buddypress{background:url(../images/icons32.png) -370px -6px no-repeat}body.branch-3-6 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-activity{background:url(../images/icons32.png) -10px -6px no-repeat}body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress-groups{background:url(../images/icons32.png) -250px -6px no-repeat}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{background-image:url(../images/menu.png)!important;background-position:-178px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image{background-position:-178px -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image{background-image:url(../images/menu.png);background-position:0 -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image{background-position:0 -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu.png);background-position:-61px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image{background-position:-61px -2px}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}body.branch-3-6 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-6 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-7 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:""}.settings_page_bp-components td.plugin-title span{float:left;width:18px;height:18px;margin-right:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.forums td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:""}body.branch-3-6.settings_page_bp-components td.plugin-title span,body.branch-3-7.settings_page_bp-components td.plugin-title span{background-image:url(../images/menu.png);background-position:-4px -40px;background-repeat:no-repeat}body.branch-3-6.settings_page_bp-components tr.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.active td.plugin-title span{background-position-y:-7px}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span{background-position:-4px -40px}body.branch-3-6.settings_page_bp-components tr.activity.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity.active td.plugin-title span{background-position:-4px -7px}body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-305px -40px}body.branch-3-6.settings_page_bp-components tr.xprofile.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile.active td.plugin-title span{background-position:-305px -7px}body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-334px -40px}body.branch-3-6.settings_page_bp-components tr.settings.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings.active td.plugin-title span{background-position:-334px -7px}body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span{background-position:-66px -40px}body.branch-3-6.settings_page_bp-components tr.groups.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups.active td.plugin-title span{background-position:-66px -7px}body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span{background-position:-154px -40px}body.branch-3-6.settings_page_bp-components tr.messages.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages.active td.plugin-title span{background-position:-154px -7px}body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.forums.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums.active td.plugin-title span{background-position:-36px -7px}body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span{background-position:-125px -40px}body.branch-3-6.settings_page_bp-components tr.blogs.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs.active td.plugin-title span{background-position:-125px -7px}body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span{background-position:-95px -40px}body.branch-3-6.settings_page_bp-components tr.friends.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends.active td.plugin-title span{background-position:-95px -7px}body.branch-3-6.settings_page_bp-components tr.core td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core td.plugin-title span{background-position:-184px -40px}body.branch-3-6.settings_page_bp-components tr.core.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core.active td.plugin-title span{background-position:-184px -7px}body.branch-3-6.settings_page_bp-components tr.members td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members td.plugin-title span{background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.members.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title span{background-position:-36px -7px}#bp-admin-component-form .widefat th{display:table-cell;vertical-align:top}.bp-badge{font:400 150px/1 dashicons!important;color:#D84800;display:inline-block}.bp-badge:before{content:"\f448"}.about-wrap .bp-badge{position:absolute;top:0;right:0}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body.branch-3-6 div#icon-buddypress,body.branch-3-6 div#icon-buddypress-activity,body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress,body.branch-3-7 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-groups{background-image:url(../images/icons64.png);background-size:419px 45px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu-2x.png)!important;background-size:209px 64px}}
|
1 |
+
body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{float:left;clear:left;margin:15px 15px 0 0;height:90px;width:90px;background-color:#ccc;-webkit-border-radius:50%;border-radius:50%;border:1px solid #c1c1c1;font-size:65px;line-height:90px;color:#999;text-align:center}.about-wrap .two-col>div{position:relative;width:47.6%;margin-right:4.799999999%;float:left}.about-wrap [class$=col] .last-feature{margin-right:0}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-left:115px}@media screen and (max-width:782px){.about-wrap .two-col>div{width:100%;margin:30px 0 0;padding:0 0 30px;border-bottom:1px solid rgba(0,0,0,.1)}body.dashboard_page_bp-about span.dashicons,body.index_page_bp-about span.dashicons{font-size:55px;line-height:70px;height:70px;width:70px}.about-wrap .feature-list h2{margin:30px 0 0;text-align:center}.about-wrap .feature-list.finer-points h4,.about-wrap .feature-list.finer-points p{margin-left:90px}}body.site-users-php th#role,body.users-php th#role,body.users_page_bp-signups th#count_sent{width:10%}body.site-users-php th#email,body.site-users-php th#name,body.users-php th#email,body.users-php th#name,body.users-php th#registered,body.users_page_bp-signups th#date_sent,body.users_page_bp-signups th#email,body.users_page_bp-signups th#name,body.users_page_bp-signups th#registered{width:15%}body.users-php th#blogs,body.users_page_bp-signups th#blogs{width:20%}body.users_page_bp-signups td.count_sent,body.users_page_bp-signups th.column-count_sent{text-align:center}body.branch-3-6 div#icon-buddypress,body.branch-3-7 div#icon-buddypress{background:url(../images/icons32.png) -370px -6px no-repeat}body.branch-3-6 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-activity{background:url(../images/icons32.png) -10px -6px no-repeat}body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress-groups{background:url(../images/icons32.png) -250px -6px no-repeat}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{background-image:url(../images/menu.png)!important;background-position:-178px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image{background-position:-178px -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image{background-image:url(../images/menu.png);background-position:0 -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image{background-position:0 -2px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu.png);background-position:-61px -34px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image{background-position:-61px -2px}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before{content:"\f108"}#adminmenu li.toplevel_page_bp-components .wp-menu-image,#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:"\f448"}body.branch-3-6 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-6 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-6 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,body.branch-3-7 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,body.branch-3-7 #adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image{content:""}.settings_page_bp-components td.plugin-title span{float:left;width:18px;height:18px;margin-right:5px}.settings_page_bp-components td.plugin-title span:before{font-family:dashicons;font-size:18px}.settings_page_bp-components tr.activity td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.notifications td.plugin-title span:before{content:"\f339"}.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:"\f336"}.settings_page_bp-components tr.settings td.plugin-title span:before{content:"\f108"}.settings_page_bp-components tr.groups td.plugin-title span:before{content:"\f456"}.settings_page_bp-components tr.messages td.plugin-title span:before{content:"\f457"}.settings_page_bp-components tr.forums td.plugin-title span:before{content:"\f452"}.settings_page_bp-components tr.blogs td.plugin-title span:before{content:"\f120"}.settings_page_bp-components tr.friends td.plugin-title span:before{content:"\f454"}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.notifications td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span:before{content:""}body.branch-3-6.settings_page_bp-components td.plugin-title span,body.branch-3-7.settings_page_bp-components td.plugin-title span{background-image:url(../images/menu.png);background-position:-4px -40px;background-repeat:no-repeat}body.branch-3-6.settings_page_bp-components tr.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.active td.plugin-title span{background-position-y:-7px}body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span{background-position:-4px -40px}body.branch-3-6.settings_page_bp-components tr.activity.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.activity.active td.plugin-title span{background-position:-4px -7px}body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-305px -40px}body.branch-3-6.settings_page_bp-components tr.xprofile.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.xprofile.active td.plugin-title span{background-position:-305px -7px}body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-334px -40px}body.branch-3-6.settings_page_bp-components tr.settings.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.settings.active td.plugin-title span{background-position:-334px -7px}body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span{background-position:-66px -40px}body.branch-3-6.settings_page_bp-components tr.groups.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.groups.active td.plugin-title span{background-position:-66px -7px}body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span{background-position:-154px -40px}body.branch-3-6.settings_page_bp-components tr.messages.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.messages.active td.plugin-title span{background-position:-154px -7px}body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span{background-image:url(../images/menu-wp.png);background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.forums.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.forums.active td.plugin-title span{background-position:-36px -7px}body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span{background-position:-125px -40px}body.branch-3-6.settings_page_bp-components tr.blogs.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.blogs.active td.plugin-title span{background-position:-125px -7px}body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span{background-position:-95px -40px}body.branch-3-6.settings_page_bp-components tr.friends.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.friends.active td.plugin-title span{background-position:-95px -7px}body.branch-3-6.settings_page_bp-components tr.core td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core td.plugin-title span{background-position:-184px -40px}body.branch-3-6.settings_page_bp-components tr.core.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.core.active td.plugin-title span{background-position:-184px -7px}body.branch-3-6.settings_page_bp-components tr.members td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members td.plugin-title span{background-position:-36px -40px}body.branch-3-6.settings_page_bp-components tr.members.active td.plugin-title span,body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title span{background-position:-36px -7px}#bp-admin-component-form .widefat th{display:table-cell;vertical-align:top}.bp-badge{font:400 150px/1 dashicons!important;color:#D84800;display:inline-block}.bp-badge:before{content:"\f448"}.about-wrap .bp-badge{position:absolute;top:0;right:0}@media only screen and (max-width:500px){.about-wrap .bp-badge{position:relative;margin:10px auto;top:auto;right:auto}}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body.branch-3-6 div#icon-buddypress,body.branch-3-6 div#icon-buddypress-activity,body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress,body.branch-3-7 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-groups{background-image:url(../images/icons64.png);background-size:419px 45px}body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image{background-image:url(../images/menu-2x.png)!important;background-size:209px 64px}}
|
bp-core/admin/images/avatar-ui.gif
ADDED
Binary file
|
bp-core/admin/images/member-types.png
DELETED
Binary file
|
bp-core/bp-core-actions.php
CHANGED
@@ -55,6 +55,7 @@ add_action( 'bp_loaded', 'bp_setup_components', 2 );
|
|
55 |
Â
add_action( 'bp_loaded', 'bp_include', 4 );
|
56 |
Â
add_action( 'bp_loaded', 'bp_setup_cache_groups', 5 );
|
57 |
Â
add_action( 'bp_loaded', 'bp_setup_widgets', 6 );
|
Â
|
|
58 |
Â
add_action( 'bp_loaded', 'bp_register_theme_packages', 12 );
|
59 |
Â
add_action( 'bp_loaded', 'bp_register_theme_directory', 14 );
|
60 |
Â
|
55 |
Â
add_action( 'bp_loaded', 'bp_include', 4 );
|
56 |
Â
add_action( 'bp_loaded', 'bp_setup_cache_groups', 5 );
|
57 |
Â
add_action( 'bp_loaded', 'bp_setup_widgets', 6 );
|
58 |
+
add_action( 'bp_loaded', 'bp_register_member_types', 8 );
|
59 |
Â
add_action( 'bp_loaded', 'bp_register_theme_packages', 12 );
|
60 |
Â
add_action( 'bp_loaded', 'bp_register_theme_directory', 14 );
|
61 |
Â
|
bp-core/bp-core-admin.php
CHANGED
@@ -16,6 +16,7 @@ if ( !class_exists( 'BP_Admin' ) ) :
|
|
16 |
Â
*
|
17 |
Â
* @package BuddyPress
|
18 |
Â
* @subpackage CoreAdministration
|
Â
|
|
19 |
Â
*
|
20 |
Â
* @since BuddyPress (1.6.0)
|
21 |
Â
*/
|
@@ -116,12 +117,12 @@ class BP_Admin {
|
|
116 |
Â
* @access private
|
117 |
Â
*/
|
118 |
Â
private function includes() {
|
119 |
-
require( $this->admin_dir . 'bp-core-actions.php' );
|
120 |
-
require( $this->admin_dir . 'bp-core-settings.php' );
|
121 |
-
require( $this->admin_dir . 'bp-core-functions.php' );
|
122 |
-
require( $this->admin_dir . 'bp-core-components.php' );
|
123 |
-
require( $this->admin_dir . 'bp-core-slugs.php' );
|
124 |
-
require( $this->admin_dir . 'bp-core-tools.php' );
|
125 |
Â
}
|
126 |
Â
|
127 |
Â
/**
|
@@ -158,7 +159,7 @@ class BP_Admin {
|
|
158 |
Â
add_action( 'admin_bar_menu', array( $this, 'admin_bar_about_link' ), 15 );
|
159 |
Â
|
160 |
Â
// Add a description of new BuddyPress tools in the available tools page
|
161 |
-
add_action( 'tool_box',
|
162 |
Â
add_action( 'bp_network_tool_box', 'bp_core_admin_available_tools_intro' );
|
163 |
Â
|
164 |
Â
// On non-multisite, catch
|
@@ -178,7 +179,7 @@ class BP_Admin {
|
|
178 |
Â
/**
|
179 |
Â
* Add the navigational menu elements.
|
180 |
Â
*
|
181 |
-
* @since BuddyPress (1.6)
|
182 |
Â
*
|
183 |
Â
* @uses add_management_page() To add the Recount page in Tools section.
|
184 |
Â
* @uses add_options_page() To add the Forums settings page in Settings
|
@@ -314,11 +315,11 @@ class BP_Admin {
|
|
314 |
Â
/** Main Section ******************************************************/
|
315 |
Â
|
316 |
Â
// Add the main section
|
317 |
-
add_settings_section( 'bp_main',
|
318 |
Â
|
319 |
Â
// Hide toolbar for logged out users setting
|
320 |
-
add_settings_field( 'hide-loggedout-adminbar',
|
321 |
-
register_setting
|
322 |
Â
|
323 |
Â
// Only show 'switch to Toolbar' option if the user chose to retain the BuddyBar during the 1.6 upgrade
|
324 |
Â
if ( (bool) bp_get_option( '_bp_force_buddybar', false ) ) {
|
@@ -328,7 +329,7 @@ class BP_Admin {
|
|
328 |
Â
|
329 |
Â
// Allow account deletion
|
330 |
Â
add_settings_field( 'bp-disable-account-deletion', __( 'Account Deletion', 'buddypress' ), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main' );
|
331 |
-
register_setting
|
332 |
Â
|
333 |
Â
/** XProfile Section **************************************************/
|
334 |
Â
|
@@ -337,11 +338,12 @@ class BP_Admin {
|
|
337 |
Â
// Add the main section
|
338 |
Â
add_settings_section( 'bp_xprofile', _x( 'Profile Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress' );
|
339 |
Â
|
340 |
-
|
Â
|
|
341 |
Â
|
342 |
Â
// Profile sync setting
|
343 |
-
add_settings_field( 'bp-disable-profile-sync', __( 'Profile Syncing', 'buddypress' ), 'bp_admin_setting_callback_profile_sync',
|
344 |
-
register_setting ( 'buddypress',
|
345 |
Â
}
|
346 |
Â
|
347 |
Â
/** Groups Section ****************************************************/
|
@@ -349,15 +351,15 @@ class BP_Admin {
|
|
349 |
Â
if ( bp_is_active( 'groups' ) ) {
|
350 |
Â
|
351 |
Â
// Add the main section
|
352 |
-
add_settings_section( 'bp_groups',
|
353 |
-
|
354 |
-
if ( empty( $avatar_setting ) ) {
|
355 |
-
$avatar_setting = 'bp_groups';
|
356 |
-
}
|
357 |
Â
|
358 |
Â
// Allow subscriptions setting
|
359 |
-
add_settings_field( 'bp_restrict_group_creation', __( 'Group Creation',
|
360 |
-
register_setting
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
361 |
Â
}
|
362 |
Â
|
363 |
Â
/** Forums ************************************************************/
|
@@ -365,11 +367,11 @@ class BP_Admin {
|
|
365 |
Â
if ( bp_is_active( 'forums' ) ) {
|
366 |
Â
|
367 |
Â
// Add the main section
|
368 |
-
add_settings_section( 'bp_forums',
|
369 |
Â
|
370 |
Â
// Allow subscriptions setting
|
371 |
Â
add_settings_field( 'bb-config-location', __( 'bbPress Configuration', 'buddypress' ), 'bp_admin_setting_callback_bbpress_configuration', 'buddypress', 'bp_forums' );
|
372 |
-
register_setting
|
373 |
Â
}
|
374 |
Â
|
375 |
Â
/** Activity Section **************************************************/
|
@@ -377,7 +379,7 @@ class BP_Admin {
|
|
377 |
Â
if ( bp_is_active( 'activity' ) ) {
|
378 |
Â
|
379 |
Â
// Add the main section
|
380 |
-
add_settings_section( 'bp_activity',
|
381 |
Â
|
382 |
Â
// Activity commenting on blog and forum posts
|
383 |
Â
add_settings_field( 'bp-disable-blogforum-comments', __( 'Blog & Forum Comments', 'buddypress' ), 'bp_admin_setting_callback_blogforum_comments', 'buddypress', 'bp_activity' );
|
@@ -389,18 +391,10 @@ class BP_Admin {
|
|
389 |
Â
|
390 |
Â
// Allow activity akismet
|
391 |
Â
if ( is_plugin_active( 'akismet/akismet.php' ) && defined( 'AKISMET_VERSION' ) ) {
|
392 |
-
add_settings_field( '_bp_enable_akismet', __( 'Akismet',
|
393 |
-
register_setting
|
394 |
Â
}
|
395 |
Â
}
|
396 |
-
|
397 |
-
/** Avatar upload for users or groups ************************************/
|
398 |
-
|
399 |
-
if ( ! empty( $avatar_setting ) ) {
|
400 |
-
// Allow avatar uploads
|
401 |
-
add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', $avatar_setting );
|
402 |
-
register_setting ( 'buddypress', 'bp-disable-avatar-uploads', 'intval' );
|
403 |
-
}
|
404 |
Â
}
|
405 |
Â
|
406 |
Â
/**
|
@@ -472,6 +466,14 @@ class BP_Admin {
|
|
472 |
Â
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
473 |
Â
|
474 |
Â
$file = $this->css_url . "common{$min}.css";
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
475 |
Â
$file = apply_filters( 'bp_core_admin_common_css', $file );
|
476 |
Â
wp_enqueue_style( 'bp-admin-common-css', $file, array(), bp_get_version() );
|
477 |
Â
|
@@ -504,7 +506,7 @@ class BP_Admin {
|
|
504 |
Â
<h3 style="margin:0"><?php _e( 'Getting Started with BuddyPress', 'buddypress' ); ?></h3>
|
505 |
Â
<div class="welcome-panel-column-container">
|
506 |
Â
<div class="welcome-panel-column">
|
507 |
-
<h4><?php _e( 'Configure
|
508 |
Â
<ul>
|
509 |
Â
<li><?php printf(
|
510 |
Â
'<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 ) ) )
|
@@ -537,88 +539,84 @@ class BP_Admin {
|
|
537 |
Â
</div>
|
538 |
Â
<div class="welcome-panel-column welcome-panel-last">
|
539 |
Â
<h4><?php _e( 'Community and Support', 'buddypress' ); ?></h4>
|
540 |
-
<p class="welcome-icon welcome-learn-more" style="margin-right:10px"><?php _e( 'Looking for help? The <a href="
|
541 |
-
<p class="welcome-icon welcome-learn-more" style="margin-right:10px"><?php _e( 'Can’t find what you need? Stop by <a href="
|
542 |
Â
</div>
|
543 |
Â
</div>
|
544 |
Â
</div>
|
545 |
Â
</div>
|
546 |
Â
|
547 |
-
<hr />
|
548 |
-
|
549 |
Â
<?php endif; ?>
|
550 |
Â
|
551 |
-
<div class="
|
552 |
-
<
|
Â
|
|
553 |
Â
<div class="featured-image">
|
554 |
-
<img src="<?php echo esc_url( buddypress()->plugin_url . 'bp-core/admin/images/
|
555 |
Â
</div>
|
556 |
Â
|
557 |
Â
<div class="feature-section">
|
558 |
-
<h3><?php esc_html_e( '
|
559 |
-
<p><?php esc_html_e( '
|
560 |
-
<p><?php esc_html_e( 'This amazing new feature is available to plugin developers starting with BuddyPress 2.2', 'buddypress' ); ?></p>
|
561 |
-
<p><a href="https://codex.buddypress.org/developer/member-types/"><?php esc_html_e( 'Learn more →', 'buddypress' ); ?></a></p>
|
562 |
Â
</div>
|
563 |
Â
|
564 |
Â
<div class="clear"></div>
|
565 |
Â
</div>
|
566 |
Â
|
567 |
-
<
|
568 |
-
|
569 |
-
<div class="changelog feature-list finer-points">
|
570 |
Â
<h2><?php esc_html_e( 'The Finer Points', 'buddypress' ); ?></h2>
|
571 |
Â
|
572 |
Â
<div class="feature-section col two-col">
|
573 |
Â
<div>
|
574 |
-
<span class=" dashicons dashicons-admin-
|
575 |
-
<h4><?php esc_html_e( '
|
576 |
-
<p><?php esc_html_e( '
|
577 |
Â
</div>
|
578 |
Â
|
579 |
Â
<div class="template-pack last-feature">
|
580 |
Â
<span class=" dashicons dashicons-admin-appearance"></span>
|
581 |
-
<h4><?php esc_html_e( '
|
582 |
-
<p><?php esc_html_e( '
|
583 |
Â
</div>
|
584 |
Â
|
585 |
Â
<div class="group-invites">
|
586 |
-
<span class=" dashicons dashicons-
|
587 |
-
<h4><?php esc_html_e( '
|
588 |
-
<p><?php esc_html_e( '
|
589 |
Â
</div>
|
590 |
Â
|
591 |
Â
<div class="last-feature">
|
592 |
-
<span class=" dashicons dashicons-
|
593 |
-
<h4><?php esc_html_e( '
|
594 |
-
<p><?php esc_html_e( '
|
595 |
Â
</div>
|
596 |
Â
</div>
|
597 |
Â
</div>
|
598 |
Â
|
599 |
-
<
|
600 |
-
|
601 |
-
<div class="changelog feature-list">
|
602 |
Â
<h2><?php esc_html_e( 'Under the Hood', 'buddypress' ); ?></h2>
|
603 |
Â
|
604 |
Â
<div class="feature-section col two-col">
|
605 |
Â
<div>
|
606 |
-
<h4><?php esc_html_e( '
|
607 |
-
<p><?php
|
608 |
Â
|
609 |
Â
<h4><?php esc_html_e( 'Cache Improvements', 'buddypress' ); ?></h4>
|
610 |
-
<p><?php esc_html_e( '
|
611 |
Â
</div>
|
612 |
Â
<div class="last-feature">
|
613 |
Â
<h4><?php esc_html_e( 'Developer Reference', 'buddypress' ); ?></h4>
|
614 |
Â
<p><?php esc_html_e( 'Continued improvements to inline code documentation make it easier for developers to understand how BuddyPress works.', 'buddypress' ); ?></p>
|
615 |
Â
|
616 |
-
<h4><?php esc_html_e( '
|
617 |
-
<p><?php esc_html_e( '
|
618 |
Â
</div>
|
619 |
Â
</div>
|
620 |
Â
</div>
|
621 |
Â
|
Â
|
|
Â
|
|
Â
|
|
622 |
Â
<?php
|
623 |
Â
}
|
624 |
Â
|
@@ -644,18 +642,18 @@ class BP_Admin {
|
|
644 |
Â
<h4 class="wp-people-group"><?php _e( 'Project Leaders', 'buddypress' ); ?></h4>
|
645 |
Â
<ul class="wp-people-group " id="wp-people-group-project-leaders">
|
646 |
Â
<li class="wp-person" id="wp-person-johnjamesjacoby">
|
647 |
-
<a href="
|
648 |
-
<a class="web" href="
|
649 |
Â
<span class="title"><?php _e( 'Project Lead', 'buddypress' ); ?></span>
|
650 |
Â
</li>
|
651 |
Â
<li class="wp-person" id="wp-person-boonebgorges">
|
652 |
-
<a href="
|
653 |
-
<a class="web" href="
|
654 |
Â
<span class="title"><?php _e( 'Lead Developer', 'buddypress' ); ?></span>
|
655 |
Â
</li>
|
656 |
Â
<li class="wp-person" id="wp-person-djpaul">
|
657 |
-
<a href="
|
658 |
-
<a class="web" href="
|
659 |
Â
<span class="title"><?php _e( 'Lead Developer', 'buddypress' ); ?></span>
|
660 |
Â
</li>
|
661 |
Â
</ul>
|
@@ -663,28 +661,33 @@ class BP_Admin {
|
|
663 |
Â
<h4 class="wp-people-group"><?php _e( 'Core Team', 'buddypress' ); ?></h4>
|
664 |
Â
<ul class="wp-people-group " id="wp-people-group-core-team">
|
665 |
Â
<li class="wp-person" id="wp-person-r-a-y">
|
666 |
-
<a href="
|
667 |
-
<a class="web" href="
|
668 |
Â
<span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
|
669 |
Â
</li>
|
670 |
Â
<li class="wp-person" id="wp-person-imath">
|
671 |
-
<a href="
|
672 |
-
<a class="web" href="
|
673 |
Â
<span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
|
674 |
Â
</li>
|
675 |
Â
<li class="wp-person" id="wp-person-mercime">
|
676 |
-
<a href="
|
677 |
-
<a class="web" href="
|
678 |
Â
<span class="title"><?php _e( 'Navigator', 'buddypress' ); ?></span>
|
679 |
Â
</li>
|
680 |
Â
<li class="wp-person" id="wp-person-dcavins">
|
681 |
-
<a href="
|
682 |
-
<a class="web" href="
|
683 |
Â
<span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
|
684 |
Â
</li>
|
685 |
Â
<li class="wp-person" id="wp-person-tw2113">
|
686 |
-
<a href="
|
687 |
-
<a class="web" href="
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
688 |
Â
<span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
|
689 |
Â
</li>
|
690 |
Â
</ul>
|
@@ -692,74 +695,70 @@ class BP_Admin {
|
|
692 |
Â
<h4 class="wp-people-group"><?php _e( 'Recent Rockstars', 'buddypress' ); ?></h4>
|
693 |
Â
<ul class="wp-people-group " id="wp-people-group-rockstars">
|
694 |
Â
<li class="wp-person" id="wp-person-henry-wright">
|
695 |
-
<a href="
|
696 |
-
<a class="web" href="
|
697 |
Â
</li>
|
698 |
Â
<li class="wp-person" id="wp-person-danbp">
|
699 |
-
<a href="
|
700 |
-
<a class="web" href="
|
701 |
Â
</li>
|
702 |
Â
<li class="wp-person" id="wp-person-shanebp">
|
703 |
-
<a href="
|
704 |
-
<a class="web" href="
|
705 |
Â
</li>
|
706 |
Â
<li class="wp-person" id="wp-person-netweb">
|
707 |
-
<a href="
|
708 |
-
<a class="web" href="
|
709 |
Â
</li>
|
710 |
-
<li class="wp-person" id="wp-person-
|
711 |
-
<a href="
|
712 |
-
<a class="web" href="
|
713 |
Â
</li>
|
Â
|
|
714 |
Â
</ul>
|
715 |
Â
|
716 |
Â
<h4 class="wp-people-group"><?php printf( esc_html__( 'Contributors to BuddyPress %s', 'buddypress' ), self::display_version() ); ?></h4>
|
717 |
Â
<p class="wp-credits-list">
|
718 |
-
<a href="https://profiles.wordpress.org/
|
719 |
-
<a href="https://profiles.wordpress.org/dontdream/">Andrea Tarantini (dontdream)</a>,
|
720 |
Â
<a href="https://profiles.wordpress.org/boonebgorges/">Boone B Gorges (boonebgorges)</a>,
|
721 |
-
<a href="https://profiles.wordpress.org/
|
722 |
-
<a href="https://profiles.wordpress.org/
|
723 |
-
<a href="https://profiles.wordpress.org/colabsadmin/">colabsadmin</a>,
|
724 |
-
<a href="https://profiles.wordpress.org/colorful-tones/">Damon Cook (colorful tones)</a>,
|
725 |
-
<a href="https://profiles.wordpress.org/danbp/">danbp</a>,
|
726 |
Â
<a href="https://profiles.wordpress.org/dcavins/">David Cavins (dcavins)</a>,
|
727 |
-
<a href="https://profiles.wordpress.org/
|
Â
|
|
Â
|
|
Â
|
|
728 |
Â
<a href="https://profiles.wordpress.org/Mamaduka/">George Mamadashvili (Mamaduka)</a>,
|
729 |
Â
<a href="https://profiles.wordpress.org/gregrickaby/">Greg Rickaby (gregrickaby)</a>,
|
Â
|
|
730 |
Â
<a href="https://profiles.wordpress.org/hnla/">Hugo (hnla)</a>,
|
731 |
-
<a href="https://profiles.wordpress.org/
|
732 |
-
<a href="https://profiles.wordpress.org/ev3rywh3re/">Jess Planck (ev3rywh3re)</a>,
|
733 |
Â
<a href="https://profiles.wordpress.org/johnjamesjacoby/">John James Jacoby (johnjamesjacoby)</a>,
|
734 |
-
<a href="https://profiles.wordpress.org/joshshashaty/">Josh (joshshashaty)</a>,
|
735 |
Â
<a href="https://profiles.wordpress.org/jreeve/">jreeve</a>,
|
736 |
-
<a href="https://profiles.wordpress.org/
|
Â
|
|
737 |
Â
<a href="https://profiles.wordpress.org/Offereins">Laurens Offereins (Offereins)</a>
|
738 |
Â
<a href="https://profiles.wordpress.org/lenasterg/">lenasterg</a>,
|
739 |
-
<a href="https://profiles.wordpress.org/
|
Â
|
|
740 |
Â
<a href="https://profiles.wordpress.org/imath/">Mathieu Viet (imath)</a>,
|
Â
|
|
741 |
Â
<a href="https://profiles.wordpress.org/mercime/">mercime</a>,
|
742 |
Â
<a href="https://profiles.wordpress.org/tw2113/">Michael Beckwith (tw2113)</a>,
|
743 |
-
<a href="https://profiles.wordpress.org/
|
744 |
-
<a href="https://profiles.wordpress.org/sooskriszta/">OC2PS (sooskriszta)</a>,
|
745 |
Â
<a href="https://profiles.wordpress.org/DJPaul/">Paul Gibbs (DJPaul)</a>,
|
746 |
-
<a href="https://profiles.wordpress.org/
|
747 |
-
<a href="https://profiles.wordpress.org/psycleuk/">psycleuk</a>,
|
748 |
Â
<a href="https://profiles.wordpress.org/r-a-y/">r-a-y</a>,
|
749 |
-
<a href="https://profiles.wordpress.org/
|
750 |
-
<a href="https://profiles.wordpress.org/
|
751 |
-
<a href="https://profiles.wordpress.org/
|
752 |
-
<a href="https://profiles.wordpress.org/
|
753 |
-
<a href="https://profiles.wordpress.org/
|
754 |
Â
<a href="https://profiles.wordpress.org/netweb/">Stephen Edgar (netweb)</a>,
|
755 |
Â
<a href="https://profiles.wordpress.org/svenl77/">svenl77</a>,
|
756 |
-
<a href="https://profiles.wordpress.org/
|
757 |
-
<a href="https://profiles.wordpress.org/
|
758 |
-
<a href="https://profiles.wordpress.org/
|
759 |
-
<a href="https://profiles.wordpress.org/tometzky/">Tomasz Ostrowski (tometzky)</a>,
|
760 |
-
<a href="https://profiles.wordpress.org/unsalkorkmaz/">Unsal Korkmaz (unsalkorkmaz)</a>,
|
761 |
-
<a href="https://profiles.wordpress.org/vimes1984/">vimes1984</a>,
|
762 |
-
<a href="https://profiles.wordpress.org/wonderboymusic/">Scott Taylor (wonderboymusic)</a>.
|
763 |
Â
</p>
|
764 |
Â
|
765 |
Â
<h4 class="wp-people-group"><?php _e( 'External Libraries', 'buddypress' ); ?></h4>
|
16 |
Â
*
|
17 |
Â
* @package BuddyPress
|
18 |
Â
* @subpackage CoreAdministration
|
19 |
+
* @todo Break this apart into each applicable Component
|
20 |
Â
*
|
21 |
Â
* @since BuddyPress (1.6.0)
|
22 |
Â
*/
|
117 |
Â
* @access private
|
118 |
Â
*/
|
119 |
Â
private function includes() {
|
120 |
+
require( $this->admin_dir . 'bp-core-admin-actions.php' );
|
121 |
+
require( $this->admin_dir . 'bp-core-admin-settings.php' );
|
122 |
+
require( $this->admin_dir . 'bp-core-admin-functions.php' );
|
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 |
Â
/**
|
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' );
|
163 |
Â
add_action( 'bp_network_tool_box', 'bp_core_admin_available_tools_intro' );
|
164 |
Â
|
165 |
Â
// On non-multisite, catch
|
179 |
Â
/**
|
180 |
Â
* Add the navigational menu elements.
|
181 |
Â
*
|
182 |
+
* @since BuddyPress (1.6.0)
|
183 |
Â
*
|
184 |
Â
* @uses add_management_page() To add the Recount page in Tools section.
|
185 |
Â
* @uses add_options_page() To add the Forums settings page in Settings
|
315 |
Â
/** Main Section ******************************************************/
|
316 |
Â
|
317 |
Â
// Add the main section
|
318 |
+
add_settings_section( 'bp_main', __( 'Main Settings', 'buddypress' ), 'bp_admin_setting_callback_main_section', 'buddypress' );
|
319 |
Â
|
320 |
Â
// Hide toolbar for logged out users setting
|
321 |
+
add_settings_field( 'hide-loggedout-adminbar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_admin_bar', 'buddypress', 'bp_main' );
|
322 |
+
register_setting( 'buddypress', 'hide-loggedout-adminbar', 'intval' );
|
323 |
Â
|
324 |
Â
// Only show 'switch to Toolbar' option if the user chose to retain the BuddyBar during the 1.6 upgrade
|
325 |
Â
if ( (bool) bp_get_option( '_bp_force_buddybar', false ) ) {
|
329 |
Â
|
330 |
Â
// Allow account deletion
|
331 |
Â
add_settings_field( 'bp-disable-account-deletion', __( 'Account Deletion', 'buddypress' ), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main' );
|
332 |
+
register_setting( 'buddypress', 'bp-disable-account-deletion', 'intval' );
|
333 |
Â
|
334 |
Â
/** XProfile Section **************************************************/
|
335 |
Â
|
338 |
Â
// Add the main section
|
339 |
Â
add_settings_section( 'bp_xprofile', _x( 'Profile Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress' );
|
340 |
Â
|
341 |
+
add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', 'bp_xprofile' );
|
342 |
+
register_setting( 'buddypress', 'bp-disable-avatar-uploads', 'intval' );
|
343 |
Â
|
344 |
Â
// Profile sync setting
|
345 |
+
add_settings_field( 'bp-disable-profile-sync', __( 'Profile Syncing', 'buddypress' ), 'bp_admin_setting_callback_profile_sync', 'buddypress', 'bp_xprofile' );
|
346 |
+
register_setting ( 'buddypress', 'bp-disable-profile-sync', 'intval' );
|
347 |
Â
}
|
348 |
Â
|
349 |
Â
/** Groups Section ****************************************************/
|
351 |
Â
if ( bp_is_active( 'groups' ) ) {
|
352 |
Â
|
353 |
Â
// Add the main section
|
354 |
+
add_settings_section( 'bp_groups', __( 'Groups Settings', 'buddypress' ), 'bp_admin_setting_callback_groups_section', 'buddypress' );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
355 |
Â
|
356 |
Â
// Allow subscriptions setting
|
357 |
+
add_settings_field( 'bp_restrict_group_creation', __( 'Group Creation', 'buddypress' ), 'bp_admin_setting_callback_group_creation', 'buddypress', 'bp_groups' );
|
358 |
+
register_setting( 'buddypress', 'bp_restrict_group_creation', 'intval' );
|
359 |
+
|
360 |
+
// Allow group avatars.
|
361 |
+
add_settings_field( 'bp-disable-group-avatar-uploads', __( 'Group Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_group_avatar_uploads', 'buddypress', 'bp_groups' );
|
362 |
+
register_setting( 'buddypress', 'bp-disable-group-avatar-uploads', 'intval' );
|
363 |
Â
}
|
364 |
Â
|
365 |
Â
/** Forums ************************************************************/
|
367 |
Â
if ( bp_is_active( 'forums' ) ) {
|
368 |
Â
|
369 |
Â
// Add the main section
|
370 |
+
add_settings_section( 'bp_forums', __( 'Legacy Group Forums', 'buddypress' ), 'bp_admin_setting_callback_bbpress_section', 'buddypress' );
|
371 |
Â
|
372 |
Â
// Allow subscriptions setting
|
373 |
Â
add_settings_field( 'bb-config-location', __( 'bbPress Configuration', 'buddypress' ), 'bp_admin_setting_callback_bbpress_configuration', 'buddypress', 'bp_forums' );
|
374 |
+
register_setting( 'buddypress', 'bb-config-location', '' );
|
375 |
Â
}
|
376 |
Â
|
377 |
Â
/** Activity Section **************************************************/
|
379 |
Â
if ( bp_is_active( 'activity' ) ) {
|
380 |
Â
|
381 |
Â
// Add the main section
|
382 |
+
add_settings_section( 'bp_activity', __( 'Activity Settings', 'buddypress' ), 'bp_admin_setting_callback_activity_section', 'buddypress' );
|
383 |
Â
|
384 |
Â
// Activity commenting on blog and forum posts
|
385 |
Â
add_settings_field( 'bp-disable-blogforum-comments', __( 'Blog & Forum Comments', 'buddypress' ), 'bp_admin_setting_callback_blogforum_comments', 'buddypress', 'bp_activity' );
|
391 |
Â
|
392 |
Â
// Allow activity akismet
|
393 |
Â
if ( is_plugin_active( 'akismet/akismet.php' ) && defined( 'AKISMET_VERSION' ) ) {
|
394 |
+
add_settings_field( '_bp_enable_akismet', __( 'Akismet', 'buddypress' ), 'bp_admin_setting_callback_activity_akismet', 'buddypress', 'bp_activity' );
|
395 |
+
register_setting( 'buddypress', '_bp_enable_akismet', 'intval' );
|
396 |
Â
}
|
397 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
398 |
Â
}
|
399 |
Â
|
400 |
Â
/**
|
466 |
Â
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
467 |
Â
|
468 |
Â
$file = $this->css_url . "common{$min}.css";
|
469 |
+
|
470 |
+
/**
|
471 |
+
* Filters the BuddyPress Core Admin CSS file path.
|
472 |
+
*
|
473 |
+
* @since BuddyPress (1.6.0)
|
474 |
+
*
|
475 |
+
* @param string $file File path for the admin CSS.
|
476 |
+
*/
|
477 |
Â
$file = apply_filters( 'bp_core_admin_common_css', $file );
|
478 |
Â
wp_enqueue_style( 'bp-admin-common-css', $file, array(), bp_get_version() );
|
479 |
Â
|
506 |
Â
<h3 style="margin:0"><?php _e( 'Getting Started with BuddyPress', 'buddypress' ); ?></h3>
|
507 |
Â
<div class="welcome-panel-column-container">
|
508 |
Â
<div class="welcome-panel-column">
|
509 |
+
<h4><?php _e( 'Configure BuddyPress', 'buddypress' ); ?></h4>
|
510 |
Â
<ul>
|
511 |
Â
<li><?php printf(
|
512 |
Â
'<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 ) ) )
|
539 |
Â
</div>
|
540 |
Â
<div class="welcome-panel-column welcome-panel-last">
|
541 |
Â
<h4><?php _e( 'Community and Support', 'buddypress' ); ?></h4>
|
542 |
+
<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>
|
543 |
+
<p class="welcome-icon welcome-learn-more" style="margin-right:10px"><?php _e( 'Can’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>
|
544 |
Â
</div>
|
545 |
Â
</div>
|
546 |
Â
</div>
|
547 |
Â
</div>
|
548 |
Â
|
Â
|
|
Â
|
|
549 |
Â
<?php endif; ?>
|
550 |
Â
|
551 |
+
<div class="headline-feature">
|
552 |
+
<h3><?php esc_html_e( 'Upload Profile Pictures with Drag and Drop', 'buddypress' ); ?></h3>
|
553 |
+
|
554 |
Â
<div class="featured-image">
|
555 |
+
<img src="<?php echo esc_url( buddypress()->plugin_url . 'bp-core/admin/images/avatar-ui.gif' ); ?>" alt="<?php esc_attr_e( 'Revamped Profile Picture Upload UI', 'buddypress' ); ?>">
|
556 |
Â
</div>
|
557 |
Â
|
558 |
Â
<div class="feature-section">
|
559 |
+
<h3><?php esc_html_e( 'Built with the Attachments API, the new foundation for BuddyPress media management.', 'buddypress' ); ?></h3>
|
560 |
+
<p><?php esc_html_e( 'You can drag and drop any image you choose to upload as your profile photo. The interface is mobile-ready and now includes integration with phone and laptop cameras. This is an example of what can be developed using the new Attachments API, the long-awaited foundation for media-related BuddyPress components and features.', 'buddypress' ); ?> <a href="https://codex.buddypress.org/plugindev/bp_attachment/"><?php esc_html_e( 'Learn more →', 'buddypress' ); ?></a></p>
|
Â
|
|
Â
|
|
561 |
Â
</div>
|
562 |
Â
|
563 |
Â
<div class="clear"></div>
|
564 |
Â
</div>
|
565 |
Â
|
566 |
+
<div class="feature-list finer-points">
|
Â
|
|
Â
|
|
567 |
Â
<h2><?php esc_html_e( 'The Finer Points', 'buddypress' ); ?></h2>
|
568 |
Â
|
569 |
Â
<div class="feature-section col two-col">
|
570 |
Â
<div>
|
571 |
+
<span class=" dashicons dashicons-admin-users"></span>
|
572 |
+
<h4><?php esc_html_e( 'Member Type Directories', 'buddypress' ); ?></h4>
|
573 |
+
<p><?php esc_html_e( 'Create directories of member types in your site using the Member Type API.', 'buddypress' ); ?></p>
|
574 |
Â
</div>
|
575 |
Â
|
576 |
Â
<div class="template-pack last-feature">
|
577 |
Â
<span class=" dashicons dashicons-admin-appearance"></span>
|
578 |
+
<h4><?php esc_html_e( 'Companion Stylesheets For Themes', 'buddypress' ); ?></h4>
|
579 |
+
<p><?php esc_html_e( 'Improved styling and integration of BuddyPress components with bundled WordPress themes, Twenty Fifteen and Twenty Fourteen.', 'buddypress' ); ?></p>
|
580 |
Â
</div>
|
581 |
Â
|
582 |
Â
<div class="group-invites">
|
583 |
+
<span class=" dashicons dashicons-admin-post"></span>
|
584 |
+
<h4><?php esc_html_e( 'Blog Post Activity', 'buddypress' ); ?></h4>
|
585 |
+
<p><?php esc_html_e( 'BuddyPress now generates better excerpts in the activity streams for posts containing images or other embedded media content.', 'buddypress' ); ?></p>
|
586 |
Â
</div>
|
587 |
Â
|
588 |
Â
<div class="last-feature">
|
589 |
+
<span class=" dashicons dashicons-star-filled"></span>
|
590 |
+
<h4><?php esc_html_e( 'Star Private Messages ', 'buddypress' ); ?></h4>
|
591 |
+
<p><?php esc_html_e( 'Mark important messages in your inbox from your friends with a star.', 'buddypress' ); ?></p>
|
592 |
Â
</div>
|
593 |
Â
</div>
|
594 |
Â
</div>
|
595 |
Â
|
596 |
+
<div class="feature-list">
|
Â
|
|
Â
|
|
597 |
Â
<h2><?php esc_html_e( 'Under the Hood', 'buddypress' ); ?></h2>
|
598 |
Â
|
599 |
Â
<div class="feature-section col two-col">
|
600 |
Â
<div>
|
601 |
+
<h4><?php esc_html_e( 'Components can register new features', 'buddypress' ); ?></h4>
|
602 |
+
<p><?php _e( 'Plugin developers can register new features or check if a component feature is registered using the <code>BP_Component</code> class.', 'buddypress' ); ?></p>
|
603 |
Â
|
604 |
Â
<h4><?php esc_html_e( 'Cache Improvements', 'buddypress' ); ?></h4>
|
605 |
+
<p><?php esc_html_e( 'Improved caching for the following components: Messages, Profiles, Members & Member Types, and Friends.', 'buddypress' ); ?></p>
|
606 |
Â
</div>
|
607 |
Â
<div class="last-feature">
|
608 |
Â
<h4><?php esc_html_e( 'Developer Reference', 'buddypress' ); ?></h4>
|
609 |
Â
<p><?php esc_html_e( 'Continued improvements to inline code documentation make it easier for developers to understand how BuddyPress works.', 'buddypress' ); ?></p>
|
610 |
Â
|
611 |
+
<h4><?php esc_html_e( 'User Documentation', 'buddypress' ); ?></h4>
|
612 |
+
<p><?php esc_html_e( 'The BuddyPress Codex is maintained and updated regularly with new articles and tutorials.', 'buddypress' ); ?></p>
|
613 |
Â
</div>
|
614 |
Â
</div>
|
615 |
Â
</div>
|
616 |
Â
|
617 |
+
<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> • <a href="https://buddypress.org/suppport/"><?php _ex( 'Support', 'About screen, link to support site', 'buddypress' ); ?></a> • <a href="https://codex.buddypress.org/"><?php _ex( 'Documentation', 'About screen, link to documentation', 'buddypress' ); ?></a> • <a href="https://bpdevel.wordpress.com/"><?php _ex( 'Development Blog', 'About screen, link to development blog', 'buddypress' ); ?></a></p>
|
618 |
+
<p><?php _ex( 'Twitter:', 'official Twitter accounts:', 'buddypress' ); ?> <a href="https://twitter.com/buddypress/"><?php _ex( 'BuddyPress', '@buddypress twitter account name', 'buddypress' ); ?></a> • <a href="https://twitter.com/bptrac/"><?php _ex( 'Trac', '@bptrac twitter account name', 'buddypress' ); ?></a> • <a href="https://twitter.com/buddypressdev/"><?php _ex( 'Development', '@buddypressdev twitter account name', 'buddypress' ); ?></a></p>
|
619 |
+
|
620 |
Â
<?php
|
621 |
Â
}
|
622 |
Â
|
642 |
Â
<h4 class="wp-people-group"><?php _e( 'Project Leaders', 'buddypress' ); ?></h4>
|
643 |
Â
<ul class="wp-people-group " id="wp-people-group-project-leaders">
|
644 |
Â
<li class="wp-person" id="wp-person-johnjamesjacoby">
|
645 |
+
<a href="https://profiles.wordpress.org/johnjamesjacoby"><img src="//www.gravatar.com/avatar/81ec16063d89b162d55efe72165c105f?s=60" class="gravatar" alt="John James Jacoby" /></a>
|
646 |
+
<a class="web" href="https://profiles.wordpress.org/johnjamesjacoby">John James Jacoby</a>
|
647 |
Â
<span class="title"><?php _e( 'Project Lead', 'buddypress' ); ?></span>
|
648 |
Â
</li>
|
649 |
Â
<li class="wp-person" id="wp-person-boonebgorges">
|
650 |
+
<a href="https://profiles.wordpress.org/boonebgorges"><img src="//www.gravatar.com/avatar/9cf7c4541a582729a5fc7ae484786c0c?s=60" class="gravatar" alt="Boone B. Gorges" /></a>
|
651 |
+
<a class="web" href="https://profiles.wordpress.org/boonebgorges">Boone B. Gorges</a>
|
652 |
Â
<span class="title"><?php _e( 'Lead Developer', 'buddypress' ); ?></span>
|
653 |
Â
</li>
|
654 |
Â
<li class="wp-person" id="wp-person-djpaul">
|
655 |
+
<a href="https://profiles.wordpress.org/djpaul"><img src="//www.gravatar.com/avatar/3bc9ab796299d67ce83dceb9554f75df?s=60" class="gravatar" alt="Paul Gibbs" /></a>
|
656 |
+
<a class="web" href="https://profiles.wordpress.org/djpaul">Paul Gibbs</a>
|
657 |
Â
<span class="title"><?php _e( 'Lead Developer', 'buddypress' ); ?></span>
|
658 |
Â
</li>
|
659 |
Â
</ul>
|
661 |
Â
<h4 class="wp-people-group"><?php _e( 'Core Team', 'buddypress' ); ?></h4>
|
662 |
Â
<ul class="wp-people-group " id="wp-people-group-core-team">
|
663 |
Â
<li class="wp-person" id="wp-person-r-a-y">
|
664 |
+
<a href="https://profiles.wordpress.org/r-a-y"><img src="//www.gravatar.com/avatar/3bfa556a62b5bfac1012b6ba5f42ebfa?s=60" class="gravatar" alt="Ray" /></a>
|
665 |
+
<a class="web" href="https://profiles.wordpress.org/r-a-y">Ray</a>
|
666 |
Â
<span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
|
667 |
Â
</li>
|
668 |
Â
<li class="wp-person" id="wp-person-imath">
|
669 |
+
<a href="https://profiles.wordpress.org/imath"><img src="//www.gravatar.com/avatar/8b208ca408dad63888253ee1800d6a03?s=60" class="gravatar" alt="Mathieu Viet" /></a>
|
670 |
+
<a class="web" href="https://profiles.wordpress.org/imath">Mathieu Viet</a>
|
671 |
Â
<span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
|
672 |
Â
</li>
|
673 |
Â
<li class="wp-person" id="wp-person-mercime">
|
674 |
+
<a href="https://profiles.wordpress.org/mercime"><img src="//www.gravatar.com/avatar/fae451be6708241627983570a1a1817a?s=60" class="gravatar" alt="Mercime" /></a>
|
675 |
+
<a class="web" href="https://profiles.wordpress.org/mercime">Mercime</a>
|
676 |
Â
<span class="title"><?php _e( 'Navigator', 'buddypress' ); ?></span>
|
677 |
Â
</li>
|
678 |
Â
<li class="wp-person" id="wp-person-dcavins">
|
679 |
+
<a href="https://profiles.wordpress.org/dcavins"><img src="//www.gravatar.com/avatar/a5fa7e83d59cb45ebb616235a176595a?s=60" class="gravatar" alt="David Cavins" /></a>
|
680 |
+
<a class="web" href="https://profiles.wordpress.org/dcavins">David Cavins</a>
|
681 |
Â
<span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
|
682 |
Â
</li>
|
683 |
Â
<li class="wp-person" id="wp-person-tw2113">
|
684 |
+
<a href="https://profiles.wordpress.org/tw2113"><img src="//www.gravatar.com/avatar/a5d7c934621fa1c025b83ee79bc62366?s=60" class="gravatar" alt="Michael Beckwith" /></a>
|
685 |
+
<a class="web" href="https://profiles.wordpress.org/tw2113">Michael Beckwith</a>
|
686 |
+
<span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
|
687 |
+
</li>
|
688 |
+
<li class="wp-person" id="wp-person-hnla">
|
689 |
+
<a href="https://profiles.wordpress.org/hnla"><img src="//www.gravatar.com/avatar/3860c955aa3f79f13b92826ae47d07fe?s=60" class="gravatar" alt="Hugo Ashmore" /></a>
|
690 |
+
<a class="web" href="https://profiles.wordpress.org/hnla">Hugo</a>
|
691 |
Â
<span class="title"><?php _e( 'Core Developer', 'buddypress' ); ?></span>
|
692 |
Â
</li>
|
693 |
Â
</ul>
|
695 |
Â
<h4 class="wp-people-group"><?php _e( 'Recent Rockstars', 'buddypress' ); ?></h4>
|
696 |
Â
<ul class="wp-people-group " id="wp-people-group-rockstars">
|
697 |
Â
<li class="wp-person" id="wp-person-henry-wright">
|
698 |
+
<a href="https://profiles.wordpress.org/henry.wright"><img src="//www.gravatar.com/avatar/0da2f1a9340d6af196b870f6c107a248?s=60" class="gravatar" alt="Henry Wright" /></a>
|
699 |
+
<a class="web" href="https://profiles.wordpress.org/henry.wright">Henry Wright</a>
|
700 |
Â
</li>
|
701 |
Â
<li class="wp-person" id="wp-person-danbp">
|
702 |
+
<a href="https://profiles.wordpress.org/danbp"><img src="//www.gravatar.com/avatar/0deae2e7003027fbf153500cd3fa5501?s=60" class="gravatar" alt="danbp" /></a>
|
703 |
+
<a class="web" href="https://profiles.wordpress.org/danbp">danbp</a>
|
704 |
Â
</li>
|
705 |
Â
<li class="wp-person" id="wp-person-shanebp">
|
706 |
+
<a href="https://profiles.wordpress.org/shanebp"><img src="//www.gravatar.com/avatar/ffd294ab5833ba14aaf175f9acc71cc4?s=60" class="gravatar" alt="shanebp" /></a>
|
707 |
+
<a class="web" href="https://profiles.wordpress.org/shanebp">shanebp</a>
|
708 |
Â
</li>
|
709 |
Â
<li class="wp-person" id="wp-person-netweb">
|
710 |
+
<a href="https://profiles.wordpress.org/netweb"><img src="//www.gravatar.com/avatar/97e1620b501da675315ba7cfb740e80f?s=60" class="gravatar" alt="Stephen Edgar" /></a>
|
711 |
+
<a class="web" href="https://profiles.wordpress.org/netweb">Stephen Edgar</a>
|
712 |
Â
</li>
|
713 |
+
<li class="wp-person" id="wp-person-dimensionmedia">
|
714 |
+
<a href="https://profiles.wordpress.org/dimensionmedia"><img src="//www.gravatar.com/avatar/7735aada1ec39d0c1118bd92ed4551f1?s=60" class="gravatar" alt="David Bisset" /></a>
|
715 |
+
<a class="web" href="https://profiles.wordpress.org/dimensionmedia">David Bisset</a>
|
716 |
Â
</li>
|
717 |
+
|
718 |
Â
</ul>
|
719 |
Â
|
720 |
Â
<h4 class="wp-people-group"><?php printf( esc_html__( 'Contributors to BuddyPress %s', 'buddypress' ), self::display_version() ); ?></h4>
|
721 |
Â
<p class="wp-credits-list">
|
722 |
+
<a href="https://profiles.wordpress.org/jorbin/">Aaron Jorbin (aaronjorbin)</a>,
|
Â
|
|
723 |
Â
<a href="https://profiles.wordpress.org/boonebgorges/">Boone B Gorges (boonebgorges)</a>,
|
724 |
+
<a href="https://profiles.wordpress.org/sbrajesh/">Brajesh Singh (sbrajesh)</a>,
|
725 |
+
<a href="https://profiles.wordpress.org/CristinaCannon/">CristinaCannon</a>,
|
Â
|
|
Â
|
|
Â
|
|
726 |
Â
<a href="https://profiles.wordpress.org/dcavins/">David Cavins (dcavins)</a>,
|
727 |
+
<a href="https://profiles.wordpress.org/wpdennis/">Dennis (wpdennis)</a>,
|
728 |
+
<a href="https://profiles.wordpress.org/ocean90/">Dominik Schilling (ocean90)</a>,
|
729 |
+
ecehren,
|
730 |
+
<a href="https://profiles.wordpress.org/finzend/">finzend</a>,
|
731 |
Â
<a href="https://profiles.wordpress.org/Mamaduka/">George Mamadashvili (Mamaduka)</a>,
|
732 |
Â
<a href="https://profiles.wordpress.org/gregrickaby/">Greg Rickaby (gregrickaby)</a>,
|
733 |
+
<a href="https://profiles.wordpress.org/henrywright/">Henry Wright (henry.wright)</a>,
|
734 |
Â
<a href="https://profiles.wordpress.org/hnla/">Hugo (hnla)</a>,
|
735 |
+
<a href="https://profiles.wordpress.org/jaimieolmstead/">jaimieolmstead</a>,
|
Â
|
|
736 |
Â
<a href="https://profiles.wordpress.org/johnjamesjacoby/">John James Jacoby (johnjamesjacoby)</a>,
|
Â
|
|
737 |
Â
<a href="https://profiles.wordpress.org/jreeve/">jreeve</a>,
|
738 |
+
<a href="https://profiles.wordpress.org/JustinSainton/">Justin Sainton (JustinSainton)</a>,
|
739 |
+
<a href="https://profiles.wordpress.org/kadamwhite/">K.Adam White (kadamwhite)</a>,
|
740 |
Â
<a href="https://profiles.wordpress.org/Offereins">Laurens Offereins (Offereins)</a>
|
741 |
Â
<a href="https://profiles.wordpress.org/lenasterg/">lenasterg</a>,
|
742 |
+
<a href="https://profiles.wordpress.org/natrio/">Marc (natrio)</a>,
|
743 |
+
<a href="https://profiles.wordpress.org/mechter/">Markus Echterhoff (mechter)</a>,
|
744 |
Â
<a href="https://profiles.wordpress.org/imath/">Mathieu Viet (imath)</a>,
|
745 |
+
<a href="https://profiles.wordpress.org/melhop/">melhop</a>,
|
746 |
Â
<a href="https://profiles.wordpress.org/mercime/">mercime</a>,
|
747 |
Â
<a href="https://profiles.wordpress.org/tw2113/">Michael Beckwith (tw2113)</a>,
|
748 |
+
<a href="https://profiles.wordpress.org/pareshradadiya/">paresh.radadiya (pareshradadiya)</a>,
|
Â
|
|
749 |
Â
<a href="https://profiles.wordpress.org/DJPaul/">Paul Gibbs (DJPaul)</a>,
|
750 |
+
<a href="https://profiles.wordpress.org/prometheus-fire/">Prometheus Fire</a>,
|
Â
|
|
751 |
Â
<a href="https://profiles.wordpress.org/r-a-y/">r-a-y</a>,
|
752 |
+
<a href="https://profiles.wordpress.org/rogercoathup/">Roger Coathup (rogercoathup)</a>,
|
753 |
+
<a href="https://profiles.wordpress.org/dtc7240/">Scott Seitz (dtc7240)</a>,
|
754 |
+
<a href="https://profiles.wordpress.org/wonderboymusic/">Scott Taylor (wonderboymusic)</a>.
|
755 |
+
<a href="https://profiles.wordpress.org/SergeyBiryukov/">Sergey Biryukov (SergeyBiryukov)</a>,
|
756 |
+
<a href="https://profiles.wordpress.org/shanebp/">shanebp</a>,
|
757 |
Â
<a href="https://profiles.wordpress.org/netweb/">Stephen Edgar (netweb)</a>,
|
758 |
Â
<a href="https://profiles.wordpress.org/svenl77/">svenl77</a>,
|
759 |
+
<a href="https://profiles.wordpress.org/WeddyWood/">WeddyWood</a>,
|
760 |
+
<a href="https://profiles.wordpress.org/wolfhoundjesse/">wolfhoundjesse</a>,
|
761 |
+
<a href="https://profiles.wordpress.org/xgz/">xgz</a>.
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
762 |
Â
</p>
|
763 |
Â
|
764 |
Â
<h4 class="wp-people-group"><?php _e( 'External Libraries', 'buddypress' ); ?></h4>
|
bp-core/bp-core-attachments.php
ADDED
@@ -0,0 +1,406 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* BuddyPress Attachments functions.
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
* @subpackage Attachments
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Exit if accessed directly
|
10 |
+
defined( 'ABSPATH' ) || exit;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Check if the current WordPress version is using Plupload 2.1.1
|
14 |
+
*
|
15 |
+
* Plupload 2.1.1 was introduced in WordPress 3.9. Our bp-plupload.js
|
16 |
+
* script requires it. So we need to make sure the current WordPress
|
17 |
+
* match with our needs.
|
18 |
+
*
|
19 |
+
* @since BuddyPress (2.3.0)
|
20 |
+
*
|
21 |
+
* @return bool True if WordPress is 3.9+, false otherwise
|
22 |
+
*/
|
23 |
+
function bp_attachments_is_wp_version_supported() {
|
24 |
+
return (bool) version_compare( bp_get_major_wp_version(), '3.9', '>=' );
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Get the BuddyPress Plupload settings
|
29 |
+
*
|
30 |
+
* @since BuddyPress (2.3.0)
|
31 |
+
*
|
32 |
+
* @return array list of BuddyPress Plupload settings
|
33 |
+
*/
|
34 |
+
function bp_attachments_get_plupload_default_settings() {
|
35 |
+
|
36 |
+
$max_upload_size = wp_max_upload_size();
|
37 |
+
|
38 |
+
if ( ! $max_upload_size ) {
|
39 |
+
$max_upload_size = 0;
|
40 |
+
}
|
41 |
+
|
42 |
+
$defaults = array(
|
43 |
+
'runtimes' => 'html5,flash,silverlight,html4',
|
44 |
+
'file_data_name' => 'file',
|
45 |
+
'multipart_params' => array(
|
46 |
+
'action' => 'bp_upload_attachment',
|
47 |
+
'_wpnonce' => wp_create_nonce( 'bp-uploader' ),
|
48 |
+
),
|
49 |
+
'url' => admin_url( 'admin-ajax.php', 'relative' ),
|
50 |
+
'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
|
51 |
+
'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
|
52 |
+
'filters' => array(
|
53 |
+
'max_file_size' => $max_upload_size . 'b',
|
54 |
+
),
|
55 |
+
'multipart' => true,
|
56 |
+
'urlstream_upload' => true,
|
57 |
+
);
|
58 |
+
|
59 |
+
// WordPress is not allowing multi selection for iOs 7 device.. See #29602.
|
60 |
+
if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false &&
|
61 |
+
strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ) {
|
62 |
+
|
63 |
+
$defaults['multi_selection'] = false;
|
64 |
+
}
|
65 |
+
|
66 |
+
$settings = array(
|
67 |
+
'defaults' => $defaults,
|
68 |
+
'browser' => array(
|
69 |
+
'mobile' => wp_is_mobile(),
|
70 |
+
'supported' => _device_can_upload(),
|
71 |
+
),
|
72 |
+
'limitExceeded' => is_multisite() && ! is_upload_space_available(),
|
73 |
+
);
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Filter the BuddyPress Plupload default settings.
|
77 |
+
*
|
78 |
+
* @since 2.3.0
|
79 |
+
*
|
80 |
+
* @param array $params Default Plupload parameters array.
|
81 |
+
*/
|
82 |
+
return apply_filters( 'bp_attachments_get_plupload_default_settings', $settings );
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Builds localization strings for the BuddyPress Uploader scripts
|
87 |
+
*
|
88 |
+
* @since BuddyPress (2.3.0)
|
89 |
+
*
|
90 |
+
* @return array Plupload default localization strings
|
91 |
+
*/
|
92 |
+
function bp_attachments_get_plupload_l10n() {
|
93 |
+
// Localization strings
|
94 |
+
return apply_filters( 'bp_attachments_get_plupload_l10n', array(
|
95 |
+
'queue_limit_exceeded' => __( 'You have attempted to queue too many files.', 'buddypress' ),
|
96 |
+
'file_exceeds_size_limit' => __( '%s exceeds the maximum upload size for this site.', 'buddypress' ),
|
97 |
+
'zero_byte_file' => __( 'This file is empty. Please try another.', 'buddypress' ),
|
98 |
+
'invalid_filetype' => __( 'This file type is not allowed. Please try another.', 'buddypress' ),
|
99 |
+
'not_an_image' => __( 'This file is not an image. Please try another.', 'buddypress' ),
|
100 |
+
'image_memory_exceeded' => __( 'Memory exceeded. Please try another smaller file.', 'buddypress' ),
|
101 |
+
'image_dimensions_exceeded' => __( 'This is larger than the maximum size. Please try another.', 'buddypress' ),
|
102 |
+
'default_error' => __( 'An error occurred. Please try again later.', 'buddypress' ),
|
103 |
+
'missing_upload_url' => __( 'There was a configuration error. Please contact the server administrator.', 'buddypress' ),
|
104 |
+
'upload_limit_exceeded' => __( 'You may only upload 1 file.', 'buddypress' ),
|
105 |
+
'http_error' => __( 'HTTP error.', 'buddypress' ),
|
106 |
+
'upload_failed' => __( 'Upload failed.', 'buddypress' ),
|
107 |
+
'big_upload_failed' => __( 'Please try uploading this file with the %1$sbrowser uploader%2$s.', 'buddypress' ),
|
108 |
+
'big_upload_queued' => __( '%s exceeds the maximum upload size for the multi-file uploader when used in your browser.', 'buddypress' ),
|
109 |
+
'io_error' => __( 'IO error.', 'buddypress' ),
|
110 |
+
'security_error' => __( 'Security error.', 'buddypress' ),
|
111 |
+
'file_cancelled' => __( 'File canceled.', 'buddypress' ),
|
112 |
+
'upload_stopped' => __( 'Upload stopped.', 'buddypress' ),
|
113 |
+
'dismiss' => __( 'Dismiss', 'buddypress' ),
|
114 |
+
'crunching' => __( 'Crunching…', 'buddypress' ),
|
115 |
+
'unique_file_warning' => __( 'Make sure to upload a unique file', 'buddypress' ),
|
116 |
+
'error_uploading' => __( '“%s” has failed to upload.', 'buddypress' ),
|
117 |
+
'has_avatar_warning' => __( 'If you'd like to delete the existing profile photo but not upload a new one, please use the delete tab.', 'buddypress' )
|
118 |
+
) );
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Enqueues the script needed for the Uploader UI
|
123 |
+
*
|
124 |
+
* @see BP_Attachment::script_data() && BP_Attachment_Avatar::script_data() for examples showing how
|
125 |
+
* to set specific script data
|
126 |
+
*
|
127 |
+
* @since BuddyPress (2.3.0)
|
128 |
+
*
|
129 |
+
* @param string $class name of the class extending BP_Attachment (eg: BP_Attachment_Avatar)
|
130 |
+
*/
|
131 |
+
function bp_attachments_enqueue_scripts( $class = '' ) {
|
132 |
+
// Enqueue me just once per page, please.
|
133 |
+
if ( did_action( 'bp_attachments_enqueue_scripts' ) ) {
|
134 |
+
return;
|
135 |
+
}
|
136 |
+
|
137 |
+
if ( ! $class || ! class_exists( $class ) ) {
|
138 |
+
return new WP_Error( 'missing_parameter' );
|
139 |
+
}
|
140 |
+
|
141 |
+
// Get an instance of the class and get the script data
|
142 |
+
$attachment = new $class;
|
143 |
+
$script_data = $attachment->script_data();
|
144 |
+
|
145 |
+
$args = bp_parse_args( $script_data, array(
|
146 |
+
'action' => '',
|
147 |
+
'file_data_name' => '',
|
148 |
+
'max_file_size' => 0,
|
149 |
+
'browse_button' => 'bp-browse-button',
|
150 |
+
'container' => 'bp-upload-ui',
|
151 |
+
'drop_element' => 'drag-drop-area',
|
152 |
+
'bp_params' => array(),
|
153 |
+
'extra_css' => array(),
|
154 |
+
'extra_js' => array(),
|
155 |
+
'feedback_messages' => array(),
|
156 |
+
), 'attachments_enqueue_scripts' );
|
157 |
+
|
158 |
+
if ( empty( $args['action'] ) || empty( $args['file_data_name'] ) ) {
|
159 |
+
return new WP_Error( 'missing_parameter' );
|
160 |
+
}
|
161 |
+
|
162 |
+
// Get the BuddyPress uploader strings
|
163 |
+
$strings = bp_attachments_get_plupload_l10n();
|
164 |
+
|
165 |
+
// Get the BuddyPress uploader settings
|
166 |
+
$settings = bp_attachments_get_plupload_default_settings();
|
167 |
+
|
168 |
+
// Set feedback messages
|
169 |
+
if ( ! empty( $args['feedback_messages'] ) ) {
|
170 |
+
$strings['feedback_messages'] = $args['feedback_messages'];
|
171 |
+
}
|
172 |
+
|
173 |
+
// Use a temporary var to ease manipulation
|
174 |
+
$defaults = $settings['defaults'];
|
175 |
+
|
176 |
+
// Set the upload action
|
177 |
+
$defaults['multipart_params']['action'] = $args['action'];
|
178 |
+
|
179 |
+
// Set BuddyPress upload parameters if provided
|
180 |
+
if ( ! empty( $args['bp_params'] ) ) {
|
181 |
+
$defaults['multipart_params']['bp_params'] = $args['bp_params'];
|
182 |
+
}
|
183 |
+
|
184 |
+
// Merge other arguments
|
185 |
+
$ui_args = array_intersect_key( $args, array(
|
186 |
+
'file_data_name' => true,
|
187 |
+
'browse_button' => true,
|
188 |
+
'container' => true,
|
189 |
+
'drop_element' => true,
|
190 |
+
) );
|
191 |
+
|
192 |
+
$defaults = array_merge( $defaults, $ui_args );
|
193 |
+
|
194 |
+
if ( ! empty( $args['max_file_size'] ) ) {
|
195 |
+
$defaults['filters']['max_file_size'] = $args['max_file_size'] . 'b';
|
196 |
+
}
|
197 |
+
|
198 |
+
// Specific to BuddyPress Avatars
|
199 |
+
if ( 'bp_avatar_upload' === $defaults['multipart_params']['action'] ) {
|
200 |
+
|
201 |
+
// Include the cropping informations for avatars
|
202 |
+
$settings['crop'] = array(
|
203 |
+
'full_h' => bp_core_avatar_full_height(),
|
204 |
+
'full_w' => bp_core_avatar_full_width(),
|
205 |
+
);
|
206 |
+
|
207 |
+
// Avatar only need 1 file and 1 only!
|
208 |
+
$defaults['multi_selection'] = false;
|
209 |
+
|
210 |
+
// Does the object already has an avatar set
|
211 |
+
$has_avatar = $defaults['multipart_params']['bp_params']['has_avatar'];
|
212 |
+
|
213 |
+
// What is the object the avatar belongs to
|
214 |
+
$object = $defaults['multipart_params']['bp_params']['object'];
|
215 |
+
|
216 |
+
// Init the Avatar nav
|
217 |
+
$avatar_nav = array(
|
218 |
+
'upload' => array( 'id' => 'upload', 'caption' => __( 'Upload', 'buddypress' ), 'order' => 0 ),
|
219 |
+
|
220 |
+
// The delete view will only show if the object has an avatar
|
221 |
+
'delete' => array( 'id' => 'delete', 'caption' => __( 'Delete', 'buddypress' ), 'order' => 100, 'hide' => (int) ! $has_avatar ),
|
222 |
+
);
|
223 |
+
|
224 |
+
// Create the Camera Nav if the WebCam capture feature is enabled
|
225 |
+
if ( bp_avatar_use_webcam() && 'user' === $object ) {
|
226 |
+
$avatar_nav['camera'] = array( 'id' => 'camera', 'caption' => __( 'Take Photo', 'buddypress' ), 'order' => 10 );
|
227 |
+
|
228 |
+
// Set warning messages
|
229 |
+
$strings['camera_warnings'] = array(
|
230 |
+
'requesting' => __( 'Please allow us to access to your camera.', 'buddypress'),
|
231 |
+
'loading' => __( 'Please wait as we access your camera.', 'buddypress' ),
|
232 |
+
'loaded' => __( 'Camera loaded. Click on the "Capture" button to take your photo.', 'buddypress' ),
|
233 |
+
'noaccess' => __( 'It looks like you do not have a webcam or we were unable to get permission to use your webcam. Please upload a photo instead.', 'buddypress' ),
|
234 |
+
'errormsg' => __( 'Your browser is not supported. Please upload a photo instead.', 'buddypress' ),
|
235 |
+
'videoerror' => __( 'Video error. Please upload a photo instead.', 'buddypress' ),
|
236 |
+
'ready' => __( 'Your profile photo is ready. Click on the "Save" button to use this photo.', 'buddypress' ),
|
237 |
+
'nocapture' => __( 'No photo was captured. Click on the "Capture" button to take your photo.', 'buddypress' ),
|
238 |
+
);
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Use this filter to add a navigation to a custom tool to set the object's avatar
|
243 |
+
*
|
244 |
+
* @since BuddyPress (2.3.0)
|
245 |
+
*
|
246 |
+
* @param array $avatar_nav An associative array of available nav items where each item is an array organized this way:
|
247 |
+
* $avatar_nav[ $nav_item_id ] {
|
248 |
+
* @type string $nav_item_id the nav item id in lower case without special characters or space
|
249 |
+
* @type string $caption the name of the item nav that will be displayed in the nav
|
250 |
+
* @type int $order An integer to specify the priority of the item nav, choose one
|
251 |
+
* between 1 and 99 to be after the uploader nav item and before the delete nav item
|
252 |
+
* @type int $hide if set to 1 the item nav will be hidden
|
253 |
+
* (only used for the delete nav item)
|
254 |
+
* }
|
255 |
+
* @param string $object the object the avatar belongs to (eg: user or group)
|
256 |
+
*/
|
257 |
+
$settings['nav'] = bp_sort_by_key( apply_filters( 'bp_attachments_avatar_nav', $avatar_nav, $object ), 'order', 'num' );
|
258 |
+
}
|
259 |
+
|
260 |
+
// Set Plupload settings
|
261 |
+
$settings['defaults'] = $defaults;
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Enqueue some extra styles if required
|
265 |
+
*
|
266 |
+
* Extra styles need to be registered.
|
267 |
+
*/
|
268 |
+
if ( ! empty( $args['extra_css'] ) ) {
|
269 |
+
foreach ( (array) $args['extra_css'] as $css ) {
|
270 |
+
if ( empty( $css ) ) {
|
271 |
+
continue;
|
272 |
+
}
|
273 |
+
|
274 |
+
wp_enqueue_style( $css );
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
wp_enqueue_script ( 'bp-plupload' );
|
279 |
+
wp_localize_script( 'bp-plupload', 'BP_Uploader', array( 'strings' => $strings, 'settings' => $settings ) );
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Enqueue some extra scripts if required
|
283 |
+
*
|
284 |
+
* Extra scripts need to be registered.
|
285 |
+
*/
|
286 |
+
if ( ! empty( $args['extra_js'] ) ) {
|
287 |
+
foreach ( (array) $args['extra_js'] as $js ) {
|
288 |
+
if ( empty( $js ) ) {
|
289 |
+
continue;
|
290 |
+
}
|
291 |
+
|
292 |
+
wp_enqueue_script( $js );
|
293 |
+
}
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Fires at the conclusion of bp_attachments_enqueue_scripts()
|
298 |
+
* to avoid the scripts to be loaded more than once.
|
299 |
+
*
|
300 |
+
* @since BuddyPress 2.3.0
|
301 |
+
*/
|
302 |
+
do_action( 'bp_attachments_enqueue_scripts' );
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Check the current user's capability to edit an avatar for a given object
|
307 |
+
*
|
308 |
+
* @since BuddyPress (2.3.0)
|
309 |
+
*
|
310 |
+
* @param string $capability the capability to check
|
311 |
+
* @param array $args an array containing the item_id and the object to check
|
312 |
+
*/
|
313 |
+
function bp_attachments_current_user_can( $capability, $args = array() ) {
|
314 |
+
$can = false;
|
315 |
+
|
316 |
+
if ( 'edit_avatar' === $capability ) {
|
317 |
+
/**
|
318 |
+
* Needed avatar arguments are set.
|
319 |
+
*/
|
320 |
+
if ( isset( $args['item_id'] ) && isset( $args['object'] ) ) {
|
321 |
+
// Group profile photo
|
322 |
+
if ( bp_is_active( 'groups' ) && 'group' === $args['object'] ) {
|
323 |
+
if ( bp_is_group_create() ) {
|
324 |
+
$can = (bool) groups_is_user_creator( bp_loggedin_user_id(), $args['item_id'] ) || bp_current_user_can( 'bp_moderate' );
|
325 |
+
} else {
|
326 |
+
$can = (bool) groups_is_user_admin( bp_loggedin_user_id(), $args['item_id'] ) || bp_current_user_can( 'bp_moderate' );
|
327 |
+
}
|
328 |
+
// User profile photo
|
329 |
+
} elseif ( bp_is_active( 'xprofile' ) && 'user' === $args['object'] ) {
|
330 |
+
$can = bp_loggedin_user_id() === (int) $args['item_id'] || bp_current_user_can( 'bp_moderate' );
|
331 |
+
}
|
332 |
+
/**
|
333 |
+
* No avatar arguments, fallback to bp_user_can_create_groups()
|
334 |
+
* or bp_is_item_admin()
|
335 |
+
*/
|
336 |
+
} else {
|
337 |
+
if ( bp_is_group_create() ) {
|
338 |
+
$can = bp_user_can_create_groups();
|
339 |
+
} else {
|
340 |
+
$can = bp_is_item_admin();
|
341 |
+
}
|
342 |
+
}
|
343 |
+
}
|
344 |
+
|
345 |
+
return apply_filters( 'bp_attachments_current_user_can', $can, $capability, $args );
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Send a JSON response back to an Ajax upload request.
|
350 |
+
*
|
351 |
+
* @since BuddyPress (2.3.0)
|
352 |
+
*
|
353 |
+
* @param bool true for a success, false otherwise
|
354 |
+
* @param bool true if the Plupload runtime used is html4, false otherwise.
|
355 |
+
* @param mixed $data Data to encode as JSON, then print and die.
|
356 |
+
*/
|
357 |
+
function bp_attachments_json_response( $success, $is_html4 = false, $data = null ) {
|
358 |
+
$response = array( 'success' => $success );
|
359 |
+
|
360 |
+
if ( isset( $data ) ) {
|
361 |
+
$response['data'] = $data;
|
362 |
+
}
|
363 |
+
|
364 |
+
// Send regular json response
|
365 |
+
if ( ! $is_html4 ) {
|
366 |
+
wp_send_json( $response );
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Send specific json response
|
370 |
+
* the html4 Plupload handler requires a text/html content-type for older IE.
|
371 |
+
* See https://core.trac.wordpress.org/ticket/31037
|
372 |
+
*/
|
373 |
+
} else {
|
374 |
+
echo wp_json_encode( $response );
|
375 |
+
|
376 |
+
wp_die();
|
377 |
+
}
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Get an Attachment template part.
|
382 |
+
*
|
383 |
+
* @since BuddyPress (2.3.0)
|
384 |
+
*
|
385 |
+
* @param string Template part slug. eg 'uploader' for 'uploader.php'.
|
386 |
+
*/
|
387 |
+
function bp_attachments_get_template_part( $slug ) {
|
388 |
+
$attachment_template_part = 'assets/_attachments/' . $slug;
|
389 |
+
|
390 |
+
// Load the attachment template in WP Administratin screens
|
391 |
+
if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
|
392 |
+
$attachment_admin_template_part = buddypress()->themes_dir . '/bp-legacy/buddypress/' . $attachment_template_part . '.php';
|
393 |
+
|
394 |
+
// Check the template part exists
|
395 |
+
if ( ! file_exists( $attachment_admin_template_part ) ) {
|
396 |
+
return false;
|
397 |
+
}
|
398 |
+
|
399 |
+
// load the template part
|
400 |
+
require( $attachment_admin_template_part );
|
401 |
+
|
402 |
+
// Load the attachment template in WP_USE_THEMES env.
|
403 |
+
} else {
|
404 |
+
bp_get_template_part( $attachment_template_part );
|
405 |
+
}
|
406 |
+
}
|
bp-core/bp-core-avatars.php
CHANGED
@@ -31,10 +31,11 @@ function bp_core_set_avatar_constants() {
|
|
31 |
Â
|
32 |
Â
if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE' ) ) {
|
33 |
Â
|
34 |
-
|
Â
|
|
35 |
Â
define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', 5120000 ); // 5mb
|
36 |
Â
} else {
|
37 |
-
define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', $
|
38 |
Â
}
|
39 |
Â
}
|
40 |
Â
|
@@ -86,6 +87,11 @@ function bp_core_set_avatar_globals() {
|
|
86 |
Â
if ( ! defined( 'BP_AVATAR_URL' ) )
|
87 |
Â
define( 'BP_AVATAR_URL', $bp->avatar->url );
|
88 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
89 |
Â
do_action( 'bp_core_set_avatar_globals' );
|
90 |
Â
}
|
91 |
Â
add_action( 'bp_setup_globals', 'bp_core_set_avatar_globals' );
|
@@ -225,6 +231,15 @@ function bp_core_fetch_avatar( $args = '' ) {
|
|
225 |
Â
break;
|
226 |
Â
}
|
227 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
228 |
Â
$params['item_id'] = apply_filters( 'bp_core_avatar_item_id', $params['item_id'], $params['object'], $params );
|
229 |
Â
|
230 |
Â
if ( empty( $params['item_id'] ) ) {
|
@@ -257,6 +272,15 @@ function bp_core_fetch_avatar( $args = '' ) {
|
|
257 |
Â
break;
|
258 |
Â
}
|
259 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
260 |
Â
$params['avatar_dir'] = apply_filters( 'bp_core_avatar_dir', $params['avatar_dir'], $params['object'], $params );
|
261 |
Â
|
262 |
Â
if ( empty( $params['avatar_dir'] ) ) {
|
@@ -284,6 +308,16 @@ function bp_core_fetch_avatar( $args = '' ) {
|
|
284 |
Â
break;
|
285 |
Â
}
|
286 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
287 |
Â
$item_name = apply_filters( 'bp_core_avatar_alt', $item_name, $params['item_id'], $params['object'], $params );
|
288 |
Â
$params['alt'] = sprintf( $params['alt'], $item_name );
|
289 |
Â
}
|
@@ -298,6 +332,17 @@ function bp_core_fetch_avatar( $args = '' ) {
|
|
298 |
Â
|
299 |
Â
// Filter image title and create html string
|
300 |
Â
$html_title = '';
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
301 |
Â
$params['title'] = apply_filters( 'bp_core_avatar_title', $params['title'], $params['item_id'], $params['object'], $params );
|
302 |
Â
|
303 |
Â
if ( ! empty( $params['title'] ) ) {
|
@@ -306,6 +351,17 @@ function bp_core_fetch_avatar( $args = '' ) {
|
|
306 |
Â
|
307 |
Â
// Set CSS ID and create html string
|
308 |
Â
$html_css_id = '';
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
309 |
Â
$params['css_id'] = apply_filters( 'bp_core_css_id', $params['css_id'], $params['item_id'], $params['object'], $params );
|
310 |
Â
|
311 |
Â
if ( ! empty( $params['css_id'] ) ) {
|
@@ -332,7 +388,16 @@ function bp_core_fetch_avatar( $args = '' ) {
|
|
332 |
Â
}
|
333 |
Â
$html_height = ' height="' . $params['height'] . '"';
|
334 |
Â
|
335 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
336 |
Â
$params['class'] = apply_filters( 'bp_core_avatar_class', $params['class'], $params['item_id'], $params['object'], $params );
|
337 |
Â
|
338 |
Â
// Use an alias to leave the param unchanged
|
@@ -359,7 +424,29 @@ function bp_core_fetch_avatar( $args = '' ) {
|
|
359 |
Â
$avatar_loc->url = trailingslashit( bp_core_avatar_url() );
|
360 |
Â
|
361 |
Â
$avatar_loc->dir = trailingslashit( $params['avatar_dir'] );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
362 |
Â
$avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', ( $avatar_loc->url . $avatar_loc->dir . $params['item_id'] ), $params['item_id'], $params['object'], $params['avatar_dir'] );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
363 |
Â
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', ( $avatar_loc->path . $avatar_loc->dir . $params['item_id'] ), $params['item_id'], $params['object'], $params['avatar_dir'] );
|
364 |
Â
|
365 |
Â
/**
|
@@ -424,24 +511,63 @@ function bp_core_fetch_avatar( $args = '' ) {
|
|
424 |
Â
|
425 |
Â
// Return it wrapped in an <img> element
|
426 |
Â
if ( true === $params['html'] ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
427 |
Â
return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '"' . $html_class . $html_css_id . $html_width . $html_height . $html_alt . $html_title . ' />', $params, $params['item_id'], $params['avatar_dir'], $html_css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
|
428 |
Â
|
429 |
Â
// ...or only the URL
|
430 |
Â
} else {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
431 |
Â
return apply_filters( 'bp_core_fetch_avatar_url', $avatar_url, $params );
|
432 |
Â
}
|
433 |
Â
}
|
434 |
Â
}
|
435 |
Â
|
436 |
-
|
437 |
-
|
438 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
439 |
Â
if ( ! apply_filters( 'bp_core_fetch_avatar_no_grav', $params['no_grav'], $params ) ) {
|
440 |
Â
|
441 |
Â
// Set gravatar type
|
442 |
Â
if ( empty( $bp->grav_default->{$params['object']} ) ) {
|
443 |
Â
$default_grav = 'wavatar';
|
444 |
Â
} elseif ( 'mystery' == $bp->grav_default->{$params['object']} ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
445 |
Â
$default_grav = apply_filters( 'bp_core_mysteryman_src', 'mm', $params['width'] );
|
446 |
Â
} else {
|
447 |
Â
$default_grav = $bp->grav_default->{$params['object']};
|
@@ -456,14 +582,26 @@ function bp_core_fetch_avatar( $args = '' ) {
|
|
456 |
Â
}
|
457 |
Â
}
|
458 |
Â
|
459 |
-
|
460 |
-
$host = 'http://gravatar.com/avatar/';
|
461 |
-
if ( is_ssl() ) {
|
462 |
-
$host = 'https://secure.gravatar.com/avatar/';
|
463 |
-
}
|
464 |
Â
|
465 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
466 |
Â
$params['email'] = apply_filters( 'bp_core_gravatar_email', $params['email'], $params['item_id'], $params['object'] );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
467 |
Â
$gravatar = apply_filters( 'bp_gravatar_url', $host ) . md5( strtolower( $params['email'] ) ) . '?d=' . $default_grav . '&s=' . $params['width'];
|
468 |
Â
|
469 |
Â
// Gravatar rating; http://bit.ly/89QxZA
|
@@ -474,12 +612,27 @@ function bp_core_fetch_avatar( $args = '' ) {
|
|
474 |
Â
|
475 |
Â
// No avatar was found, and we've been told not to use a gravatar.
|
476 |
Â
} else {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
477 |
Â
$gravatar = apply_filters( 'bp_core_default_avatar_' . $params['object'], bp_core_avatar_default( 'local' ), $params );
|
478 |
Â
}
|
479 |
Â
|
480 |
Â
if ( true === $params['html'] ) {
|
Â
|
|
Â
|
|
481 |
Â
return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $gravatar . '"' . $html_css_id . $html_class . $html_width . $html_height . $html_alt . $html_title . ' />', $params, $params['item_id'], $params['avatar_dir'], $html_css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
|
482 |
Â
} else {
|
Â
|
|
Â
|
|
483 |
Â
return apply_filters( 'bp_core_fetch_avatar_url', $gravatar, $params );
|
484 |
Â
}
|
485 |
Â
}
|
@@ -518,6 +671,7 @@ function bp_core_delete_existing_avatar( $args = '' ) {
|
|
518 |
Â
elseif ( 'blog' == $object )
|
519 |
Â
$item_id = $current_blog->id;
|
520 |
Â
|
Â
|
|
521 |
Â
$item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object );
|
522 |
Â
|
523 |
Â
if ( !$item_id ) return false;
|
@@ -531,11 +685,13 @@ function bp_core_delete_existing_avatar( $args = '' ) {
|
|
531 |
Â
elseif ( 'blog' == $object )
|
532 |
Â
$avatar_dir = 'blog-avatars';
|
533 |
Â
|
Â
|
|
534 |
Â
$avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object );
|
535 |
Â
|
536 |
Â
if ( !$avatar_dir ) return false;
|
537 |
Â
}
|
538 |
Â
|
Â
|
|
539 |
Â
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
|
540 |
Â
|
541 |
Â
if ( !file_exists( $avatar_folder_dir ) )
|
@@ -551,11 +707,73 @@ function bp_core_delete_existing_avatar( $args = '' ) {
|
|
551 |
Â
|
552 |
Â
@rmdir( $avatar_folder_dir );
|
553 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
554 |
Â
do_action( 'bp_core_delete_existing_avatar', $args );
|
555 |
Â
|
556 |
Â
return true;
|
557 |
Â
}
|
558 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
559 |
Â
/**
|
560 |
Â
* Handle avatar uploading.
|
561 |
Â
*
|
@@ -568,130 +786,262 @@ function bp_core_delete_existing_avatar( $args = '' ) {
|
|
568 |
Â
* @see bp_core_check_avatar_upload()
|
569 |
Â
* @see bp_core_check_avatar_type()
|
570 |
Â
*
|
571 |
-
* @param array
|
572 |
Â
* @param string $upload_dir_filter A filter to be applied to 'upload_dir'.
|
Â
|
|
573 |
Â
* @return bool True on success, false on failure.
|
574 |
Â
*/
|
575 |
Â
function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
|
576 |
Â
|
577 |
-
|
578 |
-
*
|
579 |
-
*
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
580 |
Â
*/
|
581 |
-
if ( !apply_filters( 'bp_core_pre_avatar_handle_upload', true, $file, $upload_dir_filter ) )
|
582 |
Â
return true;
|
Â
|
|
583 |
Â
|
584 |
-
|
Â
|
|
Â
|
|
585 |
Â
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
2 => __( 'The image exceeds the maximum allowed file size of: ', 'buddypress' ) . size_format( bp_core_avatar_original_max_filesize() ),
|
590 |
-
3 => __( 'The uploaded file was only partially uploaded.', 'buddypress' ),
|
591 |
-
4 => __( 'The image was not uploaded.', 'buddypress' ),
|
592 |
-
6 => __( 'Missing a temporary folder.', 'buddypress' )
|
593 |
-
);
|
594 |
Â
|
595 |
-
|
596 |
-
|
Â
|
|
597 |
Â
return false;
|
598 |
Â
}
|
599 |
Â
|
600 |
-
|
601 |
-
|
602 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
603 |
Â
}
|
604 |
Â
|
605 |
-
|
606 |
-
|
Â
|
|
607 |
Â
return false;
|
608 |
Â
}
|
609 |
Â
|
610 |
-
//
|
611 |
-
|
Â
|
|
Â
|
|
612 |
Â
|
613 |
-
|
Â
|
|
614 |
Â
|
615 |
-
|
Â
|
|
616 |
Â
|
617 |
-
|
618 |
-
|
619 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
620 |
Â
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
Â
|
|
Â
|
|
Â
|
|
625 |
Â
}
|
626 |
Â
|
627 |
-
//
|
628 |
-
|
629 |
-
$error = false;
|
630 |
Â
|
631 |
-
//
|
632 |
-
|
633 |
-
$editor = wp_get_image_editor( $bp->avatar_admin->original['file'] );
|
634 |
Â
|
635 |
-
|
636 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
637 |
Â
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
$error = $resized;
|
643 |
-
}
|
644 |
Â
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
Â
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
}
|
654 |
Â
|
655 |
-
|
656 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
657 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
658 |
Â
|
659 |
-
|
660 |
-
|
661 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
662 |
Â
}
|
663 |
Â
}
|
664 |
Â
|
665 |
-
|
666 |
-
|
667 |
Â
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
$bp->
|
673 |
-
|
Â
|
|
Â
|
|
674 |
Â
}
|
675 |
Â
|
676 |
-
|
677 |
-
|
678 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
679 |
Â
return false;
|
680 |
Â
}
|
681 |
Â
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
$
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
Â
}
|
690 |
Â
|
691 |
-
|
692 |
-
$bp->avatar_admin->image->url = bp_core_avatar_url() . $bp->avatar_admin->image->dir;
|
693 |
Â
|
694 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
695 |
Â
}
|
696 |
Â
|
697 |
Â
/**
|
@@ -738,86 +1088,168 @@ function bp_core_avatar_handle_crop( $args = '' ) {
|
|
738 |
Â
'crop_y' => 0
|
739 |
Â
) );
|
740 |
Â
|
741 |
-
|
742 |
-
*
|
743 |
-
*
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
744 |
Â
*/
|
745 |
-
if ( !apply_filters( 'bp_core_pre_avatar_handle_crop', true, $r ) )
|
746 |
Â
return true;
|
Â
|
|
747 |
Â
|
748 |
-
|
Â
|
|
Â
|
|
749 |
Â
|
750 |
-
|
Â
|
|
751 |
Â
return false;
|
Â
|
|
752 |
Â
|
753 |
-
|
754 |
-
|
755 |
-
if ( !file_exists( $original_file ) )
|
756 |
-
return false;
|
757 |
Â
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
762 |
Â
}
|
763 |
Â
|
764 |
-
|
765 |
-
|
766 |
Â
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
'object' => $object,
|
773 |
-
'item_id' => $item_id,
|
774 |
-
'html' => false,
|
775 |
Â
) );
|
776 |
Â
|
777 |
-
if (
|
778 |
-
|
779 |
-
|
780 |
-
$upload_dir = wp_upload_dir();
|
781 |
-
$existing_avatar_path = str_replace( $upload_dir['baseurl'], '', $existing_avatar );
|
782 |
-
$new_avatar_path = str_replace( $upload_dir['basedir'], '', $original_file );
|
783 |
Â
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
Â
}
|
788 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
789 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
790 |
Â
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
795 |
Â
|
796 |
-
|
797 |
-
$crop_h = bp_core_avatar_full_height();
|
798 |
Â
}
|
799 |
Â
|
800 |
-
|
801 |
-
$data = @getimagesize( $original_file );
|
802 |
-
$ext = $data['mime'] == 'image/png' ? 'png' : 'jpg';
|
803 |
Â
|
804 |
-
// Set
|
805 |
-
|
806 |
-
|
807 |
Â
|
808 |
-
//
|
809 |
-
|
810 |
-
|
Â
|
|
811 |
Â
|
812 |
-
//
|
813 |
-
|
814 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
815 |
Â
|
816 |
-
//
|
817 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
818 |
Â
|
819 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
820 |
Â
}
|
Â
|
|
821 |
Â
|
822 |
Â
/**
|
823 |
Â
* Replace default WordPress avatars with BP avatars, if available.
|
@@ -912,6 +1344,53 @@ function bp_core_check_avatar_size( $file ) {
|
|
912 |
Â
return true;
|
913 |
Â
}
|
914 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
915 |
Â
/**
|
916 |
Â
* Does the current avatar upload have an allowed file type?
|
917 |
Â
*
|
@@ -920,26 +1399,21 @@ function bp_core_check_avatar_size( $file ) {
|
|
920 |
Â
* @param array $file The $_FILES array.
|
921 |
Â
* @return bool True if the file extension is permitted, otherwise false.
|
922 |
Â
*/
|
923 |
-
function bp_core_check_avatar_type($file) {
|
924 |
-
|
925 |
-
return false;
|
926 |
Â
|
927 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
928 |
Â
}
|
929 |
Â
|
930 |
Â
/**
|
931 |
Â
* Fetch data from the BP root blog's upload directory.
|
932 |
Â
*
|
933 |
-
* Handy for multisite instances because all uploads are made on the BP root
|
934 |
-
* blog and we need to query the BP root blog for the upload directory data.
|
935 |
-
*
|
936 |
-
* This function ensures that we only need to use {@link switch_to_blog()}
|
937 |
-
* once to get what we need.
|
938 |
-
*
|
939 |
Â
* @since BuddyPress (1.8.0)
|
940 |
Â
*
|
941 |
-
* @uses wp_upload_dir()
|
942 |
-
*
|
943 |
Â
* @param string $type The variable we want to return from the $bp->avatars
|
944 |
Â
* object. Only 'upload_path' and 'url' are supported. Default: 'upload_path'.
|
945 |
Â
* @return string The avatar upload directory path.
|
@@ -981,16 +1455,9 @@ function bp_core_get_upload_dir( $type = 'upload_path' ) {
|
|
981 |
Â
|
982 |
Â
// No cache, so query for it
|
983 |
Â
} else {
|
984 |
-
// We need to switch to the root blog on multisite installs
|
985 |
-
if ( is_multisite() ) {
|
986 |
-
switch_to_blog( bp_get_root_blog_id() );
|
987 |
-
}
|
988 |
Â
|
989 |
Â
// Get upload directory information from current site
|
990 |
-
$upload_dir =
|
991 |
-
|
992 |
-
// Will bail if not switched
|
993 |
-
restore_current_blog();
|
994 |
Â
|
995 |
Â
// Stash upload directory data for later use
|
996 |
Â
$bp->avatar->upload_dir = $upload_dir;
|
@@ -1022,22 +1489,38 @@ function bp_core_get_upload_dir( $type = 'upload_path' ) {
|
|
1022 |
Â
/**
|
1023 |
Â
* Get the absolute upload path for the WP installation.
|
1024 |
Â
*
|
1025 |
-
* @uses
|
1026 |
Â
*
|
1027 |
Â
* @return string Absolute path to WP upload directory.
|
1028 |
Â
*/
|
1029 |
Â
function bp_core_avatar_upload_path() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1030 |
Â
return apply_filters( 'bp_core_avatar_upload_path', bp_core_get_upload_dir() );
|
1031 |
Â
}
|
1032 |
Â
|
1033 |
Â
/**
|
1034 |
Â
* Get the raw base URL for root site upload location.
|
1035 |
Â
*
|
1036 |
-
* @uses
|
1037 |
Â
*
|
1038 |
Â
* @return string Full URL to current upload location.
|
1039 |
Â
*/
|
1040 |
Â
function bp_core_avatar_url() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1041 |
Â
return apply_filters( 'bp_core_avatar_url', bp_core_get_upload_dir( 'url' ) );
|
1042 |
Â
}
|
1043 |
Â
|
@@ -1058,6 +1541,14 @@ function bp_get_user_has_avatar( $user_id = 0 ) {
|
|
1058 |
Â
if ( bp_core_fetch_avatar( array( 'item_id' => $user_id, 'no_grav' => true, 'html' => false ) ) != bp_core_avatar_default( 'local' ) )
|
1059 |
Â
$retval = true;
|
1060 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1061 |
Â
return (bool) apply_filters( 'bp_get_user_has_avatar', $retval, $user_id );
|
1062 |
Â
}
|
1063 |
Â
|
@@ -1076,6 +1567,15 @@ function bp_core_avatar_dimension( $type = 'thumb', $h_or_w = 'height' ) {
|
|
1076 |
Â
$bp = buddypress();
|
1077 |
Â
$dim = isset( $bp->avatar->{$type}->{$h_or_w} ) ? (int) $bp->avatar->{$type}->{$h_or_w} : false;
|
1078 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1079 |
Â
return apply_filters( 'bp_core_avatar_dimension', $dim, $type, $h_or_w );
|
1080 |
Â
}
|
1081 |
Â
|
@@ -1087,6 +1587,14 @@ function bp_core_avatar_dimension( $type = 'thumb', $h_or_w = 'height' ) {
|
|
1087 |
Â
* @return int The 'thumb' width.
|
1088 |
Â
*/
|
1089 |
Â
function bp_core_avatar_thumb_width() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1090 |
Â
return apply_filters( 'bp_core_avatar_thumb_width', bp_core_avatar_dimension( 'thumb', 'width' ) );
|
1091 |
Â
}
|
1092 |
Â
|
@@ -1098,6 +1606,14 @@ function bp_core_avatar_thumb_width() {
|
|
1098 |
Â
* @return int The 'thumb' height.
|
1099 |
Â
*/
|
1100 |
Â
function bp_core_avatar_thumb_height() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1101 |
Â
return apply_filters( 'bp_core_avatar_thumb_height', bp_core_avatar_dimension( 'thumb', 'height' ) );
|
1102 |
Â
}
|
1103 |
Â
|
@@ -1109,6 +1625,14 @@ function bp_core_avatar_thumb_height() {
|
|
1109 |
Â
* @return int The 'full' width.
|
1110 |
Â
*/
|
1111 |
Â
function bp_core_avatar_full_width() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1112 |
Â
return apply_filters( 'bp_core_avatar_full_width', bp_core_avatar_dimension( 'full', 'width' ) );
|
1113 |
Â
}
|
1114 |
Â
|
@@ -1120,6 +1644,14 @@ function bp_core_avatar_full_width() {
|
|
1120 |
Â
* @return int The 'full' height.
|
1121 |
Â
*/
|
1122 |
Â
function bp_core_avatar_full_height() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1123 |
Â
return apply_filters( 'bp_core_avatar_full_height', bp_core_avatar_dimension( 'full', 'height' ) );
|
1124 |
Â
}
|
1125 |
Â
|
@@ -1131,6 +1663,14 @@ function bp_core_avatar_full_height() {
|
|
1131 |
Â
* @return int The max width for original avatar uploads.
|
1132 |
Â
*/
|
1133 |
Â
function bp_core_avatar_original_max_width() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1134 |
Â
return apply_filters( 'bp_core_avatar_original_max_width', (int) buddypress()->avatar->original_max_width );
|
1135 |
Â
}
|
1136 |
Â
|
@@ -1142,6 +1682,14 @@ function bp_core_avatar_original_max_width() {
|
|
1142 |
Â
* @return int The max filesize for original avatar uploads.
|
1143 |
Â
*/
|
1144 |
Â
function bp_core_avatar_original_max_filesize() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1145 |
Â
return apply_filters( 'bp_core_avatar_original_max_filesize', (int) buddypress()->avatar->original_max_filesize );
|
1146 |
Â
}
|
1147 |
Â
|
@@ -1166,15 +1714,16 @@ function bp_core_avatar_default( $type = 'gravatar' ) {
|
|
1166 |
Â
|
1167 |
Â
// Use Gravatar's mystery man as fallback
|
1168 |
Â
} else {
|
1169 |
-
|
1170 |
-
$host = 'https://secure.gravatar.com';
|
1171 |
-
} else {
|
1172 |
-
$host = 'http://www.gravatar.com';
|
1173 |
-
}
|
1174 |
-
|
1175 |
-
$avatar = $host . '/avatar/00000000000000000000000000000000?d=mm&s=' . bp_core_avatar_full_width();
|
1176 |
Â
}
|
1177 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1178 |
Â
return apply_filters( 'bp_core_avatar_default', $avatar );
|
1179 |
Â
}
|
1180 |
Â
|
@@ -1202,15 +1751,16 @@ function bp_core_avatar_default_thumb( $type = 'gravatar' ) {
|
|
1202 |
Â
|
1203 |
Â
// Use Gravatar's mystery man as fallback
|
1204 |
Â
} else {
|
1205 |
-
|
1206 |
-
$host = 'https://secure.gravatar.com';
|
1207 |
-
} else {
|
1208 |
-
$host = 'http://www.gravatar.com';
|
1209 |
-
}
|
1210 |
-
|
1211 |
-
$avatar = $host . '/avatar/00000000000000000000000000000000?d=mm&s=' . bp_core_avatar_thumb_width();
|
1212 |
Â
}
|
1213 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1214 |
Â
return apply_filters( 'bp_core_avatar_thumb', $avatar );
|
1215 |
Â
}
|
1216 |
Â
|
@@ -1256,3 +1806,116 @@ function bp_core_avatar_reset_query( $posts_query = null ) {
|
|
1256 |
Â
}
|
1257 |
Â
}
|
1258 |
Â
add_action( 'bp_parse_query', 'bp_core_avatar_reset_query', 10, 1 );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
31 |
Â
|
32 |
Â
if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE' ) ) {
|
33 |
Â
|
34 |
+
$fileupload_maxk = bp_core_get_root_option( 'fileupload_maxk' );
|
35 |
+
if ( '' === $fileupload_maxk ) {
|
36 |
Â
define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', 5120000 ); // 5mb
|
37 |
Â
} else {
|
38 |
+
define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', $fileupload_maxk * 1024 );
|
39 |
Â
}
|
40 |
Â
}
|
41 |
Â
|
87 |
Â
if ( ! defined( 'BP_AVATAR_URL' ) )
|
88 |
Â
define( 'BP_AVATAR_URL', $bp->avatar->url );
|
89 |
Â
|
90 |
+
/**
|
91 |
+
* Fires at the end of the core avatar globals setup.
|
92 |
+
*
|
93 |
+
* @since BuddyPress (1.5.0)
|
94 |
+
*/
|
95 |
Â
do_action( 'bp_core_set_avatar_globals' );
|
96 |
Â
}
|
97 |
Â
add_action( 'bp_setup_globals', 'bp_core_set_avatar_globals' );
|
231 |
Â
break;
|
232 |
Â
}
|
233 |
Â
|
234 |
+
/**
|
235 |
+
* Filters the ID of the item being requested.
|
236 |
+
*
|
237 |
+
* @since BuddyPress (1.1.0)
|
238 |
+
*
|
239 |
+
* @param string $value ID of avatar item being requested.
|
240 |
+
* @param string $value Avatar type being requested.
|
241 |
+
* @param array $params Array of parameters for the request.
|
242 |
+
*/
|
243 |
Â
$params['item_id'] = apply_filters( 'bp_core_avatar_item_id', $params['item_id'], $params['object'], $params );
|
244 |
Â
|
245 |
Â
if ( empty( $params['item_id'] ) ) {
|
272 |
Â
break;
|
273 |
Â
}
|
274 |
Â
|
275 |
+
/**
|
276 |
+
* Filters the avatar directory to use.
|
277 |
+
*
|
278 |
+
* @since BuddyPress (1.1.0)
|
279 |
+
*
|
280 |
+
* @param string $value Name of the subdirectory where the requested avatar should be found.
|
281 |
+
* @param string $value Avatar type being requested.
|
282 |
+
* @param array $params Array of parameters for the request.
|
283 |
+
*/
|
284 |
Â
$params['avatar_dir'] = apply_filters( 'bp_core_avatar_dir', $params['avatar_dir'], $params['object'], $params );
|
285 |
Â
|
286 |
Â
if ( empty( $params['avatar_dir'] ) ) {
|
308 |
Â
break;
|
309 |
Â
}
|
310 |
Â
|
311 |
+
/**
|
312 |
+
* Filters the alt attribute value to be applied to avatar.
|
313 |
+
*
|
314 |
+
* @since BuddyPress (1.5.0)
|
315 |
+
*
|
316 |
+
* @param string $value alt to be applied to avatar.
|
317 |
+
* @param string $value ID of avatar item being requested.
|
318 |
+
* @param string $value Avatar type being requested.
|
319 |
+
* @param array $params Array of parameters for the request.
|
320 |
+
*/
|
321 |
Â
$item_name = apply_filters( 'bp_core_avatar_alt', $item_name, $params['item_id'], $params['object'], $params );
|
322 |
Â
$params['alt'] = sprintf( $params['alt'], $item_name );
|
323 |
Â
}
|
332 |
Â
|
333 |
Â
// Filter image title and create html string
|
334 |
Â
$html_title = '';
|
335 |
+
|
336 |
+
/**
|
337 |
+
* Filters the title attribute value to be applied to avatar.
|
338 |
+
*
|
339 |
+
* @since BuddyPress (1.5.0)
|
340 |
+
*
|
341 |
+
* @param string $value Title to be applied to avatar.
|
342 |
+
* @param string $value ID of avatar item being requested.
|
343 |
+
* @param string $value Avatar type being requested.
|
344 |
+
* @param array $params Array of parameters for the request.
|
345 |
+
*/
|
346 |
Â
$params['title'] = apply_filters( 'bp_core_avatar_title', $params['title'], $params['item_id'], $params['object'], $params );
|
347 |
Â
|
348 |
Â
if ( ! empty( $params['title'] ) ) {
|
351 |
Â
|
352 |
Â
// Set CSS ID and create html string
|
353 |
Â
$html_css_id = '';
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Filters the ID attribute to be applied to avatar.
|
357 |
+
*
|
358 |
+
* @since BuddyPress (2.2.0)
|
359 |
+
*
|
360 |
+
* @param string $value ID to be applied to avatar.
|
361 |
+
* @param string $value ID of avatar item being requested.
|
362 |
+
* @param string $value Avatar type being requested.
|
363 |
+
* @param array $params Array of parameters for the request.
|
364 |
+
*/
|
365 |
Â
$params['css_id'] = apply_filters( 'bp_core_css_id', $params['css_id'], $params['item_id'], $params['object'], $params );
|
366 |
Â
|
367 |
Â
if ( ! empty( $params['css_id'] ) ) {
|
388 |
Â
}
|
389 |
Â
$html_height = ' height="' . $params['height'] . '"';
|
390 |
Â
|
391 |
+
/**
|
392 |
+
* Filters the classes to be applied to the avatar.
|
393 |
+
*
|
394 |
+
* @since BuddyPress (1.6.0)
|
395 |
+
*
|
396 |
+
* @param array|string $value Class(es) to be applied to the avatar.
|
397 |
+
* @param string $value ID of the avatar item being requested.
|
398 |
+
* @param string $value Avatar type being requested.
|
399 |
+
* @param array $params Array of parameters for the request.
|
400 |
+
*/
|
401 |
Â
$params['class'] = apply_filters( 'bp_core_avatar_class', $params['class'], $params['item_id'], $params['object'], $params );
|
402 |
Â
|
403 |
Â
// Use an alias to leave the param unchanged
|
424 |
Â
$avatar_loc->url = trailingslashit( bp_core_avatar_url() );
|
425 |
Â
|
426 |
Â
$avatar_loc->dir = trailingslashit( $params['avatar_dir'] );
|
427 |
+
|
428 |
+
/**
|
429 |
+
* Filters the avatar folder directory URL.
|
430 |
+
*
|
431 |
+
* @since BuddyPress (1.1.0)
|
432 |
+
*
|
433 |
+
* @param string $value Path to the avatar folder URL.
|
434 |
+
* @param int $value ID of the avatar item being requested.
|
435 |
+
* @param string $value Avatar type being requested.
|
436 |
+
* @param string $value Subdirectory where the requested avatar should be found.
|
437 |
+
*/
|
438 |
Â
$avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', ( $avatar_loc->url . $avatar_loc->dir . $params['item_id'] ), $params['item_id'], $params['object'], $params['avatar_dir'] );
|
439 |
+
|
440 |
+
/**
|
441 |
+
* Filters the avatar folder directory path.
|
442 |
+
*
|
443 |
+
* @since BuddyPress (1.1.0)
|
444 |
+
*
|
445 |
+
* @param string $value Path to the avatar folder directory.
|
446 |
+
* @param int $value ID of the avatar item being requested.
|
447 |
+
* @param string $value Avatar type being requested.
|
448 |
+
* @param string $value Subdirectory where the requested avatar should be found.
|
449 |
+
*/
|
450 |
Â
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', ( $avatar_loc->path . $avatar_loc->dir . $params['item_id'] ), $params['item_id'], $params['object'], $params['avatar_dir'] );
|
451 |
Â
|
452 |
Â
/**
|
511 |
Â
|
512 |
Â
// Return it wrapped in an <img> element
|
513 |
Â
if ( true === $params['html'] ) {
|
514 |
+
|
515 |
+
/**
|
516 |
+
* Filters an avatar URL wrapped in an <img> element.
|
517 |
+
*
|
518 |
+
* @since BuddyPress (1.1.0)
|
519 |
+
*
|
520 |
+
* @param string $value Full <img> element for an avatar.
|
521 |
+
* @param array $params Array of parameters for the request.
|
522 |
+
* @param string $value ID of the item requested.
|
523 |
+
* @param string $value Subdirectory where the requested avatar should be found.
|
524 |
+
* @param string $html_css_id ID attribute for avatar.
|
525 |
+
* @param string $html_width Width attribute for avatar.
|
526 |
+
* @param string $html_height Height attribtue for avatar.
|
527 |
+
* @param string $avatar_folder_url Avatar URL path.
|
528 |
+
* @param string $avatar_folder_dir Avatar dir path.
|
529 |
+
*/
|
530 |
Â
return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '"' . $html_class . $html_css_id . $html_width . $html_height . $html_alt . $html_title . ' />', $params, $params['item_id'], $params['avatar_dir'], $html_css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
|
531 |
Â
|
532 |
Â
// ...or only the URL
|
533 |
Â
} else {
|
534 |
+
|
535 |
+
/**
|
536 |
+
* Filters a locally uploaded avatar URL.
|
537 |
+
*
|
538 |
+
* @since BuddyPress (1.2.5)
|
539 |
+
*
|
540 |
+
* @param string $avatar_url URL for a locally uploaded avatar.
|
541 |
+
* @param array $params Array of parameters for the request.
|
542 |
+
*/
|
543 |
Â
return apply_filters( 'bp_core_fetch_avatar_url', $avatar_url, $params );
|
544 |
Â
}
|
545 |
Â
}
|
546 |
Â
}
|
547 |
Â
|
548 |
+
/**
|
549 |
+
* Filters whether or not to skip Gravatar check.
|
550 |
+
*
|
551 |
+
* @since BuddyPress (1.5.0)
|
552 |
+
*
|
553 |
+
* @param bool $value Whether or not to skip Gravatar.
|
554 |
+
* @param array $params Array of parameters for the avatar request.
|
555 |
+
*/
|
556 |
Â
if ( ! apply_filters( 'bp_core_fetch_avatar_no_grav', $params['no_grav'], $params ) ) {
|
557 |
Â
|
558 |
Â
// Set gravatar type
|
559 |
Â
if ( empty( $bp->grav_default->{$params['object']} ) ) {
|
560 |
Â
$default_grav = 'wavatar';
|
561 |
Â
} elseif ( 'mystery' == $bp->grav_default->{$params['object']} ) {
|
562 |
+
|
563 |
+
/**
|
564 |
+
* Filters the Mysteryman avatar src value.
|
565 |
+
*
|
566 |
+
* @since BuddyPress (1.2.0)
|
567 |
+
*
|
568 |
+
* @param string $value Avatar value.
|
569 |
+
* @param string $value Width to display avatar at.
|
570 |
+
*/
|
571 |
Â
$default_grav = apply_filters( 'bp_core_mysteryman_src', 'mm', $params['width'] );
|
572 |
Â
} else {
|
573 |
Â
$default_grav = $bp->grav_default->{$params['object']};
|
582 |
Â
}
|
583 |
Â
}
|
584 |
Â
|
585 |
+
$host = '//www.gravatar.com/avatar/';
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
586 |
Â
|
587 |
+
/**
|
588 |
+
* Filters the Gravatar email to use.
|
589 |
+
*
|
590 |
+
* @since BuddyPress (1.1.0)
|
591 |
+
*
|
592 |
+
* @param string $value Email to use in Gravatar request.
|
593 |
+
* @param string $value ID of the item being requested.
|
594 |
+
* @param string $value Object type being requested.
|
595 |
+
*/
|
596 |
Â
$params['email'] = apply_filters( 'bp_core_gravatar_email', $params['email'], $params['item_id'], $params['object'] );
|
597 |
+
|
598 |
+
/**
|
599 |
+
* Filters the Gravatar URL path.
|
600 |
+
*
|
601 |
+
* @since BuddyPress (1.0.2)
|
602 |
+
*
|
603 |
+
* @param string $value Gravatar URL path.
|
604 |
+
*/
|
605 |
Â
$gravatar = apply_filters( 'bp_gravatar_url', $host ) . md5( strtolower( $params['email'] ) ) . '?d=' . $default_grav . '&s=' . $params['width'];
|
606 |
Â
|
607 |
Â
// Gravatar rating; http://bit.ly/89QxZA
|
612 |
Â
|
613 |
Â
// No avatar was found, and we've been told not to use a gravatar.
|
614 |
Â
} else {
|
615 |
+
|
616 |
+
/**
|
617 |
+
* Filters the avatar default when Gravatar is not used.
|
618 |
+
*
|
619 |
+
* This is a variable filter dependent on the avatar type being requested.
|
620 |
+
*
|
621 |
+
* @since BuddyPress (1.5.0)
|
622 |
+
*
|
623 |
+
* @param string $value Default avatar for non-gravatar requests.
|
624 |
+
* @param array $params Array of parameters for the avatar request.
|
625 |
+
*/
|
626 |
Â
$gravatar = apply_filters( 'bp_core_default_avatar_' . $params['object'], bp_core_avatar_default( 'local' ), $params );
|
627 |
Â
}
|
628 |
Â
|
629 |
Â
if ( true === $params['html'] ) {
|
630 |
+
|
631 |
+
/** This filter is documented in bp-core/bp-core-avatars.php */
|
632 |
Â
return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $gravatar . '"' . $html_css_id . $html_class . $html_width . $html_height . $html_alt . $html_title . ' />', $params, $params['item_id'], $params['avatar_dir'], $html_css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
|
633 |
Â
} else {
|
634 |
+
|
635 |
+
/** This filter is documented in bp-core/bp-core-avatars.php */
|
636 |
Â
return apply_filters( 'bp_core_fetch_avatar_url', $gravatar, $params );
|
637 |
Â
}
|
638 |
Â
}
|
671 |
Â
elseif ( 'blog' == $object )
|
672 |
Â
$item_id = $current_blog->id;
|
673 |
Â
|
674 |
+
/** This filter is documented in bp-core/bp-core-avatars.php */
|
675 |
Â
$item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object );
|
676 |
Â
|
677 |
Â
if ( !$item_id ) return false;
|
685 |
Â
elseif ( 'blog' == $object )
|
686 |
Â
$avatar_dir = 'blog-avatars';
|
687 |
Â
|
688 |
+
/** This filter is documented in bp-core/bp-core-avatars.php */
|
689 |
Â
$avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object );
|
690 |
Â
|
691 |
Â
if ( !$avatar_dir ) return false;
|
692 |
Â
}
|
693 |
Â
|
694 |
+
/** This filter is documented in bp-core/bp-core-avatars.php */
|
695 |
Â
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
|
696 |
Â
|
697 |
Â
if ( !file_exists( $avatar_folder_dir ) )
|
707 |
Â
|
708 |
Â
@rmdir( $avatar_folder_dir );
|
709 |
Â
|
710 |
+
/**
|
711 |
+
* Fires after deleting an existing avatar.
|
712 |
+
*
|
713 |
+
* @since BuddyPress (1.1.0)
|
714 |
+
*
|
715 |
+
* @param array $args Array of arguments used for avatar deletion.
|
716 |
+
*/
|
717 |
Â
do_action( 'bp_core_delete_existing_avatar', $args );
|
718 |
Â
|
719 |
Â
return true;
|
720 |
Â
}
|
721 |
Â
|
722 |
+
/**
|
723 |
+
* Ajax delete an avatar for a given object and item id
|
724 |
+
*
|
725 |
+
* @since BuddyPress (2.3.0)
|
726 |
+
*
|
727 |
+
* @return string a json object containing success data if the avatar was deleted
|
728 |
+
* error message otherwise
|
729 |
+
*/
|
730 |
+
function bp_avatar_ajax_delete() {
|
731 |
+
// Bail if not a POST action
|
732 |
+
if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
|
733 |
+
wp_send_json_error();
|
734 |
+
}
|
735 |
+
|
736 |
+
$avatar_data = $_POST;
|
737 |
+
|
738 |
+
if ( empty( $avatar_data['object'] ) || empty( $avatar_data['item_id'] ) ) {
|
739 |
+
wp_send_json_error();
|
740 |
+
}
|
741 |
+
|
742 |
+
$nonce = 'bp_delete_avatar_link';
|
743 |
+
if ( 'group' === $avatar_data['object'] ) {
|
744 |
+
$nonce = 'bp_group_avatar_delete';
|
745 |
+
}
|
746 |
+
|
747 |
+
// Check the nonce
|
748 |
+
check_admin_referer( $nonce, 'nonce' );
|
749 |
+
|
750 |
+
// Capability check
|
751 |
+
if ( ! bp_attachments_current_user_can( 'edit_avatar', $avatar_data ) ) {
|
752 |
+
wp_send_json_error();
|
753 |
+
}
|
754 |
+
|
755 |
+
// Handle delete
|
756 |
+
if ( bp_core_delete_existing_avatar( array( 'item_id' => $avatar_data['item_id'], 'object' => $avatar_data['object'] ) ) ) {
|
757 |
+
$return = array(
|
758 |
+
'avatar' => html_entity_decode( bp_core_fetch_avatar( array(
|
759 |
+
'object' => $avatar_data['object'],
|
760 |
+
'item_id' => $avatar_data['item_id'],
|
761 |
+
'html' => false,
|
762 |
+
'type' => 'full',
|
763 |
+
) ) ),
|
764 |
+
'feedback_code' => 4,
|
765 |
+
'item_id' => $avatar_data['item_id'],
|
766 |
+
);
|
767 |
+
|
768 |
+
wp_send_json_success( $return );
|
769 |
+
} else {
|
770 |
+
wp_send_json_error( array(
|
771 |
+
'feedback_code' => 3,
|
772 |
+
) );
|
773 |
+
}
|
774 |
+
}
|
775 |
+
add_action( 'wp_ajax_bp_avatar_delete', 'bp_avatar_ajax_delete' );
|
776 |
+
|
777 |
Â
/**
|
778 |
Â
* Handle avatar uploading.
|
779 |
Â
*
|
786 |
Â
* @see bp_core_check_avatar_upload()
|
787 |
Â
* @see bp_core_check_avatar_type()
|
788 |
Â
*
|
789 |
+
* @param array $file The appropriate entry the from $_FILES superglobal.
|
790 |
Â
* @param string $upload_dir_filter A filter to be applied to 'upload_dir'.
|
791 |
+
*
|
792 |
Â
* @return bool True on success, false on failure.
|
793 |
Â
*/
|
794 |
Â
function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
|
795 |
Â
|
796 |
+
/**
|
797 |
+
* Filters whether or not to handle uploading.
|
798 |
+
*
|
799 |
+
* If you want to override this function, make sure you return false.
|
800 |
+
*
|
801 |
+
* @since BuddyPress (1.2.4)
|
802 |
+
*
|
803 |
+
* @param bool $value Whether or not to crop.
|
804 |
+
* @param array $file Appropriate entry from $_FILES superglobal.
|
805 |
+
* @parma string $upload_dir_filter A filter to be applied to 'upload_dir'.
|
806 |
Â
*/
|
807 |
+
if ( ! apply_filters( 'bp_core_pre_avatar_handle_upload', true, $file, $upload_dir_filter ) ) {
|
808 |
Â
return true;
|
809 |
+
}
|
810 |
Â
|
811 |
+
// Setup some variables
|
812 |
+
$bp = buddypress();
|
813 |
+
$upload_path = bp_core_avatar_upload_path();
|
814 |
Â
|
815 |
+
// Upload the file
|
816 |
+
$avatar_attachment = new BP_Attachment_Avatar();
|
817 |
+
$bp->avatar_admin->original = $avatar_attachment->upload( $file, $upload_dir_filter );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
818 |
Â
|
819 |
+
// In case of an error, stop the process and display a feedback to the user
|
820 |
+
if ( ! empty( $bp->avatar_admin->original['error'] ) ) {
|
821 |
+
bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->original['error'] ), 'error' );
|
822 |
Â
return false;
|
823 |
Â
}
|
824 |
Â
|
825 |
+
// Maybe resize
|
826 |
+
$bp->avatar_admin->resized = $avatar_attachment->shrink( $bp->avatar_admin->original['file'] );
|
827 |
+
$bp->avatar_admin->image = new stdClass();
|
828 |
+
|
829 |
+
// We only want to handle one image after resize.
|
830 |
+
if ( empty( $bp->avatar_admin->resized ) ) {
|
831 |
+
$bp->avatar_admin->image->file = $bp->avatar_admin->original['file'];
|
832 |
+
$bp->avatar_admin->image->dir = str_replace( $upload_path, '', $bp->avatar_admin->original['file'] );
|
833 |
+
} else {
|
834 |
+
$bp->avatar_admin->image->file = $bp->avatar_admin->resized['path'];
|
835 |
+
$bp->avatar_admin->image->dir = str_replace( $upload_path, '', $bp->avatar_admin->resized['path'] );
|
836 |
+
@unlink( $bp->avatar_admin->original['file'] );
|
837 |
Â
}
|
838 |
Â
|
839 |
+
// Check for WP_Error on what should be an image
|
840 |
+
if ( is_wp_error( $bp->avatar_admin->image->dir ) ) {
|
841 |
+
bp_core_add_message( sprintf( __( 'Upload failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->image->dir->get_error_message() ), 'error' );
|
842 |
Â
return false;
|
843 |
Â
}
|
844 |
Â
|
845 |
+
// If the uploaded image is smaller than the "full" dimensions, throw a warning
|
846 |
+
if ( $avatar_attachment->is_too_small( $bp->avatar_admin->image->file ) ) {
|
847 |
+
bp_core_add_message( sprintf( __( 'You have selected an image that is smaller than recommended. For best results, upload a picture larger than %d x %d pixels.', 'buddypress' ), bp_core_avatar_full_width(), bp_core_avatar_full_height() ), 'error' );
|
848 |
+
}
|
849 |
Â
|
850 |
+
// Set the url value for the image
|
851 |
+
$bp->avatar_admin->image->url = bp_core_avatar_url() . $bp->avatar_admin->image->dir;
|
852 |
Â
|
853 |
+
return true;
|
854 |
+
}
|
855 |
Â
|
856 |
+
/**
|
857 |
+
* Ajax upload an avatar
|
858 |
+
*
|
859 |
+
* @since BuddyPress (2.3.0)
|
860 |
+
*
|
861 |
+
* @return string a json object containing success data if the upload succeeded
|
862 |
+
* error message otherwise
|
863 |
+
*/
|
864 |
+
function bp_avatar_ajax_upload() {
|
865 |
+
// Bail if not a POST action
|
866 |
+
if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
|
867 |
+
wp_die();
|
868 |
+
}
|
869 |
Â
|
870 |
+
/**
|
871 |
+
* Sending the json response will be different if
|
872 |
+
* the current Plupload runtime is html4
|
873 |
+
*/
|
874 |
+
$is_html4 = false;
|
875 |
+
if ( ! empty( $_POST['html4' ] ) ) {
|
876 |
+
$is_html4 = true;
|
877 |
Â
}
|
878 |
Â
|
879 |
+
// Check the nonce
|
880 |
+
check_admin_referer( 'bp-uploader' );
|
Â
|
|
881 |
Â
|
882 |
+
// Init the BuddyPress parameters
|
883 |
+
$bp_params = array();
|
Â
|
|
884 |
Â
|
885 |
+
// We need it to carry on
|
886 |
+
if ( ! empty( $_POST['bp_params' ] ) ) {
|
887 |
+
$bp_params = $_POST['bp_params' ];
|
888 |
+
} else {
|
889 |
+
bp_attachments_json_response( false, $is_html4 );
|
890 |
+
}
|
891 |
Â
|
892 |
+
// We need the object to set the uploads dir filter
|
893 |
+
if ( empty( $bp_params['object'] ) ) {
|
894 |
+
bp_attachments_json_response( false, $is_html4 );
|
895 |
+
}
|
Â
|
|
Â
|
|
896 |
Â
|
897 |
+
// Capability check
|
898 |
+
if ( ! bp_attachments_current_user_can( 'edit_avatar', $bp_params ) ) {
|
899 |
+
bp_attachments_json_response( false, $is_html4 );
|
900 |
+
}
|
901 |
Â
|
902 |
+
$bp = buddypress();
|
903 |
+
$bp_params['upload_dir_filter'] = '';
|
904 |
+
$needs_reset = array();
|
Â
|
|
905 |
Â
|
906 |
+
if ( 'user' === $bp_params['object'] && bp_is_active( 'xprofile' ) ) {
|
907 |
+
$bp_params['upload_dir_filter'] = 'xprofile_avatar_upload_dir';
|
908 |
+
|
909 |
+
if ( ! bp_displayed_user_id() && ! empty( $bp_params['item_id'] ) ) {
|
910 |
+
$needs_reset = array( 'key' => 'displayed_user', 'value' => $bp->displayed_user );
|
911 |
+
$bp->displayed_user->id = $bp_params['item_id'];
|
912 |
+
}
|
913 |
+
} elseif ( 'group' === $bp_params['object'] && bp_is_active( 'groups' ) ) {
|
914 |
+
$bp_params['upload_dir_filter'] = 'groups_avatar_upload_dir';
|
915 |
+
|
916 |
+
if ( ! bp_get_current_group_id() && ! empty( $bp_params['item_id'] ) ) {
|
917 |
+
$needs_reset = array( 'component' => 'groups', 'key' => 'current_group', 'value' => $bp->groups->current_group );
|
918 |
+
$bp->groups->current_group = groups_get_group( array(
|
919 |
+
'group_id' => $bp_params['item_id'],
|
920 |
+
'populate_extras' => false,
|
921 |
+
) );
|
922 |
Â
}
|
923 |
+
} else {
|
924 |
+
/**
|
925 |
+
* Filter here to deal with other components
|
926 |
+
*
|
927 |
+
* @since BuddyPress (2.3.0)
|
928 |
+
*
|
929 |
+
* @var array $bp_params the BuddyPress Ajax parameters
|
930 |
+
*/
|
931 |
+
$bp_params = apply_filters( 'bp_core_avatar_ajax_upload_params', $bp_params );
|
932 |
+
}
|
933 |
Â
|
934 |
+
if ( ! isset( $bp->avatar_admin ) ) {
|
935 |
+
$bp->avatar_admin = new stdClass();
|
936 |
+
}
|
937 |
+
|
938 |
+
// Upload the avatar
|
939 |
+
$avatar = bp_core_avatar_handle_upload( $_FILES, $bp_params['upload_dir_filter'] );
|
940 |
+
|
941 |
+
// Reset objects
|
942 |
+
if ( ! empty( $needs_reset ) ) {
|
943 |
+
if ( ! empty( $needs_reset['component'] ) ) {
|
944 |
+
$bp->{$needs_reset['component']}->{$needs_reset['key']} = $needs_reset['value'];
|
945 |
+
} else {
|
946 |
+
$bp->{$needs_reset['key']} = $needs_reset['value'];
|
947 |
Â
}
|
948 |
Â
}
|
949 |
Â
|
950 |
+
// Init the feedback message
|
951 |
+
$feedback_message = false;
|
952 |
Â
|
953 |
+
if ( ! empty( $bp->template_message ) ) {
|
954 |
+
$feedback_message = $bp->template_message;
|
955 |
+
|
956 |
+
// Remove template message.
|
957 |
+
$bp->template_message = false;
|
958 |
+
$bp->template_message_type = false;
|
959 |
+
@setcookie( 'bp-message', false, time() - 1000, COOKIEPATH );
|
960 |
+
@setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH );
|
961 |
Â
}
|
962 |
Â
|
963 |
+
if ( empty( $avatar ) ) {
|
964 |
+
// Default upload error
|
965 |
+
$message = __( 'Upload failed.', 'buddypress' );
|
966 |
+
|
967 |
+
// Use the template message if set
|
968 |
+
if ( ! empty( $feedback_message ) ) {
|
969 |
+
$message = $feedback_message;
|
970 |
+
}
|
971 |
+
|
972 |
+
// Upload error reply
|
973 |
+
bp_attachments_json_response( false, $is_html4, array(
|
974 |
+
'type' => 'upload_error',
|
975 |
+
'message' => $message,
|
976 |
+
) );
|
977 |
+
}
|
978 |
+
|
979 |
+
if ( empty( $bp->avatar_admin->image->file ) ) {
|
980 |
+
bp_attachments_json_response( false, $is_html4 );
|
981 |
+
}
|
982 |
+
|
983 |
+
$uploaded_image = @getimagesize( $bp->avatar_admin->image->file );
|
984 |
+
|
985 |
+
// Set the name of the file
|
986 |
+
$name = $_FILES['file']['name'];
|
987 |
+
$name_parts = pathinfo( $name );
|
988 |
+
$name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) );
|
989 |
+
|
990 |
+
// Finally return the avatar to the editor
|
991 |
+
bp_attachments_json_response( true, $is_html4, array(
|
992 |
+
'name' => $name,
|
993 |
+
'url' => $bp->avatar_admin->image->url,
|
994 |
+
'width' => $uploaded_image[0],
|
995 |
+
'height' => $uploaded_image[1],
|
996 |
+
'feedback' => $feedback_message,
|
997 |
+
) );
|
998 |
+
}
|
999 |
+
add_action( 'wp_ajax_bp_avatar_upload', 'bp_avatar_ajax_upload' );
|
1000 |
+
|
1001 |
+
/**
|
1002 |
+
* Handle avatar webcam capture.
|
1003 |
+
*
|
1004 |
+
* @since BuddyPress (2.3.0)
|
1005 |
+
*
|
1006 |
+
* @param string $data base64 encoded image.
|
1007 |
+
* @param int $item_id.
|
1008 |
+
* @return bool True on success, false on failure.
|
1009 |
+
*/
|
1010 |
+
function bp_avatar_handle_capture( $data = '', $item_id = 0 ) {
|
1011 |
+
if ( empty( $data ) || empty( $item_id ) ) {
|
1012 |
Â
return false;
|
1013 |
Â
}
|
1014 |
Â
|
1015 |
+
$avatar_dir = bp_core_avatar_upload_path() . '/avatars';
|
1016 |
+
|
1017 |
+
// It's not a regular upload, we may need to create this folder
|
1018 |
+
if ( ! file_exists( $avatar_dir ) ) {
|
1019 |
+
if ( ! wp_mkdir_p( $avatar_dir ) ) {
|
1020 |
+
return false;
|
1021 |
+
}
|
1022 |
Â
}
|
1023 |
Â
|
1024 |
+
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', $avatar_dir . '/' . $item_id, $item_id, 'user', 'avatars' );
|
Â
|
|
1025 |
Â
|
1026 |
+
// It's not a regular upload, we may need to create this folder
|
1027 |
+
if( ! is_dir( $avatar_folder_dir ) ) {
|
1028 |
+
if ( ! wp_mkdir_p( $avatar_folder_dir ) ) {
|
1029 |
+
return false;
|
1030 |
+
}
|
1031 |
+
}
|
1032 |
+
|
1033 |
+
$original_file = $avatar_folder_dir . '/webcam-capture-' . $item_id . '.png';
|
1034 |
+
|
1035 |
+
if ( file_put_contents( $original_file, $data ) ) {
|
1036 |
+
$avatar_to_crop = str_replace( bp_core_avatar_upload_path(), '', $original_file );
|
1037 |
+
|
1038 |
+
// Crop to default values
|
1039 |
+
$crop_args = array( 'item_id' => $item_id, 'original_file' => $avatar_to_crop, 'crop_x' => 0, 'crop_y' => 0 );
|
1040 |
+
|
1041 |
+
return bp_core_avatar_handle_crop( $crop_args );
|
1042 |
+
} else {
|
1043 |
+
return false;
|
1044 |
+
}
|
1045 |
Â
}
|
1046 |
Â
|
1047 |
Â
/**
|
1088 |
Â
'crop_y' => 0
|
1089 |
Â
) );
|
1090 |
Â
|
1091 |
+
/**
|
1092 |
+
* Filters whether or not to handle cropping.
|
1093 |
+
*
|
1094 |
+
* If you want to override this function, make sure you return false.
|
1095 |
+
*
|
1096 |
+
* @since BuddyPress (1.2.4)
|
1097 |
+
*
|
1098 |
+
* @param bool $value Whether or not to crop.
|
1099 |
+
* @param array $r Array of parsed arguments for function
|
1100 |
Â
*/
|
1101 |
+
if ( ! apply_filters( 'bp_core_pre_avatar_handle_crop', true, $r ) ) {
|
1102 |
Â
return true;
|
1103 |
+
}
|
1104 |
Â
|
1105 |
+
// Crop the file
|
1106 |
+
$avatar_attachment = new BP_Attachment_Avatar();
|
1107 |
+
$cropped = $avatar_attachment->crop( $r );
|
1108 |
Â
|
1109 |
+
// Check for errors
|
1110 |
+
if ( empty( $cropped['full'] ) || empty( $cropped['thumb'] ) || is_wp_error( $cropped['full'] ) || is_wp_error( $cropped['thumb'] ) ) {
|
1111 |
Â
return false;
|
1112 |
+
}
|
1113 |
Â
|
1114 |
+
return true;
|
1115 |
+
}
|
Â
|
|
Â
|
|
1116 |
Â
|
1117 |
+
/**
|
1118 |
+
* Ajax set an avatar for a given object and item id
|
1119 |
+
*
|
1120 |
+
* @since BuddyPress (2.3.0)
|
1121 |
+
*
|
1122 |
+
* @return string a json object containing success data if the crop/capture succeeded
|
1123 |
+
* error message otherwise
|
1124 |
+
*/
|
1125 |
+
function bp_avatar_ajax_set() {
|
1126 |
+
// Bail if not a POST action
|
1127 |
+
if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
|
1128 |
+
wp_send_json_error();
|
1129 |
Â
}
|
1130 |
Â
|
1131 |
+
// Check the nonce
|
1132 |
+
check_admin_referer( 'bp_avatar_cropstore', 'nonce' );
|
1133 |
Â
|
1134 |
+
$avatar_data = wp_parse_args( $_POST, array(
|
1135 |
+
'crop_w' => bp_core_avatar_full_width(),
|
1136 |
+
'crop_h' => bp_core_avatar_full_height(),
|
1137 |
+
'crop_x' => 0,
|
1138 |
+
'crop_y' => 0
|
Â
|
|
Â
|
|
Â
|
|
1139 |
Â
) );
|
1140 |
Â
|
1141 |
+
if ( empty( $avatar_data['object'] ) || empty( $avatar_data['item_id'] ) || empty( $avatar_data['original_file'] ) ) {
|
1142 |
+
wp_send_json_error();
|
1143 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
1144 |
Â
|
1145 |
+
// Capability check
|
1146 |
+
if ( ! bp_attachments_current_user_can( 'edit_avatar', $avatar_data ) ) {
|
1147 |
+
wp_send_json_error();
|
1148 |
Â
}
|
1149 |
Â
|
1150 |
+
if ( ! empty( $avatar_data['type'] ) && 'camera' === $avatar_data['type'] && 'user' === $avatar_data['object'] ) {
|
1151 |
+
$webcam_avatar = false;
|
1152 |
+
|
1153 |
+
if ( ! empty( $avatar_data['original_file'] ) ) {
|
1154 |
+
$webcam_avatar = str_replace( array( 'data:image/png;base64,', ' ' ), array( '', '+' ), $avatar_data['original_file'] );
|
1155 |
+
$webcam_avatar = base64_decode( $webcam_avatar );
|
1156 |
+
}
|
1157 |
Â
|
1158 |
+
if ( ! bp_avatar_handle_capture( $webcam_avatar, $avatar_data['item_id'] ) ) {
|
1159 |
+
wp_send_json_error( array(
|
1160 |
+
'feedback_code' => 1
|
1161 |
+
) );
|
1162 |
Â
|
1163 |
+
} else {
|
1164 |
+
$return = array(
|
1165 |
+
'avatar' => html_entity_decode( bp_core_fetch_avatar( array(
|
1166 |
+
'object' => $avatar_data['object'],
|
1167 |
+
'item_id' => $avatar_data['item_id'],
|
1168 |
+
'html' => false,
|
1169 |
+
'type' => 'full',
|
1170 |
+
) ) ),
|
1171 |
+
'feedback_code' => 2,
|
1172 |
+
'item_id' => $avatar_data['item_id'],
|
1173 |
+
);
|
1174 |
+
|
1175 |
+
/**
|
1176 |
+
* Fires if the new avatar was successfully captured.
|
1177 |
+
*
|
1178 |
+
* @since 1.1.0 Used to inform the avatar was successfully cropped
|
1179 |
+
* @since 2.3.4 Add two new parameters to inform about the user id and
|
1180 |
+
* about the way the avatar was set (eg: 'crop' or 'camera')
|
1181 |
+
* Move the action at the right place, once the avatar is set
|
1182 |
+
*
|
1183 |
+
* @param string $item_id Inform about the user id the avatar was set for
|
1184 |
+
* @param string $type Inform about the way the avatar was set ('camera')
|
1185 |
+
*/
|
1186 |
+
do_action( 'xprofile_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'] );
|
1187 |
+
|
1188 |
+
wp_send_json_success( $return );
|
1189 |
+
}
|
1190 |
Â
|
1191 |
+
return;
|
Â
|
|
1192 |
Â
}
|
1193 |
Â
|
1194 |
+
$original_file = str_replace( bp_core_avatar_url(), '', $avatar_data['original_file'] );
|
Â
|
|
Â
|
|
1195 |
Â
|
1196 |
+
// Set avatars dir & feedback part
|
1197 |
+
if ( 'user' === $avatar_data['object'] ) {
|
1198 |
+
$avatar_dir = 'avatars';
|
1199 |
Â
|
1200 |
+
// Defaults to object-avatars dir
|
1201 |
+
} else {
|
1202 |
+
$avatar_dir = sanitize_key( $avatar_data['object'] ) . '-avatars';
|
1203 |
+
}
|
1204 |
Â
|
1205 |
+
// Crop args
|
1206 |
+
$r = array(
|
1207 |
+
'item_id' => $avatar_data['item_id'],
|
1208 |
+
'object' => $avatar_data['object'],
|
1209 |
+
'avatar_dir' => $avatar_dir,
|
1210 |
+
'original_file' => $original_file,
|
1211 |
+
'crop_w' => $avatar_data['crop_w'],
|
1212 |
+
'crop_h' => $avatar_data['crop_h'],
|
1213 |
+
'crop_x' => $avatar_data['crop_x'],
|
1214 |
+
'crop_y' => $avatar_data['crop_y']
|
1215 |
+
);
|
1216 |
Â
|
1217 |
+
// Handle crop
|
1218 |
+
if ( bp_core_avatar_handle_crop( $r ) ) {
|
1219 |
+
$return = array(
|
1220 |
+
'avatar' => html_entity_decode( bp_core_fetch_avatar( array(
|
1221 |
+
'object' => $avatar_data['object'],
|
1222 |
+
'item_id' => $avatar_data['item_id'],
|
1223 |
+
'html' => false,
|
1224 |
+
'type' => 'full',
|
1225 |
+
) ) ),
|
1226 |
+
'feedback_code' => 2,
|
1227 |
+
'item_id' => $avatar_data['item_id'],
|
1228 |
+
);
|
1229 |
+
|
1230 |
+
if ( 'user' === $avatar_data['object'] ) {
|
1231 |
+
/**
|
1232 |
+
* Fires if the new avatar was successfully cropped.
|
1233 |
+
*
|
1234 |
+
* @since 1.1.0 Used to inform the avatar was successfully cropped
|
1235 |
+
* @since 2.3.4 Add two new parameters to inform about the user id and
|
1236 |
+
* about the way the avatar was set (eg: 'crop' or 'camera')
|
1237 |
+
* Move the action at the right place, once the avatar is set
|
1238 |
+
*
|
1239 |
+
* @param string $item_id Inform about the user id the avatar was set for
|
1240 |
+
* @param string $type Inform about the way the avatar was set ('crop')
|
1241 |
+
*/
|
1242 |
+
do_action( 'xprofile_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'] );
|
1243 |
+
}
|
1244 |
Â
|
1245 |
+
wp_send_json_success( $return );
|
1246 |
+
} else {
|
1247 |
+
wp_send_json_error( array(
|
1248 |
+
'feedback_code' => 1,
|
1249 |
+
) );
|
1250 |
+
}
|
1251 |
Â
}
|
1252 |
+
add_action( 'wp_ajax_bp_avatar_set', 'bp_avatar_ajax_set' );
|
1253 |
Â
|
1254 |
Â
/**
|
1255 |
Â
* Replace default WordPress avatars with BP avatars, if available.
|
1344 |
Â
return true;
|
1345 |
Â
}
|
1346 |
Â
|
1347 |
+
/**
|
1348 |
+
* Get allowed avatar types
|
1349 |
+
*
|
1350 |
+
* @since BuddyPress (2.3.0)
|
1351 |
+
*/
|
1352 |
+
function bp_core_get_allowed_avatar_types() {
|
1353 |
+
$allowed_types = array( 'jpeg', 'gif', 'png' );
|
1354 |
+
|
1355 |
+
/**
|
1356 |
+
* Use this filter to restrict image types
|
1357 |
+
*
|
1358 |
+
* @since BuddyPress (2.3.0)
|
1359 |
+
*
|
1360 |
+
* @param array list of image types
|
1361 |
+
*/
|
1362 |
+
$avatar_types = (array) apply_filters( 'bp_core_get_allowed_avatar_types', $allowed_types );
|
1363 |
+
|
1364 |
+
if ( empty( $avatar_types ) ) {
|
1365 |
+
$avatar_types = $allowed_types;
|
1366 |
+
} else {
|
1367 |
+
$avatar_types = array_intersect( $allowed_types, $avatar_types );
|
1368 |
+
}
|
1369 |
+
|
1370 |
+
return array_values( $avatar_types );
|
1371 |
+
}
|
1372 |
+
|
1373 |
+
/**
|
1374 |
+
* Get allowed avatar mime types
|
1375 |
+
*
|
1376 |
+
* @since BuddyPress (2.3.0)
|
1377 |
+
*/
|
1378 |
+
function bp_core_get_allowed_avatar_mimes() {
|
1379 |
+
$allowed_types = bp_core_get_allowed_avatar_types();
|
1380 |
+
$validate_mimes = wp_match_mime_types( join( ',', $allowed_types ), wp_get_mime_types() );
|
1381 |
+
$allowed_mimes = array_map( 'implode', $validate_mimes );
|
1382 |
+
|
1383 |
+
/**
|
1384 |
+
* Include jpg type if needed so that bp_core_check_avatar_type()
|
1385 |
+
* will check for jpeg and jpg extensions.
|
1386 |
+
*/
|
1387 |
+
if ( isset( $allowed_mimes['jpeg'] ) ) {
|
1388 |
+
$allowed_mimes['jpg'] = $allowed_mimes['jpeg'];
|
1389 |
+
}
|
1390 |
+
|
1391 |
+
return $allowed_mimes;
|
1392 |
+
}
|
1393 |
+
|
1394 |
Â
/**
|
1395 |
Â
* Does the current avatar upload have an allowed file type?
|
1396 |
Â
*
|
1399 |
Â
* @param array $file The $_FILES array.
|
1400 |
Â
* @return bool True if the file extension is permitted, otherwise false.
|
1401 |
Â
*/
|
1402 |
+
function bp_core_check_avatar_type( $file ) {
|
1403 |
+
$avatar_filetype = wp_check_filetype_and_ext( $file['file']['tmp_name'], $file['file']['name'], bp_core_get_allowed_avatar_mimes() );
|
Â
|
|
1404 |
Â
|
1405 |
+
if ( ! empty( $avatar_filetype['ext'] ) && ! empty( $avatar_filetype['type'] ) ) {
|
1406 |
+
return true;
|
1407 |
+
}
|
1408 |
+
|
1409 |
+
return false;
|
1410 |
Â
}
|
1411 |
Â
|
1412 |
Â
/**
|
1413 |
Â
* Fetch data from the BP root blog's upload directory.
|
1414 |
Â
*
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1415 |
Â
* @since BuddyPress (1.8.0)
|
1416 |
Â
*
|
Â
|
|
Â
|
|
1417 |
Â
* @param string $type The variable we want to return from the $bp->avatars
|
1418 |
Â
* object. Only 'upload_path' and 'url' are supported. Default: 'upload_path'.
|
1419 |
Â
* @return string The avatar upload directory path.
|
1455 |
Â
|
1456 |
Â
// No cache, so query for it
|
1457 |
Â
} else {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1458 |
Â
|
1459 |
Â
// Get upload directory information from current site
|
1460 |
+
$upload_dir = bp_upload_dir();
|
Â
|
|
Â
|
|
Â
|
|
1461 |
Â
|
1462 |
Â
// Stash upload directory data for later use
|
1463 |
Â
$bp->avatar->upload_dir = $upload_dir;
|
1489 |
Â
/**
|
1490 |
Â
* Get the absolute upload path for the WP installation.
|
1491 |
Â
*
|
1492 |
+
* @uses bp_core_get_upload_dir() To get upload directory info
|
1493 |
Â
*
|
1494 |
Â
* @return string Absolute path to WP upload directory.
|
1495 |
Â
*/
|
1496 |
Â
function bp_core_avatar_upload_path() {
|
1497 |
+
|
1498 |
+
/**
|
1499 |
+
* Filters the absolute upload path for the WP installation.
|
1500 |
+
*
|
1501 |
+
* @since BuddyPress (1.2.0)
|
1502 |
+
*
|
1503 |
+
* @param string $value Absolute upload path for the WP installation.
|
1504 |
+
*/
|
1505 |
Â
return apply_filters( 'bp_core_avatar_upload_path', bp_core_get_upload_dir() );
|
1506 |
Â
}
|
1507 |
Â
|
1508 |
Â
/**
|
1509 |
Â
* Get the raw base URL for root site upload location.
|
1510 |
Â
*
|
1511 |
+
* @uses bp_core_get_upload_dir() To get upload directory info.
|
1512 |
Â
*
|
1513 |
Â
* @return string Full URL to current upload location.
|
1514 |
Â
*/
|
1515 |
Â
function bp_core_avatar_url() {
|
1516 |
+
|
1517 |
+
/**
|
1518 |
+
* Filters the raw base URL for root site upload location.
|
1519 |
+
*
|
1520 |
+
* @since BuddyPress (1.2.0)
|
1521 |
+
*
|
1522 |
+
* @param string $value Raw base URL for the root site upload location.
|
1523 |
+
*/
|
1524 |
Â
return apply_filters( 'bp_core_avatar_url', bp_core_get_upload_dir( 'url' ) );
|
1525 |
Â
}
|
1526 |
Â
|
1541 |
Â
if ( bp_core_fetch_avatar( array( 'item_id' => $user_id, 'no_grav' => true, 'html' => false ) ) != bp_core_avatar_default( 'local' ) )
|
1542 |
Â
$retval = true;
|
1543 |
Â
|
1544 |
+
/**
|
1545 |
+
* Filters whether or not a user has an uploaded avatar.
|
1546 |
+
*
|
1547 |
+
* @since BuddyPress (1.6.0)
|
1548 |
+
*
|
1549 |
+
* @param bool $retval Whether or not a user has an uploaded avatar.
|
1550 |
+
* @param int $user_id ID of the user being checked.
|
1551 |
+
*/
|
1552 |
Â
return (bool) apply_filters( 'bp_get_user_has_avatar', $retval, $user_id );
|
1553 |
Â
}
|
1554 |
Â
|
1567 |
Â
$bp = buddypress();
|
1568 |
Â
$dim = isset( $bp->avatar->{$type}->{$h_or_w} ) ? (int) $bp->avatar->{$type}->{$h_or_w} : false;
|
1569 |
Â
|
1570 |
+
/**
|
1571 |
+
* Filters the avatar dimension setting.
|
1572 |
+
*
|
1573 |
+
* @since BuddyPress (1.5.0)
|
1574 |
+
*
|
1575 |
+
* @param int $dim Dimension setting for the type.
|
1576 |
+
* @param string $type The type of avatar whose dimensions are requested. Default 'thumb'.
|
1577 |
+
* @param string $h_or_w The dimension parameter being requested. Default 'height'.
|
1578 |
+
*/
|
1579 |
Â
return apply_filters( 'bp_core_avatar_dimension', $dim, $type, $h_or_w );
|
1580 |
Â
}
|
1581 |
Â
|
1587 |
Â
* @return int The 'thumb' width.
|
1588 |
Â
*/
|
1589 |
Â
function bp_core_avatar_thumb_width() {
|
1590 |
+
|
1591 |
+
/**
|
1592 |
+
* Filters the 'thumb' avatar width setting.
|
1593 |
+
*
|
1594 |
+
* @since BuddyPress (1.5.0)
|
1595 |
+
*
|
1596 |
+
* @param int $value Value for the 'thumb' avatar width setting.
|
1597 |
+
*/
|
1598 |
Â
return apply_filters( 'bp_core_avatar_thumb_width', bp_core_avatar_dimension( 'thumb', 'width' ) );
|
1599 |
Â
}
|
1600 |
Â
|
1606 |
Â
* @return int The 'thumb' height.
|
1607 |
Â
*/
|
1608 |
Â
function bp_core_avatar_thumb_height() {
|
1609 |
+
|
1610 |
+
/**
|
1611 |
+
* Filters the 'thumb' avatar height setting.
|
1612 |
+
*
|
1613 |
+
* @since BuddyPress (1.5.0)
|
1614 |
+
*
|
1615 |
+
* @param int $value Value for the 'thumb' avatar height setting.
|
1616 |
+
*/
|
1617 |
Â
return apply_filters( 'bp_core_avatar_thumb_height', bp_core_avatar_dimension( 'thumb', 'height' ) );
|
1618 |
Â
}
|
1619 |
Â
|
1625 |
Â
* @return int The 'full' width.
|
1626 |
Â
*/
|
1627 |
Â
function bp_core_avatar_full_width() {
|
1628 |
+
|
1629 |
+
/**
|
1630 |
+
* Filters the 'full' avatar width setting.
|
1631 |
+
*
|
1632 |
+
* @since BuddyPress (1.5.0)
|
1633 |
+
*
|
1634 |
+
* @param int $value Value for the 'full' avatar width setting.
|
1635 |
+
*/
|
1636 |
Â
return apply_filters( 'bp_core_avatar_full_width', bp_core_avatar_dimension( 'full', 'width' ) );
|
1637 |
Â
}
|
1638 |
Â
|
1644 |
Â
* @return int The 'full' height.
|
1645 |
Â
*/
|
1646 |
Â
function bp_core_avatar_full_height() {
|
1647 |
+
|
1648 |
+
/**
|
1649 |
+
* Filters the 'full' avatar height setting.
|
1650 |
+
*
|
1651 |
+
* @since BuddyPress (1.5.0)
|
1652 |
+
*
|
1653 |
+
* @param int $value Value for the 'full' avatar height setting.
|
1654 |
+
*/
|
1655 |
Â
return apply_filters( 'bp_core_avatar_full_height', bp_core_avatar_dimension( 'full', 'height' ) );
|
1656 |
Â
}
|
1657 |
Â
|
1663 |
Â
* @return int The max width for original avatar uploads.
|
1664 |
Â
*/
|
1665 |
Â
function bp_core_avatar_original_max_width() {
|
1666 |
+
|
1667 |
+
/**
|
1668 |
+
* Filters the max width for original avatar uploads.
|
1669 |
+
*
|
1670 |
+
* @since BuddyPress (1.5.0)
|
1671 |
+
*
|
1672 |
+
* @param int $value Value for the max width.
|
1673 |
+
*/
|
1674 |
Â
return apply_filters( 'bp_core_avatar_original_max_width', (int) buddypress()->avatar->original_max_width );
|
1675 |
Â
}
|
1676 |
Â
|
1682 |
Â
* @return int The max filesize for original avatar uploads.
|
1683 |
Â
*/
|
1684 |
Â
function bp_core_avatar_original_max_filesize() {
|
1685 |
+
|
1686 |
+
/**
|
1687 |
+
* Filters the max filesize for original avatar uploads.
|
1688 |
+
*
|
1689 |
+
* @since BuddyPress (1.5.0)
|
1690 |
+
*
|
1691 |
+
* @param int $value Value for the max filesize.
|
1692 |
+
*/
|
1693 |
Â
return apply_filters( 'bp_core_avatar_original_max_filesize', (int) buddypress()->avatar->original_max_filesize );
|
1694 |
Â
}
|
1695 |
Â
|
1714 |
Â
|
1715 |
Â
// Use Gravatar's mystery man as fallback
|
1716 |
Â
} else {
|
1717 |
+
$avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&s=' . bp_core_avatar_full_width();
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1718 |
Â
}
|
1719 |
Â
|
1720 |
+
/**
|
1721 |
+
* Filters the URL of the 'full' default avatar.
|
1722 |
+
*
|
1723 |
+
* @since BuddyPress (1.5.0)
|
1724 |
+
*
|
1725 |
+
* @param string $avatar URL of the default avatar.
|
1726 |
+
*/
|
1727 |
Â
return apply_filters( 'bp_core_avatar_default', $avatar );
|
1728 |
Â
}
|
1729 |
Â
|
1751 |
Â
|
1752 |
Â
// Use Gravatar's mystery man as fallback
|
1753 |
Â
} else {
|
1754 |
+
$avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&s=' . bp_core_avatar_thumb_width();
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1755 |
Â
}
|
1756 |
Â
|
1757 |
+
/**
|
1758 |
+
* Filters the URL of the 'thumb' default avatar.
|
1759 |
+
*
|
1760 |
+
* @since BuddyPress (1.5.0)
|
1761 |
+
*
|
1762 |
+
* @param string $avatar URL of the default avatar.
|
1763 |
+
*/
|
1764 |
Â
return apply_filters( 'bp_core_avatar_thumb', $avatar );
|
1765 |
Â
}
|
1766 |
Â
|
1806 |
Â
}
|
1807 |
Â
}
|
1808 |
Â
add_action( 'bp_parse_query', 'bp_core_avatar_reset_query', 10, 1 );
|
1809 |
+
|
1810 |
+
/**
|
1811 |
+
* Checks whether Avatar UI should be loaded
|
1812 |
+
*
|
1813 |
+
* @since BuddyPress (2.3.0)
|
1814 |
+
*
|
1815 |
+
* @return bool True if Avatar UI should load, false otherwise
|
1816 |
+
*/
|
1817 |
+
function bp_avatar_is_front_edit() {
|
1818 |
+
$retval = false;
|
1819 |
+
|
1820 |
+
// No need to carry on if the current WordPress version is not supported.
|
1821 |
+
if ( ! bp_attachments_is_wp_version_supported() ) {
|
1822 |
+
return $retval;
|
1823 |
+
}
|
1824 |
+
|
1825 |
+
if ( bp_is_user_change_avatar() && 'crop-image' !== bp_get_avatar_admin_step() ) {
|
1826 |
+
$retval = ! bp_core_get_root_option( 'bp-disable-avatar-uploads' );
|
1827 |
+
}
|
1828 |
+
|
1829 |
+
if ( bp_is_active( 'groups' ) ) {
|
1830 |
+
// Group creation
|
1831 |
+
if ( bp_is_group_create() && bp_is_group_creation_step( 'group-avatar' ) && 'crop-image' !== bp_get_avatar_admin_step() ) {
|
1832 |
+
$retval = ! bp_disable_group_avatar_uploads();
|
1833 |
+
|
1834 |
+
// Group Manage
|
1835 |
+
} elseif ( bp_is_group_admin_page() && bp_is_group_admin_screen( 'group-avatar' ) && 'crop-image' !== bp_get_avatar_admin_step() ) {
|
1836 |
+
$retval = ! bp_disable_group_avatar_uploads();
|
1837 |
+
}
|
1838 |
+
}
|
1839 |
+
|
1840 |
+
/**
|
1841 |
+
* Use this filter if you need to :
|
1842 |
+
* - Load the avatar UI for a component that is !groups or !user (return true regarding your conditions)
|
1843 |
+
* - Completely disable the avatar UI introduced in 2.3 (eg: __return_false())
|
1844 |
+
*
|
1845 |
+
* @since BuddyPress (2.3.0)
|
1846 |
+
*
|
1847 |
+
* @var bool whether to load the Avatar UI
|
1848 |
+
*/
|
1849 |
+
return apply_filters( 'bp_avatar_is_front_edit', $retval );
|
1850 |
+
}
|
1851 |
+
|
1852 |
+
/**
|
1853 |
+
* Checks whether the Webcam Avatar UI part should be loaded
|
1854 |
+
*
|
1855 |
+
* @since BuddyPress (2.3.0)
|
1856 |
+
*
|
1857 |
+
* @global $is_safari
|
1858 |
+
* @global $is_IE
|
1859 |
+
* @return bool True to load the Webcam Avatar UI part. False otherwise.
|
1860 |
+
*/
|
1861 |
+
function bp_avatar_use_webcam() {
|
1862 |
+
global $is_safari, $is_IE;
|
1863 |
+
|
1864 |
+
/**
|
1865 |
+
* Do not use the webcam feature for mobile devices
|
1866 |
+
* to avoid possible confusions.
|
1867 |
+
*/
|
1868 |
+
if ( wp_is_mobile() ) {
|
1869 |
+
return false;
|
1870 |
+
}
|
1871 |
+
|
1872 |
+
/**
|
1873 |
+
* Bail when the browser does not support getUserMedia.
|
1874 |
+
*
|
1875 |
+
* @see http://caniuse.com/#feat=stream
|
1876 |
+
*/
|
1877 |
+
if ( $is_safari || $is_IE ) {
|
1878 |
+
return false;
|
1879 |
+
}
|
1880 |
+
|
1881 |
+
/**
|
1882 |
+
* Use this filter if you need to disable the webcam capture feature
|
1883 |
+
* by returning false.
|
1884 |
+
*
|
1885 |
+
* @since BuddyPress (2.3.0)
|
1886 |
+
*
|
1887 |
+
* @var bool whether to load Webcam Avatar UI part
|
1888 |
+
*/
|
1889 |
+
return apply_filters( 'bp_avatar_use_webcam', true );
|
1890 |
+
}
|
1891 |
+
|
1892 |
+
/**
|
1893 |
+
* Template function to load the Avatar UI javascript templates
|
1894 |
+
*
|
1895 |
+
* @since BuddyPress (2.3.0)
|
1896 |
+
*/
|
1897 |
+
function bp_avatar_get_templates() {
|
1898 |
+
if ( ! bp_avatar_is_front_edit() ) {
|
1899 |
+
return;
|
1900 |
+
}
|
1901 |
+
|
1902 |
+
bp_attachments_get_template_part( 'avatars/index' );
|
1903 |
+
}
|
1904 |
+
|
1905 |
+
/**
|
1906 |
+
* Trick to check if the theme's BuddyPress templates are up to date
|
1907 |
+
*
|
1908 |
+
* If the "avatar templates" are not including the new template tag, this will
|
1909 |
+
* help users to get the avatar UI.
|
1910 |
+
*
|
1911 |
+
* @since BuddyPress (2.3.0)
|
1912 |
+
*/
|
1913 |
+
function bp_avatar_template_check() {
|
1914 |
+
if ( ! bp_avatar_is_front_edit() ) {
|
1915 |
+
return;
|
1916 |
+
}
|
1917 |
+
|
1918 |
+
if ( ! did_action( 'bp_attachments_avatar_check_template' ) ) {
|
1919 |
+
bp_attachments_get_template_part( 'avatars/index' );
|
1920 |
+
}
|
1921 |
+
}
|
bp-core/bp-core-buddybar.php
CHANGED
@@ -14,8 +14,6 @@ defined( 'ABSPATH' ) || exit;
|
|
14 |
Â
/**
|
15 |
Â
* Add an item to the main BuddyPress navigation array.
|
16 |
Â
*
|
17 |
-
* @global BuddyPress $bp The one true BuddyPress instance.
|
18 |
-
*
|
19 |
Â
* @param array $args {
|
20 |
Â
* Array describing the new nav item.
|
21 |
Â
* @type string $name Display name for the nav item.
|
@@ -38,7 +36,7 @@ defined( 'ABSPATH' ) || exit;
|
|
38 |
Â
* @return bool|null Returns false on failure.
|
39 |
Â
*/
|
40 |
Â
function bp_core_new_nav_item( $args = '' ) {
|
41 |
-
|
42 |
Â
|
43 |
Â
$defaults = array(
|
44 |
Â
'name' => false, // Display name for the nav item
|
@@ -108,19 +106,36 @@ function bp_core_new_nav_item( $args = '' ) {
|
|
108 |
Â
}
|
109 |
Â
|
110 |
Â
if ( !empty( $default_subnav_slug ) ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
111 |
Â
$bp->current_action = apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r );
|
112 |
Â
}
|
113 |
Â
}
|
114 |
Â
}
|
115 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
116 |
Â
do_action( 'bp_core_new_nav_item', $r, $args, $defaults );
|
117 |
Â
}
|
118 |
Â
|
119 |
Â
/**
|
120 |
Â
* Modify the default subnav item that loads when a top level nav item is clicked.
|
121 |
Â
*
|
122 |
-
* @global BuddyPress $bp The one true BuddyPress instance.
|
123 |
-
*
|
124 |
Â
* @param array $args {
|
125 |
Â
* @type string $parent_slug The slug of the nav item whose default is
|
126 |
Â
* being changed.
|
@@ -130,7 +145,7 @@ function bp_core_new_nav_item( $args = '' ) {
|
|
130 |
Â
* }
|
131 |
Â
*/
|
132 |
Â
function bp_core_new_nav_default( $args = '' ) {
|
133 |
-
|
134 |
Â
|
135 |
Â
$defaults = array(
|
136 |
Â
'parent_slug' => false, // Slug of the parent
|
@@ -195,12 +210,10 @@ function bp_core_new_nav_default( $args = '' ) {
|
|
195 |
Â
* The sorting is split into a separate function because it can only happen
|
196 |
Â
* after all plugins have had a chance to register their navigation items.
|
197 |
Â
*
|
198 |
-
* @global BuddyPress $bp The one true BuddyPress instance
|
199 |
-
*
|
200 |
Â
* @return bool|null Returns false on failure.
|
201 |
Â
*/
|
202 |
Â
function bp_core_sort_nav_items() {
|
203 |
-
|
204 |
Â
|
205 |
Â
if ( empty( $bp->bp_nav ) || !is_array( $bp->bp_nav ) )
|
206 |
Â
return false;
|
@@ -229,8 +242,6 @@ add_action( 'admin_head', 'bp_core_sort_nav_items' );
|
|
229 |
Â
/**
|
230 |
Â
* Add a subnav item to the BuddyPress navigation.
|
231 |
Â
*
|
232 |
-
* @global BuddyPress $bp The one true BuddyPress instance.
|
233 |
-
*
|
234 |
Â
* @param array $args {
|
235 |
Â
* Array describing the new subnav item.
|
236 |
Â
* @type string $name Display name for the subnav item.
|
@@ -260,7 +271,7 @@ add_action( 'admin_head', 'bp_core_sort_nav_items' );
|
|
260 |
Â
* @return bool|null Returns false on failure.
|
261 |
Â
*/
|
262 |
Â
function bp_core_new_subnav_item( $args = '' ) {
|
263 |
-
|
264 |
Â
|
265 |
Â
$r = wp_parse_args( $args, array(
|
266 |
Â
'name' => false, // Display name for the nav item
|
@@ -285,11 +296,11 @@ function bp_core_new_subnav_item( $args = '' ) {
|
|
285 |
Â
|
286 |
Â
// Link was not forced, so create one
|
287 |
Â
if ( empty( $link ) ) {
|
288 |
-
$link = $parent_url . $slug;
|
289 |
Â
|
290 |
Â
// If this sub item is the default for its parent, skip the slug
|
291 |
Â
if ( ! empty( $bp->bp_nav[$parent_slug]['default_subnav_slug'] ) && $slug == $bp->bp_nav[$parent_slug]['default_subnav_slug'] ) {
|
292 |
-
$link = $parent_url;
|
293 |
Â
}
|
294 |
Â
}
|
295 |
Â
|
@@ -302,7 +313,7 @@ function bp_core_new_subnav_item( $args = '' ) {
|
|
302 |
Â
|
303 |
Â
$subnav_item = array(
|
304 |
Â
'name' => $name,
|
305 |
-
'link' =>
|
306 |
Â
'slug' => $slug,
|
307 |
Â
'css_id' => $item_css_id,
|
308 |
Â
'position' => $position,
|
@@ -441,12 +452,10 @@ function bp_core_maybe_hook_new_subnav_screen_function( $subnav_item ) {
|
|
441 |
Â
/**
|
442 |
Â
* Sort all subnavigation arrays.
|
443 |
Â
*
|
444 |
-
* @global BuddyPress $bp The one true BuddyPress instance
|
445 |
-
*
|
446 |
Â
* @return bool|null Returns false on failure.
|
447 |
Â
*/
|
448 |
Â
function bp_core_sort_subnav_items() {
|
449 |
-
|
450 |
Â
|
451 |
Â
if ( empty( $bp->bp_options_nav ) || !is_array( $bp->bp_options_nav ) )
|
452 |
Â
return false;
|
@@ -486,13 +495,22 @@ add_action( 'admin_head', 'bp_core_sort_subnav_items' );
|
|
486 |
Â
* items; false otherwise.
|
487 |
Â
*/
|
488 |
Â
function bp_nav_item_has_subnav( $nav_item = '' ) {
|
489 |
-
|
490 |
Â
|
491 |
Â
if ( !$nav_item )
|
492 |
Â
$nav_item = bp_current_component();
|
493 |
Â
|
494 |
Â
$has_subnav = isset( $bp->bp_options_nav[$nav_item] ) && count( $bp->bp_options_nav[$nav_item] ) > 0;
|
495 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
496 |
Â
return apply_filters( 'bp_nav_item_has_subnav', $has_subnav, $nav_item );
|
497 |
Â
}
|
498 |
Â
|
@@ -503,7 +521,7 @@ function bp_nav_item_has_subnav( $nav_item = '' ) {
|
|
503 |
Â
* @param bool Returns false on failure, ie if the nav item can't be found.
|
504 |
Â
*/
|
505 |
Â
function bp_core_remove_nav_item( $parent_id ) {
|
506 |
-
|
507 |
Â
|
508 |
Â
// Unset subnav items for this nav item
|
509 |
Â
if ( isset( $bp->bp_options_nav[$parent_id] ) && is_array( $bp->bp_options_nav[$parent_id] ) ) {
|
@@ -532,9 +550,11 @@ function bp_core_remove_nav_item( $parent_id ) {
|
|
532 |
Â
* @param string $slug The slug of the subnav item to be removed.
|
533 |
Â
*/
|
534 |
Â
function bp_core_remove_subnav_item( $parent_id, $slug ) {
|
535 |
-
|
536 |
Â
|
537 |
-
$screen_function = isset( $bp->bp_options_nav[$parent_id][$slug]['screen_function'] )
|
Â
|
|
Â
|
|
538 |
Â
|
539 |
Â
if ( ! empty( $screen_function ) ) {
|
540 |
Â
// Remove our screen hook if screen function is callable
|
@@ -552,12 +572,10 @@ function bp_core_remove_subnav_item( $parent_id, $slug ) {
|
|
552 |
Â
/**
|
553 |
Â
* Clear all subnav items from a specific nav item.
|
554 |
Â
*
|
555 |
-
* @global BuddyPress $bp The one true BuddyPress instance.
|
556 |
-
*
|
557 |
Â
* @param string $parent_slug The slug of the parent navigation item.
|
558 |
Â
*/
|
559 |
Â
function bp_core_reset_subnav_items( $parent_slug ) {
|
560 |
-
|
561 |
Â
|
562 |
Â
unset( $bp->bp_options_nav[$parent_slug] );
|
563 |
Â
}
|
14 |
Â
/**
|
15 |
Â
* Add an item to the main BuddyPress navigation array.
|
16 |
Â
*
|
Â
|
|
Â
|
|
17 |
Â
* @param array $args {
|
18 |
Â
* Array describing the new nav item.
|
19 |
Â
* @type string $name Display name for the nav item.
|
36 |
Â
* @return bool|null Returns false on failure.
|
37 |
Â
*/
|
38 |
Â
function bp_core_new_nav_item( $args = '' ) {
|
39 |
+
$bp = buddypress();
|
40 |
Â
|
41 |
Â
$defaults = array(
|
42 |
Â
'name' => false, // Display name for the nav item
|
106 |
Â
}
|
107 |
Â
|
108 |
Â
if ( !empty( $default_subnav_slug ) ) {
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Filters the default component subnav item.
|
112 |
+
*
|
113 |
+
* @since BuddyPress (1.5.0)
|
114 |
+
*
|
115 |
+
* @param string $default_subnav_slug The slug of the default subnav item
|
116 |
+
* to select when clicked.
|
117 |
+
* @param array $r Parsed arguments for the nav item.
|
118 |
+
*/
|
119 |
Â
$bp->current_action = apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r );
|
120 |
Â
}
|
121 |
Â
}
|
122 |
Â
}
|
123 |
Â
|
124 |
+
/**
|
125 |
+
* Fires after adding an item to the main BuddyPress navigation array.
|
126 |
+
*
|
127 |
+
* @since BuddyPress (1.5.0)
|
128 |
+
*
|
129 |
+
* @param array $r Parsed arguments for the nav item.
|
130 |
+
* @param array $args Originally passed in arguments for the nav item.
|
131 |
+
* @param array $defaults Default arguments for a nav item.
|
132 |
+
*/
|
133 |
Â
do_action( 'bp_core_new_nav_item', $r, $args, $defaults );
|
134 |
Â
}
|
135 |
Â
|
136 |
Â
/**
|
137 |
Â
* Modify the default subnav item that loads when a top level nav item is clicked.
|
138 |
Â
*
|
Â
|
|
Â
|
|
139 |
Â
* @param array $args {
|
140 |
Â
* @type string $parent_slug The slug of the nav item whose default is
|
141 |
Â
* being changed.
|
145 |
Â
* }
|
146 |
Â
*/
|
147 |
Â
function bp_core_new_nav_default( $args = '' ) {
|
148 |
+
$bp = buddypress();
|
149 |
Â
|
150 |
Â
$defaults = array(
|
151 |
Â
'parent_slug' => false, // Slug of the parent
|
210 |
Â
* The sorting is split into a separate function because it can only happen
|
211 |
Â
* after all plugins have had a chance to register their navigation items.
|
212 |
Â
*
|
Â
|
|
Â
|
|
213 |
Â
* @return bool|null Returns false on failure.
|
214 |
Â
*/
|
215 |
Â
function bp_core_sort_nav_items() {
|
216 |
+
$bp = buddypress();
|
217 |
Â
|
218 |
Â
if ( empty( $bp->bp_nav ) || !is_array( $bp->bp_nav ) )
|
219 |
Â
return false;
|
242 |
Â
/**
|
243 |
Â
* Add a subnav item to the BuddyPress navigation.
|
244 |
Â
*
|
Â
|
|
Â
|
|
245 |
Â
* @param array $args {
|
246 |
Â
* Array describing the new subnav item.
|
247 |
Â
* @type string $name Display name for the subnav item.
|
271 |
Â
* @return bool|null Returns false on failure.
|
272 |
Â
*/
|
273 |
Â
function bp_core_new_subnav_item( $args = '' ) {
|
274 |
+
$bp = buddypress();
|
275 |
Â
|
276 |
Â
$r = wp_parse_args( $args, array(
|
277 |
Â
'name' => false, // Display name for the nav item
|
296 |
Â
|
297 |
Â
// Link was not forced, so create one
|
298 |
Â
if ( empty( $link ) ) {
|
299 |
+
$link = trailingslashit( $parent_url . $slug );
|
300 |
Â
|
301 |
Â
// If this sub item is the default for its parent, skip the slug
|
302 |
Â
if ( ! empty( $bp->bp_nav[$parent_slug]['default_subnav_slug'] ) && $slug == $bp->bp_nav[$parent_slug]['default_subnav_slug'] ) {
|
303 |
+
$link = trailingslashit( $parent_url );
|
304 |
Â
}
|
305 |
Â
}
|
306 |
Â
|
313 |
Â
|
314 |
Â
$subnav_item = array(
|
315 |
Â
'name' => $name,
|
316 |
+
'link' => $link,
|
317 |
Â
'slug' => $slug,
|
318 |
Â
'css_id' => $item_css_id,
|
319 |
Â
'position' => $position,
|
452 |
Â
/**
|
453 |
Â
* Sort all subnavigation arrays.
|
454 |
Â
*
|
Â
|
|
Â
|
|
455 |
Â
* @return bool|null Returns false on failure.
|
456 |
Â
*/
|
457 |
Â
function bp_core_sort_subnav_items() {
|
458 |
+
$bp = buddypress();
|
459 |
Â
|
460 |
Â
if ( empty( $bp->bp_options_nav ) || !is_array( $bp->bp_options_nav ) )
|
461 |
Â
return false;
|
495 |
Â
* items; false otherwise.
|
496 |
Â
*/
|
497 |
Â
function bp_nav_item_has_subnav( $nav_item = '' ) {
|
498 |
+
$bp = buddypress();
|
499 |
Â
|
500 |
Â
if ( !$nav_item )
|
501 |
Â
$nav_item = bp_current_component();
|
502 |
Â
|
503 |
Â
$has_subnav = isset( $bp->bp_options_nav[$nav_item] ) && count( $bp->bp_options_nav[$nav_item] ) > 0;
|
504 |
Â
|
505 |
+
/**
|
506 |
+
* Filters whether or not a given nav item has subnav items.
|
507 |
+
*
|
508 |
+
* @since BuddyPress (1.5.0)
|
509 |
+
*
|
510 |
+
* @param bool $has_subnav Whether or not there is any subnav items.
|
511 |
+
* @param string $nav_item The slug of the top-level nav item whose subnav
|
512 |
+
* items you're checking.
|
513 |
+
*/
|
514 |
Â
return apply_filters( 'bp_nav_item_has_subnav', $has_subnav, $nav_item );
|
515 |
Â
}
|
516 |
Â
|
521 |
Â
* @param bool Returns false on failure, ie if the nav item can't be found.
|
522 |
Â
*/
|
523 |
Â
function bp_core_remove_nav_item( $parent_id ) {
|
524 |
+
$bp = buddypress();
|
525 |
Â
|
526 |
Â
// Unset subnav items for this nav item
|
527 |
Â
if ( isset( $bp->bp_options_nav[$parent_id] ) && is_array( $bp->bp_options_nav[$parent_id] ) ) {
|
550 |
Â
* @param string $slug The slug of the subnav item to be removed.
|
551 |
Â
*/
|
552 |
Â
function bp_core_remove_subnav_item( $parent_id, $slug ) {
|
553 |
+
$bp = buddypress();
|
554 |
Â
|
555 |
+
$screen_function = isset( $bp->bp_options_nav[$parent_id][$slug]['screen_function'] )
|
556 |
+
? $bp->bp_options_nav[$parent_id][$slug]['screen_function']
|
557 |
+
: false;
|
558 |
Â
|
559 |
Â
if ( ! empty( $screen_function ) ) {
|
560 |
Â
// Remove our screen hook if screen function is callable
|
572 |
Â
/**
|
573 |
Â
* Clear all subnav items from a specific nav item.
|
574 |
Â
*
|
Â
|
|
Â
|
|
575 |
Â
* @param string $parent_slug The slug of the parent navigation item.
|
576 |
Â
*/
|
577 |
Â
function bp_core_reset_subnav_items( $parent_slug ) {
|
578 |
+
$bp = buddypress();
|
579 |
Â
|
580 |
Â
unset( $bp->bp_options_nav[$parent_slug] );
|
581 |
Â
}
|
bp-core/bp-core-cache.php
CHANGED
@@ -21,6 +21,12 @@ function bp_core_clear_cache() {
|
|
21 |
Â
global $cache_path;
|
22 |
Â
|
23 |
Â
if ( function_exists( 'prune_super_cache' ) ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
do_action( 'bp_core_clear_cache' );
|
25 |
Â
return prune_super_cache( $cache_path, true );
|
26 |
Â
}
|
21 |
Â
global $cache_path;
|
22 |
Â
|
23 |
Â
if ( function_exists( 'prune_super_cache' ) ) {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Fires before the pruning of WP Super Cache.
|
27 |
+
*
|
28 |
+
* @since BuddyPress (1.0.0)
|
29 |
+
*/
|
30 |
Â
do_action( 'bp_core_clear_cache' );
|
31 |
Â
return prune_super_cache( $cache_path, true );
|
32 |
Â
}
|
bp-core/bp-core-caps.php
CHANGED
@@ -30,10 +30,23 @@ function bp_get_current_blog_roles() {
|
|
30 |
Â
? $wp_roles->roles
|
31 |
Â
: array();
|
32 |
Â
|
33 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
34 |
Â
$roles = apply_filters( 'editable_roles', $roles );
|
35 |
Â
|
36 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
37 |
Â
return apply_filters( 'bp_get_current_blog_roles', $roles, $wp_roles );
|
38 |
Â
}
|
39 |
Â
|
@@ -62,6 +75,13 @@ function bp_add_caps() {
|
|
62 |
Â
}
|
63 |
Â
}
|
64 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
65 |
Â
do_action( 'bp_add_caps' );
|
66 |
Â
}
|
67 |
Â
|
@@ -90,6 +110,13 @@ function bp_remove_caps() {
|
|
90 |
Â
}
|
91 |
Â
}
|
92 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
93 |
Â
do_action( 'bp_remove_caps' );
|
94 |
Â
}
|
95 |
Â
|
@@ -110,6 +137,17 @@ function bp_remove_caps() {
|
|
110 |
Â
* @return array Actual capabilities for meta capability. See {@link WP_User::has_cap()}.
|
111 |
Â
*/
|
112 |
Â
function bp_map_meta_caps( $caps, $cap, $user_id, $args ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
113 |
Â
return apply_filters( 'bp_map_meta_caps', $caps, $cap, $user_id, $args );
|
114 |
Â
}
|
115 |
Â
|
@@ -127,6 +165,13 @@ function bp_get_community_caps() {
|
|
127 |
Â
// Forum meta caps
|
128 |
Â
$caps = array();
|
129 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
130 |
Â
return apply_filters( 'bp_get_community_caps', $caps );
|
131 |
Â
}
|
132 |
Â
|
@@ -163,6 +208,14 @@ function bp_get_caps_for_role( $role = '' ) {
|
|
163 |
Â
break;
|
164 |
Â
}
|
165 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
166 |
Â
return apply_filters( 'bp_get_caps_for_role', $caps, $role );
|
167 |
Â
}
|
168 |
Â
|
@@ -220,6 +273,15 @@ function bp_current_user_can( $capability, $blog_id = 0 ) {
|
|
220 |
Â
|
221 |
Â
$retval = current_user_can_for_blog( $blog_id, $capability );
|
222 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
223 |
Â
return (bool) apply_filters( 'bp_current_user_can', $retval, $capability, $blog_id );
|
224 |
Â
}
|
225 |
Â
|
30 |
Â
? $wp_roles->roles
|
31 |
Â
: array();
|
32 |
Â
|
33 |
+
/**
|
34 |
+
* Filters the list of editable roles.
|
35 |
+
*
|
36 |
+
* @since BuddyPress (2.1.0)
|
37 |
+
*
|
38 |
+
* @param array $roles List of roles.
|
39 |
+
*/
|
40 |
Â
$roles = apply_filters( 'editable_roles', $roles );
|
41 |
Â
|
42 |
+
/**
|
43 |
+
* Filters the array of roles from the currently loaded blog.
|
44 |
+
*
|
45 |
+
* @since BuddyPress (2.1.0)
|
46 |
+
*
|
47 |
+
* @param array $roles Available roles.
|
48 |
+
* @param WP_Roles $wp_roles Object of WordPress roles.
|
49 |
+
*/
|
50 |
Â
return apply_filters( 'bp_get_current_blog_roles', $roles, $wp_roles );
|
51 |
Â
}
|
52 |
Â
|
75 |
Â
}
|
76 |
Â
}
|
77 |
Â
|
78 |
+
/**
|
79 |
+
* Fires after the addition of capabilities to WordPress user roles.
|
80 |
+
*
|
81 |
+
* This is called on plugin activation.
|
82 |
+
*
|
83 |
+
* @since BuddyPress (1.6.0)
|
84 |
+
*/
|
85 |
Â
do_action( 'bp_add_caps' );
|
86 |
Â
}
|
87 |
Â
|
110 |
Â
}
|
111 |
Â
}
|
112 |
Â
|
113 |
+
/**
|
114 |
+
* Fires after the removal of capabilities from WordPress user roles.
|
115 |
+
*
|
116 |
+
* This is called on plugin deactivation.
|
117 |
+
*
|
118 |
+
* @since BuddyPress (1.6.0)
|
119 |
+
*/
|
120 |
Â
do_action( 'bp_remove_caps' );
|
121 |
Â
}
|
122 |
Â
|
137 |
Â
* @return array Actual capabilities for meta capability. See {@link WP_User::has_cap()}.
|
138 |
Â
*/
|
139 |
Â
function bp_map_meta_caps( $caps, $cap, $user_id, $args ) {
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Filters the community caps mapping to be built in WordPress caps.
|
143 |
+
*
|
144 |
+
* @since BuddyPress (1.6.0)
|
145 |
+
*
|
146 |
+
* @param array $caps Returns the user's actual capabilities.
|
147 |
+
* @param string $cap Capability name.
|
148 |
+
* @param int $user_id The user ID.
|
149 |
+
* @param array $args Adds the context to the cap. Typically the object ID.
|
150 |
+
*/
|
151 |
Â
return apply_filters( 'bp_map_meta_caps', $caps, $cap, $user_id, $args );
|
152 |
Â
}
|
153 |
Â
|
165 |
Â
// Forum meta caps
|
166 |
Â
$caps = array();
|
167 |
Â
|
168 |
+
/**
|
169 |
+
* Filters community capabilities.
|
170 |
+
*
|
171 |
+
* @since BuddyPress (1.6.0)
|
172 |
+
*
|
173 |
+
* @param array $caps Array of capabilities to add. Empty by default.
|
174 |
+
*/
|
175 |
Â
return apply_filters( 'bp_get_community_caps', $caps );
|
176 |
Â
}
|
177 |
Â
|
208 |
Â
break;
|
209 |
Â
}
|
210 |
Â
|
211 |
+
/**
|
212 |
+
* Filters the array of capabilities based on the role that is being requested.
|
213 |
+
*
|
214 |
+
* @since BuddyPress (1.6.0)
|
215 |
+
*
|
216 |
+
* @param array $caps Array of capabilities to return.
|
217 |
+
* @param string $role The role currently being loaded.
|
218 |
+
*/
|
219 |
Â
return apply_filters( 'bp_get_caps_for_role', $caps, $role );
|
220 |
Â
}
|
221 |
Â
|
273 |
Â
|
274 |
Â
$retval = current_user_can_for_blog( $blog_id, $capability );
|
275 |
Â
|
276 |
+
/**
|
277 |
+
* Filters whether or not the current user has a given capability.
|
278 |
+
*
|
279 |
+
* @since BuddyPress (1.6.0)
|
280 |
+
*
|
281 |
+
* @param bool $retval Whether or not the current user has the capability.
|
282 |
+
* @param string $capability The capability being checked for.
|
283 |
+
* @param int $blog_id Blog ID. Defaults to the BP root blog.
|
284 |
+
*/
|
285 |
Â
return (bool) apply_filters( 'bp_current_user_can', $retval, $capability, $blog_id );
|
286 |
Â
}
|
287 |
Â
|
bp-core/bp-core-catchuri.php
CHANGED
@@ -33,12 +33,14 @@ defined( 'ABSPATH' ) || exit;
|
|
33 |
Â
* @since BuddyPress (1.0.0)
|
34 |
Â
*/
|
35 |
Â
function bp_core_set_uri_globals() {
|
36 |
-
global $
|
37 |
Â
|
38 |
Â
// Don't catch URIs on non-root blogs unless multiblog mode is on
|
39 |
Â
if ( !bp_is_root_blog() && !bp_is_multiblog_mode() )
|
40 |
Â
return false;
|
41 |
Â
|
Â
|
|
Â
|
|
42 |
Â
// Define local variables
|
43 |
Â
$root_profile = $match = false;
|
44 |
Â
$key_slugs = $matches = $uri_chunks = array();
|
@@ -49,11 +51,17 @@ function bp_core_set_uri_globals() {
|
|
49 |
Â
|
50 |
Â
// Ajax or not?
|
51 |
Â
if ( defined( 'DOING_AJAX' ) && DOING_AJAX || strpos( $_SERVER['REQUEST_URI'], 'wp-load.php' ) )
|
52 |
-
$path =
|
53 |
Â
else
|
54 |
Â
$path = esc_url( $_SERVER['REQUEST_URI'] );
|
55 |
Â
|
56 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
57 |
Â
$path = apply_filters( 'bp_uri', $path );
|
58 |
Â
|
59 |
Â
// Take GET variables off the URL to avoid problems
|
@@ -250,37 +258,54 @@ function bp_core_set_uri_globals() {
|
|
250 |
Â
// If members component, do more work to find the actual component
|
251 |
Â
if ( 'members' == $match->key ) {
|
252 |
Â
|
253 |
-
|
254 |
-
if ( !empty( $bp_uri[$uri_offset + 1] ) ) {
|
Â
|
|
Â
|
|
255 |
Â
|
Â
|
|
Â
|
|
256 |
Â
// Switch the displayed_user based on compatibility mode
|
257 |
Â
if ( bp_is_username_compatibility_mode() ) {
|
258 |
-
$bp->displayed_user->id = (int) bp_core_get_userid( urldecode( $
|
259 |
Â
} else {
|
260 |
-
$bp->displayed_user->id = (int) bp_core_get_userid_from_nicename(
|
261 |
Â
}
|
Â
|
|
262 |
Â
|
263 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
264 |
Â
|
265 |
-
|
266 |
-
$bp->
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
267 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
268 |
Â
bp_do_404();
|
269 |
Â
return;
|
270 |
Â
}
|
Â
|
|
271 |
Â
|
272 |
-
|
273 |
-
|
274 |
-
if ( bp_displayed_user_id() && bp_is_user_spammer( bp_displayed_user_id() ) ) {
|
275 |
-
if ( bp_current_user_can( 'bp_moderate' ) ) {
|
276 |
-
bp_core_add_message( __( 'This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress' ), 'warning' );
|
277 |
-
} else {
|
278 |
-
bp_do_404();
|
279 |
-
return;
|
280 |
-
}
|
281 |
-
}
|
282 |
-
|
283 |
-
// Bump the offset
|
284 |
Â
if ( isset( $bp_uri[$uri_offset + 2] ) ) {
|
285 |
Â
$bp_uri = array_merge( array(), array_slice( $bp_uri, $uri_offset + 2 ) );
|
286 |
Â
$bp->current_component = $bp_uri[0];
|
@@ -325,6 +350,13 @@ function bp_core_enable_root_profiles() {
|
|
325 |
Â
if ( defined( 'BP_ENABLE_ROOT_PROFILES' ) && ( true == BP_ENABLE_ROOT_PROFILES ) )
|
326 |
Â
$retval = true;
|
327 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
328 |
Â
return apply_filters( 'bp_core_enable_root_profiles', $retval );
|
329 |
Â
}
|
330 |
Â
|
@@ -368,7 +400,16 @@ function bp_core_load_template( $templates ) {
|
|
368 |
Â
$template = '';
|
369 |
Â
}
|
370 |
Â
|
371 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
372 |
Â
$located_template = apply_filters( 'bp_located_template', $template, $filtered_templates );
|
373 |
Â
if ( !empty( $located_template ) ) {
|
374 |
Â
// Template was located, lets set this as a valid page and not a 404.
|
@@ -377,10 +418,31 @@ function bp_core_load_template( $templates ) {
|
|
377 |
Â
$wp_query->is_singular = true;
|
378 |
Â
$wp_query->is_404 = false;
|
379 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
380 |
Â
do_action( 'bp_core_pre_load_template', $located_template );
|
381 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
382 |
Â
load_template( apply_filters( 'bp_load_template', $located_template ) );
|
383 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
384 |
Â
do_action( 'bp_core_post_load_template', $located_template );
|
385 |
Â
|
386 |
Â
// Kill any other output after this.
|
@@ -399,6 +461,11 @@ function bp_core_load_template( $templates ) {
|
|
399 |
Â
$wp_query->is_404 = false;
|
400 |
Â
}
|
401 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
402 |
Â
do_action( 'bp_setup_theme_compat' );
|
403 |
Â
}
|
404 |
Â
}
|
@@ -408,6 +475,14 @@ function bp_core_load_template( $templates ) {
|
|
408 |
Â
*/
|
409 |
Â
function bp_core_catch_profile_uri() {
|
410 |
Â
if ( !bp_is_active( 'xprofile' ) ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
411 |
Â
bp_core_load_template( apply_filters( 'bp_core_template_display_profile', 'members/single/home' ) );
|
412 |
Â
}
|
413 |
Â
}
|
@@ -418,7 +493,9 @@ function bp_core_catch_profile_uri() {
|
|
418 |
Â
* @since BuddyPress (1.5.0)
|
419 |
Â
*/
|
420 |
Â
function bp_core_catch_no_access() {
|
421 |
-
global $
|
Â
|
|
Â
|
|
422 |
Â
|
423 |
Â
// If coming from bp_core_redirect() and $bp_no_status_set is true,
|
424 |
Â
// we are redirecting to an accessible page so skip this check.
|
@@ -468,6 +545,14 @@ function bp_core_no_access( $args = '' ) {
|
|
468 |
Â
);
|
469 |
Â
|
470 |
Â
$r = wp_parse_args( $args, $defaults );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
471 |
Â
$r = apply_filters( 'bp_core_no_access', $r );
|
472 |
Â
extract( $r, EXTR_SKIP );
|
473 |
Â
|
@@ -525,6 +610,14 @@ function bp_core_no_access( $args = '' ) {
|
|
525 |
Â
function bp_core_no_access_wp_login_error() {
|
526 |
Â
global $error;
|
527 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
528 |
Â
$error = apply_filters( 'bp_wp_login_error', __( 'You must log in to access the page you requested.', 'buddypress' ), $_REQUEST['redirect_to'] );
|
529 |
Â
|
530 |
Â
// shake shake shake!
|
@@ -550,8 +643,14 @@ add_action( 'login_form_bpnoaccess', 'bp_core_no_access_wp_login_error' );
|
|
550 |
Â
* @uses bp_get_requested_url()
|
551 |
Â
*/
|
552 |
Â
function bp_redirect_canonical() {
|
553 |
-
global $bp;
|
554 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
555 |
Â
if ( !bp_is_blog_page() && apply_filters( 'bp_do_redirect_canonical', true ) ) {
|
556 |
Â
// If this is a POST request, don't do a canonical redirect.
|
557 |
Â
// This is for backward compatibility with plugins that submit form requests to
|
@@ -574,6 +673,8 @@ function bp_redirect_canonical() {
|
|
574 |
Â
// Only redirect if we've assembled a URL different from the request
|
575 |
Â
if ( $canonical_url !== $req_url_clean ) {
|
576 |
Â
|
Â
|
|
Â
|
|
577 |
Â
// Template messages have been deleted from the cookie by this point, so
|
578 |
Â
// they must be readded before redirecting
|
579 |
Â
if ( isset( $bp->template_message ) ) {
|
@@ -619,13 +720,14 @@ function bp_rel_canonical() {
|
|
619 |
Â
* @return string Canonical URL for the current page.
|
620 |
Â
*/
|
621 |
Â
function bp_get_canonical_url( $args = array() ) {
|
622 |
-
global $bp;
|
623 |
Â
|
624 |
Â
// For non-BP content, return the requested url, and let WP do the work
|
625 |
Â
if ( bp_is_blog_page() ) {
|
626 |
Â
return bp_get_requested_url();
|
627 |
Â
}
|
628 |
Â
|
Â
|
|
Â
|
|
629 |
Â
$defaults = array(
|
630 |
Â
'include_query_args' => false // Include URL arguments, eg ?foo=bar&foo2=bar2
|
631 |
Â
);
|
@@ -649,7 +751,15 @@ function bp_get_canonical_url( $args = array() ) {
|
|
649 |
Â
// and the current user is logged in. In this case we send to
|
650 |
Â
// the members directory to avoid redirect loops
|
651 |
Â
} elseif ( bp_is_register_page() && 'register' == $front_page_component && is_user_logged_in() ) {
|
652 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
653 |
Â
}
|
654 |
Â
}
|
655 |
Â
|
@@ -690,6 +800,14 @@ function bp_get_canonical_url( $args = array() ) {
|
|
690 |
Â
$canonical_url = array_pop( $canonical_url );
|
691 |
Â
}
|
692 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
693 |
Â
return apply_filters( 'bp_get_canonical_url', $canonical_url, $args );
|
694 |
Â
}
|
695 |
Â
|
@@ -701,13 +819,20 @@ function bp_get_canonical_url( $args = array() ) {
|
|
701 |
Â
* @return string Requested URL string.
|
702 |
Â
*/
|
703 |
Â
function bp_get_requested_url() {
|
704 |
-
|
705 |
Â
|
706 |
Â
if ( empty( $bp->canonical_stack['requested_url'] ) ) {
|
707 |
Â
$bp->canonical_stack['requested_url'] = is_ssl() ? 'https://' : 'http://';
|
708 |
Â
$bp->canonical_stack['requested_url'] .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
709 |
Â
}
|
710 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
711 |
Â
return apply_filters( 'bp_get_requested_url', $bp->canonical_stack['requested_url'] );
|
712 |
Â
}
|
713 |
Â
|
@@ -754,8 +879,8 @@ add_action( 'bp_init', '_bp_maybe_remove_redirect_canonical' );
|
|
754 |
Â
*
|
755 |
Â
* @since BuddyPress (1.6.1)
|
756 |
Â
*
|
757 |
-
* @link
|
758 |
-
* @link
|
759 |
Â
*/
|
760 |
Â
function _bp_rehook_maybe_redirect_404() {
|
761 |
Â
if ( defined( 'NOBLOGREDIRECT' ) ) {
|
33 |
Â
* @since BuddyPress (1.0.0)
|
34 |
Â
*/
|
35 |
Â
function bp_core_set_uri_globals() {
|
36 |
+
global $current_blog, $wp_rewrite;
|
37 |
Â
|
38 |
Â
// Don't catch URIs on non-root blogs unless multiblog mode is on
|
39 |
Â
if ( !bp_is_root_blog() && !bp_is_multiblog_mode() )
|
40 |
Â
return false;
|
41 |
Â
|
42 |
+
$bp = buddypress();
|
43 |
+
|
44 |
Â
// Define local variables
|
45 |
Â
$root_profile = $match = false;
|
46 |
Â
$key_slugs = $matches = $uri_chunks = array();
|
51 |
Â
|
52 |
Â
// Ajax or not?
|
53 |
Â
if ( defined( 'DOING_AJAX' ) && DOING_AJAX || strpos( $_SERVER['REQUEST_URI'], 'wp-load.php' ) )
|
54 |
+
$path = bp_get_referer_path();
|
55 |
Â
else
|
56 |
Â
$path = esc_url( $_SERVER['REQUEST_URI'] );
|
57 |
Â
|
58 |
+
/**
|
59 |
+
* Filters the BuddyPress global URI path.
|
60 |
+
*
|
61 |
+
* @since BuddyPress (1.0.0)
|
62 |
+
*
|
63 |
+
* @param string $path Path to set.
|
64 |
+
*/
|
65 |
Â
$path = apply_filters( 'bp_uri', $path );
|
66 |
Â
|
67 |
Â
// Take GET variables off the URL to avoid problems
|
258 |
Â
// If members component, do more work to find the actual component
|
259 |
Â
if ( 'members' == $match->key ) {
|
260 |
Â
|
261 |
+
$after_member_slug = false;
|
262 |
+
if ( ! empty( $bp_uri[ $uri_offset + 1 ] ) ) {
|
263 |
+
$after_member_slug = $bp_uri[ $uri_offset + 1 ];
|
264 |
+
}
|
265 |
Â
|
266 |
+
// Are we viewing a specific user?
|
267 |
+
if ( $after_member_slug ) {
|
268 |
Â
// Switch the displayed_user based on compatibility mode
|
269 |
Â
if ( bp_is_username_compatibility_mode() ) {
|
270 |
+
$bp->displayed_user->id = (int) bp_core_get_userid( urldecode( $after_member_slug ) );
|
271 |
Â
} else {
|
272 |
+
$bp->displayed_user->id = (int) bp_core_get_userid_from_nicename( $after_member_slug );
|
273 |
Â
}
|
274 |
+
}
|
275 |
Â
|
276 |
+
// Is this a member type directory?
|
277 |
+
if ( ! bp_displayed_user_id() && $after_member_slug === apply_filters( 'bp_members_member_type_base', _x( 'type', 'member type URL base', 'buddypress' ) ) && ! empty( $bp_uri[ $uri_offset + 2 ] ) ) {
|
278 |
+
$matched_types = bp_get_member_types( array(
|
279 |
+
'has_directory' => true,
|
280 |
+
'directory_slug' => $bp_uri[ $uri_offset + 2 ],
|
281 |
+
) );
|
282 |
Â
|
283 |
+
if ( ! empty( $matched_types ) ) {
|
284 |
+
$bp->current_member_type = reset( $matched_types );
|
285 |
+
unset( $bp_uri[ $uri_offset + 1 ] );
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
+
// If the slug matches neither a member type nor a specific member, 404.
|
290 |
+
if ( ! bp_displayed_user_id() && ! bp_get_current_member_type() && $after_member_slug ) {
|
291 |
+
// Prevent components from loading their templates.
|
292 |
+
$bp->current_component = '';
|
293 |
+
bp_do_404();
|
294 |
+
return;
|
295 |
+
}
|
296 |
Â
|
297 |
+
// If the displayed user is marked as a spammer, 404 (unless logged-in user is a super admin)
|
298 |
+
if ( bp_displayed_user_id() && bp_is_user_spammer( bp_displayed_user_id() ) ) {
|
299 |
+
if ( bp_current_user_can( 'bp_moderate' ) ) {
|
300 |
+
bp_core_add_message( __( 'This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress' ), 'warning' );
|
301 |
+
} else {
|
302 |
Â
bp_do_404();
|
303 |
Â
return;
|
304 |
Â
}
|
305 |
+
}
|
306 |
Â
|
307 |
+
// Bump the offset.
|
308 |
+
if ( bp_displayed_user_id() ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
309 |
Â
if ( isset( $bp_uri[$uri_offset + 2] ) ) {
|
310 |
Â
$bp_uri = array_merge( array(), array_slice( $bp_uri, $uri_offset + 2 ) );
|
311 |
Â
$bp->current_component = $bp_uri[0];
|
350 |
Â
if ( defined( 'BP_ENABLE_ROOT_PROFILES' ) && ( true == BP_ENABLE_ROOT_PROFILES ) )
|
351 |
Â
$retval = true;
|
352 |
Â
|
353 |
+
/**
|
354 |
+
* Filters whether or not root profiles are enabled and allowed.
|
355 |
+
*
|
356 |
+
* @since BuddyPress (1.6.0)
|
357 |
+
*
|
358 |
+
* @param bool $retval Whether or not root profiles are available.
|
359 |
+
*/
|
360 |
Â
return apply_filters( 'bp_core_enable_root_profiles', $retval );
|
361 |
Â
}
|
362 |
Â
|
400 |
Â
$template = '';
|
401 |
Â
}
|
402 |
Â
|
403 |
+
/**
|
404 |
+
* Filters the template locations.
|
405 |
+
*
|
406 |
+
* Allows plugins to alter where the template files are located.
|
407 |
+
*
|
408 |
+
* @since BuddyPress (1.1.0)
|
409 |
+
*
|
410 |
+
* @param string $template Located template path.
|
411 |
+
* @param array $filtered_templates Array of templates to attempt to load.
|
412 |
+
*/
|
413 |
Â
$located_template = apply_filters( 'bp_located_template', $template, $filtered_templates );
|
414 |
Â
if ( !empty( $located_template ) ) {
|
415 |
Â
// Template was located, lets set this as a valid page and not a 404.
|
418 |
Â
$wp_query->is_singular = true;
|
419 |
Â
$wp_query->is_404 = false;
|
420 |
Â
|
421 |
+
/**
|
422 |
+
* Fires before the loading of a located template file.
|
423 |
+
*
|
424 |
+
* @since BuddyPress (1.6.0)
|
425 |
+
*
|
426 |
+
* @param string $located_template Template found to be loaded.
|
427 |
+
*/
|
428 |
Â
do_action( 'bp_core_pre_load_template', $located_template );
|
429 |
Â
|
430 |
+
/**
|
431 |
+
* Filters the selected template right before loading.
|
432 |
+
*
|
433 |
+
* @since BuddyPress (1.1.0)
|
434 |
+
*
|
435 |
+
* @param string $located_template Template found to be loaded.
|
436 |
+
*/
|
437 |
Â
load_template( apply_filters( 'bp_load_template', $located_template ) );
|
438 |
Â
|
439 |
+
/**
|
440 |
+
* Fires after the loading of a located template file.
|
441 |
+
*
|
442 |
+
* @since BuddyPress (1.6.0)
|
443 |
+
*
|
444 |
+
* @param string $located_template Template found that was loaded.
|
445 |
+
*/
|
446 |
Â
do_action( 'bp_core_post_load_template', $located_template );
|
447 |
Â
|
448 |
Â
// Kill any other output after this.
|
461 |
Â
$wp_query->is_404 = false;
|
462 |
Â
}
|
463 |
Â
|
464 |
+
/**
|
465 |
+
* Fires if there are no found templates to load and theme compat is needed.
|
466 |
+
*
|
467 |
+
* @since BuddyPress (1.7.0)
|
468 |
+
*/
|
469 |
Â
do_action( 'bp_setup_theme_compat' );
|
470 |
Â
}
|
471 |
Â
}
|
475 |
Â
*/
|
476 |
Â
function bp_core_catch_profile_uri() {
|
477 |
Â
if ( !bp_is_active( 'xprofile' ) ) {
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Filters the path to redirect users to if XProfile is not enabled.
|
481 |
+
*
|
482 |
+
* @since BuddyPress (1.0.0)
|
483 |
+
*
|
484 |
+
* @param string $value Path to redirect users to.
|
485 |
+
*/
|
486 |
Â
bp_core_load_template( apply_filters( 'bp_core_template_display_profile', 'members/single/home' ) );
|
487 |
Â
}
|
488 |
Â
}
|
493 |
Â
* @since BuddyPress (1.5.0)
|
494 |
Â
*/
|
495 |
Â
function bp_core_catch_no_access() {
|
496 |
+
global $wp_query;
|
497 |
+
|
498 |
+
$bp = buddypress();
|
499 |
Â
|
500 |
Â
// If coming from bp_core_redirect() and $bp_no_status_set is true,
|
501 |
Â
// we are redirecting to an accessible page so skip this check.
|
545 |
Â
);
|
546 |
Â
|
547 |
Â
$r = wp_parse_args( $args, $defaults );
|
548 |
+
|
549 |
+
/**
|
550 |
+
* Filters the arguments used for user redirecting when visiting access controlled areas.
|
551 |
+
*
|
552 |
+
* @since BuddyPress (1.6.0)
|
553 |
+
*
|
554 |
+
* @param array $r Array of parsed arguments for redirect determination.
|
555 |
+
*/
|
556 |
Â
$r = apply_filters( 'bp_core_no_access', $r );
|
557 |
Â
extract( $r, EXTR_SKIP );
|
558 |
Â
|
610 |
Â
function bp_core_no_access_wp_login_error() {
|
611 |
Â
global $error;
|
612 |
Â
|
613 |
+
/**
|
614 |
+
* Filters the error message for wp-login.php when needing to log in before accessing.
|
615 |
+
*
|
616 |
+
* @since BuddyPress (1.5.0)
|
617 |
+
*
|
618 |
+
* @param string $value Error message to display.
|
619 |
+
* @param string $value URL to redirect user to after successful login.
|
620 |
+
*/
|
621 |
Â
$error = apply_filters( 'bp_wp_login_error', __( 'You must log in to access the page you requested.', 'buddypress' ), $_REQUEST['redirect_to'] );
|
622 |
Â
|
623 |
Â
// shake shake shake!
|
643 |
Â
* @uses bp_get_requested_url()
|
644 |
Â
*/
|
645 |
Â
function bp_redirect_canonical() {
|
Â
|
|
646 |
Â
|
647 |
+
/**
|
648 |
+
* Filters whether or not to do canonical redirects on BuddyPress URLs.
|
649 |
+
*
|
650 |
+
* @since BuddyPress (1.6.0)
|
651 |
+
*
|
652 |
+
* @param bool $value Whether or not to do canonical redirects. Default true.
|
653 |
+
*/
|
654 |
Â
if ( !bp_is_blog_page() && apply_filters( 'bp_do_redirect_canonical', true ) ) {
|
655 |
Â
// If this is a POST request, don't do a canonical redirect.
|
656 |
Â
// This is for backward compatibility with plugins that submit form requests to
|
673 |
Â
// Only redirect if we've assembled a URL different from the request
|
674 |
Â
if ( $canonical_url !== $req_url_clean ) {
|
675 |
Â
|
676 |
+
$bp = buddypress();
|
677 |
+
|
678 |
Â
// Template messages have been deleted from the cookie by this point, so
|
679 |
Â
// they must be readded before redirecting
|
680 |
Â
if ( isset( $bp->template_message ) ) {
|
720 |
Â
* @return string Canonical URL for the current page.
|
721 |
Â
*/
|
722 |
Â
function bp_get_canonical_url( $args = array() ) {
|
Â
|
|
723 |
Â
|
724 |
Â
// For non-BP content, return the requested url, and let WP do the work
|
725 |
Â
if ( bp_is_blog_page() ) {
|
726 |
Â
return bp_get_requested_url();
|
727 |
Â
}
|
728 |
Â
|
729 |
+
$bp = buddypress();
|
730 |
+
|
731 |
Â
$defaults = array(
|
732 |
Â
'include_query_args' => false // Include URL arguments, eg ?foo=bar&foo2=bar2
|
733 |
Â
);
|
751 |
Â
// and the current user is logged in. In this case we send to
|
752 |
Â
// the members directory to avoid redirect loops
|
753 |
Â
} elseif ( bp_is_register_page() && 'register' == $front_page_component && is_user_logged_in() ) {
|
754 |
+
|
755 |
+
/**
|
756 |
+
* Filters the logged in register page redirect URL.
|
757 |
+
*
|
758 |
+
* @since BuddyPress (1.5.1)
|
759 |
+
*
|
760 |
+
* @param string $value URL to redirect logged in members to.
|
761 |
+
*/
|
762 |
+
$bp->canonical_stack['canonical_url'] = apply_filters( 'bp_loggedin_register_page_redirect_to', bp_get_members_directory_permalink() );
|
763 |
Â
}
|
764 |
Â
}
|
765 |
Â
|
800 |
Â
$canonical_url = array_pop( $canonical_url );
|
801 |
Â
}
|
802 |
Â
|
803 |
+
/**
|
804 |
+
* Filters the canonical url of the current page.
|
805 |
+
*
|
806 |
+
* @since BuddyPress (1.6.0)
|
807 |
+
*
|
808 |
+
* @param string $canonical_url Canonical URL of the current page.
|
809 |
+
* @param array $args Array of arguments to help determine canonical URL.
|
810 |
+
*/
|
811 |
Â
return apply_filters( 'bp_get_canonical_url', $canonical_url, $args );
|
812 |
Â
}
|
813 |
Â
|
819 |
Â
* @return string Requested URL string.
|
820 |
Â
*/
|
821 |
Â
function bp_get_requested_url() {
|
822 |
+
$bp = buddypress();
|
823 |
Â
|
824 |
Â
if ( empty( $bp->canonical_stack['requested_url'] ) ) {
|
825 |
Â
$bp->canonical_stack['requested_url'] = is_ssl() ? 'https://' : 'http://';
|
826 |
Â
$bp->canonical_stack['requested_url'] .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
827 |
Â
}
|
828 |
Â
|
829 |
+
/**
|
830 |
+
* Filters the URL as requested on the current page load by the user agent.
|
831 |
+
*
|
832 |
+
* @since BuddyPress (1.7.0)
|
833 |
+
*
|
834 |
+
* @param string $value Requested URL string.
|
835 |
+
*/
|
836 |
Â
return apply_filters( 'bp_get_requested_url', $bp->canonical_stack['requested_url'] );
|
837 |
Â
}
|
838 |
Â
|
879 |
Â
*
|
880 |
Â
* @since BuddyPress (1.6.1)
|
881 |
Â
*
|
882 |
+
* @link https://buddypress.trac.wordpress.org/ticket/4329
|
883 |
+
* @link https://buddypress.trac.wordpress.org/ticket/4415
|
884 |
Â
*/
|
885 |
Â
function _bp_rehook_maybe_redirect_404() {
|
886 |
Â
if ( defined( 'NOBLOGREDIRECT' ) ) {
|
bp-core/bp-core-classes.php
CHANGED
@@ -9,2968 +9,17 @@
|
|
9 |
Â
// Exit if accessed directly
|
10 |
Â
defined( 'ABSPATH' ) || exit;
|
11 |
Â
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
* @type int $user_id ID of a user. If present, and if the friends component is activated,
|
27 |
-
* results will be limited to the friends of that user. Default: 0.
|
28 |
-
* @type string|bool $search_terms Terms to search by. Search happens across xprofile fields. Requires
|
29 |
-
* XProfile component. Default: false.
|
30 |
-
* @type string $search_wildcard When searching with $search_terms, set where wildcards around the term
|
31 |
-
* should be positioned. Accepts 'both', 'left', 'right'. Default: 'both'.
|
32 |
-
* @type array|string|bool $include An array or comma-separated list of user IDs to which query should
|
33 |
-
* be limited. Default: false.
|
34 |
-
* @type array|string|bool $exclude An array or comma-separated list of user IDs that will be excluded from
|
35 |
-
* query results. Default: false.
|
36 |
-
* @type array|string|bool $user_ids An array or comma-separated list of IDs corresponding to the users
|
37 |
-
* that should be returned. When this parameter is passed, it will
|
38 |
-
* override all others; BP User objects will be constructed using these
|
39 |
-
* IDs only. Default: false.
|
40 |
-
* @type array|string $member_type Array or comma-separated list of member types to limit results to.
|
41 |
-
* @type string|bool $meta_key Limit results to users that have usermeta associated with this meta_key.
|
42 |
-
* Usually used with $meta_value. Default: false.
|
43 |
-
* @type string|bool $meta_value When used with $meta_key, limits results to users whose usermeta value
|
44 |
-
* associated with $meta_key matches $meta_value. Default: false.
|
45 |
-
* @type array $xprofile_query Filter results by xprofile data. Requires the xprofile component. See
|
46 |
-
* {@see BP_XProfile_Query} for details.
|
47 |
-
* @type bool $populate_extras True if you want to fetch extra metadata
|
48 |
-
* about returned users, such as total group and friend counts.
|
49 |
-
* @type string $count_total Determines how BP_User_Query will do a count of total users matching
|
50 |
-
* the other filter criteria. Default value is 'count_query', which does
|
51 |
-
* a separate SELECT COUNT query to determine the total.
|
52 |
-
* 'sql_count_found_rows' uses SQL_COUNT_FOUND_ROWS and
|
53 |
-
* SELECT FOUND_ROWS(). Pass an empty string to skip the total user
|
54 |
-
* count query.
|
55 |
-
* }
|
56 |
-
*/
|
57 |
-
class BP_User_Query {
|
58 |
-
|
59 |
-
/** Variables *************************************************************/
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Unaltered params as passed to the constructor.
|
63 |
-
*
|
64 |
-
* @since BuddyPress (1.8.0)
|
65 |
-
* @var array
|
66 |
-
*/
|
67 |
-
public $query_vars_raw = array();
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Array of variables to query with.
|
71 |
-
*
|
72 |
-
* @since BuddyPress (1.7.0)
|
73 |
-
* @var array
|
74 |
-
*/
|
75 |
-
public $query_vars = array();
|
76 |
-
|
77 |
-
/**
|
78 |
-
* List of found users and their respective data.
|
79 |
-
*
|
80 |
-
* @access public To allow components to manipulate them.
|
81 |
-
* @since BuddyPress (1.7.0)
|
82 |
-
* @var array
|
83 |
-
*/
|
84 |
-
public $results = array();
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Total number of found users for the current query.
|
88 |
-
*
|
89 |
-
* @access public To allow components to manipulate it.
|
90 |
-
* @since BuddyPress (1.7.0)
|
91 |
-
* @var int
|
92 |
-
*/
|
93 |
-
public $total_users = 0;
|
94 |
-
|
95 |
-
/**
|
96 |
-
* List of found user IDs.
|
97 |
-
*
|
98 |
-
* @access public To allow components to manipulate it.
|
99 |
-
* @since BuddyPress (1.7.0)
|
100 |
-
* @var array
|
101 |
-
*/
|
102 |
-
public $user_ids = array();
|
103 |
-
|
104 |
-
/**
|
105 |
-
* SQL clauses for the user ID query.
|
106 |
-
*
|
107 |
-
* @access public To allow components to manipulate it.
|
108 |
-
* @since BuddyPress (1.7.0)
|
109 |
-
* @var array
|
110 |
-
*/
|
111 |
-
public $uid_clauses = array();
|
112 |
-
|
113 |
-
/**
|
114 |
-
* SQL table where the user ID is being fetched from.
|
115 |
-
*
|
116 |
-
* @since BuddyPress (2.2.0)
|
117 |
-
* @access public
|
118 |
-
* @var string
|
119 |
-
*/
|
120 |
-
public $uid_table = '';
|
121 |
-
|
122 |
-
/**
|
123 |
-
* SQL database column name to order by.
|
124 |
-
*
|
125 |
-
* @since BuddyPress (1.7.0)
|
126 |
-
* @var string
|
127 |
-
*/
|
128 |
-
public $uid_name = '';
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Standard response when the query should not return any rows.
|
132 |
-
*
|
133 |
-
* @access protected
|
134 |
-
* @since BuddyPress (1.7.0)
|
135 |
-
* @var string
|
136 |
-
*/
|
137 |
-
protected $no_results = array( 'join' => '', 'where' => '0 = 1' );
|
138 |
-
|
139 |
-
|
140 |
-
/** Methods ***************************************************************/
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Constructor.
|
144 |
-
*
|
145 |
-
* @since BuddyPress (1.7.0)
|
146 |
-
*
|
147 |
-
* @param string|array $query See {@link BP_User_Query}.
|
148 |
-
*/
|
149 |
-
public function __construct( $query = null ) {
|
150 |
-
|
151 |
-
// Store the raw query vars for later access
|
152 |
-
$this->query_vars_raw = $query;
|
153 |
-
|
154 |
-
// Allow extending classes to register action/filter hooks
|
155 |
-
$this->setup_hooks();
|
156 |
-
|
157 |
-
if ( ! empty( $this->query_vars_raw ) ) {
|
158 |
-
$this->query_vars = wp_parse_args( $this->query_vars_raw, array(
|
159 |
-
'type' => 'newest',
|
160 |
-
'per_page' => 0,
|
161 |
-
'page' => 1,
|
162 |
-
'user_id' => 0,
|
163 |
-
'search_terms' => false,
|
164 |
-
'search_wildcard' => 'both',
|
165 |
-
'include' => false,
|
166 |
-
'exclude' => false,
|
167 |
-
'user_ids' => false,
|
168 |
-
'member_type' => '',
|
169 |
-
'meta_key' => false,
|
170 |
-
'meta_value' => false,
|
171 |
-
'xprofile_query' => false,
|
172 |
-
'populate_extras' => true,
|
173 |
-
'count_total' => 'count_query'
|
174 |
-
) );
|
175 |
-
|
176 |
-
// Plugins can use this filter to modify query args
|
177 |
-
// before the query is constructed
|
178 |
-
do_action_ref_array( 'bp_pre_user_query_construct', array( &$this ) );
|
179 |
-
|
180 |
-
// Get user ids
|
181 |
-
// If the user_ids param is present, we skip the query
|
182 |
-
if ( false !== $this->query_vars['user_ids'] ) {
|
183 |
-
$this->user_ids = wp_parse_id_list( $this->query_vars['user_ids'] );
|
184 |
-
} else {
|
185 |
-
$this->prepare_user_ids_query();
|
186 |
-
$this->do_user_ids_query();
|
187 |
-
}
|
188 |
-
}
|
189 |
-
|
190 |
-
// Bail if no user IDs were found
|
191 |
-
if ( empty( $this->user_ids ) ) {
|
192 |
-
return;
|
193 |
-
}
|
194 |
-
|
195 |
-
// Fetch additional data. First, using WP_User_Query
|
196 |
-
$this->do_wp_user_query();
|
197 |
-
|
198 |
-
// Get BuddyPress specific user data
|
199 |
-
$this->populate_extras();
|
200 |
-
}
|
201 |
-
|
202 |
-
/**
|
203 |
-
* Allow extending classes to set up action/filter hooks.
|
204 |
-
*
|
205 |
-
* When extending BP_User_Query, you may need to use some of its
|
206 |
-
* internal hooks to modify the output. It's not convenient to call
|
207 |
-
* add_action() or add_filter() in your class constructor, because
|
208 |
-
* BP_User_Query::__construct() contains a fair amount of logic that
|
209 |
-
* you may not want to override in your class. Define this method in
|
210 |
-
* your own class if you need a place where your extending class can
|
211 |
-
* add its hooks early in the query-building process. See
|
212 |
-
* {@link BP_Group_Member_Query::setup_hooks()} for an example.
|
213 |
-
*
|
214 |
-
* @since BuddyPress (1.8.0)
|
215 |
-
*/
|
216 |
-
public function setup_hooks() {}
|
217 |
-
|
218 |
-
/**
|
219 |
-
* Prepare the query for user_ids.
|
220 |
-
*
|
221 |
-
* @since BuddyPress (1.7.0)
|
222 |
-
*/
|
223 |
-
public function prepare_user_ids_query() {
|
224 |
-
global $wpdb, $bp;
|
225 |
-
|
226 |
-
// Default query variables used here
|
227 |
-
$type = '';
|
228 |
-
$per_page = 0;
|
229 |
-
$page = 1;
|
230 |
-
$user_id = 0;
|
231 |
-
$include = false;
|
232 |
-
$search_terms = false;
|
233 |
-
$exclude = false;
|
234 |
-
$meta_key = false;
|
235 |
-
$meta_value = false;
|
236 |
-
|
237 |
-
extract( $this->query_vars );
|
238 |
-
|
239 |
-
// Setup the main SQL query container
|
240 |
-
$sql = array(
|
241 |
-
'select' => '',
|
242 |
-
'where' => array(),
|
243 |
-
'orderby' => '',
|
244 |
-
'order' => '',
|
245 |
-
'limit' => ''
|
246 |
-
);
|
247 |
-
|
248 |
-
/** TYPE **************************************************************/
|
249 |
-
|
250 |
-
// Determines the sort order, which means it also determines where the
|
251 |
-
// user IDs are drawn from (the SELECT and WHERE statements)
|
252 |
-
switch ( $type ) {
|
253 |
-
|
254 |
-
// 'online' query happens against the last_activity usermeta key
|
255 |
-
// Filter 'bp_user_query_online_interval' to modify the
|
256 |
-
// number of minutes used as an interval
|
257 |
-
case 'online' :
|
258 |
-
$this->uid_name = 'user_id';
|
259 |
-
$this->uid_table = $bp->members->table_name_last_activity;
|
260 |
-
$sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
|
261 |
-
$sql['where'][] = $wpdb->prepare( "u.component = %s AND u.type = 'last_activity'", buddypress()->members->id );
|
262 |
-
$sql['where'][] = $wpdb->prepare( "u.date_recorded >= DATE_SUB( UTC_TIMESTAMP(), INTERVAL %d MINUTE )", apply_filters( 'bp_user_query_online_interval', 15 ) );
|
263 |
-
$sql['orderby'] = "ORDER BY u.date_recorded";
|
264 |
-
$sql['order'] = "DESC";
|
265 |
-
|
266 |
-
break;
|
267 |
-
|
268 |
-
// 'active', 'newest', and 'random' queries
|
269 |
-
// all happen against the last_activity usermeta key
|
270 |
-
case 'active' :
|
271 |
-
case 'newest' :
|
272 |
-
case 'random' :
|
273 |
-
$this->uid_name = 'user_id';
|
274 |
-
$this->uid_table = $bp->members->table_name_last_activity;
|
275 |
-
$sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
|
276 |
-
$sql['where'][] = $wpdb->prepare( "u.component = %s AND u.type = 'last_activity'", buddypress()->members->id );
|
277 |
-
|
278 |
-
if ( 'newest' == $type ) {
|
279 |
-
$sql['orderby'] = "ORDER BY u.user_id";
|
280 |
-
$sql['order'] = "DESC";
|
281 |
-
} elseif ( 'random' == $type ) {
|
282 |
-
$sql['orderby'] = "ORDER BY rand()";
|
283 |
-
} else {
|
284 |
-
$sql['orderby'] = "ORDER BY u.date_recorded";
|
285 |
-
$sql['order'] = "DESC";
|
286 |
-
}
|
287 |
-
|
288 |
-
break;
|
289 |
-
|
290 |
-
// 'popular' sorts by the 'total_friend_count' usermeta
|
291 |
-
case 'popular' :
|
292 |
-
$this->uid_name = 'user_id';
|
293 |
-
$this->uid_table = $wpdb->usermeta;
|
294 |
-
$sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
|
295 |
-
$sql['where'][] = $wpdb->prepare( "u.meta_key = %s", bp_get_user_meta_key( 'total_friend_count' ) );
|
296 |
-
$sql['orderby'] = "ORDER BY CONVERT(u.meta_value, SIGNED)";
|
297 |
-
$sql['order'] = "DESC";
|
298 |
-
|
299 |
-
break;
|
300 |
-
|
301 |
-
// 'alphabetical' sorts depend on the xprofile setup
|
302 |
-
case 'alphabetical' :
|
303 |
-
|
304 |
-
// We prefer to do alphabetical sorts against the display_name field
|
305 |
-
// of wp_users, because the table is smaller and better indexed. We
|
306 |
-
// can do so if xprofile sync is enabled, or if xprofile is inactive.
|
307 |
-
//
|
308 |
-
// @todo remove need for bp_is_active() check
|
309 |
-
if ( ! bp_disable_profile_sync() || ! bp_is_active( 'xprofile' ) ) {
|
310 |
-
$this->uid_name = 'ID';
|
311 |
-
$this->uid_table = $wpdb->users;
|
312 |
-
$sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
|
313 |
-
$sql['orderby'] = "ORDER BY u.display_name";
|
314 |
-
$sql['order'] = "ASC";
|
315 |
-
|
316 |
-
// When profile sync is disabled, alphabetical sorts must happen against
|
317 |
-
// the xprofile table
|
318 |
-
} else {
|
319 |
-
$this->uid_name = 'user_id';
|
320 |
-
$this->uid_table = $bp->profile->table_name_data;
|
321 |
-
$sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
|
322 |
-
$sql['where'][] = $wpdb->prepare( "u.field_id = %d", bp_xprofile_fullname_field_id() );
|
323 |
-
$sql['orderby'] = "ORDER BY u.value";
|
324 |
-
$sql['order'] = "ASC";
|
325 |
-
}
|
326 |
-
|
327 |
-
// Alphabetical queries ignore last_activity, while BP uses last_activity
|
328 |
-
// to infer spam/deleted/non-activated users. To ensure that these users
|
329 |
-
// are filtered out, we add an appropriate sub-query.
|
330 |
-
$sql['where'][] = "u.{$this->uid_name} IN ( SELECT ID FROM {$wpdb->users} WHERE " . bp_core_get_status_sql( '' ) . " )";
|
331 |
-
|
332 |
-
break;
|
333 |
-
|
334 |
-
// Any other 'type' falls through
|
335 |
-
default :
|
336 |
-
$this->uid_name = 'ID';
|
337 |
-
$this->uid_table = $wpdb->users;
|
338 |
-
$sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
|
339 |
-
|
340 |
-
// In this case, we assume that a plugin is
|
341 |
-
// handling order, so we leave those clauses
|
342 |
-
// blank
|
343 |
-
|
344 |
-
break;
|
345 |
-
}
|
346 |
-
|
347 |
-
/** WHERE *************************************************************/
|
348 |
-
|
349 |
-
// 'include' - User ids to include in the results
|
350 |
-
$include = false !== $include ? wp_parse_id_list( $include ) : array();
|
351 |
-
$include_ids = $this->get_include_ids( $include );
|
352 |
-
if ( ! empty( $include_ids ) ) {
|
353 |
-
$include_ids = implode( ',', wp_parse_id_list( $include_ids ) );
|
354 |
-
$sql['where'][] = "u.{$this->uid_name} IN ({$include_ids})";
|
355 |
-
}
|
356 |
-
|
357 |
-
// 'exclude' - User ids to exclude from the results
|
358 |
-
if ( false !== $exclude ) {
|
359 |
-
$exclude_ids = implode( ',', wp_parse_id_list( $exclude ) );
|
360 |
-
$sql['where'][] = "u.{$this->uid_name} NOT IN ({$exclude_ids})";
|
361 |
-
}
|
362 |
-
|
363 |
-
// 'user_id' - When a user id is passed, limit to the friends of the user
|
364 |
-
// @todo remove need for bp_is_active() check
|
365 |
-
if ( ! empty( $user_id ) && bp_is_active( 'friends' ) ) {
|
366 |
-
$friend_ids = friends_get_friend_user_ids( $user_id );
|
367 |
-
$friend_ids = implode( ',', wp_parse_id_list( $friend_ids ) );
|
368 |
-
|
369 |
-
if ( ! empty( $friend_ids ) ) {
|
370 |
-
$sql['where'][] = "u.{$this->uid_name} IN ({$friend_ids})";
|
371 |
-
|
372 |
-
// If the user has no friends, the query should always
|
373 |
-
// return no users
|
374 |
-
} else {
|
375 |
-
$sql['where'][] = $this->no_results['where'];
|
376 |
-
}
|
377 |
-
}
|
378 |
-
|
379 |
-
/** Search Terms ******************************************************/
|
380 |
-
|
381 |
-
// 'search_terms' searches user_login and user_nicename
|
382 |
-
// xprofile field matches happen in bp_xprofile_bp_user_query_search()
|
383 |
-
if ( false !== $search_terms ) {
|
384 |
-
$search_terms = bp_esc_like( wp_kses_normalize_entities( $search_terms ) );
|
385 |
-
|
386 |
-
if ( $search_wildcard === 'left' ) {
|
387 |
-
$search_terms_nospace = '%' . $search_terms;
|
388 |
-
$search_terms_space = '%' . $search_terms . ' %';
|
389 |
-
} elseif ( $search_wildcard === 'right' ) {
|
390 |
-
$search_terms_nospace = $search_terms . '%';
|
391 |
-
$search_terms_space = '% ' . $search_terms . '%';
|
392 |
-
} else {
|
393 |
-
$search_terms_nospace = '%' . $search_terms . '%';
|
394 |
-
$search_terms_space = '%' . $search_terms . '%';
|
395 |
-
}
|
396 |
-
|
397 |
-
$sql['where']['search'] = $wpdb->prepare(
|
398 |
-
"u.{$this->uid_name} IN ( SELECT ID FROM {$wpdb->users} WHERE ( user_login LIKE %s OR user_login LIKE %s OR user_nicename LIKE %s OR user_nicename LIKE %s ) )",
|
399 |
-
$search_terms_nospace,
|
400 |
-
$search_terms_space,
|
401 |
-
$search_terms_nospace,
|
402 |
-
$search_terms_space
|
403 |
-
);
|
404 |
-
}
|
405 |
-
|
406 |
-
// Member type.
|
407 |
-
if ( ! empty( $member_type ) ) {
|
408 |
-
$member_types = array();
|
409 |
-
|
410 |
-
if ( ! is_array( $member_type ) ) {
|
411 |
-
$member_type = preg_split( '/[,\s+]/', $member_type );
|
412 |
-
}
|
413 |
-
|
414 |
-
foreach ( $member_type as $mt ) {
|
415 |
-
if ( ! bp_get_member_type_object( $mt ) ) {
|
416 |
-
continue;
|
417 |
-
}
|
418 |
-
|
419 |
-
$member_types[] = $mt;
|
420 |
-
}
|
421 |
-
|
422 |
-
if ( ! empty( $member_types ) ) {
|
423 |
-
$member_type_tq = new WP_Tax_Query( array(
|
424 |
-
array(
|
425 |
-
'taxonomy' => 'bp_member_type',
|
426 |
-
'field' => 'name',
|
427 |
-
'operator' => 'IN',
|
428 |
-
'terms' => $member_types,
|
429 |
-
),
|
430 |
-
) );
|
431 |
-
|
432 |
-
// Switch to the root blog, where member type taxonomies live.
|
433 |
-
switch_to_blog( bp_get_root_blog_id() );
|
434 |
-
|
435 |
-
$member_type_sql_clauses = $member_type_tq->get_sql( 'u', $this->uid_name );
|
436 |
-
restore_current_blog();
|
437 |
-
|
438 |
-
// Grab the first term_relationships clause and convert to a subquery.
|
439 |
-
if ( preg_match( '/' . $wpdb->term_relationships . '\.term_taxonomy_id IN \([0-9, ]+\)/', $member_type_sql_clauses['where'], $matches ) ) {
|
440 |
-
$sql['where']['member_type'] = "u.{$this->uid_name} IN ( SELECT object_id FROM $wpdb->term_relationships WHERE {$matches[0]} )";
|
441 |
-
} elseif ( false !== strpos( $member_type_sql_clauses['where'], '0 = 1' ) ) {
|
442 |
-
$sql['where']['member_type'] = $this->no_results['where'];
|
443 |
-
}
|
444 |
-
}
|
445 |
-
}
|
446 |
-
|
447 |
-
// 'meta_key', 'meta_value' allow usermeta search
|
448 |
-
// To avoid global joins, do a separate query
|
449 |
-
if ( false !== $meta_key ) {
|
450 |
-
$meta_sql = $wpdb->prepare( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = %s", $meta_key );
|
451 |
-
|
452 |
-
if ( false !== $meta_value ) {
|
453 |
-
$meta_sql .= $wpdb->prepare( " AND meta_value = %s", $meta_value );
|
454 |
-
}
|
455 |
-
|
456 |
-
$found_user_ids = $wpdb->get_col( $meta_sql );
|
457 |
-
|
458 |
-
if ( ! empty( $found_user_ids ) ) {
|
459 |
-
$sql['where'][] = "u.{$this->uid_name} IN (" . implode( ',', wp_parse_id_list( $found_user_ids ) ) . ")";
|
460 |
-
} else {
|
461 |
-
$sql['where'][] = '1 = 0';
|
462 |
-
}
|
463 |
-
}
|
464 |
-
|
465 |
-
// 'per_page', 'page' - handles LIMIT
|
466 |
-
if ( !empty( $per_page ) && !empty( $page ) ) {
|
467 |
-
$sql['limit'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) );
|
468 |
-
} else {
|
469 |
-
$sql['limit'] = '';
|
470 |
-
}
|
471 |
-
|
472 |
-
// Allow custom filters
|
473 |
-
$sql = apply_filters_ref_array( 'bp_user_query_uid_clauses', array( $sql, &$this ) );
|
474 |
-
|
475 |
-
// Assemble the query chunks
|
476 |
-
$this->uid_clauses['select'] = $sql['select'];
|
477 |
-
$this->uid_clauses['where'] = ! empty( $sql['where'] ) ? 'WHERE ' . implode( ' AND ', $sql['where'] ) : '';
|
478 |
-
$this->uid_clauses['orderby'] = $sql['orderby'];
|
479 |
-
$this->uid_clauses['order'] = $sql['order'];
|
480 |
-
$this->uid_clauses['limit'] = $sql['limit'];
|
481 |
-
|
482 |
-
do_action_ref_array( 'bp_pre_user_query', array( &$this ) );
|
483 |
-
}
|
484 |
-
|
485 |
-
/**
|
486 |
-
* Query for IDs of users that match the query parameters.
|
487 |
-
*
|
488 |
-
* Perform a database query to specifically get only user IDs, using
|
489 |
-
* existing query variables set previously in the constructor.
|
490 |
-
*
|
491 |
-
* Also used to quickly perform user total counts.
|
492 |
-
*
|
493 |
-
* @since BuddyPress (1.7.0)
|
494 |
-
*/
|
495 |
-
public function do_user_ids_query() {
|
496 |
-
global $wpdb;
|
497 |
-
|
498 |
-
// If counting using SQL_CALC_FOUND_ROWS, set it up here
|
499 |
-
if ( 'sql_calc_found_rows' == $this->query_vars['count_total'] ) {
|
500 |
-
$this->uid_clauses['select'] = str_replace( 'SELECT', 'SELECT SQL_CALC_FOUND_ROWS', $this->uid_clauses['select'] );
|
501 |
-
}
|
502 |
-
|
503 |
-
// Get the specific user ids
|
504 |
-
$this->user_ids = $wpdb->get_col( "{$this->uid_clauses['select']} {$this->uid_clauses['where']} {$this->uid_clauses['orderby']} {$this->uid_clauses['order']} {$this->uid_clauses['limit']}" );
|
505 |
-
|
506 |
-
// Get the total user count
|
507 |
-
if ( 'sql_calc_found_rows' == $this->query_vars['count_total'] ) {
|
508 |
-
$this->total_users = $wpdb->get_var( apply_filters( 'bp_found_user_query', "SELECT FOUND_ROWS()", $this ) );
|
509 |
-
} elseif ( 'count_query' == $this->query_vars['count_total'] ) {
|
510 |
-
$count_select = preg_replace( '/^SELECT.*?FROM (\S+) u/', "SELECT COUNT(u.{$this->uid_name}) FROM $1 u", $this->uid_clauses['select'] );
|
511 |
-
$this->total_users = $wpdb->get_var( apply_filters( 'bp_found_user_query', "{$count_select} {$this->uid_clauses['where']}", $this ) );
|
512 |
-
}
|
513 |
-
}
|
514 |
-
|
515 |
-
/**
|
516 |
-
* Use WP_User_Query() to pull data for the user IDs retrieved in the main query.
|
517 |
-
*
|
518 |
-
* @since BuddyPress (1.7.0)
|
519 |
-
*/
|
520 |
-
public function do_wp_user_query() {
|
521 |
-
$fields = array( 'ID', 'user_login', 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'user_activation_key', 'user_status', 'display_name' );
|
522 |
-
|
523 |
-
if ( is_multisite() ) {
|
524 |
-
$fields[] = 'spam';
|
525 |
-
$fields[] = 'deleted';
|
526 |
-
}
|
527 |
-
|
528 |
-
$wp_user_query = new WP_User_Query( apply_filters( 'bp_wp_user_query_args', array(
|
529 |
-
|
530 |
-
// Relevant
|
531 |
-
'fields' => $fields,
|
532 |
-
'include' => $this->user_ids,
|
533 |
-
|
534 |
-
// Overrides
|
535 |
-
'blog_id' => 0, // BP does not require blog roles
|
536 |
-
'count_total' => false // We already have a count
|
537 |
-
|
538 |
-
), $this ) );
|
539 |
-
|
540 |
-
// WP_User_Query doesn't cache the data it pulls from wp_users,
|
541 |
-
// and it does not give us a way to save queries by fetching
|
542 |
-
// only uncached users. However, BP does cache this data, so
|
543 |
-
// we set it here.
|
544 |
-
foreach ( $wp_user_query->results as $u ) {
|
545 |
-
wp_cache_set( 'bp_core_userdata_' . $u->ID, $u, 'bp' );
|
546 |
-
}
|
547 |
-
|
548 |
-
// We calculate total_users using a standalone query, except
|
549 |
-
// when a whitelist of user_ids is passed to the constructor.
|
550 |
-
// This clause covers the latter situation, and ensures that
|
551 |
-
// pagination works when querying by $user_ids.
|
552 |
-
if ( empty( $this->total_users ) ) {
|
553 |
-
$this->total_users = count( $wp_user_query->results );
|
554 |
-
}
|
555 |
-
|
556 |
-
// Reindex for easier matching
|
557 |
-
$r = array();
|
558 |
-
foreach ( $wp_user_query->results as $u ) {
|
559 |
-
$r[ $u->ID ] = $u;
|
560 |
-
}
|
561 |
-
|
562 |
-
// Match up to the user ids from the main query
|
563 |
-
foreach ( $this->user_ids as $uid ) {
|
564 |
-
if ( isset( $r[ $uid ] ) ) {
|
565 |
-
$this->results[ $uid ] = $r[ $uid ];
|
566 |
-
|
567 |
-
// The BP template functions expect an 'id'
|
568 |
-
// (as opposed to 'ID') property
|
569 |
-
$this->results[ $uid ]->id = $uid;
|
570 |
-
}
|
571 |
-
}
|
572 |
-
}
|
573 |
-
|
574 |
-
/**
|
575 |
-
* Fetch the IDs of users to put in the IN clause of the main query.
|
576 |
-
*
|
577 |
-
* By default, returns the value passed to it
|
578 |
-
* ($this->query_vars['include']). Having this abstracted into a
|
579 |
-
* standalone method means that extending classes can override the
|
580 |
-
* logic, parsing together their own user_id limits with the 'include'
|
581 |
-
* ids passed to the class constructor. See {@link BP_Group_Member_Query}
|
582 |
-
* for an example.
|
583 |
-
*
|
584 |
-
* @since BuddyPress (1.8.0)
|
585 |
-
*
|
586 |
-
* @param array Sanitized array of user IDs, as passed to the 'include'
|
587 |
-
* parameter of the class constructor.
|
588 |
-
* @return array The list of users to which the main query should be
|
589 |
-
* limited.
|
590 |
-
*/
|
591 |
-
public function get_include_ids( $include = array() ) {
|
592 |
-
return $include;
|
593 |
-
}
|
594 |
-
|
595 |
-
/**
|
596 |
-
* Perform a database query to populate any extra metadata we might need.
|
597 |
-
*
|
598 |
-
* Different components will hook into the 'bp_user_query_populate_extras'
|
599 |
-
* action to loop in the things they want.
|
600 |
-
*
|
601 |
-
* @since BuddyPress (1.7.0)
|
602 |
-
*
|
603 |
-
* @global WPDB $wpdb Global WordPress database access object.
|
604 |
-
*/
|
605 |
-
public function populate_extras() {
|
606 |
-
global $wpdb;
|
607 |
-
|
608 |
-
// Bail if no users
|
609 |
-
if ( empty( $this->user_ids ) || empty( $this->results ) ) {
|
610 |
-
return;
|
611 |
-
}
|
612 |
-
|
613 |
-
// Bail if the populate_extras flag is set to false
|
614 |
-
// In the case of the 'popular' sort type, we force
|
615 |
-
// populate_extras to true, because we need the friend counts
|
616 |
-
if ( 'popular' == $this->query_vars['type'] ) {
|
617 |
-
$this->query_vars['populate_extras'] = 1;
|
618 |
-
}
|
619 |
-
|
620 |
-
if ( ! (bool) $this->query_vars['populate_extras'] ) {
|
621 |
-
return;
|
622 |
-
}
|
623 |
-
|
624 |
-
// Turn user ID's into a query-usable, comma separated value
|
625 |
-
$user_ids_sql = implode( ',', wp_parse_id_list( $this->user_ids ) );
|
626 |
-
|
627 |
-
/**
|
628 |
-
* Use this action to independently populate your own custom extras.
|
629 |
-
*
|
630 |
-
* Note that anything you add here should query using $user_ids_sql, to
|
631 |
-
* avoid running multiple queries per user in the loop.
|
632 |
-
*
|
633 |
-
* Two BuddyPress components currently do this:
|
634 |
-
* - XProfile: To override display names
|
635 |
-
* - Friends: To set whether or not a user is the current users friend
|
636 |
-
*
|
637 |
-
* @see bp_xprofile_filter_user_query_populate_extras()
|
638 |
-
* @see bp_friends_filter_user_query_populate_extras()
|
639 |
-
*/
|
640 |
-
do_action_ref_array( 'bp_user_query_populate_extras', array( $this, $user_ids_sql ) );
|
641 |
-
|
642 |
-
// Fetch last_active data from the activity table
|
643 |
-
$last_activities = BP_Core_User::get_last_activity( $this->user_ids );
|
644 |
-
|
645 |
-
// Set a last_activity value for each user, even if it's empty
|
646 |
-
foreach ( $this->results as $user_id => $user ) {
|
647 |
-
$user_last_activity = isset( $last_activities[ $user_id ] ) ? $last_activities[ $user_id ]['date_recorded'] : '';
|
648 |
-
$this->results[ $user_id ]->last_activity = $user_last_activity;
|
649 |
-
}
|
650 |
-
|
651 |
-
// Fetch usermeta data
|
652 |
-
// We want the three following pieces of info from usermeta:
|
653 |
-
// - friend count
|
654 |
-
// - latest update
|
655 |
-
$total_friend_count_key = bp_get_user_meta_key( 'total_friend_count' );
|
656 |
-
$bp_latest_update_key = bp_get_user_meta_key( 'bp_latest_update' );
|
657 |
-
|
658 |
-
// total_friend_count must be set for each user, even if its
|
659 |
-
// value is 0
|
660 |
-
foreach ( $this->results as $uindex => $user ) {
|
661 |
-
$this->results[$uindex]->total_friend_count = 0;
|
662 |
-
}
|
663 |
-
|
664 |
-
// Create, prepare, and run the separate usermeta query
|
665 |
-
$user_metas = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, meta_key, meta_value FROM {$wpdb->usermeta} WHERE meta_key IN (%s,%s) AND user_id IN ({$user_ids_sql})", $total_friend_count_key, $bp_latest_update_key ) );
|
666 |
-
|
667 |
-
// The $members_template global expects the index key to be different
|
668 |
-
// from the meta_key in some cases, so we rejig things here.
|
669 |
-
foreach ( $user_metas as $user_meta ) {
|
670 |
-
switch ( $user_meta->meta_key ) {
|
671 |
-
case $total_friend_count_key :
|
672 |
-
$key = 'total_friend_count';
|
673 |
-
break;
|
674 |
-
|
675 |
-
case $bp_latest_update_key :
|
676 |
-
$key = 'latest_update';
|
677 |
-
break;
|
678 |
-
}
|
679 |
-
|
680 |
-
if ( isset( $this->results[ $user_meta->user_id ] ) ) {
|
681 |
-
$this->results[ $user_meta->user_id ]->{$key} = $user_meta->meta_value;
|
682 |
-
}
|
683 |
-
}
|
684 |
-
|
685 |
-
// When meta_key or meta_value have been passed to the query,
|
686 |
-
// fetch the resulting values for use in the template functions
|
687 |
-
if ( ! empty( $this->query_vars['meta_key'] ) ) {
|
688 |
-
$meta_sql = array(
|
689 |
-
'select' => "SELECT user_id, meta_key, meta_value",
|
690 |
-
'from' => "FROM $wpdb->usermeta",
|
691 |
-
'where' => $wpdb->prepare( "WHERE meta_key = %s", $this->query_vars['meta_key'] )
|
692 |
-
);
|
693 |
-
|
694 |
-
if ( false !== $this->query_vars['meta_value'] ) {
|
695 |
-
$meta_sql['where'] .= $wpdb->prepare( " AND meta_value = %s", $this->query_vars['meta_value'] );
|
696 |
-
}
|
697 |
-
|
698 |
-
$metas = $wpdb->get_results( "{$meta_sql['select']} {$meta_sql['from']} {$meta_sql['where']}" );
|
699 |
-
|
700 |
-
if ( ! empty( $metas ) ) {
|
701 |
-
foreach ( $metas as $meta ) {
|
702 |
-
if ( isset( $this->results[ $meta->user_id ] ) ) {
|
703 |
-
$this->results[ $meta->user_id ]->meta_key = $meta->meta_key;
|
704 |
-
|
705 |
-
if ( ! empty( $meta->meta_value ) ) {
|
706 |
-
$this->results[ $meta->user_id ]->meta_value = $meta->meta_value;
|
707 |
-
}
|
708 |
-
}
|
709 |
-
}
|
710 |
-
}
|
711 |
-
}
|
712 |
-
}
|
713 |
-
}
|
714 |
-
|
715 |
-
/**
|
716 |
-
* Fetch data about a BuddyPress user.
|
717 |
-
*
|
718 |
-
* BP_Core_User class can be used by any component. It will fetch useful
|
719 |
-
* details for any user when provided with a user_id.
|
720 |
-
*
|
721 |
-
* Example:
|
722 |
-
* $user = new BP_Core_User( $user_id );
|
723 |
-
* $user_avatar = $user->avatar;
|
724 |
-
* $user_email = $user->email;
|
725 |
-
* $user_status = $user->status;
|
726 |
-
* etc.
|
727 |
-
*/
|
728 |
-
class BP_Core_User {
|
729 |
-
|
730 |
-
/**
|
731 |
-
* ID of the user which the object relates to.
|
732 |
-
*
|
733 |
-
* @var integer
|
734 |
-
*/
|
735 |
-
public $id;
|
736 |
-
|
737 |
-
/**
|
738 |
-
* The URL to the full size of the avatar for the user.
|
739 |
-
*
|
740 |
-
* @var string
|
741 |
-
*/
|
742 |
-
public $avatar;
|
743 |
-
|
744 |
-
/**
|
745 |
-
* The URL to the thumb size of the avatar for the user.
|
746 |
-
*
|
747 |
-
* @var string
|
748 |
-
*/
|
749 |
-
public $avatar_thumb;
|
750 |
-
|
751 |
-
/**
|
752 |
-
* The URL to the mini size of the avatar for the user.
|
753 |
-
*
|
754 |
-
* @var string
|
755 |
-
*/
|
756 |
-
public $avatar_mini;
|
757 |
-
|
758 |
-
/**
|
759 |
-
* The full name of the user
|
760 |
-
*
|
761 |
-
* @var string
|
762 |
-
*/
|
763 |
-
public $fullname;
|
764 |
-
|
765 |
-
/**
|
766 |
-
* The email for the user.
|
767 |
-
*
|
768 |
-
* @var string
|
769 |
-
*/
|
770 |
-
public $email;
|
771 |
-
|
772 |
-
/**
|
773 |
-
* The absolute url for the user's profile.
|
774 |
-
*
|
775 |
-
* @var string
|
776 |
-
*/
|
777 |
-
public $user_url;
|
778 |
-
|
779 |
-
/**
|
780 |
-
* The HTML for the user link, with the link text being the user's full name.
|
781 |
-
*
|
782 |
-
* @var string
|
783 |
-
*/
|
784 |
-
public $user_link;
|
785 |
-
|
786 |
-
/**
|
787 |
-
* Contains a formatted string when the last time the user was active.
|
788 |
-
*
|
789 |
-
* Example: "active 2 hours and 50 minutes ago"
|
790 |
-
*
|
791 |
-
* @var string
|
792 |
-
*/
|
793 |
-
public $last_active;
|
794 |
-
|
795 |
-
/* Extras */
|
796 |
-
|
797 |
-
/**
|
798 |
-
* The total number of "Friends" the user has on site.
|
799 |
-
*
|
800 |
-
* @var integer
|
801 |
-
*/
|
802 |
-
public $total_friends;
|
803 |
-
|
804 |
-
/**
|
805 |
-
* The total number of blog posts posted by the user
|
806 |
-
*
|
807 |
-
* @var integer
|
808 |
-
* @deprecated No longer used
|
809 |
-
*/
|
810 |
-
public $total_blogs;
|
811 |
-
|
812 |
-
/**
|
813 |
-
* The total number of groups the user is a part of.
|
814 |
-
*
|
815 |
-
* Example: "1 group", "2 groups"
|
816 |
-
*
|
817 |
-
* @var string
|
818 |
-
*/
|
819 |
-
public $total_groups;
|
820 |
-
|
821 |
-
/**
|
822 |
-
* Profile information for the specific user.
|
823 |
-
*
|
824 |
-
* @since BuddyPress (1.2.0)
|
825 |
-
* @var array
|
826 |
-
*/
|
827 |
-
public $profile_data;
|
828 |
-
|
829 |
-
/** Public Methods *******************************************************/
|
830 |
-
|
831 |
-
/**
|
832 |
-
* Class constructor.
|
833 |
-
*
|
834 |
-
* @param integer $user_id The ID for the user being queried.
|
835 |
-
* @param bool $populate_extras Whether to fetch extra information
|
836 |
-
* such as group/friendship counts or not. Default: false.
|
837 |
-
*/
|
838 |
-
public function __construct( $user_id, $populate_extras = false ) {
|
839 |
-
if ( !empty( $user_id ) ) {
|
840 |
-
$this->id = $user_id;
|
841 |
-
$this->populate();
|
842 |
-
|
843 |
-
if ( !empty( $populate_extras ) ) {
|
844 |
-
$this->populate_extras();
|
845 |
-
}
|
846 |
-
}
|
847 |
-
}
|
848 |
-
|
849 |
-
/**
|
850 |
-
* Populate the instantiated class with data based on the User ID provided.
|
851 |
-
*
|
852 |
-
* @uses bp_core_get_userurl() Returns the URL with no HTML markup for
|
853 |
-
* a user based on their user id.
|
854 |
-
* @uses bp_core_get_userlink() Returns a HTML formatted link for a
|
855 |
-
* user with the user's full name as the link text.
|
856 |
-
* @uses bp_core_get_user_email() Returns the email address for the
|
857 |
-
* user based on user ID.
|
858 |
-
* @uses bp_get_user_meta() BP function returns the value of passed
|
859 |
-
* usermeta name from usermeta table.
|
860 |
-
* @uses bp_core_fetch_avatar() Returns HTML formatted avatar for a user
|
861 |
-
* @uses bp_profile_last_updated_date() Returns the last updated date
|
862 |
-
* for a user.
|
863 |
-
*/
|
864 |
-
public function populate() {
|
865 |
-
|
866 |
-
if ( bp_is_active( 'xprofile' ) )
|
867 |
-
$this->profile_data = $this->get_profile_data();
|
868 |
-
|
869 |
-
if ( !empty( $this->profile_data ) ) {
|
870 |
-
$full_name_field_name = bp_xprofile_fullname_field_name();
|
871 |
-
|
872 |
-
$this->user_url = bp_core_get_user_domain( $this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login'] );
|
873 |
-
$this->fullname = esc_attr( $this->profile_data[$full_name_field_name]['field_data'] );
|
874 |
-
$this->user_link = "<a href='{$this->user_url}' title='{$this->fullname}'>{$this->fullname}</a>";
|
875 |
-
$this->email = esc_attr( $this->profile_data['user_email'] );
|
876 |
-
} else {
|
877 |
-
$this->user_url = bp_core_get_user_domain( $this->id );
|
878 |
-
$this->user_link = bp_core_get_userlink( $this->id );
|
879 |
-
$this->fullname = esc_attr( bp_core_get_user_displayname( $this->id ) );
|
880 |
-
$this->email = esc_attr( bp_core_get_user_email( $this->id ) );
|
881 |
-
}
|
882 |
-
|
883 |
-
// Cache a few things that are fetched often
|
884 |
-
wp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, 'bp' );
|
885 |
-
wp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' );
|
886 |
-
wp_cache_set( 'bp_user_url_' . $this->id, $this->user_url, 'bp' );
|
887 |
-
|
888 |
-
$this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) );
|
889 |
-
$this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) );
|
890 |
-
$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 ) );
|
891 |
-
$this->last_active = bp_core_get_last_activity( bp_get_user_last_activity( $this->id ), __( 'active %s', 'buddypress' ) );
|
892 |
-
}
|
893 |
-
|
894 |
-
/**
|
895 |
-
* Populates extra fields such as group and friendship counts.
|
896 |
-
*/
|
897 |
-
public function populate_extras() {
|
898 |
-
|
899 |
-
if ( bp_is_active( 'friends' ) ) {
|
900 |
-
$this->total_friends = BP_Friends_Friendship::total_friend_count( $this->id );
|
901 |
-
}
|
902 |
-
|
903 |
-
if ( bp_is_active( 'groups' ) ) {
|
904 |
-
$this->total_groups = BP_Groups_Member::total_group_count( $this->id );
|
905 |
-
$this->total_groups = sprintf( _n( '%d group', '%d groups', $this->total_groups, 'buddypress' ), $this->total_groups );
|
906 |
-
}
|
907 |
-
}
|
908 |
-
|
909 |
-
/**
|
910 |
-
* Fetch xprofile data for the current user.
|
911 |
-
*
|
912 |
-
* @see BP_XProfile_ProfileData::get_all_for_user() for description of
|
913 |
-
* return value.
|
914 |
-
*
|
915 |
-
* @return array See {@link BP_XProfile_Profile_Data::get_all_for_user()}.
|
916 |
-
*/
|
917 |
-
public function get_profile_data() {
|
918 |
-
return BP_XProfile_ProfileData::get_all_for_user( $this->id );
|
919 |
-
}
|
920 |
-
|
921 |
-
/** Static Methods ********************************************************/
|
922 |
-
|
923 |
-
/**
|
924 |
-
* Get a list of users that match the query parameters.
|
925 |
-
*
|
926 |
-
* Since BuddyPress 1.7, use {@link BP_User_Query} instead.
|
927 |
-
*
|
928 |
-
* @deprecated 1.7.0 Use {@link BP_User_Query}.
|
929 |
-
*
|
930 |
-
* @see BP_User_Query for a description of parameters, most of which
|
931 |
-
* are used there in the same way.
|
932 |
-
*
|
933 |
-
* @param string $type See {@link BP_User_Query}.
|
934 |
-
* @param int $limit See {@link BP_User_Query}. Default: 0.
|
935 |
-
* @param int $page See {@link BP_User_Query}. Default: 1.
|
936 |
-
* @param int $user_id See {@link BP_User_Query}. Default: 0.
|
937 |
-
* @param mixed $include See {@link BP_User_Query}. Default: false.
|
938 |
-
* @param string|bool $search_terms See {@link BP_User_Query}.
|
939 |
-
* Default: false.
|
940 |
-
* @param bool $populate_extras See {@link BP_User_Query}.
|
941 |
-
* Default: true.
|
942 |
-
* @param mixed $exclude See {@link BP_User_Query}. Default: false.
|
943 |
-
* @param string|bool $meta_key See {@link BP_User_Query}.
|
944 |
-
* Default: false.
|
945 |
-
* @param string|bool $meta_value See {@link BP_User_Query}.
|
946 |
-
* Default: false.
|
947 |
-
* @return array {
|
948 |
-
* @type int $total_users Total number of users matched by query
|
949 |
-
* params.
|
950 |
-
* @type array $paged_users The current page of users matched by
|
951 |
-
* query params.
|
952 |
-
* }
|
953 |
-
*/
|
954 |
-
public static function get_users( $type, $limit = 0, $page = 1, $user_id = 0, $include = false, $search_terms = false, $populate_extras = true, $exclude = false, $meta_key = false, $meta_value = false ) {
|
955 |
-
global $wpdb, $bp;
|
956 |
-
|
957 |
-
_deprecated_function( __METHOD__, '1.7', 'BP_User_Query' );
|
958 |
-
|
959 |
-
$sql = array();
|
960 |
-
|
961 |
-
$sql['select_main'] = "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";
|
962 |
-
|
963 |
-
if ( 'active' == $type || 'online' == $type || 'newest' == $type ) {
|
964 |
-
$sql['select_active'] = ", um.meta_value as last_activity";
|
965 |
-
}
|
966 |
-
|
967 |
-
if ( 'popular' == $type ) {
|
968 |
-
$sql['select_popular'] = ", um.meta_value as total_friend_count";
|
969 |
-
}
|
970 |
-
|
971 |
-
if ( 'alphabetical' == $type ) {
|
972 |
-
$sql['select_alpha'] = ", pd.value as fullname";
|
973 |
-
}
|
974 |
-
|
975 |
-
if ( $meta_key ) {
|
976 |
-
$sql['select_meta'] = ", umm.meta_key";
|
977 |
-
|
978 |
-
if ( $meta_value ) {
|
979 |
-
$sql['select_meta'] .= ", umm.meta_value";
|
980 |
-
}
|
981 |
-
}
|
982 |
-
|
983 |
-
$sql['from'] = "FROM {$wpdb->users} u LEFT JOIN {$wpdb->usermeta} um ON um.user_id = u.ID";
|
984 |
-
|
985 |
-
// We search against xprofile fields, so we must join the table
|
986 |
-
if ( $search_terms && bp_is_active( 'xprofile' ) ) {
|
987 |
-
$sql['join_profiledata_search'] = "LEFT JOIN {$bp->profile->table_name_data} spd ON u.ID = spd.user_id";
|
988 |
-
}
|
989 |
-
|
990 |
-
// Alphabetical sorting is done by the xprofile Full Name field
|
991 |
-
if ( 'alphabetical' == $type ) {
|
992 |
-
$sql['join_profiledata_alpha'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
|
993 |
-
}
|
994 |
-
|
995 |
-
if ( $meta_key ) {
|
996 |
-
$sql['join_meta'] = "LEFT JOIN {$wpdb->usermeta} umm ON umm.user_id = u.ID";
|
997 |
-
}
|
998 |
-
|
999 |
-
$sql['where'] = 'WHERE ' . bp_core_get_status_sql( 'u.' );
|
1000 |
-
|
1001 |
-
if ( 'active' == $type || 'online' == $type || 'newest' == $type ) {
|
1002 |
-
$sql['where_active'] = $wpdb->prepare( "AND um.meta_key = %s", bp_get_user_meta_key( 'last_activity' ) );
|
1003 |
-
}
|
1004 |
-
|
1005 |
-
if ( 'popular' == $type ) {
|
1006 |
-
$sql['where_popular'] = $wpdb->prepare( "AND um.meta_key = %s", bp_get_user_meta_key( 'total_friend_count' ) );
|
1007 |
-
}
|
1008 |
-
|
1009 |
-
if ( 'online' == $type ) {
|
1010 |
-
$sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= UTC_TIMESTAMP()";
|
1011 |
-
}
|
1012 |
-
|
1013 |
-
if ( 'alphabetical' == $type ) {
|
1014 |
-
$sql['where_alpha'] = "AND pd.field_id = 1";
|
1015 |
-
}
|
1016 |
-
|
1017 |
-
if ( !empty( $exclude ) ) {
|
1018 |
-
$exclude = implode( ',', wp_parse_id_list( $exclude ) );
|
1019 |
-
$sql['where_exclude'] = "AND u.ID NOT IN ({$exclude})";
|
1020 |
-
}
|
1021 |
-
|
1022 |
-
// Passing an $include value of 0 or '0' will necessarily result in an empty set
|
1023 |
-
// returned. The default value of false will hit the 'else' clause.
|
1024 |
-
if ( 0 === $include || '0' === $include ) {
|
1025 |
-
$sql['where_users'] = "AND 0 = 1";
|
1026 |
-
} else {
|
1027 |
-
if ( !empty( $include ) ) {
|
1028 |
-
$include = implode( ',', wp_parse_id_list( $include ) );
|
1029 |
-
$sql['where_users'] = "AND u.ID IN ({$include})";
|
1030 |
-
} elseif ( !empty( $user_id ) && bp_is_active( 'friends' ) ) {
|
1031 |
-
$friend_ids = friends_get_friend_user_ids( $user_id );
|
1032 |
-
|
1033 |
-
if ( !empty( $friend_ids ) ) {
|
1034 |
-
$friend_ids = implode( ',', wp_parse_id_list( $friend_ids ) );
|
1035 |
-
$sql['where_friends'] = "AND u.ID IN ({$friend_ids})";
|
1036 |
-
|
1037 |
-
// User has no friends, return false since there will be no users to fetch.
|
1038 |
-
} else {
|
1039 |
-
return false;
|
1040 |
-
}
|
1041 |
-
}
|
1042 |
-
}
|
1043 |
-
|
1044 |
-
if ( !empty( $search_terms ) && bp_is_active( 'xprofile' ) ) {
|
1045 |
-
$search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
|
1046 |
-
$sql['where_searchterms'] = $wpdb->prepare( "AND spd.value LIKE %s", $search_terms_like );
|
1047 |
-
}
|
1048 |
-
|
1049 |
-
if ( !empty( $meta_key ) ) {
|
1050 |
-
$sql['where_meta'] = $wpdb->prepare( " AND umm.meta_key = %s", $meta_key );
|
1051 |
-
|
1052 |
-
// If a meta value is provided, match it
|
1053 |
-
if ( $meta_value ) {
|
1054 |
-
$sql['where_meta'] .= $wpdb->prepare( " AND umm.meta_value = %s", $meta_value );
|
1055 |
-
}
|
1056 |
-
}
|
1057 |
-
|
1058 |
-
switch ( $type ) {
|
1059 |
-
case 'active': case 'online': default:
|
1060 |
-
$sql[] = "ORDER BY um.meta_value DESC";
|
1061 |
-
break;
|
1062 |
-
case 'newest':
|
1063 |
-
$sql[] = "ORDER BY u.ID DESC";
|
1064 |
-
break;
|
1065 |
-
case 'alphabetical':
|
1066 |
-
$sql[] = "ORDER BY pd.value ASC";
|
1067 |
-
break;
|
1068 |
-
case 'random':
|
1069 |
-
$sql[] = "ORDER BY rand()";
|
1070 |
-
break;
|
1071 |
-
case 'popular':
|
1072 |
-
$sql[] = "ORDER BY CONVERT(um.meta_value, SIGNED) DESC";
|
1073 |
-
break;
|
1074 |
-
}
|
1075 |
-
|
1076 |
-
if ( !empty( $limit ) && !empty( $page ) ) {
|
1077 |
-
$sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
1078 |
-
}
|
1079 |
-
|
1080 |
-
// Get paginated results
|
1081 |
-
$paged_users_sql = apply_filters( 'bp_core_get_paged_users_sql', join( ' ', (array) $sql ), $sql );
|
1082 |
-
$paged_users = $wpdb->get_results( $paged_users_sql );
|
1083 |
-
|
1084 |
-
// Re-jig the SQL so we can get the total user count
|
1085 |
-
unset( $sql['select_main'] );
|
1086 |
-
|
1087 |
-
if ( !empty( $sql['select_active'] ) ) {
|
1088 |
-
unset( $sql['select_active'] );
|
1089 |
-
}
|
1090 |
-
|
1091 |
-
if ( !empty( $sql['select_popular'] ) ) {
|
1092 |
-
unset( $sql['select_popular'] );
|
1093 |
-
}
|
1094 |
-
|
1095 |
-
if ( !empty( $sql['select_alpha'] ) ) {
|
1096 |
-
unset( $sql['select_alpha'] );
|
1097 |
-
}
|
1098 |
-
|
1099 |
-
if ( !empty( $sql['pagination'] ) ) {
|
1100 |
-
unset( $sql['pagination'] );
|
1101 |
-
}
|
1102 |
-
|
1103 |
-
array_unshift( $sql, "SELECT COUNT(u.ID)" );
|
1104 |
-
|
1105 |
-
// Get total user results
|
1106 |
-
$total_users_sql = apply_filters( 'bp_core_get_total_users_sql', join( ' ', (array) $sql ), $sql );
|
1107 |
-
$total_users = $wpdb->get_var( $total_users_sql );
|
1108 |
-
|
1109 |
-
/***
|
1110 |
-
* Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
|
1111 |
-
* We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
|
1112 |
-
*/
|
1113 |
-
if ( !empty( $populate_extras ) ) {
|
1114 |
-
$user_ids = array();
|
1115 |
-
|
1116 |
-
foreach ( (array) $paged_users as $user ) {
|
1117 |
-
$user_ids[] = $user->id;
|
1118 |
-
}
|
1119 |
-
|
1120 |
-
// Add additional data to the returned results
|
1121 |
-
$paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids, $type );
|
1122 |
-
}
|
1123 |
-
|
1124 |
-
return array( 'users' => $paged_users, 'total' => $total_users );
|
1125 |
-
}
|
1126 |
-
|
1127 |
-
|
1128 |
-
/**
|
1129 |
-
* Fetch the details for all users whose usernames start with the given letter.
|
1130 |
-
*
|
1131 |
-
* @global BuddyPress $bp The one true BuddyPress instance.
|
1132 |
-
* @global wpdb $wpdb WordPress database object.
|
1133 |
-
*
|
1134 |
-
* @param string $letter The letter the users names are to start with.
|
1135 |
-
* @param int $limit The number of users we wish to retrive.
|
1136 |
-
* @param int $page The page number we are currently on, used in
|
1137 |
-
* conjunction with $limit to get the start position for the
|
1138 |
-
* limit.
|
1139 |
-
* @param bool $populate_extras Populate extra user fields?
|
1140 |
-
* @param string $exclude Comma-separated IDs of users whose results
|
1141 |
-
* aren't to be fetched.
|
1142 |
-
* @return mixed False on error, otherwise associative array of results.
|
1143 |
-
*/
|
1144 |
-
public static function get_users_by_letter( $letter, $limit = null, $page = 1, $populate_extras = true, $exclude = '' ) {
|
1145 |
-
global $bp, $wpdb;
|
1146 |
-
|
1147 |
-
$pag_sql = '';
|
1148 |
-
if ( $limit && $page ) {
|
1149 |
-
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
1150 |
-
}
|
1151 |
-
|
1152 |
-
// Multibyte compliance
|
1153 |
-
if ( function_exists( 'mb_strlen' ) ) {
|
1154 |
-
if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || !$letter ) {
|
1155 |
-
return false;
|
1156 |
-
}
|
1157 |
-
} else {
|
1158 |
-
if ( strlen( $letter ) > 1 || is_numeric( $letter ) || !$letter ) {
|
1159 |
-
return false;
|
1160 |
-
}
|
1161 |
-
}
|
1162 |
-
|
1163 |
-
$letter_like = bp_esc_like( $letter ) . '%';
|
1164 |
-
$status_sql = bp_core_get_status_sql( 'u.' );
|
1165 |
-
|
1166 |
-
if ( !empty( $exclude ) ) {
|
1167 |
-
$exclude = implode( ',', wp_parse_id_list( $exclude ) );
|
1168 |
-
$exclude_sql = " AND u.id NOT IN ({$exclude})";
|
1169 |
-
} else {
|
1170 |
-
$exclude_sql = '';
|
1171 |
-
}
|
1172 |
-
|
1173 |
-
$total_users_sql = apply_filters( 'bp_core_users_by_letter_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT u.ID) FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE %s ORDER BY pd.value ASC", bp_xprofile_fullname_field_name(), $letter_like ) );
|
1174 |
-
$paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE %s ORDER BY pd.value ASC{$pag_sql}", bp_xprofile_fullname_field_name(), $letter_like ) );
|
1175 |
-
|
1176 |
-
$total_users = $wpdb->get_var( $total_users_sql );
|
1177 |
-
$paged_users = $wpdb->get_results( $paged_users_sql );
|
1178 |
-
|
1179 |
-
/***
|
1180 |
-
* Lets fetch some other useful data in a separate queries, this will be
|
1181 |
-
* faster than querying the data for every user in a list. We can't add
|
1182 |
-
* these to the main query above since only users who have this
|
1183 |
-
* information will be returned (since the much of the data is in
|
1184 |
-
* usermeta and won't support any type of directional join)
|
1185 |
-
*/
|
1186 |
-
$user_ids = array();
|
1187 |
-
foreach ( (array) $paged_users as $user )
|
1188 |
-
$user_ids[] = (int) $user->id;
|
1189 |
-
|
1190 |
-
// Add additional data to the returned results
|
1191 |
-
if ( $populate_extras ) {
|
1192 |
-
$paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
|
1193 |
-
}
|
1194 |
-
|
1195 |
-
return array( 'users' => $paged_users, 'total' => $total_users );
|
1196 |
-
}
|
1197 |
-
|
1198 |
-
/**
|
1199 |
-
* Get details of specific users from the database.
|
1200 |
-
*
|
1201 |
-
* Use {@link BP_User_Query} with the 'user_ids' param instead.
|
1202 |
-
*
|
1203 |
-
* @global wpdb $wpdb WordPress database object.
|
1204 |
-
* @param array $user_ids The user IDs of the users who we wish to
|
1205 |
-
* fetch information on.
|
1206 |
-
* @param int $limit The limit of results we want.
|
1207 |
-
* @param int $page The page we are on for pagination.
|
1208 |
-
* @param bool $populate_extras Populate extra user fields?
|
1209 |
-
* @return array Associative array.
|
1210 |
-
*/
|
1211 |
-
public static function get_specific_users( $user_ids, $limit = null, $page = 1, $populate_extras = true ) {
|
1212 |
-
global $wpdb;
|
1213 |
-
|
1214 |
-
$pag_sql = '';
|
1215 |
-
if ( $limit && $page )
|
1216 |
-
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
1217 |
-
|
1218 |
-
$user_ids = implode( ',', wp_parse_id_list( $user_ids ) );
|
1219 |
-
$status_sql = bp_core_get_status_sql();
|
1220 |
-
|
1221 |
-
$total_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', "SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql} AND ID IN ({$user_ids})" );
|
1222 |
-
$paged_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', "SELECT ID as id, user_registered, user_nicename, user_login, user_email FROM {$wpdb->users} WHERE {$status_sql} AND ID IN ({$user_ids}) {$pag_sql}" );
|
1223 |
-
|
1224 |
-
$total_users = $wpdb->get_var( $total_users_sql );
|
1225 |
-
$paged_users = $wpdb->get_results( $paged_users_sql );
|
1226 |
-
|
1227 |
-
/***
|
1228 |
-
* Lets fetch some other useful data in a separate queries, this will be
|
1229 |
-
* faster than querying the data for every user in a list. We can't add
|
1230 |
-
* these to the main query above since only users who have this
|
1231 |
-
* information will be returned (since the much of the data is in
|
1232 |
-
* usermeta and won't support any type of directional join)
|
1233 |
-
*/
|
1234 |
-
|
1235 |
-
// Add additional data to the returned results
|
1236 |
-
if ( !empty( $populate_extras ) ) {
|
1237 |
-
$paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
|
1238 |
-
}
|
1239 |
-
|
1240 |
-
return array( 'users' => $paged_users, 'total' => $total_users );
|
1241 |
-
}
|
1242 |
-
|
1243 |
-
/**
|
1244 |
-
* Find users who match on the value of an xprofile data.
|
1245 |
-
*
|
1246 |
-
* @global BuddyPress $bp The one true BuddyPress instance.
|
1247 |
-
* @global wpdb $wpdb WordPress database object.
|
1248 |
-
*
|
1249 |
-
* @param string $search_terms The terms to search the profile table
|
1250 |
-
* value column for.
|
1251 |
-
* @param integer $limit The limit of results we want.
|
1252 |
-
* @param integer $page The page we are on for pagination.
|
1253 |
-
* @param boolean $populate_extras Populate extra user fields?
|
1254 |
-
* @return array Associative array.
|
1255 |
-
*/
|
1256 |
-
public static function search_users( $search_terms, $limit = null, $page = 1, $populate_extras = true ) {
|
1257 |
-
global $bp, $wpdb;
|
1258 |
-
|
1259 |
-
$user_ids = array();
|
1260 |
-
$pag_sql = $limit && $page ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * intval( $limit ) ), intval( $limit ) ) : '';
|
1261 |
-
|
1262 |
-
$search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
|
1263 |
-
$status_sql = bp_core_get_status_sql( 'u.' );
|
1264 |
-
|
1265 |
-
$total_users_sql = apply_filters( 'bp_core_search_users_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT u.ID) as id FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE %s ORDER BY pd.value ASC", $search_terms_like ), $search_terms );
|
1266 |
-
$paged_users_sql = apply_filters( 'bp_core_search_users_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE %s ORDER BY pd.value ASC{$pag_sql}", $search_terms_like ), $search_terms, $pag_sql );
|
1267 |
-
|
1268 |
-
$total_users = $wpdb->get_var( $total_users_sql );
|
1269 |
-
$paged_users = $wpdb->get_results( $paged_users_sql );
|
1270 |
-
|
1271 |
-
/***
|
1272 |
-
* Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
|
1273 |
-
* We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
|
1274 |
-
*/
|
1275 |
-
foreach ( (array) $paged_users as $user )
|
1276 |
-
$user_ids[] = $user->id;
|
1277 |
-
|
1278 |
-
// Add additional data to the returned results
|
1279 |
-
if ( $populate_extras )
|
1280 |
-
$paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
|
1281 |
-
|
1282 |
-
return array( 'users' => $paged_users, 'total' => $total_users );
|
1283 |
-
}
|
1284 |
-
|
1285 |
-
/**
|
1286 |
-
* Fetch extra user information, such as friend count and last profile update message.
|
1287 |
-
*
|
1288 |
-
* Accepts multiple user IDs to fetch data for.
|
1289 |
-
*
|
1290 |
-
* @global BuddyPress $bp The one true BuddyPress instance.
|
1291 |
-
* @global wpdb $wpdb WordPress database object.
|
1292 |
-
*
|
1293 |
-
* @param array $paged_users An array of stdClass containing the users.
|
1294 |
-
* @param string $user_ids The user ids to select information about.
|
1295 |
-
* @param string $type The type of fields we wish to get.
|
1296 |
-
* @return mixed False on error, otherwise associative array of results.
|
1297 |
-
*/
|
1298 |
-
public static function get_user_extras( &$paged_users, &$user_ids, $type = false ) {
|
1299 |
-
global $bp, $wpdb;
|
1300 |
-
|
1301 |
-
if ( empty( $user_ids ) )
|
1302 |
-
return $paged_users;
|
1303 |
-
|
1304 |
-
// Sanitize user IDs
|
1305 |
-
$user_ids = implode( ',', wp_parse_id_list( $user_ids ) );
|
1306 |
-
|
1307 |
-
// Fetch the user's full name
|
1308 |
-
if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) {
|
1309 |
-
$names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", bp_xprofile_fullname_field_name() ) );
|
1310 |
-
for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
|
1311 |
-
foreach ( (array) $names as $name ) {
|
1312 |
-
if ( $name->id == $paged_users[$i]->id )
|
1313 |
-
$paged_users[$i]->fullname = $name->fullname;
|
1314 |
-
}
|
1315 |
-
}
|
1316 |
-
}
|
1317 |
-
|
1318 |
-
// Fetch the user's total friend count
|
1319 |
-
if ( 'popular' != $type ) {
|
1320 |
-
$friend_count = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as total_friend_count FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'total_friend_count' ) ) );
|
1321 |
-
for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
|
1322 |
-
foreach ( (array) $friend_count as $fcount ) {
|
1323 |
-
if ( $fcount->id == $paged_users[$i]->id )
|
1324 |
-
$paged_users[$i]->total_friend_count = (int) $fcount->total_friend_count;
|
1325 |
-
}
|
1326 |
-
}
|
1327 |
-
}
|
1328 |
-
|
1329 |
-
// Fetch whether or not the user is a friend
|
1330 |
-
if ( bp_is_active( 'friends' ) ) {
|
1331 |
-
$friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", bp_loggedin_user_id(), bp_loggedin_user_id() ) );
|
1332 |
-
for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
|
1333 |
-
foreach ( (array) $friend_status as $status ) {
|
1334 |
-
if ( $status->initiator_user_id == $paged_users[$i]->id || $status->friend_user_id == $paged_users[$i]->id )
|
1335 |
-
$paged_users[$i]->is_friend = $status->is_confirmed;
|
1336 |
-
}
|
1337 |
-
}
|
1338 |
-
}
|
1339 |
-
|
1340 |
-
if ( 'active' != $type ) {
|
1341 |
-
$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' ) ) );
|
1342 |
-
for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
|
1343 |
-
foreach ( (array) $user_activity as $activity ) {
|
1344 |
-
if ( $activity->id == $paged_users[$i]->id )
|
1345 |
-
$paged_users[$i]->last_activity = $activity->last_activity;
|
1346 |
-
}
|
1347 |
-
}
|
1348 |
-
}
|
1349 |
-
|
1350 |
-
// Fetch the user's last_activity
|
1351 |
-
if ( 'active' != $type ) {
|
1352 |
-
$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' ) ) );
|
1353 |
-
for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
|
1354 |
-
foreach ( (array) $user_activity as $activity ) {
|
1355 |
-
if ( $activity->id == $paged_users[$i]->id )
|
1356 |
-
$paged_users[$i]->last_activity = $activity->last_activity;
|
1357 |
-
}
|
1358 |
-
}
|
1359 |
-
}
|
1360 |
-
|
1361 |
-
// Fetch the user's latest update
|
1362 |
-
$user_update = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as latest_update FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'bp_latest_update' ) ) );
|
1363 |
-
for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
|
1364 |
-
foreach ( (array) $user_update as $update ) {
|
1365 |
-
if ( $update->id == $paged_users[$i]->id )
|
1366 |
-
$paged_users[$i]->latest_update = $update->latest_update;
|
1367 |
-
}
|
1368 |
-
}
|
1369 |
-
|
1370 |
-
return $paged_users;
|
1371 |
-
}
|
1372 |
-
|
1373 |
-
/**
|
1374 |
-
* Get WordPress user details for a specified user.
|
1375 |
-
*
|
1376 |
-
* @global wpdb $wpdb WordPress database object.
|
1377 |
-
*
|
1378 |
-
* @param integer $user_id User ID.
|
1379 |
-
* @return array Associative array.
|
1380 |
-
*/
|
1381 |
-
public static function get_core_userdata( $user_id ) {
|
1382 |
-
global $wpdb;
|
1383 |
-
|
1384 |
-
if ( !$user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->users} WHERE ID = %d LIMIT 1", $user_id ) ) )
|
1385 |
-
return false;
|
1386 |
-
|
1387 |
-
return $user;
|
1388 |
-
}
|
1389 |
-
|
1390 |
-
/**
|
1391 |
-
* Get last activity data for a user or set of users.
|
1392 |
-
*
|
1393 |
-
* @param int|array User IDs or multiple user IDs.
|
1394 |
-
* @return array
|
1395 |
-
*/
|
1396 |
-
public static function get_last_activity( $user_id ) {
|
1397 |
-
global $wpdb;
|
1398 |
-
|
1399 |
-
// Sanitize and remove empty values
|
1400 |
-
$user_ids = array_filter( wp_parse_id_list( $user_id ) );
|
1401 |
-
|
1402 |
-
if ( empty( $user_ids ) ) {
|
1403 |
-
return false;
|
1404 |
-
}
|
1405 |
-
|
1406 |
-
$uncached_user_ids = bp_get_non_cached_ids( $user_ids, 'bp_last_activity' );
|
1407 |
-
if ( ! empty( $uncached_user_ids ) ) {
|
1408 |
-
$bp = buddypress();
|
1409 |
-
|
1410 |
-
$user_ids_sql = implode( ',', $uncached_user_ids );
|
1411 |
-
$user_count = count( $uncached_user_ids );
|
1412 |
-
|
1413 |
-
$last_activities = $wpdb->get_results( $wpdb->prepare( "SELECT id, user_id, date_recorded FROM {$bp->members->table_name_last_activity} WHERE component = %s AND type = 'last_activity' AND user_id IN ({$user_ids_sql}) LIMIT {$user_count}", $bp->members->id ) );
|
1414 |
-
|
1415 |
-
foreach ( $last_activities as $last_activity ) {
|
1416 |
-
wp_cache_set( $last_activity->user_id, array(
|
1417 |
-
'user_id' => $last_activity->user_id,
|
1418 |
-
'date_recorded' => $last_activity->date_recorded,
|
1419 |
-
'activity_id' => $last_activity->id,
|
1420 |
-
), 'bp_last_activity' );
|
1421 |
-
}
|
1422 |
-
}
|
1423 |
-
|
1424 |
-
// Fetch all user data from the cache
|
1425 |
-
$retval = array();
|
1426 |
-
foreach ( $user_ids as $user_id ) {
|
1427 |
-
$retval[ $user_id ] = wp_cache_get( $user_id, 'bp_last_activity' );
|
1428 |
-
}
|
1429 |
-
|
1430 |
-
return $retval;
|
1431 |
-
}
|
1432 |
-
|
1433 |
-
/**
|
1434 |
-
* Set a user's last_activity value.
|
1435 |
-
*
|
1436 |
-
* Will create a new entry if it does not exist. Otherwise updates the
|
1437 |
-
* existing entry.
|
1438 |
-
*
|
1439 |
-
* @since 2.0
|
1440 |
-
*
|
1441 |
-
* @param int $user_id ID of the user whose last_activity you are updating.
|
1442 |
-
* @param string $time MySQL-formatted time string.
|
1443 |
-
* @return bool True on success, false on failure.
|
1444 |
-
*/
|
1445 |
-
public static function update_last_activity( $user_id, $time ) {
|
1446 |
-
global $wpdb;
|
1447 |
-
|
1448 |
-
$table_name = buddypress()->members->table_name_last_activity;
|
1449 |
-
|
1450 |
-
$activity = self::get_last_activity( $user_id );
|
1451 |
-
|
1452 |
-
if ( ! empty( $activity[ $user_id ] ) ) {
|
1453 |
-
$updated = $wpdb->update(
|
1454 |
-
$table_name,
|
1455 |
-
|
1456 |
-
// Data to update
|
1457 |
-
array(
|
1458 |
-
'date_recorded' => $time,
|
1459 |
-
),
|
1460 |
-
|
1461 |
-
// WHERE
|
1462 |
-
array(
|
1463 |
-
'id' => $activity[ $user_id ]['activity_id'],
|
1464 |
-
),
|
1465 |
-
|
1466 |
-
// Data sanitization format
|
1467 |
-
array(
|
1468 |
-
'%s',
|
1469 |
-
),
|
1470 |
-
|
1471 |
-
// WHERE sanitization format
|
1472 |
-
array(
|
1473 |
-
'%d',
|
1474 |
-
)
|
1475 |
-
);
|
1476 |
-
|
1477 |
-
// add new date to existing activity entry for caching
|
1478 |
-
$activity[ $user_id ]['date_recorded'] = $time;
|
1479 |
-
|
1480 |
-
} else {
|
1481 |
-
$updated = $wpdb->insert(
|
1482 |
-
$table_name,
|
1483 |
-
|
1484 |
-
// Data
|
1485 |
-
array(
|
1486 |
-
'user_id' => $user_id,
|
1487 |
-
'component' => buddypress()->members->id,
|
1488 |
-
'type' => 'last_activity',
|
1489 |
-
'action' => '',
|
1490 |
-
'content' => '',
|
1491 |
-
'primary_link' => '',
|
1492 |
-
'item_id' => 0,
|
1493 |
-
'date_recorded' => $time,
|
1494 |
-
),
|
1495 |
-
|
1496 |
-
// Data sanitization format
|
1497 |
-
array(
|
1498 |
-
'%d',
|
1499 |
-
'%s',
|
1500 |
-
'%s',
|
1501 |
-
'%s',
|
1502 |
-
'%s',
|
1503 |
-
'%s',
|
1504 |
-
'%d',
|
1505 |
-
'%s',
|
1506 |
-
)
|
1507 |
-
);
|
1508 |
-
|
1509 |
-
// set up activity array for caching
|
1510 |
-
// view the foreach loop in the get_last_activity() method for format
|
1511 |
-
$activity = array();
|
1512 |
-
$activity[ $user_id ] = array(
|
1513 |
-
'user_id' => $user_id,
|
1514 |
-
'date_recorded' => $time,
|
1515 |
-
'activity_id' => $wpdb->insert_id,
|
1516 |
-
);
|
1517 |
-
}
|
1518 |
-
|
1519 |
-
// set cache
|
1520 |
-
wp_cache_set( $user_id, $activity[ $user_id ], 'bp_last_activity' );
|
1521 |
-
|
1522 |
-
return $updated;
|
1523 |
-
}
|
1524 |
-
|
1525 |
-
/**
|
1526 |
-
* Delete a user's last_activity value.
|
1527 |
-
*
|
1528 |
-
* @since 2.0
|
1529 |
-
*
|
1530 |
-
* @param int $user_id
|
1531 |
-
* @return bool True on success, false on failure or if no last_activity
|
1532 |
-
* is found for the user.
|
1533 |
-
*/
|
1534 |
-
public static function delete_last_activity( $user_id ) {
|
1535 |
-
global $wpdb;
|
1536 |
-
|
1537 |
-
$existing = self::get_last_activity( $user_id );
|
1538 |
-
|
1539 |
-
if ( empty( $existing ) ) {
|
1540 |
-
return false;
|
1541 |
-
}
|
1542 |
-
|
1543 |
-
$deleted = $wpdb->delete(
|
1544 |
-
buddypress()->members->table_name_last_activity,
|
1545 |
-
|
1546 |
-
// WHERE
|
1547 |
-
array(
|
1548 |
-
'id' => $existing[ $user_id ]['activity_id'],
|
1549 |
-
),
|
1550 |
-
|
1551 |
-
// WHERE sanitization format
|
1552 |
-
array(
|
1553 |
-
'%s',
|
1554 |
-
)
|
1555 |
-
);
|
1556 |
-
|
1557 |
-
wp_cache_delete( $user_id, 'bp_last_activity' );
|
1558 |
-
|
1559 |
-
return $deleted;
|
1560 |
-
}
|
1561 |
-
}
|
1562 |
-
|
1563 |
-
if ( class_exists( 'WP_Date_Query' ) ) :
|
1564 |
-
/**
|
1565 |
-
* BuddyPress date query class.
|
1566 |
-
*
|
1567 |
-
* Extends the {@link WP_Date_Query} class for use with BuddyPress.
|
1568 |
-
*
|
1569 |
-
* @since BuddyPress (2.1.0)
|
1570 |
-
*
|
1571 |
-
* @param array $date_query {
|
1572 |
-
* Date query arguments. See first parameter of {@link WP_Date_Query::__construct()}.
|
1573 |
-
* }
|
1574 |
-
* @param string $column The DB column to query against.
|
1575 |
-
*/
|
1576 |
-
class BP_Date_Query extends WP_Date_Query {
|
1577 |
-
/**
|
1578 |
-
* The column to query against. Can be changed via the query arguments.
|
1579 |
-
*
|
1580 |
-
* @var string
|
1581 |
-
*/
|
1582 |
-
public $column;
|
1583 |
-
|
1584 |
-
/**
|
1585 |
-
* Constructor.
|
1586 |
-
*
|
1587 |
-
* @see WP_Date_Query::__construct()
|
1588 |
-
*/
|
1589 |
-
public function __construct( $date_query, $column = '' ) {
|
1590 |
-
if ( ! empty( $column ) ) {
|
1591 |
-
$this->column = $column;
|
1592 |
-
add_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) );
|
1593 |
-
}
|
1594 |
-
|
1595 |
-
parent::__construct( $date_query, $column );
|
1596 |
-
}
|
1597 |
-
|
1598 |
-
/**
|
1599 |
-
* Destructor.
|
1600 |
-
*/
|
1601 |
-
public function __destruct() {
|
1602 |
-
remove_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) );
|
1603 |
-
}
|
1604 |
-
|
1605 |
-
/**
|
1606 |
-
* Registers our date column with WP Date Query to pass validation.
|
1607 |
-
*
|
1608 |
-
* @param array $retval Current DB columns
|
1609 |
-
* @return array
|
1610 |
-
*/
|
1611 |
-
public function register_date_column( $retval = array() ) {
|
1612 |
-
$retval[] = $this->column;
|
1613 |
-
return $retval;
|
1614 |
-
}
|
1615 |
-
}
|
1616 |
-
endif;
|
1617 |
-
|
1618 |
-
/**
|
1619 |
-
* BP_Core_Notification is deprecated.
|
1620 |
-
*
|
1621 |
-
* Use BP_Notifications_Notification instead.
|
1622 |
-
*
|
1623 |
-
* @package BuddyPress Core
|
1624 |
-
* @deprecated since BuddyPress (1.9)
|
1625 |
-
*/
|
1626 |
-
class BP_Core_Notification {
|
1627 |
-
|
1628 |
-
/**
|
1629 |
-
* The notification id
|
1630 |
-
*
|
1631 |
-
* @var integer
|
1632 |
-
*/
|
1633 |
-
public $id;
|
1634 |
-
|
1635 |
-
/**
|
1636 |
-
* The ID to which the notification relates to within the component.
|
1637 |
-
*
|
1638 |
-
* @var integer
|
1639 |
-
*/
|
1640 |
-
public $item_id;
|
1641 |
-
|
1642 |
-
/**
|
1643 |
-
* The secondary ID to which the notification relates to within the component.
|
1644 |
-
*
|
1645 |
-
* @var integer
|
1646 |
-
*/
|
1647 |
-
public $secondary_item_id = null;
|
1648 |
-
|
1649 |
-
/**
|
1650 |
-
* The user ID for who the notification is for.
|
1651 |
-
*
|
1652 |
-
* @var integer
|
1653 |
-
*/
|
1654 |
-
public $user_id;
|
1655 |
-
|
1656 |
-
/**
|
1657 |
-
* The name of the component that the notification is for.
|
1658 |
-
*
|
1659 |
-
* @var string
|
1660 |
-
*/
|
1661 |
-
public $component_name;
|
1662 |
-
|
1663 |
-
/**
|
1664 |
-
* The action within the component which the notification is related to.
|
1665 |
-
*
|
1666 |
-
* @var string
|
1667 |
-
*/
|
1668 |
-
public $component_action;
|
1669 |
-
|
1670 |
-
/**
|
1671 |
-
* The date the notification was created.
|
1672 |
-
*
|
1673 |
-
* @var string
|
1674 |
-
*/
|
1675 |
-
public $date_notified;
|
1676 |
-
|
1677 |
-
/**
|
1678 |
-
* Is the notification new or has it already been read.
|
1679 |
-
*
|
1680 |
-
* @var boolean
|
1681 |
-
*/
|
1682 |
-
public $is_new;
|
1683 |
-
|
1684 |
-
/** Public Methods ********************************************************/
|
1685 |
-
|
1686 |
-
/**
|
1687 |
-
* Constructor
|
1688 |
-
*
|
1689 |
-
* @param integer $id
|
1690 |
-
*/
|
1691 |
-
public function __construct( $id = 0 ) {
|
1692 |
-
if ( !empty( $id ) ) {
|
1693 |
-
$this->id = $id;
|
1694 |
-
$this->populate();
|
1695 |
-
}
|
1696 |
-
}
|
1697 |
-
|
1698 |
-
/**
|
1699 |
-
* Update or insert notification details into the database.
|
1700 |
-
*
|
1701 |
-
* @global BuddyPress $bp The one true BuddyPress instance
|
1702 |
-
* @global wpdb $wpdb WordPress database object
|
1703 |
-
* @return bool Success or failure
|
1704 |
-
*/
|
1705 |
-
public function save() {
|
1706 |
-
global $bp, $wpdb;
|
1707 |
-
|
1708 |
-
// Update
|
1709 |
-
if ( !empty( $this->id ) ) {
|
1710 |
-
$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 );
|
1711 |
-
|
1712 |
-
// Save
|
1713 |
-
} else {
|
1714 |
-
$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 );
|
1715 |
-
}
|
1716 |
-
|
1717 |
-
if ( !$result = $wpdb->query( $sql ) )
|
1718 |
-
return false;
|
1719 |
-
|
1720 |
-
$this->id = $wpdb->insert_id;
|
1721 |
-
|
1722 |
-
return true;
|
1723 |
-
}
|
1724 |
-
|
1725 |
-
/** Private Methods *******************************************************/
|
1726 |
-
|
1727 |
-
/**
|
1728 |
-
* Fetches the notification data from the database.
|
1729 |
-
*
|
1730 |
-
* @global BuddyPress $bp The one true BuddyPress instance
|
1731 |
-
* @global wpdb $wpdb WordPress database object
|
1732 |
-
*/
|
1733 |
-
public function populate() {
|
1734 |
-
global $bp, $wpdb;
|
1735 |
-
|
1736 |
-
if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) {
|
1737 |
-
$this->item_id = $notification->item_id;
|
1738 |
-
$this->secondary_item_id = $notification->secondary_item_id;
|
1739 |
-
$this->user_id = $notification->user_id;
|
1740 |
-
$this->component_name = $notification->component_name;
|
1741 |
-
$this->component_action = $notification->component_action;
|
1742 |
-
$this->date_notified = $notification->date_notified;
|
1743 |
-
$this->is_new = $notification->is_new;
|
1744 |
-
}
|
1745 |
-
}
|
1746 |
-
|
1747 |
-
/** Static Methods ********************************************************/
|
1748 |
-
|
1749 |
-
public static function check_access( $user_id, $notification_id ) {
|
1750 |
-
global $wpdb, $bp;
|
1751 |
-
|
1752 |
-
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 ) );
|
1753 |
-
}
|
1754 |
-
|
1755 |
-
/**
|
1756 |
-
* Fetches all the notifications in the database for a specific user.
|
1757 |
-
*
|
1758 |
-
* @global BuddyPress $bp The one true BuddyPress instance
|
1759 |
-
* @global wpdb $wpdb WordPress database object
|
1760 |
-
* @param integer $user_id User ID
|
1761 |
-
* @param string $status 'is_new' or 'all'
|
1762 |
-
* @return array Associative array
|
1763 |
-
* @static
|
1764 |
-
*/
|
1765 |
-
public static function get_all_for_user( $user_id, $status = 'is_new' ) {
|
1766 |
-
global $bp, $wpdb;
|
1767 |
-
|
1768 |
-
$is_new = ( 'is_new' == $status ) ? ' AND is_new = 1 ' : '';
|
1769 |
-
|
1770 |
-
return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d {$is_new}", $user_id ) );
|
1771 |
-
}
|
1772 |
-
|
1773 |
-
/**
|
1774 |
-
* Delete all the notifications for a user based on the component name and action.
|
1775 |
-
*
|
1776 |
-
* @global BuddyPress $bp The one true BuddyPress instance
|
1777 |
-
* @global wpdb $wpdb WordPress database object
|
1778 |
-
* @param integer $user_id
|
1779 |
-
* @param string $component_name
|
1780 |
-
* @param string $component_action
|
1781 |
-
* @static
|
1782 |
-
*/
|
1783 |
-
public static function delete_for_user_by_type( $user_id, $component_name, $component_action ) {
|
1784 |
-
global $bp, $wpdb;
|
1785 |
-
|
1786 |
-
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 ) );
|
1787 |
-
}
|
1788 |
-
|
1789 |
-
/**
|
1790 |
-
* Delete all the notifications that have a specific item id, component name and action.
|
1791 |
-
*
|
1792 |
-
* @global BuddyPress $bp The one true BuddyPress instance
|
1793 |
-
* @global wpdb $wpdb WordPress database object
|
1794 |
-
* @param integer $user_id The ID of the user who the notifications are for.
|
1795 |
-
* @param integer $item_id The item ID of the notifications we wish to delete.
|
1796 |
-
* @param string $component_name The name of the component that the notifications we wish to delete.
|
1797 |
-
* @param string $component_action The action of the component that the notifications we wish to delete.
|
1798 |
-
* @param integer $secondary_item_id (optional) The secondary item id of the notifications that we wish to use to delete.
|
1799 |
-
* @static
|
1800 |
-
*/
|
1801 |
-
public static function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) {
|
1802 |
-
global $bp, $wpdb;
|
1803 |
-
|
1804 |
-
$secondary_item_sql = !empty( $secondary_item_id ) ? $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id ) : '';
|
1805 |
-
|
1806 |
-
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 ) );
|
1807 |
-
}
|
1808 |
-
|
1809 |
-
/**
|
1810 |
-
* Deletes all the notifications sent by a specific user, by component and action.
|
1811 |
-
*
|
1812 |
-
* @global BuddyPress $bp The one true BuddyPress instance
|
1813 |
-
* @global wpdb $wpdb WordPress database object
|
1814 |
-
* @param integer $user_id The ID of the user whose sent notifications we wish to delete.
|
1815 |
-
* @param string $component_name The name of the component the notification was sent from.
|
1816 |
-
* @param string $component_action The action of the component the notification was sent from.
|
1817 |
-
* @static
|
1818 |
-
*/
|
1819 |
-
public static function delete_from_user_by_type( $user_id, $component_name, $component_action ) {
|
1820 |
-
global $bp, $wpdb;
|
1821 |
-
|
1822 |
-
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 ) );
|
1823 |
-
}
|
1824 |
-
|
1825 |
-
/**
|
1826 |
-
* Deletes all the notifications for all users by item id, and optional secondary item id, and component name and action.
|
1827 |
-
*
|
1828 |
-
* @global BuddyPress $bp The one true BuddyPress instance
|
1829 |
-
* @global wpdb $wpdb WordPress database object
|
1830 |
-
* @param string $item_id The item id that they notifications are to be for.
|
1831 |
-
* @param string $component_name The component that the notifications are to be from.
|
1832 |
-
* @param string $component_action The action that the notifications are to be from.
|
1833 |
-
* @param string $secondary_item_id Optional secondary item id that the notifications are to have.
|
1834 |
-
* @static
|
1835 |
-
*/
|
1836 |
-
public static function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) {
|
1837 |
-
global $bp, $wpdb;
|
1838 |
-
|
1839 |
-
if ( $component_action )
|
1840 |
-
$component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action );
|
1841 |
-
else
|
1842 |
-
$component_action_sql = '';
|
1843 |
-
|
1844 |
-
if ( $secondary_item_id )
|
1845 |
-
$secondary_item_sql = $wpdb->prepare( "AND secondary_item_id = %d", $secondary_item_id );
|
1846 |
-
else
|
1847 |
-
$secondary_item_sql = '';
|
1848 |
-
|
1849 |
-
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 ) );
|
1850 |
-
}
|
1851 |
-
}
|
1852 |
-
|
1853 |
-
/**
|
1854 |
-
* API to create BuddyPress buttons.
|
1855 |
-
*
|
1856 |
-
* @since BuddyPress (1.2.6)
|
1857 |
-
*
|
1858 |
-
* @param array $args {
|
1859 |
-
* Array of arguments.
|
1860 |
-
* @type string $id String describing the button type.
|
1861 |
-
* @type string $component The name of the component the button belongs to.
|
1862 |
-
* Default: 'core'.
|
1863 |
-
* @type bool $must_be_logged_in Optional. Does the user need to be logged
|
1864 |
-
* in to see this button? Default: true.
|
1865 |
-
* @type bool $block_self Optional. True if the button should be hidden
|
1866 |
-
* when a user is viewing his own profile. Default: true.
|
1867 |
-
* @type string|bool $wrapper Optional. HTML element type that should wrap
|
1868 |
-
* the button: 'div', 'span', 'p', or 'li'. False for no wrapper at
|
1869 |
-
* all. Default: 'div'.
|
1870 |
-
* @type string $wrapper_id Optional. DOM ID of the button wrapper element.
|
1871 |
-
* Default: ''.
|
1872 |
-
* @type string $wrapper_class Optional. DOM class of the button wrapper
|
1873 |
-
* element. Default: ''.
|
1874 |
-
* @type string $link_href Optional. Destination link of the button.
|
1875 |
-
* Default: ''.
|
1876 |
-
* @type string $link_class Optional. DOM class of the button. Default: ''.
|
1877 |
-
* @type string $link_id Optional. DOM ID of the button. Default: ''.
|
1878 |
-
* @type string $link_rel Optional. DOM 'rel' attribute of the button.
|
1879 |
-
* Default: ''.
|
1880 |
-
* @type string $link_title Optional. Title attribute of the button.
|
1881 |
-
* Default: ''.
|
1882 |
-
* @type string $link_text Optional. Text to appear on the button.
|
1883 |
-
* Default: ''.
|
1884 |
-
* }
|
1885 |
-
*/
|
1886 |
-
class BP_Button {
|
1887 |
-
|
1888 |
-
/** Button properties *****************************************************/
|
1889 |
-
|
1890 |
-
/**
|
1891 |
-
* The button ID.
|
1892 |
-
*
|
1893 |
-
* @var string
|
1894 |
-
*/
|
1895 |
-
public $id = '';
|
1896 |
-
|
1897 |
-
/**
|
1898 |
-
* The name of the component that the button belongs to.
|
1899 |
-
*
|
1900 |
-
* @var string
|
1901 |
-
*/
|
1902 |
-
public $component = 'core';
|
1903 |
-
|
1904 |
-
/**
|
1905 |
-
* Does the user need to be logged in to see this button?
|
1906 |
-
*
|
1907 |
-
* @var bool
|
1908 |
-
*/
|
1909 |
-
public $must_be_logged_in = true;
|
1910 |
-
|
1911 |
-
/**
|
1912 |
-
* Whether the button should be hidden when viewing your own profile.
|
1913 |
-
*
|
1914 |
-
* @var bool
|
1915 |
-
*/
|
1916 |
-
public $block_self = true;
|
1917 |
-
|
1918 |
-
/** Wrapper ***************************************************************/
|
1919 |
-
|
1920 |
-
/**
|
1921 |
-
* The type of DOM element to use for a wrapper.
|
1922 |
-
*
|
1923 |
-
* @var string|bool 'div', 'span', 'p', 'li', or false for no wrapper.
|
1924 |
-
*/
|
1925 |
-
public $wrapper = 'div';
|
1926 |
-
|
1927 |
-
/**
|
1928 |
-
* The DOM class of the button wrapper.
|
1929 |
-
*
|
1930 |
-
* @var string
|
1931 |
-
*/
|
1932 |
-
public $wrapper_class = '';
|
1933 |
-
|
1934 |
-
/**
|
1935 |
-
* The DOM ID of the button wrapper.
|
1936 |
-
*
|
1937 |
-
* @var string
|
1938 |
-
*/
|
1939 |
-
public $wrapper_id = '';
|
1940 |
-
|
1941 |
-
/** Button ****************************************************************/
|
1942 |
-
|
1943 |
-
/**
|
1944 |
-
* The destination link of the button.
|
1945 |
-
*
|
1946 |
-
* @var string
|
1947 |
-
*/
|
1948 |
-
public $link_href = '';
|
1949 |
-
|
1950 |
-
/**
|
1951 |
-
* The DOM class of the button link.
|
1952 |
-
*
|
1953 |
-
* @var string
|
1954 |
-
*/
|
1955 |
-
public $link_class = '';
|
1956 |
-
|
1957 |
-
/**
|
1958 |
-
* The DOM ID of the button link.
|
1959 |
-
*
|
1960 |
-
* @var string
|
1961 |
-
*/
|
1962 |
-
public $link_id = '';
|
1963 |
-
|
1964 |
-
/**
|
1965 |
-
* The DOM rel value of the button link.
|
1966 |
-
*
|
1967 |
-
* @var string
|
1968 |
-
*/
|
1969 |
-
public $link_rel = '';
|
1970 |
-
|
1971 |
-
/**
|
1972 |
-
* Title of the button link.
|
1973 |
-
*
|
1974 |
-
* @var string
|
1975 |
-
*/
|
1976 |
-
public $link_title = '';
|
1977 |
-
|
1978 |
-
/**
|
1979 |
-
* The contents of the button link.
|
1980 |
-
*
|
1981 |
-
* @var string
|
1982 |
-
*/
|
1983 |
-
public $link_text = '';
|
1984 |
-
|
1985 |
-
/** HTML result ***********************************************************/
|
1986 |
-
|
1987 |
-
public $contents = '';
|
1988 |
-
|
1989 |
-
/** Methods ***************************************************************/
|
1990 |
-
|
1991 |
-
/**
|
1992 |
-
* Builds the button based on class parameters.
|
1993 |
-
*
|
1994 |
-
* @since BuddyPress (1.2.6)
|
1995 |
-
*
|
1996 |
-
* @param array $args See {@BP_Button}.
|
1997 |
-
* @return bool|null Returns false when the button is not allowed for
|
1998 |
-
* the current context.
|
1999 |
-
*/
|
2000 |
-
public function __construct( $args = '' ) {
|
2001 |
-
|
2002 |
-
$r = wp_parse_args( $args, get_class_vars( __CLASS__ ) );
|
2003 |
-
|
2004 |
-
// Required button properties
|
2005 |
-
$this->id = $r['id'];
|
2006 |
-
$this->component = $r['component'];
|
2007 |
-
$this->must_be_logged_in = (bool) $r['must_be_logged_in'];
|
2008 |
-
$this->block_self = (bool) $r['block_self'];
|
2009 |
-
$this->wrapper = $r['wrapper'];
|
2010 |
-
|
2011 |
-
// $id and $component are required
|
2012 |
-
if ( empty( $r['id'] ) || empty( $r['component'] ) )
|
2013 |
-
return false;
|
2014 |
-
|
2015 |
-
// No button if component is not active
|
2016 |
-
if ( ! bp_is_active( $this->component ) )
|
2017 |
-
return false;
|
2018 |
-
|
2019 |
-
// No button for guests if must be logged in
|
2020 |
-
if ( true == $this->must_be_logged_in && ! is_user_logged_in() )
|
2021 |
-
return false;
|
2022 |
-
|
2023 |
-
// block_self
|
2024 |
-
if ( true == $this->block_self ) {
|
2025 |
-
// No button if you are the current user in a members loop
|
2026 |
-
// This condition takes precedence, because members loops
|
2027 |
-
// can be found on user profiles
|
2028 |
-
if ( bp_get_member_user_id() ) {
|
2029 |
-
if ( is_user_logged_in() && bp_loggedin_user_id() == bp_get_member_user_id() ) {
|
2030 |
-
return false;
|
2031 |
-
}
|
2032 |
-
|
2033 |
-
// No button if viewing your own profile (and not in
|
2034 |
-
// a members loop)
|
2035 |
-
} elseif ( bp_is_my_profile() ) {
|
2036 |
-
return false;
|
2037 |
-
}
|
2038 |
-
}
|
2039 |
-
|
2040 |
-
// Wrapper properties
|
2041 |
-
if ( false !== $this->wrapper ) {
|
2042 |
-
|
2043 |
-
// Wrapper ID
|
2044 |
-
if ( !empty( $r['wrapper_id'] ) ) {
|
2045 |
-
$this->wrapper_id = ' id="' . $r['wrapper_id'] . '"';
|
2046 |
-
}
|
2047 |
-
|
2048 |
-
// Wrapper class
|
2049 |
-
if ( !empty( $r['wrapper_class'] ) ) {
|
2050 |
-
$this->wrapper_class = ' class="generic-button ' . $r['wrapper_class'] . '"';
|
2051 |
-
} else {
|
2052 |
-
$this->wrapper_class = ' class="generic-button"';
|
2053 |
-
}
|
2054 |
-
|
2055 |
-
// Set before and after
|
2056 |
-
$before = '<' . $r['wrapper'] . $this->wrapper_class . $this->wrapper_id . '>';
|
2057 |
-
$after = '</' . $r['wrapper'] . '>';
|
2058 |
-
|
2059 |
-
// No wrapper
|
2060 |
-
} else {
|
2061 |
-
$before = $after = '';
|
2062 |
-
}
|
2063 |
-
|
2064 |
-
// Link properties
|
2065 |
-
if ( !empty( $r['link_id'] ) ) $this->link_id = ' id="' . $r['link_id'] . '"';
|
2066 |
-
if ( !empty( $r['link_href'] ) ) $this->link_href = ' href="' . $r['link_href'] . '"';
|
2067 |
-
if ( !empty( $r['link_title'] ) ) $this->link_title = ' title="' . $r['link_title'] . '"';
|
2068 |
-
if ( !empty( $r['link_rel'] ) ) $this->link_rel = ' rel="' . $r['link_rel'] . '"';
|
2069 |
-
if ( !empty( $r['link_class'] ) ) $this->link_class = ' class="' . $r['link_class'] . '"';
|
2070 |
-
if ( !empty( $r['link_text'] ) ) $this->link_text = $r['link_text'];
|
2071 |
-
|
2072 |
-
// Build the button
|
2073 |
-
$this->contents = $before . '<a'. $this->link_href . $this->link_title . $this->link_id . $this->link_rel . $this->link_class . '>' . $this->link_text . '</a>' . $after;
|
2074 |
-
|
2075 |
-
// Allow button to be manipulated externally
|
2076 |
-
$this->contents = apply_filters( 'bp_button_' . $this->component . '_' . $this->id, $this->contents, $this, $before, $after );
|
2077 |
-
}
|
2078 |
-
|
2079 |
-
/**
|
2080 |
-
* Return the markup for the generated button.
|
2081 |
-
*
|
2082 |
-
* @since BuddyPress (1.2.6)
|
2083 |
-
*
|
2084 |
-
* @return string Button markup.
|
2085 |
-
*/
|
2086 |
-
public function contents() {
|
2087 |
-
return $this->contents;
|
2088 |
-
}
|
2089 |
-
|
2090 |
-
/**
|
2091 |
-
* Output the markup of button.
|
2092 |
-
*
|
2093 |
-
* @since BuddyPress (1.2.6)
|
2094 |
-
*/
|
2095 |
-
public function display() {
|
2096 |
-
if ( !empty( $this->contents ) )
|
2097 |
-
echo $this->contents;
|
2098 |
-
}
|
2099 |
-
}
|
2100 |
-
|
2101 |
-
/**
|
2102 |
-
* Enable oEmbeds in BuddyPress contexts.
|
2103 |
-
*
|
2104 |
-
* Extends WP_Embed class for use with BuddyPress.
|
2105 |
-
*
|
2106 |
-
* @since BuddyPress (1.5.0)
|
2107 |
-
*
|
2108 |
-
* @see WP_Embed
|
2109 |
-
*/
|
2110 |
-
class BP_Embed extends WP_Embed {
|
2111 |
-
|
2112 |
-
/**
|
2113 |
-
* Constructor
|
2114 |
-
*
|
2115 |
-
* @global WP_Embed $wp_embed
|
2116 |
-
*/
|
2117 |
-
public function __construct() {
|
2118 |
-
global $wp_embed;
|
2119 |
-
|
2120 |
-
// Make sure we populate the WP_Embed handlers array.
|
2121 |
-
// These are providers that use a regex callback on the URL in question.
|
2122 |
-
// Do not confuse with oEmbed providers, which require an external ping.
|
2123 |
-
// Used in WP_Embed::shortcode()
|
2124 |
-
$this->handlers = $wp_embed->handlers;
|
2125 |
-
|
2126 |
-
if ( bp_use_embed_in_activity() ) {
|
2127 |
-
add_filter( 'bp_get_activity_content_body', array( &$this, 'autoembed' ), 8 );
|
2128 |
-
add_filter( 'bp_get_activity_content_body', array( &$this, 'run_shortcode' ), 7 );
|
2129 |
-
}
|
2130 |
-
|
2131 |
-
if ( bp_use_embed_in_activity_replies() ) {
|
2132 |
-
add_filter( 'bp_get_activity_content', array( &$this, 'autoembed' ), 8 );
|
2133 |
-
add_filter( 'bp_get_activity_content', array( &$this, 'run_shortcode' ), 7 );
|
2134 |
-
}
|
2135 |
-
|
2136 |
-
if ( bp_use_embed_in_forum_posts() ) {
|
2137 |
-
add_filter( 'bp_get_the_topic_post_content', array( &$this, 'autoembed' ), 8 );
|
2138 |
-
add_filter( 'bp_get_the_topic_post_content', array( &$this, 'run_shortcode' ), 7 );
|
2139 |
-
}
|
2140 |
-
|
2141 |
-
if ( bp_use_embed_in_private_messages() ) {
|
2142 |
-
add_filter( 'bp_get_the_thread_message_content', array( &$this, 'autoembed' ), 8 );
|
2143 |
-
add_filter( 'bp_get_the_thread_message_content', array( &$this, 'run_shortcode' ), 7 );
|
2144 |
-
}
|
2145 |
-
|
2146 |
-
do_action_ref_array( 'bp_core_setup_oembed', array( &$this ) );
|
2147 |
-
}
|
2148 |
-
|
2149 |
-
/**
|
2150 |
-
* The {@link do_shortcode()} callback function.
|
2151 |
-
*
|
2152 |
-
* Attempts to convert a URL into embed HTML. Starts by checking the
|
2153 |
-
* URL against the regex of the registered embed handlers. Next, checks
|
2154 |
-
* the URL against the regex of registered {@link WP_oEmbed} providers
|
2155 |
-
* if oEmbed discovery is false. If none of the regex matches and it's
|
2156 |
-
* enabled, then the URL will be passed to {@link BP_Embed::parse_oembed()}
|
2157 |
-
* for oEmbed parsing.
|
2158 |
-
*
|
2159 |
-
* @uses wp_parse_args()
|
2160 |
-
* @uses wp_embed_defaults()
|
2161 |
-
* @uses current_user_can()
|
2162 |
-
* @uses _wp_oembed_get_object()
|
2163 |
-
* @uses WP_Embed::maybe_make_link()
|
2164 |
-
*
|
2165 |
-
* @param array $attr Shortcode attributes.
|
2166 |
-
* @param string $url The URL attempting to be embeded.
|
2167 |
-
* @return string The embed HTML on success, otherwise the original URL.
|
2168 |
-
*/
|
2169 |
-
public function shortcode( $attr, $url = '' ) {
|
2170 |
-
if ( empty( $url ) )
|
2171 |
-
return '';
|
2172 |
-
|
2173 |
-
$rawattr = $attr;
|
2174 |
-
$attr = wp_parse_args( $attr, wp_embed_defaults() );
|
2175 |
-
|
2176 |
-
// kses converts & into & and we need to undo this
|
2177 |
-
// See http://core.trac.wordpress.org/ticket/11311
|
2178 |
-
$url = str_replace( '&', '&', $url );
|
2179 |
-
|
2180 |
-
// Look for known internal handlers
|
2181 |
-
ksort( $this->handlers );
|
2182 |
-
foreach ( $this->handlers as $priority => $handlers ) {
|
2183 |
-
foreach ( $handlers as $hid => $handler ) {
|
2184 |
-
if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) {
|
2185 |
-
if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) ) {
|
2186 |
-
return apply_filters( 'embed_handler_html', $return, $url, $attr );
|
2187 |
-
}
|
2188 |
-
}
|
2189 |
-
}
|
2190 |
-
}
|
2191 |
-
|
2192 |
-
// Get object ID
|
2193 |
-
$id = apply_filters( 'embed_post_id', 0 );
|
2194 |
-
|
2195 |
-
// Is oEmbed discovery on?
|
2196 |
-
$attr['discover'] = ( apply_filters( 'bp_embed_oembed_discover', false ) && current_user_can( 'unfiltered_html' ) );
|
2197 |
-
|
2198 |
-
// Set up a new WP oEmbed object to check URL with registered oEmbed providers
|
2199 |
-
require_once( ABSPATH . WPINC . '/class-oembed.php' );
|
2200 |
-
$oembed_obj = _wp_oembed_get_object();
|
2201 |
-
|
2202 |
-
// If oEmbed discovery is true, skip oEmbed provider check
|
2203 |
-
$is_oembed_link = false;
|
2204 |
-
if ( !$attr['discover'] ) {
|
2205 |
-
foreach ( (array) $oembed_obj->providers as $provider_matchmask => $provider ) {
|
2206 |
-
$regex = ( $is_regex = $provider[1] ) ? $provider_matchmask : '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $provider_matchmask ), '#' ) ) . '#i';
|
2207 |
-
|
2208 |
-
if ( preg_match( $regex, $url ) )
|
2209 |
-
$is_oembed_link = true;
|
2210 |
-
}
|
2211 |
-
|
2212 |
-
// If url doesn't match a WP oEmbed provider, stop parsing
|
2213 |
-
if ( !$is_oembed_link )
|
2214 |
-
return $this->maybe_make_link( $url );
|
2215 |
-
}
|
2216 |
-
|
2217 |
-
return $this->parse_oembed( $id, $url, $attr, $rawattr );
|
2218 |
-
}
|
2219 |
-
|
2220 |
-
/**
|
2221 |
-
* Base function so BP components/plugins can parse links to be embedded.
|
2222 |
-
*
|
2223 |
-
* View an example to add support in {@link bp_activity_embed()}.
|
2224 |
-
*
|
2225 |
-
* @uses apply_filters() Filters cache.
|
2226 |
-
* @uses do_action() To save cache.
|
2227 |
-
* @uses wp_oembed_get() Connects to oEmbed provider and returns HTML
|
2228 |
-
* on success.
|
2229 |
-
* @uses WP_Embed::maybe_make_link() Process URL for hyperlinking on
|
2230 |
-
* oEmbed failure.
|
2231 |
-
*
|
2232 |
-
* @param int $id ID to do the caching for.
|
2233 |
-
* @param string $url The URL attempting to be embedded.
|
2234 |
-
* @param array $attr Shortcode attributes from {@link WP_Embed::shortcode()}.
|
2235 |
-
* @param array $rawattr Untouched shortcode attributes from
|
2236 |
-
* {@link WP_Embed::shortcode()}.
|
2237 |
-
* @return string The embed HTML on success, otherwise the original URL.
|
2238 |
-
*/
|
2239 |
-
public function parse_oembed( $id, $url, $attr, $rawattr ) {
|
2240 |
-
$id = intval( $id );
|
2241 |
-
|
2242 |
-
if ( $id ) {
|
2243 |
-
// Setup the cachekey
|
2244 |
-
$cachekey = '_oembed_' . md5( $url . serialize( $attr ) );
|
2245 |
-
|
2246 |
-
// Let components / plugins grab their cache
|
2247 |
-
$cache = '';
|
2248 |
-
$cache = apply_filters( 'bp_embed_get_cache', $cache, $id, $cachekey, $url, $attr, $rawattr );
|
2249 |
-
|
2250 |
-
// Grab cache and return it if available
|
2251 |
-
if ( !empty( $cache ) ) {
|
2252 |
-
return apply_filters( 'bp_embed_oembed_html', $cache, $url, $attr, $rawattr );
|
2253 |
-
|
2254 |
-
// If no cache, ping the oEmbed provider and cache the result
|
2255 |
-
} else {
|
2256 |
-
$html = wp_oembed_get( $url, $attr );
|
2257 |
-
$cache = ( $html ) ? $html : $url;
|
2258 |
-
|
2259 |
-
// Let components / plugins save their cache
|
2260 |
-
do_action( 'bp_embed_update_cache', $cache, $cachekey, $id );
|
2261 |
-
|
2262 |
-
// If there was a result, return it
|
2263 |
-
if ( $html )
|
2264 |
-
return apply_filters( 'bp_embed_oembed_html', $html, $url, $attr, $rawattr );
|
2265 |
-
}
|
2266 |
-
}
|
2267 |
-
|
2268 |
-
// Still unknown
|
2269 |
-
return $this->maybe_make_link( $url );
|
2270 |
-
}
|
2271 |
-
}
|
2272 |
-
|
2273 |
-
/**
|
2274 |
-
* Create HTML list of BP nav items.
|
2275 |
-
*
|
2276 |
-
* @since BuddyPress (1.7.0)
|
2277 |
-
*/
|
2278 |
-
class BP_Walker_Nav_Menu extends Walker_Nav_Menu {
|
2279 |
-
|
2280 |
-
/**
|
2281 |
-
* Description of fields indexes for building markup.
|
2282 |
-
*
|
2283 |
-
* @since BuddyPress (1.7.0)
|
2284 |
-
* @var array
|
2285 |
-
*/
|
2286 |
-
var $db_fields = array( 'id' => 'css_id', 'parent' => 'parent' );
|
2287 |
-
|
2288 |
-
/**
|
2289 |
-
* Tree type.
|
2290 |
-
*
|
2291 |
-
* @since BuddyPress (1.7.0)
|
2292 |
-
* @var string
|
2293 |
-
*/
|
2294 |
-
var $tree_type = array();
|
2295 |
-
|
2296 |
-
/**
|
2297 |
-
* Display array of elements hierarchically.
|
2298 |
-
*
|
2299 |
-
* This method is almost identical to the version in {@link Walker::walk()}.
|
2300 |
-
* The only change is on one line which has been commented. An IF was
|
2301 |
-
* comparing 0 to a non-empty string which was preventing child elements
|
2302 |
-
* being grouped under their parent menu element.
|
2303 |
-
*
|
2304 |
-
* This caused a problem for BuddyPress because our primary/secondary
|
2305 |
-
* navigations don't have a unique numerical ID that describes a
|
2306 |
-
* hierarchy (we use a slug). Obviously, WordPress Menus use Posts, and
|
2307 |
-
* those have ID/post_parent.
|
2308 |
-
*
|
2309 |
-
* @since BuddyPress (1.7.0)
|
2310 |
-
*
|
2311 |
-
* @see Walker::walk()
|
2312 |
-
*
|
2313 |
-
* @param array $elements See {@link Walker::walk()}.
|
2314 |
-
* @param int $max_depth See {@link Walker::walk()}.
|
2315 |
-
* @return string See {@link Walker::walk()}.
|
2316 |
-
*/
|
2317 |
-
public function walk( $elements, $max_depth ) {
|
2318 |
-
$func_args = func_get_args();
|
2319 |
-
|
2320 |
-
$args = array_slice( $func_args, 2 );
|
2321 |
-
$output = '';
|
2322 |
-
|
2323 |
-
if ( $max_depth < -1 ) // invalid parameter
|
2324 |
-
return $output;
|
2325 |
-
|
2326 |
-
if ( empty( $elements ) ) // nothing to walk
|
2327 |
-
return $output;
|
2328 |
-
|
2329 |
-
$parent_field = $this->db_fields['parent'];
|
2330 |
-
|
2331 |
-
// flat display
|
2332 |
-
if ( -1 == $max_depth ) {
|
2333 |
-
|
2334 |
-
$empty_array = array();
|
2335 |
-
foreach ( $elements as $e )
|
2336 |
-
$this->display_element( $e, $empty_array, 1, 0, $args, $output );
|
2337 |
-
|
2338 |
-
return $output;
|
2339 |
-
}
|
2340 |
-
|
2341 |
-
/*
|
2342 |
-
* need to display in hierarchical order
|
2343 |
-
* separate elements into two buckets: top level and children elements
|
2344 |
-
* children_elements is two dimensional array, eg.
|
2345 |
-
* children_elements[10][] contains all sub-elements whose parent is 10.
|
2346 |
-
*/
|
2347 |
-
$top_level_elements = array();
|
2348 |
-
$children_elements = array();
|
2349 |
-
|
2350 |
-
foreach ( $elements as $e ) {
|
2351 |
-
// BuddyPress: changed '==' to '==='. This is the only change from version in Walker::walk().
|
2352 |
-
if ( 0 === $e->$parent_field )
|
2353 |
-
$top_level_elements[] = $e;
|
2354 |
-
else
|
2355 |
-
$children_elements[$e->$parent_field][] = $e;
|
2356 |
-
}
|
2357 |
-
|
2358 |
-
/*
|
2359 |
-
* when none of the elements is top level
|
2360 |
-
* assume the first one must be root of the sub elements
|
2361 |
-
*/
|
2362 |
-
if ( empty( $top_level_elements ) ) {
|
2363 |
-
|
2364 |
-
$first = array_slice( $elements, 0, 1 );
|
2365 |
-
$root = $first[0];
|
2366 |
-
$top_level_elements = array();
|
2367 |
-
$children_elements = array();
|
2368 |
-
|
2369 |
-
foreach ( $elements as $e ) {
|
2370 |
-
if ( $root->$parent_field == $e->$parent_field )
|
2371 |
-
$top_level_elements[] = $e;
|
2372 |
-
else
|
2373 |
-
$children_elements[$e->$parent_field][] = $e;
|
2374 |
-
}
|
2375 |
-
}
|
2376 |
-
|
2377 |
-
foreach ( $top_level_elements as $e )
|
2378 |
-
$this->display_element( $e, $children_elements, $max_depth, 0, $args, $output );
|
2379 |
-
|
2380 |
-
/*
|
2381 |
-
* if we are displaying all levels, and remaining children_elements is not empty,
|
2382 |
-
* then we got orphans, which should be displayed regardless
|
2383 |
-
*/
|
2384 |
-
if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) {
|
2385 |
-
$empty_array = array();
|
2386 |
-
|
2387 |
-
foreach ( $children_elements as $orphans )
|
2388 |
-
foreach ( $orphans as $op )
|
2389 |
-
$this->display_element( $op, $empty_array, 1, 0, $args, $output );
|
2390 |
-
}
|
2391 |
-
|
2392 |
-
return $output;
|
2393 |
-
}
|
2394 |
-
|
2395 |
-
/**
|
2396 |
-
* Display the current <li> that we are on.
|
2397 |
-
*
|
2398 |
-
* @see Walker::start_el() for complete description of parameters .
|
2399 |
-
*
|
2400 |
-
* @since BuddyPress (1.7.0)
|
2401 |
-
*
|
2402 |
-
* @param string $output Passed by reference. Used to append
|
2403 |
-
* additional content.
|
2404 |
-
* @param object $item Menu item data object.
|
2405 |
-
* @param int $depth Depth of menu item. Used for padding. Optional,
|
2406 |
-
* defaults to 0.
|
2407 |
-
* @param array $args Optional. See {@link Walker::start_el()}.
|
2408 |
-
* @param int $current_page Menu item ID. Optional.
|
2409 |
-
*/
|
2410 |
-
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
2411 |
-
// If we're someway down the tree, indent the HTML with the appropriate number of tabs
|
2412 |
-
$indent = $depth ? str_repeat( "\t", $depth ) : '';
|
2413 |
-
|
2414 |
-
// Add HTML classes
|
2415 |
-
$class_names = join( ' ', apply_filters( 'bp_nav_menu_css_class', array_filter( $item->class ), $item, $args ) );
|
2416 |
-
$class_names = ! empty( $class_names ) ? ' class="' . esc_attr( $class_names ) . '"' : '';
|
2417 |
-
|
2418 |
-
// Add HTML ID
|
2419 |
-
$id = sanitize_html_class( $item->css_id . '-personal-li' ); // Backpat with BP pre-1.7
|
2420 |
-
$id = apply_filters( 'bp_nav_menu_item_id', $id, $item, $args );
|
2421 |
-
$id = ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
|
2422 |
-
|
2423 |
-
// Opening tag; closing tag is handled in Walker_Nav_Menu::end_el().
|
2424 |
-
$output .= $indent . '<li' . $id . $class_names . '>';
|
2425 |
-
|
2426 |
-
// Add href attribute
|
2427 |
-
$attributes = ! empty( $item->link ) ? ' href="' . esc_url( $item->link ) . '"' : '';
|
2428 |
-
|
2429 |
-
// Construct the link
|
2430 |
-
$item_output = $args->before;
|
2431 |
-
$item_output .= '<a' . $attributes . '>';
|
2432 |
-
$item_output .= $args->link_before . apply_filters( 'the_title', $item->name, 0 ) . $args->link_after;
|
2433 |
-
$item_output .= '</a>';
|
2434 |
-
$item_output .= $args->after;
|
2435 |
-
|
2436 |
-
// $output is byref
|
2437 |
-
$output .= apply_filters( 'bp_walker_nav_menu_start_el', $item_output, $item, $depth, $args );
|
2438 |
-
}
|
2439 |
-
}
|
2440 |
-
|
2441 |
-
/**
|
2442 |
-
* Create a set of BuddyPress-specific links for use in the Menus admin UI.
|
2443 |
-
*
|
2444 |
-
* Borrowed heavily from {@link Walker_Nav_Menu_Checklist}, but modified so as not
|
2445 |
-
* to require an actual post type or taxonomy, and to force certain CSS classes
|
2446 |
-
*
|
2447 |
-
* @since BuddyPress (1.9.0)
|
2448 |
-
*/
|
2449 |
-
class BP_Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
|
2450 |
-
|
2451 |
-
/**
|
2452 |
-
* Constructor.
|
2453 |
-
*
|
2454 |
-
* @see Walker_Nav_Menu::__construct() for a description of parameters.
|
2455 |
-
*
|
2456 |
-
* @param array $fields See {@link Walker_Nav_Menu::__construct()}.
|
2457 |
-
*/
|
2458 |
-
public function __construct( $fields = false ) {
|
2459 |
-
if ( $fields ) {
|
2460 |
-
$this->db_fields = $fields;
|
2461 |
-
}
|
2462 |
-
}
|
2463 |
-
|
2464 |
-
/**
|
2465 |
-
* Create the markup to start a tree level.
|
2466 |
-
*
|
2467 |
-
* @see Walker_Nav_Menu::start_lvl() for description of parameters.
|
2468 |
-
*
|
2469 |
-
* @param string $output See {@Walker_Nav_Menu::start_lvl()}.
|
2470 |
-
* @param int $depth See {@Walker_Nav_Menu::start_lvl()}.
|
2471 |
-
* @param array $args See {@Walker_Nav_Menu::start_lvl()}.
|
2472 |
-
*/
|
2473 |
-
public function start_lvl( &$output, $depth = 0, $args = array() ) {
|
2474 |
-
$indent = str_repeat( "\t", $depth );
|
2475 |
-
$output .= "\n$indent<ul class='children'>\n";
|
2476 |
-
}
|
2477 |
-
|
2478 |
-
/**
|
2479 |
-
* Create the markup to end a tree level.
|
2480 |
-
*
|
2481 |
-
* @see Walker_Nav_Menu::end_lvl() for description of parameters.
|
2482 |
-
*
|
2483 |
-
* @param string $output See {@Walker_Nav_Menu::end_lvl()}.
|
2484 |
-
* @param int $depth See {@Walker_Nav_Menu::end_lvl()}.
|
2485 |
-
* @param array $args See {@Walker_Nav_Menu::end_lvl()}.
|
2486 |
-
*/
|
2487 |
-
public function end_lvl( &$output, $depth = 0, $args = array() ) {
|
2488 |
-
$indent = str_repeat( "\t", $depth );
|
2489 |
-
$output .= "\n$indent</ul>";
|
2490 |
-
}
|
2491 |
-
|
2492 |
-
/**
|
2493 |
-
* Create the markup to start an element.
|
2494 |
-
*
|
2495 |
-
* @see Walker::start_el() for description of parameters.
|
2496 |
-
*
|
2497 |
-
* @param string $output Passed by reference. Used to append additional
|
2498 |
-
* content.
|
2499 |
-
* @param object $item Menu item data object.
|
2500 |
-
* @param int $depth Depth of menu item. Used for padding.
|
2501 |
-
* @param object $args See {@Walker::start_el()}.
|
2502 |
-
* @param int $id See {@Walker::start_el()}.
|
2503 |
-
*/
|
2504 |
-
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
2505 |
-
global $_nav_menu_placeholder;
|
2506 |
-
|
2507 |
-
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
|
2508 |
-
$possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
|
2509 |
-
$possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;
|
2510 |
-
|
2511 |
-
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
2512 |
-
|
2513 |
-
$output .= $indent . '<li>';
|
2514 |
-
$output .= '<label class="menu-item-title">';
|
2515 |
-
$output .= '<input type="checkbox" class="menu-item-checkbox';
|
2516 |
-
|
2517 |
-
if ( property_exists( $item, 'label' ) ) {
|
2518 |
-
$title = $item->label;
|
2519 |
-
}
|
2520 |
-
|
2521 |
-
$output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> ';
|
2522 |
-
$output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title );
|
2523 |
-
$output .= '</label>';
|
2524 |
-
|
2525 |
-
if ( empty( $item->url ) ) {
|
2526 |
-
$item->url = $item->guid;
|
2527 |
-
}
|
2528 |
-
|
2529 |
-
if ( ! in_array( array( 'bp-menu', 'bp-'. $item->post_excerpt .'-nav' ), $item->classes ) ) {
|
2530 |
-
$item->classes[] = 'bp-menu';
|
2531 |
-
$item->classes[] = 'bp-'. $item->post_excerpt .'-nav';
|
2532 |
-
}
|
2533 |
-
|
2534 |
-
// Menu item hidden fields
|
2535 |
-
$output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />';
|
2536 |
-
$output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="'. esc_attr( $item->object ) .'" />';
|
2537 |
-
$output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="'. esc_attr( $item->menu_item_parent ) .'" />';
|
2538 |
-
$output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="custom" />';
|
2539 |
-
$output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="'. esc_attr( $item->title ) .'" />';
|
2540 |
-
$output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="'. esc_attr( $item->url ) .'" />';
|
2541 |
-
$output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="'. esc_attr( $item->target ) .'" />';
|
2542 |
-
$output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item[' . $possible_object_id . '][menu-item-attr_title]" value="'. esc_attr( $item->attr_title ) .'" />';
|
2543 |
-
$output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="'. esc_attr( implode( ' ', $item->classes ) ) .'" />';
|
2544 |
-
$output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="'. esc_attr( $item->xfn ) .'" />';
|
2545 |
-
}
|
2546 |
-
}
|
2547 |
-
|
2548 |
-
/**
|
2549 |
-
* Base class for the BuddyPress Suggestions API.
|
2550 |
-
*
|
2551 |
-
* Originally built to power BuddyPress' at-mentions suggestions, it's flexible enough to be used
|
2552 |
-
* for similar kinds of future core requirements, or those desired by third-party developers.
|
2553 |
-
*
|
2554 |
-
* To implement a new suggestions service, create a new class that extends this one, and update
|
2555 |
-
* the list of default services in {@link bp_core_get_suggestions()}. If you're building a plugin,
|
2556 |
-
* it's recommend that you use the `bp_suggestions_services` filter to do this. :)
|
2557 |
-
*
|
2558 |
-
* While the implementation of the query logic is left to you, it should be as quick and efficient
|
2559 |
-
* as possible. When implementing the abstract methods in this class, pay close attention to the
|
2560 |
-
* recommendations provided in the phpDoc blocks, particularly the expected return types.
|
2561 |
-
*
|
2562 |
-
* @since BuddyPress (2.1.0)
|
2563 |
-
*/
|
2564 |
-
abstract class BP_Suggestions {
|
2565 |
-
|
2566 |
-
/**
|
2567 |
-
* Default arguments common to all suggestions services.
|
2568 |
-
*
|
2569 |
-
* If your custom service requires further defaults, add them here.
|
2570 |
-
*
|
2571 |
-
* @since BuddyPress (2.1.0)
|
2572 |
-
* @var array
|
2573 |
-
*/
|
2574 |
-
protected $default_args = array(
|
2575 |
-
'limit' => 16,
|
2576 |
-
'term' => '',
|
2577 |
-
'type' => '',
|
2578 |
-
);
|
2579 |
-
|
2580 |
-
/**
|
2581 |
-
* Holds the arguments for the query (about to made to the suggestions service).
|
2582 |
-
*
|
2583 |
-
* This includes `$default_args`, as well as the user-supplied values.
|
2584 |
-
*
|
2585 |
-
* @since BuddyPress (2.1.0)
|
2586 |
-
* @var array
|
2587 |
-
*/
|
2588 |
-
protected $args = array(
|
2589 |
-
);
|
2590 |
-
|
2591 |
-
|
2592 |
-
/**
|
2593 |
-
* Constructor.
|
2594 |
-
*
|
2595 |
-
* @param array $args Optional. If set, used as the parameters for the suggestions service query.
|
2596 |
-
* @since BuddyPress (2.1.0)
|
2597 |
-
*/
|
2598 |
-
public function __construct( array $args = array() ) {
|
2599 |
-
if ( ! empty( $args ) ) {
|
2600 |
-
$this->set_query( $args );
|
2601 |
-
}
|
2602 |
-
}
|
2603 |
-
|
2604 |
-
/**
|
2605 |
-
* Set the parameters for the suggestions service query.
|
2606 |
-
*
|
2607 |
-
* @param array $args {
|
2608 |
-
* @type int $limit Maximum number of results to display. Optional, default: 16.
|
2609 |
-
* @type string $type The name of the suggestion service to use for the request. Mandatory.
|
2610 |
-
* @type string $term The suggestion service will try to find results that contain this string.
|
2611 |
-
* Mandatory.
|
2612 |
-
* }
|
2613 |
-
* @since BuddyPress (2.1.0)
|
2614 |
-
*/
|
2615 |
-
public function set_query( array $args = array() ) {
|
2616 |
-
$this->args = wp_parse_args( $args, $this->default_args );
|
2617 |
-
}
|
2618 |
-
|
2619 |
-
/**
|
2620 |
-
* Validate and sanitise the parameters for the suggestion service query.
|
2621 |
-
*
|
2622 |
-
* Be sure to call this class' version of this method when implementing it in your own service.
|
2623 |
-
* If validation fails, you must return a WP_Error object.
|
2624 |
-
*
|
2625 |
-
* @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool).
|
2626 |
-
* @since BuddyPress (2.1.0)
|
2627 |
-
*/
|
2628 |
-
public function validate() {
|
2629 |
-
$this->args['limit'] = absint( $this->args['limit'] );
|
2630 |
-
$this->args['term'] = trim( sanitize_text_field( $this->args['term'] ) );
|
2631 |
-
$this->args = apply_filters( 'bp_suggestions_args', $this->args, $this );
|
2632 |
-
|
2633 |
-
|
2634 |
-
// Check for invalid or missing mandatory parameters.
|
2635 |
-
if ( ! $this->args['limit'] || ! $this->args['term'] ) {
|
2636 |
-
return new WP_Error( 'missing_parameter' );
|
2637 |
-
}
|
2638 |
-
|
2639 |
-
// Check for blocked users (e.g. deleted accounts, or spammers).
|
2640 |
-
if ( is_user_logged_in() && ! bp_is_user_active( get_current_user_id() ) ) {
|
2641 |
-
return new WP_Error( 'invalid_user' );
|
2642 |
-
}
|
2643 |
-
|
2644 |
-
return apply_filters( 'bp_suggestions_validate_args', true, $this );
|
2645 |
-
}
|
2646 |
-
|
2647 |
-
/**
|
2648 |
-
* Find and return a list of suggestions that match the query.
|
2649 |
-
*
|
2650 |
-
* The return type is important. If no matches are found, an empty array must be returned.
|
2651 |
-
* Matches must be returned as objects in an array.
|
2652 |
-
*
|
2653 |
-
* The object format for each match must be: { 'ID': string, 'image': string, 'name': string }
|
2654 |
-
* For example: { 'ID': 'admin', 'image': 'http://example.com/logo.png', 'name': 'Name Surname' }
|
2655 |
-
*
|
2656 |
-
* @return array|WP_Error Array of results. If there were problems, returns a WP_Error object.
|
2657 |
-
* @since BuddyPress (2.1.0)
|
2658 |
-
*/
|
2659 |
-
abstract public function get_suggestions();
|
2660 |
-
}
|
2661 |
-
|
2662 |
-
/**
|
2663 |
-
* Adds support for user at-mentions to the Suggestions API.
|
2664 |
-
*
|
2665 |
-
* This class is in the Core component because it's required by a class in the Groups component,
|
2666 |
-
* and Groups is loaded before Members (alphabetical order).
|
2667 |
-
*
|
2668 |
-
* @since BuddyPress (2.1.0)
|
2669 |
-
*/
|
2670 |
-
class BP_Members_Suggestions extends BP_Suggestions {
|
2671 |
-
|
2672 |
-
/**
|
2673 |
-
* Default arguments for this suggestions service.
|
2674 |
-
*
|
2675 |
-
* @since BuddyPress (2.1.0)
|
2676 |
-
* @var array $args {
|
2677 |
-
* @type int $limit Maximum number of results to display. Default: 16.
|
2678 |
-
* @type bool $only_friends If true, only match the current user's friends. Default: false.
|
2679 |
-
* @type string $term The suggestion service will try to find results that contain this string.
|
2680 |
-
* Mandatory.
|
2681 |
-
* }
|
2682 |
-
*/
|
2683 |
-
protected $default_args = array(
|
2684 |
-
'limit' => 10,
|
2685 |
-
'only_friends' => false,
|
2686 |
-
'term' => '',
|
2687 |
-
'type' => '',
|
2688 |
-
);
|
2689 |
-
|
2690 |
-
|
2691 |
-
/**
|
2692 |
-
* Validate and sanitise the parameters for the suggestion service query.
|
2693 |
-
*
|
2694 |
-
* @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool).
|
2695 |
-
* @since BuddyPress (2.1.0)
|
2696 |
-
*/
|
2697 |
-
public function validate() {
|
2698 |
-
$this->args['only_friends'] = (bool) $this->args['only_friends'];
|
2699 |
-
$this->args = apply_filters( 'bp_members_suggestions_args', $this->args, $this );
|
2700 |
-
|
2701 |
-
// Check for invalid or missing mandatory parameters.
|
2702 |
-
if ( $this->args['only_friends'] && ( ! bp_is_active( 'friends' ) || ! is_user_logged_in() ) ) {
|
2703 |
-
return new WP_Error( 'missing_requirement' );
|
2704 |
-
}
|
2705 |
-
|
2706 |
-
return apply_filters( 'bp_members_suggestions_validate_args', parent::validate(), $this );
|
2707 |
-
}
|
2708 |
-
|
2709 |
-
/**
|
2710 |
-
* Find and return a list of username suggestions that match the query.
|
2711 |
-
*
|
2712 |
-
* @return array|WP_Error Array of results. If there were problems, returns a WP_Error object.
|
2713 |
-
* @since BuddyPress (2.1.0)
|
2714 |
-
*/
|
2715 |
-
public function get_suggestions() {
|
2716 |
-
$user_query = array(
|
2717 |
-
'count_total' => '', // Prevents total count
|
2718 |
-
'populate_extras' => false,
|
2719 |
-
'type' => 'alphabetical',
|
2720 |
-
|
2721 |
-
'page' => 1,
|
2722 |
-
'per_page' => $this->args['limit'],
|
2723 |
-
'search_terms' => $this->args['term'],
|
2724 |
-
'search_wildcard' => 'right',
|
2725 |
-
);
|
2726 |
-
|
2727 |
-
// Only return matches of friends of this user.
|
2728 |
-
if ( $this->args['only_friends'] && is_user_logged_in() ) {
|
2729 |
-
$user_query['user_id'] = get_current_user_id();
|
2730 |
-
}
|
2731 |
-
|
2732 |
-
$user_query = apply_filters( 'bp_members_suggestions_query_args', $user_query, $this );
|
2733 |
-
if ( is_wp_error( $user_query ) ) {
|
2734 |
-
return $user_query;
|
2735 |
-
}
|
2736 |
-
|
2737 |
-
|
2738 |
-
$user_query = new BP_User_Query( $user_query );
|
2739 |
-
$results = array();
|
2740 |
-
|
2741 |
-
foreach ( $user_query->results as $user ) {
|
2742 |
-
$result = new stdClass();
|
2743 |
-
$result->ID = $user->user_nicename;
|
2744 |
-
$result->image = bp_core_fetch_avatar( array( 'html' => false, 'item_id' => $user->ID ) );
|
2745 |
-
$result->name = bp_core_get_user_displayname( $user->ID );
|
2746 |
-
|
2747 |
-
$results[] = $result;
|
2748 |
-
}
|
2749 |
-
|
2750 |
-
return apply_filters( 'bp_members_suggestions_get_suggestions', $results, $this );
|
2751 |
-
}
|
2752 |
-
}
|
2753 |
-
|
2754 |
-
/**
|
2755 |
-
* Base class for creating query classes that generate SQL fragments for filtering results based on recursive query params.
|
2756 |
-
*
|
2757 |
-
* @since BuddyPress (2.2.0)
|
2758 |
-
*/
|
2759 |
-
abstract class BP_Recursive_Query {
|
2760 |
-
|
2761 |
-
/**
|
2762 |
-
* Query arguments passed to the constructor.
|
2763 |
-
*
|
2764 |
-
* @since BuddyPress (2.2.0)
|
2765 |
-
* @access public
|
2766 |
-
* @var array
|
2767 |
-
*/
|
2768 |
-
public $queries = array();
|
2769 |
-
|
2770 |
-
/**
|
2771 |
-
* Generate SQL clauses to be appended to a main query.
|
2772 |
-
*
|
2773 |
-
* Extending classes should call this method from within a publicly
|
2774 |
-
* accessible get_sql() method, and manipulate the SQL as necessary.
|
2775 |
-
* For example, {@link BP_XProfile_Query::get_sql()} is merely a wrapper for
|
2776 |
-
* get_sql_clauses(), while {@link BP_Activity_Query::get_sql()} discards
|
2777 |
-
* the empty 'join' clause, and only passes the 'where' clause.
|
2778 |
-
*
|
2779 |
-
* @since BuddyPress (2.2.0)
|
2780 |
-
* @access protected
|
2781 |
-
*
|
2782 |
-
* @param string $primary_table
|
2783 |
-
* @param string $primary_id_column
|
2784 |
-
* @return array
|
2785 |
-
*/
|
2786 |
-
protected function get_sql_clauses() {
|
2787 |
-
$sql = $this->get_sql_for_query( $this->queries );
|
2788 |
-
|
2789 |
-
if ( ! empty( $sql['where'] ) ) {
|
2790 |
-
$sql['where'] = ' AND ' . "\n" . $sql['where'] . "\n";
|
2791 |
-
}
|
2792 |
-
|
2793 |
-
return $sql;
|
2794 |
-
}
|
2795 |
-
|
2796 |
-
/**
|
2797 |
-
* Generate SQL clauses for a single query array.
|
2798 |
-
*
|
2799 |
-
* If nested subqueries are found, this method recurses the tree to
|
2800 |
-
* produce the properly nested SQL.
|
2801 |
-
*
|
2802 |
-
* Subclasses generally do not need to call this method. It is invoked
|
2803 |
-
* automatically from get_sql_clauses().
|
2804 |
-
*
|
2805 |
-
* @since BuddyPress (2.2.0)
|
2806 |
-
* @access protected
|
2807 |
-
*
|
2808 |
-
* @param array $query Query to parse.
|
2809 |
-
* @param int $depth Optional. Number of tree levels deep we
|
2810 |
-
* currently are. Used to calculate indentation.
|
2811 |
-
* @return array
|
2812 |
-
*/
|
2813 |
-
protected function get_sql_for_query( $query, $depth = 0 ) {
|
2814 |
-
$sql_chunks = array(
|
2815 |
-
'join' => array(),
|
2816 |
-
'where' => array(),
|
2817 |
-
);
|
2818 |
-
|
2819 |
-
$sql = array(
|
2820 |
-
'join' => '',
|
2821 |
-
'where' => '',
|
2822 |
-
);
|
2823 |
-
|
2824 |
-
$indent = '';
|
2825 |
-
for ( $i = 0; $i < $depth; $i++ ) {
|
2826 |
-
$indent .= "\t";
|
2827 |
-
}
|
2828 |
-
|
2829 |
-
foreach ( $query as $key => $clause ) {
|
2830 |
-
if ( 'relation' === $key ) {
|
2831 |
-
$relation = $query['relation'];
|
2832 |
-
} elseif ( is_array( $clause ) ) {
|
2833 |
-
// This is a first-order clause
|
2834 |
-
if ( $this->is_first_order_clause( $clause ) ) {
|
2835 |
-
$clause_sql = $this->get_sql_for_clause( $clause, $query );
|
2836 |
-
|
2837 |
-
$where_count = count( $clause_sql['where'] );
|
2838 |
-
if ( ! $where_count ) {
|
2839 |
-
$sql_chunks['where'][] = '';
|
2840 |
-
} elseif ( 1 === $where_count ) {
|
2841 |
-
$sql_chunks['where'][] = $clause_sql['where'][0];
|
2842 |
-
} else {
|
2843 |
-
$sql_chunks['where'][] = '( ' . implode( ' AND ', $clause_sql['where'] ) . ' )';
|
2844 |
-
}
|
2845 |
-
|
2846 |
-
$sql_chunks['join'] = array_merge( $sql_chunks['join'], $clause_sql['join'] );
|
2847 |
-
// This is a subquery
|
2848 |
-
} else {
|
2849 |
-
$clause_sql = $this->get_sql_for_query( $clause, $depth + 1 );
|
2850 |
-
|
2851 |
-
$sql_chunks['where'][] = $clause_sql['where'];
|
2852 |
-
$sql_chunks['join'][] = $clause_sql['join'];
|
2853 |
-
}
|
2854 |
-
}
|
2855 |
-
}
|
2856 |
-
|
2857 |
-
// Filter empties
|
2858 |
-
$sql_chunks['join'] = array_filter( $sql_chunks['join'] );
|
2859 |
-
$sql_chunks['where'] = array_filter( $sql_chunks['where'] );
|
2860 |
-
|
2861 |
-
if ( empty( $relation ) ) {
|
2862 |
-
$relation = 'AND';
|
2863 |
-
}
|
2864 |
-
|
2865 |
-
if ( ! empty( $sql_chunks['join'] ) ) {
|
2866 |
-
$sql['join'] = implode( ' ', array_unique( $sql_chunks['join'] ) );
|
2867 |
-
}
|
2868 |
-
|
2869 |
-
if ( ! empty( $sql_chunks['where'] ) ) {
|
2870 |
-
$sql['where'] = '( ' . "\n\t" . $indent . implode( ' ' . "\n\t" . $indent . $relation . ' ' . "\n\t" . $indent, $sql_chunks['where'] ) . "\n" . $indent . ')' . "\n";
|
2871 |
-
}
|
2872 |
-
|
2873 |
-
return $sql;
|
2874 |
-
}
|
2875 |
-
|
2876 |
-
/**
|
2877 |
-
* Recursive-friendly query sanitizer.
|
2878 |
-
*
|
2879 |
-
* Ensures that each query-level clause has a 'relation' key, and that
|
2880 |
-
* each first-order clause contains all the necessary keys from
|
2881 |
-
* $defaults.
|
2882 |
-
*
|
2883 |
-
* Extend this method if your class uses different sanitizing logic.
|
2884 |
-
*
|
2885 |
-
* @since BuddyPress (2.2.0)
|
2886 |
-
* @access public
|
2887 |
-
*
|
2888 |
-
* @param array $queries Array of query clauses.
|
2889 |
-
* @return array Sanitized array of query clauses.
|
2890 |
-
*/
|
2891 |
-
protected function sanitize_query( $queries ) {
|
2892 |
-
$clean_queries = array();
|
2893 |
-
|
2894 |
-
if ( ! is_array( $queries ) ) {
|
2895 |
-
return $clean_queries;
|
2896 |
-
}
|
2897 |
-
|
2898 |
-
foreach ( $queries as $key => $query ) {
|
2899 |
-
if ( 'relation' === $key ) {
|
2900 |
-
$relation = $query;
|
2901 |
-
|
2902 |
-
} elseif ( ! is_array( $query ) ) {
|
2903 |
-
continue;
|
2904 |
-
|
2905 |
-
// First-order clause.
|
2906 |
-
} elseif ( $this->is_first_order_clause( $query ) ) {
|
2907 |
-
if ( isset( $query['value'] ) && array() === $query['value'] ) {
|
2908 |
-
unset( $query['value'] );
|
2909 |
-
}
|
2910 |
-
|
2911 |
-
$clean_queries[] = $query;
|
2912 |
-
|
2913 |
-
// Otherwise, it's a nested query, so we recurse.
|
2914 |
-
} else {
|
2915 |
-
$cleaned_query = $this->sanitize_query( $query );
|
2916 |
-
|
2917 |
-
if ( ! empty( $cleaned_query ) ) {
|
2918 |
-
$clean_queries[] = $cleaned_query;
|
2919 |
-
}
|
2920 |
-
}
|
2921 |
-
}
|
2922 |
-
|
2923 |
-
if ( empty( $clean_queries ) ) {
|
2924 |
-
return $clean_queries;
|
2925 |
-
}
|
2926 |
-
|
2927 |
-
// Sanitize the 'relation' key provided in the query.
|
2928 |
-
if ( isset( $relation ) && 'OR' === strtoupper( $relation ) ) {
|
2929 |
-
$clean_queries['relation'] = 'OR';
|
2930 |
-
|
2931 |
-
/*
|
2932 |
-
* If there is only a single clause, call the relation 'OR'.
|
2933 |
-
* This value will not actually be used to join clauses, but it
|
2934 |
-
* simplifies the logic around combining key-only queries.
|
2935 |
-
*/
|
2936 |
-
} elseif ( 1 === count( $clean_queries ) ) {
|
2937 |
-
$clean_queries['relation'] = 'OR';
|
2938 |
-
|
2939 |
-
// Default to AND.
|
2940 |
-
} else {
|
2941 |
-
$clean_queries['relation'] = 'AND';
|
2942 |
-
}
|
2943 |
-
|
2944 |
-
return $clean_queries;
|
2945 |
-
}
|
2946 |
-
|
2947 |
-
/**
|
2948 |
-
* Generate JOIN and WHERE clauses for a first-order clause.
|
2949 |
-
*
|
2950 |
-
* Must be overridden in a subclass.
|
2951 |
-
*
|
2952 |
-
* @since BuddyPress (2.2.0)
|
2953 |
-
* @access protected
|
2954 |
-
*
|
2955 |
-
* @param array $clause Array of arguments belonging to the clause.
|
2956 |
-
* @param array $parent_query Parent query to which the clause belongs.
|
2957 |
-
* @return array {
|
2958 |
-
* @type array $join Array of subclauses for the JOIN statement.
|
2959 |
-
* @type array $where Array of subclauses for the WHERE statement.
|
2960 |
-
* }
|
2961 |
-
*/
|
2962 |
-
abstract protected function get_sql_for_clause( $clause, $parent_query );
|
2963 |
-
|
2964 |
-
/**
|
2965 |
-
* Determine whether a clause is first-order.
|
2966 |
-
*
|
2967 |
-
* Must be overridden in a subclass.
|
2968 |
-
*
|
2969 |
-
* @since BuddyPress (2.2.0)
|
2970 |
-
* @access protected
|
2971 |
-
*
|
2972 |
-
* @param array $q Clause to check.
|
2973 |
-
* @return bool
|
2974 |
-
*/
|
2975 |
-
abstract protected function is_first_order_clause( $query );
|
2976 |
-
}
|
9 |
Â
// Exit if accessed directly
|
10 |
Â
defined( 'ABSPATH' ) || exit;
|
11 |
Â
|
12 |
+
require dirname( __FILE__ ) . '/classes/class-bp-user-query.php';
|
13 |
+
require dirname( __FILE__ ) . '/classes/class-bp-core-user.php';
|
14 |
+
require dirname( __FILE__ ) . '/classes/class-bp-date-query.php';
|
15 |
+
require dirname( __FILE__ ) . '/classes/class-bp-core-notification.php';
|
16 |
+
require dirname( __FILE__ ) . '/classes/class-bp-button.php';
|
17 |
+
require dirname( __FILE__ ) . '/classes/class-bp-embed.php';
|
18 |
+
require dirname( __FILE__ ) . '/classes/class-bp-walker-nav-menu.php';
|
19 |
+
require dirname( __FILE__ ) . '/classes/class-bp-walker-nav-menu-checklist.php';
|
20 |
+
require dirname( __FILE__ ) . '/classes/class-bp-suggestions.php';
|
21 |
+
require dirname( __FILE__ ) . '/classes/class-bp-members-suggestions.php';
|
22 |
+
require dirname( __FILE__ ) . '/classes/class-bp-recursive-query.php';
|
23 |
+
require dirname( __FILE__ ) . '/classes/class-bp-media-extractor.php';
|
24 |
+
require dirname( __FILE__ ) . '/classes/class-bp-attachment.php';
|
25 |
+
require dirname( __FILE__ ) . '/classes/class-bp-attachment-avatar.php';
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
bp-core/bp-core-component.php
CHANGED
@@ -131,19 +131,21 @@ class BP_Component {
|
|
131 |
Â
* Component loader.
|
132 |
Â
*
|
133 |
Â
* @since BuddyPress (1.5.0)
|
134 |
-
*
|
135 |
-
* @
|
136 |
-
*
|
137 |
-
* @param string $id
|
138 |
-
*
|
139 |
-
*
|
140 |
-
*
|
141 |
-
* @param
|
142 |
-
*
|
143 |
-
*
|
144 |
-
*
|
145 |
-
*
|
146 |
-
*
|
Â
|
|
Â
|
|
147 |
Â
*/
|
148 |
Â
public function start( $id = '', $name = '', $path = '', $params = array() ) {
|
149 |
Â
|
@@ -163,6 +165,11 @@ class BP_Component {
|
|
163 |
Â
$this->adminbar_myaccount_order = (int) $params['adminbar_myaccount_order'];
|
164 |
Â
}
|
165 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
166 |
Â
// Set defaults if not passed
|
167 |
Â
} else {
|
168 |
Â
// new component menus are added before the settings menu if not set
|
@@ -183,24 +190,18 @@ class BP_Component {
|
|
183 |
Â
*
|
184 |
Â
* @param array $args {
|
185 |
Â
* All values are optional.
|
186 |
-
* @type string
|
187 |
-
*
|
188 |
-
*
|
189 |
-
*
|
190 |
-
*
|
191 |
-
*
|
192 |
-
*
|
193 |
-
*
|
194 |
-
* @type
|
195 |
-
*
|
196 |
-
* @type
|
197 |
-
*
|
198 |
-
* @type string $search_term Optional. The placeholder text in the
|
199 |
-
* component directory search box. Eg, 'Search Groups...'.
|
200 |
-
* @type array $global_tables Optional. An array of database table
|
201 |
-
* names.
|
202 |
-
* @type array $meta_tables Optional. An array of metadata table
|
203 |
-
* names.
|
204 |
Â
* }
|
205 |
Â
*/
|
206 |
Â
public function setup_globals( $args = array() ) {
|
@@ -222,22 +223,58 @@ class BP_Component {
|
|
222 |
Â
'meta_tables' => '',
|
223 |
Â
) );
|
224 |
Â
|
225 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
226 |
Â
$this->slug = apply_filters( 'bp_' . $this->id . '_slug', $r['slug'] );
|
227 |
Â
|
228 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
229 |
Â
$this->root_slug = apply_filters( 'bp_' . $this->id . '_root_slug', $r['root_slug'] );
|
230 |
Â
|
231 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
232 |
Â
$this->has_directory = apply_filters( 'bp_' . $this->id . '_has_directory', $r['has_directory'] );
|
233 |
Â
|
234 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
235 |
Â
$this->directory_title = apply_filters( 'bp_' . $this->id . '_directory_title', $r['directory_title'] );
|
236 |
Â
|
237 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
238 |
Â
$this->search_string = apply_filters( 'bp_' . $this->id . '_search_string', $r['search_string'] );
|
239 |
Â
|
240 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
241 |
Â
$this->notification_callback = apply_filters( 'bp_' . $this->id . '_notification_callback', $r['notification_callback'] );
|
242 |
Â
|
243 |
Â
// Set the global table names, if applicable
|
@@ -255,7 +292,13 @@ class BP_Component {
|
|
255 |
Â
// Register this component in the loaded components array
|
256 |
Â
buddypress()->loaded_components[$this->slug] = $this->id;
|
257 |
Â
|
258 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
259 |
Â
do_action( 'bp_' . $this->id . '_setup_globals' );
|
260 |
Â
}
|
261 |
Â
|
@@ -320,7 +363,13 @@ class BP_Component {
|
|
320 |
Â
}
|
321 |
Â
}
|
322 |
Â
|
323 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
324 |
Â
do_action( 'bp_' . $this->id . '_includes' );
|
325 |
Â
}
|
326 |
Â
|
@@ -380,7 +429,13 @@ class BP_Component {
|
|
380 |
Â
// Generate rewrite rules
|
381 |
Â
add_action( 'bp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10 );
|
382 |
Â
|
383 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
384 |
Â
do_action( 'bp_' . $this->id . '_setup_actions' );
|
385 |
Â
}
|
386 |
Â
|
@@ -419,7 +474,13 @@ class BP_Component {
|
|
419 |
Â
}
|
420 |
Â
}
|
421 |
Â
|
422 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
423 |
Â
do_action( 'bp_' . $this->id . '_setup_nav' );
|
424 |
Â
}
|
425 |
Â
|
@@ -447,7 +508,15 @@ class BP_Component {
|
|
447 |
Â
return;
|
448 |
Â
}
|
449 |
Â
|
450 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
451 |
Â
$wp_admin_nav = apply_filters( 'bp_' . $this->id . '_admin_nav', $wp_admin_nav );
|
452 |
Â
|
453 |
Â
// Do we have Toolbar menus to add?
|
@@ -465,7 +534,13 @@ class BP_Component {
|
|
465 |
Â
}
|
466 |
Â
}
|
467 |
Â
|
468 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
469 |
Â
do_action( 'bp_' . $this->id . '_setup_admin_bar' );
|
470 |
Â
}
|
471 |
Â
|
@@ -477,6 +552,14 @@ class BP_Component {
|
|
477 |
Â
* @uses do_action() Calls 'bp_{@link bp_Component::name}_setup_title'.
|
478 |
Â
*/
|
479 |
Â
public function setup_title() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
480 |
Â
do_action( 'bp_' . $this->id . '_setup_title' );
|
481 |
Â
}
|
482 |
Â
|
@@ -488,6 +571,14 @@ class BP_Component {
|
|
488 |
Â
* @uses do_action() Calls 'bp_setup_{@link bp_Component::name}_cache_groups'.
|
489 |
Â
*/
|
490 |
Â
public function setup_cache_groups() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
491 |
Â
do_action( 'bp_' . $this->id . '_setup_cache_groups' );
|
492 |
Â
}
|
493 |
Â
|
@@ -500,8 +591,15 @@ class BP_Component {
|
|
500 |
Â
*/
|
501 |
Â
public function register_global_tables( $tables = array() ) {
|
502 |
Â
|
503 |
-
|
504 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
505 |
Â
$tables = apply_filters( 'bp_' . $this->id . '_global_tables', $tables );
|
506 |
Â
|
507 |
Â
// Add to the BuddyPress global object
|
@@ -514,6 +612,13 @@ class BP_Component {
|
|
514 |
Â
$this->global_tables = $tables;
|
515 |
Â
}
|
516 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
517 |
Â
do_action( 'bp_' . $this->id . '_register_global_tables' );
|
518 |
Â
}
|
519 |
Â
|
@@ -530,8 +635,15 @@ class BP_Component {
|
|
530 |
Â
public function register_meta_tables( $tables = array() ) {
|
531 |
Â
global $wpdb;
|
532 |
Â
|
533 |
-
|
534 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
535 |
Â
$tables = apply_filters( 'bp_' . $this->id . '_meta_tables', $tables );
|
536 |
Â
|
537 |
Â
/**
|
@@ -547,6 +659,13 @@ class BP_Component {
|
|
547 |
Â
$this->meta_tables = $tables;
|
548 |
Â
}
|
549 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
550 |
Â
do_action( 'bp_' . $this->id . '_register_meta_tables' );
|
551 |
Â
}
|
552 |
Â
|
@@ -558,6 +677,14 @@ class BP_Component {
|
|
558 |
Â
* @uses do_action() Calls 'bp_{@link bp_Component::name}_register_post_types'.
|
559 |
Â
*/
|
560 |
Â
public function register_post_types() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
561 |
Â
do_action( 'bp_' . $this->id . '_register_post_types' );
|
562 |
Â
}
|
563 |
Â
|
@@ -569,6 +696,14 @@ class BP_Component {
|
|
569 |
Â
* @uses do_action() Calls 'bp_{@link bp_Component::name}_register_taxonomies'.
|
570 |
Â
*/
|
571 |
Â
public function register_taxonomies() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
572 |
Â
do_action( 'bp_' . $this->id . '_register_taxonomies' );
|
573 |
Â
}
|
574 |
Â
|
@@ -580,6 +715,14 @@ class BP_Component {
|
|
580 |
Â
* @uses do_action() Calls 'bp_{@link bp_Component::name}_add_rewrite_tags'.
|
581 |
Â
*/
|
582 |
Â
public function add_rewrite_tags() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
583 |
Â
do_action( 'bp_' . $this->id . '_add_rewrite_tags' );
|
584 |
Â
}
|
585 |
Â
|
@@ -591,6 +734,14 @@ class BP_Component {
|
|
591 |
Â
* @uses do_action() Calls 'bp_{@link bp_Component::name}_add_rewrite_rules'.
|
592 |
Â
*/
|
593 |
Â
public function add_rewrite_rules() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
594 |
Â
do_action( 'bp_' . $this->id . '_add_rewrite_rules' );
|
595 |
Â
}
|
596 |
Â
|
@@ -602,6 +753,14 @@ class BP_Component {
|
|
602 |
Â
* @uses do_action() Calls 'bp_{@link bp_Component::name}_add_permastruct'
|
603 |
Â
*/
|
604 |
Â
public function add_permastructs() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
605 |
Â
do_action( 'bp_' . $this->id . '_add_permastructs' );
|
606 |
Â
}
|
607 |
Â
|
@@ -614,6 +773,16 @@ class BP_Component {
|
|
614 |
Â
* @param object The main WP_Query
|
615 |
Â
*/
|
616 |
Â
public function parse_query( $query ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
617 |
Â
do_action_ref_array( 'bp_' . $this->id . '_parse_query', array( &$query ) );
|
618 |
Â
}
|
619 |
Â
|
@@ -625,6 +794,14 @@ class BP_Component {
|
|
625 |
Â
* @uses do_action() Calls 'bp_{@link bp_Component::name}_generate_rewrite_rules'
|
626 |
Â
*/
|
627 |
Â
public function generate_rewrite_rules() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
628 |
Â
do_action( 'bp_' . $this->id . '_generate_rewrite_rules' );
|
629 |
Â
}
|
630 |
Â
}
|
131 |
Â
* Component loader.
|
132 |
Â
*
|
133 |
Â
* @since BuddyPress (1.5.0)
|
134 |
+
* @since BuddyPress (1.9.0) Added $params as a parameter.
|
135 |
+
* @since BuddyPress (2.3.0) Added $params['features'] as a configurable value.
|
136 |
+
*
|
137 |
+
* @param string $id Unique ID. Letters, numbers, and underscores only.
|
138 |
+
* @param string $name Unique name. This should be a translatable name, eg.
|
139 |
+
* __( 'Groups', 'buddypress' ).
|
140 |
+
* @param string $path The file path for the component's files. Used by {@link BP_Component::includes()}.
|
141 |
+
* @param array $params {
|
142 |
+
* Additional parameters used by the component.
|
143 |
+
* @type int $adminbar_myaccount_order Set the position for our menu under the WP Toolbar's "My Account menu"
|
144 |
+
* @type array $features An array of feature names. This is used to load additional files from your
|
145 |
+
* component directory and for feature active checks. eg. array( 'awesome' )
|
146 |
+
* would look for a file called "bp-{$this->id}-awesome.php" and you could use
|
147 |
+
* bp_is_active( $this->id, 'awesome' ) to determine if the feature is active.
|
148 |
+
* }
|
149 |
Â
*/
|
150 |
Â
public function start( $id = '', $name = '', $path = '', $params = array() ) {
|
151 |
Â
|
165 |
Â
$this->adminbar_myaccount_order = (int) $params['adminbar_myaccount_order'];
|
166 |
Â
}
|
167 |
Â
|
168 |
+
// Register features
|
169 |
+
if ( ! empty( $params['features'] ) ) {
|
170 |
+
$this->features = array_map( 'sanitize_title', (array) $params['features'] );
|
171 |
+
}
|
172 |
+
|
173 |
Â
// Set defaults if not passed
|
174 |
Â
} else {
|
175 |
Â
// new component menus are added before the settings menu if not set
|
190 |
Â
*
|
191 |
Â
* @param array $args {
|
192 |
Â
* All values are optional.
|
193 |
+
* @type string $slug The component slug. Used to construct certain URLs, such as 'friends' in
|
194 |
+
* http://example.com/members/joe/friends/. Default: the value of $this->id.
|
195 |
+
* @type string $root_slug The component root slug. Note that this value is generally unused if the
|
196 |
+
* component has a root directory (the slug will be overridden by the
|
197 |
+
* post_name of the directory page). Default: the slug of the directory page
|
198 |
+
* if one is found, otherwise an empty string.
|
199 |
+
* @type bool $has_directory Set to true if the component requires an associated WordPress page.
|
200 |
+
* @type callable $notification_callback Optional. The callable function that formats the component's notifications.
|
201 |
+
* @type string $search_term Optional. The placeholder text in the component directory search box. Eg,
|
202 |
+
* 'Search Groups...'.
|
203 |
+
* @type array $global_tables Optional. An array of database table names.
|
204 |
+
* @type array $meta_tables Optional. An array of metadata table names.
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
205 |
Â
* }
|
206 |
Â
*/
|
207 |
Â
public function setup_globals( $args = array() ) {
|
223 |
Â
'meta_tables' => '',
|
224 |
Â
) );
|
225 |
Â
|
226 |
+
/**
|
227 |
+
* Filters the slug to be used for the permalink URI chunk after root.
|
228 |
+
*
|
229 |
+
* @since BuddyPress (1.5.0)
|
230 |
+
*
|
231 |
+
* @param string $value Slug to use in permalink URI chunk.
|
232 |
+
*/
|
233 |
Â
$this->slug = apply_filters( 'bp_' . $this->id . '_slug', $r['slug'] );
|
234 |
Â
|
235 |
+
/**
|
236 |
+
* Filters the slug used for root directory.
|
237 |
+
*
|
238 |
+
* @since BuddyPress (1.5.0)
|
239 |
+
*
|
240 |
+
* @param string $value Root directory slug.
|
241 |
+
*/
|
242 |
Â
$this->root_slug = apply_filters( 'bp_' . $this->id . '_root_slug', $r['root_slug'] );
|
243 |
Â
|
244 |
+
/**
|
245 |
+
* Filters the component's top-level directory if available.
|
246 |
+
*
|
247 |
+
* @since BuddyPress (1.5.0)
|
248 |
+
*
|
249 |
+
* @param bool $value Whether or not there is a top-level directory.
|
250 |
+
*/
|
251 |
Â
$this->has_directory = apply_filters( 'bp_' . $this->id . '_has_directory', $r['has_directory'] );
|
252 |
Â
|
253 |
+
/**
|
254 |
+
* Filters the component's directory title.
|
255 |
+
*
|
256 |
+
* @since BuddyPress (2.0.0)
|
257 |
+
*
|
258 |
+
* @param string $value Title to use for the directory.
|
259 |
+
*/
|
260 |
Â
$this->directory_title = apply_filters( 'bp_' . $this->id . '_directory_title', $r['directory_title'] );
|
261 |
Â
|
262 |
+
/**
|
263 |
+
* Filters the placeholder text for search inputs for component.
|
264 |
+
*
|
265 |
+
* @since BuddyPress (1.5.0)
|
266 |
+
*
|
267 |
+
* @param string $value Name to use in search input placeholders.
|
268 |
+
*/
|
269 |
Â
$this->search_string = apply_filters( 'bp_' . $this->id . '_search_string', $r['search_string'] );
|
270 |
Â
|
271 |
+
/**
|
272 |
+
* Filters the callable function that formats the component's notifications.
|
273 |
+
*
|
274 |
+
* @since BuddyPress (1.5.0)
|
275 |
+
*
|
276 |
+
* @param string $value Function callback.
|
277 |
+
*/
|
278 |
Â
$this->notification_callback = apply_filters( 'bp_' . $this->id . '_notification_callback', $r['notification_callback'] );
|
279 |
Â
|
280 |
Â
// Set the global table names, if applicable
|
292 |
Â
// Register this component in the loaded components array
|
293 |
Â
buddypress()->loaded_components[$this->slug] = $this->id;
|
294 |
Â
|
295 |
+
/**
|
296 |
+
* Fires at the end of the setup_globals method inside BP_Component.
|
297 |
+
*
|
298 |
+
* This is a dynamic hook that is based on the component string ID.
|
299 |
+
*
|
300 |
+
* @since BuddyPress (1.5.0)
|
301 |
+
*/
|
302 |
Â
do_action( 'bp_' . $this->id . '_setup_globals' );
|
303 |
Â
}
|
304 |
Â
|
363 |
Â
}
|
364 |
Â
}
|
365 |
Â
|
366 |
+
/**
|
367 |
+
* Fires at the end of the includes method inside BP_Component.
|
368 |
+
*
|
369 |
+
* This is a dynamic hook that is based on the component string ID.
|
370 |
+
*
|
371 |
+
* @since BuddyPress (1.5.0)
|
372 |
+
*/
|
373 |
Â
do_action( 'bp_' . $this->id . '_includes' );
|
374 |
Â
}
|
375 |
Â
|
429 |
Â
// Generate rewrite rules
|
430 |
Â
add_action( 'bp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10 );
|
431 |
Â
|
432 |
+
/**
|
433 |
+
* Fires at the end of the setup_actions method inside BP_Component.
|
434 |
+
*
|
435 |
+
* This is a dynamic hook that is based on the component string ID.
|
436 |
+
*
|
437 |
+
* @since BuddyPress (1.5.0)
|
438 |
+
*/
|
439 |
Â
do_action( 'bp_' . $this->id . '_setup_actions' );
|
440 |
Â
}
|
441 |
Â
|
474 |
Â
}
|
475 |
Â
}
|
476 |
Â
|
477 |
+
/**
|
478 |
+
* Fires at the end of the setup_nav method inside BP_Component.
|
479 |
+
*
|
480 |
+
* This is a dynamic hook that is based on the component string ID.
|
481 |
+
*
|
482 |
+
* @since BuddyPress (1.5.0)
|
483 |
+
*/
|
484 |
Â
do_action( 'bp_' . $this->id . '_setup_nav' );
|
485 |
Â
}
|
486 |
Â
|
508 |
Â
return;
|
509 |
Â
}
|
510 |
Â
|
511 |
+
/**
|
512 |
+
* Filters the admin navigation passed into setup_admin_bar.
|
513 |
+
*
|
514 |
+
* This is a dynamic hook that is based on the component string ID.
|
515 |
+
*
|
516 |
+
* @since BuddyPress (1.9.0)
|
517 |
+
*
|
518 |
+
* @param array $wp_admin_nav Array of navigation items to add.
|
519 |
+
*/
|
520 |
Â
$wp_admin_nav = apply_filters( 'bp_' . $this->id . '_admin_nav', $wp_admin_nav );
|
521 |
Â
|
522 |
Â
// Do we have Toolbar menus to add?
|
534 |
Â
}
|
535 |
Â
}
|
536 |
Â
|
537 |
+
/**
|
538 |
+
* Fires at the end of the setup_admin_bar method inside BP_Component.
|
539 |
+
*
|
540 |
+
* This is a dynamic hook that is based on the component string ID.
|
541 |
+
*
|
542 |
+
* @since BuddyPress (1.5.0)
|
543 |
+
*/
|
544 |
Â
do_action( 'bp_' . $this->id . '_setup_admin_bar' );
|
545 |
Â
}
|
546 |
Â
|
552 |
Â
* @uses do_action() Calls 'bp_{@link bp_Component::name}_setup_title'.
|
553 |
Â
*/
|
554 |
Â
public function setup_title() {
|
555 |
+
|
556 |
+
/**
|
557 |
+
* Fires in the setup_title method inside BP_Component.
|
558 |
+
*
|
559 |
+
* This is a dynamic hook that is based on the component string ID.
|
560 |
+
*
|
561 |
+
* @since BuddyPress (1.5.0)
|
562 |
+
*/
|
563 |
Â
do_action( 'bp_' . $this->id . '_setup_title' );
|
564 |
Â
}
|
565 |
Â
|
571 |
Â
* @uses do_action() Calls 'bp_setup_{@link bp_Component::name}_cache_groups'.
|
572 |
Â
*/
|
573 |
Â
public function setup_cache_groups() {
|
574 |
+
|
575 |
+
/**
|
576 |
+
* Fires in the setup_cache_groups method inside BP_Component.
|
577 |
+
*
|
578 |
+
* This is a dynamic hook that is based on the component string ID.
|
579 |
+
*
|
580 |
+
* @since BuddyPress (2.2.0)
|
581 |
+
*/
|
582 |
Â
do_action( 'bp_' . $this->id . '_setup_cache_groups' );
|
583 |
Â
}
|
584 |
Â
|
591 |
Â
*/
|
592 |
Â
public function register_global_tables( $tables = array() ) {
|
593 |
Â
|
594 |
+
/**
|
595 |
+
* Filters the global tables for the component, so that it may use WordPress' database API.
|
596 |
+
*
|
597 |
+
* This is a dynamic hook that is based on the component string ID.
|
598 |
+
* It allows for component-specific filtering of table names. To filter
|
599 |
+
* *all* tables, use the 'bp_core_get_table_prefix' filter instead.
|
600 |
+
*
|
601 |
+
* @since BuddyPress (1.6.0)
|
602 |
+
*/
|
603 |
Â
$tables = apply_filters( 'bp_' . $this->id . '_global_tables', $tables );
|
604 |
Â
|
605 |
Â
// Add to the BuddyPress global object
|
612 |
Â
$this->global_tables = $tables;
|
613 |
Â
}
|
614 |
Â
|
615 |
+
/**
|
616 |
+
* Fires at the end of the register_global_tables method inside BP_Component.
|
617 |
+
*
|
618 |
+
* This is a dynamic hook that is based on the component string ID.
|
619 |
+
*
|
620 |
+
* @since BuddyPress (2.0.0)
|
621 |
+
*/
|
622 |
Â
do_action( 'bp_' . $this->id . '_register_global_tables' );
|
623 |
Â
}
|
624 |
Â
|
635 |
Â
public function register_meta_tables( $tables = array() ) {
|
636 |
Â
global $wpdb;
|
637 |
Â
|
638 |
+
/**
|
639 |
+
* Filters the global meta_tables for the component.
|
640 |
+
*
|
641 |
+
* This is a dynamic hook that is based on the component string ID.
|
642 |
+
* It allows for component-specific filtering of table names. To filter
|
643 |
+
* *all* tables, use the 'bp_core_get_table_prefix' filter instead.
|
644 |
+
*
|
645 |
+
* @since BuddyPress (2.0.0)
|
646 |
+
*/
|
647 |
Â
$tables = apply_filters( 'bp_' . $this->id . '_meta_tables', $tables );
|
648 |
Â
|
649 |
Â
/**
|
659 |
Â
$this->meta_tables = $tables;
|
660 |
Â
}
|
661 |
Â
|
662 |
+
/**
|
663 |
+
* Fires at the end of the register_meta_tables method inside BP_Component.
|
664 |
+
*
|
665 |
+
* This is a dynamic hook that is based on the component string ID.
|
666 |
+
*
|
667 |
+
* @since BuddyPress (2.0.0)
|
668 |
+
*/
|
669 |
Â
do_action( 'bp_' . $this->id . '_register_meta_tables' );
|
670 |
Â
}
|
671 |
Â
|
677 |
Â
* @uses do_action() Calls 'bp_{@link bp_Component::name}_register_post_types'.
|
678 |
Â
*/
|
679 |
Â
public function register_post_types() {
|
680 |
+
|
681 |
+
/**
|
682 |
+
* Fires in the register_post_types method inside BP_Component.
|
683 |
+
*
|
684 |
+
* This is a dynamic hook that is based on the component string ID.
|
685 |
+
*
|
686 |
+
* @since BuddyPress (1.5.0)
|
687 |
+
*/
|
688 |
Â
do_action( 'bp_' . $this->id . '_register_post_types' );
|
689 |
Â
}
|
690 |
Â
|
696 |
Â
* @uses do_action() Calls 'bp_{@link bp_Component::name}_register_taxonomies'.
|
697 |
Â
*/
|
698 |
Â
public function register_taxonomies() {
|
699 |
+
|
700 |
+
/**
|
701 |
+
* Fires in the register_taxonomies method inside BP_Component.
|
702 |
+
*
|
703 |
+
* This is a dynamic hook that is based on the component string ID.
|
704 |
+
*
|
705 |
+
* @since BuddyPress (1.5.0)
|
706 |
+
*/
|
707 |
Â
do_action( 'bp_' . $this->id . '_register_taxonomies' );
|
708 |
Â
}
|
709 |
Â
|
715 |
Â
* @uses do_action() Calls 'bp_{@link bp_Component::name}_add_rewrite_tags'.
|
716 |
Â
*/
|
717 |
Â
public function add_rewrite_tags() {
|
718 |
+
|
719 |
+
/**
|
720 |
+
* Fires in the add_rewrite_tags method inside BP_Component.
|
721 |
+
*
|
722 |
+
* This is a dynamic hook that is based on the component string ID.
|
723 |
+
*
|
724 |
+
* @since BuddyPress (1.5.0)
|
725 |
+
*/
|
726 |
Â
do_action( 'bp_' . $this->id . '_add_rewrite_tags' );
|
727 |
Â
}
|
728 |
Â
|
734 |
Â
* @uses do_action() Calls 'bp_{@link bp_Component::name}_add_rewrite_rules'.
|
735 |
Â
*/
|
736 |
Â
public function add_rewrite_rules() {
|
737 |
+
|
738 |
+
/**
|
739 |
+
* Fires in the add_rewrite_rules method inside BP_Component.
|
740 |
+
*
|
741 |
+
* This is a dynamic hook that is based on the component string ID.
|
742 |
+
*
|
743 |
+
* @since BuddyPress (1.9.0)
|
744 |
+
*/
|
745 |
Â
do_action( 'bp_' . $this->id . '_add_rewrite_rules' );
|
746 |
Â
}
|
747 |
Â
|
753 |
Â
* @uses do_action() Calls 'bp_{@link bp_Component::name}_add_permastruct'
|
754 |
Â
*/
|
755 |
Â
public function add_permastructs() {
|
756 |
+
|
757 |
+
/**
|
758 |
+
* Fires in the add_permastructs method inside BP_Component.
|
759 |
+
*
|
760 |
+
* This is a dynamic hook that is based on the component string ID.
|
761 |
+
*
|
762 |
+
* @since BuddyPress (1.9.0)
|
763 |
+
*/
|
764 |
Â
do_action( 'bp_' . $this->id . '_add_permastructs' );
|
765 |
Â
}
|
766 |
Â
|
773 |
Â
* @param object The main WP_Query
|
774 |
Â
*/
|
775 |
Â
public function parse_query( $query ) {
|
776 |
+
|
777 |
+
/**
|
778 |
+
* Fires in the parse_query method inside BP_Component.
|
779 |
+
*
|
780 |
+
* This is a dynamic hook that is based on the component string ID.
|
781 |
+
*
|
782 |
+
* @since BuddyPress (1.9.0)
|
783 |
+
*
|
784 |
+
* @param object $query Main WP_Query object. Passed by reference.
|
785 |
+
*/
|
786 |
Â
do_action_ref_array( 'bp_' . $this->id . '_parse_query', array( &$query ) );
|
787 |
Â
}
|
788 |
Â
|
794 |
Â
* @uses do_action() Calls 'bp_{@link bp_Component::name}_generate_rewrite_rules'
|
795 |
Â
*/
|
796 |
Â
public function generate_rewrite_rules() {
|
797 |
+
|
798 |
+
/**
|
799 |
+
* Fires in the generate_rewrite_rules method inside BP_Component.
|
800 |
+
*
|
801 |
+
* This is a dynamic hook that is based on the component string ID.
|
802 |
+
*
|
803 |
+
* @since BuddyPress (1.5.0)
|
804 |
+
*/
|
805 |
Â
do_action( 'bp_' . $this->id . '_generate_rewrite_rules' );
|
806 |
Â
}
|
807 |
Â
}
|
bp-core/bp-core-cssjs.php
CHANGED
@@ -17,23 +17,37 @@ defined( 'ABSPATH' ) || exit;
|
|
17 |
Â
function bp_core_register_common_scripts() {
|
18 |
Â
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
19 |
Â
$url = buddypress()->plugin_url . 'bp-core/js/';
|
20 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
21 |
Â
$scripts = apply_filters( 'bp_core_register_common_scripts', array(
|
22 |
Â
|
23 |
Â
// Legacy
|
24 |
-
'bp-confirm' => array( 'file' => "{$url}confirm{$min}.js", 'dependencies' => array( 'jquery' ) ),
|
25 |
-
'bp-widget-members' => array( 'file' => "{$url}widget-members{$min}.js", 'dependencies' => array( 'jquery' ) ),
|
26 |
-
'bp-jquery-query' => array( 'file' => "{$url}jquery-query{$min}.js", 'dependencies' => array( 'jquery' ) ),
|
27 |
-
'bp-jquery-cookie' => array( 'file' => "{$url}jquery-cookie{$min}.js", 'dependencies' => array( 'jquery' ) ),
|
Â
|
|
28 |
Â
|
29 |
Â
// 2.1
|
30 |
-
'jquery-caret' => array( 'file' => "{$url}jquery.caret{$min}.js", 'dependencies' => array( 'jquery' ) ),
|
31 |
-
'jquery-atwho' => array( 'file' => "{$url}jquery.atwho{$min}.js", 'dependencies' => array( 'jquery', 'jquery-caret' ) ),
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
32 |
Â
) );
|
33 |
Â
|
34 |
Â
$version = bp_get_version();
|
35 |
Â
foreach ( $scripts as $id => $script ) {
|
36 |
-
wp_register_script( $id, $script['file'], $script['dependencies'], $version );
|
37 |
Â
}
|
38 |
Â
}
|
39 |
Â
add_action( 'bp_enqueue_scripts', 'bp_core_register_common_scripts', 1 );
|
@@ -48,11 +62,31 @@ function bp_core_register_common_styles() {
|
|
48 |
Â
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
49 |
Â
$url = buddypress()->plugin_url . 'bp-core/css/';
|
50 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
51 |
Â
$styles = apply_filters( 'bp_core_register_common_styles', array(
|
52 |
Â
'bp-admin-bar' => array(
|
53 |
-
'file' =>
|
54 |
Â
'dependencies' => array( 'admin-bar' )
|
55 |
-
)
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
56 |
Â
) );
|
57 |
Â
|
58 |
Â
foreach ( $styles as $id => $style ) {
|
@@ -82,8 +116,28 @@ function bp_core_confirmation_js() {
|
|
82 |
Â
) );
|
83 |
Â
|
84 |
Â
}
|
85 |
-
add_action( 'bp_enqueue_scripts',
|
86 |
-
add_action( '
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
87 |
Â
|
88 |
Â
/**
|
89 |
Â
* Enqueues jCrop library and hooks BP's custom cropper JS.
|
@@ -100,7 +154,13 @@ function bp_core_add_jquery_cropper() {
|
|
100 |
Â
*/
|
101 |
Â
function bp_core_add_cropper_inline_js() {
|
102 |
Â
|
103 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
104 |
Â
$image = apply_filters( 'bp_inline_cropper_image', getimagesize( bp_core_avatar_upload_path() . buddypress()->avatar_admin->image->dir ) );
|
105 |
Â
if ( empty( $image ) ) {
|
106 |
Â
return;
|
@@ -163,7 +223,6 @@ function bp_core_add_cropper_inline_js() {
|
|
163 |
Â
aspectRatio: <?php echo (int) $aspect_ratio; ?>,
|
164 |
Â
setSelect: [ <?php echo (int) $crop_left; ?>, <?php echo (int) $crop_top; ?>, <?php echo (int) $crop_right; ?>, <?php echo (int) $crop_bottom; ?> ]
|
165 |
Â
});
|
166 |
-
updateCoords({x: <?php echo (int) $crop_left; ?>, y: <?php echo (int) $crop_top; ?>, w: <?php echo (int) $crop_right; ?>, h: <?php echo (int) $crop_bottom; ?>});
|
167 |
Â
});
|
168 |
Â
|
169 |
Â
function updateCoords(c) {
|
@@ -240,19 +299,35 @@ add_action( 'wp_head', 'bp_core_add_ajax_url_js' );
|
|
240 |
Â
* @return string AJAX endpoint URL.
|
241 |
Â
*/
|
242 |
Â
function bp_core_ajax_url() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
243 |
Â
return apply_filters( 'bp_core_ajax_url', admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ) );
|
244 |
Â
}
|
245 |
Â
|
246 |
Â
/**
|
247 |
-
* Get the
|
248 |
Â
*
|
249 |
Â
* @since BuddyPress (2.0.0)
|
250 |
Â
*
|
251 |
Â
* @uses apply_filters() to allow other component to load extra dependencies
|
252 |
Â
*
|
253 |
-
* @return array The
|
254 |
Â
*/
|
255 |
Â
function bp_core_get_js_dependencies() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
256 |
Â
return apply_filters( 'bp_core_get_js_dependencies', array(
|
257 |
Â
'jquery',
|
258 |
Â
'bp-confirm',
|
17 |
Â
function bp_core_register_common_scripts() {
|
18 |
Â
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
19 |
Â
$url = buddypress()->plugin_url . 'bp-core/js/';
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Filters the BuddyPress Core javascript files to register.
|
23 |
+
*
|
24 |
+
* @since BuddyPress (2.1.0)
|
25 |
+
*
|
26 |
+
* @param array $value Array of javascript file information to register.
|
27 |
+
*/
|
28 |
Â
$scripts = apply_filters( 'bp_core_register_common_scripts', array(
|
29 |
Â
|
30 |
Â
// Legacy
|
31 |
+
'bp-confirm' => array( 'file' => "{$url}confirm{$min}.js", 'dependencies' => array( 'jquery' ), 'footer' => false ),
|
32 |
+
'bp-widget-members' => array( 'file' => "{$url}widget-members{$min}.js", 'dependencies' => array( 'jquery' ), 'footer' => false ),
|
33 |
+
'bp-jquery-query' => array( 'file' => "{$url}jquery-query{$min}.js", 'dependencies' => array( 'jquery' ), 'footer' => false ),
|
34 |
+
'bp-jquery-cookie' => array( 'file' => "{$url}jquery-cookie{$min}.js", 'dependencies' => array( 'jquery' ), 'footer' => false ),
|
35 |
+
'bp-jquery-scroll-to' => array( 'file' => "{$url}jquery-scroll-to{$min}.js", 'dependencies' => array( 'jquery' ), 'footer' => false ),
|
36 |
Â
|
37 |
Â
// 2.1
|
38 |
+
'jquery-caret' => array( 'file' => "{$url}jquery.caret{$min}.js", 'dependencies' => array( 'jquery' ), 'footer' => true ),
|
39 |
+
'jquery-atwho' => array( 'file' => "{$url}jquery.atwho{$min}.js", 'dependencies' => array( 'jquery', 'jquery-caret' ), 'footer' => true ),
|
40 |
+
|
41 |
+
// 2.3
|
42 |
+
'bp-plupload' => array( 'file' => "{$url}bp-plupload{$min}.js", 'dependencies' => array( 'plupload', 'jquery', 'json2', 'wp-backbone' ), 'footer' => true ),
|
43 |
+
'bp-avatar' => array( 'file' => "{$url}avatar{$min}.js", 'dependencies' => array( 'jcrop' ), 'footer' => true ),
|
44 |
+
'bp-webcam' => array( 'file' => "{$url}webcam{$min}.js", 'dependencies' => array( 'bp-avatar' ), 'footer' => true ),
|
45 |
+
|
46 |
Â
) );
|
47 |
Â
|
48 |
Â
$version = bp_get_version();
|
49 |
Â
foreach ( $scripts as $id => $script ) {
|
50 |
+
wp_register_script( $id, $script['file'], $script['dependencies'], $version, $script['footer'] );
|
51 |
Â
}
|
52 |
Â
}
|
53 |
Â
add_action( 'bp_enqueue_scripts', 'bp_core_register_common_scripts', 1 );
|
62 |
Â
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
63 |
Â
$url = buddypress()->plugin_url . 'bp-core/css/';
|
64 |
Â
|
65 |
+
/**
|
66 |
+
* Filters the URL for the Admin Bar stylesheet.
|
67 |
+
*
|
68 |
+
* @since BuddyPress (1.1.0)
|
69 |
+
*
|
70 |
+
* @param string $value URL for the Admin Bar stylesheet.
|
71 |
+
*/
|
72 |
+
$admin_bar_file = apply_filters( 'bp_core_admin_bar_css', "{$url}admin-bar{$min}.css" );
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Filters the BuddyPress Core stylesheet files to register.
|
76 |
+
*
|
77 |
+
* @since BuddyPress (2.1.0)
|
78 |
+
*
|
79 |
+
* @param array $value Array of stylesheet file information to register.
|
80 |
+
*/
|
81 |
Â
$styles = apply_filters( 'bp_core_register_common_styles', array(
|
82 |
Â
'bp-admin-bar' => array(
|
83 |
+
'file' => $admin_bar_file,
|
84 |
Â
'dependencies' => array( 'admin-bar' )
|
85 |
+
),
|
86 |
+
'bp-avatar' => array(
|
87 |
+
'file' => "{$url}avatar{$min}.css",
|
88 |
+
'dependencies' => array( 'jcrop' )
|
89 |
+
),
|
90 |
Â
) );
|
91 |
Â
|
92 |
Â
foreach ( $styles as $id => $style ) {
|
116 |
Â
) );
|
117 |
Â
|
118 |
Â
}
|
119 |
+
add_action( 'bp_enqueue_scripts', 'bp_core_confirmation_js' );
|
120 |
+
add_action( 'bp_admin_enqueue_scripts', 'bp_core_confirmation_js' );
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Enqueues the css and js required by the Avatar UI
|
124 |
+
*
|
125 |
+
* @since BuddyPress (2.3.0)
|
126 |
+
*/
|
127 |
+
function bp_core_avatar_scripts() {
|
128 |
+
if ( ! bp_avatar_is_front_edit() ) {
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
|
132 |
+
// Enqueue the Attachments scripts for the Avatar UI
|
133 |
+
bp_attachments_enqueue_scripts( 'BP_Attachment_Avatar' );
|
134 |
+
|
135 |
+
// Add Some actions for Theme backcompat
|
136 |
+
add_action( 'bp_after_profile_avatar_upload_content', 'bp_avatar_template_check' );
|
137 |
+
add_action( 'bp_after_group_admin_content', 'bp_avatar_template_check' );
|
138 |
+
add_action( 'bp_after_group_avatar_creation_step', 'bp_avatar_template_check' );
|
139 |
+
}
|
140 |
+
add_action( 'bp_enqueue_scripts', 'bp_core_avatar_scripts' );
|
141 |
Â
|
142 |
Â
/**
|
143 |
Â
* Enqueues jCrop library and hooks BP's custom cropper JS.
|
154 |
Â
*/
|
155 |
Â
function bp_core_add_cropper_inline_js() {
|
156 |
Â
|
157 |
+
/**
|
158 |
+
* Filters the return value of getimagesize to determine if an image was uploaded.
|
159 |
+
*
|
160 |
+
* @since BuddyPress (1.1.0)
|
161 |
+
*
|
162 |
+
* @param array $value Array of data found by getimagesize.
|
163 |
+
*/
|
164 |
Â
$image = apply_filters( 'bp_inline_cropper_image', getimagesize( bp_core_avatar_upload_path() . buddypress()->avatar_admin->image->dir ) );
|
165 |
Â
if ( empty( $image ) ) {
|
166 |
Â
return;
|
223 |
Â
aspectRatio: <?php echo (int) $aspect_ratio; ?>,
|
224 |
Â
setSelect: [ <?php echo (int) $crop_left; ?>, <?php echo (int) $crop_top; ?>, <?php echo (int) $crop_right; ?>, <?php echo (int) $crop_bottom; ?> ]
|
225 |
Â
});
|
Â
|
|
226 |
Â
});
|
227 |
Â
|
228 |
Â
function updateCoords(c) {
|
299 |
Â
* @return string AJAX endpoint URL.
|
300 |
Â
*/
|
301 |
Â
function bp_core_ajax_url() {
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Filters the proper value for BuddyPress' ajaxurl.
|
305 |
+
*
|
306 |
+
* @since BuddyPress (1.7.0)
|
307 |
+
*
|
308 |
+
* @param string $value Proper ajaxurl value for BuddyPress.
|
309 |
+
*/
|
310 |
Â
return apply_filters( 'bp_core_ajax_url', admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ) );
|
311 |
Â
}
|
312 |
Â
|
313 |
Â
/**
|
314 |
+
* Get the JavaScript dependencies for buddypress.js.
|
315 |
Â
*
|
316 |
Â
* @since BuddyPress (2.0.0)
|
317 |
Â
*
|
318 |
Â
* @uses apply_filters() to allow other component to load extra dependencies
|
319 |
Â
*
|
320 |
+
* @return array The JavaScript dependencies.
|
321 |
Â
*/
|
322 |
Â
function bp_core_get_js_dependencies() {
|
323 |
+
|
324 |
+
/**
|
325 |
+
* Filters the javascript dependencies for buddypress.js.
|
326 |
+
*
|
327 |
+
* @since BuddyPress (2.0.0)
|
328 |
+
*
|
329 |
+
* @param array $value Array of javascript dependencies for buddypress.js.
|
330 |
+
*/
|
331 |
Â
return apply_filters( 'bp_core_get_js_dependencies', array(
|
332 |
Â
'jquery',
|
333 |
Â
'bp-confirm',
|
bp-core/bp-core-dependency.php
CHANGED
@@ -21,6 +21,12 @@
|
|
21 |
Â
* Fire the 'bp_include' action, where plugins should include files.
|
22 |
Â
*/
|
23 |
Â
function bp_include() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
do_action( 'bp_include' );
|
25 |
Â
}
|
26 |
Â
|
@@ -28,6 +34,12 @@ function bp_include() {
|
|
28 |
Â
* Fire the 'bp_setup_components' action, where plugins should initialize components.
|
29 |
Â
*/
|
30 |
Â
function bp_setup_components() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
31 |
Â
do_action( 'bp_setup_components' );
|
32 |
Â
}
|
33 |
Â
|
@@ -35,6 +47,12 @@ function bp_setup_components() {
|
|
35 |
Â
* Fire the 'bp_setup_canonical_stack' action, where plugins should set up their canonical URL.
|
36 |
Â
*/
|
37 |
Â
function bp_setup_canonical_stack() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
38 |
Â
do_action( 'bp_setup_canonical_stack' );
|
39 |
Â
}
|
40 |
Â
|
@@ -44,6 +62,12 @@ function bp_setup_canonical_stack() {
|
|
44 |
Â
* @since BuddyPress (2.2.0)
|
45 |
Â
*/
|
46 |
Â
function bp_register_taxonomies() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
47 |
Â
do_action( 'bp_register_taxonomies' );
|
48 |
Â
}
|
49 |
Â
|
@@ -51,6 +75,12 @@ function bp_register_taxonomies() {
|
|
51 |
Â
* Fire the 'bp_setup_globals' action, where plugins should initialize global settings.
|
52 |
Â
*/
|
53 |
Â
function bp_setup_globals() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
54 |
Â
do_action( 'bp_setup_globals' );
|
55 |
Â
}
|
56 |
Â
|
@@ -58,6 +88,12 @@ function bp_setup_globals() {
|
|
58 |
Â
* Fire the 'bp_setup_nav' action, where plugins should register their navigation items.
|
59 |
Â
*/
|
60 |
Â
function bp_setup_nav() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
61 |
Â
do_action( 'bp_setup_nav' );
|
62 |
Â
}
|
63 |
Â
|
@@ -65,14 +101,29 @@ function bp_setup_nav() {
|
|
65 |
Â
* Fire the 'bp_setup_admin_bar' action, where plugins should add items to the WP admin bar.
|
66 |
Â
*/
|
67 |
Â
function bp_setup_admin_bar() {
|
68 |
-
if ( bp_use_wp_admin_bar() )
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
69 |
Â
do_action( 'bp_setup_admin_bar' );
|
Â
|
|
70 |
Â
}
|
71 |
Â
|
72 |
Â
/**
|
73 |
Â
* Fire the 'bp_setup_title' action, where plugins should modify the page title.
|
74 |
Â
*/
|
75 |
Â
function bp_setup_title() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
76 |
Â
do_action( 'bp_setup_title' );
|
77 |
Â
}
|
78 |
Â
|
@@ -80,21 +131,53 @@ function bp_setup_title() {
|
|
80 |
Â
* Fire the 'bp_register_widgets' action, where plugins should register widgets.
|
81 |
Â
*/
|
82 |
Â
function bp_setup_widgets() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
83 |
Â
do_action( 'bp_register_widgets' );
|
84 |
Â
}
|
85 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
86 |
Â
/**
|
87 |
Â
* Fire the 'bp_setup_cache_groups' action, where cache groups are registered.
|
88 |
Â
*
|
89 |
Â
* @since BuddyPress (2.2.0)
|
90 |
Â
*/
|
91 |
Â
function bp_setup_cache_groups() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
92 |
Â
do_action( 'bp_setup_cache_groups' );
|
93 |
Â
}
|
94 |
Â
|
95 |
Â
/**
|
96 |
Â
* Set up the currently logged-in user.
|
97 |
Â
*
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
98 |
Â
* @uses did_action() To make sure the user isn't loaded out of order.
|
99 |
Â
* @uses do_action() Calls 'bp_setup_current_user'.
|
100 |
Â
*/
|
@@ -102,10 +185,15 @@ function bp_setup_current_user() {
|
|
102 |
Â
|
103 |
Â
// If the current user is being setup before the "init" action has fired,
|
104 |
Â
// strange (and difficult to debug) role/capability issues will occur.
|
105 |
-
if ( ! did_action( 'after_setup_theme' ) ) {
|
106 |
Â
_doing_it_wrong( __FUNCTION__, __( 'The current user is being initialized without using $wp->init().', 'buddypress' ), '1.7' );
|
107 |
Â
}
|
108 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
109 |
Â
do_action( 'bp_setup_current_user' );
|
110 |
Â
}
|
111 |
Â
|
@@ -113,6 +201,12 @@ function bp_setup_current_user() {
|
|
113 |
Â
* Fire the 'bp_init' action, BuddyPress's main initialization hook.
|
114 |
Â
*/
|
115 |
Â
function bp_init() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
116 |
Â
do_action( 'bp_init' );
|
117 |
Â
}
|
118 |
Â
|
@@ -122,6 +216,12 @@ function bp_init() {
|
|
122 |
Â
* Attached to 'plugins_loaded'.
|
123 |
Â
*/
|
124 |
Â
function bp_loaded() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
125 |
Â
do_action( 'bp_loaded' );
|
126 |
Â
}
|
127 |
Â
|
@@ -131,6 +231,12 @@ function bp_loaded() {
|
|
131 |
Â
* Attached to 'wp'.
|
132 |
Â
*/
|
133 |
Â
function bp_ready() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
134 |
Â
do_action( 'bp_ready' );
|
135 |
Â
}
|
136 |
Â
|
@@ -141,6 +247,12 @@ function bp_ready() {
|
|
141 |
Â
* custom URLs.
|
142 |
Â
*/
|
143 |
Â
function bp_actions() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
144 |
Â
do_action( 'bp_actions' );
|
145 |
Â
}
|
146 |
Â
|
@@ -151,6 +263,14 @@ function bp_actions() {
|
|
151 |
Â
* loaders.
|
152 |
Â
*/
|
153 |
Â
function bp_screens() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
154 |
Â
do_action( 'bp_screens' );
|
155 |
Â
}
|
156 |
Â
|
@@ -160,6 +280,14 @@ function bp_screens() {
|
|
160 |
Â
* Hooked to 'widgets_init'.
|
161 |
Â
*/
|
162 |
Â
function bp_widgets_init() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
163 |
Â
do_action ( 'bp_widgets_init' );
|
164 |
Â
}
|
165 |
Â
|
@@ -186,6 +314,12 @@ function bp_head() {
|
|
186 |
Â
* @uses do_action()
|
187 |
Â
*/
|
188 |
Â
function bp_template_redirect() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
189 |
Â
do_action( 'bp_template_redirect' );
|
190 |
Â
}
|
191 |
Â
|
@@ -201,6 +335,14 @@ function bp_template_redirect() {
|
|
201 |
Â
* @uses do_action()
|
202 |
Â
*/
|
203 |
Â
function bp_register_theme_directory() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
204 |
Â
do_action( 'bp_register_theme_directory' );
|
205 |
Â
}
|
206 |
Â
|
@@ -214,6 +356,12 @@ function bp_register_theme_directory() {
|
|
214 |
Â
* @uses do_action()
|
215 |
Â
*/
|
216 |
Â
function bp_register_theme_packages() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
217 |
Â
do_action( 'bp_register_theme_packages' );
|
218 |
Â
}
|
219 |
Â
|
@@ -225,6 +373,12 @@ function bp_register_theme_packages() {
|
|
225 |
Â
* @uses do_action() Calls 'bp_enqueue_scripts'.
|
226 |
Â
*/
|
227 |
Â
function bp_enqueue_scripts() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
228 |
Â
do_action ( 'bp_enqueue_scripts' );
|
229 |
Â
}
|
230 |
Â
|
@@ -236,6 +390,12 @@ function bp_enqueue_scripts() {
|
|
236 |
Â
* @uses do_action() Calls 'bp_add_rewrite_tags'.
|
237 |
Â
*/
|
238 |
Â
function bp_add_rewrite_tags() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
239 |
Â
do_action( 'bp_add_rewrite_tags' );
|
240 |
Â
}
|
241 |
Â
|
@@ -247,6 +407,12 @@ function bp_add_rewrite_tags() {
|
|
247 |
Â
* @uses do_action() Calls 'bp_add_rewrite_rules'.
|
248 |
Â
*/
|
249 |
Â
function bp_add_rewrite_rules() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
250 |
Â
do_action( 'bp_add_rewrite_rules' );
|
251 |
Â
}
|
252 |
Â
|
@@ -258,6 +424,12 @@ function bp_add_rewrite_rules() {
|
|
258 |
Â
* @uses do_action() Calls 'bp_add_permastructs'.
|
259 |
Â
*/
|
260 |
Â
function bp_add_permastructs() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
261 |
Â
do_action( 'bp_add_permastructs' );
|
262 |
Â
}
|
263 |
Â
|
@@ -272,6 +444,12 @@ function bp_add_permastructs() {
|
|
272 |
Â
* @uses do_action() Calls 'bp_setup_theme'.
|
273 |
Â
*/
|
274 |
Â
function bp_setup_theme() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
275 |
Â
do_action ( 'bp_setup_theme' );
|
276 |
Â
}
|
277 |
Â
|
@@ -290,6 +468,12 @@ function bp_setup_theme() {
|
|
290 |
Â
* @uses do_action() Calls 'bp_after_setup_theme'.
|
291 |
Â
*/
|
292 |
Â
function bp_after_setup_theme() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
293 |
Â
do_action ( 'bp_after_setup_theme' );
|
294 |
Â
}
|
295 |
Â
|
@@ -306,6 +490,14 @@ function bp_after_setup_theme() {
|
|
306 |
Â
* @return array $query_vars See {@link WP::parse_request()}.
|
307 |
Â
*/
|
308 |
Â
function bp_request( $query_vars = array() ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
309 |
Â
return apply_filters( 'bp_request', $query_vars );
|
310 |
Â
}
|
311 |
Â
|
@@ -316,9 +508,21 @@ function bp_request( $query_vars = array() ) {
|
|
316 |
Â
*
|
317 |
Â
* @param string $redirect_to See 'login_redirect'.
|
318 |
Â
* @param string $redirect_to_raw See 'login_redirect'.
|
319 |
-
* @param
|
Â
|
|
Â
|
|
320 |
Â
*/
|
321 |
Â
function bp_login_redirect( $redirect_to = '', $redirect_to_raw = '', $user = false ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
322 |
Â
return apply_filters( 'bp_login_redirect', $redirect_to, $redirect_to_raw, $user );
|
323 |
Â
}
|
324 |
Â
|
@@ -335,11 +539,19 @@ function bp_login_redirect( $redirect_to = '', $redirect_to_raw = '', $user = fa
|
|
335 |
Â
* @return string Template file to use.
|
336 |
Â
*/
|
337 |
Â
function bp_template_include( $template = '' ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
338 |
Â
return apply_filters( 'bp_template_include', $template );
|
339 |
Â
}
|
340 |
Â
|
341 |
Â
/**
|
342 |
-
* Fire the 'bp_generate_rewrite_rules'
|
343 |
Â
*
|
344 |
Â
* @since BuddyPress (1.7.0)
|
345 |
Â
*
|
@@ -348,6 +560,14 @@ function bp_template_include( $template = '' ) {
|
|
348 |
Â
* @param WP_Rewrite $wp_rewrite See 'generate_rewrite_rules'.
|
349 |
Â
*/
|
350 |
Â
function bp_generate_rewrite_rules( $wp_rewrite ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
351 |
Â
do_action_ref_array( 'bp_generate_rewrite_rules', array( &$wp_rewrite ) );
|
352 |
Â
}
|
353 |
Â
|
@@ -361,6 +581,14 @@ function bp_generate_rewrite_rules( $wp_rewrite ) {
|
|
361 |
Â
* @uses apply_filters() Calls 'bp_allowed_themes' with the allowed themes list.
|
362 |
Â
*/
|
363 |
Â
function bp_allowed_themes( $themes ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
364 |
Â
return apply_filters( 'bp_allowed_themes', $themes );
|
365 |
Â
}
|
366 |
Â
|
@@ -387,11 +615,25 @@ function bp_post_request() {
|
|
387 |
Â
// Sanitize the POST action
|
388 |
Â
$action = sanitize_key( $_POST['action'] );
|
389 |
Â
|
390 |
-
|
391 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
392 |
Â
do_action( 'bp_post_request_' . $action );
|
393 |
Â
|
394 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
395 |
Â
do_action( 'bp_post_request', $action );
|
396 |
Â
}
|
397 |
Â
|
@@ -416,10 +658,24 @@ function bp_get_request() {
|
|
416 |
Â
// Sanitize the GET action
|
417 |
Â
$action = sanitize_key( $_GET['action'] );
|
418 |
Â
|
419 |
-
|
420 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
421 |
Â
do_action( 'bp_get_request_' . $action );
|
422 |
Â
|
423 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
424 |
Â
do_action( 'bp_get_request', $action );
|
425 |
Â
}
|
21 |
Â
* Fire the 'bp_include' action, where plugins should include files.
|
22 |
Â
*/
|
23 |
Â
function bp_include() {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Fires inside the 'bp_include' function, where plugins should include files.
|
27 |
+
*
|
28 |
+
* @since BuddyPress (1.2.5)
|
29 |
+
*/
|
30 |
Â
do_action( 'bp_include' );
|
31 |
Â
}
|
32 |
Â
|
34 |
Â
* Fire the 'bp_setup_components' action, where plugins should initialize components.
|
35 |
Â
*/
|
36 |
Â
function bp_setup_components() {
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Fires inside the 'bp_setup_components' function, where plugins should initialize components.
|
40 |
+
*
|
41 |
+
* @since BuddyPress (1.6.0)
|
42 |
+
*/
|
43 |
Â
do_action( 'bp_setup_components' );
|
44 |
Â
}
|
45 |
Â
|
47 |
Â
* Fire the 'bp_setup_canonical_stack' action, where plugins should set up their canonical URL.
|
48 |
Â
*/
|
49 |
Â
function bp_setup_canonical_stack() {
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Fires inside the 'bp_setup_canonical_stack' function, where plugins should set up their canonical URL.
|
53 |
+
*
|
54 |
+
* @since BuddyPress (2.1.0)
|
55 |
+
*/
|
56 |
Â
do_action( 'bp_setup_canonical_stack' );
|
57 |
Â
}
|
58 |
Â
|
62 |
Â
* @since BuddyPress (2.2.0)
|
63 |
Â
*/
|
64 |
Â
function bp_register_taxonomies() {
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Fires inside the 'bp_register_taxonomies' function, where plugins should register taxonomies.
|
68 |
+
*
|
69 |
+
* @since BuddyPress (2.2.0)
|
70 |
+
*/
|
71 |
Â
do_action( 'bp_register_taxonomies' );
|
72 |
Â
}
|
73 |
Â
|
75 |
Â
* Fire the 'bp_setup_globals' action, where plugins should initialize global settings.
|
76 |
Â
*/
|
77 |
Â
function bp_setup_globals() {
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Fires inside the 'bp_setup_globals' function, where plugins should initialize global settings.
|
81 |
+
*
|
82 |
+
* @since BuddyPress (1.2.0)
|
83 |
+
*/
|
84 |
Â
do_action( 'bp_setup_globals' );
|
85 |
Â
}
|
86 |
Â
|
88 |
Â
* Fire the 'bp_setup_nav' action, where plugins should register their navigation items.
|
89 |
Â
*/
|
90 |
Â
function bp_setup_nav() {
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Fires inside the 'bp_setup_nav' function, where plugins should register their navigation items.
|
94 |
+
*
|
95 |
+
* @since BuddyPress (1.2.0)
|
96 |
+
*/
|
97 |
Â
do_action( 'bp_setup_nav' );
|
98 |
Â
}
|
99 |
Â
|
101 |
Â
* Fire the 'bp_setup_admin_bar' action, where plugins should add items to the WP admin bar.
|
102 |
Â
*/
|
103 |
Â
function bp_setup_admin_bar() {
|
104 |
+
if ( bp_use_wp_admin_bar() ) {
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Fires inside the 'bp_setup_admin_bar' function, where plugins should add items to the WP admin bar.
|
108 |
+
*
|
109 |
+
* This hook will only fire if bp_use_wp_admin_bar() returns true.
|
110 |
+
*
|
111 |
+
* @since BuddyPress (1.5.0)
|
112 |
+
*/
|
113 |
Â
do_action( 'bp_setup_admin_bar' );
|
114 |
+
}
|
115 |
Â
}
|
116 |
Â
|
117 |
Â
/**
|
118 |
Â
* Fire the 'bp_setup_title' action, where plugins should modify the page title.
|
119 |
Â
*/
|
120 |
Â
function bp_setup_title() {
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Fires inside the 'bp_setup_title' function, where plugins should modify the page title.
|
124 |
+
*
|
125 |
+
* @since BuddyPress (1.5.0)
|
126 |
+
*/
|
127 |
Â
do_action( 'bp_setup_title' );
|
128 |
Â
}
|
129 |
Â
|
131 |
Â
* Fire the 'bp_register_widgets' action, where plugins should register widgets.
|
132 |
Â
*/
|
133 |
Â
function bp_setup_widgets() {
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Fires inside the 'bp_register_widgets' function, where plugins should register widgets.
|
137 |
+
*
|
138 |
+
* @since BuddyPress (1.2.0)
|
139 |
+
*/
|
140 |
Â
do_action( 'bp_register_widgets' );
|
141 |
Â
}
|
142 |
Â
|
143 |
+
/**
|
144 |
+
* Fire the 'bp_register_member_types' action, where plugins should register member types.
|
145 |
+
*
|
146 |
+
* @since BuddyPress (2.3.0)
|
147 |
+
*/
|
148 |
+
function bp_register_member_types() {
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Fires inside bp_register_member_types(), so plugins can register member types.
|
152 |
+
*
|
153 |
+
* @since BuddyPress (2.3.0)
|
154 |
+
*/
|
155 |
+
do_action( 'bp_register_member_types' );
|
156 |
+
}
|
157 |
+
|
158 |
Â
/**
|
159 |
Â
* Fire the 'bp_setup_cache_groups' action, where cache groups are registered.
|
160 |
Â
*
|
161 |
Â
* @since BuddyPress (2.2.0)
|
162 |
Â
*/
|
163 |
Â
function bp_setup_cache_groups() {
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Fires inside the 'bp_setup_cache_groups' function, where cache groups are registered.
|
167 |
+
*
|
168 |
+
* @since BuddyPress (2.2.0)
|
169 |
+
*/
|
170 |
Â
do_action( 'bp_setup_cache_groups' );
|
171 |
Â
}
|
172 |
Â
|
173 |
Â
/**
|
174 |
Â
* Set up the currently logged-in user.
|
175 |
Â
*
|
176 |
+
* We white-list the WordPress customizer which purposely loads the user early.
|
177 |
+
*
|
178 |
+
* @link https://buddypress.trac.wordpress.org/ticket/6046
|
179 |
+
* @link https://core.trac.wordpress.org/ticket/24169
|
180 |
+
*
|
181 |
Â
* @uses did_action() To make sure the user isn't loaded out of order.
|
182 |
Â
* @uses do_action() Calls 'bp_setup_current_user'.
|
183 |
Â
*/
|
185 |
Â
|
186 |
Â
// If the current user is being setup before the "init" action has fired,
|
187 |
Â
// strange (and difficult to debug) role/capability issues will occur.
|
188 |
+
if ( ! isset( $GLOBALS['wp_customize'] ) && ! did_action( 'after_setup_theme' ) ) {
|
189 |
Â
_doing_it_wrong( __FUNCTION__, __( 'The current user is being initialized without using $wp->init().', 'buddypress' ), '1.7' );
|
190 |
Â
}
|
191 |
Â
|
192 |
+
/**
|
193 |
+
* Fires to set up the current user setup process.
|
194 |
+
*
|
195 |
+
* @since BuddyPress (1.7.0)
|
196 |
+
*/
|
197 |
Â
do_action( 'bp_setup_current_user' );
|
198 |
Â
}
|
199 |
Â
|
201 |
Â
* Fire the 'bp_init' action, BuddyPress's main initialization hook.
|
202 |
Â
*/
|
203 |
Â
function bp_init() {
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Fires inside the 'bp_init' function, BuddyPress' main initialization hook.
|
207 |
+
*
|
208 |
+
* @since BuddyPress (1.2.0)
|
209 |
+
*/
|
210 |
Â
do_action( 'bp_init' );
|
211 |
Â
}
|
212 |
Â
|
216 |
Â
* Attached to 'plugins_loaded'.
|
217 |
Â
*/
|
218 |
Â
function bp_loaded() {
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Fires inside the 'bp_loaded' function, which fires after BP's core plugin files have been loaded.
|
222 |
+
*
|
223 |
+
* @since BuddyPress (1.2.5)
|
224 |
+
*/
|
225 |
Â
do_action( 'bp_loaded' );
|
226 |
Â
}
|
227 |
Â
|
231 |
Â
* Attached to 'wp'.
|
232 |
Â
*/
|
233 |
Â
function bp_ready() {
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Fires inside the 'bp_ready' function, which runs after BP is set up and the page is about to render.
|
237 |
+
*
|
238 |
+
* @since BuddyPress (1.6.0)
|
239 |
+
*/
|
240 |
Â
do_action( 'bp_ready' );
|
241 |
Â
}
|
242 |
Â
|
247 |
Â
* custom URLs.
|
248 |
Â
*/
|
249 |
Â
function bp_actions() {
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Fires inside the 'bp_actions' function, which runs just before rendering.
|
253 |
+
*
|
254 |
+
* @since BuddyPress (1.5.0)
|
255 |
+
*/
|
256 |
Â
do_action( 'bp_actions' );
|
257 |
Â
}
|
258 |
Â
|
263 |
Â
* loaders.
|
264 |
Â
*/
|
265 |
Â
function bp_screens() {
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Fires inside the 'bp_screens' function, which runs just before rendering.
|
269 |
+
*
|
270 |
+
* Runs just after 'bp_actions'. Use this hook to attach your template loaders.
|
271 |
+
*
|
272 |
+
* @since BuddyPress (1.5.0)
|
273 |
+
*/
|
274 |
Â
do_action( 'bp_screens' );
|
275 |
Â
}
|
276 |
Â
|
280 |
Â
* Hooked to 'widgets_init'.
|
281 |
Â
*/
|
282 |
Â
function bp_widgets_init() {
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Fires inside the 'bp_widgets_init' function, which runs after widgets have been set up.
|
286 |
+
*
|
287 |
+
* Hooked to 'widgets_init'.
|
288 |
+
*
|
289 |
+
* @since BuddyPress (1.6.0)
|
290 |
+
*/
|
291 |
Â
do_action ( 'bp_widgets_init' );
|
292 |
Â
}
|
293 |
Â
|
314 |
Â
* @uses do_action()
|
315 |
Â
*/
|
316 |
Â
function bp_template_redirect() {
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Fires inside the 'bp_template_redirect' function.
|
320 |
+
*
|
321 |
+
* @since BuddyPress (1.6.0)
|
322 |
+
*/
|
323 |
Â
do_action( 'bp_template_redirect' );
|
324 |
Â
}
|
325 |
Â
|
335 |
Â
* @uses do_action()
|
336 |
Â
*/
|
337 |
Â
function bp_register_theme_directory() {
|
338 |
+
|
339 |
+
/**
|
340 |
+
* Fires inside the 'bp_register_theme_directory' function.
|
341 |
+
*
|
342 |
+
* The main action used registering theme directories.
|
343 |
+
*
|
344 |
+
* @since BuddyPress (1.7.0)
|
345 |
+
*/
|
346 |
Â
do_action( 'bp_register_theme_directory' );
|
347 |
Â
}
|
348 |
Â
|
356 |
Â
* @uses do_action()
|
357 |
Â
*/
|
358 |
Â
function bp_register_theme_packages() {
|
359 |
+
|
360 |
+
/**
|
361 |
+
* Fires inside the 'bp_register_theme_packages' function.
|
362 |
+
*
|
363 |
+
* @since BuddyPress (1.7.0)
|
364 |
+
*/
|
365 |
Â
do_action( 'bp_register_theme_packages' );
|
366 |
Â
}
|
367 |
Â
|
373 |
Â
* @uses do_action() Calls 'bp_enqueue_scripts'.
|
374 |
Â
*/
|
375 |
Â
function bp_enqueue_scripts() {
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Fires inside the 'bp_enqueue_scripts' function, where BP enqueues its CSS and JS.
|
379 |
+
*
|
380 |
+
* @since BuddyPress (1.6.0)
|
381 |
+
*/
|
382 |
Â
do_action ( 'bp_enqueue_scripts' );
|
383 |
Â
}
|
384 |
Â
|
390 |
Â
* @uses do_action() Calls 'bp_add_rewrite_tags'.
|
391 |
Â
*/
|
392 |
Â
function bp_add_rewrite_tags() {
|
393 |
+
|
394 |
+
/**
|
395 |
+
* Fires inside the 'bp_add_rewrite_tags' function, where BP adds its custom rewrite tags.
|
396 |
+
*
|
397 |
+
* @since BuddyPress (1.8.0)
|
398 |
+
*/
|
399 |
Â
do_action( 'bp_add_rewrite_tags' );
|
400 |
Â
}
|
401 |
Â
|
407 |
Â
* @uses do_action() Calls 'bp_add_rewrite_rules'.
|
408 |
Â
*/
|
409 |
Â
function bp_add_rewrite_rules() {
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Fires inside the 'bp_add_rewrite_rules' function, where BP adds its custom rewrite rules.
|
413 |
+
*
|
414 |
+
* @since BuddyPress (1.9.0)
|
415 |
+
*/
|
416 |
Â
do_action( 'bp_add_rewrite_rules' );
|
417 |
Â
}
|
418 |
Â
|
424 |
Â
* @uses do_action() Calls 'bp_add_permastructs'.
|
425 |
Â
*/
|
426 |
Â
function bp_add_permastructs() {
|
427 |
+
|
428 |
+
/**
|
429 |
+
* Fires inside the 'bp_add_permastructs' function, where BP adds its BP-specific permalink structure.
|
430 |
+
*
|
431 |
+
* @since BuddyPress (1.9.0)
|
432 |
+
*/
|
433 |
Â
do_action( 'bp_add_permastructs' );
|
434 |
Â
}
|
435 |
Â
|
444 |
Â
* @uses do_action() Calls 'bp_setup_theme'.
|
445 |
Â
*/
|
446 |
Â
function bp_setup_theme() {
|
447 |
+
|
448 |
+
/**
|
449 |
+
* Fires inside the 'bp_setup_theme' function.
|
450 |
+
*
|
451 |
+
* @since BuddyPress (1.6.0)
|
452 |
+
*/
|
453 |
Â
do_action ( 'bp_setup_theme' );
|
454 |
Â
}
|
455 |
Â
|
468 |
Â
* @uses do_action() Calls 'bp_after_setup_theme'.
|
469 |
Â
*/
|
470 |
Â
function bp_after_setup_theme() {
|
471 |
+
|
472 |
+
/**
|
473 |
+
* Fires inside the 'bp_after_setup_theme' function.
|
474 |
+
*
|
475 |
+
* @since BuddyPress (1.7.0)
|
476 |
+
*/
|
477 |
Â
do_action ( 'bp_after_setup_theme' );
|
478 |
Â
}
|
479 |
Â
|
490 |
Â
* @return array $query_vars See {@link WP::parse_request()}.
|
491 |
Â
*/
|
492 |
Â
function bp_request( $query_vars = array() ) {
|
493 |
+
|
494 |
+
/**
|
495 |
+
* Filters the query_vars for the current request.
|
496 |
+
*
|
497 |
+
* @since BuddyPress (1.7.0)
|
498 |
+
*
|
499 |
+
* @param array $query_vars Array of query variables.
|
500 |
+
*/
|
501 |
Â
return apply_filters( 'bp_request', $query_vars );
|
502 |
Â
}
|
503 |
Â
|
508 |
Â
*
|
509 |
Â
* @param string $redirect_to See 'login_redirect'.
|
510 |
Â
* @param string $redirect_to_raw See 'login_redirect'.
|
511 |
+
* @param bool $user See 'login_redirect'.
|
512 |
+
*
|
513 |
+
* @return string
|
514 |
Â
*/
|
515 |
Â
function bp_login_redirect( $redirect_to = '', $redirect_to_raw = '', $user = false ) {
|
516 |
+
|
517 |
+
/**
|
518 |
+
* Filters the URL to redirect to after login.
|
519 |
+
*
|
520 |
+
* @since BuddyPress (1.7.0)
|
521 |
+
*
|
522 |
+
* @param string $redirect_to The redirect destination URL.
|
523 |
+
* @param string $redirect_to_raw The requested redirect destination URL passed as a parameter.
|
524 |
+
* @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise.
|
525 |
+
*/
|
526 |
Â
return apply_filters( 'bp_login_redirect', $redirect_to, $redirect_to_raw, $user );
|
527 |
Â
}
|
528 |
Â
|
539 |
Â
* @return string Template file to use.
|
540 |
Â
*/
|
541 |
Â
function bp_template_include( $template = '' ) {
|
542 |
+
|
543 |
+
/**
|
544 |
+
* Filters the template to use with template_include.
|
545 |
+
*
|
546 |
+
* @since BuddyPress (1.6.0)
|
547 |
+
*
|
548 |
+
* @param string $template The path of the template to include.
|
549 |
+
*/
|
550 |
Â
return apply_filters( 'bp_template_include', $template );
|
551 |
Â
}
|
552 |
Â
|
553 |
Â
/**
|
554 |
+
* Fire the 'bp_generate_rewrite_rules' action, where BP generates its rewrite rules.
|
555 |
Â
*
|
556 |
Â
* @since BuddyPress (1.7.0)
|
557 |
Â
*
|
560 |
Â
* @param WP_Rewrite $wp_rewrite See 'generate_rewrite_rules'.
|
561 |
Â
*/
|
562 |
Â
function bp_generate_rewrite_rules( $wp_rewrite ) {
|
563 |
+
|
564 |
+
/**
|
565 |
+
* Fires inside the 'bp_generate_rewrite_rules' function.
|
566 |
+
*
|
567 |
+
* @since BuddyPress (1.7.0)
|
568 |
+
*
|
569 |
+
* @param WP_Rewrite $wp_rewrite WP_Rewrite object. Passed by reference.
|
570 |
+
*/
|
571 |
Â
do_action_ref_array( 'bp_generate_rewrite_rules', array( &$wp_rewrite ) );
|
572 |
Â
}
|
573 |
Â
|
581 |
Â
* @uses apply_filters() Calls 'bp_allowed_themes' with the allowed themes list.
|
582 |
Â
*/
|
583 |
Â
function bp_allowed_themes( $themes ) {
|
584 |
+
|
585 |
+
/**
|
586 |
+
* Filters the allowed themes list for BuddyPress-specific themes.
|
587 |
+
*
|
588 |
+
* @since BuddyPress (1.7.0)
|
589 |
+
*
|
590 |
+
* @param string $template The path of the template to include.
|
591 |
+
*/
|
592 |
Â
return apply_filters( 'bp_allowed_themes', $themes );
|
593 |
Â
}
|
594 |
Â
|
615 |
Â
// Sanitize the POST action
|
616 |
Â
$action = sanitize_key( $_POST['action'] );
|
617 |
Â
|
618 |
+
/**
|
619 |
+
* Fires at the end of the bp_post_request function.
|
620 |
+
*
|
621 |
+
* This dynamic action is probably the one you want to use. It narrows down
|
622 |
+
* the scope of the 'action' without needing to check it in your function.
|
623 |
+
*
|
624 |
+
* @since BuddyPress (1.9.0)
|
625 |
+
*/
|
626 |
Â
do_action( 'bp_post_request_' . $action );
|
627 |
Â
|
628 |
+
/**
|
629 |
+
* Fires at the end of the bp_post_request function.
|
630 |
+
*
|
631 |
+
* Use this static action if you don't mind checking the 'action' yourself.
|
632 |
+
*
|
633 |
+
* @since BuddyPress (1.9.0)
|
634 |
+
*
|
635 |
+
* @param string $action The action being run.
|
636 |
+
*/
|
637 |
Â
do_action( 'bp_post_request', $action );
|
638 |
Â
}
|
639 |
Â
|
658 |
Â
// Sanitize the GET action
|
659 |
Â
$action = sanitize_key( $_GET['action'] );
|
660 |
Â
|
661 |
+
/**
|
662 |
+
* Fires at the end of the bp_get_request function.
|
663 |
+
*
|
664 |
+
* This dynamic action is probably the one you want to use. It narrows down
|
665 |
+
* the scope of the 'action' without needing to check it in your function.
|
666 |
+
*
|
667 |
+
* @since BuddyPress (1.9.0)
|
668 |
+
*/
|
669 |
Â
do_action( 'bp_get_request_' . $action );
|
670 |
Â
|
671 |
+
/**
|
672 |
+
* Fires at the end of the bp_get_request function.
|
673 |
+
*
|
674 |
+
* Use this static action if you don't mind checking the 'action' yourself.
|
675 |
+
*
|
676 |
+
* @since BuddyPress (1.9.0)
|
677 |
+
*
|
678 |
+
* @param string $action The action being run.
|
679 |
+
*/
|
680 |
Â
do_action( 'bp_get_request', $action );
|
681 |
Â
}
|
bp-core/bp-core-filters.php
CHANGED
@@ -94,6 +94,13 @@ function bp_core_exclude_pages( $pages = array() ) {
|
|
94 |
Â
if ( !empty( $bp->pages->forums ) && ( !bp_is_active( 'forums' ) || ( bp_is_active( 'forums' ) && bp_forums_has_directory() && !bp_forums_is_installed_correctly() ) ) )
|
95 |
Â
$pages[] = $bp->pages->forums->id;
|
96 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
97 |
Â
return apply_filters( 'bp_core_exclude_pages', $pages );
|
98 |
Â
}
|
99 |
Â
add_filter( 'wp_list_pages_excludes', 'bp_core_exclude_pages' );
|
@@ -234,6 +241,14 @@ add_filter( 'nav_menu_css_class', 'bp_core_menu_highlight_nav_menu_item', 10, 2
|
|
234 |
Â
* @return string The blog name for the root blog.
|
235 |
Â
*/
|
236 |
Â
function bp_core_email_from_name_filter() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
237 |
Â
return apply_filters( 'bp_core_email_from_name_filter', bp_get_option( 'blogname', 'WordPress' ) );
|
238 |
Â
}
|
239 |
Â
add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
|
@@ -300,7 +315,19 @@ function bp_core_login_redirect( $redirect_to, $redirect_to_raw, $user ) {
|
|
300 |
Â
return $redirect_to;
|
301 |
Â
}
|
302 |
Â
|
303 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
304 |
Â
$maybe_redirect = apply_filters( 'bp_core_login_redirect', false, $redirect_to, $redirect_to_raw, $user );
|
305 |
Â
if ( false !== $maybe_redirect ) {
|
306 |
Â
return $maybe_redirect;
|
@@ -317,6 +344,13 @@ function bp_core_login_redirect( $redirect_to, $redirect_to_raw, $user ) {
|
|
317 |
Â
return wp_get_referer();
|
318 |
Â
}
|
319 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
320 |
Â
return apply_filters( 'bp_core_login_redirect_to', bp_get_root_domain() );
|
321 |
Â
}
|
322 |
Â
add_filter( 'bp_login_redirect', 'bp_core_login_redirect', 10, 3 );
|
@@ -414,9 +448,52 @@ function bp_core_activation_signup_blog_notification( $domain, $path, $title, $u
|
|
414 |
Â
$message = sprintf( __( "%1\$s,\n\n\n\nThanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%2\$s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%3\$s", 'buddypress' ), $user, $activate_url, esc_url( "http://{$domain}{$path}" ) );
|
415 |
Â
$subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Activate %s', 'buddypress' ), 'http://' . $domain . $path ) ) );
|
416 |
Â
|
417 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
418 |
Â
$to = apply_filters( 'bp_core_activation_signup_blog_notification_to', $user_email, $domain, $path, $title, $user, $user_email, $key, $meta );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
419 |
Â
$subject = apply_filters( 'bp_core_activation_signup_blog_notification_subject', $subject, $domain, $path, $title, $user, $user_email, $key, $meta );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
420 |
Â
$message = apply_filters( 'bp_core_activation_signup_blog_notification_message', $message, $domain, $path, $title, $user, $user_email, $key, $meta );
|
421 |
Â
|
422 |
Â
// Send the email
|
@@ -425,6 +502,22 @@ function bp_core_activation_signup_blog_notification( $domain, $path, $title, $u
|
|
425 |
Â
// Set up the $admin_email to pass to the filter
|
426 |
Â
$admin_email = bp_get_option( 'admin_email' );
|
427 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
428 |
Â
do_action( 'bp_core_sent_blog_signup_email', $admin_email, $subject, $message, $domain, $path, $title, $user, $user_email, $key, $meta );
|
429 |
Â
|
430 |
Â
// Return false to stop the original WPMU function from continuing
|
@@ -479,9 +572,43 @@ function bp_core_activation_signup_user_notification( $user, $user_email, $key,
|
|
479 |
Â
$message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%1\$s\n\n", 'buddypress' ), $activate_url );
|
480 |
Â
$subject = bp_get_email_subject( array( 'text' => __( 'Activate Your Account', 'buddypress' ) ) );
|
481 |
Â
|
482 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
483 |
Â
$to = apply_filters( 'bp_core_activation_signup_user_notification_to', $user_email, $user, $user_email, $key, $meta );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
484 |
Â
$subject = apply_filters( 'bp_core_activation_signup_user_notification_subject', $subject, $user, $user_email, $key, $meta );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
485 |
Â
$message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message, $user, $user_email, $key, $meta );
|
486 |
Â
|
487 |
Â
// Send the email
|
@@ -490,6 +617,19 @@ function bp_core_activation_signup_user_notification( $user, $user_email, $key,
|
|
490 |
Â
// Set up the $admin_email to pass to the filter
|
491 |
Â
$admin_email = bp_get_option( 'admin_email' );
|
492 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
493 |
Â
do_action( 'bp_core_sent_user_signup_email', $admin_email, $subject, $message, $user, $user_email, $key, $meta );
|
494 |
Â
|
495 |
Â
// Return false to stop the original WPMU function from continuing
|
@@ -661,9 +801,13 @@ function bp_modify_page_title( $title = '', $sep = '»', $seplocation = 'ri
|
|
661 |
Â
}
|
662 |
Â
|
663 |
Â
/**
|
664 |
-
*
|
665 |
-
*
|
666 |
-
* @
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
667 |
Â
* @param string $seplocation Location of the separator (left or right).
|
668 |
Â
*/
|
669 |
Â
return apply_filters( 'bp_modify_page_title', $new_title, $title, $sep, $seplocation );
|
@@ -704,9 +848,16 @@ function bp_setup_nav_menu_item( $menu_item ) {
|
|
704 |
Â
return $menu_item;
|
705 |
Â
}
|
706 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
707 |
Â
// We use information stored in the CSS class to determine what kind of
|
708 |
Â
// menu item this is, and how it should be treated
|
709 |
-
preg_match( '/\sbp-(.*)-nav/',
|
710 |
Â
|
711 |
Â
// If this isn't a BP menu item, we can stop here
|
712 |
Â
if ( empty( $matches[1] ) ) {
|
@@ -760,7 +911,12 @@ function bp_setup_nav_menu_item( $menu_item ) {
|
|
760 |
Â
} else {
|
761 |
Â
$current = bp_get_requested_url();
|
762 |
Â
if ( strpos( $current, $menu_item->url ) !== false ) {
|
763 |
-
$menu_item->classes
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
764 |
Â
}
|
765 |
Â
}
|
766 |
Â
|
@@ -768,6 +924,68 @@ function bp_setup_nav_menu_item( $menu_item ) {
|
|
768 |
Â
}
|
769 |
Â
add_filter( 'wp_setup_nav_menu_item', 'bp_setup_nav_menu_item', 10, 1 );
|
770 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
771 |
Â
/**
|
772 |
Â
* Filter SQL query strings to swap out the 'meta_id' column.
|
773 |
Â
*
|
94 |
Â
if ( !empty( $bp->pages->forums ) && ( !bp_is_active( 'forums' ) || ( bp_is_active( 'forums' ) && bp_forums_has_directory() && !bp_forums_is_installed_correctly() ) ) )
|
95 |
Â
$pages[] = $bp->pages->forums->id;
|
96 |
Â
|
97 |
+
/**
|
98 |
+
* Filters specific pages that shouldn't show up on page listings.
|
99 |
+
*
|
100 |
+
* @since BuddyPress (1.5.0)
|
101 |
+
*
|
102 |
+
* @param array $pages Array of pages to exclude.
|
103 |
+
*/
|
104 |
Â
return apply_filters( 'bp_core_exclude_pages', $pages );
|
105 |
Â
}
|
106 |
Â
add_filter( 'wp_list_pages_excludes', 'bp_core_exclude_pages' );
|
241 |
Â
* @return string The blog name for the root blog.
|
242 |
Â
*/
|
243 |
Â
function bp_core_email_from_name_filter() {
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Filters the "From" name in outgoing email to the site name.
|
247 |
+
*
|
248 |
+
* @since BuddyPress (1.2.0)
|
249 |
+
*
|
250 |
+
* @param string $value Value to set the "From" name to.
|
251 |
+
*/
|
252 |
Â
return apply_filters( 'bp_core_email_from_name_filter', bp_get_option( 'blogname', 'WordPress' ) );
|
253 |
Â
}
|
254 |
Â
add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
|
315 |
Â
return $redirect_to;
|
316 |
Â
}
|
317 |
Â
|
318 |
+
/**
|
319 |
+
* Filters whether or not to redirect.
|
320 |
+
*
|
321 |
+
* Allows plugins to have finer grained control of redirect upon login.
|
322 |
+
*
|
323 |
+
* @since BuddyPress (1.6.0)
|
324 |
+
*
|
325 |
+
* @param bool $value Whether or not to redirect.
|
326 |
+
* @param string $redirect_to Sanitized URL to be redirected to.
|
327 |
+
* @param string $redirect_to_raw Unsanitized URL to be redirected to.
|
328 |
+
* @param WP_User $user The WP_User object corresponding to a
|
329 |
+
* successfully logged in user.
|
330 |
+
*/
|
331 |
Â
$maybe_redirect = apply_filters( 'bp_core_login_redirect', false, $redirect_to, $redirect_to_raw, $user );
|
332 |
Â
if ( false !== $maybe_redirect ) {
|
333 |
Â
return $maybe_redirect;
|
344 |
Â
return wp_get_referer();
|
345 |
Â
}
|
346 |
Â
|
347 |
+
/**
|
348 |
+
* Filters the URL to redirect users to upon successful login.
|
349 |
+
*
|
350 |
+
* @since BuddyPress (1.9.0)
|
351 |
+
*
|
352 |
+
* @param string $value URL to redirect to.
|
353 |
+
*/
|
354 |
Â
return apply_filters( 'bp_core_login_redirect_to', bp_get_root_domain() );
|
355 |
Â
}
|
356 |
Â
add_filter( 'bp_login_redirect', 'bp_core_login_redirect', 10, 3 );
|
448 |
Â
$message = sprintf( __( "%1\$s,\n\n\n\nThanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%2\$s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%3\$s", 'buddypress' ), $user, $activate_url, esc_url( "http://{$domain}{$path}" ) );
|
449 |
Â
$subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Activate %s', 'buddypress' ), 'http://' . $domain . $path ) ) );
|
450 |
Â
|
451 |
+
/**
|
452 |
+
* Filters the email that the notification is going to upon successful registration with blog.
|
453 |
+
*
|
454 |
+
* @since BuddyPress (1.2.0)
|
455 |
+
*
|
456 |
+
* @param string $user_email The user's email address.
|
457 |
+
* @param string $domain The new blog domain.
|
458 |
+
* @param string $path The new blog path.
|
459 |
+
* @param string $title The site title.
|
460 |
+
* @param string $user The user's login name.
|
461 |
+
* @param string $user_email The user's email address.
|
462 |
+
* @param string $key The activation key created in wpmu_signup_blog().
|
463 |
+
* @param array $meta Array of meta values for the created site.
|
464 |
+
*/
|
465 |
Â
$to = apply_filters( 'bp_core_activation_signup_blog_notification_to', $user_email, $domain, $path, $title, $user, $user_email, $key, $meta );
|
466 |
+
|
467 |
+
/**
|
468 |
+
* Filters the subject that the notification uses upon successful registration with blog.
|
469 |
+
*
|
470 |
+
* @since BuddyPress (1.2.0)
|
471 |
+
*
|
472 |
+
* @param string $subject The subject to use.
|
473 |
+
* @param string $domain The new blog domain.
|
474 |
+
* @param string $path The new blog path.
|
475 |
+
* @param string $title The site title.
|
476 |
+
* @param string $user The user's login name.
|
477 |
+
* @param string $user_email The user's email address.
|
478 |
+
* @param string $key The activation key created in wpmu_signup_blog().
|
479 |
+
* @param array $meta Array of meta values for the created site.
|
480 |
+
*/
|
481 |
Â
$subject = apply_filters( 'bp_core_activation_signup_blog_notification_subject', $subject, $domain, $path, $title, $user, $user_email, $key, $meta );
|
482 |
+
|
483 |
+
/**
|
484 |
+
* Filters the message that the notification uses upon successful registration with blog.
|
485 |
+
*
|
486 |
+
* @since BuddyPress (1.2.0)
|
487 |
+
*
|
488 |
+
* @param string $message The message to use.
|
489 |
+
* @param string $domain The new blog domain.
|
490 |
+
* @param string $path The new blog path.
|
491 |
+
* @param string $title The site title.
|
492 |
+
* @param string $user The user's login name.
|
493 |
+
* @param string $user_email The user's email address.
|
494 |
+
* @param string $key The activation key created in wpmu_signup_blog().
|
495 |
+
* @param array $meta Array of meta values for the created site.
|
496 |
+
*/
|
497 |
Â
$message = apply_filters( 'bp_core_activation_signup_blog_notification_message', $message, $domain, $path, $title, $user, $user_email, $key, $meta );
|
498 |
Â
|
499 |
Â
// Send the email
|
502 |
Â
// Set up the $admin_email to pass to the filter
|
503 |
Â
$admin_email = bp_get_option( 'admin_email' );
|
504 |
Â
|
505 |
+
/**
|
506 |
+
* Fires after the sending of the notification to new users for successful registration with blog.
|
507 |
+
*
|
508 |
+
* @since BuddyPress (1.5.0)
|
509 |
+
*
|
510 |
+
* @param string $admin_email Admin Email address for the site.
|
511 |
+
* @param string $subject Subject used in the notification email.
|
512 |
+
* @param string $message Message used in the notification email.
|
513 |
+
* @param string domain The new blog domain.
|
514 |
+
* @param string $path The new blog path.
|
515 |
+
* @param string $title The site title.
|
516 |
+
* @param string $user The user's login name.
|
517 |
+
* @param string $user_email The user's email address.
|
518 |
+
* @param string $key The activation key created in wpmu_signup_blog().
|
519 |
+
* @param array $meta Array of meta values for the created site.
|
520 |
+
*/
|
521 |
Â
do_action( 'bp_core_sent_blog_signup_email', $admin_email, $subject, $message, $domain, $path, $title, $user, $user_email, $key, $meta );
|
522 |
Â
|
523 |
Â
// Return false to stop the original WPMU function from continuing
|
572 |
Â
$message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%1\$s\n\n", 'buddypress' ), $activate_url );
|
573 |
Â
$subject = bp_get_email_subject( array( 'text' => __( 'Activate Your Account', 'buddypress' ) ) );
|
574 |
Â
|
575 |
+
/**
|
576 |
+
* Filters the email that the notification is going to upon successful registration without blog.
|
577 |
+
*
|
578 |
+
* @since BuddyPress (1.2.0)
|
579 |
+
*
|
580 |
+
* @param string $user_email The user's email address.
|
581 |
+
* @param string $user The user's login name.
|
582 |
+
* @param string $user_email The user's email address.
|
583 |
+
* @param string $key The activation key created in wpmu_signup_blog().
|
584 |
+
* @param array $meta Array of meta values for the created site.
|
585 |
+
*/
|
586 |
Â
$to = apply_filters( 'bp_core_activation_signup_user_notification_to', $user_email, $user, $user_email, $key, $meta );
|
587 |
+
|
588 |
+
/**
|
589 |
+
* Filters the subject that the notification uses upon successful registration without blog.
|
590 |
+
*
|
591 |
+
* @since BuddyPress (1.2.0)
|
592 |
+
*
|
593 |
+
* @param string $subject The subject to use.
|
594 |
+
* @param string $user The user's login name.
|
595 |
+
* @param string $user_email The user's email address.
|
596 |
+
* @param string $key The activation key created in wpmu_signup_blog().
|
597 |
+
* @param array $meta Array of meta values for the created site.
|
598 |
+
*/
|
599 |
Â
$subject = apply_filters( 'bp_core_activation_signup_user_notification_subject', $subject, $user, $user_email, $key, $meta );
|
600 |
+
|
601 |
+
/**
|
602 |
+
* Filters the message that the notification uses upon successful registration without blog.
|
603 |
+
*
|
604 |
+
* @since BuddyPress (1.2.0)
|
605 |
+
*
|
606 |
+
* @param string $message The message to use.
|
607 |
+
* @param string $user The user's login name.
|
608 |
+
* @param string $user_email The user's email address.
|
609 |
+
* @param string $key The activation key created in wpmu_signup_blog().
|
610 |
+
* @param array $meta Array of meta values for the created site.
|
611 |
+
*/
|
612 |
Â
$message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message, $user, $user_email, $key, $meta );
|
613 |
Â
|
614 |
Â
// Send the email
|
617 |
Â
// Set up the $admin_email to pass to the filter
|
618 |
Â
$admin_email = bp_get_option( 'admin_email' );
|
619 |
Â
|
620 |
+
/**
|
621 |
+
* Fires after the sending of the notification to new users for successful registration without blog.
|
622 |
+
*
|
623 |
+
* @since BuddyPress (1.5.0)
|
624 |
+
*
|
625 |
+
* @param string $admin_email Admin Email address for the site.
|
626 |
+
* @param string $subject Subject used in the notification email.
|
627 |
+
* @param string $message Message used in the notification email.
|
628 |
+
* @param string $user The user's login name.
|
629 |
+
* @param string $user_email The user's email address.
|
630 |
+
* @param string $key The activation key created in wpmu_signup_blog().
|
631 |
+
* @param array $meta Array of meta values for the created site. Default empty array.
|
632 |
+
*/
|
633 |
Â
do_action( 'bp_core_sent_user_signup_email', $admin_email, $subject, $message, $user, $user_email, $key, $meta );
|
634 |
Â
|
635 |
Â
// Return false to stop the original WPMU function from continuing
|
801 |
Â
}
|
802 |
Â
|
803 |
Â
/**
|
804 |
+
* Filters the page title for BuddyPress pages.
|
805 |
+
*
|
806 |
+
* @since BuddyPress (1.5.0)
|
807 |
+
*
|
808 |
+
* @param string $new_title The BuddyPress page title.
|
809 |
+
* @param string $title The original WordPress page title.
|
810 |
+
* @param string $sep The title parts separator.
|
811 |
Â
* @param string $seplocation Location of the separator (left or right).
|
812 |
Â
*/
|
813 |
Â
return apply_filters( 'bp_modify_page_title', $new_title, $title, $sep, $seplocation );
|
848 |
Â
return $menu_item;
|
849 |
Â
}
|
850 |
Â
|
851 |
+
// Prevent a notice error when using the customizer
|
852 |
+
$menu_classes = $menu_item->classes;
|
853 |
+
|
854 |
+
if ( is_array( $menu_classes ) ) {
|
855 |
+
$menu_classes = implode( ' ', $menu_item->classes);
|
856 |
+
}
|
857 |
+
|
858 |
Â
// We use information stored in the CSS class to determine what kind of
|
859 |
Â
// menu item this is, and how it should be treated
|
860 |
+
preg_match( '/\sbp-(.*)-nav/', $menu_classes, $matches );
|
861 |
Â
|
862 |
Â
// If this isn't a BP menu item, we can stop here
|
863 |
Â
if ( empty( $matches[1] ) ) {
|
911 |
Â
} else {
|
912 |
Â
$current = bp_get_requested_url();
|
913 |
Â
if ( strpos( $current, $menu_item->url ) !== false ) {
|
914 |
+
if ( is_array( $menu_item->classes ) ) {
|
915 |
+
$menu_item->classes[] = 'current_page_item';
|
916 |
+
$menu_item->classes[] = 'current-menu-item';
|
917 |
+
} else {
|
918 |
+
$menu_item->classes = array( 'current_page_item', 'current-menu-item' );
|
919 |
+
}
|
920 |
Â
}
|
921 |
Â
}
|
922 |
Â
|
924 |
Â
}
|
925 |
Â
add_filter( 'wp_setup_nav_menu_item', 'bp_setup_nav_menu_item', 10, 1 );
|
926 |
Â
|
927 |
+
/**
|
928 |
+
* Populate BuddyPress user nav items for the customizer
|
929 |
+
*
|
930 |
+
* @since BuddyPress (2.3.3)
|
931 |
+
*
|
932 |
+
* @param array $items The array of menu items
|
933 |
+
* @param string $type The requested type
|
934 |
+
* @param string $object The requested object name
|
935 |
+
* @param integer $page The page num being requested
|
936 |
+
* @return array The paginated BuddyPress user nav items.
|
937 |
+
*/
|
938 |
+
function bp_customizer_nav_menus_get_items( $items = array(), $type = '', $object = '', $page = 0 ) {
|
939 |
+
if ( 'bp_loggedin_nav' === $object ) {
|
940 |
+
$bp_items = bp_nav_menu_get_loggedin_pages();
|
941 |
+
} elseif ( 'bp_loggedout_nav' === $object ) {
|
942 |
+
$bp_items = bp_nav_menu_get_loggedout_pages();
|
943 |
+
} else {
|
944 |
+
return $items;
|
945 |
+
}
|
946 |
+
|
947 |
+
foreach ( $bp_items as $bp_item ) {
|
948 |
+
$items[] = array(
|
949 |
+
'id' => "bp-{$bp_item->post_excerpt}",
|
950 |
+
'title' => html_entity_decode( $bp_item->post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ),
|
951 |
+
'type' => $type,
|
952 |
+
'url' => esc_url_raw( $bp_item->guid ),
|
953 |
+
'classes' => "bp-menu bp-{$bp_item->post_excerpt}-nav",
|
954 |
+
'type_label' => _x( 'Custom Link', 'customizer menu type label', 'buddypress' ),
|
955 |
+
'object' => $object,
|
956 |
+
'object_id' => -1,
|
957 |
+
);
|
958 |
+
}
|
959 |
+
|
960 |
+
return array_slice( $items, 10 * $page, 10 );
|
961 |
+
}
|
962 |
+
add_filter( 'customize_nav_menu_available_items', 'bp_customizer_nav_menus_get_items', 10, 4 );
|
963 |
+
|
964 |
+
/**
|
965 |
+
* Set BuddyPress item navs for the customizer
|
966 |
+
*
|
967 |
+
* @since BuddyPress (2.3.3)
|
968 |
+
*
|
969 |
+
* @param array $item_types an associative array structured for the customizer
|
970 |
+
*/
|
971 |
+
function bp_customizer_nav_menus_set_item_types( $item_types = array() ) {
|
972 |
+
$item_types = array_merge( $item_types, array(
|
973 |
+
'bp_loggedin_nav' => array(
|
974 |
+
'title' => _x( 'BuddyPress (logged-in)', 'customizer menu section title', 'buddypress' ),
|
975 |
+
'type' => 'bp_nav',
|
976 |
+
'object' => 'bp_loggedin_nav',
|
977 |
+
),
|
978 |
+
'bp_loggedout_nav' => array(
|
979 |
+
'title' => _x( 'BuddyPress (logged-out)', 'customizer menu section title', 'buddypress' ),
|
980 |
+
'type' => 'bp_nav',
|
981 |
+
'object' => 'bp_loggedout_nav',
|
982 |
+
),
|
983 |
+
) );
|
984 |
+
|
985 |
+
return $item_types;
|
986 |
+
}
|
987 |
+
add_filter( 'customize_nav_menu_available_item_types', 'bp_customizer_nav_menus_set_item_types', 10, 1 );
|
988 |
+
|
989 |
Â
/**
|
990 |
Â
* Filter SQL query strings to swap out the 'meta_id' column.
|
991 |
Â
*
|
bp-core/bp-core-functions.php
CHANGED
@@ -71,7 +71,7 @@ function bp_db_version_raw() {
|
|
71 |
Â
* @return string The BuddyPress version direct from the database.
|
72 |
Â
*/
|
73 |
Â
function bp_get_db_version_raw() {
|
74 |
-
$bp
|
75 |
Â
return !empty( $bp->db_version_raw ) ? $bp->db_version_raw : 0;
|
76 |
Â
}
|
77 |
Â
|
@@ -89,6 +89,15 @@ function bp_db_version_raw() {
|
|
89 |
Â
function bp_core_get_table_prefix() {
|
90 |
Â
global $wpdb;
|
91 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
92 |
Â
return apply_filters( 'bp_core_get_table_prefix', $wpdb->base_prefix );
|
93 |
Â
}
|
94 |
Â
|
@@ -171,6 +180,15 @@ function bp_core_number_format( $number = 0, $decimals = false ) {
|
|
171 |
Â
$number = 0;
|
172 |
Â
}
|
173 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
174 |
Â
return apply_filters( 'bp_core_number_format', number_format_i18n( $number, $decimals ), $number, $decimals );
|
175 |
Â
}
|
176 |
Â
|
@@ -250,6 +268,16 @@ function bp_parse_args( $args, $defaults = array(), $filter_key = '' ) {
|
|
250 |
Â
|
251 |
Â
// Passively filter the args before the parse
|
252 |
Â
if ( !empty( $filter_key ) ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
253 |
Â
$r = apply_filters( 'bp_before_' . $filter_key . '_parse_args', $r );
|
254 |
Â
}
|
255 |
Â
|
@@ -260,6 +288,16 @@ function bp_parse_args( $args, $defaults = array(), $filter_key = '' ) {
|
|
260 |
Â
|
261 |
Â
// Aggressively filter the args after the parse
|
262 |
Â
if ( !empty( $filter_key ) ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
263 |
Â
$r = apply_filters( 'bp_after_' . $filter_key . '_parse_args', $r );
|
264 |
Â
}
|
265 |
Â
|
@@ -350,6 +388,14 @@ function bp_esc_like( $text ) {
|
|
350 |
Â
* Default: false.
|
351 |
Â
*/
|
352 |
Â
function bp_is_username_compatibility_mode() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
353 |
Â
return apply_filters( 'bp_is_username_compatibility_mode', defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) && BP_ENABLE_USERNAME_COMPATIBILITY_MODE );
|
354 |
Â
}
|
355 |
Â
|
@@ -379,6 +425,13 @@ function bp_use_wp_admin_bar() {
|
|
379 |
Â
$use_admin_bar = false;
|
380 |
Â
}
|
381 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
382 |
Â
return (bool) apply_filters( 'bp_use_wp_admin_bar', $use_admin_bar );
|
383 |
Â
}
|
384 |
Â
|
@@ -452,6 +505,13 @@ function bp_core_get_directory_page_ids( $status = 'active' ) {
|
|
452 |
Â
}
|
453 |
Â
}
|
454 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
455 |
Â
return apply_filters( 'bp_core_get_directory_page_ids', $page_ids );
|
456 |
Â
}
|
457 |
Â
|
@@ -529,6 +589,13 @@ function bp_core_get_directory_pages() {
|
|
529 |
Â
wp_cache_set( 'directory_pages', $pages, 'bp' );
|
530 |
Â
}
|
531 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
532 |
Â
return apply_filters( 'bp_core_get_directory_pages', $pages );
|
533 |
Â
}
|
534 |
Â
|
@@ -687,6 +754,14 @@ function bp_core_component_slug_from_root_slug( $root_slug ) {
|
|
687 |
Â
$slug_chunks = explode( '/', $root_slug );
|
688 |
Â
$slug = array_pop( $slug_chunks );
|
689 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
690 |
Â
return apply_filters( 'bp_core_component_slug_from_root_slug', $slug, $root_slug );
|
691 |
Â
}
|
692 |
Â
|
@@ -797,6 +872,13 @@ function bp_do_register_theme_directory() {
|
|
797 |
Â
$register = true;
|
798 |
Â
}
|
799 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
800 |
Â
return apply_filters( 'bp_do_register_theme_directory', $register );
|
801 |
Â
}
|
802 |
Â
|
@@ -815,6 +897,13 @@ function bp_core_get_root_domain() {
|
|
815 |
Â
|
816 |
Â
$domain = get_home_url( bp_get_root_blog_id() );
|
817 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
818 |
Â
return apply_filters( 'bp_core_get_root_domain', $domain );
|
819 |
Â
}
|
820 |
Â
|
@@ -845,18 +934,31 @@ function bp_core_redirect( $location = '', $status = 302 ) {
|
|
845 |
Â
}
|
846 |
Â
|
847 |
Â
/**
|
848 |
-
* Return the
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
849 |
Â
*
|
850 |
-
* @
|
Â
|
|
Â
|
|
851 |
Â
*/
|
852 |
-
function
|
853 |
-
$referer =
|
854 |
-
|
855 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
856 |
Â
}
|
857 |
Â
|
858 |
Â
/**
|
859 |
-
* Get the path of
|
860 |
Â
*
|
861 |
Â
* @global object $current_site
|
862 |
Â
*
|
@@ -886,6 +988,13 @@ function bp_core_get_site_path() {
|
|
886 |
Â
}
|
887 |
Â
}
|
888 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
889 |
Â
return apply_filters( 'bp_core_get_site_path', $site_path );
|
890 |
Â
}
|
891 |
Â
|
@@ -902,6 +1011,14 @@ function bp_core_get_site_path() {
|
|
902 |
Â
* @return string Current time in 'Y-m-d h:i:s' format.
|
903 |
Â
*/
|
904 |
Â
function bp_core_current_time( $gmt = true, $type = 'mysql' ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
905 |
Â
return apply_filters( 'bp_core_current_time', current_time( $type, $gmt ) );
|
906 |
Â
}
|
907 |
Â
|
@@ -933,15 +1050,45 @@ function bp_core_current_time( $gmt = true, $type = 'mysql' ) {
|
|
933 |
Â
*/
|
934 |
Â
function bp_core_time_since( $older_date, $newer_date = false ) {
|
935 |
Â
|
936 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
937 |
Â
$pre_value = apply_filters( 'bp_core_time_since_pre', false, $older_date, $newer_date );
|
938 |
Â
if ( false !== $pre_value ) {
|
939 |
Â
return $pre_value;
|
940 |
Â
}
|
941 |
Â
|
942 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
943 |
Â
$unknown_text = apply_filters( 'bp_core_time_since_unknown_text', __( 'sometime', 'buddypress' ) );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
944 |
Â
$right_now_text = apply_filters( 'bp_core_time_since_right_now_text', __( 'right now', 'buddypress' ) );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
945 |
Â
$ago_text = apply_filters( 'bp_core_time_since_ago_text', __( '%s ago', 'buddypress' ) );
|
946 |
Â
|
947 |
Â
// array of time period chunks
|
@@ -1072,6 +1219,15 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
|
|
1072 |
Â
$output = sprintf( $ago_text, $output );
|
1073 |
Â
}
|
1074 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1075 |
Â
return apply_filters( 'bp_core_time_since', $output, $older_date, $newer_date );
|
1076 |
Â
}
|
1077 |
Â
|
@@ -1156,6 +1312,16 @@ function bp_core_render_message() {
|
|
1156 |
Â
|
1157 |
Â
if ( !empty( $bp->template_message ) ) :
|
1158 |
Â
$type = ( 'success' === $bp->template_message_type ) ? 'updated' : 'error';
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1159 |
Â
$content = apply_filters( 'bp_core_render_message_content', $bp->template_message, $type ); ?>
|
1160 |
Â
|
1161 |
Â
<div id="message" class="bp-template-notice <?php echo esc_attr( $type ); ?>">
|
@@ -1166,6 +1332,11 @@ function bp_core_render_message() {
|
|
1166 |
Â
|
1167 |
Â
<?php
|
1168 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1169 |
Â
do_action( 'bp_core_render_message' );
|
1170 |
Â
|
1171 |
Â
endif;
|
@@ -1214,6 +1385,16 @@ function bp_core_record_activity() {
|
|
1214 |
Â
|
1215 |
Â
// Use this action to detect the very first activity for a given member
|
1216 |
Â
if ( empty( $activity ) ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1217 |
Â
do_action( 'bp_first_activity_for_member', $user_id );
|
1218 |
Â
}
|
1219 |
Â
|
@@ -1246,7 +1427,15 @@ function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {
|
|
1246 |
Â
? __( 'Not recently active', 'buddypress' )
|
1247 |
Â
: sprintf( $string, bp_core_time_since( $last_activity_date ) );
|
1248 |
Â
|
1249 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1250 |
Â
return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
|
1251 |
Â
}
|
1252 |
Â
|
@@ -1276,6 +1465,14 @@ function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {
|
|
1276 |
Â
* @return string $key The usermeta meta_key.
|
1277 |
Â
*/
|
1278 |
Â
function bp_get_user_meta_key( $key = false ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1279 |
Â
return apply_filters( 'bp_get_user_meta_key', $key );
|
1280 |
Â
}
|
1281 |
Â
|
@@ -1371,6 +1568,14 @@ add_action( 'bp_init', 'bp_embed_init', 9 );
|
|
1371 |
Â
* enabled. Default: true.
|
1372 |
Â
*/
|
1373 |
Â
function bp_use_embed_in_activity() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1374 |
Â
return apply_filters( 'bp_use_oembed_in_activity', !defined( 'BP_EMBED_DISABLE_ACTIVITY' ) || !BP_EMBED_DISABLE_ACTIVITY );
|
1375 |
Â
}
|
1376 |
Â
|
@@ -1383,6 +1588,14 @@ function bp_use_embed_in_activity() {
|
|
1383 |
Â
* when enabled. Default: true.
|
1384 |
Â
*/
|
1385 |
Â
function bp_use_embed_in_activity_replies() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1386 |
Â
return apply_filters( 'bp_use_embed_in_activity_replies', !defined( 'BP_EMBED_DISABLE_ACTIVITY_REPLIES' ) || !BP_EMBED_DISABLE_ACTIVITY_REPLIES );
|
1387 |
Â
}
|
1388 |
Â
|
@@ -1395,6 +1608,14 @@ function bp_use_embed_in_activity_replies() {
|
|
1395 |
Â
* enabled. Default: true.
|
1396 |
Â
*/
|
1397 |
Â
function bp_use_embed_in_forum_posts() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1398 |
Â
return apply_filters( 'bp_use_embed_in_forum_posts', !defined( 'BP_EMBED_DISABLE_FORUM_POSTS' ) || !BP_EMBED_DISABLE_FORUM_POSTS );
|
1399 |
Â
}
|
1400 |
Â
|
@@ -1407,6 +1628,14 @@ function bp_use_embed_in_forum_posts() {
|
|
1407 |
Â
* enabled. Default: true.
|
1408 |
Â
*/
|
1409 |
Â
function bp_use_embed_in_private_messages() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1410 |
Â
return apply_filters( 'bp_use_embed_in_private_messages', !defined( 'BP_EMBED_DISABLE_PRIVATE_MESSAGES' ) || !BP_EMBED_DISABLE_PRIVATE_MESSAGES );
|
1411 |
Â
}
|
1412 |
Â
|
@@ -1479,6 +1708,13 @@ function bp_core_do_network_admin() {
|
|
1479 |
Â
$retval = false;
|
1480 |
Â
}
|
1481 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1482 |
Â
return (bool) apply_filters( 'bp_core_do_network_admin', $retval );
|
1483 |
Â
}
|
1484 |
Â
|
@@ -1497,6 +1733,13 @@ function bp_core_do_network_admin() {
|
|
1497 |
Â
function bp_core_admin_hook() {
|
1498 |
Â
$hook = bp_core_do_network_admin() ? 'network_admin_menu' : 'admin_menu';
|
1499 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1500 |
Â
return apply_filters( 'bp_core_admin_hook', $hook );
|
1501 |
Â
}
|
1502 |
Â
|
@@ -1525,6 +1768,13 @@ function bp_is_root_blog( $blog_id = 0 ) {
|
|
1525 |
Â
$is_root_blog = true;
|
1526 |
Â
}
|
1527 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1528 |
Â
return (bool) apply_filters( 'bp_is_root_blog', (bool) $is_root_blog );
|
1529 |
Â
}
|
1530 |
Â
|
@@ -1540,6 +1790,14 @@ function bp_is_root_blog( $blog_id = 0 ) {
|
|
1540 |
Â
* @return int The root site ID.
|
1541 |
Â
*/
|
1542 |
Â
function bp_get_root_blog_id() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1543 |
Â
return (int) apply_filters( 'bp_get_root_blog_id', (int) buddypress()->root_blog_id );
|
1544 |
Â
}
|
1545 |
Â
|
@@ -1590,6 +1848,13 @@ function bp_is_multiblog_mode() {
|
|
1590 |
Â
$retval = true;
|
1591 |
Â
}
|
1592 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1593 |
Â
return apply_filters( 'bp_is_multiblog_mode', $retval );
|
1594 |
Â
}
|
1595 |
Â
|
@@ -1619,6 +1884,13 @@ function bp_is_network_activated() {
|
|
1619 |
Â
$retval = false;
|
1620 |
Â
}
|
1621 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1622 |
Â
return (bool) apply_filters( 'bp_is_network_activated', $retval );
|
1623 |
Â
}
|
1624 |
Â
|
@@ -1637,6 +1909,14 @@ function bp_update_is_directory( $is_directory = false, $component = '' ) {
|
|
1637 |
Â
$component = bp_current_component();
|
1638 |
Â
}
|
1639 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1640 |
Â
buddypress()->is_directory = apply_filters( 'bp_update_is_directory', $is_directory, $component );
|
1641 |
Â
}
|
1642 |
Â
|
@@ -1653,6 +1933,14 @@ function bp_update_is_item_admin( $is_item_admin = false, $component = '' ) {
|
|
1653 |
Â
$component = bp_current_component();
|
1654 |
Â
}
|
1655 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1656 |
Â
buddypress()->is_item_admin = apply_filters( 'bp_update_is_item_admin', $is_item_admin, $component );
|
1657 |
Â
}
|
1658 |
Â
|
@@ -1669,6 +1957,14 @@ function bp_update_is_item_mod( $is_item_mod = false, $component = '' ) {
|
|
1669 |
Â
$component = bp_current_component();
|
1670 |
Â
}
|
1671 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1672 |
Â
buddypress()->is_item_mod = apply_filters( 'bp_update_is_item_mod', $is_item_mod, $component );
|
1673 |
Â
}
|
1674 |
Â
|
@@ -1685,6 +1981,14 @@ function bp_update_is_item_mod( $is_item_mod = false, $component = '' ) {
|
|
1685 |
Â
function bp_do_404( $redirect = 'remove_canonical_direct' ) {
|
1686 |
Â
global $wp_query;
|
1687 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1688 |
Â
do_action( 'bp_do_404', $redirect );
|
1689 |
Â
|
1690 |
Â
$wp_query->set_404();
|
@@ -1744,7 +2048,15 @@ function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
|
|
1744 |
Â
|
1745 |
Â
/** Look for match ********************************************************/
|
1746 |
Â
|
1747 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1748 |
Â
$matched_url = apply_filters( 'bp_verify_nonce_request_url', $requested_url );
|
1749 |
Â
|
1750 |
Â
// Check the nonce
|
@@ -1755,7 +2067,14 @@ function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
|
|
1755 |
Â
$result = false;
|
1756 |
Â
}
|
1757 |
Â
|
1758 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1759 |
Â
do_action( 'bp_verify_nonce_request', $action, $result );
|
1760 |
Â
|
1761 |
Â
return $result;
|
@@ -1795,8 +2114,23 @@ function bp_is_get_request() {
|
|
1795 |
Â
*/
|
1796 |
Â
function bp_core_load_buddypress_textdomain() {
|
1797 |
Â
$domain = 'buddypress';
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1798 |
Â
$mofile_custom = sprintf( '%s-%s.mo', $domain, apply_filters( 'buddypress_locale', get_locale() ) );
|
1799 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1800 |
Â
$locations = apply_filters( 'buddypress_locale_locations', array(
|
1801 |
Â
trailingslashit( WP_LANG_DIR . '/' . $domain ),
|
1802 |
Â
trailingslashit( WP_LANG_DIR ),
|
@@ -1815,7 +2149,7 @@ function bp_core_load_buddypress_textdomain() {
|
|
1815 |
Â
add_action ( 'bp_core_loaded', 'bp_core_load_buddypress_textdomain' );
|
1816 |
Â
|
1817 |
Â
/**
|
1818 |
-
* A
|
1819 |
Â
*
|
1820 |
Â
* @param string $slug The slug to redirect to for searching.
|
1821 |
Â
*/
|
@@ -1876,6 +2210,14 @@ function bp_core_action_search_site( $slug = '' ) {
|
|
1876 |
Â
}
|
1877 |
Â
}
|
1878 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1879 |
Â
bp_core_redirect( apply_filters( 'bp_core_search_site', home_url( $slug . $query_string . urlencode( $search_terms ) ), $search_terms ) );
|
1880 |
Â
}
|
1881 |
Â
add_action( 'bp_init', 'bp_core_action_search_site', 7 );
|
@@ -2114,7 +2456,18 @@ function bp_core_get_suggestions( $args ) {
|
|
2114 |
Â
}
|
2115 |
Â
|
2116 |
Â
} else {
|
2117 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2118 |
Â
$class = apply_filters( 'bp_suggestions_services', '', $args );
|
2119 |
Â
}
|
2120 |
Â
|
@@ -2132,5 +2485,60 @@ function bp_core_get_suggestions( $args ) {
|
|
2132 |
Â
$retval = $suggestions->get_suggestions();
|
2133 |
Â
}
|
2134 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2135 |
Â
return apply_filters( 'bp_core_get_suggestions', $retval, $args );
|
2136 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
71 |
Â
* @return string The BuddyPress version direct from the database.
|
72 |
Â
*/
|
73 |
Â
function bp_get_db_version_raw() {
|
74 |
+
$bp = buddypress();
|
75 |
Â
return !empty( $bp->db_version_raw ) ? $bp->db_version_raw : 0;
|
76 |
Â
}
|
77 |
Â
|
89 |
Â
function bp_core_get_table_prefix() {
|
90 |
Â
global $wpdb;
|
91 |
Â
|
92 |
+
/**
|
93 |
+
* Filters the $wpdb base prefix.
|
94 |
+
*
|
95 |
+
* Intended primarily for use in multinetwork installations.
|
96 |
+
*
|
97 |
+
* @since BuddyPress (1.2.6)
|
98 |
+
*
|
99 |
+
* @param string $base_prefix Base prefix to use.
|
100 |
+
*/
|
101 |
Â
return apply_filters( 'bp_core_get_table_prefix', $wpdb->base_prefix );
|
102 |
Â
}
|
103 |
Â
|
180 |
Â
$number = 0;
|
181 |
Â
}
|
182 |
Â
|
183 |
+
/**
|
184 |
+
* Filters the BuddyPress formatted number.
|
185 |
+
*
|
186 |
+
* @since BuddyPress (1.2.4)
|
187 |
+
*
|
188 |
+
* @param string $value BuddyPress formatted value.
|
189 |
+
* @param int $number The number to be formatted.
|
190 |
+
* @param bool $decimals Whether or not to use decimals.
|
191 |
+
*/
|
192 |
Â
return apply_filters( 'bp_core_number_format', number_format_i18n( $number, $decimals ), $number, $decimals );
|
193 |
Â
}
|
194 |
Â
|
268 |
Â
|
269 |
Â
// Passively filter the args before the parse
|
270 |
Â
if ( !empty( $filter_key ) ) {
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Filters the arguments key before parsing if filter key provided.
|
274 |
+
*
|
275 |
+
* This is a dynamic filter dependent on the specified key.
|
276 |
+
*
|
277 |
+
* @since BuddyPress (2.0.0)
|
278 |
+
*
|
279 |
+
* @param array $r Array of arguments to use.
|
280 |
+
*/
|
281 |
Â
$r = apply_filters( 'bp_before_' . $filter_key . '_parse_args', $r );
|
282 |
Â
}
|
283 |
Â
|
288 |
Â
|
289 |
Â
// Aggressively filter the args after the parse
|
290 |
Â
if ( !empty( $filter_key ) ) {
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Filters the arguments key after parsing if filter key provided.
|
294 |
+
*
|
295 |
+
* This is a dynamic filter dependent on the specified key.
|
296 |
+
*
|
297 |
+
* @since BuddyPress (2.0.0)
|
298 |
+
*
|
299 |
+
* @param array $r Array of parsed arguments.
|
300 |
+
*/
|
301 |
Â
$r = apply_filters( 'bp_after_' . $filter_key . '_parse_args', $r );
|
302 |
Â
}
|
303 |
Â
|
388 |
Â
* Default: false.
|
389 |
Â
*/
|
390 |
Â
function bp_is_username_compatibility_mode() {
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Filters whether or not to use username compatibility mode.
|
394 |
+
*
|
395 |
+
* @since BuddyPress (1.5.0)
|
396 |
+
*
|
397 |
+
* @param bool $value Whether or not username compatibility mode should be used.
|
398 |
+
*/
|
399 |
Â
return apply_filters( 'bp_is_username_compatibility_mode', defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) && BP_ENABLE_USERNAME_COMPATIBILITY_MODE );
|
400 |
Â
}
|
401 |
Â
|
425 |
Â
$use_admin_bar = false;
|
426 |
Â
}
|
427 |
Â
|
428 |
+
/**
|
429 |
+
* Filters whether or not to use the admin bar.
|
430 |
+
*
|
431 |
+
* @since BuddyPress (1.5.0)
|
432 |
+
*
|
433 |
+
* @param bool $use_admin_bar Whether or not to use the admin bar.
|
434 |
+
*/
|
435 |
Â
return (bool) apply_filters( 'bp_use_wp_admin_bar', $use_admin_bar );
|
436 |
Â
}
|
437 |
Â
|
505 |
Â
}
|
506 |
Â
}
|
507 |
Â
|
508 |
+
/**
|
509 |
+
* Filters the list of BP directory pages from the appropriate meta table.
|
510 |
+
*
|
511 |
+
* @since BuddyPress (1.5.0)
|
512 |
+
*
|
513 |
+
* @param array $page_ids Array of directory pages.
|
514 |
+
*/
|
515 |
Â
return apply_filters( 'bp_core_get_directory_page_ids', $page_ids );
|
516 |
Â
}
|
517 |
Â
|
589 |
Â
wp_cache_set( 'directory_pages', $pages, 'bp' );
|
590 |
Â
}
|
591 |
Â
|
592 |
+
/**
|
593 |
+
* Filters the names and slugs for BuddyPress component directory pages.
|
594 |
+
*
|
595 |
+
* @since BuddyPress (1.5.0)
|
596 |
+
*
|
597 |
+
* @param object $pages Object holding page names and slugs.
|
598 |
+
*/
|
599 |
Â
return apply_filters( 'bp_core_get_directory_pages', $pages );
|
600 |
Â
}
|
601 |
Â
|
754 |
Â
$slug_chunks = explode( '/', $root_slug );
|
755 |
Â
$slug = array_pop( $slug_chunks );
|
756 |
Â
|
757 |
+
/**
|
758 |
+
* Filters the default component slug from a WP page root_slug.
|
759 |
+
*
|
760 |
+
* @since BuddyPress (1.5.0)
|
761 |
+
*
|
762 |
+
* @param string $slug Short slug for use in the middle of URLs.
|
763 |
+
* @param string $root_slug The root slug which comes from $bp->pages-[component]->slug.
|
764 |
+
*/
|
765 |
Â
return apply_filters( 'bp_core_component_slug_from_root_slug', $slug, $root_slug );
|
766 |
Â
}
|
767 |
Â
|
872 |
Â
$register = true;
|
873 |
Â
}
|
874 |
Â
|
875 |
+
/**
|
876 |
+
* Filters whether BuddyPress should register the bp-themes directory.
|
877 |
+
*
|
878 |
+
* @since BuddyPress (1.9.0)
|
879 |
+
*
|
880 |
+
* @param bool $register If bp-themes should be registered.
|
881 |
+
*/
|
882 |
Â
return apply_filters( 'bp_do_register_theme_directory', $register );
|
883 |
Â
}
|
884 |
Â
|
897 |
Â
|
898 |
Â
$domain = get_home_url( bp_get_root_blog_id() );
|
899 |
Â
|
900 |
+
/**
|
901 |
+
* Filters the domain for the root blog.
|
902 |
+
*
|
903 |
+
* @since BuddyPress (1.0.1)
|
904 |
+
*
|
905 |
+
* @param string $domain The domain URL for the blog.
|
906 |
+
*/
|
907 |
Â
return apply_filters( 'bp_core_get_root_domain', $domain );
|
908 |
Â
}
|
909 |
Â
|
934 |
Â
}
|
935 |
Â
|
936 |
Â
/**
|
937 |
+
* Return the URL path of the referring page.
|
938 |
+
*
|
939 |
+
* This is a wrapper for `wp_get_referer()` that sanitizes the referer URL to
|
940 |
+
* a webroot-relative path. For example, 'http://example.com/foo/' will be
|
941 |
+
* reduced to '/foo/'.
|
942 |
Â
*
|
943 |
+
* @since BuddyPress (2.3.0)
|
944 |
+
*
|
945 |
+
* @return bool|string Returns false on error, a URL path on success.
|
946 |
Â
*/
|
947 |
+
function bp_get_referer_path() {
|
948 |
+
$referer = wp_get_referer();
|
949 |
+
|
950 |
+
if ( false === $referer ) {
|
951 |
+
return false;
|
952 |
+
}
|
953 |
+
|
954 |
+
// Turn into an absolute path.
|
955 |
+
$referer = preg_replace( '|https?\://[^/]+/|', '/', $referer );
|
956 |
+
|
957 |
+
return $referer;
|
958 |
Â
}
|
959 |
Â
|
960 |
Â
/**
|
961 |
+
* Get the path of the current site.
|
962 |
Â
*
|
963 |
Â
* @global object $current_site
|
964 |
Â
*
|
988 |
Â
}
|
989 |
Â
}
|
990 |
Â
|
991 |
+
/**
|
992 |
+
* Filters the path of the current site.
|
993 |
+
*
|
994 |
+
* @since BuddyPress (1.2.0)
|
995 |
+
*
|
996 |
+
* @param string $site_path URL to the current site.
|
997 |
+
*/
|
998 |
Â
return apply_filters( 'bp_core_get_site_path', $site_path );
|
999 |
Â
}
|
1000 |
Â
|
1011 |
Â
* @return string Current time in 'Y-m-d h:i:s' format.
|
1012 |
Â
*/
|
1013 |
Â
function bp_core_current_time( $gmt = true, $type = 'mysql' ) {
|
1014 |
+
|
1015 |
+
/**
|
1016 |
+
* Filters the current GMT time to save into the DB.
|
1017 |
+
*
|
1018 |
+
* @since BuddyPress (1.2.6)
|
1019 |
+
*
|
1020 |
+
* @param string $value Current GMT time.
|
1021 |
+
*/
|
1022 |
Â
return apply_filters( 'bp_core_current_time', current_time( $type, $gmt ) );
|
1023 |
Â
}
|
1024 |
Â
|
1050 |
Â
*/
|
1051 |
Â
function bp_core_time_since( $older_date, $newer_date = false ) {
|
1052 |
Â
|
1053 |
+
/**
|
1054 |
+
* Filters whether or not to bypass BuddyPress' time_since calculations.
|
1055 |
+
*
|
1056 |
+
* @since BuddyPress (1.7.0)
|
1057 |
+
*
|
1058 |
+
* @param bool $value Whether or not to bypass.
|
1059 |
+
* @param string $older_date Earlier time from which we're calculating time elapsed.
|
1060 |
+
* @param string $newer_date Unix timestamp of date to compare older time to.
|
1061 |
+
*/
|
1062 |
Â
$pre_value = apply_filters( 'bp_core_time_since_pre', false, $older_date, $newer_date );
|
1063 |
Â
if ( false !== $pre_value ) {
|
1064 |
Â
return $pre_value;
|
1065 |
Â
}
|
1066 |
Â
|
1067 |
+
/**
|
1068 |
+
* Filters the value to use if the time since is unknown.
|
1069 |
+
*
|
1070 |
+
* @since BuddyPress (1.5.0)
|
1071 |
+
*
|
1072 |
+
* @param string $value String representing the time since the older date.
|
1073 |
+
*/
|
1074 |
Â
$unknown_text = apply_filters( 'bp_core_time_since_unknown_text', __( 'sometime', 'buddypress' ) );
|
1075 |
+
|
1076 |
+
/**
|
1077 |
+
* Filters the value to use if the time since is right now.
|
1078 |
+
*
|
1079 |
+
* @since BuddyPress (1.5.0)
|
1080 |
+
*
|
1081 |
+
* @param string $value String representing the time since the older date.
|
1082 |
+
*/
|
1083 |
Â
$right_now_text = apply_filters( 'bp_core_time_since_right_now_text', __( 'right now', 'buddypress' ) );
|
1084 |
+
|
1085 |
+
/**
|
1086 |
+
* Filters the value to use if the time since is some time ago.
|
1087 |
+
*
|
1088 |
+
* @since BuddyPress (1.5.0)
|
1089 |
+
*
|
1090 |
+
* @param string $value String representing the time since the older date.
|
1091 |
+
*/
|
1092 |
Â
$ago_text = apply_filters( 'bp_core_time_since_ago_text', __( '%s ago', 'buddypress' ) );
|
1093 |
Â
|
1094 |
Â
// array of time period chunks
|
1219 |
Â
$output = sprintf( $ago_text, $output );
|
1220 |
Â
}
|
1221 |
Â
|
1222 |
+
/**
|
1223 |
+
* Filters the English-language representation of the time elapsed since a given date.
|
1224 |
+
*
|
1225 |
+
* @since BuddyPress (1.7.0)
|
1226 |
+
*
|
1227 |
+
* @param string $output Final 'time since' string.
|
1228 |
+
* @param string $older_date Earlier time from which we're calculating time elapsed.
|
1229 |
+
* @param string $newer_date Unix timestamp of date to compare older time to.
|
1230 |
+
*/
|
1231 |
Â
return apply_filters( 'bp_core_time_since', $output, $older_date, $newer_date );
|
1232 |
Â
}
|
1233 |
Â
|
1312 |
Â
|
1313 |
Â
if ( !empty( $bp->template_message ) ) :
|
1314 |
Â
$type = ( 'success' === $bp->template_message_type ) ? 'updated' : 'error';
|
1315 |
+
|
1316 |
+
/**
|
1317 |
+
* Filters the 'template_notices' feedback message content.
|
1318 |
+
*
|
1319 |
+
* @since BuddyPress (1.5.5)
|
1320 |
+
*
|
1321 |
+
* @param string $template_message Feedback message content.
|
1322 |
+
* @param string $type The type of message being displayed.
|
1323 |
+
* Either 'updated' or 'error'.
|
1324 |
+
*/
|
1325 |
Â
$content = apply_filters( 'bp_core_render_message_content', $bp->template_message, $type ); ?>
|
1326 |
Â
|
1327 |
Â
<div id="message" class="bp-template-notice <?php echo esc_attr( $type ); ?>">
|
1332 |
Â
|
1333 |
Â
<?php
|
1334 |
Â
|
1335 |
+
/**
|
1336 |
+
* Fires after the display of any template_notices feedback messages.
|
1337 |
+
*
|
1338 |
+
* @since BuddyPress (1.1.0)
|
1339 |
+
*/
|
1340 |
Â
do_action( 'bp_core_render_message' );
|
1341 |
Â
|
1342 |
Â
endif;
|
1385 |
Â
|
1386 |
Â
// Use this action to detect the very first activity for a given member
|
1387 |
Â
if ( empty( $activity ) ) {
|
1388 |
+
|
1389 |
+
/**
|
1390 |
+
* Fires inside the recording of an activity item.
|
1391 |
+
*
|
1392 |
+
* Use this action to detect the very first activity for a given member.
|
1393 |
+
*
|
1394 |
+
* @since BuddyPress (1.6.0)
|
1395 |
+
*
|
1396 |
+
* @param int $user_id ID of the user whose activity is recorded.
|
1397 |
+
*/
|
1398 |
Â
do_action( 'bp_first_activity_for_member', $user_id );
|
1399 |
Â
}
|
1400 |
Â
|
1427 |
Â
? __( 'Not recently active', 'buddypress' )
|
1428 |
Â
: sprintf( $string, bp_core_time_since( $last_activity_date ) );
|
1429 |
Â
|
1430 |
+
/**
|
1431 |
+
* Filters last activity string based on time since date given.
|
1432 |
+
*
|
1433 |
+
* @since BuddyPress (1.2.0)
|
1434 |
+
*
|
1435 |
+
* @param string $last_active Last activity string based on time since date given.
|
1436 |
+
* @param string $last_activity_date The date of last activity.
|
1437 |
+
* @param string $string A sprintf()-able statement of the form 'active %s'.
|
1438 |
+
*/
|
1439 |
Â
return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
|
1440 |
Â
}
|
1441 |
Â
|
1465 |
Â
* @return string $key The usermeta meta_key.
|
1466 |
Â
*/
|
1467 |
Â
function bp_get_user_meta_key( $key = false ) {
|
1468 |
+
|
1469 |
+
/**
|
1470 |
+
* Filters the meta_key for a given piece of user metadata.
|
1471 |
+
*
|
1472 |
+
* @since BuddyPress (1.5.0)
|
1473 |
+
*
|
1474 |
+
* @param string $key The usermeta meta key.
|
1475 |
+
*/
|
1476 |
Â
return apply_filters( 'bp_get_user_meta_key', $key );
|
1477 |
Â
}
|
1478 |
Â
|
1568 |
Â
* enabled. Default: true.
|
1569 |
Â
*/
|
1570 |
Â
function bp_use_embed_in_activity() {
|
1571 |
+
|
1572 |
+
/**
|
1573 |
+
* Filters whether or not oEmbeds are allowed in activity items.
|
1574 |
+
*
|
1575 |
+
* @since BuddyPress (1.5.0)
|
1576 |
+
*
|
1577 |
+
* @param bool $value Whether or not oEmbeds are allowed.
|
1578 |
+
*/
|
1579 |
Â
return apply_filters( 'bp_use_oembed_in_activity', !defined( 'BP_EMBED_DISABLE_ACTIVITY' ) || !BP_EMBED_DISABLE_ACTIVITY );
|
1580 |
Â
}
|
1581 |
Â
|
1588 |
Â
* when enabled. Default: true.
|
1589 |
Â
*/
|
1590 |
Â
function bp_use_embed_in_activity_replies() {
|
1591 |
+
|
1592 |
+
/**
|
1593 |
+
* Filters whether or not oEmbeds are allowed in activity replies.
|
1594 |
+
*
|
1595 |
+
* @since BuddyPress (1.5.0)
|
1596 |
+
*
|
1597 |
+
* @param bool $value Whether or not oEmbeds are allowed.
|
1598 |
+
*/
|
1599 |
Â
return apply_filters( 'bp_use_embed_in_activity_replies', !defined( 'BP_EMBED_DISABLE_ACTIVITY_REPLIES' ) || !BP_EMBED_DISABLE_ACTIVITY_REPLIES );
|
1600 |
Â
}
|
1601 |
Â
|
1608 |
Â
* enabled. Default: true.
|
1609 |
Â
*/
|
1610 |
Â
function bp_use_embed_in_forum_posts() {
|
1611 |
+
|
1612 |
+
/**
|
1613 |
+
* Filters whether or not oEmbeds are allowed in forum posts.
|
1614 |
+
*
|
1615 |
+
* @since BuddyPress (1.5.0)
|
1616 |
+
*
|
1617 |
+
* @param bool $value Whether or not oEmbeds are allowed.
|
1618 |
+
*/
|
1619 |
Â
return apply_filters( 'bp_use_embed_in_forum_posts', !defined( 'BP_EMBED_DISABLE_FORUM_POSTS' ) || !BP_EMBED_DISABLE_FORUM_POSTS );
|
1620 |
Â
}
|
1621 |
Â
|
1628 |
Â
* enabled. Default: true.
|
1629 |
Â
*/
|
1630 |
Â
function bp_use_embed_in_private_messages() {
|
1631 |
+
|
1632 |
+
/**
|
1633 |
+
* Filters whether or not oEmbeds are allowed in private messages.
|
1634 |
+
*
|
1635 |
+
* @since BuddyPress (1.5.0)
|
1636 |
+
*
|
1637 |
+
* @param bool $value Whether or not oEmbeds are allowed.
|
1638 |
+
*/
|
1639 |
Â
return apply_filters( 'bp_use_embed_in_private_messages', !defined( 'BP_EMBED_DISABLE_PRIVATE_MESSAGES' ) || !BP_EMBED_DISABLE_PRIVATE_MESSAGES );
|
1640 |
Â
}
|
1641 |
Â
|
1708 |
Â
$retval = false;
|
1709 |
Â
}
|
1710 |
Â
|
1711 |
+
/**
|
1712 |
+
* Filters whether or not BuddyPress should appear in network admin.
|
1713 |
+
*
|
1714 |
+
* @since BuddyPress (1.5.0)
|
1715 |
+
*
|
1716 |
+
* @param bool $retval Whether or not BuddyPress should be in the network admin.
|
1717 |
+
*/
|
1718 |
Â
return (bool) apply_filters( 'bp_core_do_network_admin', $retval );
|
1719 |
Â
}
|
1720 |
Â
|
1733 |
Â
function bp_core_admin_hook() {
|
1734 |
Â
$hook = bp_core_do_network_admin() ? 'network_admin_menu' : 'admin_menu';
|
1735 |
Â
|
1736 |
+
/**
|
1737 |
+
* Filters the action name that BuddyPress nav setup callbacks should be hooked to.
|
1738 |
+
*
|
1739 |
+
* @since BuddyPress (1.5.0)
|
1740 |
+
*
|
1741 |
+
* @param string $hook Action name to be attached to.
|
1742 |
+
*/
|
1743 |
Â
return apply_filters( 'bp_core_admin_hook', $hook );
|
1744 |
Â
}
|
1745 |
Â
|
1768 |
Â
$is_root_blog = true;
|
1769 |
Â
}
|
1770 |
Â
|
1771 |
+
/**
|
1772 |
+
* Filters whether or not we're on the root blog.
|
1773 |
+
*
|
1774 |
+
* @since BuddyPress (1.5.0)
|
1775 |
+
*
|
1776 |
+
* @param bool $is_root_blog Whether or not we're on the root blog.
|
1777 |
+
*/
|
1778 |
Â
return (bool) apply_filters( 'bp_is_root_blog', (bool) $is_root_blog );
|
1779 |
Â
}
|
1780 |
Â
|
1790 |
Â
* @return int The root site ID.
|
1791 |
Â
*/
|
1792 |
Â
function bp_get_root_blog_id() {
|
1793 |
+
|
1794 |
+
/**
|
1795 |
+
* Filters the ID for the root blog.
|
1796 |
+
*
|
1797 |
+
* @since BuddyPress (1.5.0)
|
1798 |
+
*
|
1799 |
+
* @param int $root_blog_id ID for the root blog.
|
1800 |
+
*/
|
1801 |
Â
return (int) apply_filters( 'bp_get_root_blog_id', (int) buddypress()->root_blog_id );
|
1802 |
Â
}
|
1803 |
Â
|
1848 |
Â
$retval = true;
|
1849 |
Â
}
|
1850 |
Â
|
1851 |
+
/**
|
1852 |
+
* Filters whether or not we're running in multiblog mode.
|
1853 |
+
*
|
1854 |
+
* @since BuddyPress (1.5.0)
|
1855 |
+
*
|
1856 |
+
* @param bool $retval Whether or not we're running multiblog mode.
|
1857 |
+
*/
|
1858 |
Â
return apply_filters( 'bp_is_multiblog_mode', $retval );
|
1859 |
Â
}
|
1860 |
Â
|
1884 |
Â
$retval = false;
|
1885 |
Â
}
|
1886 |
Â
|
1887 |
+
/**
|
1888 |
+
* Filters whether or not we're active at the network level.
|
1889 |
+
*
|
1890 |
+
* @since BuddyPress (1.7.0)
|
1891 |
+
*
|
1892 |
+
* @param bool $retval Whether or not we're network activated.
|
1893 |
+
*/
|
1894 |
Â
return (bool) apply_filters( 'bp_is_network_activated', $retval );
|
1895 |
Â
}
|
1896 |
Â
|
1909 |
Â
$component = bp_current_component();
|
1910 |
Â
}
|
1911 |
Â
|
1912 |
+
/**
|
1913 |
+
* Filters the "is_directory" global value.
|
1914 |
+
*
|
1915 |
+
* @since BuddyPress (1.5.0)
|
1916 |
+
*
|
1917 |
+
* @param bool $is_directory Whether or not we're "is_directory".
|
1918 |
+
* @param string $component Component name. Default: the current component.
|
1919 |
+
*/
|
1920 |
Â
buddypress()->is_directory = apply_filters( 'bp_update_is_directory', $is_directory, $component );
|
1921 |
Â
}
|
1922 |
Â
|
1933 |
Â
$component = bp_current_component();
|
1934 |
Â
}
|
1935 |
Â
|
1936 |
+
/**
|
1937 |
+
* Filters the "is_item_admin" global value.
|
1938 |
+
*
|
1939 |
+
* @since BuddyPress (1.5.0)
|
1940 |
+
*
|
1941 |
+
* @param bool $is_item_admin Whether or not we're "is_item_admin".
|
1942 |
+
* @param string $component Component name. Default: the current component.
|
1943 |
+
*/
|
1944 |
Â
buddypress()->is_item_admin = apply_filters( 'bp_update_is_item_admin', $is_item_admin, $component );
|
1945 |
Â
}
|
1946 |
Â
|
1957 |
Â
$component = bp_current_component();
|
1958 |
Â
}
|
1959 |
Â
|
1960 |
+
/**
|
1961 |
+
* Filters the "is_item_mod" global value.
|
1962 |
+
*
|
1963 |
+
* @since BuddyPress (1.5.0)
|
1964 |
+
*
|
1965 |
+
* @param bool $is_item_mod Whether or not we're "is_item_mod".
|
1966 |
+
* @param string $component Component name. Default: the current component.
|
1967 |
+
*/
|
1968 |
Â
buddypress()->is_item_mod = apply_filters( 'bp_update_is_item_mod', $is_item_mod, $component );
|
1969 |
Â
}
|
1970 |
Â
|
1981 |
Â
function bp_do_404( $redirect = 'remove_canonical_direct' ) {
|
1982 |
Â
global $wp_query;
|
1983 |
Â
|
1984 |
+
/**
|
1985 |
+
* Fires inside the triggering of a 404.
|
1986 |
+
*
|
1987 |
+
* @since BuddyPress (1.5.0)
|
1988 |
+
*
|
1989 |
+
* @param string $redirect Redirect type used to determine if redirect_canonical
|
1990 |
+
* function should be be removed.
|
1991 |
+
*/
|
1992 |
Â
do_action( 'bp_do_404', $redirect );
|
1993 |
Â
|
1994 |
Â
$wp_query->set_404();
|
2048 |
Â
|
2049 |
Â
/** Look for match ********************************************************/
|
2050 |
Â
|
2051 |
+
/**
|
2052 |
+
* Filters the requested URL being nonce-verified.
|
2053 |
+
*
|
2054 |
+
* Useful for configurations like reverse proxying.
|
2055 |
+
*
|
2056 |
+
* @since BuddyPress (1.9.0)
|
2057 |
+
*
|
2058 |
+
* @param string $requested_url The requested URL.
|
2059 |
+
*/
|
2060 |
Â
$matched_url = apply_filters( 'bp_verify_nonce_request_url', $requested_url );
|
2061 |
Â
|
2062 |
Â
// Check the nonce
|
2067 |
Â
$result = false;
|
2068 |
Â
}
|
2069 |
Â
|
2070 |
+
/**
|
2071 |
+
* Fires at the end of the nonce verification check.
|
2072 |
+
*
|
2073 |
+
* @since BuddyPress (1.6.0)
|
2074 |
+
*
|
2075 |
+
* @param string $action Action nonce.
|
2076 |
+
* @param bool $result Boolean result of nonce verification.
|
2077 |
+
*/
|
2078 |
Â
do_action( 'bp_verify_nonce_request', $action, $result );
|
2079 |
Â
|
2080 |
Â
return $result;
|
2114 |
Â
*/
|
2115 |
Â
function bp_core_load_buddypress_textdomain() {
|
2116 |
Â
$domain = 'buddypress';
|
2117 |
+
|
2118 |
+
/**
|
2119 |
+
* Filters the locale to be loaded for the language files.
|
2120 |
+
*
|
2121 |
+
* @since BuddyPress (1.0.2)
|
2122 |
+
*
|
2123 |
+
* @param string $value Current locale for the install.
|
2124 |
+
*/
|
2125 |
Â
$mofile_custom = sprintf( '%s-%s.mo', $domain, apply_filters( 'buddypress_locale', get_locale() ) );
|
2126 |
Â
|
2127 |
+
/**
|
2128 |
+
* Filters the locations to load language files from.
|
2129 |
+
*
|
2130 |
+
* @since BuddyPress (2.2.0)
|
2131 |
+
*
|
2132 |
+
* @param array $value Array of directories to check for language files in.
|
2133 |
+
*/
|
2134 |
Â
$locations = apply_filters( 'buddypress_locale_locations', array(
|
2135 |
Â
trailingslashit( WP_LANG_DIR . '/' . $domain ),
|
2136 |
Â
trailingslashit( WP_LANG_DIR ),
|
2149 |
Â
add_action ( 'bp_core_loaded', 'bp_core_load_buddypress_textdomain' );
|
2150 |
Â
|
2151 |
Â
/**
|
2152 |
+
* A JavaScript-free implementation of the search functions in BuddyPress.
|
2153 |
Â
*
|
2154 |
Â
* @param string $slug The slug to redirect to for searching.
|
2155 |
Â
*/
|
2210 |
Â
}
|
2211 |
Â
}
|
2212 |
Â
|
2213 |
+
/**
|
2214 |
+
* Filters the constructed url for use with site searching.
|
2215 |
+
*
|
2216 |
+
* @since BuddyPress (1.0.0)
|
2217 |
+
*
|
2218 |
+
* @param string $value URL for use with site searching.
|
2219 |
+
* @param array $search_terms Array of search terms.
|
2220 |
+
*/
|
2221 |
Â
bp_core_redirect( apply_filters( 'bp_core_search_site', home_url( $slug . $query_string . urlencode( $search_terms ) ), $search_terms ) );
|
2222 |
Â
}
|
2223 |
Â
add_action( 'bp_init', 'bp_core_action_search_site', 7 );
|
2456 |
Â
}
|
2457 |
Â
|
2458 |
Â
} else {
|
2459 |
+
|
2460 |
+
/**
|
2461 |
+
* Filters the default suggestions service to use.
|
2462 |
+
*
|
2463 |
+
* Use this hook to tell BP the name of your class
|
2464 |
+
* if you've built a custom suggestions service.
|
2465 |
+
*
|
2466 |
+
* @since BuddyPress (2.1.0)
|
2467 |
+
*
|
2468 |
+
* @param string $value Custom class to use. Default: none.
|
2469 |
+
* @param array $args Array of arguments for sugggestions.
|
2470 |
+
*/
|
2471 |
Â
$class = apply_filters( 'bp_suggestions_services', '', $args );
|
2472 |
Â
}
|
2473 |
Â
|
2485 |
Â
$retval = $suggestions->get_suggestions();
|
2486 |
Â
}
|
2487 |
Â
|
2488 |
+
/**
|
2489 |
+
* Filters the available type of at-mentions.
|
2490 |
+
*
|
2491 |
+
* @since BuddyPress (2.1.0)
|
2492 |
+
*
|
2493 |
+
* @param array|WP_Error $retval Array of results or WP_Error object.
|
2494 |
+
* @param array $args Array of arguments for suggestions.
|
2495 |
+
*/
|
2496 |
Â
return apply_filters( 'bp_core_get_suggestions', $retval, $args );
|
2497 |
Â
}
|
2498 |
+
|
2499 |
+
/**
|
2500 |
+
* Set data from the BP root blog's upload directory.
|
2501 |
+
*
|
2502 |
+
* Handy for multisite instances because all uploads are made on the BP root
|
2503 |
+
* blog and we need to query the BP root blog for the upload directory data.
|
2504 |
+
*
|
2505 |
+
* This function ensures that we only need to use {@link switch_to_blog()}
|
2506 |
+
* once to get what we need.
|
2507 |
+
*
|
2508 |
+
* @since BuddyPress (2.3.0)
|
2509 |
+
*
|
2510 |
+
* @uses is_multisite()
|
2511 |
+
* @uses bp_is_root_blog()
|
2512 |
+
* @uses switch_to_blog()
|
2513 |
+
* @uses wp_upload_dir()
|
2514 |
+
* @uses restore_current_blog()
|
2515 |
+
*/
|
2516 |
+
function bp_upload_dir() {
|
2517 |
+
$bp = buddypress();
|
2518 |
+
|
2519 |
+
if ( empty( $bp->upload_dir ) ) {
|
2520 |
+
$need_switch = (bool) ( is_multisite() && ! bp_is_root_blog() );
|
2521 |
+
|
2522 |
+
// Maybe juggle to root blog
|
2523 |
+
if ( true === $need_switch ) {
|
2524 |
+
switch_to_blog( bp_get_root_blog_id() );
|
2525 |
+
}
|
2526 |
+
|
2527 |
+
// Get the upload directory (maybe for root blog)
|
2528 |
+
$wp_upload_dir = wp_upload_dir();
|
2529 |
+
|
2530 |
+
// Maybe juggle back to current blog
|
2531 |
+
if ( true === $need_switch ) {
|
2532 |
+
restore_current_blog();
|
2533 |
+
}
|
2534 |
+
|
2535 |
+
// Bail if an error occurred
|
2536 |
+
if ( ! empty( $wp_upload_dir['error'] ) ) {
|
2537 |
+
return false;
|
2538 |
+
}
|
2539 |
+
|
2540 |
+
$bp->upload_dir = $wp_upload_dir;
|
2541 |
+
}
|
2542 |
+
|
2543 |
+
return $bp->upload_dir;
|
2544 |
+
}
|
bp-core/bp-core-loader.php
CHANGED
@@ -43,25 +43,47 @@ class BP_Core extends BP_Component {
|
|
43 |
Â
$bp = buddypress();
|
44 |
Â
|
45 |
Â
/**
|
46 |
-
*
|
47 |
-
* individual components (friends/activity/groups/etc...) have not.
|
48 |
Â
*
|
49 |
-
*
|
50 |
-
*
|
Â
|
|
51 |
Â
*/
|
52 |
Â
do_action( 'bp_core_loaded' );
|
53 |
Â
|
54 |
Â
/** Components ********************************************************/
|
55 |
Â
|
56 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
57 |
Â
$bp->optional_components = apply_filters( 'bp_optional_components', array( 'activity', 'blogs', 'forums', 'friends', 'groups', 'messages', 'notifications', 'settings', 'xprofile' ) );
|
58 |
Â
|
59 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
60 |
Â
$bp->required_components = apply_filters( 'bp_required_components', array( 'members' ) );
|
61 |
Â
|
62 |
Â
// Get a list of activated components
|
63 |
Â
if ( $active_components = bp_get_option( 'bp-active-components' ) ) {
|
Â
|
|
Â
|
|
64 |
Â
$bp->active_components = apply_filters( 'bp_active_components', $active_components );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
65 |
Â
$bp->deactivated_components = apply_filters( 'bp_deactivated_components', array_values( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_keys( $bp->active_components ) ) ) );
|
66 |
Â
|
67 |
Â
// Pre 1.5 Backwards compatibility
|
@@ -72,13 +94,13 @@ class BP_Core extends BP_Component {
|
|
72 |
Â
$trimmed[] = str_replace( '.php', '', str_replace( 'bp-', '', $component ) );
|
73 |
Â
}
|
74 |
Â
|
75 |
-
|
76 |
Â
$bp->deactivated_components = apply_filters( 'bp_deactivated_components', $trimmed );
|
77 |
Â
|
78 |
Â
// Setup the active components
|
79 |
Â
$active_components = array_fill_keys( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_values( $bp->deactivated_components ) ), '1' );
|
80 |
Â
|
81 |
-
|
82 |
Â
$bp->active_components = apply_filters( 'bp_active_components', $bp->active_components );
|
83 |
Â
|
84 |
Â
// Default to all components active
|
@@ -90,7 +112,7 @@ class BP_Core extends BP_Component {
|
|
90 |
Â
// Setup the active components
|
91 |
Â
$active_components = array_fill_keys( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), '1' );
|
92 |
Â
|
93 |
-
|
94 |
Â
$bp->active_components = apply_filters( 'bp_active_components', $bp->active_components );
|
95 |
Â
}
|
96 |
Â
|
@@ -111,6 +133,11 @@ class BP_Core extends BP_Component {
|
|
111 |
Â
// Add Core to required components
|
112 |
Â
$bp->required_components[] = 'core';
|
113 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
114 |
Â
do_action( 'bp_core_components_included' );
|
115 |
Â
}
|
116 |
Â
|
@@ -179,8 +206,32 @@ class BP_Core extends BP_Component {
|
|
179 |
Â
|
180 |
Â
// Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar
|
181 |
Â
$bp->grav_default = new stdClass;
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
182 |
Â
$bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['avatar_default'] );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
183 |
Â
$bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', $bp->grav_default->user );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
184 |
Â
$bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', $bp->grav_default->user );
|
185 |
Â
|
186 |
Â
// Notifications table. Included here for legacy purposes. Use
|
@@ -200,6 +251,11 @@ class BP_Core extends BP_Component {
|
|
200 |
Â
// Is the logged in user is a mod for the current item?
|
201 |
Â
bp_update_is_item_mod( false, 'core' );
|
202 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
203 |
Â
do_action( 'bp_core_setup_globals' );
|
204 |
Â
}
|
205 |
Â
|
43 |
Â
$bp = buddypress();
|
44 |
Â
|
45 |
Â
/**
|
46 |
+
* Fires before the loading of individual components and after BuddyPress Core.
|
Â
|
|
47 |
Â
*
|
48 |
+
* Allows plugins to run code ahead of the other components.
|
49 |
+
*
|
50 |
+
* @since BuddyPress (1.2.0)
|
51 |
Â
*/
|
52 |
Â
do_action( 'bp_core_loaded' );
|
53 |
Â
|
54 |
Â
/** Components ********************************************************/
|
55 |
Â
|
56 |
+
/**
|
57 |
+
* Filters the included and optional components.
|
58 |
+
*
|
59 |
+
* @since BuddyPress (1.5.0)
|
60 |
+
*
|
61 |
+
* @param array $value Array of included and optional components.
|
62 |
+
*/
|
63 |
Â
$bp->optional_components = apply_filters( 'bp_optional_components', array( 'activity', 'blogs', 'forums', 'friends', 'groups', 'messages', 'notifications', 'settings', 'xprofile' ) );
|
64 |
Â
|
65 |
+
/**
|
66 |
+
* Filters the required components.
|
67 |
+
*
|
68 |
+
* @since BuddyPress (1.5.0)
|
69 |
+
*
|
70 |
+
* @param array $value Array of required components.
|
71 |
+
*/
|
72 |
Â
$bp->required_components = apply_filters( 'bp_required_components', array( 'members' ) );
|
73 |
Â
|
74 |
Â
// Get a list of activated components
|
75 |
Â
if ( $active_components = bp_get_option( 'bp-active-components' ) ) {
|
76 |
+
|
77 |
+
/** This filter is documented in bp-core/admin/bp-core-admin-components.php */
|
78 |
Â
$bp->active_components = apply_filters( 'bp_active_components', $active_components );
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Filters the deactivated components.
|
82 |
+
*
|
83 |
+
* @since BuddyPress (1.0.0)
|
84 |
+
*
|
85 |
+
* @param array $value Array of deactivated components.
|
86 |
+
*/
|
87 |
Â
$bp->deactivated_components = apply_filters( 'bp_deactivated_components', array_values( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_keys( $bp->active_components ) ) ) );
|
88 |
Â
|
89 |
Â
// Pre 1.5 Backwards compatibility
|
94 |
Â
$trimmed[] = str_replace( '.php', '', str_replace( 'bp-', '', $component ) );
|
95 |
Â
}
|
96 |
Â
|
97 |
+
/** This filter is documented in bp-core/bp-core-loader.php */
|
98 |
Â
$bp->deactivated_components = apply_filters( 'bp_deactivated_components', $trimmed );
|
99 |
Â
|
100 |
Â
// Setup the active components
|
101 |
Â
$active_components = array_fill_keys( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_values( $bp->deactivated_components ) ), '1' );
|
102 |
Â
|
103 |
+
/** This filter is documented in bp-core/admin/bp-core-admin-components.php */
|
104 |
Â
$bp->active_components = apply_filters( 'bp_active_components', $bp->active_components );
|
105 |
Â
|
106 |
Â
// Default to all components active
|
112 |
Â
// Setup the active components
|
113 |
Â
$active_components = array_fill_keys( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), '1' );
|
114 |
Â
|
115 |
+
/** This filter is documented in bp-core/admin/bp-core-admin-components.php */
|
116 |
Â
$bp->active_components = apply_filters( 'bp_active_components', $bp->active_components );
|
117 |
Â
}
|
118 |
Â
|
133 |
Â
// Add Core to required components
|
134 |
Â
$bp->required_components[] = 'core';
|
135 |
Â
|
136 |
+
/**
|
137 |
+
* Fires after the loading of individual components.
|
138 |
+
*
|
139 |
+
* @since BuddyPress (2.0.0)
|
140 |
+
*/
|
141 |
Â
do_action( 'bp_core_components_included' );
|
142 |
Â
}
|
143 |
Â
|
206 |
Â
|
207 |
Â
// Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar
|
208 |
Â
$bp->grav_default = new stdClass;
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Filters the default user Gravatar.
|
212 |
+
*
|
213 |
+
* @since BuddyPress (1.1.0)
|
214 |
+
*
|
215 |
+
* @param string $value Default user Gravatar.
|
216 |
+
*/
|
217 |
Â
$bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['avatar_default'] );
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Filters the default group Gravatar.
|
221 |
+
*
|
222 |
+
* @since BuddyPress (1.1.0)
|
223 |
+
*
|
224 |
+
* @param string $value Default group Gravatar.
|
225 |
+
*/
|
226 |
Â
$bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', $bp->grav_default->user );
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Filters the default blog Gravatar.
|
230 |
+
*
|
231 |
+
* @since BuddyPress (1.1.0)
|
232 |
+
*
|
233 |
+
* @param string $value Default blog Gravatar.
|
234 |
+
*/
|
235 |
Â
$bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', $bp->grav_default->user );
|
236 |
Â
|
237 |
Â
// Notifications table. Included here for legacy purposes. Use
|
251 |
Â
// Is the logged in user is a mod for the current item?
|
252 |
Â
bp_update_is_item_mod( false, 'core' );
|
253 |
Â
|
254 |
+
/**
|
255 |
+
* Fires at the end of the setup of bp-core globals setting.
|
256 |
+
*
|
257 |
+
* @since BuddyPress (1.1.0)
|
258 |
+
*/
|
259 |
Â
do_action( 'bp_core_setup_globals' );
|
260 |
Â
}
|
261 |
Â
|
bp-core/bp-core-moderation.php
CHANGED
@@ -64,7 +64,16 @@ function bp_core_check_for_flood( $user_id = 0 ) {
|
|
64 |
Â
*/
|
65 |
Â
function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = '' ) {
|
66 |
Â
|
67 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
68 |
Â
if ( apply_filters( 'bp_bypass_check_for_moderation', false, $user_id, $title, $content ) ) {
|
69 |
Â
return true;
|
70 |
Â
}
|
@@ -111,6 +120,15 @@ function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = ''
|
|
111 |
Â
|
112 |
Â
// Allow for bumping the max to include the user's URL
|
113 |
Â
if ( ! empty( $_post['url'] ) ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
114 |
Â
$num_links = apply_filters( 'comment_max_links_url', $num_links, $_post['url'] );
|
115 |
Â
}
|
116 |
Â
|
@@ -180,7 +198,16 @@ function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = ''
|
|
180 |
Â
*/
|
181 |
Â
function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '' ) {
|
182 |
Â
|
183 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
184 |
Â
if ( apply_filters( 'bp_bypass_check_for_blacklist', false, $user_id, $title, $content ) ) {
|
185 |
Â
return true;
|
186 |
Â
}
|
@@ -272,6 +299,13 @@ function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '' )
|
|
272 |
Â
function bp_core_current_user_ip() {
|
273 |
Â
$retval = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] );
|
274 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
275 |
Â
return apply_filters( 'bp_core_current_user_ip', $retval );
|
276 |
Â
}
|
277 |
Â
|
@@ -291,5 +325,12 @@ function bp_core_current_user_ua() {
|
|
291 |
Â
$retval = '';
|
292 |
Â
}
|
293 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
294 |
Â
return apply_filters( 'bp_core_current_user_ua', $retval );
|
295 |
Â
}
|
64 |
Â
*/
|
65 |
Â
function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = '' ) {
|
66 |
Â
|
67 |
+
/**
|
68 |
+
* Filters whether or not to bypass checking for moderation keys and too many links.
|
69 |
+
*
|
70 |
+
* @since BuddyPress (2.2.0)
|
71 |
+
*
|
72 |
+
* @param bool $value Whether or not to bypass checking. Default false.
|
73 |
+
* @param int $user_id Topic of reply author ID.
|
74 |
+
* @param string $title The title of the content.
|
75 |
+
* @param string $content $the content being posted.
|
76 |
+
*/
|
77 |
Â
if ( apply_filters( 'bp_bypass_check_for_moderation', false, $user_id, $title, $content ) ) {
|
78 |
Â
return true;
|
79 |
Â
}
|
120 |
Â
|
121 |
Â
// Allow for bumping the max to include the user's URL
|
122 |
Â
if ( ! empty( $_post['url'] ) ) {
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Filters the maximum amount of links allowed to include the user's URL.
|
126 |
+
*
|
127 |
+
* @since BuddyPress (1.6.0)
|
128 |
+
*
|
129 |
+
* @param string $num_links How many links found.
|
130 |
+
* @param string $value User's url.
|
131 |
+
*/
|
132 |
Â
$num_links = apply_filters( 'comment_max_links_url', $num_links, $_post['url'] );
|
133 |
Â
}
|
134 |
Â
|
198 |
Â
*/
|
199 |
Â
function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '' ) {
|
200 |
Â
|
201 |
+
/**
|
202 |
+
* Filters whether or not to bypass checking for blocked keys.
|
203 |
+
*
|
204 |
+
* @since BuddyPress (2.2.0)
|
205 |
+
*
|
206 |
+
* @param bool $value Whether or not to bypass checking. Default false.
|
207 |
+
* @param int $user_id Topic of reply author ID.
|
208 |
+
* @param string $title The title of the content.
|
209 |
+
* @param string $content $the content being posted.
|
210 |
+
*/
|
211 |
Â
if ( apply_filters( 'bp_bypass_check_for_blacklist', false, $user_id, $title, $content ) ) {
|
212 |
Â
return true;
|
213 |
Â
}
|
299 |
Â
function bp_core_current_user_ip() {
|
300 |
Â
$retval = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] );
|
301 |
Â
|
302 |
+
/**
|
303 |
+
* Filters the current user's IP address.
|
304 |
+
*
|
305 |
+
* @since BuddyPress (1.6.0)
|
306 |
+
*
|
307 |
+
* @param string $retval Current user's IP Address.
|
308 |
+
*/
|
309 |
Â
return apply_filters( 'bp_core_current_user_ip', $retval );
|
310 |
Â
}
|
311 |
Â
|
325 |
Â
$retval = '';
|
326 |
Â
}
|
327 |
Â
|
328 |
+
/**
|
329 |
+
* Filters the current user's user-agent.
|
330 |
+
*
|
331 |
+
* @since BuddyPress (1.6.0)
|
332 |
+
*
|
333 |
+
* @param string $retval Current user's user-agent
|
334 |
+
*/
|
335 |
Â
return apply_filters( 'bp_core_current_user_ua', $retval );
|
336 |
Â
}
|
bp-core/bp-core-options.php
CHANGED
@@ -55,6 +55,9 @@ function bp_get_default_options() {
|
|
55 |
Â
// Avatar uploads
|
56 |
Â
'bp-disable-avatar-uploads' => false,
|
57 |
Â
|
Â
|
|
Â
|
|
Â
|
|
58 |
Â
// Allow users to delete their own accounts
|
59 |
Â
'bp-disable-account-deletion' => false,
|
60 |
Â
|
@@ -100,6 +103,13 @@ function bp_get_default_options() {
|
|
100 |
Â
'widget_bp_messages_sitewide_notices_widget' => false,
|
101 |
Â
);
|
102 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
103 |
Â
return apply_filters( 'bp_get_default_options', $options );
|
104 |
Â
}
|
105 |
Â
|
@@ -125,7 +135,13 @@ function bp_add_options() {
|
|
125 |
Â
bp_add_option( $key, $value );
|
126 |
Â
}
|
127 |
Â
|
128 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
129 |
Â
do_action( 'bp_add_options' );
|
130 |
Â
}
|
131 |
Â
|
@@ -153,7 +169,13 @@ function bp_delete_options() {
|
|
153 |
Â
delete_option( $key );
|
154 |
Â
}
|
155 |
Â
|
156 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
157 |
Â
do_action( 'bp_delete_options' );
|
158 |
Â
}
|
159 |
Â
|
@@ -178,7 +200,13 @@ function bp_setup_option_filters() {
|
|
178 |
Â
add_filter( 'pre_option_' . $key, 'bp_pre_get_option' );
|
179 |
Â
}
|
180 |
Â
|
181 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
182 |
Â
do_action( 'bp_setup_option_filters' );
|
183 |
Â
}
|
184 |
Â
|
@@ -187,7 +215,7 @@ function bp_setup_option_filters() {
|
|
187 |
Â
*
|
188 |
Â
* Currently unused.
|
189 |
Â
*
|
190 |
-
* @since BuddyPress (1.6)
|
191 |
Â
*
|
192 |
Â
* @param bool $value Optional. Default value false
|
193 |
Â
* @return mixed false if not overloaded, mixed if set
|
@@ -218,7 +246,7 @@ function bp_pre_get_option( $value = false ) {
|
|
218 |
Â
*
|
219 |
Â
* The 'bp_get_option' filter is primarily for backward-compatibility.
|
220 |
Â
*
|
221 |
-
* @since BuddyPress (1.
|
222 |
Â
*
|
223 |
Â
* @uses bp_get_root_blog_id()
|
224 |
Â
*
|
@@ -229,6 +257,14 @@ function bp_pre_get_option( $value = false ) {
|
|
229 |
Â
*/
|
230 |
Â
function bp_get_option( $option_name, $default = '' ) {
|
231 |
Â
$value = get_blog_option( bp_get_root_blog_id(), $option_name, $default );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
232 |
Â
return apply_filters( 'bp_get_option', $value );
|
233 |
Â
}
|
234 |
Â
|
@@ -296,9 +332,10 @@ function bp_delete_option( $option_name ) {
|
|
296 |
Â
* @deprecated 1.6.0
|
297 |
Â
*/
|
298 |
Â
function bp_core_activate_site_options( $keys = array() ) {
|
299 |
-
global $bp;
|
300 |
Â
|
301 |
Â
if ( !empty( $keys ) && is_array( $keys ) ) {
|
Â
|
|
Â
|
|
302 |
Â
$errors = false;
|
303 |
Â
|
304 |
Â
foreach ( $keys as $key => $default ) {
|
@@ -353,6 +390,14 @@ function bp_core_get_root_options() {
|
|
353 |
Â
|
354 |
Â
// On Multisite installations, some options must always be fetched from sitemeta
|
355 |
Â
if ( is_multisite() ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
356 |
Â
$network_options = apply_filters( 'bp_core_network_options', array(
|
357 |
Â
'tags_blog_id' => '0',
|
358 |
Â
'sitewide_tags_blog' => '',
|
@@ -429,9 +474,43 @@ function bp_core_get_root_options() {
|
|
429 |
Â
wp_cache_set( 'root_blog_options', $root_blog_options_meta, 'bp' );
|
430 |
Â
}
|
431 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
432 |
Â
return apply_filters( 'bp_core_get_root_options', $root_blog_options_meta );
|
433 |
Â
}
|
434 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
435 |
Â
/** Active? *******************************************************************/
|
436 |
Â
|
437 |
Â
/**
|
@@ -446,6 +525,14 @@ function bp_core_get_root_options() {
|
|
446 |
Â
* @return bool True if profile sync is enabled, otherwise false.
|
447 |
Â
*/
|
448 |
Â
function bp_disable_profile_sync( $default = false ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
449 |
Â
return (bool) apply_filters( 'bp_disable_profile_sync', (bool) bp_get_option( 'bp-disable-profile-sync', $default ) );
|
450 |
Â
}
|
451 |
Â
|
@@ -462,6 +549,14 @@ function bp_disable_profile_sync( $default = false ) {
|
|
462 |
Â
* otherwise false.
|
463 |
Â
*/
|
464 |
Â
function bp_hide_loggedout_adminbar( $default = true ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
465 |
Â
return (bool) apply_filters( 'bp_hide_loggedout_adminbar', (bool) bp_get_option( 'hide-loggedout-adminbar', $default ) );
|
466 |
Â
}
|
467 |
Â
|
@@ -477,9 +572,51 @@ function bp_hide_loggedout_adminbar( $default = true ) {
|
|
477 |
Â
* @return bool True if avatar uploads are disabled, otherwise false.
|
478 |
Â
*/
|
479 |
Â
function bp_disable_avatar_uploads( $default = true ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
480 |
Â
return (bool) apply_filters( 'bp_disable_avatar_uploads', (bool) bp_get_option( 'bp-disable-avatar-uploads', $default ) );
|
481 |
Â
}
|
482 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
483 |
Â
/**
|
484 |
Â
* Are members able to delete their own accounts?
|
485 |
Â
*
|
@@ -493,6 +630,14 @@ function bp_disable_avatar_uploads( $default = true ) {
|
|
493 |
Â
* false.
|
494 |
Â
*/
|
495 |
Â
function bp_disable_account_deletion( $default = false ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
496 |
Â
return apply_filters( 'bp_disable_account_deletion', (bool) bp_get_option( 'bp-disable-account-deletion', $default ) );
|
497 |
Â
}
|
498 |
Â
|
@@ -510,6 +655,14 @@ function bp_disable_account_deletion( $default = false ) {
|
|
510 |
Â
* items, otherwise false.
|
511 |
Â
*/
|
512 |
Â
function bp_disable_blogforum_comments( $default = false ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
513 |
Â
return (bool) apply_filters( 'bp_disable_blogforum_comments', (bool) bp_get_option( 'bp-disable-blogforum-comments', $default ) );
|
514 |
Â
}
|
515 |
Â
|
@@ -526,6 +679,14 @@ function bp_disable_blogforum_comments( $default = false ) {
|
|
526 |
Â
* @return bool True if group creation is restricted, otherwise false.
|
527 |
Â
*/
|
528 |
Â
function bp_restrict_group_creation( $default = true ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
529 |
Â
return (bool) apply_filters( 'bp_restrict_group_creation', (bool) bp_get_option( 'bp_restrict_group_creation', $default ) );
|
530 |
Â
}
|
531 |
Â
|
@@ -541,6 +702,14 @@ function bp_restrict_group_creation( $default = true ) {
|
|
541 |
Â
* @return bool True if the BuddyBar should be forced on, otherwise false.
|
542 |
Â
*/
|
543 |
Â
function bp_force_buddybar( $default = true ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
544 |
Â
return (bool) apply_filters( 'bp_force_buddybar', (bool) bp_get_option( '_bp_force_buddybar', $default ) );
|
545 |
Â
}
|
546 |
Â
|
@@ -565,6 +734,14 @@ function bp_group_forums_root_id( $default = '0' ) {
|
|
565 |
Â
* @return int The ID of the group forums root forum.
|
566 |
Â
*/
|
567 |
Â
function bp_get_group_forums_root_id( $default = '0' ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
568 |
Â
return (int) apply_filters( 'bp_get_group_forums_root_id', (int) bp_get_option( '_bp_group_forums_root_id', $default ) );
|
569 |
Â
}
|
570 |
Â
|
@@ -580,6 +757,14 @@ function bp_group_forums_root_id( $default = '0' ) {
|
|
580 |
Â
* @return bool True if group forums are active, otherwise false.
|
581 |
Â
*/
|
582 |
Â
function bp_is_group_forums_active( $default = true ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
583 |
Â
return (bool) apply_filters( 'bp_is_group_forums_active', (bool) bp_get_option( '_bp_enable_group_forums', $default ) );
|
584 |
Â
}
|
585 |
Â
|
@@ -595,6 +780,14 @@ function bp_is_group_forums_active( $default = true ) {
|
|
595 |
Â
* @return bool True if Akismet is enabled, otherwise false.
|
596 |
Â
*/
|
597 |
Â
function bp_is_akismet_active( $default = true ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
598 |
Â
return (bool) apply_filters( 'bp_is_akismet_active', (bool) bp_get_option( '_bp_enable_akismet', $default ) );
|
599 |
Â
}
|
600 |
Â
|
@@ -610,6 +803,14 @@ function bp_is_akismet_active( $default = true ) {
|
|
610 |
Â
* @return bool True if Heartbeat refresh is enabled, otherwise false.
|
611 |
Â
*/
|
612 |
Â
function bp_is_activity_heartbeat_active( $default = true ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
613 |
Â
return (bool) apply_filters( 'bp_is_activity_heartbeat_active', (bool) bp_get_option( '_bp_enable_heartbeat_refresh', $default ) );
|
614 |
Â
}
|
615 |
Â
|
@@ -625,5 +826,13 @@ function bp_is_activity_heartbeat_active( $default = true ) {
|
|
625 |
Â
* @return string ID of the theme package.
|
626 |
Â
*/
|
627 |
Â
function bp_get_theme_package_id( $default = 'legacy' ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
628 |
Â
return apply_filters( 'bp_get_theme_package_id', bp_get_option( '_bp_theme_package_id', $default ) );
|
629 |
Â
}
|
55 |
Â
// Avatar uploads
|
56 |
Â
'bp-disable-avatar-uploads' => false,
|
57 |
Â
|
58 |
+
// Group Profile Photos
|
59 |
+
'bp-disable-group-avatar-uploads' => false,
|
60 |
+
|
61 |
Â
// Allow users to delete their own accounts
|
62 |
Â
'bp-disable-account-deletion' => false,
|
63 |
Â
|
103 |
Â
'widget_bp_messages_sitewide_notices_widget' => false,
|
104 |
Â
);
|
105 |
Â
|
106 |
+
/**
|
107 |
+
* Filters the default options to be set upon activation.
|
108 |
+
*
|
109 |
+
* @since BuddyPress (1.6.0)
|
110 |
+
*
|
111 |
+
* @param array $options Array of default options to set.
|
112 |
+
*/
|
113 |
Â
return apply_filters( 'bp_get_default_options', $options );
|
114 |
Â
}
|
115 |
Â
|
135 |
Â
bp_add_option( $key, $value );
|
136 |
Â
}
|
137 |
Â
|
138 |
+
/**
|
139 |
+
* Fires after the addition of default options when BuddyPress is first activated.
|
140 |
+
*
|
141 |
+
* Allows previously activated plugins to append their own options.
|
142 |
+
*
|
143 |
+
* @since BuddyPress (1.6.0)
|
144 |
+
*/
|
145 |
Â
do_action( 'bp_add_options' );
|
146 |
Â
}
|
147 |
Â
|
169 |
Â
delete_option( $key );
|
170 |
Â
}
|
171 |
Â
|
172 |
+
/**
|
173 |
+
* Fires after the deletion of default options when BuddyPress is first deactivated.
|
174 |
+
*
|
175 |
+
* Allows previously activated plugins to append their own options.
|
176 |
+
*
|
177 |
+
* @since BuddyPress (1.6.0)
|
178 |
+
*/
|
179 |
Â
do_action( 'bp_delete_options' );
|
180 |
Â
}
|
181 |
Â
|
200 |
Â
add_filter( 'pre_option_' . $key, 'bp_pre_get_option' );
|
201 |
Â
}
|
202 |
Â
|
203 |
+
/**
|
204 |
+
* Fires after the addition of filters to each BuddyPress option.
|
205 |
+
*
|
206 |
+
* Allows previously activated plugins to append their own options.
|
207 |
+
*
|
208 |
+
* @since BuddyPress (1.6.0)
|
209 |
+
*/
|
210 |
Â
do_action( 'bp_setup_option_filters' );
|
211 |
Â
}
|
212 |
Â
|
215 |
Â
*
|
216 |
Â
* Currently unused.
|
217 |
Â
*
|
218 |
+
* @since BuddyPress (1.6.0)
|
219 |
Â
*
|
220 |
Â
* @param bool $value Optional. Default value false
|
221 |
Â
* @return mixed false if not overloaded, mixed if set
|
246 |
Â
*
|
247 |
Â
* The 'bp_get_option' filter is primarily for backward-compatibility.
|
248 |
Â
*
|
249 |
+
* @since BuddyPress (1.2.0)
|
250 |
Â
*
|
251 |
Â
* @uses bp_get_root_blog_id()
|
252 |
Â
*
|
257 |
Â
*/
|
258 |
Â
function bp_get_option( $option_name, $default = '' ) {
|
259 |
Â
$value = get_blog_option( bp_get_root_blog_id(), $option_name, $default );
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Filters the option value for the requested option.
|
263 |
+
*
|
264 |
+
* @since BuddyPress (1.2.0)
|
265 |
+
*
|
266 |
+
* @param mixed $value The value for the option.
|
267 |
+
*/
|
268 |
Â
return apply_filters( 'bp_get_option', $value );
|
269 |
Â
}
|
270 |
Â
|
332 |
Â
* @deprecated 1.6.0
|
333 |
Â
*/
|
334 |
Â
function bp_core_activate_site_options( $keys = array() ) {
|
Â
|
|
335 |
Â
|
336 |
Â
if ( !empty( $keys ) && is_array( $keys ) ) {
|
337 |
+
$bp = buddypress();
|
338 |
+
|
339 |
Â
$errors = false;
|
340 |
Â
|
341 |
Â
foreach ( $keys as $key => $default ) {
|
390 |
Â
|
391 |
Â
// On Multisite installations, some options must always be fetched from sitemeta
|
392 |
Â
if ( is_multisite() ) {
|
393 |
+
|
394 |
+
/**
|
395 |
+
* Filters multisite options retrieved from sitemeta.
|
396 |
+
*
|
397 |
+
* @since BuddyPress (1.5.0)
|
398 |
+
*
|
399 |
+
* @param array $value Array of multisite options from sitemeta table.
|
400 |
+
*/
|
401 |
Â
$network_options = apply_filters( 'bp_core_network_options', array(
|
402 |
Â
'tags_blog_id' => '0',
|
403 |
Â
'sitewide_tags_blog' => '',
|
474 |
Â
wp_cache_set( 'root_blog_options', $root_blog_options_meta, 'bp' );
|
475 |
Â
}
|
476 |
Â
|
477 |
+
/**
|
478 |
+
* Filters the global BP options.
|
479 |
+
*
|
480 |
+
* @since BuddyPress (1.5.0)
|
481 |
+
*
|
482 |
+
* @param array $root_blog_options_meta Array of global BP options.
|
483 |
+
*/
|
484 |
Â
return apply_filters( 'bp_core_get_root_options', $root_blog_options_meta );
|
485 |
Â
}
|
486 |
Â
|
487 |
+
/**
|
488 |
+
* Get a root option.
|
489 |
+
*
|
490 |
+
* "Root options" are those that apply across an entire installation, and are fetched only a single
|
491 |
+
* time during a pageload and stored in `buddypress()->site_options` to prevent future lookups.
|
492 |
+
* See {@see bp_core_get_root_options()}.
|
493 |
+
*
|
494 |
+
* @since BuddyPress (2.3.0)
|
495 |
+
*
|
496 |
+
* @param string $option Name of the option key.
|
497 |
+
* @return mixed Value, if found.
|
498 |
+
*/
|
499 |
+
function bp_core_get_root_option( $option ) {
|
500 |
+
$bp = buddypress();
|
501 |
+
|
502 |
+
if ( ! isset( $bp->site_options ) ) {
|
503 |
+
$bp->site_options = bp_core_get_root_options();
|
504 |
+
}
|
505 |
+
|
506 |
+
$value = '';
|
507 |
+
if ( isset( $bp->site_options[ $option ] ) ) {
|
508 |
+
$value = $bp->site_options[ $option ];
|
509 |
+
}
|
510 |
+
|
511 |
+
return $value;
|
512 |
+
}
|
513 |
+
|
514 |
Â
/** Active? *******************************************************************/
|
515 |
Â
|
516 |
Â
/**
|
525 |
Â
* @return bool True if profile sync is enabled, otherwise false.
|
526 |
Â
*/
|
527 |
Â
function bp_disable_profile_sync( $default = false ) {
|
528 |
+
|
529 |
+
/**
|
530 |
+
* Filters whether or not profile syncing is disabled.
|
531 |
+
*
|
532 |
+
* @since BuddyPress (1.6.0)
|
533 |
+
*
|
534 |
+
* @param bool $value Whether or not syncing is disabled.
|
535 |
+
*/
|
536 |
Â
return (bool) apply_filters( 'bp_disable_profile_sync', (bool) bp_get_option( 'bp-disable-profile-sync', $default ) );
|
537 |
Â
}
|
538 |
Â
|
549 |
Â
* otherwise false.
|
550 |
Â
*/
|
551 |
Â
function bp_hide_loggedout_adminbar( $default = true ) {
|
552 |
+
|
553 |
+
/**
|
554 |
+
* Filters whether or not the toolbar is hidden for logged out users.
|
555 |
+
*
|
556 |
+
* @since BuddyPress (1.6.0)
|
557 |
+
*
|
558 |
+
* @param bool $value Whether or not the toolbar is hidden.
|
559 |
+
*/
|
560 |
Â
return (bool) apply_filters( 'bp_hide_loggedout_adminbar', (bool) bp_get_option( 'hide-loggedout-adminbar', $default ) );
|
561 |
Â
}
|
562 |
Â
|
572 |
Â
* @return bool True if avatar uploads are disabled, otherwise false.
|
573 |
Â
*/
|
574 |
Â
function bp_disable_avatar_uploads( $default = true ) {
|
575 |
+
|
576 |
+
/**
|
577 |
+
* Filters whether or not members are able to upload their own avatars.
|
578 |
+
*
|
579 |
+
* @since BuddyPress (1.6.0)
|
580 |
+
*
|
581 |
+
* @param bool $value Whether or not members are able to upload their own avatars.
|
582 |
+
*/
|
583 |
Â
return (bool) apply_filters( 'bp_disable_avatar_uploads', (bool) bp_get_option( 'bp-disable-avatar-uploads', $default ) );
|
584 |
Â
}
|
585 |
Â
|
586 |
+
/**
|
587 |
+
* Are group avatars disabled?
|
588 |
+
*
|
589 |
+
* For backward compatibility, this option falls back on the value of 'bp-disable-avatar-uploads' when no value is
|
590 |
+
* found in the database.
|
591 |
+
*
|
592 |
+
* @since BuddyPress (2.3.0)
|
593 |
+
*
|
594 |
+
* @param bool $default Optional. Fallback value if not found in the database.
|
595 |
+
* Defaults to the value of `bp_disable_avatar_uploads()`.
|
596 |
+
* @return bool True if group avatar uploads are disabled, otherwise false.
|
597 |
+
*/
|
598 |
+
function bp_disable_group_avatar_uploads( $default = null ) {
|
599 |
+
$disabled = bp_get_option( 'bp-disable-group-avatar-uploads', '' );
|
600 |
+
|
601 |
+
if ( '' === $disabled ) {
|
602 |
+
if ( is_null( $default ) ) {
|
603 |
+
$disabled = bp_disable_avatar_uploads();
|
604 |
+
} else {
|
605 |
+
$disabled = $default;
|
606 |
+
}
|
607 |
+
}
|
608 |
+
|
609 |
+
/**
|
610 |
+
* Filters whether or not members are able to upload group avatars.
|
611 |
+
*
|
612 |
+
* @since BuddyPress (2.3.0)
|
613 |
+
*
|
614 |
+
* @param bool $disabled Whether or not members are able to upload their groups avatars.
|
615 |
+
* @param bool $default Default value passed to the function.
|
616 |
+
*/
|
617 |
+
return (bool) apply_filters( 'bp_disable_group_avatar_uploads', $disabled, $default );
|
618 |
+
}
|
619 |
+
|
620 |
Â
/**
|
621 |
Â
* Are members able to delete their own accounts?
|
622 |
Â
*
|
630 |
Â
* false.
|
631 |
Â
*/
|
632 |
Â
function bp_disable_account_deletion( $default = false ) {
|
633 |
+
|
634 |
+
/**
|
635 |
+
* Filters whether or not members are able to delete their own accounts.
|
636 |
+
*
|
637 |
+
* @since BuddyPress (1.6.0)
|
638 |
+
*
|
639 |
+
* @param bool $value Whether or not members are able to delete their own accounts.
|
640 |
+
*/
|
641 |
Â
return apply_filters( 'bp_disable_account_deletion', (bool) bp_get_option( 'bp-disable-account-deletion', $default ) );
|
642 |
Â
}
|
643 |
Â
|
655 |
Â
* items, otherwise false.
|
656 |
Â
*/
|
657 |
Â
function bp_disable_blogforum_comments( $default = false ) {
|
658 |
+
|
659 |
+
/**
|
660 |
+
* Filters whether or not blog and forum activity stream comments are disabled.
|
661 |
+
*
|
662 |
+
* @since BuddyPress (1.6.0)
|
663 |
+
*
|
664 |
+
* @param bool $value Whether or not blog and forum activity stream comments are disabled.
|
665 |
+
*/
|
666 |
Â
return (bool) apply_filters( 'bp_disable_blogforum_comments', (bool) bp_get_option( 'bp-disable-blogforum-comments', $default ) );
|
667 |
Â
}
|
668 |
Â
|
679 |
Â
* @return bool True if group creation is restricted, otherwise false.
|
680 |
Â
*/
|
681 |
Â
function bp_restrict_group_creation( $default = true ) {
|
682 |
+
|
683 |
+
/**
|
684 |
+
* Filters whether or not group creation is turned off.
|
685 |
+
*
|
686 |
+
* @since BuddyPress (1.6.0)
|
687 |
+
*
|
688 |
+
* @param bool $value Whether or not group creation is turned off.
|
689 |
+
*/
|
690 |
Â
return (bool) apply_filters( 'bp_restrict_group_creation', (bool) bp_get_option( 'bp_restrict_group_creation', $default ) );
|
691 |
Â
}
|
692 |
Â
|
702 |
Â
* @return bool True if the BuddyBar should be forced on, otherwise false.
|
703 |
Â
*/
|
704 |
Â
function bp_force_buddybar( $default = true ) {
|
705 |
+
|
706 |
+
/**
|
707 |
+
* Filters whether or not BuddyBar should be forced in place of WP Admin Bar.
|
708 |
+
*
|
709 |
+
* @since BuddyPress (1.6.0)
|
710 |
+
*
|
711 |
+
* @param bool $value Whether or not BuddyBar should be forced in place of WP Admin Bar.
|
712 |
+
*/
|
713 |
Â
return (bool) apply_filters( 'bp_force_buddybar', (bool) bp_get_option( '_bp_force_buddybar', $default ) );
|
714 |
Â
}
|
715 |
Â
|
734 |
Â
* @return int The ID of the group forums root forum.
|
735 |
Â
*/
|
736 |
Â
function bp_get_group_forums_root_id( $default = '0' ) {
|
737 |
+
|
738 |
+
/**
|
739 |
+
* Filters the group forums root parent forum id.
|
740 |
+
*
|
741 |
+
* @since BuddyPress (1.6.0)
|
742 |
+
*
|
743 |
+
* @param int $value The group forums root parent forum id.
|
744 |
+
*/
|
745 |
Â
return (int) apply_filters( 'bp_get_group_forums_root_id', (int) bp_get_option( '_bp_group_forums_root_id', $default ) );
|
746 |
Â
}
|
747 |
Â
|
757 |
Â
* @return bool True if group forums are active, otherwise false.
|
758 |
Â
*/
|
759 |
Â
function bp_is_group_forums_active( $default = true ) {
|
760 |
+
|
761 |
+
/**
|
762 |
+
* Filters whether or not BuddyPress Group Forums are enabled.
|
763 |
+
*
|
764 |
+
* @since BuddyPress (1.6.0)
|
765 |
+
*
|
766 |
+
* @param bool $value Whether or not BuddyPress Group Forums are enabled.
|
767 |
+
*/
|
768 |
Â
return (bool) apply_filters( 'bp_is_group_forums_active', (bool) bp_get_option( '_bp_enable_group_forums', $default ) );
|
769 |
Â
}
|
770 |
Â
|
780 |
Â
* @return bool True if Akismet is enabled, otherwise false.
|
781 |
Â
*/
|
782 |
Â
function bp_is_akismet_active( $default = true ) {
|
783 |
+
|
784 |
+
/**
|
785 |
+
* Filters whether or not Akismet is enabled.
|
786 |
+
*
|
787 |
+
* @since BuddyPress (1.6.0)
|
788 |
+
*
|
789 |
+
* @param bool $value Whether or not Akismet is enabled.
|
790 |
+
*/
|
791 |
Â
return (bool) apply_filters( 'bp_is_akismet_active', (bool) bp_get_option( '_bp_enable_akismet', $default ) );
|
792 |
Â
}
|
793 |
Â
|
803 |
Â
* @return bool True if Heartbeat refresh is enabled, otherwise false.
|
804 |
Â
*/
|
805 |
Â
function bp_is_activity_heartbeat_active( $default = true ) {
|
806 |
+
|
807 |
+
/**
|
808 |
+
* Filters whether or not Activity Heartbeat refresh is enabled.
|
809 |
+
*
|
810 |
+
* @since BuddyPress (2.0.0)
|
811 |
+
*
|
812 |
+
* @param bool $value Whether or not Activity Heartbeat refresh is enabled.
|
813 |
+
*/
|
814 |
Â
return (bool) apply_filters( 'bp_is_activity_heartbeat_active', (bool) bp_get_option( '_bp_enable_heartbeat_refresh', $default ) );
|
815 |
Â
}
|
816 |
Â
|
826 |
Â
* @return string ID of the theme package.
|
827 |
Â
*/
|
828 |
Â
function bp_get_theme_package_id( $default = 'legacy' ) {
|
829 |
+
|
830 |
+
/**
|
831 |
+
* Filters the current theme package ID.
|
832 |
+
*
|
833 |
+
* @since BuddyPress (1.7.0)
|
834 |
+
*
|
835 |
+
* @param string $value The current theme package ID.
|
836 |
+
*/
|
837 |
Â
return apply_filters( 'bp_get_theme_package_id', bp_get_option( '_bp_theme_package_id', $default ) );
|
838 |
Â
}
|
bp-core/bp-core-taxonomy.php
CHANGED
@@ -79,3 +79,31 @@ function bp_get_object_terms( $object_ids, $taxonomies, $args = array() ) {
|
|
79 |
Â
|
80 |
Â
return $retval;
|
81 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
79 |
Â
|
80 |
Â
return $retval;
|
81 |
Â
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Remove taxonomy terms on a BuddyPress object.
|
85 |
+
*
|
86 |
+
* @since BuddyPress (2.3.0)
|
87 |
+
*
|
88 |
+
* @see wp_remove_object_terms() for a full description of function and parameters.
|
89 |
+
*
|
90 |
+
* @param int $object_id Object ID.
|
91 |
+
* @param string|array $terms Term or terms to remove.
|
92 |
+
* @param string $taxonomy Taxonomy name.
|
93 |
+
* @return bool|WP_Error True on success, false or WP_Error on failure.
|
94 |
+
*/
|
95 |
+
function bp_remove_object_terms( $object_id, $terms, $taxonomy ) {
|
96 |
+
$is_root_blog = bp_is_root_blog();
|
97 |
+
|
98 |
+
if ( ! $is_root_blog ) {
|
99 |
+
switch_to_blog( bp_get_root_blog_id() );
|
100 |
+
}
|
101 |
+
|
102 |
+
$retval = wp_remove_object_terms( $object_id, $terms, $taxonomy );
|
103 |
+
|
104 |
+
if ( ! $is_root_blog ) {
|
105 |
+
restore_current_blog();
|
106 |
+
}
|
107 |
+
|
108 |
+
return $retval;
|
109 |
+
}
|
bp-core/bp-core-template-loader.php
CHANGED
@@ -32,6 +32,16 @@ defined( 'ABSPATH' ) || exit;
|
|
32 |
Â
function bp_get_template_part( $slug, $name = null ) {
|
33 |
Â
|
34 |
Â
// Execute code for this part
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
35 |
Â
do_action( 'get_template_part_' . $slug, $slug, $name );
|
36 |
Â
|
37 |
Â
// Setup possible parts
|
@@ -42,6 +52,15 @@ function bp_get_template_part( $slug, $name = null ) {
|
|
42 |
Â
$templates[] = $slug . '.php';
|
43 |
Â
|
44 |
Â
// Allow template parts to be filtered
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
45 |
Â
$templates = apply_filters( 'bp_get_template_part', $templates, $slug, $name );
|
46 |
Â
|
47 |
Â
// Return the part that is found
|
@@ -215,6 +234,13 @@ function bp_get_template_stack() {
|
|
215 |
Â
// Remove empties and duplicates
|
216 |
Â
$stack = array_unique( array_filter( $stack ) );
|
217 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
218 |
Â
return (array) apply_filters( 'bp_get_template_stack', $stack ) ;
|
219 |
Â
}
|
220 |
Â
|
@@ -278,20 +304,41 @@ function bp_get_query_template( $type, $templates = array() ) {
|
|
278 |
Â
$templates = array( "{$type}.php" );
|
279 |
Â
}
|
280 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
281 |
Â
// Filter possible templates, try to match one, and set any BuddyPress theme
|
282 |
Â
// compat properties so they can be cross-checked later.
|
283 |
-
$templates = apply_filters( "bp_get_{$type}_template", $templates );
|
284 |
Â
$templates = bp_set_theme_compat_templates( $templates );
|
285 |
Â
$template = bp_locate_template( $templates );
|
286 |
Â
$template = bp_set_theme_compat_template( $template );
|
287 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
288 |
Â
return apply_filters( "bp_{$type}_template", $template );
|
289 |
Â
}
|
290 |
Â
|
291 |
Â
/**
|
292 |
Â
* Get the possible subdirectories to check for templates in
|
293 |
Â
*
|
294 |
-
* @since BuddyPress (1.7)
|
295 |
Â
* @param array $templates Templates we are looking for
|
296 |
Â
* @return array Possible subfolders to look in
|
297 |
Â
*/
|
@@ -301,6 +348,15 @@ function bp_get_template_locations( $templates = array() ) {
|
|
301 |
Â
'community',
|
302 |
Â
''
|
303 |
Â
);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
304 |
Â
return apply_filters( 'bp_get_template_locations', $locations, $templates );
|
305 |
Â
}
|
306 |
Â
|
@@ -325,6 +381,14 @@ function bp_add_template_stack_locations( $stacks = array() ) {
|
|
325 |
Â
}
|
326 |
Â
}
|
327 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
328 |
Â
return apply_filters( 'bp_add_template_stack_locations', array_unique( $retval ), $stacks );
|
329 |
Â
}
|
330 |
Â
|
@@ -352,7 +416,15 @@ function bp_parse_query( $posts_query ) {
|
|
352 |
Â
return;
|
353 |
Â
}
|
354 |
Â
|
355 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
356 |
Â
do_action_ref_array( 'bp_parse_query', array( &$posts_query ) );
|
357 |
Â
}
|
358 |
Â
|
@@ -373,7 +445,14 @@ function bp_parse_query( $posts_query ) {
|
|
373 |
Â
*/
|
374 |
Â
function bp_template_include_theme_supports( $template = '' ) {
|
375 |
Â
|
376 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
377 |
Â
$new_template = apply_filters( 'bp_get_root_template', false, $template );
|
378 |
Â
|
379 |
Â
// A BuddyPress template file was located, so override the WordPress
|
@@ -382,6 +461,13 @@ function bp_template_include_theme_supports( $template = '' ) {
|
|
382 |
Â
$template = bp_set_template_included( $new_template );
|
383 |
Â
}
|
384 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
385 |
Â
return apply_filters( 'bp_template_include_theme_supports', $template );
|
386 |
Â
}
|
387 |
Â
|
32 |
Â
function bp_get_template_part( $slug, $name = null ) {
|
33 |
Â
|
34 |
Â
// Execute code for this part
|
35 |
+
/**
|
36 |
+
* Fires at the start of bp_get_template_part().
|
37 |
+
*
|
38 |
+
* This is a variable hook that is dependent on the slug passed in.
|
39 |
+
*
|
40 |
+
* @since BuddyPress (1.7.0)
|
41 |
+
*
|
42 |
+
* @param string $slug Template part slug requested.
|
43 |
+
* @param string $name Template part name requested.
|
44 |
+
*/
|
45 |
Â
do_action( 'get_template_part_' . $slug, $slug, $name );
|
46 |
Â
|
47 |
Â
// Setup possible parts
|
52 |
Â
$templates[] = $slug . '.php';
|
53 |
Â
|
54 |
Â
// Allow template parts to be filtered
|
55 |
+
/**
|
56 |
+
* Filters the template parts to be loaded.
|
57 |
+
*
|
58 |
+
* @since BuddyPress (1.7.0)
|
59 |
+
*
|
60 |
+
* @param array $templates Array of templates located.
|
61 |
+
* @param string $slug Template part slug requested.
|
62 |
+
* @param string $name Template part name requested.
|
63 |
+
*/
|
64 |
Â
$templates = apply_filters( 'bp_get_template_part', $templates, $slug, $name );
|
65 |
Â
|
66 |
Â
// Return the part that is found
|
234 |
Â
// Remove empties and duplicates
|
235 |
Â
$stack = array_unique( array_filter( $stack ) );
|
236 |
Â
|
237 |
+
/**
|
238 |
+
* Filters the "template stack" list of registered directories where templates can be found.
|
239 |
+
*
|
240 |
+
* @since BuddyPress (1.7.0)
|
241 |
+
*
|
242 |
+
* @param array $stack Array of registered directories for template locations.
|
243 |
+
*/
|
244 |
Â
return (array) apply_filters( 'bp_get_template_stack', $stack ) ;
|
245 |
Â
}
|
246 |
Â
|
304 |
Â
$templates = array( "{$type}.php" );
|
305 |
Â
}
|
306 |
Â
|
307 |
+
/**
|
308 |
+
* Filters possible file paths to check for for a template.
|
309 |
+
*
|
310 |
+
* This is a variable filter based on the type passed into
|
311 |
+
* bp_get_query_template.
|
312 |
+
*
|
313 |
+
* @since BuddyPress (1.7.0)
|
314 |
+
*
|
315 |
+
* @param array $templates Array of template files already prepared.
|
316 |
+
*/
|
317 |
+
$templates = apply_filters( "bp_get_{$type}_template", $templates );
|
318 |
+
|
319 |
Â
// Filter possible templates, try to match one, and set any BuddyPress theme
|
320 |
Â
// compat properties so they can be cross-checked later.
|
Â
|
|
321 |
Â
$templates = bp_set_theme_compat_templates( $templates );
|
322 |
Â
$template = bp_locate_template( $templates );
|
323 |
Â
$template = bp_set_theme_compat_template( $template );
|
324 |
Â
|
325 |
+
/**
|
326 |
+
* Filters the path to a template file.
|
327 |
+
*
|
328 |
+
* This is a variable filter based on the type passed into
|
329 |
+
* bp_get_query_template.
|
330 |
+
*
|
331 |
+
* @since BuddyPress (1.7.0)
|
332 |
+
*
|
333 |
+
* @param string $template Path to the most appropriate found template file.
|
334 |
+
*/
|
335 |
Â
return apply_filters( "bp_{$type}_template", $template );
|
336 |
Â
}
|
337 |
Â
|
338 |
Â
/**
|
339 |
Â
* Get the possible subdirectories to check for templates in
|
340 |
Â
*
|
341 |
+
* @since BuddyPress (1.7.0)
|
342 |
Â
* @param array $templates Templates we are looking for
|
343 |
Â
* @return array Possible subfolders to look in
|
344 |
Â
*/
|
348 |
Â
'community',
|
349 |
Â
''
|
350 |
Â
);
|
351 |
+
|
352 |
+
/**
|
353 |
+
* Filters the possible subdirectories to check for templates in.
|
354 |
+
*
|
355 |
+
* @since BuddyPress (1.7.0)
|
356 |
+
*
|
357 |
+
* @param array $locations Array of subfolders to look in.
|
358 |
+
* @param array $templates Array of templates we are looking for.
|
359 |
+
*/
|
360 |
Â
return apply_filters( 'bp_get_template_locations', $locations, $templates );
|
361 |
Â
}
|
362 |
Â
|
381 |
Â
}
|
382 |
Â
}
|
383 |
Â
|
384 |
+
/**
|
385 |
+
* Filters the template locations to template files being searched for.
|
386 |
+
*
|
387 |
+
* @since BuddyPress (1.7.0)
|
388 |
+
*
|
389 |
+
* @param array $value Array of all template locations registered so far.
|
390 |
+
* @param array $stacks Array of template locations.
|
391 |
+
*/
|
392 |
Â
return apply_filters( 'bp_add_template_stack_locations', array_unique( $retval ), $stacks );
|
393 |
Â
}
|
394 |
Â
|
416 |
Â
return;
|
417 |
Â
}
|
418 |
Â
|
419 |
+
/**
|
420 |
+
* Fires at the end of the bp_parse_query function.
|
421 |
+
*
|
422 |
+
* Allow BuddyPress components to parse the main query.
|
423 |
+
*
|
424 |
+
* @since BuddyPress (1.7.0)
|
425 |
+
*
|
426 |
+
* @param WP_Query $posts_query WP_Query instance. Passed by reference.
|
427 |
+
*/
|
428 |
Â
do_action_ref_array( 'bp_parse_query', array( &$posts_query ) );
|
429 |
Â
}
|
430 |
Â
|
445 |
Â
*/
|
446 |
Â
function bp_template_include_theme_supports( $template = '' ) {
|
447 |
Â
|
448 |
+
/**
|
449 |
+
* Filters whether or not to override the template being loaded in parent/child themes.
|
450 |
+
*
|
451 |
+
* @since BuddyPress (1.7.0)
|
452 |
+
*
|
453 |
+
* @param bool $value Whether or not there is a file override. Default false.
|
454 |
+
* @param string $template The path to the template file that is being used.
|
455 |
+
*/
|
456 |
Â
$new_template = apply_filters( 'bp_get_root_template', false, $template );
|
457 |
Â
|
458 |
Â
// A BuddyPress template file was located, so override the WordPress
|
461 |
Â
$template = bp_set_template_included( $new_template );
|
462 |
Â
}
|
463 |
Â
|
464 |
+
/**
|
465 |
+
* Filters the final template being loaded in parent/child themes.
|
466 |
+
*
|
467 |
+
* @since BuddyPress (1.7.0)
|
468 |
+
*
|
469 |
+
* @param string $template The path to the template file that is being used.
|
470 |
+
*/
|
471 |
Â
return apply_filters( 'bp_template_include_theme_supports', $template );
|
472 |
Â
}
|
473 |
Â
|
bp-core/bp-core-template.php
CHANGED
@@ -71,8 +71,18 @@ function bp_get_options_nav( $parent_slug = '' ) {
|
|
71 |
Â
// List type depends on our current component
|
72 |
Â
$list_type = bp_is_group() ? 'groups' : 'personal';
|
73 |
Â
|
74 |
-
|
75 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
76 |
Â
}
|
77 |
Â
}
|
78 |
Â
|
@@ -114,6 +124,14 @@ function bp_get_directory_title( $component = '' ) {
|
|
114 |
Â
$title = sprintf( __( '%s Directory', 'buddypress' ), buddypress()->{$component}->name );
|
115 |
Â
}
|
116 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
117 |
Â
return apply_filters( 'bp_get_directory_title', $title, $component );
|
118 |
Â
}
|
119 |
Â
|
@@ -200,6 +218,13 @@ function bp_avatar_admin_step() {
|
|
200 |
Â
? $step = $bp->avatar_admin->step
|
201 |
Â
: 'upload-image';
|
202 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
203 |
Â
return apply_filters( 'bp_get_avatar_admin_step', $step );
|
204 |
Â
}
|
205 |
Â
|
@@ -220,6 +245,13 @@ function bp_avatar_to_crop() {
|
|
220 |
Â
? $bp->avatar_admin->image->url
|
221 |
Â
: '';
|
222 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
223 |
Â
return apply_filters( 'bp_get_avatar_to_crop', $url );
|
224 |
Â
}
|
225 |
Â
|
@@ -240,6 +272,13 @@ function bp_avatar_to_crop_src() {
|
|
240 |
Â
? str_replace( WP_CONTENT_DIR, '', $bp->avatar_admin->image->dir )
|
241 |
Â
: '';
|
242 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
243 |
Â
return apply_filters( 'bp_get_avatar_to_crop_src', $src );
|
244 |
Â
}
|
245 |
Â
|
@@ -268,49 +307,96 @@ function bp_site_name() {
|
|
268 |
Â
* @since BuddyPress (1.6.0)
|
269 |
Â
*/
|
270 |
Â
function bp_get_site_name() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
271 |
Â
return apply_filters( 'bp_site_name', get_bloginfo( 'name', 'display' ) );
|
272 |
Â
}
|
273 |
Â
|
274 |
Â
/**
|
275 |
-
* Format a date
|
276 |
Â
*
|
277 |
-
*
|
278 |
-
*
|
279 |
-
*
|
280 |
-
*
|
281 |
-
*
|
282 |
-
*
|
283 |
-
*
|
284 |
-
*
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
285 |
Â
*/
|
286 |
-
function bp_format_time( $time, $
|
287 |
Â
|
288 |
-
|
Â
|
|
Â
|
|
289 |
Â
return false;
|
290 |
Â
}
|
291 |
Â
|
292 |
Â
// Get GMT offset from root blog
|
293 |
-
$
|
294 |
-
|
295 |
-
|
296 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
297 |
Â
|
298 |
-
//
|
299 |
-
|
Â
|
|
Â
|
|
300 |
Â
|
301 |
-
//
|
302 |
-
$
|
303 |
Â
|
304 |
Â
// Should we show the time also?
|
305 |
-
if (
|
306 |
-
|
307 |
-
|
Â
|
|
308 |
Â
|
309 |
Â
// Return string formatted with date and time
|
310 |
-
$
|
311 |
Â
}
|
312 |
Â
|
313 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
314 |
Â
}
|
315 |
Â
|
316 |
Â
/**
|
@@ -339,8 +425,18 @@ function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true
|
|
339 |
Â
|
340 |
Â
if ( bp_displayed_user_id() == bp_loggedin_user_id() ) {
|
341 |
Â
if ( true == $echo ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
342 |
Â
echo apply_filters( 'bp_word_or_name', $youtext );
|
343 |
Â
} else {
|
Â
|
|
Â
|
|
344 |
Â
return apply_filters( 'bp_word_or_name', $youtext );
|
345 |
Â
}
|
346 |
Â
} else {
|
@@ -348,8 +444,12 @@ function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true
|
|
348 |
Â
$fullname = (array) explode( ' ', $fullname );
|
349 |
Â
$nametext = sprintf( $nametext, $fullname[0] );
|
350 |
Â
if ( true == $echo ) {
|
Â
|
|
Â
|
|
351 |
Â
echo apply_filters( 'bp_word_or_name', $nametext );
|
352 |
Â
} else {
|
Â
|
|
Â
|
|
353 |
Â
return apply_filters( 'bp_word_or_name', $nametext );
|
354 |
Â
}
|
355 |
Â
}
|
@@ -375,6 +475,14 @@ function bp_styles() {
|
|
375 |
Â
* @return string URL action attribute for search forms, eg example.com/search/.
|
376 |
Â
*/
|
377 |
Â
function bp_search_form_action() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
378 |
Â
return apply_filters( 'bp_search_form_action', trailingslashit( bp_get_root_domain() . '/' . bp_get_search_slug() ) );
|
379 |
Â
}
|
380 |
Â
|
@@ -411,6 +519,13 @@ function bp_search_form_type_select() {
|
|
411 |
Â
$selection_box = '<label for="search-which" class="accessibly-hidden">' . _x( 'Search these:', 'search form', 'buddypress' ) . '</label>';
|
412 |
Â
$selection_box .= '<select name="search-which" id="search-which" style="width: auto">';
|
413 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
414 |
Â
$options = apply_filters( 'bp_search_form_type_select_options', $options );
|
415 |
Â
foreach( (array) $options as $option_value => $option_title ) {
|
416 |
Â
$selection_box .= sprintf( '<option value="%s">%s</option>', $option_value, $option_title );
|
@@ -418,6 +533,13 @@ function bp_search_form_type_select() {
|
|
418 |
Â
|
419 |
Â
$selection_box .= '</select>';
|
420 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
421 |
Â
return apply_filters( 'bp_search_form_type_select', $selection_box );
|
422 |
Â
}
|
423 |
Â
|
@@ -442,7 +564,8 @@ function bp_search_default_text( $component = '' ) {
|
|
442 |
Â
* @return string Placeholder text for search field.
|
443 |
Â
*/
|
444 |
Â
function bp_get_search_default_text( $component = '' ) {
|
445 |
-
|
Â
|
|
446 |
Â
|
447 |
Â
if ( empty( $component ) ) {
|
448 |
Â
$component = bp_current_component();
|
@@ -466,6 +589,14 @@ function bp_search_default_text( $component = '' ) {
|
|
466 |
Â
}
|
467 |
Â
}
|
468 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
469 |
Â
return apply_filters( 'bp_get_search_default_text', $default_text, $component );
|
470 |
Â
}
|
471 |
Â
|
@@ -585,6 +716,16 @@ function bp_button( $args = '' ) {
|
|
585 |
Â
*/
|
586 |
Â
function bp_get_button( $args = '' ) {
|
587 |
Â
$button = new BP_Button( $args );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
588 |
Â
return apply_filters( 'bp_get_button', $button->contents, $args, $button );
|
589 |
Â
}
|
590 |
Â
|
@@ -635,8 +776,22 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
|
|
635 |
Â
// Save the original text, to be passed along to the filter
|
636 |
Â
$original_text = $text;
|
637 |
Â
|
638 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
639 |
Â
$length = apply_filters( 'bp_excerpt_length', $length );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
640 |
Â
$ending = apply_filters( 'bp_excerpt_append_text', $r['ending'] );
|
641 |
Â
|
642 |
Â
// Remove shortcodes if necessary
|
@@ -657,10 +812,10 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
|
|
657 |
Â
$openTags = array();
|
658 |
Â
$truncate = '';
|
659 |
Â
|
660 |
-
// Find all the tags and put them in a stack for later use
|
661 |
-
preg_match_all( '/(<\/?([\w
|
662 |
-
foreach ( $tags as $tag ) {
|
663 |
Â
|
Â
|
|
664 |
Â
// Process tags that need to be closed
|
665 |
Â
if ( !preg_match( '/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/s', $tag[2] ) ) {
|
666 |
Â
if ( preg_match( '/<[\w]+[^>]*>/s', $tag[0] ) ) {
|
@@ -710,21 +865,70 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
|
|
710 |
Â
|
711 |
Â
// If $exact is false, we can't break on words
|
712 |
Â
if ( empty( $r['exact'] ) ) {
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
723 |
Â
}
|
724 |
Â
}
|
725 |
Â
}
|
726 |
-
$truncate = mb_substr( $truncate, 0, $spacepos );
|
727 |
Â
}
|
Â
|
|
Â
|
|
728 |
Â
}
|
729 |
Â
$truncate .= $ending;
|
730 |
Â
|
@@ -734,6 +938,16 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
|
|
734 |
Â
}
|
735 |
Â
}
|
736 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
737 |
Â
return apply_filters( 'bp_create_excerpt', $truncate, $original_text, $length, $options );
|
738 |
Â
}
|
739 |
Â
add_filter( 'bp_create_excerpt', 'stripslashes_deep' );
|
@@ -760,6 +974,14 @@ function bp_total_member_count() {
|
|
760 |
Â
* @return int Member count.
|
761 |
Â
*/
|
762 |
Â
function bp_get_total_member_count() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
763 |
Â
return apply_filters( 'bp_get_total_member_count', bp_core_get_active_member_count() );
|
764 |
Â
}
|
765 |
Â
add_filter( 'bp_get_total_member_count', 'bp_core_number_format' );
|
@@ -786,7 +1008,7 @@ function bp_blog_signup_allowed() {
|
|
786 |
Â
return false;
|
787 |
Â
}
|
788 |
Â
|
789 |
-
$status =
|
790 |
Â
if ( ( 'none' !== $status ) && ( 'user' !== $status ) ) {
|
791 |
Â
return true;
|
792 |
Â
}
|
@@ -819,6 +1041,14 @@ function bp_account_was_activated() {
|
|
819 |
Â
* @return bool True by default.
|
820 |
Â
*/
|
821 |
Â
function bp_registration_needs_activation() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
822 |
Â
return apply_filters( 'bp_registration_needs_activation', true );
|
823 |
Â
}
|
824 |
Â
|
@@ -830,7 +1060,7 @@ function bp_registration_needs_activation() {
|
|
830 |
Â
*
|
831 |
Â
* @since BuddyPress (1.7.0)
|
832 |
Â
*
|
833 |
-
* @see
|
834 |
Â
*
|
835 |
Â
* @param array $args {
|
836 |
Â
* Array of optional parameters.
|
@@ -856,6 +1086,14 @@ function bp_get_email_subject( $args = array() ) {
|
|
856 |
Â
|
857 |
Â
$subject = $r['before'] . wp_specialchars_decode( bp_get_option( 'blogname', $r['default'] ), ENT_QUOTES ) . $r['after'] . ' ' . $r['text'];
|
858 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
859 |
Â
return apply_filters( 'bp_get_email_subject', $subject, $r );
|
860 |
Â
}
|
861 |
Â
|
@@ -879,6 +1117,16 @@ function bp_ajax_querystring( $object = false ) {
|
|
879 |
Â
$bp->ajax_querystring = '';
|
880 |
Â
}
|
881 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
882 |
Â
return apply_filters( 'bp_ajax_querystring', $bp->ajax_querystring, $object );
|
883 |
Â
}
|
884 |
Â
|
@@ -895,6 +1143,13 @@ function bp_current_component() {
|
|
895 |
Â
? $bp->current_component
|
896 |
Â
: false;
|
897 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
898 |
Â
return apply_filters( 'bp_current_component', $current_component );
|
899 |
Â
}
|
900 |
Â
|
@@ -909,6 +1164,13 @@ function bp_current_action() {
|
|
909 |
Â
? $bp->current_action
|
910 |
Â
: '';
|
911 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
912 |
Â
return apply_filters( 'bp_current_action', $current_action );
|
913 |
Â
}
|
914 |
Â
|
@@ -923,6 +1185,13 @@ function bp_current_item() {
|
|
923 |
Â
? $bp->current_item
|
924 |
Â
: false;
|
925 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
926 |
Â
return apply_filters( 'bp_current_item', $current_item );
|
927 |
Â
}
|
928 |
Â
|
@@ -938,6 +1207,13 @@ function bp_action_variables() {
|
|
938 |
Â
? $bp->action_variables
|
939 |
Â
: false;
|
940 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
941 |
Â
return apply_filters( 'bp_action_variables', $action_variables );
|
942 |
Â
}
|
943 |
Â
|
@@ -956,6 +1232,14 @@ function bp_action_variable( $position = 0 ) {
|
|
956 |
Â
? $action_variables[ $position ]
|
957 |
Â
: false;
|
958 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
959 |
Â
return apply_filters( 'bp_action_variable', $action_variable, $position );
|
960 |
Â
}
|
961 |
Â
|
@@ -980,6 +1264,13 @@ function bp_root_domain() {
|
|
980 |
Â
$bp->root_domain = $domain;
|
981 |
Â
}
|
982 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
983 |
Â
return apply_filters( 'bp_get_root_domain', $domain );
|
984 |
Â
}
|
985 |
Â
|
@@ -1052,6 +1343,14 @@ function bp_root_slug( $component = '' ) {
|
|
1052 |
Â
$root_slug = $component;
|
1053 |
Â
}
|
1054 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1055 |
Â
return apply_filters( 'bp_get_root_slug', $root_slug, $component );
|
1056 |
Â
}
|
1057 |
Â
|
@@ -1091,6 +1390,13 @@ function bp_user_has_access() {
|
|
1091 |
Â
? true
|
1092 |
Â
: false;
|
1093 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1094 |
Â
return (bool) apply_filters( 'bp_user_has_access', $has_access );
|
1095 |
Â
}
|
1096 |
Â
|
@@ -1112,6 +1418,14 @@ function bp_search_slug() {
|
|
1112 |
Â
* @return string The search slug. Default: 'search'.
|
1113 |
Â
*/
|
1114 |
Â
function bp_get_search_slug() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1115 |
Â
return apply_filters( 'bp_get_search_slug', BP_SEARCH_SLUG );
|
1116 |
Â
}
|
1117 |
Â
|
@@ -1128,6 +1442,13 @@ function bp_displayed_user_id() {
|
|
1128 |
Â
? $bp->displayed_user->id
|
1129 |
Â
: 0;
|
1130 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1131 |
Â
return (int) apply_filters( 'bp_displayed_user_id', $id );
|
1132 |
Â
}
|
1133 |
Â
|
@@ -1144,6 +1465,13 @@ function bp_loggedin_user_id() {
|
|
1144 |
Â
? $bp->loggedin_user->id
|
1145 |
Â
: 0;
|
1146 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1147 |
Â
return (int) apply_filters( 'bp_loggedin_user_id', $id );
|
1148 |
Â
}
|
1149 |
Â
|
@@ -1223,6 +1551,14 @@ function bp_is_current_component( $component = '' ) {
|
|
1223 |
Â
}
|
1224 |
Â
}
|
1225 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1226 |
Â
return apply_filters( 'bp_is_current_component', $is_current_component, $component );
|
1227 |
Â
}
|
1228 |
Â
|
@@ -1284,6 +1620,15 @@ function bp_is_action_variable( $action_variable = '', $position = false ) {
|
|
1284 |
Â
$is_action_variable = in_array( $action_variable, (array)bp_action_variables() );
|
1285 |
Â
}
|
1286 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1287 |
Â
return apply_filters( 'bp_is_action_variable', $is_action_variable, $action_variable, $position );
|
1288 |
Â
}
|
1289 |
Â
|
@@ -1296,6 +1641,14 @@ function bp_is_action_variable( $action_variable = '', $position = false ) {
|
|
1296 |
Â
function bp_is_current_item( $item = '' ) {
|
1297 |
Â
$retval = ( $item === bp_current_item() );
|
1298 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1299 |
Â
return (bool) apply_filters( 'bp_is_current_item', $retval, $item );
|
1300 |
Â
}
|
1301 |
Â
|
@@ -1312,6 +1665,13 @@ function bp_is_single_item() {
|
|
1312 |
Â
$retval = $bp->is_single_item;
|
1313 |
Â
}
|
1314 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1315 |
Â
return (bool) apply_filters( 'bp_is_single_item', $retval );
|
1316 |
Â
}
|
1317 |
Â
|
@@ -1329,6 +1689,13 @@ function bp_is_item_admin() {
|
|
1329 |
Â
$retval = $bp->is_item_admin;
|
1330 |
Â
}
|
1331 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1332 |
Â
return (bool) apply_filters( 'bp_is_item_admin', $retval );
|
1333 |
Â
}
|
1334 |
Â
|
@@ -1346,6 +1713,13 @@ function bp_is_item_mod() {
|
|
1346 |
Â
$retval = $bp->is_item_mod;
|
1347 |
Â
}
|
1348 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1349 |
Â
return (bool) apply_filters( 'bp_is_item_mod', $retval );
|
1350 |
Â
}
|
1351 |
Â
|
@@ -1363,6 +1737,13 @@ function bp_is_directory() {
|
|
1363 |
Â
$retval = $bp->is_directory;
|
1364 |
Â
}
|
1365 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1366 |
Â
return (bool) apply_filters( 'bp_is_directory', $retval );
|
1367 |
Â
}
|
1368 |
Â
|
@@ -1396,6 +1777,13 @@ function bp_is_root_component( $component_name = '' ) {
|
|
1396 |
Â
}
|
1397 |
Â
}
|
1398 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1399 |
Â
return (bool) apply_filters( 'bp_is_root_component', $retval );
|
1400 |
Â
}
|
1401 |
Â
|
@@ -1436,6 +1824,14 @@ function bp_is_component_front_page( $component = '' ) {
|
|
1436 |
Â
return false;
|
1437 |
Â
}
|
1438 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1439 |
Â
return (bool) apply_filters( 'bp_is_component_front_page', ( $bp->pages->{$component}->id == $page_on_front ), $component );
|
1440 |
Â
}
|
1441 |
Â
|
@@ -1458,6 +1854,13 @@ function bp_is_blog_page() {
|
|
1458 |
Â
$is_blog_page = true;
|
1459 |
Â
}
|
1460 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1461 |
Â
return (bool) apply_filters( 'bp_is_blog_page', $is_blog_page );
|
1462 |
Â
}
|
1463 |
Â
|
@@ -1478,18 +1881,29 @@ function bp_is_blog_page() {
|
|
1478 |
Â
function is_buddypress() {
|
1479 |
Â
$retval = (bool) ( bp_current_component() || bp_is_user() );
|
1480 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1481 |
Â
return apply_filters( 'is_buddypress', $retval );
|
1482 |
Â
}
|
1483 |
Â
|
1484 |
Â
/** Components ****************************************************************/
|
1485 |
Â
|
1486 |
Â
/**
|
1487 |
-
* Check whether a given component
|
Â
|
|
Â
|
|
Â
|
|
1488 |
Â
*
|
1489 |
Â
* @param string $component The component name.
|
1490 |
-
* @
|
Â
|
|
1491 |
Â
*/
|
1492 |
-
function bp_is_active( $component = '' ) {
|
1493 |
Â
$retval = false;
|
1494 |
Â
|
1495 |
Â
// Default to the current component if none is passed
|
@@ -1500,8 +1914,32 @@ function bp_is_active( $component = '' ) {
|
|
1500 |
Â
// Is component in either the active or required components arrays
|
1501 |
Â
if ( isset( buddypress()->active_components[ $component ] ) || isset( buddypress()->required_components[ $component ] ) ) {
|
1502 |
Â
$retval = true;
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1503 |
Â
}
|
1504 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1505 |
Â
return apply_filters( 'bp_is_active', $retval, $component );
|
1506 |
Â
}
|
1507 |
Â
|
@@ -1680,6 +2118,13 @@ function bp_is_my_profile() {
|
|
1680 |
Â
$my_profile = false;
|
1681 |
Â
}
|
1682 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1683 |
Â
return apply_filters( 'bp_is_my_profile', $my_profile );
|
1684 |
Â
}
|
1685 |
Â
|
@@ -2501,6 +2946,16 @@ function bp_the_body_class() {
|
|
2501 |
Â
// Merge WP classes with BuddyPress classes and remove any duplicates
|
2502 |
Â
$classes = array_unique( array_merge( (array) $bp_classes, (array) $wp_classes ) );
|
2503 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2504 |
Â
return apply_filters( 'bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes );
|
2505 |
Â
}
|
2506 |
Â
add_filter( 'body_class', 'bp_get_the_body_class', 10, 2 );
|
@@ -2650,7 +3105,7 @@ function bp_get_nav_menu_items() {
|
|
2650 |
Â
continue;
|
2651 |
Â
}
|
2652 |
Â
|
2653 |
-
// Get the correct menu link. See
|
2654 |
Â
$link = bp_loggedin_user_domain() ? str_replace( bp_loggedin_user_domain(), bp_displayed_user_domain(), $nav['link'] ) : trailingslashit( bp_displayed_user_domain() . $nav['link'] );
|
2655 |
Â
|
2656 |
Â
// Add this menu
|
@@ -2669,6 +3124,13 @@ function bp_get_nav_menu_items() {
|
|
2669 |
Â
$menus[] = $menu;
|
2670 |
Â
}
|
2671 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2672 |
Â
return apply_filters( 'bp_get_nav_menu_items', $menus );
|
2673 |
Â
}
|
2674 |
Â
|
@@ -2728,6 +3190,14 @@ function bp_nav_menu( $args = array() ) {
|
|
2728 |
Â
'walker' => '',
|
2729 |
Â
);
|
2730 |
Â
$args = wp_parse_args( $args, $defaults );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2731 |
Â
$args = apply_filters( 'bp_nav_menu_args', $args );
|
2732 |
Â
$args = (object) $args;
|
2733 |
Â
|
@@ -2745,6 +3215,14 @@ function bp_nav_menu( $args = array() ) {
|
|
2745 |
Â
|
2746 |
Â
// Whether to wrap the ul, and what to wrap it with
|
2747 |
Â
if ( $args->container ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2748 |
Â
$allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav', ) );
|
2749 |
Â
|
2750 |
Â
if ( in_array( $args->container, $allowed_tags ) ) {
|
@@ -2756,7 +3234,14 @@ function bp_nav_menu( $args = array() ) {
|
|
2756 |
Â
}
|
2757 |
Â
}
|
2758 |
Â
|
2759 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2760 |
Â
$menu_items = apply_filters( 'bp_nav_menu_objects', bp_get_nav_menu_items(), $args );
|
2761 |
Â
$items = walk_nav_menu_tree( $menu_items, $args->depth, $args );
|
2762 |
Â
unset( $menu_items );
|
@@ -2779,7 +3264,16 @@ function bp_nav_menu( $args = array() ) {
|
|
2779 |
Â
}
|
2780 |
Â
$menu_id_slugs[] = $wrap_id;
|
2781 |
Â
|
2782 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2783 |
Â
$items = apply_filters( 'bp_nav_menu_items', $items, $args );
|
2784 |
Â
|
2785 |
Â
// Build the output
|
@@ -2792,7 +3286,14 @@ function bp_nav_menu( $args = array() ) {
|
|
2792 |
Â
$nav_menu .= '</' . $args->container . '>';
|
2793 |
Â
}
|
2794 |
Â
|
2795 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2796 |
Â
$nav_menu = apply_filters( 'bp_nav_menu', $nav_menu, $args );
|
2797 |
Â
|
2798 |
Â
if ( ! empty( $args->echo ) ) {
|
71 |
Â
// List type depends on our current component
|
72 |
Â
$list_type = bp_is_group() ? 'groups' : 'personal';
|
73 |
Â
|
74 |
+
/**
|
75 |
+
* Filters the "options nav", the secondary-level single item navigation menu.
|
76 |
+
*
|
77 |
+
* This is a dynamic filter that is dependent on the provided css_id value.
|
78 |
+
*
|
79 |
+
* @since BuddyPress (1.1.0)
|
80 |
+
*
|
81 |
+
* @param string $value HTML list item for the submenu item.
|
82 |
+
* @param array $subnav_item Submenu array item being displayed.
|
83 |
+
* @param string $selected_item Current action.
|
84 |
+
*/
|
85 |
+
echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="' . esc_attr( $subnav_item['css_id'] . '-' . $list_type . '-li' ) . '" ' . $selected . '><a id="' . esc_attr( $subnav_item['css_id'] ) . '" href="' . esc_url( $subnav_item['link'] ) . '">' . $subnav_item['name'] . '</a></li>', $subnav_item, $selected_item );
|
86 |
Â
}
|
87 |
Â
}
|
88 |
Â
|
124 |
Â
$title = sprintf( __( '%s Directory', 'buddypress' ), buddypress()->{$component}->name );
|
125 |
Â
}
|
126 |
Â
|
127 |
+
/**
|
128 |
+
* Filters the directory title for a component.
|
129 |
+
*
|
130 |
+
* @since BuddyPress (2.0.0)
|
131 |
+
*
|
132 |
+
* @param string $title Text to be used in <title> tag.
|
133 |
+
* @param string $component Current componet being displayed.
|
134 |
+
*/
|
135 |
Â
return apply_filters( 'bp_get_directory_title', $title, $component );
|
136 |
Â
}
|
137 |
Â
|
218 |
Â
? $step = $bp->avatar_admin->step
|
219 |
Â
: 'upload-image';
|
220 |
Â
|
221 |
+
/**
|
222 |
+
* Filters the current avatar upload step.
|
223 |
+
*
|
224 |
+
* @since BuddyPress (1.1.0)
|
225 |
+
*
|
226 |
+
* @param string $step The current avatar upload step.
|
227 |
+
*/
|
228 |
Â
return apply_filters( 'bp_get_avatar_admin_step', $step );
|
229 |
Â
}
|
230 |
Â
|
245 |
Â
? $bp->avatar_admin->image->url
|
246 |
Â
: '';
|
247 |
Â
|
248 |
+
/**
|
249 |
+
* Filters the URL of the avatar to crop.
|
250 |
+
*
|
251 |
+
* @since BuddyPress (1.1.0)
|
252 |
+
*
|
253 |
+
* @param string $url URL for the avatar.
|
254 |
+
*/
|
255 |
Â
return apply_filters( 'bp_get_avatar_to_crop', $url );
|
256 |
Â
}
|
257 |
Â
|
272 |
Â
? str_replace( WP_CONTENT_DIR, '', $bp->avatar_admin->image->dir )
|
273 |
Â
: '';
|
274 |
Â
|
275 |
+
/**
|
276 |
+
* Filters the relative file path to the avatar to crop.
|
277 |
+
*
|
278 |
+
* @since BuddyPress (1.1.0)
|
279 |
+
*
|
280 |
+
* @param string $src Relative file path for the avatar.
|
281 |
+
*/
|
282 |
Â
return apply_filters( 'bp_get_avatar_to_crop_src', $src );
|
283 |
Â
}
|
284 |
Â
|
307 |
Â
* @since BuddyPress (1.6.0)
|
308 |
Â
*/
|
309 |
Â
function bp_get_site_name() {
|
310 |
+
|
311 |
+
/**
|
312 |
+
* Filters the name of the BP site. Used in RSS headers.
|
313 |
+
*
|
314 |
+
* @since BuddyPress (1.0.0)
|
315 |
+
*
|
316 |
+
* @param string $value Current BP site name.
|
317 |
+
*/
|
318 |
Â
return apply_filters( 'bp_site_name', get_bloginfo( 'name', 'display' ) );
|
319 |
Â
}
|
320 |
Â
|
321 |
Â
/**
|
322 |
+
* Format a date based on a UNIX timestamp
|
323 |
Â
*
|
324 |
+
* This function can be used to turn a UNIX timestamp into a properly formatted
|
325 |
+
* (and possibly localized) string, userful for ouputting the date & time an
|
326 |
+
* action took place.
|
327 |
+
*
|
328 |
+
* Not to be confused with `bp_core_time_since()`, this function is best used
|
329 |
+
* for displaying a more exact date and time vs. a human-readable time.
|
330 |
+
*
|
331 |
+
* Note: This function may be improved or removed at a later date, as it is
|
332 |
+
* hardly used and adds an additional layer of complexity to calculating dates
|
333 |
+
* and times together with timezone offsets and i18n.
|
334 |
+
*
|
335 |
+
* @since BuddyPress (1.1.0)
|
336 |
+
*
|
337 |
+
* @param int $time The UNIX timestamp to be formatted.
|
338 |
+
* @param bool $exclude_time Optional. True to return only the month + day, false
|
339 |
+
* to return month, day, and time. Default: false.
|
340 |
+
* @param bool $gmt Optional. True to display in local time, false to
|
341 |
+
* leave in GMT. Default: true.
|
342 |
+
*
|
343 |
+
* @return mixed A string representation of $time, in the format
|
344 |
+
* "March 18, 2014 at 2:00 pm" (or whatever your
|
345 |
+
* 'date_format' and 'time_format' settings are
|
346 |
+
* on your root blog). False on failure.
|
347 |
Â
*/
|
348 |
+
function bp_format_time( $time = '', $exclude_time = false, $gmt = true ) {
|
349 |
Â
|
350 |
+
// Bail if time is empty or not numeric
|
351 |
+
// @todo We should output something smarter here
|
352 |
+
if ( empty( $time ) || ! is_numeric( $time ) ) {
|
353 |
Â
return false;
|
354 |
Â
}
|
355 |
Â
|
356 |
Â
// Get GMT offset from root blog
|
357 |
+
if ( true === $gmt ) {
|
358 |
+
|
359 |
+
// Use Timezone string if set
|
360 |
+
$timezone_string = bp_get_option( 'timezone_string' );
|
361 |
+
if ( ! empty( $timezone_string ) ) {
|
362 |
+
$timezone_object = timezone_open( $timezone_string );
|
363 |
+
$datetime_object = date_create( "@{$time}" );
|
364 |
+
$timezone_offset = timezone_offset_get( $timezone_object, $datetime_object ) / HOUR_IN_SECONDS;
|
365 |
+
|
366 |
+
// Fall back on less reliable gmt_offset
|
367 |
+
} else {
|
368 |
+
$timezone_offset = bp_get_option( 'gmt_offset' );
|
369 |
+
}
|
370 |
+
|
371 |
+
// Calculate time based on the offset
|
372 |
+
$calculated_time = $time + ( $timezone_offset * HOUR_IN_SECONDS );
|
373 |
Â
|
374 |
+
// No localizing, so just use the time that was submitted
|
375 |
+
} else {
|
376 |
+
$calculated_time = $time;
|
377 |
+
}
|
378 |
Â
|
379 |
+
// Formatted date: "March 18, 2014"
|
380 |
+
$formatted_date = date_i18n( bp_get_option( 'date_format' ), $calculated_time, $gmt );
|
381 |
Â
|
382 |
Â
// Should we show the time also?
|
383 |
+
if ( true !== $exclude_time ) {
|
384 |
+
|
385 |
+
// Formatted time: "2:00 pm"
|
386 |
+
$formatted_time = date_i18n( bp_get_option( 'time_format' ), $calculated_time, $gmt );
|
387 |
Â
|
388 |
Â
// Return string formatted with date and time
|
389 |
+
$formatted_date = sprintf( esc_html__( '%1$s at %2$s', 'buddypress' ), $formatted_date, $formatted_time );
|
390 |
Â
}
|
391 |
Â
|
392 |
+
/**
|
393 |
+
* Filters the date based on a UNIX timestamp.
|
394 |
+
*
|
395 |
+
* @since BuddyPress (1.0.0)
|
396 |
+
*
|
397 |
+
* @param string $formatted_date Formatted date from the timestamp.
|
398 |
+
*/
|
399 |
+
return apply_filters( 'bp_format_time', $formatted_date );
|
400 |
Â
}
|
401 |
Â
|
402 |
Â
/**
|
425 |
Â
|
426 |
Â
if ( bp_displayed_user_id() == bp_loggedin_user_id() ) {
|
427 |
Â
if ( true == $echo ) {
|
428 |
+
|
429 |
+
/**
|
430 |
+
* Filters the text used based on context of own profile or someone else's profile.
|
431 |
+
*
|
432 |
+
* @since BuddyPress (1.0.0)
|
433 |
+
*
|
434 |
+
* @param string $youtext Context-determined string to display.
|
435 |
+
*/
|
436 |
Â
echo apply_filters( 'bp_word_or_name', $youtext );
|
437 |
Â
} else {
|
438 |
+
|
439 |
+
/** This filter is documented in bp-core/bp-core-template.php */
|
440 |
Â
return apply_filters( 'bp_word_or_name', $youtext );
|
441 |
Â
}
|
442 |
Â
} else {
|
444 |
Â
$fullname = (array) explode( ' ', $fullname );
|
445 |
Â
$nametext = sprintf( $nametext, $fullname[0] );
|
446 |
Â
if ( true == $echo ) {
|
447 |
+
|
448 |
+
/** This filter is documented in bp-core/bp-core-template.php */
|
449 |
Â
echo apply_filters( 'bp_word_or_name', $nametext );
|
450 |
Â
} else {
|
451 |
+
|
452 |
+
/** This filter is documented in bp-core/bp-core-template.php */
|
453 |
Â
return apply_filters( 'bp_word_or_name', $nametext );
|
454 |
Â
}
|
455 |
Â
}
|
475 |
Â
* @return string URL action attribute for search forms, eg example.com/search/.
|
476 |
Â
*/
|
477 |
Â
function bp_search_form_action() {
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Filters the "action" attribute for search forms.
|
481 |
+
*
|
482 |
+
* @since BuddyPress (1.0.0)
|
483 |
+
*
|
484 |
+
* @param string $value Search form action url.
|
485 |
+
*/
|
486 |
Â
return apply_filters( 'bp_search_form_action', trailingslashit( bp_get_root_domain() . '/' . bp_get_search_slug() ) );
|
487 |
Â
}
|
488 |
Â
|
519 |
Â
$selection_box = '<label for="search-which" class="accessibly-hidden">' . _x( 'Search these:', 'search form', 'buddypress' ) . '</label>';
|
520 |
Â
$selection_box .= '<select name="search-which" id="search-which" style="width: auto">';
|
521 |
Â
|
522 |
+
/**
|
523 |
+
* Filters all of the component options available for search scope.
|
524 |
+
*
|
525 |
+
* @since BuddyPress (1.5.0)
|
526 |
+
*
|
527 |
+
* @param array $options Array of options to add to select field.
|
528 |
+
*/
|
529 |
Â
$options = apply_filters( 'bp_search_form_type_select_options', $options );
|
530 |
Â
foreach( (array) $options as $option_value => $option_title ) {
|
531 |
Â
$selection_box .= sprintf( '<option value="%s">%s</option>', $option_value, $option_title );
|
533 |
Â
|
534 |
Â
$selection_box .= '</select>';
|
535 |
Â
|
536 |
+
/**
|
537 |
+
* Filters the complete <select> input used for search scope.
|
538 |
+
*
|
539 |
+
* @since BuddyPress (1.0.0)
|
540 |
+
*
|
541 |
+
* @param string $selection_box <select> input for selecting search scope.
|
542 |
+
*/
|
543 |
Â
return apply_filters( 'bp_search_form_type_select', $selection_box );
|
544 |
Â
}
|
545 |
Â
|
564 |
Â
* @return string Placeholder text for search field.
|
565 |
Â
*/
|
566 |
Â
function bp_get_search_default_text( $component = '' ) {
|
567 |
+
|
568 |
+
$bp = buddypress();
|
569 |
Â
|
570 |
Â
if ( empty( $component ) ) {
|
571 |
Â
$component = bp_current_component();
|
589 |
Â
}
|
590 |
Â
}
|
591 |
Â
|
592 |
+
/**
|
593 |
+
* Filters the default text for the search box for a given component.
|
594 |
+
*
|
595 |
+
* @since BuddyPress (1.5.0)
|
596 |
+
*
|
597 |
+
* @param string $default_text Default text for search box.
|
598 |
+
* @param string $component Current component displayed.
|
599 |
+
*/
|
600 |
Â
return apply_filters( 'bp_get_search_default_text', $default_text, $component );
|
601 |
Â
}
|
602 |
Â
|
716 |
Â
*/
|
717 |
Â
function bp_get_button( $args = '' ) {
|
718 |
Â
$button = new BP_Button( $args );
|
719 |
+
|
720 |
+
/**
|
721 |
+
* Filters the requested button output.
|
722 |
+
*
|
723 |
+
* @since BuddyPress (1.2.6)
|
724 |
+
*
|
725 |
+
* @param string $contents Button context to be used.
|
726 |
+
* @param array $args Array of args for the button.
|
727 |
+
* @param BP_Button $button BP_Button object.
|
728 |
+
*/
|
729 |
Â
return apply_filters( 'bp_get_button', $button->contents, $args, $button );
|
730 |
Â
}
|
731 |
Â
|
776 |
Â
// Save the original text, to be passed along to the filter
|
777 |
Â
$original_text = $text;
|
778 |
Â
|
779 |
+
/**
|
780 |
+
* Filters the excerpt length to trim text to.
|
781 |
+
*
|
782 |
+
* @since BuddyPress (1.5.0)
|
783 |
+
*
|
784 |
+
* @param int $length Length of returned string, including ellipsis.
|
785 |
+
*/
|
786 |
Â
$length = apply_filters( 'bp_excerpt_length', $length );
|
787 |
+
|
788 |
+
/**
|
789 |
+
* Filters the excerpt appended text value.
|
790 |
+
*
|
791 |
+
* @since BuddyPress (1.5.0)
|
792 |
+
*
|
793 |
+
* @param string $value Text to append to the end of the excerpt.
|
794 |
+
*/
|
795 |
Â
$ending = apply_filters( 'bp_excerpt_append_text', $r['ending'] );
|
796 |
Â
|
797 |
Â
// Remove shortcodes if necessary
|
812 |
Â
$openTags = array();
|
813 |
Â
$truncate = '';
|
814 |
Â
|
815 |
+
// Find all the tags and HTML comments and put them in a stack for later use
|
816 |
+
preg_match_all( '/(<\/?([\w+!]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER );
|
Â
|
|
817 |
Â
|
818 |
+
foreach ( $tags as $tag ) {
|
819 |
Â
// Process tags that need to be closed
|
820 |
Â
if ( !preg_match( '/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/s', $tag[2] ) ) {
|
821 |
Â
if ( preg_match( '/<[\w]+[^>]*>/s', $tag[0] ) ) {
|
865 |
Â
|
866 |
Â
// If $exact is false, we can't break on words
|
867 |
Â
if ( empty( $r['exact'] ) ) {
|
868 |
+
// Find the position of the last space character not part of a tag.
|
869 |
+
preg_match_all( '/<[a-z\!\/][^>]*>/', $truncate, $_truncate_tags, PREG_OFFSET_CAPTURE );
|
870 |
+
|
871 |
+
// Rekey tags by the string index of their last character.
|
872 |
+
$truncate_tags = array();
|
873 |
+
if ( ! empty( $_truncate_tags[0] ) ) {
|
874 |
+
foreach ( $_truncate_tags[0] as $_tt ) {
|
875 |
+
$_tt['start'] = $_tt[1];
|
876 |
+
$_tt['end'] = $_tt[1] + strlen( $_tt[0] );
|
877 |
+
$truncate_tags[ $_tt['end'] ] = $_tt;
|
878 |
+
}
|
879 |
+
}
|
880 |
+
|
881 |
+
$truncate_length = mb_strlen( $truncate );
|
882 |
+
$spacepos = $truncate_length + 1;
|
883 |
+
for ( $pos = $truncate_length - 1; $pos >= 0; $pos-- ) {
|
884 |
+
// Word boundaries are spaces and the close of HTML tags, when the tag is preceded by a space.
|
885 |
+
$is_word_boundary = ' ' === $truncate[ $pos ];
|
886 |
+
if ( ! $is_word_boundary && isset( $truncate_tags[ $pos - 1 ] ) ) {
|
887 |
+
$preceding_tag = $truncate_tags[ $pos - 1 ];
|
888 |
+
if ( ' ' === $truncate[ $preceding_tag['start'] - 1 ] ) {
|
889 |
+
$is_word_boundary = true;
|
890 |
+
break;
|
891 |
+
}
|
892 |
+
}
|
893 |
+
|
894 |
+
if ( ! $is_word_boundary ) {
|
895 |
+
continue;
|
896 |
+
}
|
897 |
+
|
898 |
+
// If there are no tags in the string, the first space found is the right one.
|
899 |
+
if ( empty( $truncate_tags ) ) {
|
900 |
+
$spacepos = $pos;
|
901 |
+
break;
|
902 |
+
}
|
903 |
+
|
904 |
+
// Look at each tag to see if the space is inside of it.
|
905 |
+
$intag = false;
|
906 |
+
foreach ( $truncate_tags as $tt ) {
|
907 |
+
if ( $pos > $tt['start'] && $pos < $tt['end'] ) {
|
908 |
+
$intag = true;
|
909 |
+
break;
|
910 |
+
}
|
911 |
+
}
|
912 |
+
|
913 |
+
if ( ! $intag ) {
|
914 |
+
$spacepos = $pos;
|
915 |
+
break;
|
916 |
+
}
|
917 |
+
}
|
918 |
+
|
919 |
+
if ( $r['html'] ) {
|
920 |
+
$bits = mb_substr( $truncate, $spacepos );
|
921 |
+
preg_match_all( '/<\/([a-z]+)>/', $bits, $droppedTags, PREG_SET_ORDER );
|
922 |
+
if ( !empty( $droppedTags ) ) {
|
923 |
+
foreach ( $droppedTags as $closingTag ) {
|
924 |
+
if ( !in_array( $closingTag[1], $openTags ) ) {
|
925 |
+
array_unshift( $openTags, $closingTag[1] );
|
926 |
Â
}
|
927 |
Â
}
|
928 |
Â
}
|
Â
|
|
929 |
Â
}
|
930 |
+
|
931 |
+
$truncate = rtrim( mb_substr( $truncate, 0, $spacepos ) );
|
932 |
Â
}
|
933 |
Â
$truncate .= $ending;
|
934 |
Â
|
938 |
Â
}
|
939 |
Â
}
|
940 |
Â
|
941 |
+
/**
|
942 |
+
* Filters the final generated excerpt.
|
943 |
+
*
|
944 |
+
* @since BuddyPress (1.1.0)
|
945 |
+
*
|
946 |
+
* @param string $truncate Generated excerpt.
|
947 |
+
* @param string $original_text Original text provided.
|
948 |
+
* @param int $length Length of returned string, including ellipsis.
|
949 |
+
* @param array $options Array of HTML attributes and options.
|
950 |
+
*/
|
951 |
Â
return apply_filters( 'bp_create_excerpt', $truncate, $original_text, $length, $options );
|
952 |
Â
}
|
953 |
Â
add_filter( 'bp_create_excerpt', 'stripslashes_deep' );
|
974 |
Â
* @return int Member count.
|
975 |
Â
*/
|
976 |
Â
function bp_get_total_member_count() {
|
977 |
+
|
978 |
+
/**
|
979 |
+
* Filters the total member count in your BP instance.
|
980 |
+
*
|
981 |
+
* @since BuddyPress (1.2.0)
|
982 |
+
*
|
983 |
+
* @param int $value Member count.
|
984 |
+
*/
|
985 |
Â
return apply_filters( 'bp_get_total_member_count', bp_core_get_active_member_count() );
|
986 |
Â
}
|
987 |
Â
add_filter( 'bp_get_total_member_count', 'bp_core_number_format' );
|
1008 |
Â
return false;
|
1009 |
Â
}
|
1010 |
Â
|
1011 |
+
$status = bp_core_get_root_option( 'registration' );
|
1012 |
Â
if ( ( 'none' !== $status ) && ( 'user' !== $status ) ) {
|
1013 |
Â
return true;
|
1014 |
Â
}
|
1041 |
Â
* @return bool True by default.
|
1042 |
Â
*/
|
1043 |
Â
function bp_registration_needs_activation() {
|
1044 |
+
|
1045 |
+
/**
|
1046 |
+
* Filters whether registrations require activation on this installation.
|
1047 |
+
*
|
1048 |
+
* @since BuddyPress (1.2.0)
|
1049 |
+
*
|
1050 |
+
* @param bool $value Whether registrations require activation. Default true.
|
1051 |
+
*/
|
1052 |
Â
return apply_filters( 'bp_registration_needs_activation', true );
|
1053 |
Â
}
|
1054 |
Â
|
1060 |
Â
*
|
1061 |
Â
* @since BuddyPress (1.7.0)
|
1062 |
Â
*
|
1063 |
+
* @see https://buddypress.trac.wordpress.org/ticket/4401
|
1064 |
Â
*
|
1065 |
Â
* @param array $args {
|
1066 |
Â
* Array of optional parameters.
|
1086 |
Â
|
1087 |
Â
$subject = $r['before'] . wp_specialchars_decode( bp_get_option( 'blogname', $r['default'] ), ENT_QUOTES ) . $r['after'] . ' ' . $r['text'];
|
1088 |
Â
|
1089 |
+
/**
|
1090 |
+
* Filters a client friendly version of the root blog name.
|
1091 |
+
*
|
1092 |
+
* @since BuddyPress (1.7.0)
|
1093 |
+
*
|
1094 |
+
* @param string $subject Client friendy version of the root blog name.
|
1095 |
+
* @param array $r Array of arguments for the email subject.
|
1096 |
+
*/
|
1097 |
Â
return apply_filters( 'bp_get_email_subject', $subject, $r );
|
1098 |
Â
}
|
1099 |
Â
|
1117 |
Â
$bp->ajax_querystring = '';
|
1118 |
Â
}
|
1119 |
Â
|
1120 |
+
/**
|
1121 |
+
* Filters the template paramenters to be used in the query string.
|
1122 |
+
*
|
1123 |
+
* Allows templates to pass parameters into the template loops via AJAX.
|
1124 |
+
*
|
1125 |
+
* @since BuddyPress (1.2.0)
|
1126 |
+
*
|
1127 |
+
* @param string $ajax_querystring Current query string.
|
1128 |
+
* @param string $object Current template component.
|
1129 |
+
*/
|
1130 |
Â
return apply_filters( 'bp_ajax_querystring', $bp->ajax_querystring, $object );
|
1131 |
Â
}
|
1132 |
Â
|
1143 |
Â
? $bp->current_component
|
1144 |
Â
: false;
|
1145 |
Â
|
1146 |
+
/**
|
1147 |
+
* Filters the name of the current component.
|
1148 |
+
*
|
1149 |
+
* @since BuddyPress (1.0.0)
|
1150 |
+
*
|
1151 |
+
* @param string|bool $current_component Current component if available or false.
|
1152 |
+
*/
|
1153 |
Â
return apply_filters( 'bp_current_component', $current_component );
|
1154 |
Â
}
|
1155 |
Â
|
1164 |
Â
? $bp->current_action
|
1165 |
Â
: '';
|
1166 |
Â
|
1167 |
+
/**
|
1168 |
+
* Filters the name of the current action.
|
1169 |
+
*
|
1170 |
+
* @since BuddyPress (1.0.0)
|
1171 |
+
*
|
1172 |
+
* @param string $current_action Current action.
|
1173 |
+
*/
|
1174 |
Â
return apply_filters( 'bp_current_action', $current_action );
|
1175 |
Â
}
|
1176 |
Â
|
1185 |
Â
? $bp->current_item
|
1186 |
Â
: false;
|
1187 |
Â
|
1188 |
+
/**
|
1189 |
+
* Filters the name of the current item.
|
1190 |
+
*
|
1191 |
+
* @since BuddyPress (1.1.0)
|
1192 |
+
*
|
1193 |
+
* @param string|bool $current_item Current item if available or false.
|
1194 |
+
*/
|
1195 |
Â
return apply_filters( 'bp_current_item', $current_item );
|
1196 |
Â
}
|
1197 |
Â
|
1207 |
Â
? $bp->action_variables
|
1208 |
Â
: false;
|
1209 |
Â
|
1210 |
+
/**
|
1211 |
+
* Filters the value of $bp->action_variables.
|
1212 |
+
*
|
1213 |
+
* @since BuddyPress (1.0.0)
|
1214 |
+
*
|
1215 |
+
* @param array|bool $action_variables Available action variables.
|
1216 |
+
*/
|
1217 |
Â
return apply_filters( 'bp_action_variables', $action_variables );
|
1218 |
Â
}
|
1219 |
Â
|
1232 |
Â
? $action_variables[ $position ]
|
1233 |
Â
: false;
|
1234 |
Â
|
1235 |
+
/**
|
1236 |
+
* Filters the value of a given action variable.
|
1237 |
+
*
|
1238 |
+
* @since BuddyPress (1.5.0)
|
1239 |
+
*
|
1240 |
+
* @param string|bool $action_variable Requested action variable based on position.
|
1241 |
+
* @param int $position The key of the action variable requested.
|
1242 |
+
*/
|
1243 |
Â
return apply_filters( 'bp_action_variable', $action_variable, $position );
|
1244 |
Â
}
|
1245 |
Â
|
1264 |
Â
$bp->root_domain = $domain;
|
1265 |
Â
}
|
1266 |
Â
|
1267 |
+
/**
|
1268 |
+
* Filters the "root domain", the URL of the BP root blog.
|
1269 |
+
*
|
1270 |
+
* @since BuddyPress (1.2.4)
|
1271 |
+
*
|
1272 |
+
* @param string $domain URL of the BP root blog.
|
1273 |
+
*/
|
1274 |
Â
return apply_filters( 'bp_get_root_domain', $domain );
|
1275 |
Â
}
|
1276 |
Â
|
1343 |
Â
$root_slug = $component;
|
1344 |
Â
}
|
1345 |
Â
|
1346 |
+
/**
|
1347 |
+
* Filters the root slug for given component.
|
1348 |
+
*
|
1349 |
+
* @since BuddyPress (1.5.0)
|
1350 |
+
*
|
1351 |
+
* @param string $root_slug Root slug for given component.
|
1352 |
+
* @param string $component Current component.
|
1353 |
+
*/
|
1354 |
Â
return apply_filters( 'bp_get_root_slug', $root_slug, $component );
|
1355 |
Â
}
|
1356 |
Â
|
1390 |
Â
? true
|
1391 |
Â
: false;
|
1392 |
Â
|
1393 |
+
/**
|
1394 |
+
* Filters whether or not a user has access.
|
1395 |
+
*
|
1396 |
+
* @since BuddyPress (1.2.4)
|
1397 |
+
*
|
1398 |
+
* @param bool $has_access Whether or not user has access.
|
1399 |
+
*/
|
1400 |
Â
return (bool) apply_filters( 'bp_user_has_access', $has_access );
|
1401 |
Â
}
|
1402 |
Â
|
1418 |
Â
* @return string The search slug. Default: 'search'.
|
1419 |
Â
*/
|
1420 |
Â
function bp_get_search_slug() {
|
1421 |
+
|
1422 |
+
/**
|
1423 |
+
* Filters the search slug.
|
1424 |
+
*
|
1425 |
+
* @since BuddyPress (1.5.0)
|
1426 |
+
*
|
1427 |
+
* @param string BP_SEARCH_SLUG The search slug. Default "search".
|
1428 |
+
*/
|
1429 |
Â
return apply_filters( 'bp_get_search_slug', BP_SEARCH_SLUG );
|
1430 |
Â
}
|
1431 |
Â
|
1442 |
Â
? $bp->displayed_user->id
|
1443 |
Â
: 0;
|
1444 |
Â
|
1445 |
+
/**
|
1446 |
+
* Filters the ID of the currently displayed user.
|
1447 |
+
*
|
1448 |
+
* @since BuddyPress (1.0.0)
|
1449 |
+
*
|
1450 |
+
* @param int $id ID of the currently displayed user.
|
1451 |
+
*/
|
1452 |
Â
return (int) apply_filters( 'bp_displayed_user_id', $id );
|
1453 |
Â
}
|
1454 |
Â
|
1465 |
Â
? $bp->loggedin_user->id
|
1466 |
Â
: 0;
|
1467 |
Â
|
1468 |
+
/**
|
1469 |
+
* Filters the ID of the currently logged-in user.
|
1470 |
+
*
|
1471 |
+
* @since BuddyPress (1.0.0)
|
1472 |
+
*
|
1473 |
+
* @param int $id ID of the currently logged-in user.
|
1474 |
+
*/
|
1475 |
Â
return (int) apply_filters( 'bp_loggedin_user_id', $id );
|
1476 |
Â
}
|
1477 |
Â
|
1551 |
Â
}
|
1552 |
Â
}
|
1553 |
Â
|
1554 |
+
/**
|
1555 |
+
* Filters whether the current page belongs to the specified component.
|
1556 |
+
*
|
1557 |
+
* @since BuddyPress (1.5.0)
|
1558 |
+
*
|
1559 |
+
* @param bool $is_current_component Whether or not the current page belongs to specified component.
|
1560 |
+
* @param string $component Name of the component being checked.
|
1561 |
+
*/
|
1562 |
Â
return apply_filters( 'bp_is_current_component', $is_current_component, $component );
|
1563 |
Â
}
|
1564 |
Â
|
1620 |
Â
$is_action_variable = in_array( $action_variable, (array)bp_action_variables() );
|
1621 |
Â
}
|
1622 |
Â
|
1623 |
+
/**
|
1624 |
+
* Filters whether the current page matches a given action_variable.
|
1625 |
+
*
|
1626 |
+
* @since BuddyPress (1.5.0)
|
1627 |
+
*
|
1628 |
+
* @param bool $is_action_variable Whether the current page matches a given action_variable.
|
1629 |
+
* @param string $action_variable The action_variable being tested against.
|
1630 |
+
* @param int $position The array key tested against.
|
1631 |
+
*/
|
1632 |
Â
return apply_filters( 'bp_is_action_variable', $is_action_variable, $action_variable, $position );
|
1633 |
Â
}
|
1634 |
Â
|
1641 |
Â
function bp_is_current_item( $item = '' ) {
|
1642 |
Â
$retval = ( $item === bp_current_item() );
|
1643 |
Â
|
1644 |
+
/**
|
1645 |
+
* Filters whether or not an item is the current item.
|
1646 |
+
*
|
1647 |
+
* @since BuddyPress (2.1.0)
|
1648 |
+
*
|
1649 |
+
* @param bool $retval Whether or not an item is the current item.
|
1650 |
+
* @param string $item The item being checked.
|
1651 |
+
*/
|
1652 |
Â
return (bool) apply_filters( 'bp_is_current_item', $retval, $item );
|
1653 |
Â
}
|
1654 |
Â
|
1665 |
Â
$retval = $bp->is_single_item;
|
1666 |
Â
}
|
1667 |
Â
|
1668 |
+
/**
|
1669 |
+
* Filters whether or not an item is the a single item. (group, user, etc)
|
1670 |
+
*
|
1671 |
+
* @since BuddyPress (2.1.0)
|
1672 |
+
*
|
1673 |
+
* @param bool $retval Whether or not an item is a single item.
|
1674 |
+
*/
|
1675 |
Â
return (bool) apply_filters( 'bp_is_single_item', $retval );
|
1676 |
Â
}
|
1677 |
Â
|
1689 |
Â
$retval = $bp->is_item_admin;
|
1690 |
Â
}
|
1691 |
Â
|
1692 |
+
/**
|
1693 |
+
* Filters whether or not the logged-in user is an admin for the current item.
|
1694 |
+
*
|
1695 |
+
* @since BuddyPress (2.1.0)
|
1696 |
+
*
|
1697 |
+
* @param bool $retval Whether or not the logged-in user is an admin.
|
1698 |
+
*/
|
1699 |
Â
return (bool) apply_filters( 'bp_is_item_admin', $retval );
|
1700 |
Â
}
|
1701 |
Â
|
1713 |
Â
$retval = $bp->is_item_mod;
|
1714 |
Â
}
|
1715 |
Â
|
1716 |
+
/**
|
1717 |
+
* Filters whether or not the logged-in user is a mod for the current item.
|
1718 |
+
*
|
1719 |
+
* @since BuddyPress (2.1.0)
|
1720 |
+
*
|
1721 |
+
* @param bool $retval Whether or not the logged-in user is a mod.
|
1722 |
+
*/
|
1723 |
Â
return (bool) apply_filters( 'bp_is_item_mod', $retval );
|
1724 |
Â
}
|
1725 |
Â
|
1737 |
Â
$retval = $bp->is_directory;
|
1738 |
Â
}
|
1739 |
Â
|
1740 |
+
/**
|
1741 |
+
* Filters whether or not user is on a component directory page.
|
1742 |
+
*
|
1743 |
+
* @since BuddyPress (2.1.0)
|
1744 |
+
*
|
1745 |
+
* @param bool $retval Whether or not user is on a component directory page.
|
1746 |
+
*/
|
1747 |
Â
return (bool) apply_filters( 'bp_is_directory', $retval );
|
1748 |
Â
}
|
1749 |
Â
|
1777 |
Â
}
|
1778 |
Â
}
|
1779 |
Â
|
1780 |
+
/**
|
1781 |
+
* Filters whether or not a component's URL should be in the root, not under a member page.
|
1782 |
+
*
|
1783 |
+
* @since BuddyPress (2.1.0)
|
1784 |
+
*
|
1785 |
+
* @param bool $retval Whether or not URL should be in the root.
|
1786 |
+
*/
|
1787 |
Â
return (bool) apply_filters( 'bp_is_root_component', $retval );
|
1788 |
Â
}
|
1789 |
Â
|
1824 |
Â
return false;
|
1825 |
Â
}
|
1826 |
Â
|
1827 |
+
/**
|
1828 |
+
* Filters whether or not the specified BuddyPress component directory is set to be the front page.
|
1829 |
+
*
|
1830 |
+
* @since BuddyPress (1.5.0)
|
1831 |
+
*
|
1832 |
+
* @param bool $value Whether or not the specified component directory is set as front page.
|
1833 |
+
* @param string $component Current component being checked.
|
1834 |
+
*/
|
1835 |
Â
return (bool) apply_filters( 'bp_is_component_front_page', ( $bp->pages->{$component}->id == $page_on_front ), $component );
|
1836 |
Â
}
|
1837 |
Â
|
1854 |
Â
$is_blog_page = true;
|
1855 |
Â
}
|
1856 |
Â
|
1857 |
+
/**
|
1858 |
+
* Filters whether or not current page is a blog page or not.
|
1859 |
+
*
|
1860 |
+
* @since BuddyPress (1.5.0)
|
1861 |
+
*
|
1862 |
+
* @param bool $is_blog_page Whether or not current page is a blog page.
|
1863 |
+
*/
|
1864 |
Â
return (bool) apply_filters( 'bp_is_blog_page', $is_blog_page );
|
1865 |
Â
}
|
1866 |
Â
|
1881 |
Â
function is_buddypress() {
|
1882 |
Â
$retval = (bool) ( bp_current_component() || bp_is_user() );
|
1883 |
Â
|
1884 |
+
/**
|
1885 |
+
* Filters whether or not this is a BuddyPress component.
|
1886 |
+
*
|
1887 |
+
* @since BuddyPress (1.7.0)
|
1888 |
+
*
|
1889 |
+
* @param bool $retval Whether or not this is a BuddyPress component.
|
1890 |
+
*/
|
1891 |
Â
return apply_filters( 'is_buddypress', $retval );
|
1892 |
Â
}
|
1893 |
Â
|
1894 |
Â
/** Components ****************************************************************/
|
1895 |
Â
|
1896 |
Â
/**
|
1897 |
+
* Check whether a given component (or feature of a component) is active.
|
1898 |
+
*
|
1899 |
+
* @since BuddyPress (1.2.0) See r2539.
|
1900 |
+
* @since BuddyPress (2.3.0) Added $feature as a parameter.
|
1901 |
Â
*
|
1902 |
Â
* @param string $component The component name.
|
1903 |
+
* @param string $feature The feature name.
|
1904 |
+
* @return bool
|
1905 |
Â
*/
|
1906 |
+
function bp_is_active( $component = '', $feature = '' ) {
|
1907 |
Â
$retval = false;
|
1908 |
Â
|
1909 |
Â
// Default to the current component if none is passed
|
1914 |
Â
// Is component in either the active or required components arrays
|
1915 |
Â
if ( isset( buddypress()->active_components[ $component ] ) || isset( buddypress()->required_components[ $component ] ) ) {
|
1916 |
Â
$retval = true;
|
1917 |
+
|
1918 |
+
// Is feature active?
|
1919 |
+
if ( ! empty( $feature ) ) {
|
1920 |
+
if ( empty( buddypress()->$component->features ) || false === in_array( $feature, buddypress()->$component->features, true ) ) {
|
1921 |
+
$retval = false;
|
1922 |
+
}
|
1923 |
+
|
1924 |
+
/**
|
1925 |
+
* Filters whether or not a given feature for a component is active.
|
1926 |
+
*
|
1927 |
+
* @since BuddyPress (2.3.0)
|
1928 |
+
*
|
1929 |
+
* @param bool $retval
|
1930 |
+
*/
|
1931 |
+
$retval = apply_filters( "bp_is_{$component}_{$feature}_active", $retval );
|
1932 |
+
}
|
1933 |
Â
}
|
1934 |
Â
|
1935 |
+
/**
|
1936 |
+
* Filters whether or not a given component has been activated by the admin.
|
1937 |
+
*
|
1938 |
+
* @since BuddyPress (2.1.0)
|
1939 |
+
*
|
1940 |
+
* @param bool $retval Whether or not a given component has been activated by the admin.
|
1941 |
+
* @param string $component Current component being checked.
|
1942 |
+
*/
|
1943 |
Â
return apply_filters( 'bp_is_active', $retval, $component );
|
1944 |
Â
}
|
1945 |
Â
|
2118 |
Â
$my_profile = false;
|
2119 |
Â
}
|
2120 |
Â
|
2121 |
+
/**
|
2122 |
+
* Filters whether or not current page is part of the profile for the logged-in user.
|
2123 |
+
*
|
2124 |
+
* @since BuddyPress (1.2.4)
|
2125 |
+
*
|
2126 |
+
* @param bool $my_profile Whether or not current page is part of the profile for the logged-in user.
|
2127 |
+
*/
|
2128 |
Â
return apply_filters( 'bp_is_my_profile', $my_profile );
|
2129 |
Â
}
|
2130 |
Â
|
2946 |
Â
// Merge WP classes with BuddyPress classes and remove any duplicates
|
2947 |
Â
$classes = array_unique( array_merge( (array) $bp_classes, (array) $wp_classes ) );
|
2948 |
Â
|
2949 |
+
/**
|
2950 |
+
* Filters the BuddyPress classes to be added to body_class()
|
2951 |
+
*
|
2952 |
+
* @since BuddyPress (1.1.0)
|
2953 |
+
*
|
2954 |
+
* @param array $classes Array of body classes to add.
|
2955 |
+
* @param array $bp_classes Array of BuddyPress-based classes.
|
2956 |
+
* @param array $wp_classes Array of WordPress-based classes.
|
2957 |
+
* @param array $custom_classes Array of classes that were passed to get_body_class().
|
2958 |
+
*/
|
2959 |
Â
return apply_filters( 'bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes );
|
2960 |
Â
}
|
2961 |
Â
add_filter( 'body_class', 'bp_get_the_body_class', 10, 2 );
|
3105 |
Â
continue;
|
3106 |
Â
}
|
3107 |
Â
|
3108 |
+
// Get the correct menu link. See https://buddypress.trac.wordpress.org/ticket/4624
|
3109 |
Â
$link = bp_loggedin_user_domain() ? str_replace( bp_loggedin_user_domain(), bp_displayed_user_domain(), $nav['link'] ) : trailingslashit( bp_displayed_user_domain() . $nav['link'] );
|
3110 |
Â
|
3111 |
Â
// Add this menu
|
3124 |
Â
$menus[] = $menu;
|
3125 |
Â
}
|
3126 |
Â
|
3127 |
+
/**
|
3128 |
+
* Filters the items registered in the primary and secondary BuddyPress navigation menus.
|
3129 |
+
*
|
3130 |
+
* @since BuddyPress (1.7.0)
|
3131 |
+
*
|
3132 |
+
* @param array $menus Array of items registered in the primary and secondary BuddyPress navigation.
|
3133 |
+
*/
|
3134 |
Â
return apply_filters( 'bp_get_nav_menu_items', $menus );
|
3135 |
Â
}
|
3136 |
Â
|
3190 |
Â
'walker' => '',
|
3191 |
Â
);
|
3192 |
Â
$args = wp_parse_args( $args, $defaults );
|
3193 |
+
|
3194 |
+
/**
|
3195 |
+
* Filters the parsed bp_nav_menu arguments.
|
3196 |
+
*
|
3197 |
+
* @since BuddyPress (1.7.0)
|
3198 |
+
*
|
3199 |
+
* @param array $args Array of parsed arguments.
|
3200 |
+
*/
|
3201 |
Â
$args = apply_filters( 'bp_nav_menu_args', $args );
|
3202 |
Â
$args = (object) $args;
|
3203 |
Â
|
3215 |
Â
|
3216 |
Â
// Whether to wrap the ul, and what to wrap it with
|
3217 |
Â
if ( $args->container ) {
|
3218 |
+
|
3219 |
+
/**
|
3220 |
+
* Filters the allowed tags for the wp_nav_menu_container.
|
3221 |
+
*
|
3222 |
+
* @since BuddyPress (1.7.0)
|
3223 |
+
*
|
3224 |
+
* @param array $value Array of allowed tags. Default 'div' and 'nav'.
|
3225 |
+
*/
|
3226 |
Â
$allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav', ) );
|
3227 |
Â
|
3228 |
Â
if ( in_array( $args->container, $allowed_tags ) ) {
|
3234 |
Â
}
|
3235 |
Â
}
|
3236 |
Â
|
3237 |
+
/**
|
3238 |
+
* Filters the BuddyPress menu objects.
|
3239 |
+
*
|
3240 |
+
* @since BuddyPress (1.7.0)
|
3241 |
+
*
|
3242 |
+
* @param array $value Array of nav menu objects.
|
3243 |
+
* @param array $args Array of arguments for the menu.
|
3244 |
+
*/
|
3245 |
Â
$menu_items = apply_filters( 'bp_nav_menu_objects', bp_get_nav_menu_items(), $args );
|
3246 |
Â
$items = walk_nav_menu_tree( $menu_items, $args->depth, $args );
|
3247 |
Â
unset( $menu_items );
|
3264 |
Â
}
|
3265 |
Â
$menu_id_slugs[] = $wrap_id;
|
3266 |
Â
|
3267 |
+
/**
|
3268 |
+
* Filters the BuddyPress menu items.
|
3269 |
+
*
|
3270 |
+
* Allow plugins to hook into the menu to add their own <li>'s
|
3271 |
+
*
|
3272 |
+
* @since BuddyPress (1.7.0)
|
3273 |
+
*
|
3274 |
+
* @param array $items Array of nav menu items.
|
3275 |
+
* @param array $args Array of arguments for the menu.
|
3276 |
+
*/
|
3277 |
Â
$items = apply_filters( 'bp_nav_menu_items', $items, $args );
|
3278 |
Â
|
3279 |
Â
// Build the output
|
3286 |
Â
$nav_menu .= '</' . $args->container . '>';
|
3287 |
Â
}
|
3288 |
Â
|
3289 |
+
/**
|
3290 |
+
* Filters the final BuddyPress menu output.
|
3291 |
+
*
|
3292 |
+
* @since BuddyPress (1.7.0)
|
3293 |
+
*
|
3294 |
+
* @param string $nav_menu Final nav menu output.
|
3295 |
+
* @param array $args Array of arguments for the menu.
|
3296 |
+
*/
|
3297 |
Â
$nav_menu = apply_filters( 'bp_nav_menu', $nav_menu, $args );
|
3298 |
Â
|
3299 |
Â
if ( ! empty( $args->echo ) ) {
|
bp-core/bp-core-theme-compatibility.php
CHANGED
@@ -164,6 +164,14 @@ function bp_setup_theme_compat( $theme = '' ) {
|
|
164 |
Â
* @return string ID of the theme package in use.
|
165 |
Â
*/
|
166 |
Â
function bp_get_theme_compat_id() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
167 |
Â
return apply_filters( 'bp_get_theme_compat_id', buddypress()->theme_compat->theme->id );
|
168 |
Â
}
|
169 |
Â
|
@@ -180,6 +188,14 @@ function bp_get_theme_compat_id() {
|
|
180 |
Â
* @return string Name of the theme package currently in use.
|
181 |
Â
*/
|
182 |
Â
function bp_get_theme_compat_name() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
183 |
Â
return apply_filters( 'bp_get_theme_compat_name', buddypress()->theme_compat->theme->name );
|
184 |
Â
}
|
185 |
Â
|
@@ -196,6 +212,14 @@ function bp_get_theme_compat_name() {
|
|
196 |
Â
* @return string The version string of the theme package currently in use.
|
197 |
Â
*/
|
198 |
Â
function bp_get_theme_compat_version() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
199 |
Â
return apply_filters( 'bp_get_theme_compat_version', buddypress()->theme_compat->theme->version );
|
200 |
Â
}
|
201 |
Â
|
@@ -212,6 +236,14 @@ function bp_get_theme_compat_version() {
|
|
212 |
Â
* @return string The absolute path of the theme package currently in use.
|
213 |
Â
*/
|
214 |
Â
function bp_get_theme_compat_dir() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
215 |
Â
return apply_filters( 'bp_get_theme_compat_dir', buddypress()->theme_compat->theme->dir );
|
216 |
Â
}
|
217 |
Â
|
@@ -229,6 +261,14 @@ function bp_get_theme_compat_dir() {
|
|
229 |
Â
* @return string URL of the theme package currently in use.
|
230 |
Â
*/
|
231 |
Â
function bp_get_theme_compat_url() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
232 |
Â
return apply_filters( 'bp_get_theme_compat_url', buddypress()->theme_compat->theme->url );
|
233 |
Â
}
|
234 |
Â
|
@@ -249,6 +289,13 @@ function bp_use_theme_compat_with_current_theme() {
|
|
249 |
Â
bp_detect_theme_compat_with_current_theme();
|
250 |
Â
}
|
251 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
252 |
Â
return apply_filters( 'bp_use_theme_compat_with_current_theme', buddypress()->theme_compat->use_with_current_theme );
|
253 |
Â
}
|
254 |
Â
|
@@ -406,7 +453,7 @@ function bp_is_theme_compat_original_template( $template = '' ) {
|
|
406 |
Â
* For an example of how this function is used, see:
|
407 |
Â
* {@link BuddyPress::register_theme_packages()}.
|
408 |
Â
*
|
409 |
-
* @since BuddyPress (1.7)
|
410 |
Â
*
|
411 |
Â
* @see BP_Theme_Compat for a description of the $theme parameter arguments.
|
412 |
Â
*
|
@@ -550,7 +597,7 @@ function bp_theme_compat_reset_post( $args = array() ) {
|
|
550 |
Â
/**
|
551 |
Â
* Force the header back to 200 status if not a deliberate 404
|
552 |
Â
*
|
553 |
-
* @see
|
554 |
Â
*/
|
555 |
Â
if ( ! $wp_query->is_404() ) {
|
556 |
Â
status_header( 200 );
|
@@ -597,9 +644,13 @@ function bp_template_include_theme_compat( $template = '' ) {
|
|
597 |
Â
}
|
598 |
Â
|
599 |
Â
/**
|
Â
|
|
Â
|
|
600 |
Â
* Use this action to execute code that will communicate to BuddyPress's
|
601 |
Â
* theme compatibility layer whether or not we're replacing the_content()
|
602 |
Â
* with some other template part.
|
Â
|
|
Â
|
|
603 |
Â
*/
|
604 |
Â
do_action( 'bp_template_include_reset_dummy_post_data' );
|
605 |
Â
|
@@ -636,6 +687,13 @@ function bp_template_include_theme_compat( $template = '' ) {
|
|
636 |
Â
}
|
637 |
Â
}
|
638 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
639 |
Â
return apply_filters( 'bp_template_include_theme_compat', $template );
|
640 |
Â
}
|
641 |
Â
|
@@ -662,7 +720,13 @@ function bp_replace_the_content( $content = '' ) {
|
|
662 |
Â
// the_content() that execute before theme compat has unhooked itself.
|
663 |
Â
bp_set_theme_compat_active( false );
|
664 |
Â
|
665 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
666 |
Â
$new_content = apply_filters( 'bp_replace_the_content', $content );
|
667 |
Â
|
668 |
Â
// Juggle the content around and try to prevent unsightly comments
|
@@ -823,7 +887,15 @@ function bp_comments_open( $open, $post_id = 0 ) {
|
|
823 |
Â
|
824 |
Â
$retval = is_buddypress() ? false : $open;
|
825 |
Â
|
826 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
827 |
Â
return apply_filters( 'bp_force_comment_status', $retval, $open, $post_id );
|
828 |
Â
}
|
829 |
Â
|
@@ -848,8 +920,7 @@ function bp_comments_open( $open, $post_id = 0 ) {
|
|
848 |
Â
function bp_theme_compat_toggle_is_page( $retval = '' ) {
|
849 |
Â
global $wp_query;
|
850 |
Â
|
851 |
-
$wp_query->
|
852 |
-
$wp_query->is_page = false;
|
853 |
Â
|
854 |
Â
// Set a switch so we know that we've toggled these WP_Query properties
|
855 |
Â
buddypress()->theme_compat->is_page_toggled = true;
|
@@ -877,8 +948,7 @@ function bp_theme_compat_loop_end( $query ) {
|
|
877 |
Â
}
|
878 |
Â
|
879 |
Â
// Revert our toggled WP_Query properties
|
880 |
-
$query->
|
881 |
-
$query->is_page = true;
|
882 |
Â
|
883 |
Â
// Unset our switch
|
884 |
Â
unset( $bp->theme_compat->is_page_toggled );
|
164 |
Â
* @return string ID of the theme package in use.
|
165 |
Â
*/
|
166 |
Â
function bp_get_theme_compat_id() {
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Filters the ID of the theme package being used.
|
170 |
+
*
|
171 |
+
* @since BuddyPress (1.7.0)
|
172 |
+
*
|
173 |
+
* @param string $id ID of the theme package in use.
|
174 |
+
*/
|
175 |
Â
return apply_filters( 'bp_get_theme_compat_id', buddypress()->theme_compat->theme->id );
|
176 |
Â
}
|
177 |
Â
|
188 |
Â
* @return string Name of the theme package currently in use.
|
189 |
Â
*/
|
190 |
Â
function bp_get_theme_compat_name() {
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Filters the name of the theme package being used.
|
194 |
+
*
|
195 |
+
* @since BuddyPress (1.7.0)
|
196 |
+
*
|
197 |
+
* @param string $name Name of the theme package in use.
|
198 |
+
*/
|
199 |
Â
return apply_filters( 'bp_get_theme_compat_name', buddypress()->theme_compat->theme->name );
|
200 |
Â
}
|
201 |
Â
|
212 |
Â
* @return string The version string of the theme package currently in use.
|
213 |
Â
*/
|
214 |
Â
function bp_get_theme_compat_version() {
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Filters the version of the theme package being used.
|
218 |
+
*
|
219 |
+
* @since BuddyPress (1.7.0)
|
220 |
+
*
|
221 |
+
* @param string $version The version string of the theme package in use.
|
222 |
+
*/
|
223 |
Â
return apply_filters( 'bp_get_theme_compat_version', buddypress()->theme_compat->theme->version );
|
224 |
Â
}
|
225 |
Â
|
236 |
Â
* @return string The absolute path of the theme package currently in use.
|
237 |
Â
*/
|
238 |
Â
function bp_get_theme_compat_dir() {
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Filters the absolute path of the theme package being used.
|
242 |
+
*
|
243 |
+
* @since BuddyPress (1.7.0)
|
244 |
+
*
|
245 |
+
* @param string $dir The absolute path of the theme package in use.
|
246 |
+
*/
|
247 |
Â
return apply_filters( 'bp_get_theme_compat_dir', buddypress()->theme_compat->theme->dir );
|
248 |
Â
}
|
249 |
Â
|
261 |
Â
* @return string URL of the theme package currently in use.
|
262 |
Â
*/
|
263 |
Â
function bp_get_theme_compat_url() {
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Filters the URL of the theme package being used.
|
267 |
+
*
|
268 |
+
* @since BuddyPress (1.7.0)
|
269 |
+
*
|
270 |
+
* @param string $url URL of the theme package in use.
|
271 |
+
*/
|
272 |
Â
return apply_filters( 'bp_get_theme_compat_url', buddypress()->theme_compat->theme->url );
|
273 |
Â
}
|
274 |
Â
|
289 |
Â
bp_detect_theme_compat_with_current_theme();
|
290 |
Â
}
|
291 |
Â
|
292 |
+
/**
|
293 |
+
* Filters whether or not to use theme compat for the active theme.
|
294 |
+
*
|
295 |
+
* @since BuddyPress (1.9.0)
|
296 |
+
*
|
297 |
+
* @param bool $use_with_current_theme True if the current theme needs theme compatibility.
|
298 |
+
*/
|
299 |
Â
return apply_filters( 'bp_use_theme_compat_with_current_theme', buddypress()->theme_compat->use_with_current_theme );
|
300 |
Â
}
|
301 |
Â
|
453 |
Â
* For an example of how this function is used, see:
|
454 |
Â
* {@link BuddyPress::register_theme_packages()}.
|
455 |
Â
*
|
456 |
+
* @since BuddyPress (1.7.0)
|
457 |
Â
*
|
458 |
Â
* @see BP_Theme_Compat for a description of the $theme parameter arguments.
|
459 |
Â
*
|
597 |
Â
/**
|
598 |
Â
* Force the header back to 200 status if not a deliberate 404
|
599 |
Â
*
|
600 |
+
* @see https://bbpress.trac.wordpress.org/ticket/1973
|
601 |
Â
*/
|
602 |
Â
if ( ! $wp_query->is_404() ) {
|
603 |
Â
status_header( 200 );
|
644 |
Â
}
|
645 |
Â
|
646 |
Â
/**
|
647 |
+
* Fires when resetting main query vars and filtering 'the_content' to output BuddyPress template parts.
|
648 |
+
*
|
649 |
Â
* Use this action to execute code that will communicate to BuddyPress's
|
650 |
Â
* theme compatibility layer whether or not we're replacing the_content()
|
651 |
Â
* with some other template part.
|
652 |
+
*
|
653 |
+
* @since BuddyPress (1.7.0)
|
654 |
Â
*/
|
655 |
Â
do_action( 'bp_template_include_reset_dummy_post_data' );
|
656 |
Â
|
687 |
Â
}
|
688 |
Â
}
|
689 |
Â
|
690 |
+
/**
|
691 |
+
* Filters the template name to include.
|
692 |
+
*
|
693 |
+
* @since BuddyPress (1.7.0)
|
694 |
+
*
|
695 |
+
* @param string $template Template name.
|
696 |
+
*/
|
697 |
Â
return apply_filters( 'bp_template_include_theme_compat', $template );
|
698 |
Â
}
|
699 |
Â
|
720 |
Â
// the_content() that execute before theme compat has unhooked itself.
|
721 |
Â
bp_set_theme_compat_active( false );
|
722 |
Â
|
723 |
+
/**
|
724 |
+
* Filters the content to replace in the post.
|
725 |
+
*
|
726 |
+
* @since BuddyPress (1.7.0)
|
727 |
+
*
|
728 |
+
* @param string $content Original post content.
|
729 |
+
*/
|
730 |
Â
$new_content = apply_filters( 'bp_replace_the_content', $content );
|
731 |
Â
|
732 |
Â
// Juggle the content around and try to prevent unsightly comments
|
887 |
Â
|
888 |
Â
$retval = is_buddypress() ? false : $open;
|
889 |
Â
|
890 |
+
/**
|
891 |
+
* Filters whether or not to force comments_status to closed for BuddyPress post types.
|
892 |
+
*
|
893 |
+
* @since BuddyPress (1.7.0)
|
894 |
+
*
|
895 |
+
* @param bool $retval Whether or not we are on a BuddyPress post type.
|
896 |
+
* @param bool $open True if comments open, false if closed.
|
897 |
+
* @param int $post_id Post ID for the checked post.
|
898 |
+
*/
|
899 |
Â
return apply_filters( 'bp_force_comment_status', $retval, $open, $post_id );
|
900 |
Â
}
|
901 |
Â
|
920 |
Â
function bp_theme_compat_toggle_is_page( $retval = '' ) {
|
921 |
Â
global $wp_query;
|
922 |
Â
|
923 |
+
$wp_query->is_page = false;
|
Â
|
|
924 |
Â
|
925 |
Â
// Set a switch so we know that we've toggled these WP_Query properties
|
926 |
Â
buddypress()->theme_compat->is_page_toggled = true;
|
948 |
Â
}
|
949 |
Â
|
950 |
Â
// Revert our toggled WP_Query properties
|
951 |
+
$query->is_page = true;
|
Â
|
|
952 |
Â
|
953 |
Â
// Unset our switch
|
954 |
Â
unset( $bp->theme_compat->is_page_toggled );
|
bp-core/bp-core-update.php
CHANGED
@@ -187,6 +187,13 @@ function bp_version_updater() {
|
|
187 |
Â
// Get the raw database version
|
188 |
Â
$raw_db_version = (int) bp_get_db_version_raw();
|
189 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
190 |
Â
$default_components = apply_filters( 'bp_new_install_default_components', array(
|
191 |
Â
'activity' => 1,
|
192 |
Â
'members' => 1,
|
@@ -195,7 +202,7 @@ function bp_version_updater() {
|
|
195 |
Â
'notifications' => 1,
|
196 |
Â
) );
|
197 |
Â
|
198 |
-
require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-schema.php' );
|
199 |
Â
|
200 |
Â
// Install BP schema and activate only Activity and XProfile
|
201 |
Â
if ( bp_is_install() ) {
|
@@ -211,18 +218,18 @@ function bp_version_updater() {
|
|
211 |
Â
// Run the schema install to update tables
|
212 |
Â
bp_core_install();
|
213 |
Â
|
214 |
-
// 1.5
|
215 |
Â
if ( $raw_db_version < 1801 ) {
|
216 |
Â
bp_update_to_1_5();
|
217 |
Â
bp_core_add_page_mappings( $default_components, 'delete' );
|
218 |
Â
}
|
219 |
Â
|
220 |
-
// 1.6
|
221 |
Â
if ( $raw_db_version < 6067 ) {
|
222 |
Â
bp_update_to_1_6();
|
223 |
Â
}
|
224 |
Â
|
225 |
-
// 1.9
|
226 |
Â
if ( $raw_db_version < 7553 ) {
|
227 |
Â
bp_update_to_1_9();
|
228 |
Â
}
|
@@ -232,7 +239,7 @@ function bp_version_updater() {
|
|
232 |
Â
bp_update_to_1_9_2();
|
233 |
Â
}
|
234 |
Â
|
235 |
-
// 2.0
|
236 |
Â
if ( $raw_db_version < 7892 ) {
|
237 |
Â
bp_update_to_2_0();
|
238 |
Â
}
|
@@ -242,10 +249,15 @@ function bp_version_updater() {
|
|
242 |
Â
bp_update_to_2_0_1();
|
243 |
Â
}
|
244 |
Â
|
245 |
-
// 2.2
|
246 |
Â
if ( $raw_db_version < 9181 ) {
|
247 |
Â
bp_update_to_2_2();
|
248 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
249 |
Â
}
|
250 |
Â
|
251 |
Â
/** All done! *************************************************************/
|
@@ -254,6 +266,41 @@ function bp_version_updater() {
|
|
254 |
Â
bp_version_bump();
|
255 |
Â
}
|
256 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
257 |
Â
/** Upgrade Routines **********************************************************/
|
258 |
Â
|
259 |
Â
/**
|
@@ -404,6 +451,8 @@ function bp_update_to_2_0_1() {
|
|
404 |
Â
* @since BuddyPress (2.2.0)
|
405 |
Â
*/
|
406 |
Â
function bp_update_to_2_2() {
|
Â
|
|
Â
|
|
407 |
Â
if ( bp_is_active( 'messages' ) ) {
|
408 |
Â
bp_core_install_private_messaging();
|
409 |
Â
}
|
@@ -417,6 +466,21 @@ function bp_update_to_2_2() {
|
|
417 |
Â
}
|
418 |
Â
}
|
419 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
420 |
Â
/**
|
421 |
Â
* Updates the component field for new_members type.
|
422 |
Â
*
|
@@ -557,7 +621,13 @@ function bp_activation() {
|
|
557 |
Â
// Add options
|
558 |
Â
bp_add_options();
|
559 |
Â
|
560 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
561 |
Â
do_action( 'bp_activation' );
|
562 |
Â
|
563 |
Â
// @deprecated as of (1.6)
|
@@ -586,7 +656,13 @@ function bp_deactivation() {
|
|
586 |
Â
update_option( 'stylesheet_root', get_raw_theme_root( WP_DEFAULT_THEME, true ) );
|
587 |
Â
}
|
588 |
Â
|
589 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
590 |
Â
do_action( 'bp_deactivation' );
|
591 |
Â
|
592 |
Â
// @deprecated as of (1.6)
|
@@ -603,5 +679,11 @@ function bp_deactivation() {
|
|
603 |
Â
* @uses do_action() Calls 'bp_uninstall' hook.
|
604 |
Â
*/
|
605 |
Â
function bp_uninstall() {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
606 |
Â
do_action( 'bp_uninstall' );
|
607 |
Â
}
|
187 |
Â
// Get the raw database version
|
188 |
Â
$raw_db_version = (int) bp_get_db_version_raw();
|
189 |
Â
|
190 |
+
/**
|
191 |
+
* Filters the default components to activate for a new install.
|
192 |
+
*
|
193 |
+
* @since BuddyPress (1.7.0)
|
194 |
+
*
|
195 |
+
* @param array $value Array of default components to activate.
|
196 |
+
*/
|
197 |
Â
$default_components = apply_filters( 'bp_new_install_default_components', array(
|
198 |
Â
'activity' => 1,
|
199 |
Â
'members' => 1,
|
202 |
Â
'notifications' => 1,
|
203 |
Â
) );
|
204 |
Â
|
205 |
+
require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
|
206 |
Â
|
207 |
Â
// Install BP schema and activate only Activity and XProfile
|
208 |
Â
if ( bp_is_install() ) {
|
218 |
Â
// Run the schema install to update tables
|
219 |
Â
bp_core_install();
|
220 |
Â
|
221 |
+
// 1.5.0
|
222 |
Â
if ( $raw_db_version < 1801 ) {
|
223 |
Â
bp_update_to_1_5();
|
224 |
Â
bp_core_add_page_mappings( $default_components, 'delete' );
|
225 |
Â
}
|
226 |
Â
|
227 |
+
// 1.6.0
|
228 |
Â
if ( $raw_db_version < 6067 ) {
|
229 |
Â
bp_update_to_1_6();
|
230 |
Â
}
|
231 |
Â
|
232 |
+
// 1.9.0
|
233 |
Â
if ( $raw_db_version < 7553 ) {
|
234 |
Â
bp_update_to_1_9();
|
235 |
Â
}
|
239 |
Â
bp_update_to_1_9_2();
|
240 |
Â
}
|
241 |
Â
|
242 |
+
// 2.0.0
|
243 |
Â
if ( $raw_db_version < 7892 ) {
|
244 |
Â
bp_update_to_2_0();
|
245 |
Â
}
|
249 |
Â
bp_update_to_2_0_1();
|
250 |
Â
}
|
251 |
Â
|
252 |
+
// 2.2.0
|
253 |
Â
if ( $raw_db_version < 9181 ) {
|
254 |
Â
bp_update_to_2_2();
|
255 |
Â
}
|
256 |
+
|
257 |
+
// 2.3.0
|
258 |
+
if ( $raw_db_version < 9615 ) {
|
259 |
+
bp_update_to_2_3();
|
260 |
+
}
|
261 |
Â
}
|
262 |
Â
|
263 |
Â
/** All done! *************************************************************/
|
266 |
Â
bp_version_bump();
|
267 |
Â
}
|
268 |
Â
|
269 |
+
/**
|
270 |
+
* Perform database operations that must take place before the general schema upgrades.
|
271 |
+
*
|
272 |
+
* `dbDelta()` cannot handle certain operations - like changing indexes - so we do it here instead.
|
273 |
+
*
|
274 |
+
* @since BuddyPress (2.3.0)
|
275 |
+
*/
|
276 |
+
function bp_pre_schema_upgrade() {
|
277 |
+
global $wpdb;
|
278 |
+
|
279 |
+
$raw_db_version = (int) bp_get_db_version_raw();
|
280 |
+
$bp_prefix = bp_core_get_table_prefix();
|
281 |
+
|
282 |
+
// 2.3.0: Change index lengths to account for utf8mb4.
|
283 |
+
if ( $raw_db_version < 9695 ) {
|
284 |
+
// table_name => columns.
|
285 |
+
$tables = array(
|
286 |
+
$bp_prefix . 'bp_activity_meta' => array( 'meta_key' ),
|
287 |
+
$bp_prefix . 'bp_groups_groupmeta' => array( 'meta_key' ),
|
288 |
+
$bp_prefix . 'bp_messages_meta' => array( 'meta_key' ),
|
289 |
+
$bp_prefix . 'bp_notifications_meta' => array( 'meta_key' ),
|
290 |
+
$bp_prefix . 'bp_user_blogs_blogmeta' => array( 'meta_key' ),
|
291 |
+
$bp_prefix . 'bp_xprofile_meta' => array( 'meta_key' ),
|
292 |
+
);
|
293 |
+
|
294 |
+
foreach ( $tables as $table_name => $indexes ) {
|
295 |
+
foreach ( $indexes as $index ) {
|
296 |
+
if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", bp_esc_like( $table_name ) ) ) ) {
|
297 |
+
$wpdb->query( "ALTER TABLE {$table_name} DROP INDEX {$index}" );
|
298 |
+
}
|
299 |
+
}
|
300 |
+
}
|
301 |
+
}
|
302 |
+
}
|
303 |
+
|
304 |
Â
/** Upgrade Routines **********************************************************/
|
305 |
Â
|
306 |
Â
/**
|
451 |
Â
* @since BuddyPress (2.2.0)
|
452 |
Â
*/
|
453 |
Â
function bp_update_to_2_2() {
|
454 |
+
|
455 |
+
// Also handled by `bp_core_install()`
|
456 |
Â
if ( bp_is_active( 'messages' ) ) {
|
457 |
Â
bp_core_install_private_messaging();
|
458 |
Â
}
|
466 |
Â
}
|
467 |
Â
}
|
468 |
Â
|
469 |
+
/**
|
470 |
+
* 2.3.0 update routine.
|
471 |
+
*
|
472 |
+
* - Add notifications meta table
|
473 |
+
*
|
474 |
+
* @since BuddyPress (2.3.0)
|
475 |
+
*/
|
476 |
+
function bp_update_to_2_3() {
|
477 |
+
|
478 |
+
// Also handled by `bp_core_install()`
|
479 |
+
if ( bp_is_active( 'notifications' ) ) {
|
480 |
+
bp_core_install_notifications();
|
481 |
+
}
|
482 |
+
}
|
483 |
+
|
484 |
Â
/**
|
485 |
Â
* Updates the component field for new_members type.
|
486 |
Â
*
|
621 |
Â
// Add options
|
622 |
Â
bp_add_options();
|
623 |
Â
|
624 |
+
/**
|
625 |
+
* Fires during the activation of BuddyPress.
|
626 |
+
*
|
627 |
+
* Use as of (1.6.0)
|
628 |
+
*
|
629 |
+
* @since BuddyPress (1.6.0)
|
630 |
+
*/
|
631 |
Â
do_action( 'bp_activation' );
|
632 |
Â
|
633 |
Â
// @deprecated as of (1.6)
|
656 |
Â
update_option( 'stylesheet_root', get_raw_theme_root( WP_DEFAULT_THEME, true ) );
|
657 |
Â
}
|
658 |
Â
|
659 |
+
/**
|
660 |
+
* Fires during the deactivation of BuddyPress.
|
661 |
+
*
|
662 |
+
* Use as of (1.6.0)
|
663 |
+
*
|
664 |
+
* @since BuddyPress (1.6.0)
|
665 |
+
*/
|
666 |
Â
do_action( 'bp_deactivation' );
|
667 |
Â
|
668 |
Â
// @deprecated as of (1.6)
|
679 |
Â
* @uses do_action() Calls 'bp_uninstall' hook.
|
680 |
Â
*/
|
681 |
Â
function bp_uninstall() {
|
682 |
+
|
683 |
+
/**
|
684 |
+
* Fires during the uninstallation of BuddyPress.
|
685 |
+
*
|
686 |
+
* @since BuddyPress (1.6.0)
|
687 |
+
*/
|
688 |
Â
do_action( 'bp_uninstall' );
|
689 |
Â
}
|
bp-core/bp-core-widgets.php
CHANGED
@@ -50,7 +50,18 @@ class BP_Core_Login_Widget extends WP_Widget {
|
|
50 |
Â
*/
|
51 |
Â
public function widget( $args, $instance ) {
|
52 |
Â
$title = isset( $instance['title'] ) ? $instance['title'] : '';
|
53 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
54 |
Â
|
55 |
Â
echo $args['before_widget'];
|
56 |
Â
|
@@ -58,7 +69,14 @@ class BP_Core_Login_Widget extends WP_Widget {
|
|
58 |
Â
|
59 |
Â
<?php if ( is_user_logged_in() ) : ?>
|
60 |
Â
|
61 |
-
<?php
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
62 |
Â
|
63 |
Â
<div class="bp-login-widget-user-avatar">
|
64 |
Â
<a href="<?php echo bp_loggedin_user_domain(); ?>">
|
@@ -71,18 +89,32 @@ class BP_Core_Login_Widget extends WP_Widget {
|
|
71 |
Â
<div class="bp-login-widget-user-logout"><a class="logout" href="<?php echo wp_logout_url( bp_get_requested_url() ); ?>"><?php _e( 'Log Out', 'buddypress' ); ?></a></div>
|
72 |
Â
</div>
|
73 |
Â
|
74 |
-
<?php
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
75 |
Â
|
76 |
Â
<?php else : ?>
|
77 |
Â
|
78 |
-
<?php
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
79 |
Â
|
80 |
Â
<form name="bp-login-form" id="bp-login-widget-form" class="standard-form" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
|
81 |
Â
<label for="bp-login-widget-user-login"><?php _e( 'Username', 'buddypress' ); ?></label>
|
82 |
Â
<input type="text" name="log" id="bp-login-widget-user-login" class="input" value="" />
|
83 |
Â
|
84 |
Â
<label for="bp-login-widget-user-pass"><?php _e( 'Password', 'buddypress' ); ?></label>
|
85 |
-
<input type="password" name="pwd" id="bp-login-widget-user-pass" class="input" value=""
|
86 |
Â
|
87 |
Â
<div class="forgetmenot"><label><input name="rememberme" type="checkbox" id="bp-login-widget-rememberme" value="forever" /> <?php _e( 'Remember Me', 'buddypress' ); ?></label></div>
|
88 |
Â
|
@@ -96,7 +128,14 @@ class BP_Core_Login_Widget extends WP_Widget {
|
|
96 |
Â
|
97 |
Â
</form>
|
98 |
Â
|
99 |
-
<?php
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
100 |
Â
|
101 |
Â
<?php endif;
|
102 |
Â
|
50 |
Â
*/
|
51 |
Â
public function widget( $args, $instance ) {
|
52 |
Â
$title = isset( $instance['title'] ) ? $instance['title'] : '';
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Filters the title of the Login widget.
|
56 |
+
*
|
57 |
+
* @since BuddyPress (1.9.0)
|
58 |
+
* @since BuddyPress (2.3.0) Added 'instance' and 'id_base' to arguments passed to filter.
|
59 |
+
*
|
60 |
+
* @param string $title The widget title.
|
61 |
+
* @param array $instance The settings for the particular instance of the widget.
|
62 |
+
* @param string $id_base Root ID for all widgets of this type.
|
63 |
+
*/
|
64 |
+
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
65 |
Â
|
66 |
Â
echo $args['before_widget'];
|
67 |
Â
|
69 |
Â
|
70 |
Â
<?php if ( is_user_logged_in() ) : ?>
|
71 |
Â
|
72 |
+
<?php
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Fires before the display of widget content if logged in.
|
76 |
+
*
|
77 |
+
* @since BuddyPress (1.9.0)
|
78 |
+
*/
|
79 |
+
do_action( 'bp_before_login_widget_loggedin' ); ?>
|
80 |
Â
|
81 |
Â
<div class="bp-login-widget-user-avatar">
|
82 |
Â
<a href="<?php echo bp_loggedin_user_domain(); ?>">
|
89 |
Â
<div class="bp-login-widget-user-logout"><a class="logout" href="<?php echo wp_logout_url( bp_get_requested_url() ); ?>"><?php _e( 'Log Out', 'buddypress' ); ?></a></div>
|
90 |
Â
</div>
|
91 |
Â
|
92 |
+
<?php
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Fires after the display of widget content if logged in.
|
96 |
+
*
|
97 |
+
* @since BuddyPress (1.9.0)
|
98 |
+
*/
|
99 |
+
do_action( 'bp_after_login_widget_loggedin' ); ?>
|
100 |
Â
|
101 |
Â
<?php else : ?>
|
102 |
Â
|
103 |
+
<?php
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Fires before the display of widget content if logged out.
|
107 |
+
*
|
108 |
+
* @since BuddyPress (1.9.0)
|
109 |
+
*/
|
110 |
+
do_action( 'bp_before_login_widget_loggedout' ); ?>
|
111 |
Â
|
112 |
Â
<form name="bp-login-form" id="bp-login-widget-form" class="standard-form" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
|
113 |
Â
<label for="bp-login-widget-user-login"><?php _e( 'Username', 'buddypress' ); ?></label>
|
114 |
Â
<input type="text" name="log" id="bp-login-widget-user-login" class="input" value="" />
|
115 |
Â
|
116 |
Â
<label for="bp-login-widget-user-pass"><?php _e( 'Password', 'buddypress' ); ?></label>
|
117 |
+
<input type="password" name="pwd" id="bp-login-widget-user-pass" class="input" value="" <?php bp_form_field_attributes( 'password' ) ?> />
|
118 |
Â
|
119 |
Â
<div class="forgetmenot"><label><input name="rememberme" type="checkbox" id="bp-login-widget-rememberme" value="forever" /> <?php _e( 'Remember Me', 'buddypress' ); ?></label></div>
|
120 |
Â
|
128 |
Â
|
129 |
Â
</form>
|
130 |
Â
|
131 |
+
<?php
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Fires after the display of widget content if logged out.
|
135 |
+
*
|
136 |
+
* @since BuddyPress (1.9.0)
|
137 |
+
*/
|
138 |
+
do_action( 'bp_after_login_widget_loggedout' ); ?>
|
139 |
Â
|
140 |
Â
<?php endif;
|
141 |
Â
|
bp-core/classes/class-bp-attachment-avatar.php
ADDED
@@ -0,0 +1,415 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Core Avatars attachment class
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
* @subpackage Core
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Exit if accessed directly
|
10 |
+
defined( 'ABSPATH' ) || exit;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* BP Attachment Avatar class
|
14 |
+
*
|
15 |
+
* Extends BP Attachment to manage the avatar uploads
|
16 |
+
*
|
17 |
+
* @since BuddyPress (2.3.0)
|
18 |
+
*/
|
19 |
+
class BP_Attachment_Avatar extends BP_Attachment {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Construct Upload parameters
|
23 |
+
*
|
24 |
+
* @since BuddyPress (2.3.0)
|
25 |
+
*
|
26 |
+
* @see BP_Attachment::__construct() for list of parameters
|
27 |
+
* @uses bp_core_avatar_original_max_filesize()
|
28 |
+
* @uses BP_Attachment::__construct()
|
29 |
+
*/
|
30 |
+
public function __construct() {
|
31 |
+
// Allowed avatar types
|
32 |
+
$allowed_types = bp_core_get_allowed_avatar_types();
|
33 |
+
|
34 |
+
parent::__construct( array(
|
35 |
+
'action' => 'bp_avatar_upload',
|
36 |
+
'file_input' => 'file',
|
37 |
+
'original_max_filesize' => bp_core_avatar_original_max_filesize(),
|
38 |
+
|
39 |
+
// Specific errors for avatars
|
40 |
+
'upload_error_strings' => array(
|
41 |
+
9 => sprintf( __( 'That photo is too big. Please upload one smaller than %s', 'buddypress' ), size_format( bp_core_avatar_original_max_filesize() ) ),
|
42 |
+
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 ) ),
|
43 |
+
),
|
44 |
+
) );
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Gets the available avatar types
|
49 |
+
*
|
50 |
+
* @since BuddyPress (2.3.0)
|
51 |
+
* @return string comma separated list of allowed avatar types
|
52 |
+
*/
|
53 |
+
public static function get_avatar_types( $allowed_types = array() ) {
|
54 |
+
$types = array_map( 'strtoupper', $allowed_types );
|
55 |
+
$comma = _x( ',', 'avatar types separator', 'buddypress' );
|
56 |
+
return join( $comma . ' ', $types );
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Set Upload Dir data for avatars
|
61 |
+
*
|
62 |
+
* @since BuddyPress (2.3.0)
|
63 |
+
*
|
64 |
+
* @uses bp_core_avatar_upload_path()
|
65 |
+
* @uses bp_core_avatar_url()
|
66 |
+
* @uses bp_upload_dir()
|
67 |
+
* @uses BP_Attachment::set_upload_dir()
|
68 |
+
*/
|
69 |
+
public function set_upload_dir() {
|
70 |
+
if ( bp_core_avatar_upload_path() && bp_core_avatar_url() ) {
|
71 |
+
$this->upload_path = bp_core_avatar_upload_path();
|
72 |
+
$this->url = bp_core_avatar_url();
|
73 |
+
$this->upload_dir = bp_upload_dir();
|
74 |
+
} else {
|
75 |
+
parent::set_upload_dir();
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Avatar specific rules
|
81 |
+
*
|
82 |
+
* Adds an error if the avatar size or type don't match BuddyPress needs
|
83 |
+
* The error code is the index of $upload_error_strings
|
84 |
+
*
|
85 |
+
* @since BuddyPress (2.3.0)
|
86 |
+
*
|
87 |
+
* @param array $file the temporary file attributes (before it has been moved)
|
88 |
+
* @uses bp_core_check_avatar_size()
|
89 |
+
* @uses bp_core_check_avatar_type()
|
90 |
+
* @return array the file with extra errors if needed
|
91 |
+
*/
|
92 |
+
public function validate_upload( $file = array() ) {
|
93 |
+
// Bail if already an error
|
94 |
+
if ( ! empty( $file['error'] ) ) {
|
95 |
+
return $file;
|
96 |
+
}
|
97 |
+
|
98 |
+
// File size is too big
|
99 |
+
if ( ! bp_core_check_avatar_size( array( 'file' => $file ) ) ) {
|
100 |
+
$file['error'] = 9;
|
101 |
+
|
102 |
+
// File is of invalid type
|
103 |
+
} elseif ( ! bp_core_check_avatar_type( array( 'file' => $file ) ) ) {
|
104 |
+
$file['error'] = 10;
|
105 |
+
}
|
106 |
+
|
107 |
+
// Return with error code attached
|
108 |
+
return $file;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Maybe shrink the attachment to fit maximum allowed width
|
113 |
+
*
|
114 |
+
* @since BuddyPress (2.3.0)
|
115 |
+
*
|
116 |
+
* @param string $file the absolute path to the file
|
117 |
+
* @uses bp_core_avatar_original_max_width()
|
118 |
+
* @uses wp_get_image_editor()
|
119 |
+
* @return mixed
|
120 |
+
*/
|
121 |
+
public static function shrink( $file = '' ) {
|
122 |
+
// Get image size
|
123 |
+
$size = @getimagesize( $file );
|
124 |
+
$retval = false;
|
125 |
+
|
126 |
+
// Check image size and shrink if too large
|
127 |
+
if ( $size[0] > bp_core_avatar_original_max_width() ) {
|
128 |
+
$editor = wp_get_image_editor( $file );
|
129 |
+
|
130 |
+
if ( ! is_wp_error( $editor ) ) {
|
131 |
+
$editor->set_quality( 100 );
|
132 |
+
|
133 |
+
$resized = $editor->resize( bp_core_avatar_original_max_width(), bp_core_avatar_original_max_width(), false );
|
134 |
+
if ( ! is_wp_error( $resized ) ) {
|
135 |
+
$thumb = $editor->save( $editor->generate_filename() );
|
136 |
+
} else {
|
137 |
+
$retval = $resized;
|
138 |
+
}
|
139 |
+
|
140 |
+
// Check for thumbnail creation errors
|
141 |
+
if ( ( false === $retval ) && is_wp_error( $thumb ) ) {
|
142 |
+
$retval = $thumb;
|
143 |
+
}
|
144 |
+
|
145 |
+
// Thumbnail is good so proceed
|
146 |
+
if ( false === $retval ) {
|
147 |
+
$retval = $thumb;
|
148 |
+
}
|
149 |
+
|
150 |
+
} else {
|
151 |
+
$retval = $editor;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
return $retval;
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Check if the image dimensions are smaller than full avatar dimensions
|
160 |
+
*
|
161 |
+
* @since BuddyPress (2.3.0)
|
162 |
+
*
|
163 |
+
* @param string $file the absolute path to the file
|
164 |
+
* @uses bp_core_avatar_full_width()
|
165 |
+
* @uses bp_core_avatar_full_height()
|
166 |
+
* @return boolean
|
167 |
+
*/
|
168 |
+
public static function is_too_small( $file = '' ) {
|
169 |
+
$uploaded_image = @getimagesize( $file );
|
170 |
+
$full_width = bp_core_avatar_full_width();
|
171 |
+
$full_height = bp_core_avatar_full_height();
|
172 |
+
|
173 |
+
if ( isset( $uploaded_image[0] ) && $uploaded_image[0] < $full_width || $uploaded_image[1] < $full_height ) {
|
174 |
+
return true;
|
175 |
+
}
|
176 |
+
|
177 |
+
return false;
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Crop the avatar
|
182 |
+
*
|
183 |
+
* @since BuddyPress (2.3.0)
|
184 |
+
*
|
185 |
+
* @see BP_Attachment::crop for the list of parameters
|
186 |
+
* @param array $args
|
187 |
+
* @uses bp_core_fetch_avatar()
|
188 |
+
* @uses bp_core_delete_existing_avatar()
|
189 |
+
* @uses bp_core_avatar_full_width()
|
190 |
+
* @uses bp_core_avatar_full_height()
|
191 |
+
* @uses bp_core_avatar_dimension()
|
192 |
+
* @uses BP_Attachment::crop
|
193 |
+
* @return array the cropped avatars (full and thumb)
|
194 |
+
*/
|
195 |
+
public function crop( $args = array() ) {
|
196 |
+
// Bail if the original file is missing
|
197 |
+
if ( empty( $args['original_file'] ) ) {
|
198 |
+
return false;
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Original file is a relative path to the image
|
203 |
+
* eg: /avatars/1/avatar.jpg
|
204 |
+
*/
|
205 |
+
$relative_path = $args['original_file'];
|
206 |
+
$absolute_path = $this->upload_path . $relative_path;
|
207 |
+
|
208 |
+
// Bail if the avatar is not available
|
209 |
+
if ( ! file_exists( $absolute_path ) ) {
|
210 |
+
return false;
|
211 |
+
}
|
212 |
+
|
213 |
+
if ( empty( $args['item_id'] ) ) {
|
214 |
+
|
215 |
+
/** This filter is documented in bp-core/bp-core-avatars.php */
|
216 |
+
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', dirname( $absolute_path ), $args['item_id'], $args['object'], $args['avatar_dir'] );
|
217 |
+
} else {
|
218 |
+
|
219 |
+
/** This filter is documented in bp-core/bp-core-avatars.php */
|
220 |
+
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', $this->upload_path . '/' . $args['avatar_dir'] . '/' . $args['item_id'], $args['item_id'], $args['object'], $args['avatar_dir'] );
|
221 |
+
}
|
222 |
+
|
223 |
+
// Bail if the avatar folder is missing for this item_id
|
224 |
+
if ( ! file_exists( $avatar_folder_dir ) ) {
|
225 |
+
return false;
|
226 |
+
}
|
227 |
+
|
228 |
+
// Delete the existing avatar files for the object
|
229 |
+
$existing_avatar = bp_core_fetch_avatar( array(
|
230 |
+
'object' => $args['object'],
|
231 |
+
'item_id' => $args['item_id'],
|
232 |
+
'html' => false,
|
233 |
+
) );
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Check that the new avatar doesn't have the same name as the
|
237 |
+
* old one before deleting
|
238 |
+
*/
|
239 |
+
if ( ! empty( $existing_avatar ) && $existing_avatar !== $this->url . $relative_path ) {
|
240 |
+
bp_core_delete_existing_avatar( array( 'object' => $args['object'], 'item_id' => $args['item_id'], 'avatar_path' => $avatar_folder_dir ) );
|
241 |
+
}
|
242 |
+
|
243 |
+
// Make sure we at least have minimal data for cropping
|
244 |
+
if ( empty( $args['crop_w'] ) ) {
|
245 |
+
$args['crop_w'] = bp_core_avatar_full_width();
|
246 |
+
}
|
247 |
+
|
248 |
+
if ( empty( $args['crop_h'] ) ) {
|
249 |
+
$args['crop_h'] = bp_core_avatar_full_height();
|
250 |
+
}
|
251 |
+
|
252 |
+
// Get the file extension
|
253 |
+
$data = @getimagesize( $absolute_path );
|
254 |
+
$ext = $data['mime'] == 'image/png' ? 'png' : 'jpg';
|
255 |
+
|
256 |
+
$args['original_file'] = $absolute_path;
|
257 |
+
$args['src_abs'] = false;
|
258 |
+
$avatar_types = array( 'full' => '', 'thumb' => '' );
|
259 |
+
|
260 |
+
foreach ( $avatar_types as $key_type => $type ) {
|
261 |
+
if ( 'thumb' === $key_type ) {
|
262 |
+
$args['dst_w'] = bp_core_avatar_thumb_width();
|
263 |
+
$args['dst_h'] = bp_core_avatar_thumb_height();
|
264 |
+
} else {
|
265 |
+
$args['dst_w'] = bp_core_avatar_full_width();
|
266 |
+
$args['dst_h'] = bp_core_avatar_full_height();
|
267 |
+
}
|
268 |
+
|
269 |
+
$args['dst_file'] = $avatar_folder_dir . '/' . wp_hash( $absolute_path . time() ) . '-bp' . $key_type . '.' . $ext;
|
270 |
+
|
271 |
+
$avatar_types[ $key_type ] = parent::crop( $args );
|
272 |
+
}
|
273 |
+
|
274 |
+
// Remove the original
|
275 |
+
@unlink( $absolute_path );
|
276 |
+
|
277 |
+
// Return the full and thumb cropped avatars
|
278 |
+
return $avatar_types;
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Get the user id to set its avatar
|
283 |
+
*
|
284 |
+
* @since BuddyPress (2.3.0)
|
285 |
+
*
|
286 |
+
* @return integer the user ID
|
287 |
+
*/
|
288 |
+
private function get_user_id() {
|
289 |
+
$bp = buddypress();
|
290 |
+
$user_id = 0;
|
291 |
+
|
292 |
+
if ( bp_is_user() ) {
|
293 |
+
$user_id = bp_displayed_user_id();
|
294 |
+
}
|
295 |
+
|
296 |
+
if ( ! empty( $bp->members->admin->user_id ) ) {
|
297 |
+
$user_id = $bp->members->admin->user_id;
|
298 |
+
}
|
299 |
+
|
300 |
+
return $user_id;
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Get the group id to set its avatar
|
305 |
+
*
|
306 |
+
* @since BuddyPress (2.3.0)
|
307 |
+
*
|
308 |
+
* @return integer the group id
|
309 |
+
*/
|
310 |
+
private function get_group_id() {
|
311 |
+
$group_id = 0;
|
312 |
+
|
313 |
+
if ( bp_is_group() ) {
|
314 |
+
$group_id = bp_get_current_group_id();
|
315 |
+
}
|
316 |
+
|
317 |
+
return $group_id;
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Build script datas for the Uploader UI
|
322 |
+
*
|
323 |
+
* @since BuddyPress (2.3.0)
|
324 |
+
*
|
325 |
+
* @return array the javascript localization data
|
326 |
+
*/
|
327 |
+
public function script_data() {
|
328 |
+
// Get default script data
|
329 |
+
$script_data = parent::script_data();
|
330 |
+
|
331 |
+
// Defaults to Avatar Backbone script
|
332 |
+
$js_scripts = array( 'bp-avatar' );
|
333 |
+
|
334 |
+
// Default object
|
335 |
+
$object = '';
|
336 |
+
|
337 |
+
// Get the possible item ids
|
338 |
+
$user_id = $this->get_user_id();
|
339 |
+
$group_id = $this->get_group_id();
|
340 |
+
|
341 |
+
if ( ! empty( $user_id ) ) {
|
342 |
+
// Should we load the the Webcam Avatar javascript file
|
343 |
+
if ( bp_avatar_use_webcam() ) {
|
344 |
+
$js_scripts = array( 'bp-webcam' );
|
345 |
+
}
|
346 |
+
|
347 |
+
$script_data['bp_params'] = array(
|
348 |
+
'object' => 'user',
|
349 |
+
'item_id' => $user_id,
|
350 |
+
'has_avatar' => bp_get_user_has_avatar( $user_id ),
|
351 |
+
'nonces' => array(
|
352 |
+
'set' => wp_create_nonce( 'bp_avatar_cropstore' ),
|
353 |
+
'remove' => wp_create_nonce( 'bp_delete_avatar_link' ),
|
354 |
+
),
|
355 |
+
);
|
356 |
+
|
357 |
+
// Set feedback messages
|
358 |
+
$script_data['feedback_messages'] = array(
|
359 |
+
1 => __( 'There was a problem cropping your profile photo.', 'buddypress' ),
|
360 |
+
2 => __( 'Your new profile photo was uploaded successfully.', 'buddypress' ),
|
361 |
+
3 => __( 'There was a problem deleting your profile photo. Please try again.', 'buddypress' ),
|
362 |
+
4 => __( 'Your profile photo was deleted successfully!', 'buddypress' ),
|
363 |
+
);
|
364 |
+
} elseif ( ! empty( $group_id ) ) {
|
365 |
+
$script_data['bp_params'] = array(
|
366 |
+
'object' => 'group',
|
367 |
+
'item_id' => $group_id,
|
368 |
+
'has_avatar' => bp_get_group_has_avatar( $group_id ),
|
369 |
+
'nonces' => array(
|
370 |
+
'set' => wp_create_nonce( 'bp_avatar_cropstore' ),
|
371 |
+
'remove' => wp_create_nonce( 'bp_group_avatar_delete' ),
|
372 |
+
),
|
373 |
+
);
|
374 |
+
|
375 |
+
// Set feedback messages
|
376 |
+
$script_data['feedback_messages'] = array(
|
377 |
+
1 => __( 'There was a problem cropping the group profile photo.', 'buddypress' ),
|
378 |
+
2 => __( 'The group profile photo was uploaded successfully.', 'buddypress' ),
|
379 |
+
3 => __( 'There was a problem deleting the group profile photo. Please try again.', 'buddypress' ),
|
380 |
+
4 => __( 'The group profile photo was deleted successfully!', 'buddypress' ),
|
381 |
+
);
|
382 |
+
} else {
|
383 |
+
/**
|
384 |
+
* Use this filter to include specific BuddyPress params for your object
|
385 |
+
* e.g. Blavatar
|
386 |
+
*
|
387 |
+
* @since BuddyPress (2.3.0)
|
388 |
+
*
|
389 |
+
* @param array the avatar specific BuddyPress parameters
|
390 |
+
*/
|
391 |
+
$script_data['bp_params'] = apply_filters( 'bp_attachment_avatar_params', array() );
|
392 |
+
}
|
393 |
+
|
394 |
+
// Include the specific css
|
395 |
+
$script_data['extra_css'] = array( 'bp-avatar' );
|
396 |
+
|
397 |
+
// Include the specific css
|
398 |
+
$script_data['extra_js'] = $js_scripts;
|
399 |
+
|
400 |
+
// Set the object to contextualize the filter
|
401 |
+
if ( isset( $script_data['bp_params']['object'] ) ) {
|
402 |
+
$object = $script_data['bp_params']['object'];
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Use this filter to override/extend the avatar script data
|
407 |
+
*
|
408 |
+
* @since BuddyPress (2.3.0)
|
409 |
+
*
|
410 |
+
* @param array $script_data the avatar script data
|
411 |
+
* @param string $object the object the avatar belongs to (eg: user or group)
|
412 |
+
*/
|
413 |
+
return apply_filters( 'bp_attachment_avatar_script_data', $script_data, $object );
|
414 |
+
}
|
415 |
+
}
|
bp-core/classes/class-bp-attachment.php
ADDED
@@ -0,0 +1,518 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Core attachment class.
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
* @subpackage Core
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Exit if accessed directly
|
10 |
+
defined( 'ABSPATH' ) || exit;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* BP Attachment class
|
14 |
+
*
|
15 |
+
* Extend it to manage your component's uploads.
|
16 |
+
*
|
17 |
+
* @since BuddyPress (2.3.0)
|
18 |
+
*/
|
19 |
+
abstract class BP_Attachment {
|
20 |
+
|
21 |
+
/** Upload properties *****************************************************/
|
22 |
+
|
23 |
+
/**
|
24 |
+
* The file being uploaded
|
25 |
+
*
|
26 |
+
* @var array
|
27 |
+
*/
|
28 |
+
public $attachment = array();
|
29 |
+
|
30 |
+
/**
|
31 |
+
* The default args to be merged with the
|
32 |
+
* ones passed by the child class
|
33 |
+
*
|
34 |
+
* @var array
|
35 |
+
*/
|
36 |
+
protected $default_args = array(
|
37 |
+
'original_max_filesize' => 0,
|
38 |
+
'allowed_mime_types' => array(),
|
39 |
+
'base_dir' => '',
|
40 |
+
'action' => '',
|
41 |
+
'file_input' => '',
|
42 |
+
'upload_error_strings' => array(),
|
43 |
+
'required_wp_files' => array( 'file' ),
|
44 |
+
);
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Construct Upload parameters
|
48 |
+
*
|
49 |
+
* @since BuddyPress (2.3.0)
|
50 |
+
*
|
51 |
+
* @param array $args {
|
52 |
+
* @type int $original_max_filesize Maximum file size in kilobytes. Defaults to php.ini settings.
|
53 |
+
* @type array $allowed_mime_types List of allowed file extensions (eg: array( 'jpg', 'gif', 'png' ) ).
|
54 |
+
* Defaults to WordPress allowed mime types
|
55 |
+
* @type string $base_dir Component's upload base directory. Defaults to WordPress 'uploads'
|
56 |
+
* @type string $action The upload action used when uploading a file, $_POST['action'] must be set
|
57 |
+
* and its value must equal $action {@link wp_handle_upload()} (required)
|
58 |
+
* @type string $file_input The name attribute used in the file input. (required)
|
59 |
+
* @type array $upload_error_strings A list of specific error messages (optional).
|
60 |
+
* @type array $required_wp_files The list of required WordPress core files. Default: array( 'file' );
|
61 |
+
* }
|
62 |
+
* @uses sanitize_key()
|
63 |
+
* @uses wp_max_upload_size()
|
64 |
+
* @uses bp_parse_args()
|
65 |
+
* @uses BP_Attachment->set_upload_error_strings()
|
66 |
+
* @uses BP_Attachment->set_upload_dir()
|
67 |
+
*/
|
68 |
+
public function __construct( $args = '' ) {
|
69 |
+
// Upload action and the file input name are required parameters
|
70 |
+
if ( empty( $args['action'] ) || empty( $args['file_input'] ) ) {
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
|
74 |
+
// Sanitize the action ID and the file input name
|
75 |
+
$this->action = sanitize_key( $args['action'] );
|
76 |
+
$this->file_input = sanitize_key( $args['file_input'] );
|
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 |
+
|
84 |
+
$params = bp_parse_args( $args, $this->default_args, $this->action . '_upload_params' );
|
85 |
+
|
86 |
+
foreach ( $params as $key => $param ) {
|
87 |
+
if ( 'upload_error_strings' === $key ) {
|
88 |
+
$this->{$key} = $this->set_upload_error_strings( $param );
|
89 |
+
|
90 |
+
// Sanitize the base dir
|
91 |
+
} elseif ( 'base_dir' === $key ) {
|
92 |
+
$this->{$key} = sanitize_title( $param );
|
93 |
+
|
94 |
+
// Action & File input are already set and sanitized
|
95 |
+
} elseif ( 'action' !== $key && 'file_input' !== $key ) {
|
96 |
+
$this->{$key} = $param;
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
// Set the path/url and base dir for uploads
|
101 |
+
$this->set_upload_dir();
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Set upload path and url for the component.
|
106 |
+
*
|
107 |
+
* @since BuddyPress (2.3.0)
|
108 |
+
*
|
109 |
+
* @uses bp_upload_dir()
|
110 |
+
*/
|
111 |
+
public function set_upload_dir() {
|
112 |
+
// Set the directory, path, & url variables
|
113 |
+
$this->upload_dir = bp_upload_dir();
|
114 |
+
|
115 |
+
if ( empty( $this->upload_dir ) ) {
|
116 |
+
return false;
|
117 |
+
}
|
118 |
+
|
119 |
+
$this->upload_path = $this->upload_dir['basedir'];
|
120 |
+
$this->url = $this->upload_dir['baseurl'];
|
121 |
+
|
122 |
+
// Ensure URL is https if SSL is set/forced
|
123 |
+
if ( is_ssl() ) {
|
124 |
+
$this->url = str_replace( 'http://', 'https://', $this->url );
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Custom base dir.
|
129 |
+
*
|
130 |
+
* If the component set this property, set the specific path, url and create the dir
|
131 |
+
*/
|
132 |
+
if ( ! empty( $this->base_dir ) ) {
|
133 |
+
$this->upload_path = trailingslashit( $this->upload_path ) . $this->base_dir;
|
134 |
+
$this->url = trailingslashit( $this->url ) . $this->base_dir;
|
135 |
+
|
136 |
+
// Finally create the base dir
|
137 |
+
$this->create_dir();
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Set Upload error messages
|
143 |
+
*
|
144 |
+
* Used into the $overrides argument of BP_Attachment->upload()
|
145 |
+
*
|
146 |
+
* @since BuddyPress (2.3.0)
|
147 |
+
*
|
148 |
+
* @param array $param a list of error messages to add to BuddyPress core ones
|
149 |
+
* @return array the list of upload errors
|
150 |
+
*/
|
151 |
+
public function set_upload_error_strings( $param = array() ) {
|
152 |
+
/**
|
153 |
+
* Index of the array is the error code
|
154 |
+
* Custom errors will start at 9 code
|
155 |
+
*/
|
156 |
+
$upload_errors = array(
|
157 |
+
0 => __( 'The file was uploaded successfully', 'buddypress' ),
|
158 |
+
1 => __( 'The uploaded file exceeds the maximum allowed file size for this site', 'buddypress' ),
|
159 |
+
2 => sprintf( __( 'The uploaded file exceeds the maximum allowed file size of: %s', 'buddypress' ), size_format( $this->original_max_filesize ) ),
|
160 |
+
3 => __( 'The uploaded file was only partially uploaded.', 'buddypress' ),
|
161 |
+
4 => __( 'No file was uploaded.', 'buddypress' ),
|
162 |
+
5 => '',
|
163 |
+
6 => __( 'Missing a temporary folder.', 'buddypress' ),
|
164 |
+
7 => __( 'Failed to write file to disk.', 'buddypress' ),
|
165 |
+
8 => __( 'File upload stopped by extension.', 'buddypress' ),
|
166 |
+
);
|
167 |
+
|
168 |
+
if ( ! array_intersect_key( $upload_errors, (array) $param ) ) {
|
169 |
+
foreach ( $param as $key_error => $error_message ) {
|
170 |
+
$upload_errors[ $key_error ] = $error_message;
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
return $upload_errors;
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Include the WordPress core needed files
|
179 |
+
*
|
180 |
+
* @since BuddyPress (2.3.0)
|
181 |
+
*/
|
182 |
+
public function includes() {
|
183 |
+
foreach ( array_unique( $this->required_wp_files ) as $wp_file ) {
|
184 |
+
if ( ! file_exists( ABSPATH . "/wp-admin/includes/{$wp_file}.php" ) ) {
|
185 |
+
continue;
|
186 |
+
}
|
187 |
+
|
188 |
+
require_once( ABSPATH . "/wp-admin/includes/{$wp_file}.php" );
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Upload the attachment
|
194 |
+
*
|
195 |
+
* @since BuddyPress (2.3.0)
|
196 |
+
*
|
197 |
+
* @param array $file The appropriate entry the from $_FILES superglobal.
|
198 |
+
* @param string $upload_dir_filter A specific filter to be applied to 'upload_dir' (optional).
|
199 |
+
* @param string $time Optional. Time formatted in 'yyyy/mm'. Default null.
|
200 |
+
* @uses wp_handle_upload() To upload the file
|
201 |
+
* @uses add_filter() To temporarly overrides WordPress uploads data
|
202 |
+
* @uses remove_filter() To stop overriding WordPress uploads data
|
203 |
+
* @uses apply_filters() Call 'bp_attachment_upload_overrides' to include specific upload overrides
|
204 |
+
*
|
205 |
+
* @return array On success, returns an associative array of file attributes.
|
206 |
+
* On failure, returns an array containing the error message
|
207 |
+
* (eg: array( 'error' => $message ) )
|
208 |
+
*/
|
209 |
+
public function upload( $file, $upload_dir_filter = '', $time = null ) {
|
210 |
+
/**
|
211 |
+
* Upload action and the file input name are required parameters
|
212 |
+
* @see BP_Attachment:__construct()
|
213 |
+
*/
|
214 |
+
if ( empty( $this->action ) || empty( $this->file_input ) ) {
|
215 |
+
return false;
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Add custom rules before enabling the file upload
|
220 |
+
*/
|
221 |
+
add_filter( "{$this->action}_prefilter", array( $this, 'validate_upload' ), 10, 1 );
|
222 |
+
|
223 |
+
/**
|
224 |
+
* The above dynamic filter was introduced in WordPress 4.0, as we support WordPress
|
225 |
+
* back to 3.6, we need to also use the pre 4.0 static filter and remove it after
|
226 |
+
* the upload was processed.
|
227 |
+
*/
|
228 |
+
add_filter( 'wp_handle_upload_prefilter', array( $this, 'validate_upload' ), 10, 1 );
|
229 |
+
|
230 |
+
// Set Default overrides
|
231 |
+
$overrides = array(
|
232 |
+
'action' => $this->action,
|
233 |
+
'upload_error_strings' => $this->upload_error_strings,
|
234 |
+
);
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Add a mime override if needed
|
238 |
+
* Used to restrict uploads by extensions
|
239 |
+
*/
|
240 |
+
if ( ! empty( $this->allowed_mime_types ) ) {
|
241 |
+
$mime_types = $this->validate_mime_types();
|
242 |
+
|
243 |
+
if ( ! empty( $mime_types ) ) {
|
244 |
+
$overrides['mimes'] = $mime_types;
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* If you need to add some overrides we haven't thought of
|
250 |
+
*
|
251 |
+
* @var array $overrides the wp_handle_upload overrides
|
252 |
+
*/
|
253 |
+
$overrides = apply_filters( 'bp_attachment_upload_overrides', $overrides );
|
254 |
+
|
255 |
+
$this->includes();
|
256 |
+
|
257 |
+
/**
|
258 |
+
* If the $base_dir was set when constructing the class,
|
259 |
+
* and no specific filter has been requested, use a default
|
260 |
+
* filter to create the specific $base dir
|
261 |
+
* @see BP_Attachment->upload_dir_filter()
|
262 |
+
*/
|
263 |
+
if ( empty( $upload_dir_filter ) && ! empty( $this->base_dir ) ) {
|
264 |
+
$upload_dir_filter = array( $this, 'upload_dir_filter' );
|
265 |
+
}
|
266 |
+
|
267 |
+
// Make sure the file will be uploaded in the attachment directory
|
268 |
+
if ( ! empty( $upload_dir_filter ) ) {
|
269 |
+
add_filter( 'upload_dir', $upload_dir_filter, 10, 0 );
|
270 |
+
}
|
271 |
+
|
272 |
+
// Upload the attachment
|
273 |
+
$this->attachment = wp_handle_upload( $file[ $this->file_input ], $overrides, $time );
|
274 |
+
|
275 |
+
// Restore WordPress Uploads data
|
276 |
+
if ( ! empty( $upload_dir_filter ) ) {
|
277 |
+
remove_filter( 'upload_dir', $upload_dir_filter, 10, 0 );
|
278 |
+
}
|
279 |
+
|
280 |
+
// Remove the pre WordPress 4.0 static filter
|
281 |
+
remove_filter( 'wp_handle_upload_prefilter', array( $this, 'validate_upload' ), 10, 1 );
|
282 |
+
|
283 |
+
// Finally return the uploaded file or the error
|
284 |
+
return $this->attachment;
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Validate the allowed mime types using WordPress allowed mime types
|
289 |
+
*
|
290 |
+
* In case of a multisite, the mime types are already restricted by
|
291 |
+
* the 'upload_filetypes' setting. BuddyPress will respect this setting.
|
292 |
+
* @see check_upload_mimes()
|
293 |
+
*
|
294 |
+
* @since BuddyPress (2.3.0)
|
295 |
+
*
|
296 |
+
* @uses get_allowed_mime_types()
|
297 |
+
*/
|
298 |
+
protected function validate_mime_types() {
|
299 |
+
$wp_mimes = get_allowed_mime_types();
|
300 |
+
$valid_mimes = array();
|
301 |
+
|
302 |
+
// Set the allowed mimes for the upload
|
303 |
+
foreach ( (array) $this->allowed_mime_types as $ext ) {
|
304 |
+
foreach ( $wp_mimes as $ext_pattern => $mime ) {
|
305 |
+
if ( $ext !== '' && strpos( $ext_pattern, $ext ) !== false ) {
|
306 |
+
$valid_mimes[$ext_pattern] = $mime;
|
307 |
+
}
|
308 |
+
}
|
309 |
+
}
|
310 |
+
return $valid_mimes;
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Specific upload rules
|
315 |
+
*
|
316 |
+
* Override this function from your child class to build your specific rules
|
317 |
+
* By default, if an original_max_filesize is provided, a check will be done
|
318 |
+
* on the file size.
|
319 |
+
*
|
320 |
+
* @see BP_Attachment_Avatar->validate_upload() for an example of use
|
321 |
+
*
|
322 |
+
* @since BuddyPress (2.3.0)
|
323 |
+
*
|
324 |
+
* @param array $file the temporary file attributes (before it has been moved)
|
325 |
+
* @return array the file
|
326 |
+
*/
|
327 |
+
public function validate_upload( $file = array() ) {
|
328 |
+
// Bail if already an error
|
329 |
+
if ( ! empty( $file['error'] ) ) {
|
330 |
+
return $file;
|
331 |
+
}
|
332 |
+
|
333 |
+
if ( ! empty( $this->original_max_filesize ) && $file['size'] > $this->original_max_filesize ) {
|
334 |
+
$file['error'] = 2;
|
335 |
+
}
|
336 |
+
|
337 |
+
// Return the file
|
338 |
+
return $file;
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Default filter to save the attachments
|
343 |
+
*
|
344 |
+
* @since BuddyPress (2.3.0)
|
345 |
+
*
|
346 |
+
* @uses apply_filters() call 'bp_attachment_upload_dir' to eventually override the upload location
|
347 |
+
* regarding to context
|
348 |
+
* @return array the upload directory data
|
349 |
+
*/
|
350 |
+
public function upload_dir_filter() {
|
351 |
+
/**
|
352 |
+
* Filters the component's upload directory.
|
353 |
+
*
|
354 |
+
* @since BuddyPress (2.3.0)
|
355 |
+
*
|
356 |
+
* @param array $value Array containing the path, URL, and other helpful settings.
|
357 |
+
*/
|
358 |
+
return apply_filters( 'bp_attachment_upload_dir', array(
|
359 |
+
'path' => $this->upload_path,
|
360 |
+
'url' => $this->url,
|
361 |
+
'subdir' => false,
|
362 |
+
'basedir' => $this->upload_path,
|
363 |
+
'baseurl' => $this->url,
|
364 |
+
'error' => false
|
365 |
+
) );
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Create the custom base directory for the component uploads
|
370 |
+
*
|
371 |
+
* Override this function in your child class to run specific actions
|
372 |
+
* (eg: add an .htaccess file)
|
373 |
+
*
|
374 |
+
* @since BuddyPress (2.3.0)
|
375 |
+
*
|
376 |
+
* @uses wp_mkdir_p()
|
377 |
+
*/
|
378 |
+
public function create_dir() {
|
379 |
+
// Bail if no specific base dir is set
|
380 |
+
if ( empty( $this->base_dir ) ) {
|
381 |
+
return false;
|
382 |
+
}
|
383 |
+
|
384 |
+
// Check if upload path already exists
|
385 |
+
if ( ! is_dir( $this->upload_path ) ) {
|
386 |
+
|
387 |
+
// If path does not exist, attempt to create it
|
388 |
+
if ( ! wp_mkdir_p( $this->upload_path ) ) {
|
389 |
+
return false;
|
390 |
+
}
|
391 |
+
}
|
392 |
+
|
393 |
+
// Directory exists
|
394 |
+
return true;
|
395 |
+
}
|
396 |
+
|
397 |
+
/**
|
398 |
+
* Crop an image file
|
399 |
+
*
|
400 |
+
* @since BuddyPress (2.3.0)
|
401 |
+
*
|
402 |
+
* @param array $args {
|
403 |
+
* @type string $original_file The source file (absolute path) for the Attachment.
|
404 |
+
* @type int $crop_x The start x position to crop from.
|
405 |
+
* @type int $crop_y The start y position to crop from.
|
406 |
+
* @type int $crop_w The width to crop.
|
407 |
+
* @type int $crop_h The height to crop.
|
408 |
+
* @type int $dst_w The destination width.
|
409 |
+
* @type int $dst_h The destination height.
|
410 |
+
* @type int $src_abs Optional. If the source crop points are absolute.
|
411 |
+
* @type string $dst_file Optional. The destination file to write to.
|
412 |
+
* }
|
413 |
+
* @uses wp_crop_image()
|
414 |
+
* @return string|WP_Error New filepath on success, WP_Error on failure.
|
415 |
+
*/
|
416 |
+
public function crop( $args = array() ) {
|
417 |
+
$wp_error = new WP_Error();
|
418 |
+
|
419 |
+
$r = bp_parse_args( $args, array(
|
420 |
+
'original_file' => '',
|
421 |
+
'crop_x' => 0,
|
422 |
+
'crop_y' => 0,
|
423 |
+
'crop_w' => 0,
|
424 |
+
'crop_h' => 0,
|
425 |
+
'dst_w' => 0,
|
426 |
+
'dst_h' => 0,
|
427 |
+
'src_abs' => false,
|
428 |
+
'dst_file' => false,
|
429 |
+
), 'bp_attachment_crop_args' );
|
430 |
+
|
431 |
+
if ( empty( $r['original_file'] ) || ! file_exists( $r['original_file'] ) ) {
|
432 |
+
$wp_error->add( 'crop_error', __( 'Cropping the file failed: missing source file.', 'buddypress' ) );
|
433 |
+
return $wp_error;
|
434 |
+
}
|
435 |
+
|
436 |
+
// Check image file pathes
|
437 |
+
$path_error = __( 'Cropping the file failed: the file path is not allowed.', 'buddypress' );
|
438 |
+
|
439 |
+
// Make sure it's coming from an uploaded file
|
440 |
+
if ( false === strpos( $r['original_file'], $this->upload_path ) ) {
|
441 |
+
$wp_error->add( 'crop_error', $path_error );
|
442 |
+
return $wp_error;
|
443 |
+
}
|
444 |
+
|
445 |
+
/**
|
446 |
+
* If no destination file is provided, WordPress will use a default name
|
447 |
+
* and will write the file in the source file's folder.
|
448 |
+
* If a destination file is provided, we need to make sure it's going into uploads
|
449 |
+
*/
|
450 |
+
if ( ! empty( $r['dst_file'] ) && false === strpos( $r['dst_file'], $this->upload_path ) ) {
|
451 |
+
$wp_error->add( 'crop_error', $path_error );
|
452 |
+
return $wp_error;
|
453 |
+
}
|
454 |
+
|
455 |
+
// Check image file types
|
456 |
+
$check_types = array( 'src_file' => array( 'file' => $r['original_file'], 'error' => _x( 'source file', 'Attachment source file', 'buddypress' ) ) );
|
457 |
+
if ( ! empty( $r['dst_file'] ) ) {
|
458 |
+
$check_types['dst_file'] = array( 'file' => $r['dst_file'], 'error' => _x( 'destination file', 'Attachment destination file', 'buddypress' ) );
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* WordPress image supported types
|
463 |
+
* @see wp_attachment_is()
|
464 |
+
*/
|
465 |
+
$supported_image_types = array(
|
466 |
+
'jpg' => 1,
|
467 |
+
'jpeg' => 1,
|
468 |
+
'jpe' => 1,
|
469 |
+
'gif' => 1,
|
470 |
+
'png' => 1,
|
471 |
+
);
|
472 |
+
|
473 |
+
foreach ( $check_types as $file ) {
|
474 |
+
$is_image = wp_check_filetype( $file['file'] );
|
475 |
+
$ext = $is_image['ext'];
|
476 |
+
|
477 |
+
if ( empty( $ext ) || empty( $supported_image_types[ $ext ] ) ) {
|
478 |
+
$wp_error->add( 'crop_error', sprintf( __( 'Cropping the file failed: %s is not a supported image file.', 'buddypress' ), $file['error'] ) );
|
479 |
+
return $wp_error;
|
480 |
+
}
|
481 |
+
}
|
482 |
+
|
483 |
+
// Add the image.php to the required WordPress files, if it's not already the case
|
484 |
+
$required_files = array_flip( $this->required_wp_files );
|
485 |
+
if ( ! isset( $required_files['image'] ) ) {
|
486 |
+
$this->required_wp_files[] = 'image';
|
487 |
+
}
|
488 |
+
|
489 |
+
// Load the files
|
490 |
+
$this->includes();
|
491 |
+
|
492 |
+
// Finally crop the image
|
493 |
+
return wp_crop_image( $r['original_file'], (int) $r['crop_x'], (int) $r['crop_y'], (int) $r['crop_w'], (int) $r['crop_h'], (int) $r['dst_w'], (int) $r['dst_h'], $r['src_abs'], $r['dst_file'] );
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Build script datas for the Uploader UI
|
498 |
+
*
|
499 |
+
* Override this method from your child class to build the script datas
|
500 |
+
*
|
501 |
+
* @since BuddyPress (2.3.0)
|
502 |
+
*
|
503 |
+
* @return array the javascript localization data
|
504 |
+
*/
|
505 |
+
public function script_data() {
|
506 |
+
$script_data = array(
|
507 |
+
'action' => $this->action,
|
508 |
+
'file_data_name' => $this->file_input,
|
509 |
+
'max_file_size' => $this->original_max_filesize,
|
510 |
+
'feedback_messages' => array(
|
511 |
+
1 => __( 'Sorry, uploading the file failed.', 'buddypress' ),
|
512 |
+
2 => __( 'File successfully uploaded.', 'buddypress' ),
|
513 |
+
),
|
514 |
+
);
|
515 |
+
|
516 |
+
return $script_data;
|
517 |
+
}
|
518 |
+
}
|
bp-core/classes/class-bp-button.php
ADDED
@@ -0,0 +1,270 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Core component classes.
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
* @subpackage Core
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Exit if accessed directly
|
10 |
+
defined( 'ABSPATH' ) || exit;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* API to create BuddyPress buttons.
|
14 |
+
*
|
15 |
+
* @since BuddyPress (1.2.6)
|
16 |
+
*
|
17 |
+
* @param array $args {
|
18 |
+
* Array of arguments.
|
19 |
+
* @type string $id String describing the button type.
|
20 |
+
* @type string $component The name of the component the button belongs to.
|
21 |
+
* Default: 'core'.
|
22 |
+
* @type bool $must_be_logged_in Optional. Does the user need to be logged
|
23 |
+
* in to see this button? Default: true.
|
24 |
+
* @type bool $block_self Optional. True if the button should be hidden
|
25 |
+
* when a user is viewing his own profile. Default: true.
|
26 |
+
* @type string|bool $wrapper Optional. HTML element type that should wrap
|
27 |
+
* the button: 'div', 'span', 'p', or 'li'. False for no wrapper at
|
28 |
+
* all. Default: 'div'.
|
29 |
+
* @type string $wrapper_id Optional. DOM ID of the button wrapper element.
|
30 |
+
* Default: ''.
|
31 |
+
* @type string $wrapper_class Optional. DOM class of the button wrapper
|
32 |
+
* element. Default: ''.
|
33 |
+
* @type string $link_href Optional. Destination link of the button.
|
34 |
+
* Default: ''.
|
35 |
+
* @type string $link_class Optional. DOM class of the button. Default: ''.
|
36 |
+
* @type string $link_id Optional. DOM ID of the button. Default: ''.
|
37 |
+
* @type string $link_rel Optional. DOM 'rel' attribute of the button.
|
38 |
+
* Default: ''.
|
39 |
+
* @type string $link_title Optional. Title attribute of the button.
|
40 |
+
* Default: ''.
|
41 |
+
* @type string $link_text Optional. Text to appear on the button.
|
42 |
+
* Default: ''.
|
43 |
+
* }
|
44 |
+
*/
|
45 |
+
class BP_Button {
|
46 |
+
|
47 |
+
/** Button properties *****************************************************/
|
48 |
+
|
49 |
+
/**
|
50 |
+
* The button ID.
|
51 |
+
*
|
52 |
+
* @var string
|
53 |
+
*/
|
54 |
+
public $id = '';
|
55 |
+
|
56 |
+
/**
|
57 |
+
* The name of the component that the button belongs to.
|
58 |
+
*
|
59 |
+
* @var string
|
60 |
+
*/
|
61 |
+
public $component = 'core';
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Does the user need to be logged in to see this button?
|
65 |
+
*
|
66 |
+
* @var bool
|
67 |
+
*/
|
68 |
+
public $must_be_logged_in = true;
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Whether the button should be hidden when viewing your own profile.
|
72 |
+
*
|
73 |
+
* @var bool
|
74 |
+
*/
|
75 |
+
public $block_self = true;
|
76 |
+
|
77 |
+
/** Wrapper ***************************************************************/
|
78 |
+
|
79 |
+
/**
|
80 |
+
* The type of DOM element to use for a wrapper.
|
81 |
+
*
|
82 |
+
* @var string|bool 'div', 'span', 'p', 'li', or false for no wrapper.
|
83 |
+
*/
|
84 |
+
public $wrapper = 'div';
|
85 |
+
|
86 |
+
/**
|
87 |
+
* The DOM class of the button wrapper.
|
88 |
+
*
|
89 |
+
* @var string
|
90 |
+
*/
|
91 |
+
public $wrapper_class = '';
|
92 |
+
|
93 |
+
/**
|
94 |
+
* The DOM ID of the button wrapper.
|
95 |
+
*
|
96 |
+
* @var string
|
97 |
+
*/
|
98 |
+
public $wrapper_id = '';
|
99 |
+
|
100 |
+
/** Button ****************************************************************/
|
101 |
+
|
102 |
+
/**
|
103 |
+
* The destination link of the button.
|
104 |
+
*
|
105 |
+
* @var string
|
106 |
+
*/
|
107 |
+
public $link_href = '';
|
108 |
+
|
109 |
+
/**
|
110 |
+
* The DOM class of the button link.
|
111 |
+
*
|
112 |
+
* @var string
|
113 |
+
*/
|
114 |
+
public $link_class = '';
|
115 |
+
|
116 |
+
/**
|
117 |
+
* The DOM ID of the button link.
|
118 |
+
*
|
119 |
+
* @var string
|
120 |
+
*/
|
121 |
+
public $link_id = '';
|
122 |
+
|
123 |
+
/**
|
124 |
+
* The DOM rel value of the button link.
|
125 |
+
*
|
126 |
+
* @var string
|
127 |
+
*/
|
128 |
+
public $link_rel = '';
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Title of the button link.
|
132 |
+
*
|
133 |
+
* @var string
|
134 |
+
*/
|
135 |
+
public $link_title = '';
|
136 |
+
|
137 |
+
/**
|
138 |
+
* The contents of the button link.
|
139 |
+
*
|
140 |
+
* @var string
|
141 |
+
*/
|
142 |
+
public $link_text = '';
|
143 |
+
|
144 |
+
/** HTML result ***********************************************************/
|
145 |
+
|
146 |
+
public $contents = '';
|
147 |
+
|
148 |
+
/** Methods ***************************************************************/
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Builds the button based on class parameters.
|
152 |
+
*
|
153 |
+
* @since BuddyPress (1.2.6)
|
154 |
+
*
|
155 |
+
* @param array $args See {@BP_Button}.
|
156 |
+
* @return bool|null Returns false when the button is not allowed for
|
157 |
+
* the current context.
|
158 |
+
*/
|
159 |
+
public function __construct( $args = '' ) {
|
160 |
+
|
161 |
+
$r = wp_parse_args( $args, get_class_vars( __CLASS__ ) );
|
162 |
+
|
163 |
+
// Required button properties
|
164 |
+
$this->id = $r['id'];
|
165 |
+
$this->component = $r['component'];
|
166 |
+
$this->must_be_logged_in = (bool) $r['must_be_logged_in'];
|
167 |
+
$this->block_self = (bool) $r['block_self'];
|
168 |
+
$this->wrapper = $r['wrapper'];
|
169 |
+
|
170 |
+
// $id and $component are required
|
171 |
+
if ( empty( $r['id'] ) || empty( $r['component'] ) )
|
172 |
+
return false;
|
173 |
+
|
174 |
+
// No button if component is not active
|
175 |
+
if ( ! bp_is_active( $this->component ) )
|
176 |
+
return false;
|
177 |
+
|
178 |
+
// No button for guests if must be logged in
|
179 |
+
if ( true == $this->must_be_logged_in && ! is_user_logged_in() )
|
180 |
+
return false;
|
181 |
+
|
182 |
+
// block_self
|
183 |
+
if ( true == $this->block_self ) {
|
184 |
+
// No button if you are the current user in a members loop
|
185 |
+
// This condition takes precedence, because members loops
|
186 |
+
// can be found on user profiles
|
187 |
+
if ( bp_get_member_user_id() ) {
|
188 |
+
if ( is_user_logged_in() && bp_loggedin_user_id() == bp_get_member_user_id() ) {
|
189 |
+
return false;
|
190 |
+
}
|
191 |
+
|
192 |
+
// No button if viewing your own profile (and not in
|
193 |
+
// a members loop)
|
194 |
+
} elseif ( bp_is_my_profile() ) {
|
195 |
+
return false;
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
// Wrapper properties
|
200 |
+
if ( false !== $this->wrapper ) {
|
201 |
+
|
202 |
+
// Wrapper ID
|
203 |
+
if ( !empty( $r['wrapper_id'] ) ) {
|
204 |
+
$this->wrapper_id = ' id="' . $r['wrapper_id'] . '"';
|
205 |
+
}
|
206 |
+
|
207 |
+
// Wrapper class
|
208 |
+
if ( !empty( $r['wrapper_class'] ) ) {
|
209 |
+
$this->wrapper_class = ' class="generic-button ' . $r['wrapper_class'] . '"';
|
210 |
+
} else {
|
211 |
+
$this->wrapper_class = ' class="generic-button"';
|
212 |
+
}
|
213 |
+
|
214 |
+
// Set before and after
|
215 |
+
$before = '<' . $r['wrapper'] . $this->wrapper_class . $this->wrapper_id . '>';
|
216 |
+
$after = '</' . $r['wrapper'] . '>';
|
217 |
+
|
218 |
+
// No wrapper
|
219 |
+
} else {
|
220 |
+
$before = $after = '';
|
221 |
+
}
|
222 |
+
|
223 |
+
// Link properties
|
224 |
+
if ( !empty( $r['link_id'] ) ) $this->link_id = ' id="' . $r['link_id'] . '"';
|
225 |
+
if ( !empty( $r['link_href'] ) ) $this->link_href = ' href="' . $r['link_href'] . '"';
|
226 |
+
if ( !empty( $r['link_title'] ) ) $this->link_title = ' title="' . $r['link_title'] . '"';
|
227 |
+
if ( !empty( $r['link_rel'] ) ) $this->link_rel = ' rel="' . $r['link_rel'] . '"';
|
228 |
+
if ( !empty( $r['link_class'] ) ) $this->link_class = ' class="' . $r['link_class'] . '"';
|
229 |
+
if ( !empty( $r['link_text'] ) ) $this->link_text = $r['link_text'];
|
230 |
+
|
231 |
+
// Build the button
|
232 |
+
$this->contents = $before . '<a'. $this->link_href . $this->link_title . $this->link_id . $this->link_rel . $this->link_class . '>' . $this->link_text . '</a>' . $after;
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Filters the button based on class parameters.
|
236 |
+
*
|
237 |
+
* This filter is a dynamic filter based on component and component ID and
|
238 |
+
* allows button to be manipulated externally.
|
239 |
+
*
|
240 |
+
* @since BuddyPress (1.2.6)
|
241 |
+
*
|
242 |
+
* @param string $contents HTML being used for the button.
|
243 |
+
* @param BP_Button $this Current BP_Button instance.
|
244 |
+
* @param string $before HTML appended before the actual button.
|
245 |
+
* @param string $after HTML appended after the actual button.
|
246 |
+
*/
|
247 |
+
$this->contents = apply_filters( 'bp_button_' . $this->component . '_' . $this->id, $this->contents, $this, $before, $after );
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Return the markup for the generated button.
|
252 |
+
*
|
253 |
+
* @since BuddyPress (1.2.6)
|
254 |
+
*
|
255 |
+
* @return string Button markup.
|
256 |
+
*/
|
257 |
+
public function contents() {
|
258 |
+
return $this->contents;
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Output the markup of button.
|
263 |
+
*
|
264 |
+
* @since BuddyPress (1.2.6)
|
265 |
+
*/
|
266 |
+
public function display() {
|
267 |
+
if ( !empty( $this->contents ) )
|
268 |
+
echo $this->contents;
|
269 |
+
}
|
270 |
+
}
|
bp-core/classes/class-bp-core-notification.php
ADDED
@@ -0,0 +1,258 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Core component classes.
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
* @subpackage Core
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Exit if accessed directly
|
10 |
+
defined( 'ABSPATH' ) || exit;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* BP_Core_Notification is deprecated.
|
14 |
+
*
|
15 |
+
* Use BP_Notifications_Notification instead.
|
16 |
+
*
|
17 |
+
* @package BuddyPress Core
|
18 |
+
* @deprecated since BuddyPress (1.9.0)
|
19 |
+
*/
|
20 |
+
class BP_Core_Notification {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* The notification id
|
24 |
+
*
|
25 |
+
* @var integer
|
26 |
+
*/
|
27 |
+
public $id;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* The ID to which the notification relates to within the component.
|
31 |
+
*
|
32 |
+
* @var integer
|
33 |
+
*/
|
34 |
+
public $item_id;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* The secondary ID to which the notification relates to within the component.
|
38 |
+
*
|
39 |
+
* @var integer
|
40 |
+
*/
|
41 |
+
public $secondary_item_id = null;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* The user ID for who the notification is for.
|
45 |
+
*
|
46 |
+
* @var integer
|
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 |
+
|
80 |
+
/**
|
81 |
+
* Constructor
|
82 |
+
*
|
83 |
+
* @param integer $id
|
84 |
+
*/
|
85 |
+
public function __construct( $id = 0 ) {
|
86 |
+
if ( !empty( $id ) ) {
|
87 |
+
$this->id = $id;
|
88 |
+
$this->populate();
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Update or insert notification details into the database.
|
94 |
+
*
|
95 |
+
* @global wpdb $wpdb WordPress database object
|
96 |
+
* @return bool Success or failure
|
97 |
+
*/
|
98 |
+
public function save() {
|
99 |
+
global $wpdb;
|
100 |
+
|
101 |
+
$bp = buddypress();
|
102 |
+
|
103 |
+
// Update
|
104 |
+
if ( !empty( $this->id ) ) {
|
105 |
+
$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 );
|
106 |
+
|
107 |
+
// Save
|
108 |
+
} else {
|
109 |
+
$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 );
|
110 |
+
}
|
111 |
+
|
112 |
+
if ( !$result = $wpdb->query( $sql ) )
|
113 |
+
return false;
|
114 |
+
|
115 |
+
$this->id = $wpdb->insert_id;
|
116 |
+
|
117 |
+
return true;
|
118 |
+
}
|
119 |
+
|
120 |
+
/** Private Methods *******************************************************/
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Fetches the notification data from the database.
|
124 |
+
*
|
125 |
+
* @global wpdb $wpdb WordPress database object
|
126 |
+
*/
|
127 |
+
public function populate() {
|
128 |
+
global $wpdb;
|
129 |
+
|
130 |
+
$bp = buddypress();
|
131 |
+
|
132 |
+
if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) {
|
133 |
+
$this->item_id = $notification->item_id;
|
134 |
+
$this->secondary_item_id = $notification->secondary_item_id;
|
135 |
+
$this->user_id = $notification->user_id;
|
136 |
+
$this->component_name = $notification->component_name;
|
137 |
+
$this->component_action = $notification->component_action;
|
138 |
+
$this->date_notified = $notification->date_notified;
|
139 |
+
$this->is_new = $notification->is_new;
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
/** Static Methods ********************************************************/
|
144 |
+
|
145 |
+
public static function check_access( $user_id, $notification_id ) {
|
146 |
+
global $wpdb;
|
147 |
+
|
148 |
+
$bp = buddypress();
|
149 |
+
|
150 |
+
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 ) );
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Fetches all the notifications in the database for a specific user.
|
155 |
+
*
|
156 |
+
* @global wpdb $wpdb WordPress database object
|
157 |
+
* @param integer $user_id User ID
|
158 |
+
* @param string $status 'is_new' or 'all'
|
159 |
+
* @return array Associative array
|
160 |
+
* @static
|
161 |
+
*/
|
162 |
+
public static function get_all_for_user( $user_id, $status = 'is_new' ) {
|
163 |
+
global $wpdb;
|
164 |
+
|
165 |
+
$bp = buddypress();
|
166 |
+
|
167 |
+
$is_new = ( 'is_new' === $status )
|
168 |
+
? ' AND is_new = 1 '
|
169 |
+
: '';
|
170 |
+
|
171 |
+
return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d {$is_new}", $user_id ) );
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Delete all the notifications for a user based on the component name and action.
|
176 |
+
*
|
177 |
+
* @global wpdb $wpdb WordPress database object
|
178 |
+
* @param integer $user_id
|
179 |
+
* @param string $component_name
|
180 |
+
* @param string $component_action
|
181 |
+
* @static
|
182 |
+
*/
|
183 |
+
public static function delete_for_user_by_type( $user_id, $component_name, $component_action ) {
|
184 |
+
global $wpdb;
|
185 |
+
|
186 |
+
$bp = buddypress();
|
187 |
+
|
188 |
+
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 ) );
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Delete all the notifications that have a specific item id, component name and action.
|
193 |
+
*
|
194 |
+
* @global wpdb $wpdb WordPress database object
|
195 |
+
* @param integer $user_id The ID of the user who the notifications are for.
|
196 |
+
* @param integer $item_id The item ID of the notifications we wish to delete.
|
197 |
+
* @param string $component_name The name of the component that the notifications we wish to delete.
|
198 |
+
* @param string $component_action The action of the component that the notifications we wish to delete.
|
199 |
+
* @param integer $secondary_item_id (optional) The secondary item id of the notifications that we wish to use to delete.
|
200 |
+
* @static
|
201 |
+
*/
|
202 |
+
public static function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) {
|
203 |
+
global $wpdb;
|
204 |
+
|
205 |
+
$bp = buddypress();
|
206 |
+
|
207 |
+
$secondary_item_sql = !empty( $secondary_item_id )
|
208 |
+
? $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id )
|
209 |
+
: '';
|
210 |
+
|
211 |
+
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 ) );
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Deletes all the notifications sent by a specific user, by component and action.
|
216 |
+
*
|
217 |
+
* @global wpdb $wpdb WordPress database object
|
218 |
+
* @param integer $user_id The ID of the user whose sent notifications we wish to delete.
|
219 |
+
* @param string $component_name The name of the component the notification was sent from.
|
220 |
+
* @param string $component_action The action of the component the notification was sent from.
|
221 |
+
* @static
|
222 |
+
*/
|
223 |
+
public static function delete_from_user_by_type( $user_id, $component_name, $component_action ) {
|
224 |
+
global $wpdb;
|
225 |
+
|
226 |
+
$bp = buddypress();
|
227 |
+
|
228 |
+
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 ) );
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Deletes all the notifications for all users by item id, and optional secondary item id, and component name and action.
|
233 |
+
*
|
234 |
+
* @global wpdb $wpdb WordPress database object
|
235 |
+
* @param string $item_id The item id that they notifications are to be for.
|
236 |
+
* @param string $component_name The component that the notifications are to be from.
|
237 |
+
* @param string $component_action The action that the notifications are to be from.
|
238 |
+
* @param string $secondary_item_id Optional secondary item id that the notifications are to have.
|
239 |
+
* @static
|
240 |
+
*/
|
241 |
+
public static function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) {
|
242 |
+
global $wpdb;
|
243 |
+
|
244 |
+
if ( $component_action )
|
245 |
+
$component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action );
|
246 |
+
else
|
247 |
+
$component_action_sql = '';
|
248 |
+
|
249 |
+
if ( $secondary_item_id )
|
250 |
+
$secondary_item_sql = $wpdb->prepare( "AND secondary_item_id = %d", $secondary_item_id );
|
251 |
+
else
|
252 |
+
$secondary_item_sql = '';
|
253 |
+
|
254 |
+
$bp = buddypress();
|
255 |
+
|
256 |
+
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 ) );
|
257 |
+
}
|
258 |
+
}
|
bp-core/classes/class-bp-core-user.php
ADDED
@@ -0,0 +1,958 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Core component classes.
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
* @subpackage Core
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Exit if accessed directly
|
10 |
+
defined( 'ABSPATH' ) || exit;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Fetch data about a BuddyPress user.
|
14 |
+
*
|
15 |
+
* BP_Core_User class can be used by any component. It will fetch useful
|
16 |
+
* details for any user when provided with a user_id.
|
17 |
+
*
|
18 |
+
* Example:
|
19 |
+
* $user = new BP_Core_User( $user_id );
|
20 |
+
* $user_avatar = $user->avatar;
|
21 |
+
* $user_email = $user->email;
|
22 |
+
* $user_status = $user->status;
|
23 |
+
* etc.
|
24 |
+
*/
|
25 |
+
class BP_Core_User {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* ID of the user which the object relates to.
|
29 |
+
*
|
30 |
+
* @var integer
|
31 |
+
*/
|
32 |
+
public $id;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* The URL to the full size of the avatar for the user.
|
36 |
+
*
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
public $avatar;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* The URL to the thumb size of the avatar for the user.
|
43 |
+
*
|
44 |
+
* @var string
|
45 |
+
*/
|
46 |
+
public $avatar_thumb;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* The URL to the mini size of the avatar for the user.
|
50 |
+
*
|
51 |
+
* @var string
|
52 |
+
*/
|
53 |
+
public $avatar_mini;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* The full name of the user
|
57 |
+
*
|
58 |
+
* @var string
|
59 |
+
*/
|
60 |
+
public $fullname;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* The email for the user.
|
64 |
+
*
|
65 |
+
* @var string
|
66 |
+
*/
|
67 |
+
public $email;
|
68 |
+
|
69 |
+
/**
|
70 |
+
* The absolute url for the user's profile.
|
71 |
+
*
|
72 |
+
* @var string
|
73 |
+
*/
|
74 |
+
public $user_url;
|
75 |
+
|
76 |
+
/**
|
77 |
+
* The HTML for the user link, with the link text being the user's full name.
|
78 |
+
*
|
79 |
+
* @var string
|
80 |
+
*/
|
81 |
+
public $user_link;
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Contains a formatted string when the last time the user was active.
|
85 |
+
*
|
86 |
+
* Example: "active 2 hours and 50 minutes ago"
|
87 |
+
*
|
88 |
+
* @var string
|
89 |
+
*/
|
90 |
+
public $last_active;
|
91 |
+
|
92 |
+
/* Extras */
|
93 |
+
|
94 |
+
/**
|
95 |
+
* The total number of "Friends" the user has on site.
|
96 |
+
*
|
97 |
+
* @var integer
|
98 |
+
*/
|
99 |
+
public $total_friends;
|
100 |
+
|
101 |
+
/**
|
102 |
+
* The total number of blog posts posted by the user
|
103 |
+
*
|
104 |
+
* @var integer
|
105 |
+
* @deprecated No longer used
|
106 |
+
*/
|
107 |
+
public $total_blogs;
|
108 |
+
|
109 |
+
/**
|
110 |
+
* The total number of groups the user is a part of.
|
111 |
+
*
|
112 |
+
* Example: "1 group", "2 groups"
|
113 |
+
*
|
114 |
+
* @var string
|
115 |
+
*/
|
116 |
+
public $total_groups;
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Profile information for the specific user.
|
120 |
+
*
|
121 |
+
* @since BuddyPress (1.2.0)
|
122 |
+
* @var array
|
123 |
+
*/
|
124 |
+
public $profile_data;
|
125 |
+
|
126 |
+
/** Public Methods *******************************************************/
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Class constructor.
|
130 |
+
*
|
131 |
+
* @param integer $user_id The ID for the user being queried.
|
132 |
+
* @param bool $populate_extras Whether to fetch extra information
|
133 |
+
* such as group/friendship counts or not. Default: false.
|
134 |
+
*/
|
135 |
+
public function __construct( $user_id, $populate_extras = false ) {
|
136 |
+
if ( !empty( $user_id ) ) {
|
137 |
+
$this->id = $user_id;
|
138 |
+
$this->populate();
|
139 |
+
|
140 |
+
if ( !empty( $populate_extras ) ) {
|
141 |
+
$this->populate_extras();
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Populate the instantiated class with data based on the User ID provided.
|
148 |
+
*
|
149 |
+
* @uses bp_core_get_userurl() Returns the URL with no HTML markup for
|
150 |
+
* a user based on their user id.
|
151 |
+
* @uses bp_core_get_userlink() Returns a HTML formatted link for a
|
152 |
+
* user with the user's full name as the link text.
|
153 |
+
* @uses bp_core_get_user_email() Returns the email address for the
|
154 |
+
* user based on user ID.
|
155 |
+
* @uses bp_get_user_meta() BP function returns the value of passed
|
156 |
+
* usermeta name from usermeta table.
|
157 |
+
* @uses bp_core_fetch_avatar() Returns HTML formatted avatar for a user
|
158 |
+
* @uses bp_profile_last_updated_date() Returns the last updated date
|
159 |
+
* for a user.
|
160 |
+
*/
|
161 |
+
public function populate() {
|
162 |
+
|
163 |
+
if ( bp_is_active( 'xprofile' ) )
|
164 |
+
$this->profile_data = $this->get_profile_data();
|
165 |
+
|
166 |
+
if ( !empty( $this->profile_data ) ) {
|
167 |
+
$full_name_field_name = bp_xprofile_fullname_field_name();
|
168 |
+
|
169 |
+
$this->user_url = bp_core_get_user_domain( $this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login'] );
|
170 |
+
$this->fullname = esc_attr( $this->profile_data[$full_name_field_name]['field_data'] );
|
171 |
+
$this->user_link = "<a href='{$this->user_url}' title='{$this->fullname}'>{$this->fullname}</a>";
|
172 |
+
$this->email = esc_attr( $this->profile_data['user_email'] );
|
173 |
+
} else {
|
174 |
+
$this->user_url = bp_core_get_user_domain( $this->id );
|
175 |
+
$this->user_link = bp_core_get_userlink( $this->id );
|
176 |
+
$this->fullname = esc_attr( bp_core_get_user_displayname( $this->id ) );
|
177 |
+
$this->email = esc_attr( bp_core_get_user_email( $this->id ) );
|
178 |
+
}
|
179 |
+
|
180 |
+
// Cache a few things that are fetched often
|
181 |
+
wp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, 'bp' );
|
182 |
+
wp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' );
|
183 |
+
wp_cache_set( 'bp_user_url_' . $this->id, $this->user_url, 'bp' );
|
184 |
+
|
185 |
+
$this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) );
|
186 |
+
$this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) );
|
187 |
+
$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 ) );
|
188 |
+
$this->last_active = bp_core_get_last_activity( bp_get_user_last_activity( $this->id ), __( 'active %s', 'buddypress' ) );
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Populates extra fields such as group and friendship counts.
|
193 |
+
*/
|
194 |
+
public function populate_extras() {
|
195 |
+
|
196 |
+
if ( bp_is_active( 'friends' ) ) {
|
197 |
+
$this->total_friends = BP_Friends_Friendship::total_friend_count( $this->id );
|
198 |
+
}
|
199 |
+
|
200 |
+
if ( bp_is_active( 'groups' ) ) {
|
201 |
+
$this->total_groups = BP_Groups_Member::total_group_count( $this->id );
|
202 |
+
$this->total_groups = sprintf( _n( '%d group', '%d groups', $this->total_groups, 'buddypress' ), $this->total_groups );
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Fetch xprofile data for the current user.
|
208 |
+
*
|
209 |
+
* @see BP_XProfile_ProfileData::get_all_for_user() for description of
|
210 |
+
* return value.
|
211 |
+
*
|
212 |
+
* @return array See {@link BP_XProfile_Profile_Data::get_all_for_user()}.
|
213 |
+
*/
|
214 |
+
public function get_profile_data() {
|
215 |
+
return BP_XProfile_ProfileData::get_all_for_user( $this->id );
|
216 |
+
}
|
217 |
+
|
218 |
+
/** Static Methods ********************************************************/
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Get a list of users that match the query parameters.
|
222 |
+
*
|
223 |
+
* Since BuddyPress 1.7, use {@link BP_User_Query} instead.
|
224 |
+
*
|
225 |
+
* @deprecated 1.7.0 Use {@link BP_User_Query}.
|
226 |
+
*
|
227 |
+
* @see BP_User_Query for a description of parameters, most of which
|
228 |
+
* are used there in the same way.
|
229 |
+
*
|
230 |
+
* @param string $type See {@link BP_User_Query}.
|
231 |
+
* @param int $limit See {@link BP_User_Query}. Default: 0.
|
232 |
+
* @param int $page See {@link BP_User_Query}. Default: 1.
|
233 |
+
* @param int $user_id See {@link BP_User_Query}. Default: 0.
|
234 |
+
* @param mixed $include See {@link BP_User_Query}. Default: false.
|
235 |
+
* @param string|bool $search_terms See {@link BP_User_Query}.
|
236 |
+
* Default: false.
|
237 |
+
* @param bool $populate_extras See {@link BP_User_Query}.
|
238 |
+
* Default: true.
|
239 |
+
* @param mixed $exclude See {@link BP_User_Query}. Default: false.
|
240 |
+
* @param string|bool $meta_key See {@link BP_User_Query}.
|
241 |
+
* Default: false.
|
242 |
+
* @param string|bool $meta_value See {@link BP_User_Query}.
|
243 |
+
* Default: false.
|
244 |
+
* @return array {
|
245 |
+
* @type int $total_users Total number of users matched by query
|
246 |
+
* params.
|
247 |
+
* @type array $paged_users The current page of users matched by
|
248 |
+
* query params.
|
249 |
+
* }
|
250 |
+
*/
|
251 |
+
public static function get_users( $type, $limit = 0, $page = 1, $user_id = 0, $include = false, $search_terms = false, $populate_extras = true, $exclude = false, $meta_key = false, $meta_value = false ) {
|
252 |
+
global $wpdb;
|
253 |
+
|
254 |
+
_deprecated_function( __METHOD__, '1.7', 'BP_User_Query' );
|
255 |
+
|
256 |
+
$bp = buddypress();
|
257 |
+
|
258 |
+
$sql = array();
|
259 |
+
|
260 |
+
$sql['select_main'] = "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";
|
261 |
+
|
262 |
+
if ( 'active' == $type || 'online' == $type || 'newest' == $type ) {
|
263 |
+
$sql['select_active'] = ", um.meta_value as last_activity";
|
264 |
+
}
|
265 |
+
|
266 |
+
if ( 'popular' == $type ) {
|
267 |
+
$sql['select_popular'] = ", um.meta_value as total_friend_count";
|
268 |
+
}
|
269 |
+
|
270 |
+
if ( 'alphabetical' == $type ) {
|
271 |
+
$sql['select_alpha'] = ", pd.value as fullname";
|
272 |
+
}
|
273 |
+
|
274 |
+
if ( $meta_key ) {
|
275 |
+
$sql['select_meta'] = ", umm.meta_key";
|
276 |
+
|
277 |
+
if ( $meta_value ) {
|
278 |
+
$sql['select_meta'] .= ", umm.meta_value";
|
279 |
+
}
|
280 |
+
}
|
281 |
+
|
282 |
+
$sql['from'] = "FROM {$wpdb->users} u LEFT JOIN {$wpdb->usermeta} um ON um.user_id = u.ID";
|
283 |
+
|
284 |
+
// We search against xprofile fields, so we must join the table
|
285 |
+
if ( $search_terms && bp_is_active( 'xprofile' ) ) {
|
286 |
+
$sql['join_profiledata_search'] = "LEFT JOIN {$bp->profile->table_name_data} spd ON u.ID = spd.user_id";
|
287 |
+
}
|
288 |
+
|
289 |
+
// Alphabetical sorting is done by the xprofile Full Name field
|
290 |
+
if ( 'alphabetical' == $type ) {
|
291 |
+
$sql['join_profiledata_alpha'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
|
292 |
+
}
|
293 |
+
|
294 |
+
if ( $meta_key ) {
|
295 |
+
$sql['join_meta'] = "LEFT JOIN {$wpdb->usermeta} umm ON umm.user_id = u.ID";
|
296 |
+
}
|
297 |
+
|
298 |
+
$sql['where'] = 'WHERE ' . bp_core_get_status_sql( 'u.' );
|
299 |
+
|
300 |
+
if ( 'active' == $type || 'online' == $type || 'newest' == $type ) {
|
301 |
+
$sql['where_active'] = $wpdb->prepare( "AND um.meta_key = %s", bp_get_user_meta_key( 'last_activity' ) );
|
302 |
+
}
|
303 |
+
|
304 |
+
if ( 'popular' == $type ) {
|
305 |
+
$sql['where_popular'] = $wpdb->prepare( "AND um.meta_key = %s", bp_get_user_meta_key( 'total_friend_count' ) );
|
306 |
+
}
|
307 |
+
|
308 |
+
if ( 'online' == $type ) {
|
309 |
+
$sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= UTC_TIMESTAMP()";
|
310 |
+
}
|
311 |
+
|
312 |
+
if ( 'alphabetical' == $type ) {
|
313 |
+
$sql['where_alpha'] = "AND pd.field_id = 1";
|
314 |
+
}
|
315 |
+
|
316 |
+
if ( !empty( $exclude ) ) {
|
317 |
+
$exclude = implode( ',', wp_parse_id_list( $exclude ) );
|
318 |
+
$sql['where_exclude'] = "AND u.ID NOT IN ({$exclude})";
|
319 |
+
}
|
320 |
+
|
321 |
+
// Passing an $include value of 0 or '0' will necessarily result in an empty set
|
322 |
+
// returned. The default value of false will hit the 'else' clause.
|
323 |
+
if ( 0 === $include || '0' === $include ) {
|
324 |
+
$sql['where_users'] = "AND 0 = 1";
|
325 |
+
} else {
|
326 |
+
if ( !empty( $include ) ) {
|
327 |
+
$include = implode( ',', wp_parse_id_list( $include ) );
|
328 |
+
$sql['where_users'] = "AND u.ID IN ({$include})";
|
329 |
+
} elseif ( !empty( $user_id ) && bp_is_active( 'friends' ) ) {
|
330 |
+
$friend_ids = friends_get_friend_user_ids( $user_id );
|
331 |
+
|
332 |
+
if ( !empty( $friend_ids ) ) {
|
333 |
+
$friend_ids = implode( ',', wp_parse_id_list( $friend_ids ) );
|
334 |
+
$sql['where_friends'] = "AND u.ID IN ({$friend_ids})";
|
335 |
+
|
336 |
+
// User has no friends, return false since there will be no users to fetch.
|
337 |
+
} else {
|
338 |
+
return false;
|
339 |
+
}
|
340 |
+
}
|
341 |
+
}
|
342 |
+
|
343 |
+
if ( !empty( $search_terms ) && bp_is_active( 'xprofile' ) ) {
|
344 |
+
$search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
|
345 |
+
$sql['where_searchterms'] = $wpdb->prepare( "AND spd.value LIKE %s", $search_terms_like );
|
346 |
+
}
|
347 |
+
|
348 |
+
if ( !empty( $meta_key ) ) {
|
349 |
+
$sql['where_meta'] = $wpdb->prepare( " AND umm.meta_key = %s", $meta_key );
|
350 |
+
|
351 |
+
// If a meta value is provided, match it
|
352 |
+
if ( $meta_value ) {
|
353 |
+
$sql['where_meta'] .= $wpdb->prepare( " AND umm.meta_value = %s", $meta_value );
|
354 |
+
}
|
355 |
+
}
|
356 |
+
|
357 |
+
switch ( $type ) {
|
358 |
+
case 'active': case 'online': default:
|
359 |
+
$sql[] = "ORDER BY um.meta_value DESC";
|
360 |
+
break;
|
361 |
+
case 'newest':
|
362 |
+
$sql[] = "ORDER BY u.ID DESC";
|
363 |
+
break;
|
364 |
+
case 'alphabetical':
|
365 |
+
$sql[] = "ORDER BY pd.value ASC";
|
366 |
+
break;
|
367 |
+
case 'random':
|
368 |
+
$sql[] = "ORDER BY rand()";
|
369 |
+
break;
|
370 |
+
case 'popular':
|
371 |
+
$sql[] = "ORDER BY CONVERT(um.meta_value, SIGNED) DESC";
|
372 |
+
break;
|
373 |
+
}
|
374 |
+
|
375 |
+
if ( !empty( $limit ) && !empty( $page ) ) {
|
376 |
+
$sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Filters the SQL used to query for paged users.
|
381 |
+
*
|
382 |
+
* @since BuddyPress (1.2.6)
|
383 |
+
*
|
384 |
+
* @param string $value Concatenated SQL statement for the query.
|
385 |
+
* @param array $sql Array of SQL statement parts for the query.
|
386 |
+
*/
|
387 |
+
$paged_users_sql = apply_filters( 'bp_core_get_paged_users_sql', join( ' ', (array) $sql ), $sql );
|
388 |
+
$paged_users = $wpdb->get_results( $paged_users_sql );
|
389 |
+
|
390 |
+
// Re-jig the SQL so we can get the total user count
|
391 |
+
unset( $sql['select_main'] );
|
392 |
+
|
393 |
+
if ( !empty( $sql['select_active'] ) ) {
|
394 |
+
unset( $sql['select_active'] );
|
395 |
+
}
|
396 |
+
|
397 |
+
if ( !empty( $sql['select_popular'] ) ) {
|
398 |
+
unset( $sql['select_popular'] );
|
399 |
+
}
|
400 |
+
|
401 |
+
if ( !empty( $sql['select_alpha'] ) ) {
|
402 |
+
unset( $sql['select_alpha'] );
|
403 |
+
}
|
404 |
+
|
405 |
+
if ( !empty( $sql['pagination'] ) ) {
|
406 |
+
unset( $sql['pagination'] );
|
407 |
+
}
|
408 |
+
|
409 |
+
array_unshift( $sql, "SELECT COUNT(u.ID)" );
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Filters the SQL used to query for total users.
|
413 |
+
*
|
414 |
+
* @since BuddyPress (1.2.6)
|
415 |
+
*
|
416 |
+
* @param string $value Concatenated SQL statement for the query.
|
417 |
+
* @param array $sql Array of SQL statement parts for the query.
|
418 |
+
*/
|
419 |
+
$total_users_sql = apply_filters( 'bp_core_get_total_users_sql', join( ' ', (array) $sql ), $sql );
|
420 |
+
$total_users = $wpdb->get_var( $total_users_sql );
|
421 |
+
|
422 |
+
/***
|
423 |
+
* Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
|
424 |
+
* We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
|
425 |
+
*/
|
426 |
+
if ( !empty( $populate_extras ) ) {
|
427 |
+
$user_ids = array();
|
428 |
+
|
429 |
+
foreach ( (array) $paged_users as $user ) {
|
430 |
+
$user_ids[] = $user->id;
|
431 |
+
}
|
432 |
+
|
433 |
+
// Add additional data to the returned results
|
434 |
+
$paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids, $type );
|
435 |
+
}
|
436 |
+
|
437 |
+
return array( 'users' => $paged_users, 'total' => $total_users );
|
438 |
+
}
|
439 |
+
|
440 |
+
|
441 |
+
/**
|
442 |
+
* Fetch the details for all users whose usernames start with the given letter.
|
443 |
+
*
|
444 |
+
* @global wpdb $wpdb WordPress database object.
|
445 |
+
*
|
446 |
+
* @param string $letter The letter the users names are to start with.
|
447 |
+
* @param int $limit The number of users we wish to retrive.
|
448 |
+
* @param int $page The page number we are currently on, used in
|
449 |
+
* conjunction with $limit to get the start position for the
|
450 |
+
* limit.
|
451 |
+
* @param bool $populate_extras Populate extra user fields?
|
452 |
+
* @param string $exclude Comma-separated IDs of users whose results
|
453 |
+
* aren't to be fetched.
|
454 |
+
* @return mixed False on error, otherwise associative array of results.
|
455 |
+
*/
|
456 |
+
public static function get_users_by_letter( $letter, $limit = null, $page = 1, $populate_extras = true, $exclude = '' ) {
|
457 |
+
global $wpdb;
|
458 |
+
|
459 |
+
$pag_sql = '';
|
460 |
+
if ( $limit && $page ) {
|
461 |
+
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
462 |
+
}
|
463 |
+
|
464 |
+
// Multibyte compliance
|
465 |
+
if ( function_exists( 'mb_strlen' ) ) {
|
466 |
+
if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || !$letter ) {
|
467 |
+
return false;
|
468 |
+
}
|
469 |
+
} else {
|
470 |
+
if ( strlen( $letter ) > 1 || is_numeric( $letter ) || !$letter ) {
|
471 |
+
return false;
|
472 |
+
}
|
473 |
+
}
|
474 |
+
|
475 |
+
$bp = buddypress();
|
476 |
+
|
477 |
+
$letter_like = bp_esc_like( $letter ) . '%';
|
478 |
+
$status_sql = bp_core_get_status_sql( 'u.' );
|
479 |
+
|
480 |
+
if ( !empty( $exclude ) ) {
|
481 |
+
$exclude = implode( ',', wp_parse_id_list( $exclude ) );
|
482 |
+
$exclude_sql = " AND u.id NOT IN ({$exclude})";
|
483 |
+
} else {
|
484 |
+
$exclude_sql = '';
|
485 |
+
}
|
486 |
+
|
487 |
+
/**
|
488 |
+
* Filters the SQL used to query for total user count by first letter.
|
489 |
+
*
|
490 |
+
* @since BuddyPress (1.0.0)
|
491 |
+
*
|
492 |
+
* @param string $value SQL prepared statement for the user count query.
|
493 |
+
*/
|
494 |
+
$total_users_sql = apply_filters( 'bp_core_users_by_letter_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT u.ID) FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE %s ORDER BY pd.value ASC", bp_xprofile_fullname_field_name(), $letter_like ) );
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Filters the SQL used to query for users by first letter.
|
498 |
+
*
|
499 |
+
* @since BuddyPress (1.0.0)
|
500 |
+
*
|
501 |
+
* @param string $value SQL prepared statement for the user query.
|
502 |
+
*/
|
503 |
+
$paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE %s ORDER BY pd.value ASC{$pag_sql}", bp_xprofile_fullname_field_name(), $letter_like ) );
|
504 |
+
|
505 |
+
$total_users = $wpdb->get_var( $total_users_sql );
|
506 |
+
$paged_users = $wpdb->get_results( $paged_users_sql );
|
507 |
+
|
508 |
+
/***
|
509 |
+
* Lets fetch some other useful data in a separate queries, this will be
|
510 |
+
* faster than querying the data for every user in a list. We can't add
|
511 |
+
* these to the main query above since only users who have this
|
512 |
+
* information will be returned (since the much of the data is in
|
513 |
+
* usermeta and won't support any type of directional join)
|
514 |
+
*/
|
515 |
+
$user_ids = array();
|
516 |
+
foreach ( (array) $paged_users as $user )
|
517 |
+
$user_ids[] = (int) $user->id;
|
518 |
+
|
519 |
+
// Add additional data to the returned results
|
520 |
+
if ( $populate_extras ) {
|
521 |
+
$paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
|
522 |
+
}
|
523 |
+
|
524 |
+
return array( 'users' => $paged_users, 'total' => $total_users );
|
525 |
+
}
|
526 |
+
|
527 |
+
/**
|
528 |
+
* Get details of specific users from the database.
|
529 |
+
*
|
530 |
+
* Use {@link BP_User_Query} with the 'user_ids' param instead.
|
531 |
+
*
|
532 |
+
* @global wpdb $wpdb WordPress database object.
|
533 |
+
* @param array $user_ids The user IDs of the users who we wish to
|
534 |
+
* fetch information on.
|
535 |
+
* @param int $limit The limit of results we want.
|
536 |
+
* @param int $page The page we are on for pagination.
|
537 |
+
* @param bool $populate_extras Populate extra user fields?
|
538 |
+
* @return array Associative array.
|
539 |
+
*/
|
540 |
+
public static function get_specific_users( $user_ids, $limit = null, $page = 1, $populate_extras = true ) {
|
541 |
+
global $wpdb;
|
542 |
+
|
543 |
+
$pag_sql = '';
|
544 |
+
if ( $limit && $page )
|
545 |
+
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
546 |
+
|
547 |
+
$user_ids = implode( ',', wp_parse_id_list( $user_ids ) );
|
548 |
+
$status_sql = bp_core_get_status_sql();
|
549 |
+
|
550 |
+
/**
|
551 |
+
* Filter the SQL string used for querying specific user count.
|
552 |
+
*
|
553 |
+
* This same filter name is used for the paged user SQL, and so should be avoided.
|
554 |
+
* Use 'bp_core_user_get_specific_users_count_sql' instead.
|
555 |
+
*
|
556 |
+
* @deprecated BuddyPress (2.3.0)
|
557 |
+
*
|
558 |
+
* @param string $sql SQL string.
|
559 |
+
*/
|
560 |
+
$total_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', "SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql} AND ID IN ({$user_ids})" );
|
561 |
+
|
562 |
+
/**
|
563 |
+
* Filter the SQL string used for querying specific user count results.
|
564 |
+
*
|
565 |
+
* Use this instead of the deprecated 'bp_core_get_specific_users_count_sql'.
|
566 |
+
*
|
567 |
+
* @since BuddyPress (2.3.0)
|
568 |
+
*
|
569 |
+
* @param string $sql SQL string.
|
570 |
+
* @param array $user_ids Array of IDs of specific users to fetch.
|
571 |
+
* @param int|null $limit Max number of records to return. Null for no limit.
|
572 |
+
* @param int $page The page we're on for pagination.
|
573 |
+
* @param bool $populate_extras Whether to populate extra user fields.
|
574 |
+
*/
|
575 |
+
$total_users_sql = apply_filters( 'bp_core_user_get_specific_users_count_sql', $total_users_sql, $user_ids, $limit, $page, $populate_extras );
|
576 |
+
|
577 |
+
/**
|
578 |
+
* Filter the SQL string used for querying specific user paged results.
|
579 |
+
*
|
580 |
+
* This same filter name is used for the user count SQL, and so should be avoided.
|
581 |
+
* Use 'bp_core_user_get_specific_users_paged_sql' instead.
|
582 |
+
*
|
583 |
+
* @deprecated BuddyPress (2.3.0)
|
584 |
+
*
|
585 |
+
* @param string $sql SQL string.
|
586 |
+
*/
|
587 |
+
$paged_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', "SELECT ID as id, user_registered, user_nicename, user_login, user_email FROM {$wpdb->users} WHERE {$status_sql} AND ID IN ({$user_ids}) {$pag_sql}" );
|
588 |
+
|
589 |
+
/**
|
590 |
+
* Filter the SQL string used for querying specific user paged results.
|
591 |
+
*
|
592 |
+
* Use this instead of the deprecated 'bp_core_get_specific_users_count_sql'.
|
593 |
+
*
|
594 |
+
* @since BuddyPress (2.3.0)
|
595 |
+
*
|
596 |
+
* @param string $sql SQL string.
|
597 |
+
* @param array $user_ids Array of IDs of specific users to fetch.
|
598 |
+
* @param int|null $limit Max number of records to return. Null for no limit.
|
599 |
+
* @param int $page The page we're on for pagination.
|
600 |
+
* @param bool $populate_extras Whether to populate extra user fields.
|
601 |
+
*/
|
602 |
+
$paged_users_sql = apply_filters( 'bp_core_user_get_specific_users_paged_sql', $paged_users_sql, $user_ids, $limit, $page, $populate_extras );
|
603 |
+
|
604 |
+
$total_users = $wpdb->get_var( $total_users_sql );
|
605 |
+
$paged_users = $wpdb->get_results( $paged_users_sql );
|
606 |
+
|
607 |
+
/***
|
608 |
+
* Lets fetch some other useful data in a separate queries, this will be
|
609 |
+
* faster than querying the data for every user in a list. We can't add
|
610 |
+
* these to the main query above since only users who have this
|
611 |
+
* information will be returned (since the much of the data is in
|
612 |
+
* usermeta and won't support any type of directional join)
|
613 |
+
*/
|
614 |
+
|
615 |
+
// Add additional data to the returned results
|
616 |
+
if ( !empty( $populate_extras ) ) {
|
617 |
+
$paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
|
618 |
+
}
|
619 |
+
|
620 |
+
return array( 'users' => $paged_users, 'total' => $total_users );
|
621 |
+
}
|
622 |
+
|
623 |
+
/**
|
624 |
+
* Find users who match on the value of an xprofile data.
|
625 |
+
*
|
626 |
+
* @global wpdb $wpdb WordPress database object.
|
627 |
+
*
|
628 |
+
* @param string $search_terms The terms to search the profile table
|
629 |
+
* value column for.
|
630 |
+
* @param integer $limit The limit of results we want.
|
631 |
+
* @param integer $page The page we are on for pagination.
|
632 |
+
* @param boolean $populate_extras Populate extra user fields?
|
633 |
+
* @return array Associative array.
|
634 |
+
*/
|
635 |
+
public static function search_users( $search_terms, $limit = null, $page = 1, $populate_extras = true ) {
|
636 |
+
global $wpdb;
|
637 |
+
|
638 |
+
$bp = buddypress();
|
639 |
+
|
640 |
+
$user_ids = array();
|
641 |
+
$pag_sql = $limit && $page ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * intval( $limit ) ), intval( $limit ) ) : '';
|
642 |
+
|
643 |
+
$search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
|
644 |
+
$status_sql = bp_core_get_status_sql( 'u.' );
|
645 |
+
|
646 |
+
/**
|
647 |
+
* Filters the SQL used to query for searched users count.
|
648 |
+
*
|
649 |
+
* @since BuddyPress (1.0.0)
|
650 |
+
*
|
651 |
+
* @param string $value SQL statement for the searched users count query.
|
652 |
+
*/
|
653 |
+
$total_users_sql = apply_filters( 'bp_core_search_users_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT u.ID) as id FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE %s ORDER BY pd.value ASC", $search_terms_like ), $search_terms );
|
654 |
+
|
655 |
+
/**
|
656 |
+
* Filters the SQL used to query for searched users.
|
657 |
+
*
|
658 |
+
* @since BuddyPress (1.0.0)
|
659 |
+
*
|
660 |
+
* @param string $value SQL statement for the searched users query.
|
661 |
+
*/
|
662 |
+
$paged_users_sql = apply_filters( 'bp_core_search_users_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE %s ORDER BY pd.value ASC{$pag_sql}", $search_terms_like ), $search_terms, $pag_sql );
|
663 |
+
|
664 |
+
$total_users = $wpdb->get_var( $total_users_sql );
|
665 |
+
$paged_users = $wpdb->get_results( $paged_users_sql );
|
666 |
+
|
667 |
+
/***
|
668 |
+
* Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
|
669 |
+
* We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
|
670 |
+
*/
|
671 |
+
foreach ( (array) $paged_users as $user )
|
672 |
+
$user_ids[] = $user->id;
|
673 |
+
|
674 |
+
// Add additional data to the returned results
|
675 |
+
if ( $populate_extras )
|
676 |
+
$paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
|
677 |
+
|
678 |
+
return array( 'users' => $paged_users, 'total' => $total_users );
|
679 |
+
}
|
680 |
+
|
681 |
+
/**
|
682 |
+
* Fetch extra user information, such as friend count and last profile update message.
|
683 |
+
*
|
684 |
+
* Accepts multiple user IDs to fetch data for.
|
685 |
+
*
|
686 |
+
* @global wpdb $wpdb WordPress database object.
|
687 |
+
*
|
688 |
+
* @param array $paged_users An array of stdClass containing the users.
|
689 |
+
* @param string $user_ids The user ids to select information about.
|
690 |
+
* @param string $type The type of fields we wish to get.
|
691 |
+
* @return mixed False on error, otherwise associative array of results.
|
692 |
+
*/
|
693 |
+
public static function get_user_extras( &$paged_users, &$user_ids, $type = false ) {
|
694 |
+
global $wpdb;
|
695 |
+
|
696 |
+
$bp = buddypress();
|
697 |
+
|
698 |
+
if ( empty( $user_ids ) )
|
699 |
+
return $paged_users;
|
700 |
+
|
701 |
+
// Sanitize user IDs
|
702 |
+
$user_ids = implode( ',', wp_parse_id_list( $user_ids ) );
|
703 |
+
|
704 |
+
// Fetch the user's full name
|
705 |
+
if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) {
|
706 |
+
$names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", bp_xprofile_fullname_field_name() ) );
|
707 |
+
for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
|
708 |
+
foreach ( (array) $names as $name ) {
|
709 |
+
if ( $name->id == $paged_users[$i]->id )
|
710 |
+
$paged_users[$i]->fullname = $name->fullname;
|
711 |
+
}
|
712 |
+
}
|
713 |
+
}
|
714 |
+
|
715 |
+
// Fetch the user's total friend count
|
716 |
+
if ( 'popular' != $type ) {
|
717 |
+
$friend_count = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as total_friend_count FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'total_friend_count' ) ) );
|
718 |
+
for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
|
719 |
+
foreach ( (array) $friend_count as $fcount ) {
|
720 |
+
if ( $fcount->id == $paged_users[$i]->id )
|
721 |
+
$paged_users[$i]->total_friend_count = (int) $fcount->total_friend_count;
|
722 |
+
}
|
723 |
+
}
|
724 |
+
}
|
725 |
+
|
726 |
+
// Fetch whether or not the user is a friend
|
727 |
+
if ( bp_is_active( 'friends' ) ) {
|
728 |
+
$friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", bp_loggedin_user_id(), bp_loggedin_user_id() ) );
|
729 |
+
for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
|
730 |
+
foreach ( (array) $friend_status as $status ) {
|
731 |
+
if ( $status->initiator_user_id == $paged_users[$i]->id || $status->friend_user_id == $paged_users[$i]->id )
|
732 |
+
$paged_users[$i]->is_friend = $status->is_confirmed;
|
733 |
+
}
|
734 |
+
}
|
735 |
+
}
|
736 |
+
|
737 |
+
if ( 'active' != $type ) {
|
738 |
+
$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' ) ) );
|
739 |
+
for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
|
740 |
+
foreach ( (array) $user_activity as $activity ) {
|
741 |
+
if ( $activity->id == $paged_users[$i]->id )
|
742 |
+
$paged_users[$i]->last_activity = $activity->last_activity;
|
743 |
+
}
|
744 |
+
}
|
745 |
+
}
|
746 |
+
|
747 |
+
// Fetch the user's last_activity
|
748 |
+
if ( 'active' != $type ) {
|
749 |
+
$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' ) ) );
|
750 |
+
for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
|
751 |
+
foreach ( (array) $user_activity as $activity ) {
|
752 |
+
if ( $activity->id == $paged_users[$i]->id )
|
753 |
+
$paged_users[$i]->last_activity = $activity->last_activity;
|
754 |
+
}
|
755 |
+
}
|
756 |
+
}
|
757 |
+
|
758 |
+
// Fetch the user's latest update
|
759 |
+
$user_update = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as latest_update FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'bp_latest_update' ) ) );
|
760 |
+
for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
|
761 |
+
foreach ( (array) $user_update as $update ) {
|
762 |
+
if ( $update->id == $paged_users[$i]->id )
|
763 |
+
$paged_users[$i]->latest_update = $update->latest_update;
|
764 |
+
}
|
765 |
+
}
|
766 |
+
|
767 |
+
return $paged_users;
|
768 |
+
}
|
769 |
+
|
770 |
+
/**
|
771 |
+
* Get WordPress user details for a specified user.
|
772 |
+
*
|
773 |
+
* @global wpdb $wpdb WordPress database object.
|
774 |
+
*
|
775 |
+
* @param integer $user_id User ID.
|
776 |
+
* @return array Associative array.
|
777 |
+
*/
|
778 |
+
public static function get_core_userdata( $user_id ) {
|
779 |
+
global $wpdb;
|
780 |
+
|
781 |
+
if ( !$user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->users} WHERE ID = %d LIMIT 1", $user_id ) ) )
|
782 |
+
return false;
|
783 |
+
|
784 |
+
return $user;
|
785 |
+
}
|
786 |
+
|
787 |
+
/**
|
788 |
+
* Get last activity data for a user or set of users.
|
789 |
+
*
|
790 |
+
* @param int|array User IDs or multiple user IDs.
|
791 |
+
* @return array
|
792 |
+
*/
|
793 |
+
public static function get_last_activity( $user_id ) {
|
794 |
+
global $wpdb;
|
795 |
+
|
796 |
+
// Sanitize and remove empty values
|
797 |
+
$user_ids = array_filter( wp_parse_id_list( $user_id ) );
|
798 |
+
|
799 |
+
if ( empty( $user_ids ) ) {
|
800 |
+
return false;
|
801 |
+
}
|
802 |
+
|
803 |
+
$uncached_user_ids = bp_get_non_cached_ids( $user_ids, 'bp_last_activity' );
|
804 |
+
if ( ! empty( $uncached_user_ids ) ) {
|
805 |
+
$bp = buddypress();
|
806 |
+
|
807 |
+
$user_ids_sql = implode( ',', $uncached_user_ids );
|
808 |
+
$user_count = count( $uncached_user_ids );
|
809 |
+
|
810 |
+
$last_activities = $wpdb->get_results( $wpdb->prepare( "SELECT id, user_id, date_recorded FROM {$bp->members->table_name_last_activity} WHERE component = %s AND type = 'last_activity' AND user_id IN ({$user_ids_sql}) LIMIT {$user_count}", $bp->members->id ) );
|
811 |
+
|
812 |
+
foreach ( $last_activities as $last_activity ) {
|
813 |
+
wp_cache_set( $last_activity->user_id, array(
|
814 |
+
'user_id' => $last_activity->user_id,
|
815 |
+
'date_recorded' => $last_activity->date_recorded,
|
816 |
+
'activity_id' => $last_activity->id,
|
817 |
+
), 'bp_last_activity' );
|
818 |
+
}
|
819 |
+
}
|
820 |
+
|
821 |
+
// Fetch all user data from the cache
|
822 |
+
$retval = array();
|
823 |
+
foreach ( $user_ids as $user_id ) {
|
824 |
+
$retval[ $user_id ] = wp_cache_get( $user_id, 'bp_last_activity' );
|
825 |
+
}
|
826 |
+
|
827 |
+
return $retval;
|
828 |
+
}
|
829 |
+
|
830 |
+
/**
|
831 |
+
* Set a user's last_activity value.
|
832 |
+
*
|
833 |
+
* Will create a new entry if it does not exist. Otherwise updates the
|
834 |
+
* existing entry.
|
835 |
+
*
|
836 |
+
* @since BuddyPress (2.0.0)
|
837 |
+
*
|
838 |
+
* @param int $user_id ID of the user whose last_activity you are updating.
|
839 |
+
* @param string $time MySQL-formatted time string.
|
840 |
+
* @return bool True on success, false on failure.
|
841 |
+
*/
|
842 |
+
public static function update_last_activity( $user_id, $time ) {
|
843 |
+
global $wpdb;
|
844 |
+
|
845 |
+
$table_name = buddypress()->members->table_name_last_activity;
|
846 |
+
|
847 |
+
$activity = self::get_last_activity( $user_id );
|
848 |
+
|
849 |
+
if ( ! empty( $activity[ $user_id ] ) ) {
|
850 |
+
$updated = $wpdb->update(
|
851 |
+
$table_name,
|
852 |
+
|
853 |
+
// Data to update
|
854 |
+
array(
|
855 |
+
'date_recorded' => $time,
|
856 |
+
),
|
857 |
+
|
858 |
+
// WHERE
|
859 |
+
array(
|
860 |
+
'id' => $activity[ $user_id ]['activity_id'],
|
861 |
+
),
|
862 |
+
|
863 |
+
// Data sanitization format
|
864 |
+
array(
|
865 |
+
'%s',
|
866 |
+
),
|
867 |
+
|
868 |
+
// WHERE sanitization format
|
869 |
+
array(
|
870 |
+
'%d',
|
871 |
+
)
|
872 |
+
);
|
873 |
+
|
874 |
+
// add new date to existing activity entry for caching
|
875 |
+
$activity[ $user_id ]['date_recorded'] = $time;
|
876 |
+
|
877 |
+
} else {
|
878 |
+
$updated = $wpdb->insert(
|
879 |
+
$table_name,
|
880 |
+
|
881 |
+
// Data
|
882 |
+
array(
|
883 |
+
'user_id' => $user_id,
|
884 |
+
'component' => buddypress()->members->id,
|
885 |
+
'type' => 'last_activity',
|
886 |
+
'action' => '',
|
887 |
+
'content' => '',
|
888 |
+
'primary_link' => '',
|
889 |
+
'item_id' => 0,
|
890 |
+
'date_recorded' => $time,
|
891 |
+
),
|
892 |
+
|
893 |
+
// Data sanitization format
|
894 |
+
array(
|
895 |
+
'%d',
|
896 |
+
'%s',
|
897 |
+
'%s',
|
898 |
+
'%s',
|
899 |
+
'%s',
|
900 |
+
'%s',
|
901 |
+
'%d',
|
902 |
+
'%s',
|
903 |
+
)
|
904 |
+
);
|
905 |
+
|
906 |
+
// set up activity array for caching
|
907 |
+
// view the foreach loop in the get_last_activity() method for format
|
908 |
+
$activity = array();
|
909 |
+
$activity[ $user_id ] = array(
|
910 |
+
'user_id' => $user_id,
|
911 |
+
'date_recorded' => $time,
|
912 |
+
'activity_id' => $wpdb->insert_id,
|
913 |
+
);
|
914 |
+
}
|
915 |
+
|
916 |
+
// set cache
|
917 |
+
wp_cache_set( $user_id, $activity[ $user_id ], 'bp_last_activity' );
|
918 |
+
|
919 |
+
return $updated;
|
920 |
+
}
|
921 |
+
|
922 |
+
/**
|
923 |
+
* Delete a user's last_activity value.
|
924 |
+
*
|
925 |
+
* @since BuddyPress (2.0.0)
|
926 |
+
*
|
927 |
+
* @param int $user_id
|
928 |
+
* @return bool True on success, false on failure or if no last_activity
|
929 |
+
* is found for the user.
|
930 |
+
*/
|
931 |
+
public static function delete_last_activity( $user_id ) {
|
932 |
+
global $wpdb;
|
933 |
+
|
934 |
+
$existing = self::get_last_activity( $user_id );
|
935 |
+
|
936 |
+
if ( empty( $existing ) ) {
|
937 |
+
return false;
|
938 |
+
}
|
939 |
+
|
940 |
+
$deleted = $wpdb->delete(
|
941 |
+
buddypress()->members->table_name_last_activity,
|
942 |
+
|
943 |
+
// WHERE
|
944 |
+
array(
|
945 |
+
'id' => $existing[ $user_id ]['activity_id'],
|
946 |
+
),
|
947 |
+
|
948 |
+
// WHERE sanitization format
|
949 |
+
array(
|
950 |
+
'%s',
|
951 |
+
)
|
952 |
+
);
|
953 |
+
|
954 |
+
wp_cache_delete( $user_id, 'bp_last_activity' );
|
955 |
+
|
956 |
+
return $deleted;
|
957 |
+
}
|
958 |
+
}
|
bp-core/classes/class-bp-date-query.php
ADDED
@@ -0,0 +1,65 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Core component classes.
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
* @subpackage Core
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Exit if accessed directly
|
10 |
+
defined( 'ABSPATH' ) || exit;
|
11 |
+
|
12 |
+
if ( class_exists( 'WP_Date_Query' ) ) :
|
13 |
+
/**
|
14 |
+
* BuddyPress date query class.
|
15 |
+
*
|
16 |
+
* Extends the {@link WP_Date_Query} class for use with BuddyPress.
|
17 |
+
*
|
18 |
+
* @since BuddyPress (2.1.0)
|
19 |
+
*
|
20 |
+
* @param array $date_query {
|
21 |
+
* Date query arguments. See first parameter of {@link WP_Date_Query::__construct()}.
|
22 |
+
* }
|
23 |
+
* @param string $column The DB column to query against.
|
24 |
+
*/
|
25 |
+
class BP_Date_Query extends WP_Date_Query {
|
26 |
+
/**
|
27 |
+
* The column to query against. Can be changed via the query arguments.
|
28 |
+
*
|
29 |
+
* @var string
|
30 |
+
*/
|
31 |
+
public $column;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Constructor.
|
35 |
+
*
|
36 |
+
* @see WP_Date_Query::__construct()
|
37 |
+
*/
|
38 |
+
public function __construct( $date_query, $column = '' ) {
|
39 |
+
if ( ! empty( $column ) ) {
|
40 |
+
$this->column = $column;
|
41 |
+
add_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) );
|
42 |
+
}
|
43 |
+
|
44 |
+
parent::__construct( $date_query, $column );
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Destructor.
|
49 |
+
*/
|
50 |
+
public function __destruct() {
|
51 |
+
remove_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) );
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Registers our date column with WP Date Query to pass validation.
|
56 |
+
*
|
57 |
+
* @param array $retval Current DB columns
|
58 |
+
* @return array
|
59 |
+
*/
|
60 |
+
public function register_date_column( $retval = array() ) {
|
61 |
+
$retval[] = $this->column;
|
62 |
+
return $retval;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
endif;
|
bp-core/classes/class-bp-embed.php
ADDED
@@ -0,0 +1,248 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Core component classes.
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
* @subpackage Core
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Exit if accessed directly
|
10 |
+
defined( 'ABSPATH' ) || exit;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Enable oEmbeds in BuddyPress contexts.
|
14 |
+
*
|
15 |
+
* Extends WP_Embed class for use with BuddyPress.
|
16 |
+
*
|
17 |
+
* @since BuddyPress (1.5.0)
|
18 |
+
*
|
19 |
+
* @see WP_Embed
|
20 |
+
*/
|
21 |
+
class BP_Embed extends WP_Embed {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Constructor
|
25 |
+
*
|
26 |
+
* @global WP_Embed $wp_embed
|
27 |
+
*/
|
28 |
+
public function __construct() {
|
29 |
+
global $wp_embed;
|
30 |
+
|
31 |
+
// Make sure we populate the WP_Embed handlers array.
|
32 |
+
// These are providers that use a regex callback on the URL in question.
|
33 |
+
// Do not confuse with oEmbed providers, which require an external ping.
|
34 |
+
// Used in WP_Embed::shortcode()
|
35 |
+
$this->handlers = $wp_embed->handlers;
|
36 |
+
|
37 |
+
if ( bp_use_embed_in_activity() ) {
|
38 |
+
add_filter( 'bp_get_activity_content_body', array( &$this, 'autoembed' ), 8 );
|
39 |
+
add_filter( 'bp_get_activity_content_body', array( &$this, 'run_shortcode' ), 7 );
|
40 |
+
}
|
41 |
+
|
42 |
+
if ( bp_use_embed_in_activity_replies() ) {
|
43 |
+
add_filter( 'bp_get_activity_content', array( &$this, 'autoembed' ), 8 );
|
44 |
+
add_filter( 'bp_get_activity_content', array( &$this, 'run_shortcode' ), 7 );
|
45 |
+
}
|
46 |
+
|
47 |
+
if ( bp_use_embed_in_forum_posts() ) {
|
48 |
+
add_filter( 'bp_get_the_topic_post_content', array( &$this, 'autoembed' ), 8 );
|
49 |
+
add_filter( 'bp_get_the_topic_post_content', array( &$this, 'run_shortcode' ), 7 );
|
50 |
+
}
|
51 |
+
|
52 |
+
if ( bp_use_embed_in_private_messages() ) {
|
53 |
+
add_filter( 'bp_get_the_thread_message_content', array( &$this, 'autoembed' ), 8 );
|
54 |
+
add_filter( 'bp_get_the_thread_message_content', array( &$this, 'run_shortcode' ), 7 );
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Filters the BuddyPress Core oEmbed setup.
|
59 |
+
*
|
60 |
+
* @since BuddyPress (1.5.0)
|
61 |
+
*
|
62 |
+
* @param BP_Embed $this Current instance of the BP_Embed. Passed by reference.
|
63 |
+
*/
|
64 |
+
do_action_ref_array( 'bp_core_setup_oembed', array( &$this ) );
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* The {@link do_shortcode()} callback function.
|
69 |
+
*
|
70 |
+
* Attempts to convert a URL into embed HTML. Starts by checking the
|
71 |
+
* URL against the regex of the registered embed handlers. Next, checks
|
72 |
+
* the URL against the regex of registered {@link WP_oEmbed} providers
|
73 |
+
* if oEmbed discovery is false. If none of the regex matches and it's
|
74 |
+
* enabled, then the URL will be passed to {@link BP_Embed::parse_oembed()}
|
75 |
+
* for oEmbed parsing.
|
76 |
+
*
|
77 |
+
* @uses wp_parse_args()
|
78 |
+
* @uses wp_embed_defaults()
|
79 |
+
* @uses current_user_can()
|
80 |
+
* @uses _wp_oembed_get_object()
|
81 |
+
* @uses WP_Embed::maybe_make_link()
|
82 |
+
*
|
83 |
+
* @param array $attr Shortcode attributes.
|
84 |
+
* @param string $url The URL attempting to be embeded.
|
85 |
+
* @return string The embed HTML on success, otherwise the original URL.
|
86 |
+
*/
|
87 |
+
public function shortcode( $attr, $url = '' ) {
|
88 |
+
if ( empty( $url ) )
|
89 |
+
return '';
|
90 |
+
|
91 |
+
$rawattr = $attr;
|
92 |
+
$attr = wp_parse_args( $attr, wp_embed_defaults() );
|
93 |
+
|
94 |
+
// kses converts & into & and we need to undo this
|
95 |
+
// See https://core.trac.wordpress.org/ticket/11311
|
96 |
+
$url = str_replace( '&', '&', $url );
|
97 |
+
|
98 |
+
// Look for known internal handlers
|
99 |
+
ksort( $this->handlers );
|
100 |
+
foreach ( $this->handlers as $priority => $handlers ) {
|
101 |
+
foreach ( $handlers as $hid => $handler ) {
|
102 |
+
if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) {
|
103 |
+
if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) ) {
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Filters the oEmbed handler result for the provided URL.
|
107 |
+
*
|
108 |
+
* @since BuddyPress (1.5.0)
|
109 |
+
*
|
110 |
+
* @param string $return Handler callback for the oEmbed.
|
111 |
+
* @param string $url URL attempting to be embedded.
|
112 |
+
* @param array $attr Shortcode attributes.
|
113 |
+
*/
|
114 |
+
return apply_filters( 'embed_handler_html', $return, $url, $attr );
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Filters the embed object ID.
|
122 |
+
*
|
123 |
+
* @since BuddyPress (1.5.0)
|
124 |
+
*
|
125 |
+
* @param int $value Value of zero.
|
126 |
+
*/
|
127 |
+
$id = apply_filters( 'embed_post_id', 0 );
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Filters whether or not oEmbed discovery is on.
|
131 |
+
*
|
132 |
+
* @since BuddyPress (1.5.0)
|
133 |
+
*
|
134 |
+
* @param bool $value Current status of oEmbed discovery.
|
135 |
+
*/
|
136 |
+
$attr['discover'] = ( apply_filters( 'bp_embed_oembed_discover', false ) && current_user_can( 'unfiltered_html' ) );
|
137 |
+
|
138 |
+
// Set up a new WP oEmbed object to check URL with registered oEmbed providers
|
139 |
+
require_once( ABSPATH . WPINC . '/class-oembed.php' );
|
140 |
+
$oembed_obj = _wp_oembed_get_object();
|
141 |
+
|
142 |
+
// If oEmbed discovery is true, skip oEmbed provider check
|
143 |
+
$is_oembed_link = false;
|
144 |
+
if ( !$attr['discover'] ) {
|
145 |
+
foreach ( (array) $oembed_obj->providers as $provider_matchmask => $provider ) {
|
146 |
+
$regex = ( $is_regex = $provider[1] ) ? $provider_matchmask : '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $provider_matchmask ), '#' ) ) . '#i';
|
147 |
+
|
148 |
+
if ( preg_match( $regex, $url ) )
|
149 |
+
$is_oembed_link = true;
|
150 |
+
}
|
151 |
+
|
152 |
+
// If url doesn't match a WP oEmbed provider, stop parsing
|
153 |
+
if ( !$is_oembed_link )
|
154 |
+
return $this->maybe_make_link( $url );
|
155 |
+
}
|
156 |
+
|
157 |
+
return $this->parse_oembed( $id, $url, $attr, $rawattr );
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Base function so BP components/plugins can parse links to be embedded.
|
162 |
+
*
|
163 |
+
* View an example to add support in {@link bp_activity_embed()}.
|
164 |
+
*
|
165 |
+
* @uses apply_filters() Filters cache.
|
166 |
+
* @uses do_action() To save cache.
|
167 |
+
* @uses wp_oembed_get() Connects to oEmbed provider and returns HTML
|
168 |
+
* on success.
|
169 |
+
* @uses WP_Embed::maybe_make_link() Process URL for hyperlinking on
|
170 |
+
* oEmbed failure.
|
171 |
+
*
|
172 |
+
* @param int $id ID to do the caching for.
|
173 |
+
* @param string $url The URL attempting to be embedded.
|
174 |
+
* @param array $attr Shortcode attributes from {@link WP_Embed::shortcode()}.
|
175 |
+
* @param array $rawattr Untouched shortcode attributes from
|
176 |
+
* {@link WP_Embed::shortcode()}.
|
177 |
+
* @return string The embed HTML on success, otherwise the original URL.
|
178 |
+
*/
|
179 |
+
public function parse_oembed( $id, $url, $attr, $rawattr ) {
|
180 |
+
$id = intval( $id );
|
181 |
+
|
182 |
+
if ( $id ) {
|
183 |
+
// Setup the cachekey
|
184 |
+
$cachekey = '_oembed_' . md5( $url . serialize( $attr ) );
|
185 |
+
|
186 |
+
// Let components / plugins grab their cache
|
187 |
+
$cache = '';
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Filters the cache value to be used in the oEmbed, if exists.
|
191 |
+
*
|
192 |
+
* @since BuddyPress (1.5.0)
|
193 |
+
*
|
194 |
+
* @param string $cache Empty initial cache value.
|
195 |
+
* @param int $id ID that the caching is for.
|
196 |
+
* @param string $cachekey Key to use for the caching in the database.
|
197 |
+
* @param string $url The URL attempting to be embedded.
|
198 |
+
* @param array $attr Parsed shortcode attributes.
|
199 |
+
* @param array $rawattr Unparsed shortcode attributes.
|
200 |
+
*/
|
201 |
+
$cache = apply_filters( 'bp_embed_get_cache', $cache, $id, $cachekey, $url, $attr, $rawattr );
|
202 |
+
|
203 |
+
// Grab cache and return it if available
|
204 |
+
if ( !empty( $cache ) ) {
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Filters the found cache for the provided URL.
|
208 |
+
*
|
209 |
+
* @since BuddyPress (1.5.0)
|
210 |
+
*
|
211 |
+
* @param string $cache Cached HTML markup for embed.
|
212 |
+
* @param string $url The URL being embedded.
|
213 |
+
* @param array $attr Parsed shortcode attributes.
|
214 |
+
* @param array $rawattr Unparased shortcode attributes.
|
215 |
+
*/
|
216 |
+
return apply_filters( 'bp_embed_oembed_html', $cache, $url, $attr, $rawattr );
|
217 |
+
|
218 |
+
// If no cache, ping the oEmbed provider and cache the result
|
219 |
+
} else {
|
220 |
+
$html = wp_oembed_get( $url, $attr );
|
221 |
+
$cache = ( $html ) ? $html : $url;
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Fires if there is no existing cache and triggers cache setting.
|
225 |
+
*
|
226 |
+
* Lets components / plugins save their cache.
|
227 |
+
*
|
228 |
+
* @since BuddyPress (1.5.0)
|
229 |
+
*
|
230 |
+
* @param string $cache Newly cached HTML markup for embed.
|
231 |
+
* @param string $cachekey Key to use for the caching in the database.
|
232 |
+
* @param int $id ID to do the caching for.
|
233 |
+
*/
|
234 |
+
do_action( 'bp_embed_update_cache', $cache, $cachekey, $id );
|
235 |
+
|
236 |
+
// If there was a result, return it
|
237 |
+
if ( $html ) {
|
238 |
+
|
239 |
+
/** This filter is documented in bp-core/cla
|