Version Description
= 2.1 = See: http://codex.buddypress.org/releases/version-2-1/
= 2.0.2 = See: http://codex.buddypress.org/releases/version-2-0-2/
= 2.0.1 = See: http://codex.buddypress.org/releases/version-2-0-1/
= 2.0 = See: http://codex.buddypress.org/releases/version-2-0/
= 1.9.2 = See: http://codex.buddypress.org/releases/version-1-9-2/
= 1.9.1 = See: http://codex.buddypress.org/releases/version-1-9-1/
= 1.9 = See: http://codex.buddypress.org/releases/version-1-9/
= 1.8.1 = See: http://codex.buddypress.org/releases/version-1-8-1/
= 1.8 = See: http://codex.buddypress.org/releases/version-1-8/
= 1.7.3 = See: http://codex.buddypress.org/releases/version-1-7-3/
= 1.7.2 = See: http://codex.buddypress.org/releases/version-1-7-2/
= 1.7.1 = See: http://codex.buddypress.org/releases/version-1-7-1/
= 1.7 = See: http://codex.buddypress.org/releases/version-1-7/
= 1.6.5 = See: http://codex.buddypress.org/releases/version-1-6-5/
= 1.6.4 = See: http://codex.buddypress.org/releases/version-1-6-4/
= 1.6.3 = See: http://codex.buddypress.org/releases/version-1-6-3/
= 1.6.2 = Compatibility with WordPress 3.5
= 1.6.1 = Fixes 4 bugs
= 1.6 = See: http://codex.buddypress.org/releases/version-1-6/
= 1.5 = See: http://codex.buddypress.org/releases/version-1-5/
= 1.2.9 = Compatibility with WordPress 3.2
= 1.2.8 = Compatibility with WordPress 3.1
= 1.2.7 = Fixes over 10 bugs.
Release Info
Developer | DJPaul |
Plugin | BuddyPress |
Version | 2.1-beta1 |
Comparing to | |
See all releases |
Code changes from version 2.0.2 to 2.1-beta1
- bp-activity/admin/css/admin-rtl.css +80 -0
- bp-activity/admin/css/admin-rtl.min.css +2 -0
- bp-activity/admin/css/admin.css +1 -1
- bp-activity/admin/css/admin.min.css +2 -1
- bp-activity/admin/js/admin.js +9 -8
- bp-activity/admin/js/admin.min.js +2 -1
- bp-activity/bp-activity-actions.php +27 -2
- bp-activity/bp-activity-admin.php +45 -19
- bp-activity/bp-activity-classes.php +99 -19
- bp-activity/bp-activity-cssjs.php +48 -0
- bp-activity/bp-activity-filters.php +9 -2
- bp-activity/bp-activity-functions.php +376 -279
- bp-activity/bp-activity-loader.php +16 -15
- bp-activity/bp-activity-screens.php +2 -2
- bp-activity/bp-activity-template.php +473 -147
- bp-activity/css/mentions-rtl.css +76 -0
- bp-activity/css/mentions-rtl.min.css +2 -0
- bp-activity/css/mentions.css +76 -0
- bp-activity/css/mentions.min.css +2 -0
- bp-activity/js/mentions.js +204 -0
- bp-activity/js/mentions.min.js +2 -0
- bp-blogs/bp-blogs-activity.php +114 -40
- bp-blogs/bp-blogs-buddybar.php +0 -78
- bp-blogs/bp-blogs-classes.php +13 -9
- bp-blogs/bp-blogs-filters.php +16 -0
- bp-blogs/bp-blogs-functions.php +231 -54
- bp-blogs/bp-blogs-loader.php +18 -13
- bp-blogs/bp-blogs-screens.php +2 -2
- bp-blogs/bp-blogs-template.php +142 -117
- bp-core/admin/bp-core-functions.php +42 -26
- bp-core/admin/bp-core-schema.php +211 -122
- bp-core/admin/bp-core-settings.php +0 -29
- bp-core/admin/bp-core-tools.php +42 -1
- bp-core/admin/css/common-rtl.css +432 -0
- bp-core/admin/css/common-rtl.min.css +2 -0
- bp-core/admin/css/common.css +33 -34
- bp-core/admin/css/common.min.css +2 -1
- bp-core/admin/images/icons32.png +0 -0
- bp-core/admin/images/icons64.png +0 -0
- bp-core/admin/images/menu-2x.png +0 -0
- bp-core/admin/images/menu-wp.png +0 -0
- bp-core/admin/images/menu.png +0 -0
- bp-core/bp-core-actions.php +1 -0
- bp-core/bp-core-admin.php +163 -111
- bp-core/bp-core-adminbar.php +26 -13
- bp-core/bp-core-avatars.php +16 -3
- bp-core/bp-core-buddybar.php +88 -221
- bp-core/bp-core-caps.php +27 -0
- bp-core/bp-core-catchuri.php +38 -19
- bp-core/bp-core-classes.php +335 -49
- bp-core/bp-core-component.php +38 -27
- bp-core/bp-core-cssjs.php +126 -17
- bp-core/bp-core-dependency.php +7 -0
- bp-core/bp-core-filters.php +40 -7
- bp-core/bp-core-functions.php +206 -65
- bp-core/bp-core-loader.php +3 -3
- bp-core/bp-core-options.php +23 -14
- bp-core/bp-core-template-loader.php +8 -8
- bp-core/bp-core-template.php +513 -480
- bp-core/bp-core-update.php +5 -9
- bp-core/bp-core-widgets.php +4 -5
- bp-core/css/admin-bar-rtl.css +49 -18
- bp-core/css/admin-bar-rtl.min.css +2 -1
- bp-core/css/admin-bar.css +1 -1
- bp-core/css/admin-bar.min.css +2 -1
- bp-core/css/buddybar-rtl.css +141 -15
- bp-core/css/buddybar-rtl.min.css +2 -1
- bp-core/css/buddybar.css +4 -4
- bp-core/css/buddybar.min.css +2 -1
- bp-members/bp-members-notifications.php → bp-core/deprecated/1.9.php +40 -43
- bp-core/deprecated/2.1.php +625 -0
- bp-core/deprecated/css/autocomplete/jquery.autocompletefb-rtl.css +80 -0
- bp-core/deprecated/css/autocomplete/jquery.autocompletefb-rtl.min.css +2 -0
- {bp-messages → bp-core/deprecated}/css/autocomplete/jquery.autocompletefb.css +0 -5
- bp-core/deprecated/css/autocomplete/jquery.autocompletefb.min.css +2 -0
- {bp-messages → bp-core/deprecated}/js/autocomplete/jquery.autocomplete.js +0 -0
- bp-core/deprecated/js/autocomplete/jquery.autocomplete.min.js +2 -0
- {bp-messages → bp-core/deprecated}/js/autocomplete/jquery.autocompletefb.js +0 -0
- bp-core/deprecated/js/autocomplete/jquery.autocompletefb.min.js +2 -0
- {bp-messages → bp-core/deprecated}/js/autocomplete/jquery.bgiframe.js +0 -0
- bp-core/deprecated/js/autocomplete/jquery.bgiframe.min.js +2 -0
- {bp-messages → bp-core/deprecated}/js/autocomplete/jquery.dimensions.js +0 -0
- bp-core/deprecated/js/autocomplete/jquery.dimensions.min.js +2 -0
- {bp-messages → bp-core/deprecated}/js/autocomplete/license.bgiframe.txt +0 -0
- bp-core/deprecated/js/jquery-scroll-to.js +208 -0
- bp-core/deprecated/js/jquery-scroll-to.min.js +2 -0
- bp-core/images/60pc_black.png +0 -0
- bp-core/images/Jcrop.gif +0 -0
- bp-core/images/admin-menu-arrow.gif +0 -0
- bp-core/images/bp20/admin-xprofile.jpg +0 -0
- bp-core/images/bp20/load-newest.jpg +0 -0
- bp-core/images/bp20/performance.png +0 -0
- bp-core/images/bp20/tools-buddypress.jpg +0 -0
- bp-core/images/bp20/user-mark-spam.jpg +0 -0
- bp-core/images/bp20/users-pending.jpg +0 -0
- bp-core/images/mystery-man-50.jpg +0 -0
- bp-core/images/mystery-man.jpg +0 -0
- bp-core/js/confirm.js +8 -3
- bp-core/js/confirm.min.js +2 -1
- bp-core/js/jquery-cookie.js +120 -0
- bp-core/js/jquery-cookie.min.js +2 -0
- bp-core/js/jquery-query.js +6 -0
- bp-core/js/jquery-query.min.js +2 -0
- bp-core/js/jquery.atwho.js +824 -0
- bp-core/js/jquery.atwho.min.js +2 -0
- bp-core/js/jquery.atwho.txt +22 -0
- bp-core/js/jquery.caret.js +366 -0
- bp-core/js/jquery.caret.min.js +2 -0
- bp-core/js/jquery.caret.txt +22 -0
- bp-core/js/widget-members.js +11 -11
- bp-core/js/widget-members.min.js +2 -1
- bp-forums/bp-forums-screens.php +1 -1
- bp-forums/bp-forums-template.php +2 -2
- bp-friends/bp-friends-activity.php +6 -2
- bp-friends/bp-friends-classes.php +17 -11
- bp-friends/bp-friends-filters.php +8 -1
- bp-friends/bp-friends-functions.php +54 -1
- bp-friends/bp-friends-loader.php +9 -9
- bp-friends/bp-friends-screens.php +3 -3
- bp-friends/bp-friends-template.php +4 -9
- bp-friends/bp-friends-widgets.php +7 -0
- bp-friends/js/widget-friends.js +12 -12
- bp-friends/js/widget-friends.min.js +2 -1
- bp-groups/admin/css/admin-rtl.css +86 -0
- bp-groups/admin/css/admin-rtl.min.css +2 -0
- bp-groups/admin/css/admin.css +33 -3
- bp-groups/admin/css/admin.min.css +2 -1
- bp-groups/admin/js/admin.js +24 -12
- bp-groups/admin/js/admin.min.js +2 -1
- bp-groups/bp-groups-actions.php +79 -2
- bp-groups/bp-groups-activity.php +26 -6
- bp-groups/bp-groups-admin.php +115 -104
- bp-groups/bp-groups-adminbar.php +2 -2
- bp-groups/bp-groups-buddybar.php +0 -67
- bp-groups/bp-groups-cache.php +29 -0
- bp-groups/bp-groups-classes.php +530 -57
- bp-groups/bp-groups-filters.php +48 -22
- bp-groups/bp-groups-forums.php +174 -147
- bp-groups/bp-groups-functions.php +1 -1
- bp-groups/bp-groups-loader.php +72 -99
- bp-groups/bp-groups-notifications.php +129 -68
- bp-groups/bp-groups-screens.php +24 -24
- bp-groups/bp-groups-template.php +415 -138
- bp-groups/bp-groups-widgets.php +11 -2
- bp-groups/js/widget-groups.js +11 -11
- bp-groups/js/widget-groups.min.js +2 -1
- bp-loader.php +33 -34
- bp-members/admin/bp-members-classes.php +78 -56
- bp-members/admin/css/admin-rtl.css +160 -0
- bp-members/admin/css/admin-rtl.min.css +2 -0
- bp-members/admin/css/admin.css +21 -40
- bp-members/admin/css/admin.min.css +2 -1
- bp-members/admin/js/admin.js +3 -1
- bp-members/admin/js/admin.min.js +2 -1
- bp-members/bp-members-actions.php +9 -8
- bp-members/bp-members-admin.php +625 -255
- bp-members/bp-members-adminbar.php +11 -12
- bp-members/bp-members-buddybar.php +0 -116
- bp-members/bp-members-classes.php +9 -10
- bp-members/bp-members-filters.php +50 -12
- bp-members/bp-members-functions.php +380 -211
- bp-members/bp-members-loader.php +111 -75
- bp-members/bp-members-screens.php +48 -52
- bp-members/bp-members-template.php +356 -120
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.akismet-status {
|
2 |
+
float: left;
|
3 |
+
}
|
4 |
+
.akismet-status a {
|
5 |
+
color: #AAA;
|
6 |
+
font-style: italic;
|
7 |
+
}
|
8 |
+
.akismet-history {
|
9 |
+
margin: 13px;
|
10 |
+
}
|
11 |
+
.akismet-history div {
|
12 |
+
margin-bottom: 13px;
|
13 |
+
}
|
14 |
+
.akismet-history span {
|
15 |
+
color: #999;
|
16 |
+
}
|
17 |
+
|
18 |
+
#wp-bp-activities-wrap {
|
19 |
+
padding: 5px 0;
|
20 |
+
}
|
21 |
+
#bp-activities {
|
22 |
+
height: 120px;
|
23 |
+
}
|
24 |
+
#bp-replyhead {
|
25 |
+
font-size: 1em;
|
26 |
+
line-height: 1.4em;
|
27 |
+
margin: 0;
|
28 |
+
}
|
29 |
+
#bp-replysubmit {
|
30 |
+
margin: 0;
|
31 |
+
padding: 0 0 3px;
|
32 |
+
text-align: center;
|
33 |
+
}
|
34 |
+
#bp-replysubmit .error {
|
35 |
+
color: red;
|
36 |
+
line-height: 21px;
|
37 |
+
text-align: center;
|
38 |
+
vertical-align: center;
|
39 |
+
}
|
40 |
+
#bp-replysubmit img.waiting {
|
41 |
+
float: left;
|
42 |
+
padding: 4px 10px 0;
|
43 |
+
vertical-align: top;
|
44 |
+
}
|
45 |
+
#bp-activities-form .column-response img {
|
46 |
+
float: right;
|
47 |
+
margin-left: 10px;
|
48 |
+
margin-top: 1px;
|
49 |
+
}
|
50 |
+
.activity-errors {
|
51 |
+
list-style-type: disc;
|
52 |
+
margin-right: 2em;
|
53 |
+
}
|
54 |
+
|
55 |
+
#bp_activity_action div.inside,
|
56 |
+
#bp_activity_content div.inside {
|
57 |
+
line-height: 0;
|
58 |
+
}
|
59 |
+
#bp_activity_action h3,
|
60 |
+
#bp_activity_content h3 {
|
61 |
+
cursor: auto;
|
62 |
+
}
|
63 |
+
#bp_activity_action td.mceIframeContainer,
|
64 |
+
#bp_activity_content td.mceIframeContainer {
|
65 |
+
background-color: white;
|
66 |
+
}
|
67 |
+
#post-body #bp-activities-action_resize,
|
68 |
+
#post-body #bp-activities-content_resize {
|
69 |
+
position: inherit;
|
70 |
+
margin-top: -2px;
|
71 |
+
}
|
72 |
+
#bp_activity_link input {
|
73 |
+
width: 99%;
|
74 |
+
}
|
75 |
+
#bp-activities-primaryid {
|
76 |
+
margin-bottom: 1em;
|
77 |
+
}
|
78 |
+
.column-action {
|
79 |
+
width: 12%;
|
80 |
+
}
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
.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%}
|
@@ -77,4 +77,4 @@
|
|
77 |
}
|
78 |
.column-action {
|
79 |
width: 12%;
|
80 |
-
}
|
77 |
}
|
78 |
.column-action {
|
79 |
width: 12%;
|
80 |
+
}
|
@@ -1 +1,2 @@
|
|
1 |
-
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
.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,3 +1,4 @@
|
|
|
|
1 |
(function( $ ) {
|
2 |
|
3 |
/**
|
@@ -19,7 +20,7 @@ var activityReply = {
|
|
19 |
|
20 |
// Close textarea on escape
|
21 |
$(document).on( 'keyup', '#bp-activities:visible', function( e ) {
|
22 |
-
if ( 27
|
23 |
activityReply.close();
|
24 |
}
|
25 |
});
|
@@ -30,7 +31,7 @@ var activityReply = {
|
|
30 |
*
|
31 |
* @since BuddyPress (1.6)
|
32 |
*/
|
33 |
-
open : function(
|
34 |
// Hide the container row, and move it to the new location
|
35 |
var box = $( '#bp-activities-container' ).hide();
|
36 |
$( this ).parents( 'tr' ).after( box );
|
@@ -47,9 +48,9 @@ var activityReply = {
|
|
47 |
*
|
48 |
* @since BuddyPress (1.6)
|
49 |
*/
|
50 |
-
close : function(
|
51 |
// Hide the container row
|
52 |
-
$('#bp-activities-container').fadeOut( '200', function () {
|
53 |
|
54 |
// Empty and unfocus the text area
|
55 |
$( '#bp-activities' ).val( '' ).blur();
|
@@ -67,7 +68,7 @@ var activityReply = {
|
|
67 |
*
|
68 |
* @since BuddyPress (1.6)
|
69 |
*/
|
70 |
-
send : function(
|
71 |
// Hide any existing error message, and show the loading spinner
|
72 |
$( '#bp-replysubmit .error' ).hide();
|
73 |
$( '#bp-replysubmit .waiting' ).show();
|
@@ -123,7 +124,7 @@ var activityReply = {
|
|
123 |
var bg, id, response;
|
124 |
|
125 |
// Handle any errors in the response
|
126 |
-
if ( typeof( xml )
|
127 |
activityReply.error( { 'responseText': xml } );
|
128 |
return false;
|
129 |
}
|
@@ -136,7 +137,7 @@ var activityReply = {
|
|
136 |
response = response.responses[0];
|
137 |
|
138 |
// Close and reset the reply row, and add the new Activity item into the list.
|
139 |
-
$('#bp-activities-container').fadeOut( '200', function () {
|
140 |
|
141 |
// Empty and unfocus the text area
|
142 |
$( '#bp-activities' ).val( '' ).blur();
|
@@ -169,4 +170,4 @@ $(document).ready( function () {
|
|
169 |
postboxes.add_postbox_toggles( bp_activity_admin_vars.page );
|
170 |
});
|
171 |
|
172 |
-
})(jQuery);
|
1 |
+
/* global bp_activity_admin_vars, postboxes, wpAjax */
|
2 |
(function( $ ) {
|
3 |
|
4 |
/**
|
20 |
|
21 |
// Close textarea on escape
|
22 |
$(document).on( 'keyup', '#bp-activities:visible', function( e ) {
|
23 |
+
if ( 27 === e.which ) {
|
24 |
activityReply.close();
|
25 |
}
|
26 |
});
|
31 |
*
|
32 |
* @since BuddyPress (1.6)
|
33 |
*/
|
34 |
+
open : function() {
|
35 |
// Hide the container row, and move it to the new location
|
36 |
var box = $( '#bp-activities-container' ).hide();
|
37 |
$( this ).parents( 'tr' ).after( box );
|
48 |
*
|
49 |
* @since BuddyPress (1.6)
|
50 |
*/
|
51 |
+
close : function() {
|
52 |
// Hide the container row
|
53 |
+
$('#bp-activities-container').fadeOut( '200', function () {
|
54 |
|
55 |
// Empty and unfocus the text area
|
56 |
$( '#bp-activities' ).val( '' ).blur();
|
68 |
*
|
69 |
* @since BuddyPress (1.6)
|
70 |
*/
|
71 |
+
send : function() {
|
72 |
// Hide any existing error message, and show the loading spinner
|
73 |
$( '#bp-replysubmit .error' ).hide();
|
74 |
$( '#bp-replysubmit .waiting' ).show();
|
124 |
var bg, id, response;
|
125 |
|
126 |
// Handle any errors in the response
|
127 |
+
if ( typeof( xml ) === 'string' ) {
|
128 |
activityReply.error( { 'responseText': xml } );
|
129 |
return false;
|
130 |
}
|
137 |
response = response.responses[0];
|
138 |
|
139 |
// Close and reset the reply row, and add the new Activity item into the list.
|
140 |
+
$('#bp-activities-container').fadeOut( '200', function () {
|
141 |
|
142 |
// Empty and unfocus the text area
|
143 |
$( '#bp-activities' ).val( '' ).blur();
|
170 |
postboxes.add_postbox_toggles( bp_activity_admin_vars.page );
|
171 |
});
|
172 |
|
173 |
+
})(jQuery);
|
@@ -1 +1,2 @@
|
|
1 |
-
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
!function(a){var b={init:function(){a(document).on("click",".row-actions a.reply",b.open),a(document).on("click","#bp-activities-container a.cancel",b.close),a(document).on("click","#bp-activities-container a.save",b.send),a(document).on("keyup","#bp-activities:visible",function(a){27===a.which&&b.close()})},open:function(){var b=a("#bp-activities-container").hide();return a(this).parents("tr").after(b),b.fadeIn("300"),a("#bp-activities").focus(),!1},close:function(){return a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide()}),!1},send:function(){a("#bp-replysubmit .error").hide(),a("#bp-replysubmit .waiting").show();var c={};return c["_ajax_nonce-bp-activity-admin-reply"]=a('#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]').val(),c.action="bp-activity-admin-reply",c.content=a("#bp-activities").val(),c.parent_id=a("#bp-activities-container").prev().data("parent_id"),c.root_id=a("#bp-activities-container").prev().data("root_id"),a.ajax({data:c,type:"POST",url:ajaxurl,error:function(a){b.error(a)},success:function(a){b.show(a)}}),!1},error:function(b){var c=b.statusText;a("#bp-replysubmit .waiting").hide(),b.responseText&&(c=b.responseText.replace(/<.[^<>]*?>/g,"")),c&&a("#bp-replysubmit .error").html(c).show()},show:function(c){var d,e,f;return"string"==typeof c?(b.error({responseText:c}),!1):(f=wpAjax.parseAjaxResponse(c),f.errors?(b.error({responseText:wpAjax.broken}),!1):(f=f.responses[0],void a("#bp-activities-container").fadeOut("200",function(){a("#bp-activities").val("").blur(),a("#bp-replysubmit .error").html("").hide(),a("#bp-replysubmit .waiting").hide(),a("#bp-activities-container").before(f.data),e=a("#activity-"+f.id),d=e.closest(".widefat").css("backgroundColor"),e.animate({backgroundColor:"#CEB"},300).animate({backgroundColor:d},300)})))}};a(document).ready(function(){b.init(),a("#bp_activity_action h3, #bp_activity_content h3").unbind("click"),postboxes.add_postbox_toggles(bp_activity_admin_vars.page)})}(jQuery);
|
@@ -437,7 +437,7 @@ function bp_activity_action_sitewide_feed() {
|
|
437 |
'id' => 'sitewide',
|
438 |
|
439 |
/* translators: Sitewide activity RSS title - "[Site Name] | Site Wide Activity" */
|
440 |
-
'title' => sprintf( __( '%s | Site
|
441 |
|
442 |
'link' => bp_get_activity_directory_permalink(),
|
443 |
'description' => __( 'Activity feed for the entire site.', 'buddypress' ),
|
@@ -540,7 +540,7 @@ function bp_activity_action_my_groups_feed() {
|
|
540 |
'title' => sprintf( __( '%1$s | %2$s | Group Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
|
541 |
|
542 |
'link' => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() ),
|
543 |
-
'description' => sprintf( __( "Public group activity feed of which %s is a member
|
544 |
'activity_args' => array(
|
545 |
'object' => buddypress()->groups->id,
|
546 |
'primary_id' => $group_ids,
|
@@ -647,3 +647,28 @@ function bp_activity_setup_akismet() {
|
|
647 |
// Instantiate Akismet for BuddyPress
|
648 |
$bp->activity->akismet = new BP_Akismet();
|
649 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
437 |
'id' => 'sitewide',
|
438 |
|
439 |
/* translators: Sitewide activity RSS title - "[Site Name] | Site Wide Activity" */
|
440 |
+
'title' => sprintf( __( '%s | Site-Wide Activity', 'buddypress' ), bp_get_site_name() ),
|
441 |
|
442 |
'link' => bp_get_activity_directory_permalink(),
|
443 |
'description' => __( 'Activity feed for the entire site.', 'buddypress' ),
|
540 |
'title' => sprintf( __( '%1$s | %2$s | Group Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
|
541 |
|
542 |
'link' => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() ),
|
543 |
+
'description' => sprintf( __( "Public group activity feed of which %s is a member.", 'buddypress' ), bp_get_displayed_user_fullname() ),
|
544 |
'activity_args' => array(
|
545 |
'object' => buddypress()->groups->id,
|
546 |
'primary_id' => $group_ids,
|
647 |
// Instantiate Akismet for BuddyPress
|
648 |
$bp->activity->akismet = new BP_Akismet();
|
649 |
}
|
650 |
+
|
651 |
+
/**
|
652 |
+
* AJAX endpoint for Suggestions API lookups.
|
653 |
+
*
|
654 |
+
* @since BuddyPress (2.1.0)
|
655 |
+
*/
|
656 |
+
function bp_ajax_get_suggestions() {
|
657 |
+
if ( ! bp_is_user_active() || empty( $_GET['term'] ) || empty( $_GET['type'] ) ) {
|
658 |
+
wp_send_json_error( 'missing_parameter' );
|
659 |
+
exit;
|
660 |
+
}
|
661 |
+
|
662 |
+
$results = bp_core_get_suggestions( array(
|
663 |
+
'term' => sanitize_text_field( $_GET['term'] ),
|
664 |
+
'type' => sanitize_text_field( $_GET['type'] ),
|
665 |
+
) );
|
666 |
+
|
667 |
+
if ( is_wp_error( $results ) ) {
|
668 |
+
wp_send_json_error( $results->get_error_message() );
|
669 |
+
exit;
|
670 |
+
}
|
671 |
+
|
672 |
+
wp_send_json_success( $results );
|
673 |
+
}
|
674 |
+
add_action( 'wp_ajax_bp_get_suggestions', 'bp_ajax_get_suggestions' );
|
@@ -29,8 +29,8 @@ function bp_activity_add_admin_menu() {
|
|
29 |
|
30 |
// Add our screen
|
31 |
$hook = add_menu_page(
|
32 |
-
|
33 |
-
|
34 |
'bp_moderate',
|
35 |
'bp-activity',
|
36 |
'bp_activity_admin',
|
@@ -220,7 +220,7 @@ function bp_activity_admin_load() {
|
|
220 |
'title' => __( 'Item, Link, Type', 'buddypress' ),
|
221 |
'content' =>
|
222 |
'<p>' . __( '<strong>Primary Item/Secondary Item</strong> - These identify the object that created the activity. For example, the fields could reference a comment left on a specific site. Some types of activity may only use one, or none, of these fields.', 'buddypress' ) . '</p>' .
|
223 |
-
'<p>' . __( '<strong>Link</strong> -
|
224 |
'<p>' . __( '<strong>Type</strong> - Each distinct kind of activity has its own type. For example, <code>created_group</code> is used when a group is created and <code>joined_group</code> is used when a user joins a group.', 'buddypress' ) . '</p>' .
|
225 |
'<p>' . __( 'For information about when and how BuddyPress uses all of these settings, see the Managing Activity link in the panel to the side.', 'buddypress' ) . '</p>'
|
226 |
) );
|
@@ -284,6 +284,12 @@ function bp_activity_admin_load() {
|
|
284 |
) );
|
285 |
wp_enqueue_style( 'bp_activity_admin_css', $bp->plugin_url . "bp-activity/admin/css/admin.{$min}css", array(), bp_get_version() );
|
286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
// Handle spam/un-spam/delete of activities
|
288 |
if ( !empty( $doaction ) && ! in_array( $doaction, array( '-1', 'edit', 'save', ) ) ) {
|
289 |
|
@@ -903,7 +909,7 @@ function bp_activity_admin_index() {
|
|
903 |
<?php if ( !empty( $_REQUEST['aid'] ) ) : ?>
|
904 |
<?php printf( __( 'Activity related to ID #%s', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?>
|
905 |
<?php else : ?>
|
906 |
-
<?php
|
907 |
<?php endif; ?>
|
908 |
|
909 |
<?php if ( !empty( $_REQUEST['s'] ) ) : ?>
|
@@ -1057,6 +1063,7 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1057 |
'display_comments' => 'stream',
|
1058 |
'show_hidden' => true,
|
1059 |
'spam' => 'spam_only',
|
|
|
1060 |
) );
|
1061 |
$this->spam_count = $spams['total'];
|
1062 |
unset( $spams );
|
@@ -1072,6 +1079,7 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1072 |
'show_hidden' => true,
|
1073 |
//'sort' => $sort,
|
1074 |
'spam' => $spam,
|
|
|
1075 |
) );
|
1076 |
|
1077 |
// If we're viewing a specific activity, flatten all activites into a single array.
|
@@ -1138,8 +1146,6 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1138 |
* @since BuddyPress (1.6.0)
|
1139 |
*/
|
1140 |
function display() {
|
1141 |
-
extract( $this->_args );
|
1142 |
-
|
1143 |
$this->display_tablenav( 'top' ); ?>
|
1144 |
|
1145 |
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
|
@@ -1238,10 +1244,10 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1238 |
function get_columns() {
|
1239 |
return array(
|
1240 |
'cb' => '<input name type="checkbox" />',
|
1241 |
-
'author' =>
|
1242 |
-
'comment' =>
|
1243 |
-
'action' =>
|
1244 |
-
'response' =>
|
1245 |
);
|
1246 |
}
|
1247 |
|
@@ -1272,23 +1278,43 @@ class BP_Activity_List_Table extends WP_List_Table {
|
|
1272 |
* @param string $which 'top' or 'bottom'.
|
1273 |
*/
|
1274 |
function extra_tablenav( $which ) {
|
1275 |
-
|
|
|
|
|
1276 |
return;
|
|
|
1277 |
|
1278 |
-
|
|
|
1279 |
|
1280 |
-
// Get
|
1281 |
-
$
|
1282 |
-
natsort( $actions );
|
1283 |
-
?>
|
1284 |
|
1285 |
<div class="alignleft actions">
|
1286 |
<select name="activity_type">
|
1287 |
-
<option value="" <?php selected(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1288 |
|
1289 |
-
<?php foreach ( $actions as $k => $v ) : ?>
|
1290 |
-
<option value="<?php echo esc_attr( $k ); ?>" <?php selected( $k, $selected ); ?>><?php echo esc_html( $v ); ?></option>
|
1291 |
<?php endforeach; ?>
|
|
|
1292 |
</select>
|
1293 |
|
1294 |
<?php submit_button( __( 'Filter', 'buddypress' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) ); ?>
|
29 |
|
30 |
// Add our screen
|
31 |
$hook = add_menu_page(
|
32 |
+
_x( 'Activity', 'Admin Dashbord SWA page title', 'buddypress' ),
|
33 |
+
_x( 'Activity', 'Admin Dashbord SWA menu', 'buddypress' ),
|
34 |
'bp_moderate',
|
35 |
'bp-activity',
|
36 |
'bp_activity_admin',
|
220 |
'title' => __( 'Item, Link, Type', 'buddypress' ),
|
221 |
'content' =>
|
222 |
'<p>' . __( '<strong>Primary Item/Secondary Item</strong> - These identify the object that created the activity. For example, the fields could reference a comment left on a specific site. Some types of activity may only use one, or none, of these fields.', 'buddypress' ) . '</p>' .
|
223 |
+
'<p>' . __( '<strong>Link</strong> - Used by some types of activity (e.g blog posts and comments, and forum topics and replies) to store a link back to the original content.', 'buddypress' ) . '</p>' .
|
224 |
'<p>' . __( '<strong>Type</strong> - Each distinct kind of activity has its own type. For example, <code>created_group</code> is used when a group is created and <code>joined_group</code> is used when a user joins a group.', 'buddypress' ) . '</p>' .
|
225 |
'<p>' . __( 'For information about when and how BuddyPress uses all of these settings, see the Managing Activity link in the panel to the side.', 'buddypress' ) . '</p>'
|
226 |
) );
|
284 |
) );
|
285 |
wp_enqueue_style( 'bp_activity_admin_css', $bp->plugin_url . "bp-activity/admin/css/admin.{$min}css", array(), bp_get_version() );
|
286 |
|
287 |
+
wp_style_add_data( 'bp_activity_admin_css', 'rtl', true );
|
288 |
+
if ( $min ) {
|
289 |
+
wp_style_add_data( 'bp_activity_admin_css', 'suffix', $min );
|
290 |
+
}
|
291 |
+
|
292 |
+
|
293 |
// Handle spam/un-spam/delete of activities
|
294 |
if ( !empty( $doaction ) && ! in_array( $doaction, array( '-1', 'edit', 'save', ) ) ) {
|
295 |
|
909 |
<?php if ( !empty( $_REQUEST['aid'] ) ) : ?>
|
910 |
<?php printf( __( 'Activity related to ID #%s', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?>
|
911 |
<?php else : ?>
|
912 |
+
<?php _ex( 'Activity', 'Admin SWA page', 'buddypress' ); ?>
|
913 |
<?php endif; ?>
|
914 |
|
915 |
<?php if ( !empty( $_REQUEST['s'] ) ) : ?>
|
1063 |
'display_comments' => 'stream',
|
1064 |
'show_hidden' => true,
|
1065 |
'spam' => 'spam_only',
|
1066 |
+
'count_total' => 'count_query',
|
1067 |
) );
|
1068 |
$this->spam_count = $spams['total'];
|
1069 |
unset( $spams );
|
1079 |
'show_hidden' => true,
|
1080 |
//'sort' => $sort,
|
1081 |
'spam' => $spam,
|
1082 |
+
'count_total' => 'count_query',
|
1083 |
) );
|
1084 |
|
1085 |
// If we're viewing a specific activity, flatten all activites into a single array.
|
1146 |
* @since BuddyPress (1.6.0)
|
1147 |
*/
|
1148 |
function display() {
|
|
|
|
|
1149 |
$this->display_tablenav( 'top' ); ?>
|
1150 |
|
1151 |
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
|
1244 |
function get_columns() {
|
1245 |
return array(
|
1246 |
'cb' => '<input name type="checkbox" />',
|
1247 |
+
'author' => _x('Author', 'Admin SWA column header', 'buddypress' ),
|
1248 |
+
'comment' => _x( 'Activity', 'Admin SWA column header', 'buddypress' ),
|
1249 |
+
'action' => _x( 'Action', 'Admin SWA column header', 'buddypress' ),
|
1250 |
+
'response' => _x( 'In Response To', 'Admin SWA column header', 'buddypress' ),
|
1251 |
);
|
1252 |
}
|
1253 |
|
1278 |
* @param string $which 'top' or 'bottom'.
|
1279 |
*/
|
1280 |
function extra_tablenav( $which ) {
|
1281 |
+
|
1282 |
+
// Bail on bottom table nav
|
1283 |
+
if ( 'bottom' === $which ) {
|
1284 |
return;
|
1285 |
+
}
|
1286 |
|
1287 |
+
// Is any filter currently selected?
|
1288 |
+
$selected = ( ! empty( $_REQUEST['activity_type'] ) ) ? $_REQUEST['activity_type'] : '';
|
1289 |
|
1290 |
+
// Get the actions
|
1291 |
+
$activity_actions = buddypress()->activity->actions; ?>
|
|
|
|
|
1292 |
|
1293 |
<div class="alignleft actions">
|
1294 |
<select name="activity_type">
|
1295 |
+
<option value="" <?php selected( ! $selected ); ?>><?php _e( 'View all actions', 'buddypress' ); ?></option>
|
1296 |
+
|
1297 |
+
<?php foreach ( $activity_actions as $component => $actions ) : ?>
|
1298 |
+
|
1299 |
+
<optgroup label="<?php echo ucfirst( $component ); ?>">
|
1300 |
+
|
1301 |
+
<?php foreach ( $actions as $action_key => $action_values ) : ?>
|
1302 |
+
|
1303 |
+
<?php
|
1304 |
+
|
1305 |
+
// Skip the incorrectly named pre-1.6 action
|
1306 |
+
if ( 'friends_register_activity_action' !== $action_key ) : ?>
|
1307 |
+
|
1308 |
+
<option value="<?php echo esc_attr( $action_key ); ?>" <?php selected( $action_key, $selected ); ?>><?php echo esc_html( $action_values[ 'value' ] ); ?></option>
|
1309 |
+
|
1310 |
+
<?php endif; ?>
|
1311 |
+
|
1312 |
+
<?php endforeach; ?>
|
1313 |
+
|
1314 |
+
</optgroup>
|
1315 |
|
|
|
|
|
1316 |
<?php endforeach; ?>
|
1317 |
+
|
1318 |
</select>
|
1319 |
|
1320 |
<?php submit_button( __( 'Filter', 'buddypress' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) ); ?>
|
@@ -146,10 +146,10 @@ class BP_Activity_Activity {
|
|
146 |
}
|
147 |
|
148 |
if ( ! empty( $row ) ) {
|
149 |
-
$this->id = $row->id;
|
150 |
-
$this->item_id = $row->item_id;
|
151 |
-
$this->secondary_item_id = $row->secondary_item_id;
|
152 |
-
$this->user_id = $row->user_id;
|
153 |
$this->primary_link = $row->primary_link;
|
154 |
$this->component = $row->component;
|
155 |
$this->type = $row->type;
|
@@ -157,8 +157,8 @@ class BP_Activity_Activity {
|
|
157 |
$this->content = $row->content;
|
158 |
$this->date_recorded = $row->date_recorded;
|
159 |
$this->hide_sitewide = $row->hide_sitewide;
|
160 |
-
$this->mptt_left = $row->mptt_left;
|
161 |
-
$this->mptt_right = $row->mptt_right;
|
162 |
$this->is_spam = $row->is_spam;
|
163 |
}
|
164 |
|
@@ -257,6 +257,9 @@ class BP_Activity_Activity {
|
|
257 |
* Default: false.
|
258 |
* @type array $meta_query An array of meta_query conditions.
|
259 |
* See WP_Meta_Query::queries for description.
|
|
|
|
|
|
|
260 |
* @type array $filter See BP_Activity_Activity::get_filter_sql().
|
261 |
* @type string $search_terms Limit results by a search term.
|
262 |
* Default: false.
|
@@ -267,6 +270,9 @@ class BP_Activity_Activity {
|
|
267 |
* @type string $spam Spam status. Default: 'ham_only'.
|
268 |
* @type bool $update_meta_cache Whether to pre-fetch metadata for
|
269 |
* queried activity items. Default: true.
|
|
|
|
|
|
|
270 |
* }
|
271 |
* @return array The array returned has two keys:
|
272 |
* - 'total' is the count of located activities
|
@@ -305,12 +311,14 @@ class BP_Activity_Activity {
|
|
305 |
'exclude' => false, // Array of ids to exclude
|
306 |
'in' => false, // Array of ids to limit query by (IN)
|
307 |
'meta_query' => false, // Filter by activitymeta
|
|
|
308 |
'filter' => false, // See self::get_filter_sql()
|
309 |
'search_terms' => false, // Terms to search by
|
310 |
'display_comments' => false, // Whether to include activity comments
|
311 |
'show_hidden' => false, // Show items marked hide_sitewide
|
312 |
'spam' => 'ham_only', // Spam status
|
313 |
'update_meta_cache' => true,
|
|
|
314 |
);
|
315 |
$r = wp_parse_args( $args, $defaults );
|
316 |
extract( $r );
|
@@ -325,6 +333,9 @@ class BP_Activity_Activity {
|
|
325 |
// Where conditions
|
326 |
$where_conditions = array();
|
327 |
|
|
|
|
|
|
|
328 |
// Spam
|
329 |
if ( 'ham_only' == $spam )
|
330 |
$where_conditions['spam_sql'] = 'a.is_spam = 0';
|
@@ -333,8 +344,8 @@ class BP_Activity_Activity {
|
|
333 |
|
334 |
// Searching
|
335 |
if ( $search_terms ) {
|
336 |
-
$
|
337 |
-
$where_conditions['search_sql'] =
|
338 |
}
|
339 |
|
340 |
// Filtering
|
@@ -372,17 +383,35 @@ class BP_Activity_Activity {
|
|
372 |
$where_conditions[] = $meta_query_sql['where'];
|
373 |
}
|
374 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
// Alter the query based on whether we want to show activity item
|
376 |
// comments in the stream like normal comments or threaded below
|
377 |
// the activity.
|
378 |
if ( false === $display_comments || 'threaded' === $display_comments ) {
|
379 |
-
$
|
380 |
}
|
381 |
|
382 |
// Exclude 'last_activity' items unless the 'action' filter has
|
383 |
// been explicitly set
|
384 |
if ( empty( $filter['object'] ) ) {
|
385 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
386 |
}
|
387 |
|
388 |
// Filter the where conditions
|
@@ -411,6 +440,12 @@ class BP_Activity_Activity {
|
|
411 |
$page = absint( $page );
|
412 |
$per_page = absint( $per_page );
|
413 |
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
// Filter and return true to use the legacy query structure (not recommended)
|
415 |
if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) {
|
416 |
|
@@ -431,17 +466,25 @@ class BP_Activity_Activity {
|
|
431 |
$activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
|
432 |
|
433 |
if ( ! empty( $per_page ) && ! empty( $page ) ) {
|
434 |
-
|
|
|
|
|
435 |
}
|
436 |
|
437 |
$activity_ids_sql = apply_filters( 'bp_activity_paged_activities_sql', $activity_ids_sql, $r );
|
438 |
|
439 |
$activity_ids = $wpdb->get_col( $activity_ids_sql );
|
440 |
-
$activities = self::get_activity_data( $activity_ids );
|
441 |
-
}
|
442 |
|
443 |
-
|
444 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
445 |
|
446 |
// Get the fullnames of users so we don't have to query in the loop
|
447 |
$activities = self::append_user_fullnames( $activities );
|
@@ -465,13 +508,23 @@ class BP_Activity_Activity {
|
|
465 |
// Generate action strings
|
466 |
$activities = BP_Activity_Activity::generate_action_strings( $activities );
|
467 |
|
|
|
|
|
468 |
// If $max is set, only return up to the max results
|
469 |
-
if ( !empty( $
|
470 |
-
|
471 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
472 |
}
|
473 |
|
474 |
-
return
|
475 |
}
|
476 |
|
477 |
/**
|
@@ -656,6 +709,33 @@ class BP_Activity_Activity {
|
|
656 |
return $sql_array;
|
657 |
}
|
658 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
659 |
/**
|
660 |
* In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
|
661 |
*
|
146 |
}
|
147 |
|
148 |
if ( ! empty( $row ) ) {
|
149 |
+
$this->id = (int) $row->id;
|
150 |
+
$this->item_id = (int) $row->item_id;
|
151 |
+
$this->secondary_item_id = (int) $row->secondary_item_id;
|
152 |
+
$this->user_id = (int) $row->user_id;
|
153 |
$this->primary_link = $row->primary_link;
|
154 |
$this->component = $row->component;
|
155 |
$this->type = $row->type;
|
157 |
$this->content = $row->content;
|
158 |
$this->date_recorded = $row->date_recorded;
|
159 |
$this->hide_sitewide = $row->hide_sitewide;
|
160 |
+
$this->mptt_left = (int) $row->mptt_left;
|
161 |
+
$this->mptt_right = (int) $row->mptt_right;
|
162 |
$this->is_spam = $row->is_spam;
|
163 |
}
|
164 |
|
257 |
* Default: false.
|
258 |
* @type array $meta_query An array of meta_query conditions.
|
259 |
* See WP_Meta_Query::queries for description.
|
260 |
+
* @type array $date_query An array of date_query conditions.
|
261 |
+
* See first parameter of WP_Date_Query::__construct()
|
262 |
+
* for description.
|
263 |
* @type array $filter See BP_Activity_Activity::get_filter_sql().
|
264 |
* @type string $search_terms Limit results by a search term.
|
265 |
* Default: false.
|
270 |
* @type string $spam Spam status. Default: 'ham_only'.
|
271 |
* @type bool $update_meta_cache Whether to pre-fetch metadata for
|
272 |
* queried activity items. Default: true.
|
273 |
+
* @type string|bool $count_total If true, an additional DB query
|
274 |
+
* is run to count the total activity items for the query.
|
275 |
+
* Default: false.
|
276 |
* }
|
277 |
* @return array The array returned has two keys:
|
278 |
* - 'total' is the count of located activities
|
311 |
'exclude' => false, // Array of ids to exclude
|
312 |
'in' => false, // Array of ids to limit query by (IN)
|
313 |
'meta_query' => false, // Filter by activitymeta
|
314 |
+
'date_query' => false, // Filter by date
|
315 |
'filter' => false, // See self::get_filter_sql()
|
316 |
'search_terms' => false, // Terms to search by
|
317 |
'display_comments' => false, // Whether to include activity comments
|
318 |
'show_hidden' => false, // Show items marked hide_sitewide
|
319 |
'spam' => 'ham_only', // Spam status
|
320 |
'update_meta_cache' => true,
|
321 |
+
'count_total' => false,
|
322 |
);
|
323 |
$r = wp_parse_args( $args, $defaults );
|
324 |
extract( $r );
|
333 |
// Where conditions
|
334 |
$where_conditions = array();
|
335 |
|
336 |
+
// Excluded types
|
337 |
+
$excluded_types = array();
|
338 |
+
|
339 |
// Spam
|
340 |
if ( 'ham_only' == $spam )
|
341 |
$where_conditions['spam_sql'] = 'a.is_spam = 0';
|
344 |
|
345 |
// Searching
|
346 |
if ( $search_terms ) {
|
347 |
+
$search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
|
348 |
+
$where_conditions['search_sql'] = $wpdb->prepare( 'a.content LIKE %s', $search_terms_like );
|
349 |
}
|
350 |
|
351 |
// Filtering
|
383 |
$where_conditions[] = $meta_query_sql['where'];
|
384 |
}
|
385 |
|
386 |
+
// Process date_query into SQL
|
387 |
+
$date_query_sql = self::get_date_query_sql( $date_query );
|
388 |
+
|
389 |
+
if ( ! empty( $date_query_sql ) ) {
|
390 |
+
$where_conditions['date'] = $date_query_sql;
|
391 |
+
}
|
392 |
+
|
393 |
// Alter the query based on whether we want to show activity item
|
394 |
// comments in the stream like normal comments or threaded below
|
395 |
// the activity.
|
396 |
if ( false === $display_comments || 'threaded' === $display_comments ) {
|
397 |
+
$excluded_types[] = 'activity_comment';
|
398 |
}
|
399 |
|
400 |
// Exclude 'last_activity' items unless the 'action' filter has
|
401 |
// been explicitly set
|
402 |
if ( empty( $filter['object'] ) ) {
|
403 |
+
$excluded_types[] = 'last_activity';
|
404 |
+
}
|
405 |
+
|
406 |
+
// Exclude 'new_member' items if xprofile component is not active
|
407 |
+
if ( ! bp_is_active( 'xprofile' ) ) {
|
408 |
+
$excluded_types[] = 'new_member';
|
409 |
+
}
|
410 |
+
|
411 |
+
// Build the excluded type sql part
|
412 |
+
if ( ! empty( $excluded_types ) ) {
|
413 |
+
$not_in = "'" . implode( "', '", esc_sql( $excluded_types ) ) . "'";
|
414 |
+
$where_conditions['excluded_types'] = "a.type NOT IN ({$not_in})";
|
415 |
}
|
416 |
|
417 |
// Filter the where conditions
|
440 |
$page = absint( $page );
|
441 |
$per_page = absint( $per_page );
|
442 |
|
443 |
+
$retval = array(
|
444 |
+
'activities' => null,
|
445 |
+
'total' => null,
|
446 |
+
'has_more_items' => null,
|
447 |
+
);
|
448 |
+
|
449 |
// Filter and return true to use the legacy query structure (not recommended)
|
450 |
if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) {
|
451 |
|
466 |
$activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
|
467 |
|
468 |
if ( ! empty( $per_page ) && ! empty( $page ) ) {
|
469 |
+
// We query for $per_page + 1 items in order to
|
470 |
+
// populate the has_more_items flag
|
471 |
+
$activity_ids_sql .= $wpdb->prepare( " LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page + 1 );
|
472 |
}
|
473 |
|
474 |
$activity_ids_sql = apply_filters( 'bp_activity_paged_activities_sql', $activity_ids_sql, $r );
|
475 |
|
476 |
$activity_ids = $wpdb->get_col( $activity_ids_sql );
|
|
|
|
|
477 |
|
478 |
+
$retval['has_more_items'] = ! empty( $per_page ) && count( $activity_ids ) > $per_page;
|
479 |
+
|
480 |
+
// If we've fetched more than the $per_page value, we
|
481 |
+
// can discard the extra now
|
482 |
+
if ( ! empty( $per_page ) && count( $activity_ids ) === $per_page + 1 ) {
|
483 |
+
array_pop( $activity_ids );
|
484 |
+
}
|
485 |
+
|
486 |
+
$activities = self::get_activity_data( $activity_ids );
|
487 |
+
}
|
488 |
|
489 |
// Get the fullnames of users so we don't have to query in the loop
|
490 |
$activities = self::append_user_fullnames( $activities );
|
508 |
// Generate action strings
|
509 |
$activities = BP_Activity_Activity::generate_action_strings( $activities );
|
510 |
|
511 |
+
$retval['activities'] = $activities;
|
512 |
+
|
513 |
// If $max is set, only return up to the max results
|
514 |
+
if ( ! empty( $r['count_total'] ) ) {
|
515 |
+
|
516 |
+
$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 );
|
517 |
+
$total_activities = $wpdb->get_var( $total_activities_sql );
|
518 |
+
|
519 |
+
if ( !empty( $max ) ) {
|
520 |
+
if ( (int) $total_activities > (int) $max )
|
521 |
+
$total_activities = $max;
|
522 |
+
}
|
523 |
+
|
524 |
+
$retval['total'] = $total_activities;
|
525 |
}
|
526 |
|
527 |
+
return $retval;
|
528 |
}
|
529 |
|
530 |
/**
|
709 |
return $sql_array;
|
710 |
}
|
711 |
|
712 |
+
/**
|
713 |
+
* Get the SQL for the 'date_query' param in BP_Activity_Activity::get().
|
714 |
+
*
|
715 |
+
* We use BP_Date_Query, which extends WP_Date_Query, to do the heavy lifting
|
716 |
+
* of parsing the date_query array and creating the necessary SQL clauses.
|
717 |
+
* However, since BP_Activity_Activity::get() builds its SQL differently than
|
718 |
+
* WP_Query, we have to alter the return value (stripping the leading AND
|
719 |
+
* keyword from the query).
|
720 |
+
*
|
721 |
+
* @since BuddyPress (2.1.0)
|
722 |
+
*
|
723 |
+
* @param array $date_query An array of date_query parameters. See the
|
724 |
+
* documentation for the first parameter of WP_Date_Query.
|
725 |
+
* @return string
|
726 |
+
*/
|
727 |
+
public static function get_date_query_sql( $date_query = array() ) {
|
728 |
+
$sql = '';
|
729 |
+
|
730 |
+
// Date query
|
731 |
+
if ( ! empty( $date_query ) && is_array( $date_query ) && class_exists( 'BP_Date_Query' ) ) {
|
732 |
+
$date_query = new BP_Date_Query( $date_query, 'date_recorded' );
|
733 |
+
$sql = preg_replace( '/^\sAND/', '', $date_query->get_sql() );
|
734 |
+
}
|
735 |
+
|
736 |
+
return $sql;
|
737 |
+
}
|
738 |
+
|
739 |
/**
|
740 |
* In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
|
741 |
*
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Activity component CSS/JS
|
5 |
+
*
|
6 |
+
* @package BuddyPress
|
7 |
+
* @subpackage ActivityScripts
|
8 |
+
*/
|
9 |
+
|
10 |
+
// Exit if accessed directly
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
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() ) {
|
20 |
+
return;
|
21 |
+
}
|
22 |
+
|
23 |
+
// Special handling for New/Edit screens in wp-admin
|
24 |
+
if ( is_admin() ) {
|
25 |
+
if (
|
26 |
+
! get_current_screen() ||
|
27 |
+
! in_array( get_current_screen()->base, array( 'page', 'post' ) ) ||
|
28 |
+
! post_type_supports( get_current_screen()->post_type, 'editor' ) ) {
|
29 |
+
return;
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
35 |
+
|
36 |
+
wp_enqueue_script( 'bp-mentions', buddypress()->plugin_url . "bp-activity/js/mentions{$min}.js", array( 'jquery', 'jquery-atwho' ), bp_get_version(), true );
|
37 |
+
wp_enqueue_style( 'bp-mentions-css', buddypress()->plugin_url . "bp-activity/css/mentions{$min}.css", array(), bp_get_version() );
|
38 |
+
|
39 |
+
wp_style_add_data( 'bp-mentions-css', 'rtl', true );
|
40 |
+
if ( $min ) {
|
41 |
+
wp_style_add_data( 'bp-mentions-css', 'suffix', $min );
|
42 |
+
}
|
43 |
+
|
44 |
+
// Print a list of the current user's friends to the page for quicker @mentions lookups.
|
45 |
+
do_action( 'bp_activity_mentions_prime_results' );
|
46 |
+
}
|
47 |
+
add_action( 'bp_enqueue_scripts', 'bp_activity_mentions_script' );
|
48 |
+
add_action( 'bp_admin_enqueue_scripts', 'bp_activity_mentions_script' );
|
@@ -22,7 +22,7 @@ add_filter( 'bp_get_activity_latest_update_excerpt', 'bp_activity_filter_kses',
|
|
22 |
add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_filter_kses', 1 );
|
23 |
add_filter( 'bp_activity_content_before_save', 'bp_activity_filter_kses', 1 );
|
24 |
add_filter( 'bp_activity_action_before_save', 'bp_activity_filter_kses', 1 );
|
25 |
-
add_filter( 'bp_activity_latest_update_content', '
|
26 |
|
27 |
add_filter( 'bp_get_activity_action', 'force_balance_tags' );
|
28 |
add_filter( 'bp_get_activity_content_body', 'force_balance_tags' );
|
@@ -96,6 +96,9 @@ add_filter( 'bp_get_activity_parent_content', 'bp_create_excerpt' );
|
|
96 |
add_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
|
97 |
add_filter( 'bp_get_activity_content', 'bp_activity_truncate_entry', 5 );
|
98 |
|
|
|
|
|
|
|
99 |
/** Actions *******************************************************************/
|
100 |
|
101 |
// At-name filter
|
@@ -456,7 +459,7 @@ function bp_activity_timestamp_class( $classes = '' ) {
|
|
456 |
if ( empty( $activity_date ) ) {
|
457 |
return $classes;
|
458 |
}
|
459 |
-
|
460 |
$classes .= ' date-recorded-' . strtotime( $activity_date );
|
461 |
|
462 |
return $classes;
|
@@ -489,6 +492,10 @@ function bp_activity_heartbeat_last_recorded( $response = array(), $data = array
|
|
489 |
'activity_latest_args'
|
490 |
);
|
491 |
|
|
|
|
|
|
|
|
|
492 |
$newest_activities = array();
|
493 |
$last_activity_recorded = 0;
|
494 |
|
22 |
add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_filter_kses', 1 );
|
23 |
add_filter( 'bp_activity_content_before_save', 'bp_activity_filter_kses', 1 );
|
24 |
add_filter( 'bp_activity_action_before_save', 'bp_activity_filter_kses', 1 );
|
25 |
+
add_filter( 'bp_activity_latest_update_content', 'bp_activity_filter_kses', 1 );
|
26 |
|
27 |
add_filter( 'bp_get_activity_action', 'force_balance_tags' );
|
28 |
add_filter( 'bp_get_activity_content_body', 'force_balance_tags' );
|
96 |
add_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
|
97 |
add_filter( 'bp_get_activity_content', 'bp_activity_truncate_entry', 5 );
|
98 |
|
99 |
+
add_filter( 'bp_get_total_favorite_count_for_user', 'bp_core_number_format' );
|
100 |
+
add_filter( 'bp_get_total_mention_count_for_user', 'bp_core_number_format' );
|
101 |
+
|
102 |
/** Actions *******************************************************************/
|
103 |
|
104 |
// At-name filter
|
459 |
if ( empty( $activity_date ) ) {
|
460 |
return $classes;
|
461 |
}
|
462 |
+
|
463 |
$classes .= ' date-recorded-' . strtotime( $activity_date );
|
464 |
|
465 |
return $classes;
|
492 |
'activity_latest_args'
|
493 |
);
|
494 |
|
495 |
+
if ( ! empty( $data['bp_activity_last_recorded_search_terms'] ) && empty( $activity_latest_args['search_terms'] ) ) {
|
496 |
+
$activity_latest_args['search_terms'] = addslashes( $data['bp_activity_last_recorded_search_terms'] );
|
497 |
+
}
|
498 |
+
|
499 |
$newest_activities = array();
|
500 |
$last_activity_recorded = 0;
|
501 |
|
@@ -15,16 +15,12 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|
15 |
/**
|
16 |
* Check whether the $bp global lists an activity directory page.
|
17 |
*
|
18 |
-
* @since BuddyPress (1.5)
|
19 |
-
*
|
20 |
-
* @global object $bp BuddyPress global settings
|
21 |
*
|
22 |
* @return bool True if activity directory page is found, otherwise false.
|
23 |
*/
|
24 |
function bp_activity_has_directory() {
|
25 |
-
|
26 |
-
|
27 |
-
return (bool) !empty( $bp->pages->activity->id );
|
28 |
}
|
29 |
|
30 |
/**
|
@@ -42,7 +38,7 @@ function bp_activity_has_directory() {
|
|
42 |
*
|
43 |
* add_filter( 'bp_activity_do_mentions', '__return_false' );
|
44 |
*
|
45 |
-
* @since BuddyPress (1.8)
|
46 |
*
|
47 |
* @uses apply_filters() To call 'bp_activity_do_mentions' hook.
|
48 |
*
|
@@ -52,36 +48,60 @@ function bp_activity_do_mentions() {
|
|
52 |
return (bool) apply_filters( 'bp_activity_do_mentions', true );
|
53 |
}
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
/**
|
56 |
* Locate usernames in an activity content string, as designated by an @ sign.
|
57 |
*
|
58 |
-
* @since BuddyPress (1.5)
|
59 |
*
|
60 |
-
* @param string $content The content of the activity, usually found in
|
61 |
-
*
|
|
|
|
|
62 |
*/
|
63 |
function bp_activity_find_mentions( $content ) {
|
|
|
64 |
$pattern = '/[@]+([A-Za-z0-9-_\.@]+)\b/';
|
65 |
preg_match_all( $pattern, $content, $usernames );
|
66 |
|
67 |
// Make sure there's only one instance of each username
|
68 |
-
|
|
|
|
|
|
|
69 |
return false;
|
|
|
70 |
|
71 |
$mentioned_users = array();
|
72 |
|
73 |
// We've found some mentions! Check to see if users exist
|
74 |
-
foreach( (array) $usernames as $
|
75 |
$user_id = bp_activity_get_userid_from_mentionname( $username );
|
76 |
|
77 |
// user ID exists, so let's add it to our array
|
78 |
if ( ! empty( $user_id ) ) {
|
79 |
-
$mentioned_users[$user_id] = $username;
|
80 |
}
|
81 |
}
|
82 |
|
83 |
-
if ( empty( $mentioned_users ) )
|
84 |
return false;
|
|
|
85 |
|
86 |
return $mentioned_users;
|
87 |
}
|
@@ -89,7 +109,7 @@ function bp_activity_find_mentions( $content ) {
|
|
89 |
/**
|
90 |
* Reset a user's unread mentions list and count.
|
91 |
*
|
92 |
-
* @since BuddyPress (1.5)
|
93 |
*
|
94 |
* @uses bp_delete_user_meta()
|
95 |
*
|
@@ -97,7 +117,7 @@ function bp_activity_find_mentions( $content ) {
|
|
97 |
*/
|
98 |
function bp_activity_clear_new_mentions( $user_id ) {
|
99 |
bp_delete_user_meta( $user_id, 'bp_new_mention_count' );
|
100 |
-
bp_delete_user_meta( $user_id, 'bp_new_mentions'
|
101 |
}
|
102 |
|
103 |
/**
|
@@ -108,7 +128,7 @@ function bp_activity_clear_new_mentions( $user_id ) {
|
|
108 |
*
|
109 |
* Currently, only used in {@link bp_activity_delete()}.
|
110 |
*
|
111 |
-
* @since BuddyPress (1.5)
|
112 |
*
|
113 |
* @uses bp_activity_find_mentions()
|
114 |
* @uses bp_activity_update_mention_count_for_user()
|
@@ -117,21 +137,25 @@ function bp_activity_clear_new_mentions( $user_id ) {
|
|
117 |
* @param string $action Can be 'delete' or 'add'. Defaults to 'add'.
|
118 |
*/
|
119 |
function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
|
120 |
-
|
|
|
|
|
121 |
return false;
|
|
|
122 |
|
123 |
// Get activity object
|
124 |
-
$activity
|
125 |
|
126 |
// Try to find mentions
|
127 |
$usernames = bp_activity_find_mentions( strip_tags( $activity->content ) );
|
128 |
|
129 |
// Still empty? Stop now
|
130 |
-
if ( empty( $usernames ) )
|
131 |
return false;
|
|
|
132 |
|
133 |
// Increment mention count foreach mentioned user
|
134 |
-
foreach( (array) $usernames as $user_id
|
135 |
bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action );
|
136 |
}
|
137 |
}
|
@@ -142,7 +166,7 @@ function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
|
|
142 |
* This function should be used when you've already parsed your activity item
|
143 |
* for @mentions.
|
144 |
*
|
145 |
-
* @since BuddyPress (1.7)
|
146 |
*
|
147 |
* @uses bp_get_user_meta()
|
148 |
* @uses bp_update_user_meta()
|
@@ -153,13 +177,19 @@ function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
|
|
153 |
* @return bool
|
154 |
*/
|
155 |
function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action = 'add' ) {
|
156 |
-
|
|
|
157 |
return false;
|
|
|
158 |
|
159 |
// Adjust the mention list and count for the member
|
160 |
$new_mention_count = (int) bp_get_user_meta( $user_id, 'bp_new_mention_count', true );
|
161 |
-
|
|
|
|
|
|
|
162 |
$new_mentions = array();
|
|
|
163 |
|
164 |
switch ( $action ) {
|
165 |
case 'delete' :
|
@@ -275,9 +305,13 @@ function bp_activity_get_userid_from_mentionname( $mentionname ) {
|
|
275 |
* @param string $type The action type.
|
276 |
* @param string $description The action description.
|
277 |
* @param callable $format_callback Callback for formatting the action string.
|
|
|
|
|
|
|
|
|
278 |
* @return bool False if any param is empty, otherwise true.
|
279 |
*/
|
280 |
-
function bp_activity_set_action( $component_id, $type, $description, $format_callback = false ) {
|
281 |
$bp = buddypress();
|
282 |
|
283 |
// Return false if any of the above values are not set
|
@@ -303,7 +337,9 @@ function bp_activity_set_action( $component_id, $type, $description, $format_cal
|
|
303 |
'key' => $type,
|
304 |
'value' => $description,
|
305 |
'format_callback' => $format_callback,
|
306 |
-
|
|
|
|
|
307 |
|
308 |
return true;
|
309 |
}
|
@@ -311,9 +347,8 @@ function bp_activity_set_action( $component_id, $type, $description, $format_cal
|
|
311 |
/**
|
312 |
* Retreive the current action from a component and key.
|
313 |
*
|
314 |
-
* @since BuddyPress (1.1)
|
315 |
*
|
316 |
-
* @global object $bp BuddyPress global settings.
|
317 |
* @uses apply_filters() To call the 'bp_activity_get_action' hook.
|
318 |
*
|
319 |
* @param string $component_id The unique string ID of the component.
|
@@ -321,19 +356,24 @@ function bp_activity_set_action( $component_id, $type, $description, $format_cal
|
|
321 |
* @return string|bool Action value if found, otherwise false.
|
322 |
*/
|
323 |
function bp_activity_get_action( $component_id, $key ) {
|
324 |
-
global $bp;
|
325 |
|
326 |
// Return false if any of the above values are not set
|
327 |
-
if ( empty( $component_id ) || empty( $key ) )
|
328 |
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
|
330 |
-
return apply_filters( 'bp_activity_get_action', $
|
331 |
}
|
332 |
|
333 |
/**
|
334 |
* Fetch details of all registered activity types.
|
335 |
*
|
336 |
-
* @since BuddyPress (1.7)
|
337 |
*
|
338 |
* @return array array( type => description ), ...
|
339 |
*/
|
@@ -344,8 +384,9 @@ function bp_activity_get_types() {
|
|
344 |
foreach ( buddypress()->activity->actions as $action ) {
|
345 |
$action = array_values( (array) $action );
|
346 |
|
347 |
-
for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ )
|
348 |
$actions[ $action[$i]['key'] ] = $action[$i]['value'];
|
|
|
349 |
}
|
350 |
|
351 |
// This was a mis-named activity type from before BP 1.6
|
@@ -359,7 +400,7 @@ function bp_activity_get_types() {
|
|
359 |
/**
|
360 |
* Get a users favorite activity stream items.
|
361 |
*
|
362 |
-
* @since BuddyPress (1.2)
|
363 |
*
|
364 |
* @uses bp_get_user_meta()
|
365 |
* @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook.
|
@@ -370,8 +411,9 @@ function bp_activity_get_types() {
|
|
370 |
function bp_activity_get_user_favorites( $user_id = 0 ) {
|
371 |
|
372 |
// Fallback to logged in user if no user_id is passed
|
373 |
-
if ( empty( $user_id ) )
|
374 |
$user_id = bp_displayed_user_id();
|
|
|
375 |
|
376 |
// Get favorites for user
|
377 |
$favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
|
@@ -382,7 +424,7 @@ function bp_activity_get_user_favorites( $user_id = 0 ) {
|
|
382 |
/**
|
383 |
* Add an activity stream item as a favorite for a user.
|
384 |
*
|
385 |
-
* @since BuddyPress (1.2)
|
386 |
*
|
387 |
* @uses is_user_logged_in()
|
388 |
* @uses bp_get_user_meta()
|
@@ -399,12 +441,14 @@ function bp_activity_get_user_favorites( $user_id = 0 ) {
|
|
399 |
function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
|
400 |
|
401 |
// Favorite activity stream items are for logged in users only
|
402 |
-
if ( !is_user_logged_in() )
|
403 |
return false;
|
|
|
404 |
|
405 |
// Fallback to logged in user if no user_id is passed
|
406 |
-
if ( empty( $user_id ) )
|
407 |
$user_id = bp_loggedin_user_id();
|
|
|
408 |
|
409 |
$my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
|
410 |
if ( empty( $my_favs ) || ! is_array( $my_favs ) ) {
|
@@ -447,7 +491,7 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
|
|
447 |
/**
|
448 |
* Remove an activity stream item as a favorite for a user.
|
449 |
*
|
450 |
-
* @since BuddyPress (1.2)
|
451 |
*
|
452 |
* @uses is_user_logged_in()
|
453 |
* @uses bp_get_user_meta()
|
@@ -463,12 +507,14 @@ function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
|
|
463 |
function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
|
464 |
|
465 |
// Favorite activity stream items are for logged in users only
|
466 |
-
if ( !is_user_logged_in() )
|
467 |
return false;
|
|
|
468 |
|
469 |
// Fallback to logged in user if no user_id is passed
|
470 |
-
if ( empty( $user_id ) )
|
471 |
$user_id = bp_loggedin_user_id();
|
|
|
472 |
|
473 |
$my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
|
474 |
$my_favs = array_flip( (array) $my_favs );
|
@@ -483,7 +529,8 @@ function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
|
|
483 |
$my_favs = array_unique( array_flip( $my_favs ) );
|
484 |
|
485 |
// Update the total number of users who have favorited this activity
|
486 |
-
|
|
|
487 |
|
488 |
// Deduct from total favorites
|
489 |
if ( bp_activity_update_meta( $activity_id, 'favorite_count', (int) $fav_count - 1 ) ) {
|
@@ -516,7 +563,7 @@ function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
|
|
516 |
/**
|
517 |
* Check whether an activity item exists with a given content string.
|
518 |
*
|
519 |
-
* @since BuddyPress (1.1)
|
520 |
*
|
521 |
* @uses BP_Activity_Activity::check_exists_by_content() {@link BP_Activity_Activity}
|
522 |
* @uses apply_filters() To call the 'bp_activity_check_exists_by_content' hook.
|
@@ -531,7 +578,7 @@ function bp_activity_check_exists_by_content( $content ) {
|
|
531 |
/**
|
532 |
* Retrieve the last time activity was updated.
|
533 |
*
|
534 |
-
* @since BuddyPress (1.0)
|
535 |
*
|
536 |
* @uses BP_Activity_Activity::get_last_updated() {@link BP_Activity_Activity}
|
537 |
* @uses apply_filters() To call the 'bp_activity_get_last_updated' hook.
|
@@ -545,7 +592,7 @@ function bp_activity_get_last_updated() {
|
|
545 |
/**
|
546 |
* Retrieve the number of favorite activity stream items a user has.
|
547 |
*
|
548 |
-
* @since BuddyPress (1.2)
|
549 |
*
|
550 |
* @uses BP_Activity_Activity::total_favorite_count() {@link BP_Activity_Activity}
|
551 |
*
|
@@ -555,8 +602,9 @@ function bp_activity_get_last_updated() {
|
|
555 |
function bp_activity_total_favorites_for_user( $user_id = 0 ) {
|
556 |
|
557 |
// Fallback on displayed user, and then logged in user
|
558 |
-
if ( empty( $user_id ) )
|
559 |
$user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
|
|
|
560 |
|
561 |
return BP_Activity_Activity::total_favorite_count( $user_id );
|
562 |
}
|
@@ -584,7 +632,6 @@ function bp_activity_total_favorites_for_user( $user_id = 0 ) {
|
|
584 |
* @return bool True on success, false on failure.
|
585 |
*/
|
586 |
function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '', $delete_all = false ) {
|
587 |
-
global $wpdb, $bp;
|
588 |
|
589 |
// Legacy - if no meta_key is passed, delete all for the item
|
590 |
if ( empty( $meta_key ) ) {
|
@@ -611,7 +658,7 @@ function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = ''
|
|
611 |
/**
|
612 |
* Get metadata for a given activity item.
|
613 |
*
|
614 |
-
* @since BuddyPress (1.2)
|
615 |
*
|
616 |
* @uses apply_filters() To call the 'bp_activity_get_meta' hook.
|
617 |
*
|
@@ -636,7 +683,7 @@ function bp_activity_get_meta( $activity_id = 0, $meta_key = '', $single = true
|
|
636 |
/**
|
637 |
* Update a piece of activity meta.
|
638 |
*
|
639 |
-
* @since BuddyPress (1.2)
|
640 |
*
|
641 |
* @param int $activity_id ID of the activity item whose metadata is being
|
642 |
* updated.
|
@@ -665,7 +712,7 @@ function bp_activity_update_meta( $activity_id, $meta_key, $meta_value, $prev_va
|
|
665 |
* @param int $activity_id ID of the activity item.
|
666 |
* @param string $meta_key Metadata key.
|
667 |
* @param mixed $meta_value Metadata value.
|
668 |
-
* @param bool $unique
|
669 |
* for the given key. If true, and the object already has a value for
|
670 |
* the key, no change will be made. Default: false.
|
671 |
* @return int|bool The meta ID on successful update, false on failure.
|
@@ -683,7 +730,7 @@ function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = f
|
|
683 |
/**
|
684 |
* Completely remove a user's activity data.
|
685 |
*
|
686 |
-
* @since BuddyPress (1.5)
|
687 |
*
|
688 |
* @uses is_user_logged_in()
|
689 |
* @uses bp_activity_delete()
|
@@ -696,14 +743,15 @@ function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = f
|
|
696 |
function bp_activity_remove_all_user_data( $user_id = 0 ) {
|
697 |
|
698 |
// Do not delete user data unless a logged in user says so
|
699 |
-
if ( empty( $user_id ) || !is_user_logged_in() )
|
700 |
return false;
|
|
|
701 |
|
702 |
// Clear the user's activity from the sitewide stream and clear their activity tables
|
703 |
bp_activity_delete( array( 'user_id' => $user_id ) );
|
704 |
|
705 |
// Remove any usermeta
|
706 |
-
bp_delete_user_meta( $user_id, 'bp_latest_update'
|
707 |
bp_delete_user_meta( $user_id, 'bp_favorite_activities' );
|
708 |
|
709 |
// Execute additional code
|
@@ -718,7 +766,7 @@ add_action( 'delete_user', 'bp_activity_remove_all_user_data' );
|
|
718 |
/**
|
719 |
* Mark all of the user's activity as spam.
|
720 |
*
|
721 |
-
* @since BuddyPress (1.6)
|
722 |
*
|
723 |
* @global object $wpdb WordPress database access object.
|
724 |
* @global object $bp BuddyPress global settings.
|
@@ -726,22 +774,30 @@ add_action( 'delete_user', 'bp_activity_remove_all_user_data' );
|
|
726 |
* @param int $user_id ID of the user whose activity is being spammed.
|
727 |
*/
|
728 |
function bp_activity_spam_all_user_data( $user_id = 0 ) {
|
729 |
-
global $
|
730 |
|
731 |
// Do not delete user data unless a logged in user says so
|
732 |
-
if ( empty( $user_id ) || ! is_user_logged_in() )
|
733 |
return false;
|
|
|
734 |
|
735 |
// Get all the user's activities.
|
736 |
-
$activities = bp_activity_get( array(
|
|
|
|
|
|
|
|
|
|
|
|
|
737 |
|
738 |
// Mark each as spam
|
739 |
foreach ( (array) $activities['activities'] as $activity ) {
|
740 |
|
741 |
// Create an activity object
|
742 |
$activity_obj = new BP_Activity_Activity;
|
743 |
-
foreach ( $activity as $k => $v )
|
744 |
$activity_obj->$k = $v;
|
|
|
745 |
|
746 |
// Mark as spam
|
747 |
bp_activity_mark_as_spam( $activity_obj );
|
@@ -753,8 +809,9 @@ function bp_activity_spam_all_user_data( $user_id = 0 ) {
|
|
753 |
* as we're going to be updating all the activity statuses directly, for efficency,
|
754 |
* we need to update manually.
|
755 |
*/
|
756 |
-
if ( ! empty( $bp->activity->akismet ) )
|
757 |
$bp->activity->akismet->update_activity_spam_meta( $activity_obj );
|
|
|
758 |
|
759 |
// Tidy up
|
760 |
unset( $activity_obj );
|
@@ -771,7 +828,7 @@ add_action( 'bp_make_spam_user', 'bp_activity_spam_all_user_data' );
|
|
771 |
/**
|
772 |
* Mark all of the user's activity as ham (not spam).
|
773 |
*
|
774 |
-
* @since BuddyPress (1.6)
|
775 |
*
|
776 |
* @global object $wpdb WordPress database access object.
|
777 |
* @global object $bp BuddyPress global settings.
|
@@ -779,22 +836,31 @@ add_action( 'bp_make_spam_user', 'bp_activity_spam_all_user_data' );
|
|
779 |
* @param int $user_id ID of the user whose activity is being hammed.
|
780 |
*/
|
781 |
function bp_activity_ham_all_user_data( $user_id = 0 ) {
|
782 |
-
global $
|
783 |
|
784 |
// Do not delete user data unless a logged in user says so
|
785 |
-
if ( empty( $user_id ) || ! is_user_logged_in() )
|
786 |
return false;
|
|
|
787 |
|
788 |
// Get all the user's activities.
|
789 |
-
$activities = bp_activity_get( array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
790 |
|
791 |
// Mark each as not spam
|
792 |
foreach ( (array) $activities['activities'] as $activity ) {
|
793 |
|
794 |
// Create an activity object
|
795 |
$activity_obj = new BP_Activity_Activity;
|
796 |
-
foreach ( $activity as $k => $v )
|
797 |
$activity_obj->$k = $v;
|
|
|
798 |
|
799 |
// Mark as not spam
|
800 |
bp_activity_mark_as_ham( $activity_obj );
|
@@ -806,8 +872,9 @@ function bp_activity_ham_all_user_data( $user_id = 0 ) {
|
|
806 |
* as we're going to be updating all the activity statuses directly, for efficency,
|
807 |
* we need to update manually.
|
808 |
*/
|
809 |
-
if ( ! empty( $bp->activity->akismet ) )
|
810 |
$bp->activity->akismet->update_activity_ham_meta( $activity_obj );
|
|
|
811 |
|
812 |
// Tidy up
|
813 |
unset( $activity_obj );
|
@@ -824,25 +891,26 @@ add_action( 'bp_make_ham_user', 'bp_activity_ham_all_user_data' );
|
|
824 |
/**
|
825 |
* Register the activity stream actions for updates
|
826 |
*
|
827 |
-
* @since BuddyPress (1.6)
|
828 |
-
*
|
829 |
-
* @global object $bp BuddyPress global settings.
|
830 |
*/
|
831 |
function bp_activity_register_activity_actions() {
|
832 |
-
|
833 |
|
834 |
bp_activity_set_action(
|
835 |
$bp->activity->id,
|
836 |
'activity_update',
|
837 |
__( 'Posted a status update', 'buddypress' ),
|
838 |
-
'bp_activity_format_activity_action_activity_update'
|
|
|
|
|
839 |
);
|
840 |
|
841 |
bp_activity_set_action(
|
842 |
$bp->activity->id,
|
843 |
'activity_comment',
|
844 |
__( 'Replied to a status update', 'buddypress' ),
|
845 |
-
'bp_activity_format_activity_action_activity_comment'
|
|
|
846 |
);
|
847 |
|
848 |
do_action( 'bp_activity_register_activity_actions' );
|
@@ -860,6 +928,7 @@ add_action( 'bp_register_activity_actions', 'bp_activity_register_activity_actio
|
|
860 |
* the formatted action string.
|
861 |
*/
|
862 |
function bp_activity_generate_action_string( $activity ) {
|
|
|
863 |
// Check for valid input
|
864 |
if ( empty( $activity->component ) || empty( $activity->type ) ) {
|
865 |
return false;
|
@@ -926,7 +995,7 @@ function bp_activity_format_activity_action_activity_comment( $action, $activity
|
|
926 |
* the default for the bp_activity_get()).
|
927 |
* - 'per_page' (false)
|
928 |
*
|
929 |
-
* @since BuddyPress (1.2)
|
930 |
*
|
931 |
* @see BP_Activity_Activity::get() For more information on accepted arguments
|
932 |
* and the format of the returned value.
|
@@ -940,7 +1009,8 @@ function bp_activity_format_activity_action_activity_comment( $action, $activity
|
|
940 |
* @return array $activity See BP_Activity_Activity::get() for description.
|
941 |
*/
|
942 |
function bp_activity_get( $args = '' ) {
|
943 |
-
|
|
|
944 |
'max' => false, // Maximum number of results to return
|
945 |
'page' => 1, // page 1 without a per_page will result in no pagination.
|
946 |
'per_page' => false, // results per page
|
@@ -949,11 +1019,13 @@ function bp_activity_get( $args = '' ) {
|
|
949 |
|
950 |
'search_terms' => false, // Pass search terms as a string
|
951 |
'meta_query' => false, // Filter by activity meta. See WP_Meta_Query for format
|
|
|
952 |
'show_hidden' => false, // Show activity items that are hidden site-wide?
|
953 |
'exclude' => false, // Comma-separated list of activity IDs to exclude
|
954 |
'in' => false, // Comma-separated list or array of activity IDs to which you want to limit the query
|
955 |
'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'.
|
956 |
'update_meta_cache' => true,
|
|
|
957 |
|
958 |
/**
|
959 |
* Pass filters as an array -- all filter items can be multiple values comma separated:
|
@@ -966,46 +1038,50 @@ function bp_activity_get( $args = '' ) {
|
|
966 |
* );
|
967 |
*/
|
968 |
'filter' => array()
|
969 |
-
);
|
970 |
-
$r = wp_parse_args( $args, $defaults );
|
971 |
-
extract( $r, EXTR_SKIP );
|
972 |
|
973 |
// Attempt to return a cached copy of the first page of sitewide activity.
|
974 |
-
if ( 1
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
'
|
981 |
-
'
|
982 |
-
'
|
983 |
-
'
|
984 |
-
'
|
985 |
-
'
|
986 |
-
'
|
987 |
-
'
|
988 |
-
|
989 |
-
|
|
|
|
|
|
|
|
|
|
|
990 |
wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' );
|
991 |
}
|
992 |
|
993 |
} else {
|
994 |
-
$
|
995 |
-
'page' => $page,
|
996 |
-
'per_page' => $per_page,
|
997 |
-
'max' => $max,
|
998 |
-
'sort' => $sort,
|
999 |
-
'search_terms' => $search_terms,
|
1000 |
-
'meta_query' => $meta_query,
|
1001 |
-
'
|
1002 |
-
'
|
1003 |
-
'
|
1004 |
-
'
|
1005 |
-
'
|
1006 |
-
'
|
1007 |
-
|
1008 |
-
|
|
|
1009 |
}
|
1010 |
|
1011 |
return apply_filters_ref_array( 'bp_activity_get', array( &$activity, &$r ) );
|
@@ -1014,7 +1090,7 @@ function bp_activity_get( $args = '' ) {
|
|
1014 |
/**
|
1015 |
* Fetch specific activity items.
|
1016 |
*
|
1017 |
-
* @since BuddyPress (1.2)
|
1018 |
*
|
1019 |
* @see BP_Activity_Activity::get() For more information on accepted arguments
|
1020 |
* @uses wp_parse_args()
|
@@ -1030,38 +1106,38 @@ function bp_activity_get( $args = '' ) {
|
|
1030 |
* @return array $activity See BP_Activity_Activity::get() for description.
|
1031 |
*/
|
1032 |
function bp_activity_get_specific( $args = '' ) {
|
1033 |
-
|
1034 |
-
|
1035 |
-
'
|
1036 |
-
'
|
1037 |
-
'
|
1038 |
-
'
|
1039 |
-
'
|
1040 |
-
'
|
1041 |
-
'
|
|
|
1042 |
'update_meta_cache' => true,
|
1043 |
-
);
|
1044 |
-
$r = wp_parse_args( $args, $defaults );
|
1045 |
-
extract( $r, EXTR_SKIP );
|
1046 |
|
1047 |
$get_args = array(
|
1048 |
-
'
|
1049 |
-
'
|
1050 |
-
'max' => $max,
|
1051 |
-
'
|
1052 |
-
'
|
1053 |
-
'show_hidden' => $show_hidden,
|
1054 |
-
'
|
1055 |
-
'spam' => $spam,
|
1056 |
-
'update_meta_cache' => $update_meta_cache,
|
1057 |
);
|
|
|
1058 |
return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $get_args ), $args, $get_args );
|
1059 |
}
|
1060 |
|
1061 |
/**
|
1062 |
* Add an activity item.
|
1063 |
*
|
1064 |
-
* @since BuddyPress (1.1)
|
1065 |
*
|
1066 |
* @uses wp_parse_args()
|
1067 |
* @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
|
@@ -1104,56 +1180,57 @@ function bp_activity_get_specific( $args = '' ) {
|
|
1104 |
*/
|
1105 |
function bp_activity_add( $args = '' ) {
|
1106 |
|
1107 |
-
$
|
1108 |
-
'id' => false,
|
1109 |
-
|
1110 |
-
'
|
1111 |
-
'
|
1112 |
-
|
1113 |
-
'
|
1114 |
-
'
|
1115 |
-
'
|
1116 |
-
|
1117 |
-
'user_id' => bp_loggedin_user_id(), // Optional: The user to record the activity for, can be false if this activity is not for a user.
|
1118 |
-
'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
|
1119 |
-
'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
|
1120 |
'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded
|
1121 |
-
'hide_sitewide' => false,
|
1122 |
-
'is_spam' => false,
|
1123 |
-
);
|
1124 |
-
$params = wp_parse_args( $args, $defaults );
|
1125 |
-
extract( $params, EXTR_SKIP );
|
1126 |
|
1127 |
// Make sure we are backwards compatible
|
1128 |
-
if ( empty( $component ) && !empty( $component_name ) )
|
1129 |
-
$component = $component_name;
|
|
|
1130 |
|
1131 |
-
if ( empty( $type ) && !empty( $component_action ) )
|
1132 |
-
$type = $component_action;
|
|
|
1133 |
|
1134 |
// Setup activity to be added
|
1135 |
-
$activity = new BP_Activity_Activity( $id );
|
1136 |
-
$activity->user_id = $user_id;
|
1137 |
-
$activity->component = $component;
|
1138 |
-
$activity->type = $type;
|
1139 |
-
$activity->content = $content;
|
1140 |
-
$activity->primary_link = $primary_link;
|
1141 |
-
$activity->item_id = $item_id;
|
1142 |
-
$activity->secondary_item_id = $secondary_item_id;
|
1143 |
-
$activity->date_recorded = $recorded_time;
|
1144 |
-
$activity->hide_sitewide = $hide_sitewide;
|
1145 |
-
$activity->is_spam = $is_spam;
|
1146 |
-
$activity->action = ! empty( $action )
|
1147 |
-
|
1148 |
-
|
|
|
|
|
1149 |
return false;
|
|
|
1150 |
|
1151 |
// If this is an activity comment, rebuild the tree
|
1152 |
-
if ( 'activity_comment'
|
1153 |
BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id );
|
|
|
1154 |
|
1155 |
wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
|
1156 |
-
do_action( 'bp_activity_add', $
|
1157 |
|
1158 |
return $activity->id;
|
1159 |
}
|
@@ -1161,9 +1238,8 @@ function bp_activity_add( $args = '' ) {
|
|
1161 |
/**
|
1162 |
* Post an activity update.
|
1163 |
*
|
1164 |
-
* @since BuddyPress (1.2)
|
1165 |
*
|
1166 |
-
* @global object $bp BuddyPress global settings.
|
1167 |
* @uses wp_parse_args()
|
1168 |
* @uses bp_is_user_inactive()
|
1169 |
* @uses bp_core_get_userlink()
|
@@ -1182,41 +1258,42 @@ function bp_activity_add( $args = '' ) {
|
|
1182 |
* @return int $activity_id The activity id
|
1183 |
*/
|
1184 |
function bp_activity_post_update( $args = '' ) {
|
1185 |
-
global $bp;
|
1186 |
|
1187 |
-
$
|
1188 |
'content' => false,
|
1189 |
'user_id' => bp_loggedin_user_id()
|
1190 |
-
);
|
1191 |
-
$r = wp_parse_args( $args, $defaults );
|
1192 |
-
extract( $r, EXTR_SKIP );
|
1193 |
|
1194 |
-
if ( empty( $content ) || !strlen( trim( $content ) ) )
|
1195 |
return false;
|
|
|
1196 |
|
1197 |
-
if ( bp_is_user_inactive( $user_id ) )
|
1198 |
return false;
|
|
|
1199 |
|
1200 |
// Record this on the user's profile
|
1201 |
-
$
|
1202 |
-
$
|
1203 |
-
$primary_link = bp_core_get_userlink( $user_id, false, true );
|
1204 |
|
1205 |
// Now write the values
|
1206 |
$activity_id = bp_activity_add( array(
|
1207 |
-
'user_id' => $user_id,
|
1208 |
'content' => apply_filters( 'bp_activity_new_update_content', $activity_content ),
|
1209 |
'primary_link' => apply_filters( 'bp_activity_new_update_primary_link', $primary_link ),
|
1210 |
-
'component' =>
|
1211 |
'type' => 'activity_update',
|
1212 |
) );
|
1213 |
|
1214 |
-
$activity_content = apply_filters( 'bp_activity_latest_update_content', $content, $activity_content );
|
1215 |
|
1216 |
// Add this update to the "latest update" usermeta so it can be fetched anywhere.
|
1217 |
-
bp_update_user_meta( bp_loggedin_user_id(), 'bp_latest_update', array(
|
|
|
|
|
|
|
1218 |
|
1219 |
-
do_action( 'bp_activity_posted_update', $content, $user_id, $activity_id );
|
1220 |
|
1221 |
return $activity_id;
|
1222 |
}
|
@@ -1224,7 +1301,7 @@ function bp_activity_post_update( $args = '' ) {
|
|
1224 |
/**
|
1225 |
* Add an activity comment.
|
1226 |
*
|
1227 |
-
* @since BuddyPress (1.2)
|
1228 |
*
|
1229 |
* @global object $bp BuddyPress global settings.
|
1230 |
* @uses wp_parse_args()
|
@@ -1239,18 +1316,18 @@ function bp_activity_post_update( $args = '' ) {
|
|
1239 |
* @type int $id Optional. Pass an ID to update an existing comment.
|
1240 |
* @type string $content The content of the comment.
|
1241 |
* @type int $user_id Optional. The ID of the user making the comment.
|
1242 |
-
*
|
1243 |
* @type int $activity_id The ID of the "root" activity item, ie the oldest
|
1244 |
-
*
|
1245 |
* @type int $parent_id Optional. The ID of the parent activity item, ie the
|
1246 |
-
*
|
1247 |
-
*
|
1248 |
* }
|
1249 |
* @return int|bool The ID of the comment on success, otherwise false.
|
1250 |
*/
|
1251 |
function bp_activity_new_comment( $args = '' ) {
|
1252 |
|
1253 |
-
$
|
1254 |
'id' => false,
|
1255 |
'content' => false,
|
1256 |
'user_id' => bp_loggedin_user_id(),
|
@@ -1258,31 +1335,31 @@ function bp_activity_new_comment( $args = '' ) {
|
|
1258 |
'parent_id' => false // ID of a parent comment (optional)
|
1259 |
) );
|
1260 |
|
1261 |
-
extract( $params, EXTR_SKIP );
|
1262 |
-
|
1263 |
// Bail if missing necessary data
|
1264 |
-
if ( empty( $content ) || empty( $user_id ) || empty( $activity_id ) ) {
|
1265 |
return false;
|
1266 |
}
|
1267 |
|
1268 |
// Maybe set current activity ID as the parent
|
1269 |
-
if ( empty( $parent_id ) ) {
|
1270 |
-
$parent_id = $activity_id;
|
1271 |
}
|
1272 |
|
|
|
|
|
1273 |
// Check to see if the parent activity is hidden, and if so, hide this comment publically.
|
1274 |
$activity = new BP_Activity_Activity( $activity_id );
|
1275 |
$is_hidden = ( (int) $activity->hide_sitewide ) ? 1 : 0;
|
1276 |
|
1277 |
// Insert the activity comment
|
1278 |
$comment_id = bp_activity_add( array(
|
1279 |
-
'id' => $id,
|
1280 |
-
'content' => apply_filters( 'bp_activity_comment_content', $content ),
|
1281 |
'component' => buddypress()->activity->id,
|
1282 |
'type' => 'activity_comment',
|
1283 |
-
'user_id' => $user_id,
|
1284 |
'item_id' => $activity_id,
|
1285 |
-
'secondary_item_id' => $parent_id,
|
1286 |
'hide_sitewide' => $is_hidden
|
1287 |
) );
|
1288 |
|
@@ -1290,7 +1367,7 @@ function bp_activity_new_comment( $args = '' ) {
|
|
1290 |
wp_cache_delete( $activity_id, 'bp_activity_comments' );
|
1291 |
|
1292 |
// Walk the tree to clear caches for all parent items
|
1293 |
-
$clear_id = $parent_id;
|
1294 |
while ( $clear_id != $activity_id ) {
|
1295 |
$clear_object = new BP_Activity_Activity( $clear_id );
|
1296 |
wp_cache_delete( $clear_id, 'bp_activity' );
|
@@ -1298,7 +1375,7 @@ function bp_activity_new_comment( $args = '' ) {
|
|
1298 |
}
|
1299 |
wp_cache_delete( $activity_id, 'bp_activity' );
|
1300 |
|
1301 |
-
do_action( 'bp_activity_comment_posted', $comment_id, $
|
1302 |
|
1303 |
return $comment_id;
|
1304 |
}
|
@@ -1306,7 +1383,7 @@ function bp_activity_new_comment( $args = '' ) {
|
|
1306 |
/**
|
1307 |
* Fetch the activity_id for an existing activity entry in the DB.
|
1308 |
*
|
1309 |
-
* @since BuddyPress (1.2)
|
1310 |
*
|
1311 |
* @see BP_Activity_Activity::get() For more information on accepted arguments.
|
1312 |
* @uses wp_parse_args()
|
@@ -1317,7 +1394,8 @@ function bp_activity_new_comment( $args = '' ) {
|
|
1317 |
* @return int $activity_id The ID of the activity item found.
|
1318 |
*/
|
1319 |
function bp_activity_get_activity_id( $args = '' ) {
|
1320 |
-
|
|
|
1321 |
'user_id' => false,
|
1322 |
'component' => false,
|
1323 |
'type' => false,
|
@@ -1326,12 +1404,18 @@ function bp_activity_get_activity_id( $args = '' ) {
|
|
1326 |
'action' => false,
|
1327 |
'content' => false,
|
1328 |
'date_recorded' => false,
|
1329 |
-
);
|
1330 |
-
|
1331 |
-
$r = wp_parse_args( $args, $defaults );
|
1332 |
-
extract( $r, EXTR_SKIP );
|
1333 |
|
1334 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1335 |
}
|
1336 |
|
1337 |
/**
|
@@ -1347,7 +1431,7 @@ function bp_activity_get_activity_id( $args = '' ) {
|
|
1347 |
*
|
1348 |
* If you are deleting an activity comment please use bp_activity_delete_comment();
|
1349 |
*
|
1350 |
-
* @since BuddyPress (1.0)
|
1351 |
*
|
1352 |
* @see BP_Activity_Activity::get() For more information on accepted arguments.
|
1353 |
* @uses wp_parse_args()
|
@@ -1369,7 +1453,7 @@ function bp_activity_get_activity_id( $args = '' ) {
|
|
1369 |
function bp_activity_delete( $args = '' ) {
|
1370 |
|
1371 |
// Pass one or more the of following variables to delete by those variables
|
1372 |
-
$
|
1373 |
'id' => false,
|
1374 |
'action' => false,
|
1375 |
'content' => false,
|
@@ -1381,23 +1465,22 @@ function bp_activity_delete( $args = '' ) {
|
|
1381 |
'secondary_item_id' => false,
|
1382 |
'date_recorded' => false,
|
1383 |
'hide_sitewide' => false
|
1384 |
-
);
|
1385 |
-
|
1386 |
-
$args = wp_parse_args( $args, $defaults );
|
1387 |
|
1388 |
do_action( 'bp_before_activity_delete', $args );
|
1389 |
|
1390 |
// Adjust the new mention count of any mentioned member
|
1391 |
bp_activity_adjust_mention_count( $args['id'], 'delete' );
|
1392 |
|
1393 |
-
|
|
|
1394 |
return false;
|
|
|
1395 |
|
1396 |
// Check if the user's latest update has been deleted
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
$user_id = $args['user_id'];
|
1401 |
|
1402 |
$latest_update = bp_get_user_meta( $user_id, 'bp_latest_update', true );
|
1403 |
if ( !empty( $latest_update ) ) {
|
@@ -1419,7 +1502,7 @@ function bp_activity_delete( $args = '' ) {
|
|
1419 |
*
|
1420 |
* You should use bp_activity_delete() instead.
|
1421 |
*
|
1422 |
-
* @since BuddyPress (1.1)
|
1423 |
* @deprecated BuddyPress (1.2)
|
1424 |
*
|
1425 |
* @uses wp_parse_args()
|
@@ -1432,23 +1515,21 @@ function bp_activity_delete( $args = '' ) {
|
|
1432 |
*/
|
1433 |
function bp_activity_delete_by_item_id( $args = '' ) {
|
1434 |
|
1435 |
-
$
|
1436 |
'item_id' => false,
|
1437 |
'component' => false,
|
1438 |
'type' => false,
|
1439 |
'user_id' => false,
|
1440 |
'secondary_item_id' => false
|
1441 |
-
);
|
1442 |
-
$r = wp_parse_args( $args, $defaults );
|
1443 |
-
extract( $r, EXTR_SKIP );
|
1444 |
|
1445 |
-
return bp_activity_delete(
|
1446 |
}
|
1447 |
|
1448 |
/**
|
1449 |
* Delete an activity item by activity id.
|
1450 |
*
|
1451 |
-
* @since BuddyPress (1.1)
|
1452 |
*
|
1453 |
* @uses bp_activity_delete()
|
1454 |
*
|
@@ -1464,7 +1545,7 @@ function bp_activity_delete( $args = '' ) {
|
|
1464 |
*
|
1465 |
* You should use bp_activity_delete() instead.
|
1466 |
*
|
1467 |
-
* @since BuddyPress (1.1)
|
1468 |
* @deprecated BuddyPress (1.2)
|
1469 |
*
|
1470 |
* @uses bp_activity_delete()
|
@@ -1476,7 +1557,12 @@ function bp_activity_delete( $args = '' ) {
|
|
1476 |
* @return bool True on success, false on failure.
|
1477 |
*/
|
1478 |
function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
|
1479 |
-
return bp_activity_delete( array(
|
|
|
|
|
|
|
|
|
|
|
1480 |
}
|
1481 |
|
1482 |
/**
|
@@ -1484,7 +1570,7 @@ function bp_activity_delete( $args = '' ) {
|
|
1484 |
*
|
1485 |
* You should use bp_activity_delete() instead.
|
1486 |
*
|
1487 |
-
* @since BuddyPress (1.1)
|
1488 |
* @deprecated BuddyPress (1.2)
|
1489 |
*
|
1490 |
* @uses bp_activity_delete()
|
@@ -1494,13 +1580,16 @@ function bp_activity_delete( $args = '' ) {
|
|
1494 |
* @return bool True on success, false on failure.
|
1495 |
*/
|
1496 |
function bp_activity_delete_for_user_by_component( $user_id, $component ) {
|
1497 |
-
return bp_activity_delete( array(
|
|
|
|
|
|
|
1498 |
}
|
1499 |
|
1500 |
/**
|
1501 |
* Delete an activity comment.
|
1502 |
*
|
1503 |
-
* @since BuddyPress (1.2)
|
1504 |
*
|
1505 |
* @uses apply_filters() To call the 'bp_activity_delete_comment_pre' hook.
|
1506 |
* @uses bp_activity_delete_children()
|
@@ -1522,15 +1611,17 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
|
|
1522 |
* You may want to hook into this filter if you want to override this function and
|
1523 |
* handle the deletion of child comments differently. Make sure you return false.
|
1524 |
*/
|
1525 |
-
if ( !apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) )
|
1526 |
return false;
|
|
|
1527 |
|
1528 |
// Delete any children of this comment.
|
1529 |
bp_activity_delete_children( $activity_id, $comment_id );
|
1530 |
|
1531 |
// Delete the actual comment
|
1532 |
-
if ( !bp_activity_delete( array( 'id' => $comment_id, 'type' => 'activity_comment' ) ) )
|
1533 |
return false;
|
|
|
1534 |
|
1535 |
// Recalculate the comment tree
|
1536 |
BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id );
|
@@ -1543,24 +1634,34 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
|
|
1543 |
/**
|
1544 |
* Delete an activity comment's children.
|
1545 |
*
|
1546 |
-
* @since BuddyPress (1.2)
|
1547 |
*
|
1548 |
* @uses BP_Activity_Activity::get_child_comments() {@link BP_Activity_Activity}
|
1549 |
* @uses bp_activity_delete_children()
|
1550 |
* @uses bp_activity_delete()
|
1551 |
*
|
1552 |
* @param int $activity_id The ID of the "root" activity, ie the
|
1553 |
-
*
|
1554 |
* @param int $comment_id The ID of the comment to be deleted.
|
1555 |
*/
|
1556 |
-
function bp_activity_delete_children( $activity_id, $comment_id) {
|
|
|
|
|
|
|
|
|
1557 |
// Recursively delete all children of this comment.
|
1558 |
-
if (
|
1559 |
foreach( (array) $children as $child ) {
|
1560 |
bp_activity_delete_children( $activity_id, $child->id );
|
1561 |
}
|
1562 |
}
|
1563 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1564 |
}
|
1565 |
|
1566 |
/**
|
@@ -1571,7 +1672,7 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
|
|
1571 |
* be sure to pass the full $activity_obj parameter as well, if you already
|
1572 |
* have it available.
|
1573 |
*
|
1574 |
-
* @since BuddyPress (1.2)
|
1575 |
*
|
1576 |
* @uses bp_get_root_domain()
|
1577 |
* @uses bp_get_activity_root_slug()
|
@@ -1583,8 +1684,9 @@ function bp_activity_delete_comment( $activity_id, $comment_id ) {
|
|
1583 |
*/
|
1584 |
function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
|
1585 |
|
1586 |
-
if ( empty( $activity_obj ) )
|
1587 |
$activity_obj = new BP_Activity_Activity( $activity_id );
|
|
|
1588 |
|
1589 |
if ( isset( $activity_obj->current_comment ) ) {
|
1590 |
$activity_obj = $activity_obj->current_comment;
|
@@ -1606,7 +1708,7 @@ function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
|
|
1606 |
/**
|
1607 |
* Hide a user's activity.
|
1608 |
*
|
1609 |
-
* @since BuddyPress (1.2)
|
1610 |
*
|
1611 |
* @uses BP_Activity_Activity::hide_all_for_user() {@link BP_Activity_Activity}
|
1612 |
*
|
@@ -1627,18 +1729,18 @@ function bp_activity_hide_user_activity( $user_id ) {
|
|
1627 |
* through the content, grabs the first image and converts it to a thumbnail,
|
1628 |
* and removes the rest of the images from the string.
|
1629 |
*
|
1630 |
-
* @since BuddyPress (1.2)
|
1631 |
*
|
1632 |
* @uses esc_attr()
|
1633 |
* @uses apply_filters() To call the 'bp_activity_thumbnail_content_images' hook
|
1634 |
*
|
1635 |
* @param string $content The content of the activity item.
|
1636 |
* @param string $link Optional. The unescaped URL that the image should link
|
1637 |
-
*
|
1638 |
-
* @param array $
|
1639 |
-
*
|
1640 |
* @return string $content The content with images stripped and replaced with a
|
1641 |
-
*
|
1642 |
*/
|
1643 |
function bp_activity_thumbnail_content_images( $content, $link = false, $args = false ) {
|
1644 |
|
@@ -1648,17 +1750,18 @@ function bp_activity_thumbnail_content_images( $content, $link = false, $args =
|
|
1648 |
$content = preg_replace('|(\[caption(.*?)\])?<img[^>]*>([^\[\[]*\[\/caption\])?|', '', $content );
|
1649 |
|
1650 |
if ( !empty( $matches ) && !empty( $matches[0] ) ) {
|
|
|
1651 |
// Get the SRC value
|
1652 |
-
preg_match( '/<img.*?(src\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i',
|
1653 |
|
1654 |
// Get the width and height
|
1655 |
preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height );
|
1656 |
preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width );
|
1657 |
|
1658 |
if ( !empty( $src ) ) {
|
1659 |
-
$src = substr( substr( str_replace( 'src=',
|
1660 |
$height = substr( substr( str_replace( 'height=', '', $height[1] ), 0, -1 ), 1 );
|
1661 |
-
$width = substr( substr( str_replace( 'width=',
|
1662 |
|
1663 |
if ( empty( $width ) || empty( $height ) ) {
|
1664 |
$width = 100;
|
@@ -1684,7 +1787,7 @@ function bp_activity_thumbnail_content_images( $content, $link = false, $args =
|
|
1684 |
/**
|
1685 |
* Fetch whether the current user is allowed to mark items as spam.
|
1686 |
*
|
1687 |
-
* @since BuddyPress (1.6)
|
1688 |
*
|
1689 |
* @return bool True if user is allowed to mark activity items as spam.
|
1690 |
*/
|
@@ -1695,17 +1798,15 @@ function bp_activity_user_can_mark_spam() {
|
|
1695 |
/**
|
1696 |
* Mark an activity item as spam.
|
1697 |
*
|
1698 |
-
* @since BuddyPress (1.6)
|
1699 |
-
*
|
1700 |
-
* @global object $bp BuddyPress global settings.
|
1701 |
*
|
1702 |
* @param BP_Activity_Activity $activity The activity item to be spammed.
|
1703 |
* @param string $source Optional. Default is "by_a_person" (ie, a person has
|
1704 |
-
*
|
1705 |
-
*
|
1706 |
*/
|
1707 |
function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
|
1708 |
-
|
1709 |
|
1710 |
$activity->is_spam = 1;
|
1711 |
|
@@ -1735,17 +1836,15 @@ function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
|
|
1735 |
/**
|
1736 |
* Mark an activity item as ham.
|
1737 |
*
|
1738 |
-
* @since BuddyPress (1.6)
|
1739 |
-
*
|
1740 |
-
* @global object $bp BuddyPress global settings.
|
1741 |
*
|
1742 |
* @param BP_Activity_Activity $activity The activity item to be hammed.
|
1743 |
* @param string $source Optional. Default is "by_a_person" (ie, a person has
|
1744 |
-
*
|
1745 |
-
*
|
1746 |
*/
|
1747 |
function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
|
1748 |
-
|
1749 |
|
1750 |
$activity->is_spam = 0;
|
1751 |
|
@@ -1785,7 +1884,7 @@ function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
|
|
1785 |
* This does not cover recursive activity comments, as they do not use a real loop.
|
1786 |
* For that, see {@link bp_activity_comment_embed()}.
|
1787 |
*
|
1788 |
-
* @since BuddyPress (1.5)
|
1789 |
*
|
1790 |
* @see BP_Embed
|
1791 |
* @see bp_embed_activity_cache()
|
@@ -1809,7 +1908,7 @@ add_action( 'activity_loop_start', 'bp_activity_embed' );
|
|
1809 |
* necessary to grab each comment's embeds from the cache, or put them in
|
1810 |
* the cache if they are not there yet.
|
1811 |
*
|
1812 |
-
* @since BuddyPress (1.5)
|
1813 |
*
|
1814 |
* @see BP_Embed
|
1815 |
* @see bp_embed_activity_cache()
|
@@ -1828,10 +1927,9 @@ add_action( 'bp_before_activity_comment', 'bp_activity_comment_embed' );
|
|
1828 |
/**
|
1829 |
* When a user clicks on a "Read More" item, make sure embeds are correctly parsed and shown for the expanded content.
|
1830 |
*
|
1831 |
-
* @since BuddyPress (1.5)
|
1832 |
*
|
1833 |
* @see BP_Embed
|
1834 |
-
* @global object $bp BuddyPress global settings
|
1835 |
* @uses add_filter() To attach create_function() to 'embed_post_id'.
|
1836 |
* @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'.
|
1837 |
* @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'.
|
@@ -1839,15 +1937,14 @@ add_action( 'bp_before_activity_comment', 'bp_activity_comment_embed' );
|
|
1839 |
* @param object $activity The activity that is being expanded.
|
1840 |
*/
|
1841 |
function bp_dtheme_embed_read_more( $activity ) {
|
1842 |
-
|
1843 |
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
add_filter( 'bp_embed_get_cache', 'bp_embed_activity_cache', 10, 3 );
|
1848 |
-
add_action( 'bp_embed_update_cache', 'bp_embed_activity_save_cache', 10, 3 );
|
1849 |
}
|
1850 |
-
add_action( 'bp_dtheme_get_single_activity_content',
|
|
|
1851 |
|
1852 |
/**
|
1853 |
* Clean up 'embed_post_id' filter after comment recursion.
|
@@ -1855,7 +1952,7 @@ add_action( 'bp_dtheme_get_single_activity_content', 'bp_dtheme_embed_read_more'
|
|
1855 |
* This filter must be removed so that the non-comment filters take over again
|
1856 |
* once the comments are done being processed.
|
1857 |
*
|
1858 |
-
* @since BuddyPress (1.5)
|
1859 |
*
|
1860 |
* @see bp_activity_comment_embed()
|
1861 |
* @uses remove_filter() To remove 'bp_get_activity_comment_id' from 'embed_post_id'.
|
@@ -1870,13 +1967,13 @@ add_action( 'bp_after_activity_comment', 'bp_activity_comment_embed_after_recurs
|
|
1870 |
*
|
1871 |
* Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
|
1872 |
*
|
1873 |
-
* @since BuddyPress (1.5)
|
1874 |
*
|
1875 |
* @see BP_Embed::parse_oembed()
|
1876 |
* @uses bp_activity_get_meta()
|
1877 |
*
|
1878 |
* @param string $cache An empty string passed by BP_Embed::parse_oembed() for
|
1879 |
-
*
|
1880 |
* @param int $id The ID of the activity item.
|
1881 |
* @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
|
1882 |
* @return mixed The cached embeds for this activity item.
|
@@ -1890,15 +1987,15 @@ function bp_embed_activity_cache( $cache, $id, $cachekey ) {
|
|
1890 |
*
|
1891 |
* Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
|
1892 |
*
|
1893 |
-
* @since BuddyPress (1.5)
|
1894 |
*
|
1895 |
* @see BP_Embed::parse_oembed()
|
1896 |
* @uses bp_activity_update_meta()
|
1897 |
*
|
1898 |
* @param string $cache An empty string passed by BP_Embed::parse_oembed() for
|
1899 |
-
*
|
1900 |
-
* @param int $id The ID of the activity item.
|
1901 |
* @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
|
|
|
1902 |
* @return bool True on success, false on failure.
|
1903 |
*/
|
1904 |
function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
|
15 |
/**
|
16 |
* Check whether the $bp global lists an activity directory page.
|
17 |
*
|
18 |
+
* @since BuddyPress (1.5.0)
|
|
|
|
|
19 |
*
|
20 |
* @return bool True if activity directory page is found, otherwise false.
|
21 |
*/
|
22 |
function bp_activity_has_directory() {
|
23 |
+
return (bool) !empty( buddypress()->pages->activity->id );
|
|
|
|
|
24 |
}
|
25 |
|
26 |
/**
|
38 |
*
|
39 |
* add_filter( 'bp_activity_do_mentions', '__return_false' );
|
40 |
*
|
41 |
+
* @since BuddyPress (1.8.0)
|
42 |
*
|
43 |
* @uses apply_filters() To call 'bp_activity_do_mentions' hook.
|
44 |
*
|
48 |
return (bool) apply_filters( 'bp_activity_do_mentions', true );
|
49 |
}
|
50 |
|
51 |
+
/**
|
52 |
+
* Should BuddyPress load the mentions scripts and related assets, including results to prime the
|
53 |
+
* mentions suggestions?
|
54 |
+
*
|
55 |
+
* @return bool True if mentions scripts should be loaded.
|
56 |
+
* @since BuddyPress (2.1.0)
|
57 |
+
*/
|
58 |
+
function bp_activity_maybe_load_mentions_scripts() {
|
59 |
+
$retval =
|
60 |
+
bp_activity_do_mentions() &&
|
61 |
+
bp_is_user_active() &&
|
62 |
+
( bp_is_activity_component() || bp_is_blog_page() && is_singular() && comments_open() || is_admin() );
|
63 |
+
|
64 |
+
return (bool) apply_filters( 'bp_activity_maybe_load_mentions_scripts', $retval );
|
65 |
+
}
|
66 |
+
|
67 |
/**
|
68 |
* Locate usernames in an activity content string, as designated by an @ sign.
|
69 |
*
|
70 |
+
* @since BuddyPress (1.5.0)
|
71 |
*
|
72 |
+
* @param string $content The content of the activity, usually found in
|
73 |
+
* $activity->content.
|
74 |
+
* @return array|bool Associative array with user ID as key and username as
|
75 |
+
* value. Boolean false if no mentions found.
|
76 |
*/
|
77 |
function bp_activity_find_mentions( $content ) {
|
78 |
+
|
79 |
$pattern = '/[@]+([A-Za-z0-9-_\.@]+)\b/';
|
80 |
preg_match_all( $pattern, $content, $usernames );
|
81 |
|
82 |
// Make sure there's only one instance of each username
|
83 |
+
$usernames = array_unique( $usernames[1] );
|
84 |
+
|
85 |
+
// Bail if no usernames
|
86 |
+
if ( empty( $usernames ) ) {
|
87 |
return false;
|
88 |
+
}
|
89 |
|
90 |
$mentioned_users = array();
|
91 |
|
92 |
// We've found some mentions! Check to see if users exist
|
93 |
+
foreach( (array) array_values( $usernames ) as $username ) {
|
94 |
$user_id = bp_activity_get_userid_from_mentionname( $username );
|
95 |
|
96 |
// user ID exists, so let's add it to our array
|
97 |
if ( ! empty( $user_id ) ) {
|
98 |
+
$mentioned_users[ $user_id ] = $username;
|
99 |
}
|
100 |
}
|
101 |
|
102 |
+
if ( empty( $mentioned_users ) ) {
|
103 |
return false;
|
104 |
+
}
|
105 |
|
106 |
return $mentioned_users;
|
107 |
}
|
109 |
/**
|
110 |
* Reset a user's unread mentions list and count.
|
111 |
*
|
112 |
+
* @since BuddyPress (1.5.0)
|
113 |
*
|
114 |
* @uses bp_delete_user_meta()
|
115 |
*
|
117 |
*/
|
118 |
function bp_activity_clear_new_mentions( $user_id ) {
|
119 |
bp_delete_user_meta( $user_id, 'bp_new_mention_count' );
|
120 |
+
bp_delete_user_meta( $user_id, 'bp_new_mentions' );
|
121 |
}
|
122 |
|
123 |
/**
|
128 |
*
|
129 |
* Currently, only used in {@link bp_activity_delete()}.
|
130 |
*
|
131 |
+
* @since BuddyPress (1.5.0)
|
132 |
*
|
133 |
* @uses bp_activity_find_mentions()
|
134 |
* @uses bp_activity_update_mention_count_for_user()
|
137 |
* @param string $action Can be 'delete' or 'add'. Defaults to 'add'.
|
138 |
*/
|
139 |
function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
|
140 |
+
|
141 |
+
// Bail if no activity ID passed
|
142 |
+
if ( empty( $activity_id ) ) {
|
143 |
return false;
|
144 |
+
}
|
145 |
|
146 |
// Get activity object
|
147 |
+
$activity = new BP_Activity_Activity( (int) $activity_id );
|
148 |
|
149 |
// Try to find mentions
|
150 |
$usernames = bp_activity_find_mentions( strip_tags( $activity->content ) );
|
151 |
|
152 |
// Still empty? Stop now
|
153 |
+
if ( empty( $usernames ) ) {
|
154 |
return false;
|
155 |
+
}
|
156 |
|
157 |
// Increment mention count foreach mentioned user
|
158 |
+
foreach( (array) array_keys( $usernames ) as $user_id ) {
|
159 |
bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action );
|
160 |
}
|
161 |
}
|
166 |
* This function should be used when you've already parsed your activity item
|
167 |
* for @mentions.
|
168 |
*
|
169 |
+
* @since BuddyPress (1.7.0)
|
170 |
*
|
171 |
* @uses bp_get_user_meta()
|
172 |
* @uses bp_update_user_meta()
|
177 |
* @return bool
|
178 |
*/
|
179 |
function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action = 'add' ) {
|
180 |
+
|
181 |
+
if ( empty( $user_id ) || empty( $activity_id ) ) {
|
182 |
return false;
|
183 |
+
}
|
184 |
|
185 |
// Adjust the mention list and count for the member
|
186 |
$new_mention_count = (int) bp_get_user_meta( $user_id, 'bp_new_mention_count', true );
|
187 |
+
$new_mentions = bp_get_user_meta( $user_id, 'bp_new_mentions', true );
|
188 |
+
|
189 |
+
// Make sure new mentions is an array
|
190 |
+
if ( empty( $new_mentions ) ) {
|
191 |
$new_mentions = array();
|
192 |
+
}
|
193 |
|
194 |
switch ( $action ) {
|
195 |
case 'delete' :
|
305 |
* @param string $type The action type.
|
306 |
* @param string $description The action description.
|
307 |
* @param callable $format_callback Callback for formatting the action string.
|
308 |
+
* @param string $label String to describe this action in the activity stream
|
309 |
+
* filter dropdown.
|
310 |
+
* @param array $context Activity stream contexts where the filter should appear.
|
311 |
+
* 'activity', 'member', 'member_groups', 'group'
|
312 |
* @return bool False if any param is empty, otherwise true.
|
313 |
*/
|
314 |
+
function bp_activity_set_action( $component_id, $type, $description, $format_callback = false, $label = false, $context = array() ) {
|
315 |
$bp = buddypress();
|
316 |
|
317 |
// Return false if any of the above values are not set
|
337 |
'key' => $type,
|
338 |
'value' => $description,
|
339 |
'format_callback' => $format_callback,
|
340 |
+
'label' => $label,
|
341 |
+
'context' => $context,
|
342 |
+
), $component_id, $type, $description, $format_callback, $label, $context );
|
343 |
|
344 |
return true;
|
345 |
}
|
347 |
/**
|
348 |
* Retreive the current action from a component and key.
|
349 |
*
|
350 |
+
* @since BuddyPress (1.1.0)
|
351 |
*
|
|
|
352 |
* @uses apply_filters() To call the 'bp_activity_get_action' hook.
|
353 |
*
|
354 |
* @param string $component_id The unique string ID of the component.
|
356 |
* @return string|bool Action value if found, otherwise false.
|
357 |
*/
|
358 |
function bp_activity_get_action( $component_id, $key ) {
|
|
|
359 |
|
360 |
// Return false if any of the above values are not set
|
361 |
+
if ( empty( $component_id ) || empty( $key ) ) {
|
362 |
return false;
|
363 |
+
}
|
364 |
+
|
365 |
+
$bp = buddypress();
|
366 |
+
$retval = isset( $bp->activity->actions->{$component_id}->{$key} )
|
367 |
+
? $bp->activity->actions->{$component_id}->{$key}
|
368 |
+
: false;
|
369 |
|
370 |
+
return apply_filters( 'bp_activity_get_action', $retval, $component_id, $key );
|
371 |
}
|
372 |
|
373 |
/**
|
374 |
* Fetch details of all registered activity types.
|
375 |
*
|
376 |
+
* @since BuddyPress (1.7.0)
|
377 |
*
|
378 |
* @return array array( type => description ), ...
|
379 |
*/
|
384 |
foreach ( buddypress()->activity->actions as $action ) {
|
385 |
$action = array_values( (array) $action );
|
386 |
|
387 |
+
for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) {
|
388 |
$actions[ $action[$i]['key'] ] = $action[$i]['value'];
|
389 |
+
}
|
390 |
}
|
391 |
|
392 |
// This was a mis-named activity type from before BP 1.6
|
400 |
/**
|
401 |
* Get a users favorite activity stream items.
|
402 |
*
|
403 |
+
* @since BuddyPress (1.2.0)
|
404 |
*
|
405 |
* @uses bp_get_user_meta()
|
406 |
* @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook.
|
411 |
function bp_activity_get_user_favorites( $user_id = 0 ) {
|
412 |
|
413 |
// Fallback to logged in user if no user_id is passed
|
414 |
+
if ( empty( $user_id ) ) {
|
415 |
$user_id = bp_displayed_user_id();
|
416 |
+
}
|
417 |
|
418 |
// Get favorites for user
|
419 |
$favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
|
424 |
/**
|
425 |
* Add an activity stream item as a favorite for a user.
|
426 |
*
|
427 |
+
* @since BuddyPress (1.2.0)
|
428 |
*
|
429 |
* @uses is_user_logged_in()
|
430 |
* @uses bp_get_user_meta()
|
441 |
function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
|
442 |
|
443 |
// Favorite activity stream items are for logged in users only
|
444 |
+
if ( ! is_user_logged_in() ) {
|
445 |
return false;
|
446 |
+
}
|
447 |
|
448 |
// Fallback to logged in user if no user_id is passed
|
449 |
+
if ( empty( $user_id ) ) {
|
450 |
$user_id = bp_loggedin_user_id();
|
451 |
+
}
|
452 |
|
453 |
$my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
|
454 |
if ( empty( $my_favs ) || ! is_array( $my_favs ) ) {
|
491 |
/**
|
492 |
* Remove an activity stream item as a favorite for a user.
|
493 |
*
|
494 |
+
* @since BuddyPress (1.2.0)
|
495 |
*
|
496 |
* @uses is_user_logged_in()
|
497 |
* @uses bp_get_user_meta()
|
507 |
function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
|
508 |
|
509 |
// Favorite activity stream items are for logged in users only
|
510 |
+
if ( ! is_user_logged_in() ) {
|
511 |
return false;
|
512 |
+
}
|
513 |
|
514 |
// Fallback to logged in user if no user_id is passed
|
515 |
+
if ( empty( $user_id ) ) {
|
516 |
$user_id = bp_loggedin_user_id();
|
517 |
+
}
|
518 |
|
519 |
$my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
|
520 |
$my_favs = array_flip( (array) $my_favs );
|
529 |
$my_favs = array_unique( array_flip( $my_favs ) );
|
530 |
|
531 |
// Update the total number of users who have favorited this activity
|
532 |
+
$fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' );
|
533 |
+
if ( ! empty( $fav_count ) ) {
|
534 |
|
535 |
// Deduct from total favorites
|
536 |
if ( bp_activity_update_meta( $activity_id, 'favorite_count', (int) $fav_count - 1 ) ) {
|
563 |
/**
|
564 |
* Check whether an activity item exists with a given content string.
|
565 |
*
|
566 |
+
* @since BuddyPress (1.1.0)
|
567 |
*
|
568 |
* @uses BP_Activity_Activity::check_exists_by_content() {@link BP_Activity_Activity}
|
569 |
* @uses apply_filters() To call the 'bp_activity_check_exists_by_content' hook.
|
578 |
/**
|
579 |
* Retrieve the last time activity was updated.
|
580 |
*
|
581 |
+
* @since BuddyPress (1.0.0)
|
582 |
*
|
583 |
* @uses BP_Activity_Activity::get_last_updated() {@link BP_Activity_Activity}
|
584 |
* @uses apply_filters() To call the 'bp_activity_get_last_updated' hook.
|
592 |
/**
|
593 |
* Retrieve the number of favorite activity stream items a user has.
|
594 |
*
|
595 |
+
* @since BuddyPress (1.2.0)
|
596 |
*
|
597 |
* @uses BP_Activity_Activity::total_favorite_count() {@link BP_Activity_Activity}
|
598 |
*
|
602 |
function bp_activity_total_favorites_for_user( $user_id = 0 ) {
|
603 |
|
604 |
// Fallback on displayed user, and then logged in user
|
605 |
+
if ( empty( $user_id ) ) {
|
606 |
$user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
|
607 |
+
}
|
608 |
|
609 |
return BP_Activity_Activity::total_favorite_count( $user_id );
|
610 |
}
|
632 |
* @return bool True on success, false on failure.
|
633 |
*/
|
634 |
function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '', $delete_all = false ) {
|
|
|
635 |
|
636 |
// Legacy - if no meta_key is passed, delete all for the item
|
637 |
if ( empty( $meta_key ) ) {
|
658 |
/**
|
659 |
* Get metadata for a given activity item.
|
660 |
*
|
661 |
+
* @since BuddyPress (1.2.0)
|
662 |
*
|
663 |
* @uses apply_filters() To call the 'bp_activity_get_meta' hook.
|
664 |
*
|
683 |
/**
|
684 |
* Update a piece of activity meta.
|
685 |
*
|
686 |
+
* @since BuddyPress (1.2.0)
|
687 |
*
|
688 |
* @param int $activity_id ID of the activity item whose metadata is being
|
689 |
* updated.
|
712 |
* @param int $activity_id ID of the activity item.
|
713 |
* @param string $meta_key Metadata key.
|
714 |
* @param mixed $meta_value Metadata value.
|
715 |
+
* @param bool $unique Optional. Whether to enforce a single metadata value
|
716 |
* for the given key. If true, and the object already has a value for
|
717 |
* the key, no change will be made. Default: false.
|
718 |
* @return int|bool The meta ID on successful update, false on failure.
|
730 |
/**
|
731 |
* Completely remove a user's activity data.
|
732 |
*
|
733 |
+
* @since BuddyPress (1.5.0)
|
734 |
*
|
735 |
* @uses is_user_logged_in()
|
736 |
* @uses bp_activity_delete()
|
743 |
function bp_activity_remove_all_user_data( $user_id = 0 ) {
|
744 |
|
745 |
// Do not delete user data unless a logged in user says so
|
746 |
+
if ( empty( $user_id ) || ! is_user_logged_in() ) {
|
747 |
return false;
|
748 |
+
}
|
749 |
|
750 |
// Clear the user's activity from the sitewide stream and clear their activity tables
|
751 |
bp_activity_delete( array( 'user_id' => $user_id ) );
|
752 |
|
753 |
// Remove any usermeta
|
754 |
+
bp_delete_user_meta( $user_id, 'bp_latest_update' );
|
755 |
bp_delete_user_meta( $user_id, 'bp_favorite_activities' );
|
756 |
|
757 |
// Execute additional code
|
766 |
/**
|
767 |
* Mark all of the user's activity as spam.
|
768 |
*
|
769 |
+
* @since BuddyPress (1.6.0)
|
770 |
*
|
771 |
* @global object $wpdb WordPress database access object.
|
772 |
* @global object $bp BuddyPress global settings.
|
774 |
* @param int $user_id ID of the user whose activity is being spammed.
|
775 |
*/
|
776 |
function bp_activity_spam_all_user_data( $user_id = 0 ) {
|
777 |
+
global $wpdb;
|
778 |
|
779 |
// Do not delete user data unless a logged in user says so
|
780 |
+
if ( empty( $user_id ) || ! is_user_logged_in() ) {
|
781 |
return false;
|
782 |
+
}
|
783 |
|
784 |
// Get all the user's activities.
|
785 |
+
$activities = bp_activity_get( array(
|
786 |
+
'display_comments' => 'stream',
|
787 |
+
'filter' => array( 'user_id' => $user_id ),
|
788 |
+
'show_hidden' => true
|
789 |
+
) );
|
790 |
+
|
791 |
+
$bp = buddypress();
|
792 |
|
793 |
// Mark each as spam
|
794 |
foreach ( (array) $activities['activities'] as $activity ) {
|
795 |
|
796 |
// Create an activity object
|
797 |
$activity_obj = new BP_Activity_Activity;
|
798 |
+
foreach ( $activity as $k => $v ) {
|
799 |
$activity_obj->$k = $v;
|
800 |
+
}
|
801 |
|
802 |
// Mark as spam
|
803 |
bp_activity_mark_as_spam( $activity_obj );
|
809 |
* as we're going to be updating all the activity statuses directly, for efficency,
|
810 |
* we need to update manually.
|
811 |
*/
|
812 |
+
if ( ! empty( $bp->activity->akismet ) ) {
|
813 |
$bp->activity->akismet->update_activity_spam_meta( $activity_obj );
|
814 |
+
}
|
815 |
|
816 |
// Tidy up
|
817 |
unset( $activity_obj );
|
828 |
/**
|
829 |
* Mark all of the user's activity as ham (not spam).
|
830 |
*
|
831 |
+
* @since BuddyPress (1.6.0)
|
832 |
*
|
833 |
* @global object $wpdb WordPress database access object.
|
834 |
* @global object $bp BuddyPress global settings.
|
836 |
* @param int $user_id ID of the user whose activity is being hammed.
|
837 |
*/
|
838 |
function bp_activity_ham_all_user_data( $user_id = 0 ) {
|
839 |
+
global $wpdb;
|
840 |
|
841 |
// Do not delete user data unless a logged in user says so
|
842 |
+
if ( empty( $user_id ) || ! is_user_logged_in() ) {
|
843 |
return false;
|
844 |
+
}
|
845 |
|
846 |
// Get all the user's activities.
|
847 |
+
$activities = bp_activity_get( array(
|
848 |
+
'display_comments' => 'stream',
|
849 |
+
'filter' => array( 'user_id' => $user_id ),
|
850 |
+
'show_hidden' => true,
|
851 |
+
'spam' => 'all'
|
852 |
+
) );
|
853 |
+
|
854 |
+
$bp = buddypress();
|
855 |
|
856 |
// Mark each as not spam
|
857 |
foreach ( (array) $activities['activities'] as $activity ) {
|
858 |
|
859 |
// Create an activity object
|
860 |
$activity_obj = new BP_Activity_Activity;
|
861 |
+
foreach ( $activity as $k => $v ) {
|
862 |
$activity_obj->$k = $v;
|
863 |
+
}
|
864 |
|
865 |
// Mark as not spam
|
866 |
bp_activity_mark_as_ham( $activity_obj );
|
872 |
* as we're going to be updating all the activity statuses directly, for efficency,
|
873 |
* we need to update manually.
|
874 |
*/
|
875 |
+
if ( ! empty( $bp->activity->akismet ) ) {
|
876 |
$bp->activity->akismet->update_activity_ham_meta( $activity_obj );
|
877 |
+
}
|
878 |
|
879 |
// Tidy up
|
880 |
unset( $activity_obj );
|
891 |
/**
|
892 |
* Register the activity stream actions for updates
|
893 |
*
|
894 |
+
* @since BuddyPress (1.6.0)
|
|
|
|
|
895 |
*/
|
896 |
function bp_activity_register_activity_actions() {
|
897 |
+
$bp = buddypress();
|
898 |
|
899 |
bp_activity_set_action(
|
900 |
$bp->activity->id,
|
901 |
'activity_update',
|
902 |
__( 'Posted a status update', 'buddypress' ),
|
903 |
+
'bp_activity_format_activity_action_activity_update',
|
904 |
+
__( 'Updates', 'buddypress' ),
|
905 |
+
array( 'activity', 'group', 'member', 'member_groups' )
|
906 |
);
|
907 |
|
908 |
bp_activity_set_action(
|
909 |
$bp->activity->id,
|
910 |
'activity_comment',
|
911 |
__( 'Replied to a status update', 'buddypress' ),
|
912 |
+
'bp_activity_format_activity_action_activity_comment',
|
913 |
+
__( 'Activity Comments', 'buddypress' )
|
914 |
);
|
915 |
|
916 |
do_action( 'bp_activity_register_activity_actions' );
|
928 |
* the formatted action string.
|
929 |
*/
|
930 |
function bp_activity_generate_action_string( $activity ) {
|
931 |
+
|
932 |
// Check for valid input
|
933 |
if ( empty( $activity->component ) || empty( $activity->type ) ) {
|
934 |
return false;
|
995 |
* the default for the bp_activity_get()).
|
996 |
* - 'per_page' (false)
|
997 |
*
|
998 |
+
* @since BuddyPress (1.2.0)
|
999 |
*
|
1000 |
* @see BP_Activity_Activity::get() For more information on accepted arguments
|
1001 |
* and the format of the returned value.
|
1009 |
* @return array $activity See BP_Activity_Activity::get() for description.
|
1010 |
*/
|
1011 |
function bp_activity_get( $args = '' ) {
|
1012 |
+
|
1013 |
+
$r = bp_parse_args( $args, array(
|
1014 |
'max' => false, // Maximum number of results to return
|
1015 |
'page' => 1, // page 1 without a per_page will result in no pagination.
|
1016 |
'per_page' => false, // results per page
|
1019 |
|
1020 |
'search_terms' => false, // Pass search terms as a string
|
1021 |
'meta_query' => false, // Filter by activity meta. See WP_Meta_Query for format
|
1022 |
+
'date_query' => false, // Filter by date. See first parameter of WP_Date_Query for format
|
1023 |
'show_hidden' => false, // Show activity items that are hidden site-wide?
|
1024 |
'exclude' => false, // Comma-separated list of activity IDs to exclude
|
1025 |
'in' => false, // Comma-separated list or array of activity IDs to which you want to limit the query
|
1026 |
'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'.
|
1027 |
'update_meta_cache' => true,
|
1028 |
+
'count_total' => false,
|
1029 |
|
1030 |
/**
|
1031 |
* Pass filters as an array -- all filter items can be multiple values comma separated:
|
1038 |
* );
|
1039 |
*/
|
1040 |
'filter' => array()
|
1041 |
+
) );
|
|
|
|
|
1042 |
|
1043 |
// Attempt to return a cached copy of the first page of sitewide activity.
|
1044 |
+
if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['date_query'] ) && empty( $r['filter'] ) && empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) {
|
1045 |
+
|
1046 |
+
$activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' );
|
1047 |
+
if ( false === $activity ) {
|
1048 |
+
|
1049 |
+
$activity = BP_Activity_Activity::get( array(
|
1050 |
+
'page' => $r['page'],
|
1051 |
+
'per_page' => $r['per_page'],
|
1052 |
+
'max' => $r['max'],
|
1053 |
+
'sort' => $r['sort'],
|
1054 |
+
'search_terms' => $r['search_terms'],
|
1055 |
+
'meta_query' => $r['meta_query'],
|
1056 |
+
'date_query' => $r['date_query'],
|
1057 |
+
'filter' => $r['filter'],
|
1058 |
+
'display_comments' => $r['display_comments'],
|
1059 |
+
'show_hidden' => $r['show_hidden'],
|
1060 |
+
'spam' => $r['spam'],
|
1061 |
+
'update_meta_cache' => $r['update_meta_cache'],
|
1062 |
+
'count_total' => $r['count_total'],
|
1063 |
+
) );
|
1064 |
+
|
1065 |
wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' );
|
1066 |
}
|
1067 |
|
1068 |
} else {
|
1069 |
+
$activity = BP_Activity_Activity::get( array(
|
1070 |
+
'page' => $r['page'],
|
1071 |
+
'per_page' => $r['per_page'],
|
1072 |
+
'max' => $r['max'],
|
1073 |
+
'sort' => $r['sort'],
|
1074 |
+
'search_terms' => $r['search_terms'],
|
1075 |
+
'meta_query' => $r['meta_query'],
|
1076 |
+
'date_query' => $r['date_query'],
|
1077 |
+
'filter' => $r['filter'],
|
1078 |
+
'display_comments' => $r['display_comments'],
|
1079 |
+
'show_hidden' => $r['show_hidden'],
|
1080 |
+
'exclude' => $r['exclude'],
|
1081 |
+
'in' => $r['in'],
|
1082 |
+
'spam' => $r['spam'],
|
1083 |
+
'count_total' => $r['count_total'],
|
1084 |
+
) );
|
1085 |
}
|
1086 |
|
1087 |
return apply_filters_ref_array( 'bp_activity_get', array( &$activity, &$r ) );
|
1090 |
/**
|
1091 |
* Fetch specific activity items.
|
1092 |
*
|
1093 |
+
* @since BuddyPress (1.2.0)
|
1094 |
*
|
1095 |
* @see BP_Activity_Activity::get() For more information on accepted arguments
|
1096 |
* @uses wp_parse_args()
|
1106 |
* @return array $activity See BP_Activity_Activity::get() for description.
|
1107 |
*/
|
1108 |
function bp_activity_get_specific( $args = '' ) {
|
1109 |
+
|
1110 |
+
$r = bp_parse_args( $args, array(
|
1111 |
+
'activity_ids' => false, // A single activity_id or array of IDs.
|
1112 |
+
'display_comments' => false, // true or false to display threaded comments for these specific activity items
|
1113 |
+
'max' => false, // Maximum number of results to return
|
1114 |
+
'page' => 1, // page 1 without a per_page will result in no pagination.
|
1115 |
+
'per_page' => false, // results per page
|
1116 |
+
'show_hidden' => true, // When fetching specific items, show all
|
1117 |
+
'sort' => 'DESC', // sort ASC or DESC
|
1118 |
+
'spam' => 'ham_only', // Retrieve items marked as spam
|
1119 |
'update_meta_cache' => true,
|
1120 |
+
) );
|
|
|
|
|
1121 |
|
1122 |
$get_args = array(
|
1123 |
+
'display_comments' => $r['display_comments'],
|
1124 |
+
'in' => $r['activity_ids'],
|
1125 |
+
'max' => $r['max'],
|
1126 |
+
'page' => $r['page'],
|
1127 |
+
'per_page' => $r['per_page'],
|
1128 |
+
'show_hidden' => $r['show_hidden'],
|
1129 |
+
'sort' => $r['sort'],
|
1130 |
+
'spam' => $r['spam'],
|
1131 |
+
'update_meta_cache' => $r['update_meta_cache'],
|
1132 |
);
|
1133 |
+
|
1134 |
return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $get_args ), $args, $get_args );
|
1135 |
}
|
1136 |
|
1137 |
/**
|
1138 |
* Add an activity item.
|
1139 |
*
|
1140 |
+
* @since BuddyPress (1.1.0)
|
1141 |
*
|
1142 |
* @uses wp_parse_args()
|
1143 |
* @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
|
1180 |
*/
|
1181 |
function bp_activity_add( $args = '' ) {
|
1182 |
|
1183 |
+
$r = bp_parse_args( $args, array(
|
1184 |
+
'id' => false, // Pass an existing activity ID to update an existing entry.
|
1185 |
+
'action' => '', // The activity action - e.g. "Jon Doe posted an update"
|
1186 |
+
'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
|
1187 |
+
'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent
|
1188 |
+
'type' => false, // The activity type e.g. activity_update, profile_updated
|
1189 |
+
'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
|
1190 |
+
'user_id' => bp_loggedin_user_id(), // Optional: The user to record the activity for, can be false if this activity is not for a user.
|
1191 |
+
'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
|
1192 |
+
'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
|
|
|
|
|
|
|
1193 |
'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded
|
1194 |
+
'hide_sitewide' => false, // Should this be hidden on the sitewide activity stream?
|
1195 |
+
'is_spam' => false, // Is this activity item to be marked as spam?
|
1196 |
+
) );
|
|
|
|
|
1197 |
|
1198 |
// Make sure we are backwards compatible
|
1199 |
+
if ( empty( $r['component'] ) && !empty( $r['component_name'] ) ) {
|
1200 |
+
$r['component'] = $r['component_name'];
|
1201 |
+
}
|
1202 |
|
1203 |
+
if ( empty( $r['type'] ) && !empty( $r['component_action'] ) ) {
|
1204 |
+
$r['type'] = $r['component_action'];
|
1205 |
+
}
|
1206 |
|
1207 |
// Setup activity to be added
|
1208 |
+
$activity = new BP_Activity_Activity( $r['id'] );
|
1209 |
+
$activity->user_id = $r['user_id'];
|
1210 |
+
$activity->component = $r['component'];
|
1211 |
+
$activity->type = $r['type'];
|
1212 |
+
$activity->content = $r['content'];
|
1213 |
+
$activity->primary_link = $r['primary_link'];
|
1214 |
+
$activity->item_id = $r['item_id'];
|
1215 |
+
$activity->secondary_item_id = $r['secondary_item_id'];
|
1216 |
+
$activity->date_recorded = $r['recorded_time'];
|
1217 |
+
$activity->hide_sitewide = $r['hide_sitewide'];
|
1218 |
+
$activity->is_spam = $r['is_spam'];
|
1219 |
+
$activity->action = ! empty( $r['action'] )
|
1220 |
+
? $r['action']
|
1221 |
+
: bp_activity_generate_action_string( $activity );
|
1222 |
+
|
1223 |
+
if ( ! $activity->save() ) {
|
1224 |
return false;
|
1225 |
+
}
|
1226 |
|
1227 |
// If this is an activity comment, rebuild the tree
|
1228 |
+
if ( 'activity_comment' === $activity->type ) {
|
1229 |
BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id );
|
1230 |
+
}
|
1231 |
|
1232 |
wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
|
1233 |
+
do_action( 'bp_activity_add', $r );
|
1234 |
|
1235 |
return $activity->id;
|
1236 |
}
|
1238 |
/**
|
1239 |
* Post an activity update.
|
1240 |
*
|
1241 |
+
* @since BuddyPress (1.2.0)
|
1242 |
*
|
|
|
1243 |
* @uses wp_parse_args()
|
1244 |
* @uses bp_is_user_inactive()
|
1245 |
* @uses bp_core_get_userlink()
|
1258 |
* @return int $activity_id The activity id
|
1259 |
*/
|
1260 |
function bp_activity_post_update( $args = '' ) {
|
|
|
1261 |
|
1262 |
+
$r = wp_parse_args( $args, array(
|
1263 |
'content' => false,
|
1264 |
'user_id' => bp_loggedin_user_id()
|
1265 |
+
) );
|
|
|
|
|
1266 |
|
1267 |
+
if ( empty( $r['content'] ) || !strlen( trim( $r['content'] ) ) ) {
|
1268 |
return false;
|
1269 |
+
}
|
1270 |
|
1271 |
+
if ( bp_is_user_inactive( $r['user_id'] ) ) {
|
1272 |
return false;
|
1273 |
+
}
|
1274 |
|
1275 |
// Record this on the user's profile
|
1276 |
+
$activity_content = $r['content'];
|
1277 |
+
$primary_link = bp_core_get_userlink( $r['user_id'], false, true );
|
|
|
1278 |
|
1279 |
// Now write the values
|
1280 |
$activity_id = bp_activity_add( array(
|
1281 |
+
'user_id' => $r['user_id'],
|
1282 |
'content' => apply_filters( 'bp_activity_new_update_content', $activity_content ),
|
1283 |
'primary_link' => apply_filters( 'bp_activity_new_update_primary_link', $primary_link ),
|
1284 |
+
'component' => buddypress()->activity->id,
|
1285 |
'type' => 'activity_update',
|
1286 |
) );
|
1287 |
|
1288 |
+
$activity_content = apply_filters( 'bp_activity_latest_update_content', $r['content'], $activity_content );
|
1289 |
|
1290 |
// Add this update to the "latest update" usermeta so it can be fetched anywhere.
|
1291 |
+
bp_update_user_meta( bp_loggedin_user_id(), 'bp_latest_update', array(
|
1292 |
+
'id' => $activity_id,
|
1293 |
+
'content' => $activity_content
|
1294 |
+
) );
|
1295 |
|
1296 |
+
do_action( 'bp_activity_posted_update', $r['content'], $r['user_id'], $activity_id );
|
1297 |
|
1298 |
return $activity_id;
|
1299 |
}
|
1301 |
/**
|
1302 |
* Add an activity comment.
|
1303 |
*
|
1304 |
+
* @since BuddyPress (1.2.0)
|
1305 |
*
|
1306 |
* @global object $bp BuddyPress global settings.
|
1307 |
* @uses wp_parse_args()
|
1316 |
* @type int $id Optional. Pass an ID to update an existing comment.
|
1317 |
* @type string $content The content of the comment.
|
1318 |
* @type int $user_id Optional. The ID of the user making the comment.
|
1319 |
+
* Defaults to the ID of the logged-in user.
|
1320 |
* @type int $activity_id The ID of the "root" activity item, ie the oldest
|
1321 |
+
* ancestor of the comment.
|
1322 |
* @type int $parent_id Optional. The ID of the parent activity item, ie the
|
1323 |
+
* item to which the comment is an immediate reply. If not provided,
|
1324 |
+
* this value defaults to the $activity_id.
|
1325 |
* }
|
1326 |
* @return int|bool The ID of the comment on success, otherwise false.
|
1327 |
*/
|
1328 |
function bp_activity_new_comment( $args = '' ) {
|
1329 |
|
1330 |
+
$r = wp_parse_args( $args, array(
|
1331 |
'id' => false,
|
1332 |
'content' => false,
|
1333 |
'user_id' => bp_loggedin_user_id(),
|
1335 |
'parent_id' => false // ID of a parent comment (optional)
|
1336 |
) );
|
1337 |
|
|
|
|
|
1338 |
// Bail if missing necessary data
|
1339 |
+
if ( empty( $r['content'] ) || empty( $r['user_id'] ) || empty( $r['activity_id'] ) ) {
|
1340 |
return false;
|
1341 |
}
|
1342 |
|
1343 |
// Maybe set current activity ID as the parent
|
1344 |
+
if ( empty( $r['parent_id'] ) ) {
|
1345 |
+
$r['parent_id'] = $r['activity_id'];
|
1346 |
}
|
1347 |
|
1348 |
+
$activity_id = $r['activity_id'];
|
1349 |
+
|
1350 |
// Check to see if the parent activity is hidden, and if so, hide this comment publically.
|
1351 |
$activity = new BP_Activity_Activity( $activity_id );
|
1352 |
$is_hidden = ( (int) $activity->hide_sitewide ) ? 1 : 0;
|
1353 |
|
1354 |
// Insert the activity comment
|
1355 |
$comment_id = bp_activity_add( array(
|
1356 |
+
'id' => $r['id'],
|
1357 |
+
'content' => apply_filters( 'bp_activity_comment_content', $r['content'] ),
|
1358 |
'component' => buddypress()->activity->id,
|
1359 |
'type' => 'activity_comment',
|
1360 |
+
'user_id' => $r['user_id'],
|
1361 |
'item_id' => $activity_id,
|
1362 |
+
'secondary_item_id' => $r['parent_id'],
|
1363 |
'hide_sitewide' => $is_hidden
|
1364 |
) );
|
1365 |
|
1367 |
wp_cache_delete( $activity_id, 'bp_activity_comments' );
|
1368 |
|
1369 |
// Walk the tree to clear caches for all parent items
|
1370 |
+
$clear_id = $r['parent_id'];
|
1371 |
while ( $clear_id != $activity_id ) {
|
1372 |
$clear_object = new BP_Activity_Activity( $clear_id );
|
1373 |
wp_cache_delete( $clear_id, 'bp_activity' );
|
1375 |
}
|
1376 |
wp_cache_delete( $activity_id, 'bp_activity' );
|
1377 |
|
1378 |
+
do_action( 'bp_activity_comment_posted', $comment_id, $r, $activity );
|
1379 |
|
1380 |
return $comment_id;
|
1381 |
}
|
1383 |
/**
|
1384 |
* Fetch the activity_id for an existing activity entry in the DB.
|
1385 |
*
|
1386 |
+
* @since BuddyPress (1.2.0)
|
1387 |
*
|
1388 |
* @see BP_Activity_Activity::get() For more information on accepted arguments.
|
1389 |
* @uses wp_parse_args()
|
1394 |
* @return int $activity_id The ID of the activity item found.
|
1395 |
*/
|
1396 |
function bp_activity_get_activity_id( $args = '' ) {
|
1397 |
+
|
1398 |
+
$r = bp_parse_args( $args, array(
|
1399 |
'user_id' => false,
|
1400 |
'component' => false,
|
1401 |
'type' => false,
|
1404 |
'action' => false,
|
1405 |
'content' => false,
|
1406 |
'date_recorded' => false,
|
1407 |
+
) );
|
|
|
|
|
|
|
1408 |
|
1409 |
+
return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id(
|
1410 |
+
$r['user_id'],
|
1411 |
+
$r['component'],
|
1412 |
+
$r['type'],
|
1413 |
+
$r['item_id'],
|
1414 |
+
$r['secondary_item_id'],
|
1415 |
+
$r['action'],
|
1416 |
+
$r['content'],
|
1417 |
+
$r['date_recorded']
|
1418 |
+
) );
|
1419 |
}
|
1420 |
|
1421 |
/**
|
1431 |
*
|
1432 |
* If you are deleting an activity comment please use bp_activity_delete_comment();
|
1433 |
*
|
1434 |
+
* @since BuddyPress (1.0.0)
|
1435 |
*
|
1436 |
* @see BP_Activity_Activity::get() For more information on accepted arguments.
|
1437 |
* @uses wp_parse_args()
|
1453 |
function bp_activity_delete( $args = '' ) {
|
1454 |
|
1455 |
// Pass one or more the of following variables to delete by those variables
|
1456 |
+
$args = bp_parse_args( $args, array(
|
1457 |
'id' => false,
|
1458 |
'action' => false,
|
1459 |
'content' => false,
|
1465 |
'secondary_item_id' => false,
|
1466 |
'date_recorded' => false,
|
1467 |
'hide_sitewide' => false
|
1468 |
+
) );
|
|
|
|
|
1469 |
|
1470 |
do_action( 'bp_before_activity_delete', $args );
|
1471 |
|
1472 |
// Adjust the new mention count of any mentioned member
|
1473 |
bp_activity_adjust_mention_count( $args['id'], 'delete' );
|
1474 |
|
1475 |
+
$activity_ids_deleted = BP_Activity_Activity::delete( $args );
|
1476 |
+
if ( empty( $activity_ids_deleted ) ) {
|
1477 |
return false;
|
1478 |
+
}
|
1479 |
|
1480 |
// Check if the user's latest update has been deleted
|
1481 |
+
$user_id = empty( $args['user_id'] )
|
1482 |
+
? bp_loggedin_user_id()
|
1483 |
+
: $args['user_id'];
|
|
|
1484 |
|
1485 |
$latest_update = bp_get_user_meta( $user_id, 'bp_latest_update', true );
|
1486 |
if ( !empty( $latest_update ) ) {
|
1502 |
*
|
1503 |
* You should use bp_activity_delete() instead.
|
1504 |
*
|
1505 |
+
* @since BuddyPress (1.1.0)
|
1506 |
* @deprecated BuddyPress (1.2)
|
1507 |
*
|
1508 |
* @uses wp_parse_args()
|
1515 |
*/
|
1516 |
function bp_activity_delete_by_item_id( $args = '' ) {
|
1517 |
|
1518 |
+
$r = bp_parse_args( $args, array(
|
1519 |
'item_id' => false,
|
1520 |
'component' => false,
|
1521 |
'type' => false,
|
1522 |
'user_id' => false,
|
1523 |
'secondary_item_id' => false
|
1524 |
+
) );
|
|
|
|
|
1525 |
|
1526 |
+
return bp_activity_delete( $r );
|
1527 |
}
|
1528 |
|
1529 |
/**
|
1530 |
* Delete an activity item by activity id.
|
1531 |
*
|
1532 |
+
* @since BuddyPress (1.1.0)
|
1533 |
*
|
1534 |
* @uses bp_activity_delete()
|
1535 |
*
|
1545 |
*
|
1546 |
* You should use bp_activity_delete() instead.
|
1547 |
*
|
1548 |
+
* @since BuddyPress (1.1.0)
|
1549 |
* @deprecated BuddyPress (1.2)
|
1550 |
*
|
1551 |
* @uses bp_activity_delete()
|
1557 |
* @return bool True on success, false on failure.
|
1558 |
*/
|
1559 |
function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
|
1560 |
+
return bp_activity_delete( array(
|
1561 |
+
'user_id' => $user_id,
|
1562 |
+
'content' => $content,
|
1563 |
+
'component' => $component,
|
1564 |
+
'type' => $type
|
1565 |
+
) );
|
1566 |
}
|
1567 |
|
1568 |
/**
|
1570 |
*
|
1571 |
* You should use bp_activity_delete() instead.
|
1572 |
*
|
1573 |
+
* @since BuddyPress (1.1.0)
|
1574 |
* @deprecated BuddyPress (1.2)
|
1575 |
*
|
1576 |
* @uses bp_activity_delete()
|
1580 |
* @return bool True on success, false on failure.
|
1581 |
*/
|
1582 |
function bp_activity_delete_for_user_by_component( $user_id, $component ) {
|
1583 |
+
return bp_activity_delete( array(
|
1584 |
+
'user_id' => $user_id,
|
1585 |
+
'component' => $component
|
1586 |
+
) );
|
1587 |
}
|
1588 |
|
1589 |
/**
|
1590 |
* Delete an activity comment.
|
1591 |
*
|
1592 |
+
* @since BuddyPress (1.2.0)
|
1593 |
*
|
1594 |
* @uses apply_filters() To call the 'bp_activity_delete_comment_pre' hook.
|
1595 |
* @uses bp_activity_delete_children()
|
1611 |
* You may want to hook into this filter if you want to override this function and
|
1612 |
* handle the deletion of child comments differently. Make sure you return false.
|
1613 |
*/
|
1614 |
+
if ( ! apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) ) {
|
1615 |
return false;
|
1616 |
+
}
|
1617 |
|
1618 |
// Delete any children of this comment.
|
1619 |
bp_activity_delete_children( $activity_id, $comment_id );
|
1620 |
|
1621 |
// Delete the actual comment
|
1622 |
+
if ( ! bp_activity_delete( array( 'id' => $comment_id, 'type' => 'activity_comment' ) ) ) {
|
1623 |
return false;
|
1624 |
+
}
|
1625 |
|
1626 |
// Recalculate the comment tree
|
1627 |
BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id );
|
1634 |
/**
|
1635 |
* Delete an activity comment's children.
|
1636 |
*
|
1637 |
+
* @since BuddyPress (1.2.0)
|
1638 |
*
|
1639 |
* @uses BP_Activity_Activity::get_child_comments() {@link BP_Activity_Activity}
|
1640 |
* @uses bp_activity_delete_children()
|
1641 |
* @uses bp_activity_delete()
|
1642 |
*
|
1643 |
* @param int $activity_id The ID of the "root" activity, ie the
|
1644 |
+
* comment's oldest ancestor.
|
1645 |
* @param int $comment_id The ID of the comment to be deleted.
|
1646 |
*/
|
1647 |
+
function bp_activity_delete_children( $activity_id, $comment_id ) {
|
1648 |
+
|
1649 |
+
// Get activity children to delete
|
1650 |
+
$children = BP_Activity_Activity::get_child_comments( $comment_id );
|
1651 |
+
|
1652 |
// Recursively delete all children of this comment.
|
1653 |
+
if ( ! empty( $children ) ) {
|
1654 |
foreach( (array) $children as $child ) {
|
1655 |
bp_activity_delete_children( $activity_id, $child->id );
|
1656 |
}
|
1657 |
}
|
1658 |
+
|
1659 |
+
// Delete the comment itself
|
1660 |
+
bp_activity_delete( array(
|
1661 |
+
'secondary_item_id' => $comment_id,
|
1662 |
+
'type' => 'activity_comment',
|
1663 |
+
'item_id' => $activity_id
|
1664 |
+
) );
|
1665 |
}
|
1666 |
|
1667 |
/**
|
1672 |
* be sure to pass the full $activity_obj parameter as well, if you already
|
1673 |
* have it available.
|
1674 |
*
|
1675 |
+
* @since BuddyPress (1.2.0)
|
1676 |
*
|
1677 |
* @uses bp_get_root_domain()
|
1678 |
* @uses bp_get_activity_root_slug()
|
1684 |
*/
|
1685 |
function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
|
1686 |
|
1687 |
+
if ( empty( $activity_obj ) ) {
|
1688 |
$activity_obj = new BP_Activity_Activity( $activity_id );
|
1689 |
+
}
|
1690 |
|
1691 |
if ( isset( $activity_obj->current_comment ) ) {
|
1692 |
$activity_obj = $activity_obj->current_comment;
|
1708 |
/**
|
1709 |
* Hide a user's activity.
|
1710 |
*
|
1711 |
+
* @since BuddyPress (1.2.0)
|
1712 |
*
|
1713 |
* @uses BP_Activity_Activity::hide_all_for_user() {@link BP_Activity_Activity}
|
1714 |
*
|
1729 |
* through the content, grabs the first image and converts it to a thumbnail,
|
1730 |
* and removes the rest of the images from the string.
|
1731 |
*
|
1732 |
+
* @since BuddyPress (1.2.0)
|
1733 |
*
|
1734 |
* @uses esc_attr()
|
1735 |
* @uses apply_filters() To call the 'bp_activity_thumbnail_content_images' hook
|
1736 |
*
|
1737 |
* @param string $content The content of the activity item.
|
1738 |
* @param string $link Optional. The unescaped URL that the image should link
|
1739 |
+
* to. If absent, the image will not be a link.
|
1740 |
+
* @param array $args Optional. The args passed to the activity
|
1741 |
+
* creation function (eg bp_blogs_record_activity()).
|
1742 |
* @return string $content The content with images stripped and replaced with a
|
1743 |
+
* single thumb.
|
1744 |
*/
|
1745 |
function bp_activity_thumbnail_content_images( $content, $link = false, $args = false ) {
|
1746 |
|
1750 |
$content = preg_replace('|(\[caption(.*?)\])?<img[^>]*>([^\[\[]*\[\/caption\])?|', '', $content );
|
1751 |
|
1752 |
if ( !empty( $matches ) && !empty( $matches[0] ) ) {
|
1753 |
+
|
1754 |
// Get the SRC value
|
1755 |
+
preg_match( '/<img.*?(src\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $src );
|
1756 |
|
1757 |
// Get the width and height
|
1758 |
preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height );
|
1759 |
preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width );
|
1760 |
|
1761 |
if ( !empty( $src ) ) {
|
1762 |
+
$src = substr( substr( str_replace( 'src=', '', $src[1] ), 0, -1 ), 1 );
|
1763 |
$height = substr( substr( str_replace( 'height=', '', $height[1] ), 0, -1 ), 1 );
|
1764 |
+
$width = substr( substr( str_replace( 'width=', '', $width[1] ), 0, -1 ), 1 );
|
1765 |
|
1766 |
if ( empty( $width ) || empty( $height ) ) {
|
1767 |
$width = 100;
|
1787 |
/**
|
1788 |
* Fetch whether the current user is allowed to mark items as spam.
|
1789 |
*
|
1790 |
+
* @since BuddyPress (1.6.0)
|
1791 |
*
|
1792 |
* @return bool True if user is allowed to mark activity items as spam.
|
1793 |
*/
|
1798 |
/**
|
1799 |
* Mark an activity item as spam.
|
1800 |
*
|
1801 |
+
* @since BuddyPress (1.6.0)
|
|
|
|
|
1802 |
*
|
1803 |
* @param BP_Activity_Activity $activity The activity item to be spammed.
|
1804 |
* @param string $source Optional. Default is "by_a_person" (ie, a person has
|
1805 |
+
* manually marked the activity as spam). BP core also accepts
|
1806 |
+
* 'by_akismet'.
|
1807 |
*/
|
1808 |
function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) {
|
1809 |
+
$bp = buddypress();
|
1810 |
|
1811 |
$activity->is_spam = 1;
|
1812 |
|
1836 |
/**
|
1837 |
* Mark an activity item as ham.
|
1838 |
*
|
1839 |
+
* @since BuddyPress (1.6.0)
|
|
|
|
|
1840 |
*
|
1841 |
* @param BP_Activity_Activity $activity The activity item to be hammed.
|
1842 |
* @param string $source Optional. Default is "by_a_person" (ie, a person has
|
1843 |
+
* manually marked the activity as spam). BP core also accepts
|
1844 |
+
* 'by_akismet'.
|
1845 |
*/
|
1846 |
function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) {
|
1847 |
+
$bp = buddypress();
|
1848 |
|
1849 |
$activity->is_spam = 0;
|
1850 |
|
1884 |
* This does not cover recursive activity comments, as they do not use a real loop.
|
1885 |
* For that, see {@link bp_activity_comment_embed()}.
|
1886 |
*
|
1887 |
+
* @since BuddyPress (1.5.0)
|
1888 |
*
|
1889 |
* @see BP_Embed
|
1890 |
* @see bp_embed_activity_cache()
|
1908 |
* necessary to grab each comment's embeds from the cache, or put them in
|
1909 |
* the cache if they are not there yet.
|
1910 |
*
|
1911 |
+
* @since BuddyPress (1.5.0)
|
1912 |
*
|
1913 |
* @see BP_Embed
|
1914 |
* @see bp_embed_activity_cache()
|
1927 |
/**
|
1928 |
* When a user clicks on a "Read More" item, make sure embeds are correctly parsed and shown for the expanded content.
|
1929 |
*
|
1930 |
+
* @since BuddyPress (1.5.0)
|
1931 |
*
|
1932 |
* @see BP_Embed
|
|
|
1933 |
* @uses add_filter() To attach create_function() to 'embed_post_id'.
|
1934 |
* @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'.
|
1935 |
* @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'.
|
1937 |
* @param object $activity The activity that is being expanded.
|
1938 |
*/
|
1939 |
function bp_dtheme_embed_read_more( $activity ) {
|
1940 |
+
buddypress()->activity->read_more_id = $activity->id;
|
1941 |
|
1942 |
+
add_filter( 'embed_post_id', create_function( '', 'return buddypress()->activity->read_more_id;' ) );
|
1943 |
+
add_filter( 'bp_embed_get_cache', 'bp_embed_activity_cache', 10, 3 );
|
1944 |
+
add_action( 'bp_embed_update_cache', 'bp_embed_activity_save_cache', 10, 3 );
|
|
|
|
|
1945 |
}
|
1946 |
+
add_action( 'bp_dtheme_get_single_activity_content', 'bp_dtheme_embed_read_more' );
|
1947 |
+
add_action( 'bp_legacy_theme_get_single_activity_content', 'bp_dtheme_embed_read_more' );
|
1948 |
|
1949 |
/**
|
1950 |
* Clean up 'embed_post_id' filter after comment recursion.
|
1952 |
* This filter must be removed so that the non-comment filters take over again
|
1953 |
* once the comments are done being processed.
|
1954 |
*
|
1955 |
+
* @since BuddyPress (1.5.0)
|
1956 |
*
|
1957 |
* @see bp_activity_comment_embed()
|
1958 |
* @uses remove_filter() To remove 'bp_get_activity_comment_id' from 'embed_post_id'.
|
1967 |
*
|
1968 |
* Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
|
1969 |
*
|
1970 |
+
* @since BuddyPress (1.5.0)
|
1971 |
*
|
1972 |
* @see BP_Embed::parse_oembed()
|
1973 |
* @uses bp_activity_get_meta()
|
1974 |
*
|
1975 |
* @param string $cache An empty string passed by BP_Embed::parse_oembed() for
|
1976 |
+
* functions like this one to filter.
|
1977 |
* @param int $id The ID of the activity item.
|
1978 |
* @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
|
1979 |
* @return mixed The cached embeds for this activity item.
|
1987 |
*
|
1988 |
* Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
|
1989 |
*
|
1990 |
+
* @since BuddyPress (1.5.0)
|
1991 |
*
|
1992 |
* @see BP_Embed::parse_oembed()
|
1993 |
* @uses bp_activity_update_meta()
|
1994 |
*
|
1995 |
* @param string $cache An empty string passed by BP_Embed::parse_oembed() for
|
1996 |
+
* functions like this one to filter.
|
|
|
1997 |
* @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
|
1998 |
+
* @param int $id The ID of the activity item.
|
1999 |
* @return bool True on success, false on failure.
|
2000 |
*/
|
2001 |
function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
|
@@ -47,6 +47,7 @@ class BP_Activity_Component extends BP_Component {
|
|
47 |
public function includes( $includes = array() ) {
|
48 |
// Files to include
|
49 |
$includes = array(
|
|
|
50 |
'actions',
|
51 |
'screens',
|
52 |
'filters',
|
@@ -106,7 +107,7 @@ class BP_Activity_Component extends BP_Component {
|
|
106 |
'slug' => BP_ACTIVITY_SLUG,
|
107 |
'root_slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG,
|
108 |
'has_directory' => true,
|
109 |
-
'directory_title' => _x( '
|
110 |
'notification_callback' => 'bp_activity_format_notifications',
|
111 |
'search_string' => __( 'Search Activity...', 'buddypress' ),
|
112 |
'global_tables' => $global_tables,
|
@@ -136,7 +137,7 @@ class BP_Activity_Component extends BP_Component {
|
|
136 |
|
137 |
// Add 'Activity' to the main navigation
|
138 |
$main_nav = array(
|
139 |
-
'name' =>
|
140 |
'slug' => $this->slug,
|
141 |
'position' => 10,
|
142 |
'screen_function' => 'bp_activity_screen_my_activity',
|
@@ -162,7 +163,7 @@ class BP_Activity_Component extends BP_Component {
|
|
162 |
|
163 |
// Add the subnav items to the activity nav item if we are using a theme that supports this
|
164 |
$sub_nav[] = array(
|
165 |
-
'name' =>
|
166 |
'slug' => 'just-me',
|
167 |
'parent_url' => $activity_link,
|
168 |
'parent_slug' => $this->slug,
|
@@ -173,7 +174,7 @@ class BP_Activity_Component extends BP_Component {
|
|
173 |
// @ mentions
|
174 |
if ( bp_activity_do_mentions() ) {
|
175 |
$sub_nav[] = array(
|
176 |
-
'name' =>
|
177 |
'slug' => 'mentions',
|
178 |
'parent_url' => $activity_link,
|
179 |
'parent_slug' => $this->slug,
|
@@ -185,7 +186,7 @@ class BP_Activity_Component extends BP_Component {
|
|
185 |
|
186 |
// Favorite activity items
|
187 |
$sub_nav[] = array(
|
188 |
-
'name' =>
|
189 |
'slug' => 'favorites',
|
190 |
'parent_url' => $activity_link,
|
191 |
'parent_slug' => $this->slug,
|
@@ -197,7 +198,7 @@ class BP_Activity_Component extends BP_Component {
|
|
197 |
// Additional menu if friends is active
|
198 |
if ( bp_is_active( 'friends' ) ) {
|
199 |
$sub_nav[] = array(
|
200 |
-
'name' =>
|
201 |
'slug' => bp_get_friends_slug(),
|
202 |
'parent_url' => $activity_link,
|
203 |
'parent_slug' => $this->slug,
|
@@ -210,7 +211,7 @@ class BP_Activity_Component extends BP_Component {
|
|
210 |
// Additional menu if groups is active
|
211 |
if ( bp_is_active( 'groups' ) ) {
|
212 |
$sub_nav[] = array(
|
213 |
-
'name' =>
|
214 |
'slug' => bp_get_groups_slug(),
|
215 |
'parent_url' => $activity_link,
|
216 |
'parent_slug' => $this->slug,
|
@@ -255,9 +256,9 @@ class BP_Activity_Component extends BP_Component {
|
|
255 |
if ( bp_activity_do_mentions() ) {
|
256 |
$count = bp_get_total_mention_count_for_user( bp_loggedin_user_id() );
|
257 |
if ( !empty( $count ) ) {
|
258 |
-
$title = sprintf(
|
259 |
} else {
|
260 |
-
$title =
|
261 |
}
|
262 |
}
|
263 |
|
@@ -265,7 +266,7 @@ class BP_Activity_Component extends BP_Component {
|
|
265 |
$wp_admin_nav[] = array(
|
266 |
'parent' => $bp->my_account_menu_id,
|
267 |
'id' => 'my-account-' . $this->id,
|
268 |
-
'title' =>
|
269 |
'href' => trailingslashit( $activity_link )
|
270 |
);
|
271 |
|
@@ -273,7 +274,7 @@ class BP_Activity_Component extends BP_Component {
|
|
273 |
$wp_admin_nav[] = array(
|
274 |
'parent' => 'my-account-' . $this->id,
|
275 |
'id' => 'my-account-' . $this->id . '-personal',
|
276 |
-
'title' =>
|
277 |
'href' => trailingslashit( $activity_link )
|
278 |
);
|
279 |
|
@@ -291,7 +292,7 @@ class BP_Activity_Component extends BP_Component {
|
|
291 |
$wp_admin_nav[] = array(
|
292 |
'parent' => 'my-account-' . $this->id,
|
293 |
'id' => 'my-account-' . $this->id . '-favorites',
|
294 |
-
'title' =>
|
295 |
'href' => trailingslashit( $activity_link . 'favorites' )
|
296 |
);
|
297 |
|
@@ -300,7 +301,7 @@ class BP_Activity_Component extends BP_Component {
|
|
300 |
$wp_admin_nav[] = array(
|
301 |
'parent' => 'my-account-' . $this->id,
|
302 |
'id' => 'my-account-' . $this->id . '-friends',
|
303 |
-
'title' =>
|
304 |
'href' => trailingslashit( $activity_link . bp_get_friends_slug() )
|
305 |
);
|
306 |
}
|
@@ -310,7 +311,7 @@ class BP_Activity_Component extends BP_Component {
|
|
310 |
$wp_admin_nav[] = array(
|
311 |
'parent' => 'my-account-' . $this->id,
|
312 |
'id' => 'my-account-' . $this->id . '-groups',
|
313 |
-
'title' =>
|
314 |
'href' => trailingslashit( $activity_link . bp_get_groups_slug() )
|
315 |
);
|
316 |
}
|
@@ -334,7 +335,7 @@ class BP_Activity_Component extends BP_Component {
|
|
334 |
// Adjust title based on view
|
335 |
if ( bp_is_activity_component() ) {
|
336 |
if ( bp_is_my_profile() ) {
|
337 |
-
$bp->bp_options_title =
|
338 |
} else {
|
339 |
$bp->bp_options_avatar = bp_core_fetch_avatar( array(
|
340 |
'item_id' => bp_displayed_user_id(),
|
47 |
public function includes( $includes = array() ) {
|
48 |
// Files to include
|
49 |
$includes = array(
|
50 |
+
'cssjs',
|
51 |
'actions',
|
52 |
'screens',
|
53 |
'filters',
|
107 |
'slug' => BP_ACTIVITY_SLUG,
|
108 |
'root_slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG,
|
109 |
'has_directory' => true,
|
110 |
+
'directory_title' => _x( 'Site-Wide Activity', 'component directory title', 'buddypress' ),
|
111 |
'notification_callback' => 'bp_activity_format_notifications',
|
112 |
'search_string' => __( 'Search Activity...', 'buddypress' ),
|
113 |
'global_tables' => $global_tables,
|
137 |
|
138 |
// Add 'Activity' to the main navigation
|
139 |
$main_nav = array(
|
140 |
+
'name' => _x( 'Activity', 'Profile activity screen nav', 'buddypress' ),
|
141 |
'slug' => $this->slug,
|
142 |
'position' => 10,
|
143 |
'screen_function' => 'bp_activity_screen_my_activity',
|
163 |
|
164 |
// Add the subnav items to the activity nav item if we are using a theme that supports this
|
165 |
$sub_nav[] = array(
|
166 |
+
'name' => _x( 'Personal', 'Profile activity screen sub nav', 'buddypress' ),
|
167 |
'slug' => 'just-me',
|
168 |
'parent_url' => $activity_link,
|
169 |
'parent_slug' => $this->slug,
|
174 |
// @ mentions
|
175 |
if ( bp_activity_do_mentions() ) {
|
176 |
$sub_nav[] = array(
|
177 |
+
'name' => _x( 'Mentions', 'Profile activity screen sub nav', 'buddypress' ),
|
178 |
'slug' => 'mentions',
|
179 |
'parent_url' => $activity_link,
|
180 |
'parent_slug' => $this->slug,
|
186 |
|
187 |
// Favorite activity items
|
188 |
$sub_nav[] = array(
|
189 |
+
'name' => _x( 'Favorites', 'Profile activity screen sub nav', 'buddypress' ),
|
190 |
'slug' => 'favorites',
|
191 |
'parent_url' => $activity_link,
|
192 |
'parent_slug' => $this->slug,
|
198 |
// Additional menu if friends is active
|
199 |
if ( bp_is_active( 'friends' ) ) {
|
200 |
$sub_nav[] = array(
|
201 |
+
'name' => _x( 'Friends', 'Profile activity screen sub nav', 'buddypress' ),
|
202 |
'slug' => bp_get_friends_slug(),
|
203 |
'parent_url' => $activity_link,
|
204 |
'parent_slug' => $this->slug,
|
211 |
// Additional menu if groups is active
|
212 |
if ( bp_is_active( 'groups' ) ) {
|
213 |
$sub_nav[] = array(
|
214 |
+
'name' => _x( 'Groups', 'Profile activity screen sub nav', 'buddypress' ),
|
215 |
'slug' => bp_get_groups_slug(),
|
216 |
'parent_url' => $activity_link,
|
217 |
'parent_slug' => $this->slug,
|
256 |
if ( bp_activity_do_mentions() ) {
|
257 |
$count = bp_get_total_mention_count_for_user( bp_loggedin_user_id() );
|
258 |
if ( !empty( $count ) ) {
|
259 |
+
$title = sprintf( _x( 'Mentions <span class="count">%s</span>', 'Toolbar Mention logged in user', 'buddypress' ), number_format_i18n( $count ) );
|
260 |
} else {
|
261 |
+
$title = _x( 'Mentions', 'Toolbar Mention logged in user', 'buddypress' );
|
262 |
}
|
263 |
}
|
264 |
|
266 |
$wp_admin_nav[] = array(
|
267 |
'parent' => $bp->my_account_menu_id,
|
268 |
'id' => 'my-account-' . $this->id,
|
269 |
+
'title' => _x( 'Activity', 'My Account Activity sub nav', 'buddypress' ),
|
270 |
'href' => trailingslashit( $activity_link )
|
271 |
);
|
272 |
|
274 |
$wp_admin_nav[] = array(
|
275 |
'parent' => 'my-account-' . $this->id,
|
276 |
'id' => 'my-account-' . $this->id . '-personal',
|
277 |
+
'title' => _x( 'Personal', 'My Account Activity sub nav', 'buddypress' ),
|
278 |
'href' => trailingslashit( $activity_link )
|
279 |
);
|
280 |
|
292 |
$wp_admin_nav[] = array(
|
293 |
'parent' => 'my-account-' . $this->id,
|
294 |
'id' => 'my-account-' . $this->id . '-favorites',
|
295 |
+
'title' => _x( 'Favorites', 'My Account Activity sub nav', 'buddypress' ),
|
296 |
'href' => trailingslashit( $activity_link . 'favorites' )
|
297 |
);
|
298 |
|
301 |
$wp_admin_nav[] = array(
|
302 |
'parent' => 'my-account-' . $this->id,
|
303 |
'id' => 'my-account-' . $this->id . '-friends',
|
304 |
+
'title' => _x( 'Friends', 'My Account Activity sub nav', 'buddypress' ),
|
305 |
'href' => trailingslashit( $activity_link . bp_get_friends_slug() )
|
306 |
);
|
307 |
}
|
311 |
$wp_admin_nav[] = array(
|
312 |
'parent' => 'my-account-' . $this->id,
|
313 |
'id' => 'my-account-' . $this->id . '-groups',
|
314 |
+
'title' => _x( 'Groups', 'My Account Activity sub nav', 'buddypress' ),
|
315 |
'href' => trailingslashit( $activity_link . bp_get_groups_slug() )
|
316 |
);
|
317 |
}
|
335 |
// Adjust title based on view
|
336 |
if ( bp_is_activity_component() ) {
|
337 |
if ( bp_is_my_profile() ) {
|
338 |
+
$bp->bp_options_title = _x( 'My Activity', 'Page and <title>', 'buddypress' );
|
339 |
} else {
|
340 |
$bp->bp_options_avatar = bp_core_fetch_avatar( array(
|
341 |
'item_id' => bp_displayed_user_id(),
|
@@ -385,7 +385,7 @@ class BP_Activity_Theme_Compat {
|
|
385 |
'post_author' => 0,
|
386 |
'post_date' => 0,
|
387 |
'post_content' => '',
|
388 |
-
'post_type' => '
|
389 |
'post_status' => 'publish',
|
390 |
'is_page' => true,
|
391 |
'comment_status' => 'closed'
|
@@ -438,7 +438,7 @@ class BP_Activity_Theme_Compat {
|
|
438 |
'post_author' => 0,
|
439 |
'post_date' => 0,
|
440 |
'post_content' => '',
|
441 |
-
'post_type' => '
|
442 |
'post_status' => 'publish',
|
443 |
'is_page' => true,
|
444 |
'comment_status' => 'closed'
|
385 |
'post_author' => 0,
|
386 |
'post_date' => 0,
|
387 |
'post_content' => '',
|
388 |
+
'post_type' => 'page',
|
389 |
'post_status' => 'publish',
|
390 |
'is_page' => true,
|
391 |
'comment_status' => 'closed'
|
438 |
'post_author' => 0,
|
439 |
'post_date' => 0,
|
440 |
'post_content' => '',
|
441 |
+
'post_type' => 'page',
|
442 |
'post_status' => 'publish',
|
443 |
'is_page' => true,
|
444 |
'comment_status' => 'closed'
|
@@ -98,6 +98,14 @@ class BP_Activity_Template {
|
|
98 |
|
99 |
var $in_the_loop;
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
var $pag_page;
|
102 |
var $pag_num;
|
103 |
var $pag_links;
|
@@ -170,6 +178,7 @@ class BP_Activity_Template {
|
|
170 |
'filter' => false,
|
171 |
'search_terms' => false,
|
172 |
'meta_query' => false,
|
|
|
173 |
'display_comments' => 'threaded',
|
174 |
'show_hidden' => false,
|
175 |
'spam' => 'ham_only',
|
@@ -178,7 +187,8 @@ class BP_Activity_Template {
|
|
178 |
$r = wp_parse_args( $args, $defaults );
|
179 |
extract( $r );
|
180 |
|
181 |
-
$this->
|
|
|
182 |
$this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
|
183 |
|
184 |
// Check if blog/forum replies are disabled
|
@@ -211,6 +221,7 @@ class BP_Activity_Template {
|
|
211 |
'sort' => $sort,
|
212 |
'search_terms' => $search_terms,
|
213 |
'meta_query' => $meta_query,
|
|
|
214 |
'filter' => $filter,
|
215 |
'show_hidden' => $show_hidden,
|
216 |
'exclude' => $exclude,
|
@@ -220,10 +231,17 @@ class BP_Activity_Template {
|
|
220 |
) );
|
221 |
}
|
222 |
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
|
228 |
$this->activities = $this->activities['activities'];
|
229 |
|
@@ -507,8 +525,9 @@ function bp_has_activities( $args = '' ) {
|
|
507 |
$object = $bp->groups->id;
|
508 |
$primary_id = $bp->groups->current_group->id;
|
509 |
|
510 |
-
if (
|
511 |
$show_hidden = true;
|
|
|
512 |
}
|
513 |
|
514 |
// The default scope should recognize custom slugs
|
@@ -550,6 +569,7 @@ function bp_has_activities( $args = '' ) {
|
|
550 |
'since' => false, // return only items recorded since this Y-m-d H:i:s date
|
551 |
|
552 |
'meta_query' => false, // filter on activity meta. See WP_Meta_Query for format
|
|
|
553 |
|
554 |
// Searching
|
555 |
'search_terms' => false, // specify terms to search on
|
@@ -663,6 +683,7 @@ function bp_has_activities( $args = '' ) {
|
|
663 |
'filter' => $filter,
|
664 |
'search_terms' => $search_terms,
|
665 |
'meta_query' => $meta_query,
|
|
|
666 |
'display_comments' => $display_comments,
|
667 |
'show_hidden' => $show_hidden,
|
668 |
'spam' => $spam,
|
@@ -704,6 +725,23 @@ function bp_the_activity() {
|
|
704 |
return $activities_template->the_activity();
|
705 |
}
|
706 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
707 |
/**
|
708 |
* Output the activity pagination count.
|
709 |
*
|
@@ -734,7 +772,7 @@ function bp_activity_pagination_count() {
|
|
734 |
$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 ) );
|
735 |
$total = bp_core_number_format( $activities_template->total_activity_count );
|
736 |
|
737 |
-
return sprintf( _n( 'Viewing
|
738 |
}
|
739 |
|
740 |
/**
|
@@ -777,13 +815,17 @@ function bp_activity_pagination_links() {
|
|
777 |
function bp_activity_has_more_items() {
|
778 |
global $activities_template;
|
779 |
|
780 |
-
$
|
|
|
|
|
|
|
781 |
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
|
786 |
-
|
|
|
787 |
|
788 |
return apply_filters( 'bp_activity_has_more_items', $has_more_items );
|
789 |
}
|
@@ -1138,10 +1180,11 @@ function bp_activity_user_link() {
|
|
1138 |
function bp_get_activity_user_link() {
|
1139 |
global $activities_template;
|
1140 |
|
1141 |
-
if ( empty( $activities_template->activity->user_id ) )
|
1142 |
$link = $activities_template->activity->primary_link;
|
1143 |
-
else
|
1144 |
$link = bp_core_get_user_domain( $activities_template->activity->user_id, $activities_template->activity->user_nicename, $activities_template->activity->user_login );
|
|
|
1145 |
|
1146 |
return apply_filters( 'bp_get_activity_user_link', $link );
|
1147 |
}
|
@@ -1596,24 +1639,41 @@ function bp_insert_activity_meta( $content ) {
|
|
1596 |
function bp_activity_user_can_delete( $activity = false ) {
|
1597 |
global $activities_template;
|
1598 |
|
1599 |
-
|
|
|
1600 |
$activity = $activities_template->activity;
|
|
|
1601 |
|
1602 |
-
|
|
|
1603 |
$activity = $activity->current_comment;
|
|
|
1604 |
|
|
|
1605 |
$can_delete = false;
|
1606 |
|
1607 |
-
|
1608 |
-
|
1609 |
|
1610 |
-
|
1611 |
-
|
|
|
|
|
1612 |
|
1613 |
-
|
1614 |
-
|
|
|
|
|
|
|
|
|
1615 |
|
1616 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1617 |
}
|
1618 |
|
1619 |
/**
|
@@ -1750,7 +1810,7 @@ function bp_activity_is_favorite() {
|
|
1750 |
function bp_get_activity_is_favorite() {
|
1751 |
global $activities_template;
|
1752 |
|
1753 |
-
return apply_filters( 'bp_get_activity_is_favorite', in_array( $activities_template->activity->id, (array) $activities_template->my_favs ) );
|
1754 |
}
|
1755 |
|
1756 |
/**
|
@@ -2090,63 +2150,65 @@ function bp_activity_comment_count() {
|
|
2090 |
}
|
2091 |
|
2092 |
/**
|
2093 |
-
* Return the
|
2094 |
-
*
|
2095 |
-
* The content is run through two filters. 'bp_get_activity_content'
|
2096 |
-
* will apply all filters applied to activity items in general. Use
|
2097 |
-
* 'bp_activity_comment_content' to modify the content of activity
|
2098 |
-
* comments only.
|
2099 |
*
|
2100 |
* @since BuddyPress (1.2)
|
2101 |
*
|
2102 |
* @global object $activities_template {@link BP_Activity_Template}
|
2103 |
* @uses bp_activity_recurse_comment_count()
|
2104 |
* @uses apply_filters() To call the 'bp_activity_get_comment_count' hook.
|
2105 |
-
* @todo deprecate $args
|
2106 |
*
|
2107 |
-
* @param array $
|
|
|
2108 |
* @return int $count The activity comment count.
|
2109 |
*/
|
2110 |
-
function bp_activity_get_comment_count( $
|
2111 |
global $activities_template;
|
2112 |
|
2113 |
-
|
2114 |
-
|
|
|
|
|
2115 |
|
2116 |
-
|
|
|
|
|
|
|
2117 |
|
2118 |
return apply_filters( 'bp_activity_get_comment_count', (int) $count );
|
2119 |
}
|
2120 |
|
2121 |
/**
|
2122 |
-
* Return the
|
2123 |
*
|
2124 |
-
*
|
2125 |
-
*
|
2126 |
-
* Use bp_activity_comment_content to modify the content of
|
2127 |
-
* activity comments only.
|
2128 |
*
|
2129 |
* @since BuddyPress (1.2)
|
2130 |
*
|
2131 |
* @uses bp_activity_recurse_comment_count()
|
2132 |
-
* @uses apply_filters() To call the '
|
2133 |
-
* @todo investigate why bp_activity_recurse_comment_count() is used while being declared
|
2134 |
*
|
2135 |
* @param object $comment Activity comment object.
|
2136 |
* @param int $count The current iteration count.
|
|
|
2137 |
* @return int $count The activity comment count.
|
2138 |
*/
|
2139 |
function bp_activity_recurse_comment_count( $comment, $count = 0 ) {
|
2140 |
|
2141 |
-
|
2142 |
-
|
2143 |
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
|
|
|
|
|
|
2147 |
}
|
2148 |
|
2149 |
-
return
|
|
|
2150 |
}
|
2151 |
|
2152 |
/**
|
@@ -2326,9 +2388,20 @@ function bp_activity_comment_permalink() {
|
|
2326 |
function bp_get_activity_comment_permalink() {
|
2327 |
global $activities_template;
|
2328 |
|
2329 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2330 |
|
2331 |
-
|
|
|
|
|
|
|
2332 |
}
|
2333 |
|
2334 |
/**
|
@@ -2466,21 +2539,63 @@ function bp_activity_delete_link() {
|
|
2466 |
* if on single activity page.
|
2467 |
*/
|
2468 |
function bp_get_activity_delete_link() {
|
2469 |
-
global $activities_template;
|
2470 |
|
2471 |
-
$url =
|
2472 |
$class = 'delete-activity';
|
2473 |
|
2474 |
// Determine if we're on a single activity page, and customize accordingly
|
2475 |
if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
|
2476 |
-
$url = add_query_arg( array( 'redirect_to' => wp_get_referer() ), $url );
|
2477 |
$class = 'delete-activity-single';
|
2478 |
}
|
2479 |
|
2480 |
-
$link = '<a href="' .
|
|
|
2481 |
return apply_filters( 'bp_get_activity_delete_link', $link );
|
2482 |
}
|
2483 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2484 |
/**
|
2485 |
* Output the activity latest update link.
|
2486 |
*
|
@@ -2642,39 +2757,69 @@ function bp_activity_filter_links( $args = false ) {
|
|
2642 |
function bp_activity_can_comment() {
|
2643 |
global $activities_template;
|
2644 |
|
|
|
2645 |
$can_comment = true;
|
2646 |
|
2647 |
-
|
2648 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2649 |
$can_comment = false;
|
|
|
2650 |
}
|
2651 |
|
2652 |
-
|
2653 |
-
$can_comment = false;
|
2654 |
-
|
2655 |
-
return apply_filters( 'bp_activity_can_comment', $can_comment );
|
2656 |
}
|
2657 |
|
2658 |
/**
|
2659 |
-
* Determine
|
2660 |
*
|
2661 |
-
*
|
2662 |
-
*
|
2663 |
-
* @since BuddyPress (1.5)
|
2664 |
-
*
|
2665 |
-
* @uses apply_filters() To call the 'bp_activity_can_comment_reply' hook
|
2666 |
*
|
2667 |
* @param object $comment Activity comment.
|
2668 |
-
* @return bool $can_comment True if comment can receive comments
|
|
|
2669 |
*/
|
2670 |
-
function bp_activity_can_comment_reply( $comment ) {
|
|
|
|
|
2671 |
$can_comment = true;
|
2672 |
|
2673 |
-
|
2674 |
-
|
|
|
2675 |
}
|
2676 |
|
2677 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2678 |
}
|
2679 |
|
2680 |
/**
|
@@ -2686,12 +2831,10 @@ function bp_activity_can_comment_reply( $comment ) {
|
|
2686 |
*
|
2687 |
* @uses apply_filters() To call the 'bp_activity_can_favorite' hook.
|
2688 |
*
|
2689 |
-
* @return bool
|
2690 |
*/
|
2691 |
function bp_activity_can_favorite() {
|
2692 |
-
|
2693 |
-
|
2694 |
-
return apply_filters( 'bp_activity_can_favorite', $can_favorite );
|
2695 |
}
|
2696 |
|
2697 |
/**
|
@@ -2720,13 +2863,20 @@ function bp_total_favorite_count_for_user( $user_id = 0 ) {
|
|
2720 |
* @return int The total favorite count for the specified user.
|
2721 |
*/
|
2722 |
function bp_get_total_favorite_count_for_user( $user_id = 0 ) {
|
2723 |
-
if ( ! $user_id ) {
|
2724 |
-
$user_id = bp_displayed_user_id();
|
2725 |
-
}
|
2726 |
|
2727 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2728 |
}
|
2729 |
-
|
2730 |
|
2731 |
/**
|
2732 |
* Output the total mention count for a specified user.
|
@@ -2754,13 +2904,19 @@ function bp_total_mention_count_for_user( $user_id = 0 ) {
|
|
2754 |
* @return int The total mention count for the specified user.
|
2755 |
*/
|
2756 |
function bp_get_total_mention_count_for_user( $user_id = 0 ) {
|
2757 |
-
if ( ! $user_id ) {
|
2758 |
-
$user_id = bp_displayed_user_id();
|
2759 |
-
}
|
2760 |
|
2761 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2762 |
}
|
2763 |
-
add_filter( 'bp_get_total_mention_count_for_user', 'bp_core_number_format' );
|
2764 |
|
2765 |
/**
|
2766 |
* Output the public message link for displayed user.
|
@@ -2789,10 +2945,16 @@ function bp_send_public_message_link() {
|
|
2789 |
*/
|
2790 |
function bp_get_send_public_message_link() {
|
2791 |
|
2792 |
-
if
|
2793 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2794 |
|
2795 |
-
return apply_filters( 'bp_get_send_public_message_link',
|
2796 |
}
|
2797 |
|
2798 |
/**
|
@@ -2832,7 +2994,7 @@ function bp_activity_recurse_comments_activity_ids( $activity = array(), $activi
|
|
2832 |
*
|
2833 |
* @param int|string $user_id_or_username See {@link bp_get_mentioned_user_display_name()}.
|
2834 |
*/
|
2835 |
-
function bp_mentioned_user_display_name( $user_id_or_username ) {
|
2836 |
echo bp_get_mentioned_user_display_name( $user_id_or_username );
|
2837 |
}
|
2838 |
|
@@ -2847,9 +3009,15 @@ function bp_mentioned_user_display_name( $user_id_or_username ) {
|
|
2847 |
* @param int|string User ID or username.
|
2848 |
* @return string The mentioned user's display name.
|
2849 |
*/
|
2850 |
-
function bp_get_mentioned_user_display_name( $user_id_or_username ) {
|
2851 |
-
|
|
|
|
|
|
|
|
|
|
|
2852 |
$name = __( 'a user', 'buddypress' );
|
|
|
2853 |
|
2854 |
return apply_filters( 'bp_get_mentioned_user_display_name', $name, $user_id_or_username );
|
2855 |
}
|
@@ -2896,7 +3064,8 @@ function bp_send_public_message_button( $args = '' ) {
|
|
2896 |
* @return string The button for sending a public message.
|
2897 |
*/
|
2898 |
function bp_get_send_public_message_button( $args = '' ) {
|
2899 |
-
|
|
|
2900 |
'id' => 'public_message',
|
2901 |
'component' => 'activity',
|
2902 |
'must_be_logged_in' => true,
|
@@ -2906,12 +3075,10 @@ function bp_send_public_message_button( $args = '' ) {
|
|
2906 |
'link_title' => __( 'Send a public message on your activity stream.', 'buddypress' ),
|
2907 |
'link_text' => __( 'Public Message', 'buddypress' ),
|
2908 |
'link_class' => 'activity-button mention'
|
2909 |
-
);
|
2910 |
-
|
2911 |
-
$button = wp_parse_args( $args, $defaults );
|
2912 |
|
2913 |
// Filter and return the HTML button
|
2914 |
-
return bp_get_button( apply_filters( 'bp_get_send_public_message_button', $
|
2915 |
}
|
2916 |
|
2917 |
/**
|
@@ -2955,28 +3122,52 @@ function bp_activity_post_form_action() {
|
|
2955 |
* @param array $args See {@link bp_core_fetch_avatar()}.
|
2956 |
*/
|
2957 |
function bp_activity_comments_user_avatars( $args = array() ) {
|
2958 |
-
|
|
|
2959 |
'height' => false,
|
2960 |
'html' => true,
|
2961 |
'type' => 'thumb',
|
2962 |
'width' => false,
|
2963 |
-
);
|
2964 |
-
|
2965 |
-
$args = wp_parse_args( $args, $defaults );
|
2966 |
-
extract( $args, EXTR_SKIP );
|
2967 |
|
2968 |
// Get the user IDs of everyone who has left a comment to the current activity item
|
2969 |
$user_ids = bp_activity_get_comments_user_ids();
|
|
|
|
|
2970 |
|
2971 |
-
|
2972 |
-
|
2973 |
-
|
2974 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2975 |
|
2976 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2977 |
}
|
2978 |
|
2979 |
-
echo apply_filters( 'bp_activity_comments_user_avatars',
|
2980 |
}
|
2981 |
|
2982 |
/**
|
@@ -2987,10 +3178,12 @@ function bp_activity_comments_user_avatars( $args = array() ) {
|
|
2987 |
* @return bool|array An array of IDs, or false if none are found.
|
2988 |
*/
|
2989 |
function bp_activity_get_comments_user_ids() {
|
2990 |
-
|
2991 |
-
|
|
|
|
|
|
|
2992 |
|
2993 |
-
$user_ids = (array) bp_activity_recurse_comments_user_ids( $GLOBALS['activities_template']->activity->children );
|
2994 |
return apply_filters( 'bp_activity_get_comments_user_ids', array_unique( $user_ids ) );
|
2995 |
}
|
2996 |
|
@@ -3002,22 +3195,33 @@ function bp_activity_get_comments_user_ids() {
|
|
3002 |
* @param array $comments Array of {@link BP_Activity_Activity} items.
|
3003 |
* @return array Array of user IDs.
|
3004 |
*/
|
3005 |
-
function bp_activity_recurse_comments_user_ids( array $comments ) {
|
|
|
|
|
3006 |
$user_ids = array();
|
3007 |
|
3008 |
-
|
3009 |
-
|
3010 |
-
|
3011 |
-
|
|
|
|
|
|
|
|
|
|
|
3012 |
|
3013 |
-
|
|
|
3014 |
|
3015 |
-
|
3016 |
-
|
3017 |
-
|
|
|
|
|
3018 |
}
|
3019 |
|
3020 |
-
return
|
|
|
3021 |
}
|
3022 |
|
3023 |
/**
|
@@ -3054,11 +3258,11 @@ function bp_displayed_user_mentionname() {
|
|
3054 |
* }
|
3055 |
*/
|
3056 |
function bp_activity_types_list( $output = 'select', $args = '' ) {
|
3057 |
-
|
|
|
3058 |
'checkbox_name' => 'bp_activity_types',
|
3059 |
'selected' => array(),
|
3060 |
-
);
|
3061 |
-
$args = wp_parse_args( $args, $defaults );
|
3062 |
|
3063 |
$activities = bp_activity_get_types();
|
3064 |
natsort( $activities );
|
@@ -3070,19 +3274,24 @@ function bp_activity_types_list( $output = 'select', $args = '' ) {
|
|
3070 |
$checked = checked( true, in_array( $type, (array) $args['selected'] ), false );
|
3071 |
$selected = selected( true, in_array( $type, (array) $args['selected'] ), false );
|
3072 |
|
3073 |
-
|
3074 |
-
|
3075 |
-
|
3076 |
-
|
3077 |
-
|
|
|
|
|
|
|
|
|
3078 |
|
3079 |
// Allow custom markup
|
3080 |
do_action( 'bp_activity_types_list_' . $output, $args, $type, $description );
|
3081 |
}
|
3082 |
|
3083 |
// Backpat with BP-Default for dropdown boxes only
|
3084 |
-
if ( 'select'
|
3085 |
do_action( 'bp_activity_filter_options' );
|
|
|
3086 |
}
|
3087 |
|
3088 |
|
@@ -3155,18 +3364,30 @@ function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link
|
|
3155 |
*/
|
3156 |
function bp_get_member_activity_feed_link() {
|
3157 |
|
3158 |
-
|
|
|
3159 |
$link = bp_displayed_user_domain() . bp_get_activity_slug() . '/feed/';
|
3160 |
-
|
|
|
|
|
3161 |
$link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed/';
|
3162 |
-
|
|
|
|
|
3163 |
$link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/';
|
3164 |
-
|
|
|
|
|
3165 |
$link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
|
3166 |
-
|
|
|
|
|
3167 |
$link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
|
3168 |
-
|
|
|
|
|
3169 |
$link = '';
|
|
|
3170 |
|
3171 |
return apply_filters( 'bp_get_activities_member_rss_link', $link );
|
3172 |
}
|
@@ -3242,19 +3463,22 @@ function bp_activity_feed_item_title() {
|
|
3242 |
function bp_get_activity_feed_item_title() {
|
3243 |
global $activities_template;
|
3244 |
|
3245 |
-
if ( !empty( $activities_template->activity->action ) )
|
3246 |
$content = $activities_template->activity->action;
|
3247 |
-
else
|
3248 |
$content = $activities_template->activity->content;
|
|
|
3249 |
|
3250 |
$content = explode( '<span', $content );
|
3251 |
-
$title
|
3252 |
|
3253 |
-
if ( ':'
|
3254 |
$title = substr( $title, 0, -1 );
|
|
|
3255 |
|
3256 |
-
if ( 'activity_update'
|
3257 |
$title .= ': ' . strip_tags( ent2ncr( trim( convert_chars( bp_create_excerpt( $activities_template->activity->content, 70, array( 'ending' => " […]" ) ) ) ) ) );
|
|
|
3258 |
|
3259 |
return apply_filters( 'bp_get_activity_feed_item_title', $title );
|
3260 |
}
|
@@ -3283,7 +3507,11 @@ function bp_activity_feed_item_link() {
|
|
3283 |
function bp_get_activity_feed_item_link() {
|
3284 |
global $activities_template;
|
3285 |
|
3286 |
-
|
|
|
|
|
|
|
|
|
3287 |
}
|
3288 |
|
3289 |
/**
|
@@ -3310,7 +3538,11 @@ function bp_activity_feed_item_date() {
|
|
3310 |
function bp_get_activity_feed_item_date() {
|
3311 |
global $activities_template;
|
3312 |
|
3313 |
-
|
|
|
|
|
|
|
|
|
3314 |
}
|
3315 |
|
3316 |
/**
|
@@ -3339,11 +3571,17 @@ function bp_activity_feed_item_description() {
|
|
3339 |
function bp_get_activity_feed_item_description() {
|
3340 |
global $activities_template;
|
3341 |
|
3342 |
-
|
3343 |
-
|
3344 |
-
|
|
|
3345 |
|
3346 |
-
|
|
|
|
|
|
|
|
|
|
|
3347 |
}
|
3348 |
|
3349 |
/**
|
@@ -3362,3 +3600,91 @@ function bp_activity_sitewide_feed() {
|
|
3362 |
<?php
|
3363 |
}
|
3364 |
add_action( 'bp_head', 'bp_activity_sitewide_feed' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
var $in_the_loop;
|
100 |
|
101 |
+
/**
|
102 |
+
* URL parameter key for activity pagination. Default: 'acpage'.
|
103 |
+
*
|
104 |
+
* @since BuddyPress (2.1.0)
|
105 |
+
* @var string
|
106 |
+
*/
|
107 |
+
var $pag_arg;
|
108 |
+
|
109 |
var $pag_page;
|
110 |
var $pag_num;
|
111 |
var $pag_links;
|
178 |
'filter' => false,
|
179 |
'search_terms' => false,
|
180 |
'meta_query' => false,
|
181 |
+
'date_query' => false,
|
182 |
'display_comments' => 'threaded',
|
183 |
'show_hidden' => false,
|
184 |
'spam' => 'ham_only',
|
187 |
$r = wp_parse_args( $args, $defaults );
|
188 |
extract( $r );
|
189 |
|
190 |
+
$this->pag_arg = $r['page_arg'];
|
191 |
+
$this->pag_page = isset( $_REQUEST[ $this->pag_arg ] ) ? intval( $_REQUEST[ $this->pag_arg ] ) : $page;
|
192 |
$this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
|
193 |
|
194 |
// Check if blog/forum replies are disabled
|
221 |
'sort' => $sort,
|
222 |
'search_terms' => $search_terms,
|
223 |
'meta_query' => $meta_query,
|
224 |
+
'date_query' => $date_query,
|
225 |
'filter' => $filter,
|
226 |
'show_hidden' => $show_hidden,
|
227 |
'exclude' => $exclude,
|
231 |
) );
|
232 |
}
|
233 |
|
234 |
+
// The total_activity_count property will be set only if a
|
235 |
+
// 'count_total' query has taken place
|
236 |
+
if ( ! is_null( $this->activities['total'] ) ) {
|
237 |
+
if ( ! $max || $max >= (int) $this->activities['total'] ) {
|
238 |
+
$this->total_activity_count = (int) $this->activities['total'];
|
239 |
+
} else {
|
240 |
+
$this->total_activity_count = (int) $max;
|
241 |
+
}
|
242 |
+
}
|
243 |
+
|
244 |
+
$this->has_more_items = $this->activities['has_more_items'];
|
245 |
|
246 |
$this->activities = $this->activities['activities'];
|
247 |
|
525 |
$object = $bp->groups->id;
|
526 |
$primary_id = $bp->groups->current_group->id;
|
527 |
|
528 |
+
if ( groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) || bp_current_user_can( 'bp_moderate' ) ) {
|
529 |
$show_hidden = true;
|
530 |
+
}
|
531 |
}
|
532 |
|
533 |
// The default scope should recognize custom slugs
|
569 |
'since' => false, // return only items recorded since this Y-m-d H:i:s date
|
570 |
|
571 |
'meta_query' => false, // filter on activity meta. See WP_Meta_Query for format
|
572 |
+
'date_query' => false, // filter by date. See first parameter of WP_Date_Query for format
|
573 |
|
574 |
// Searching
|
575 |
'search_terms' => false, // specify terms to search on
|
683 |
'filter' => $filter,
|
684 |
'search_terms' => $search_terms,
|
685 |
'meta_query' => $meta_query,
|
686 |
+
'date_query' => $date_query,
|
687 |
'display_comments' => $display_comments,
|
688 |
'show_hidden' => $show_hidden,
|
689 |
'spam' => $spam,
|
725 |
return $activities_template->the_activity();
|
726 |
}
|
727 |
|
728 |
+
/**
|
729 |
+
* Output the URL for the Load More link.
|
730 |
+
*
|
731 |
+
* @since BuddyPress (2.1.0)
|
732 |
+
*/
|
733 |
+
function bp_activity_load_more_link() {
|
734 |
+
echo bp_get_activity_load_more_link();
|
735 |
+
}
|
736 |
+
function bp_get_activity_load_more_link() {
|
737 |
+
global $activities_template;
|
738 |
+
|
739 |
+
$link = bp_get_requested_url();
|
740 |
+
$link = add_query_arg( $activities_template->pag_arg, $activities_template->pag_page + 1, $link );
|
741 |
+
|
742 |
+
return apply_filters( 'bp_get_activity_load_more_link', $link );
|
743 |
+
}
|
744 |
+
|
745 |
/**
|
746 |
* Output the activity pagination count.
|
747 |
*
|
772 |
$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 ) );
|
773 |
$total = bp_core_number_format( $activities_template->total_activity_count );
|
774 |
|
775 |
+
return sprintf( _n( 'Viewing 1 item', 'Viewing %1$s - %2$s of %3$s items', $total, 'buddypress' ), $from_num, $to_num, $total );
|
776 |
}
|
777 |
|
778 |
/**
|
815 |
function bp_activity_has_more_items() {
|
816 |
global $activities_template;
|
817 |
|
818 |
+
if ( ! empty( $activities_template->has_more_items ) ) {
|
819 |
+
$has_more_items = true;
|
820 |
+
} else {
|
821 |
+
$remaining_pages = 0;
|
822 |
|
823 |
+
if ( ! empty( $activities_template->pag_page ) ) {
|
824 |
+
$remaining_pages = floor( ( $activities_template->total_activity_count - 1 ) / ( $activities_template->pag_num * $activities_template->pag_page ) );
|
825 |
+
}
|
826 |
|
827 |
+
$has_more_items = (int) $remaining_pages > 0;
|
828 |
+
}
|
829 |
|
830 |
return apply_filters( 'bp_activity_has_more_items', $has_more_items );
|
831 |
}
|
1180 |
function bp_get_activity_user_link() {
|
1181 |
global $activities_template;
|
1182 |
|
1183 |
+
if ( empty( $activities_template->activity->user_id ) || empty( $activities_template->activity->user_nicename ) || empty( $activities_template->activity->user_login ) ) {
|
1184 |
$link = $activities_template->activity->primary_link;
|
1185 |
+
} else {
|
1186 |
$link = bp_core_get_user_domain( $activities_template->activity->user_id, $activities_template->activity->user_nicename, $activities_template->activity->user_login );
|
1187 |
+
}
|
1188 |
|
1189 |
return apply_filters( 'bp_get_activity_user_link', $link );
|
1190 |
}
|
1639 |
function bp_activity_user_can_delete( $activity = false ) {
|
1640 |
global $activities_template;
|
1641 |
|
1642 |
+
// Try to use current activity if none was passed
|
1643 |
+
if ( empty( $activity ) && ! empty( $activities_template->activity ) ) {
|
1644 |
$activity = $activities_template->activity;
|
1645 |
+
}
|
1646 |
|
1647 |
+
// If current_comment is set, we'll use that in place of the main activity
|
1648 |
+
if ( isset( $activity->current_comment ) ) {
|
1649 |
$activity = $activity->current_comment;
|
1650 |
+
}
|
1651 |
|
1652 |
+
// Assume the user cannot delete the activity item
|
1653 |
$can_delete = false;
|
1654 |
|
1655 |
+
// Only logged in users can delete activity
|
1656 |
+
if ( is_user_logged_in() ) {
|
1657 |
|
1658 |
+
// Community moderators can always delete activity (at least for now)
|
1659 |
+
if ( bp_current_user_can( 'bp_moderate' ) ) {
|
1660 |
+
$can_delete = true;
|
1661 |
+
}
|
1662 |
|
1663 |
+
// Users are allowed to delete their own activity. This is actually
|
1664 |
+
// quite powerful, because doing so also deletes all comments to that
|
1665 |
+
// activity item. We should revisit this eventually.
|
1666 |
+
if ( isset( $activity->user_id ) && ( $activity->user_id === bp_loggedin_user_id() ) ) {
|
1667 |
+
$can_delete = true;
|
1668 |
+
}
|
1669 |
|
1670 |
+
// Viewing a single item, and this user is an admin of that item
|
1671 |
+
if ( bp_is_single_item() && bp_is_item_admin() ) {
|
1672 |
+
$can_delete = true;
|
1673 |
+
}
|
1674 |
+
}
|
1675 |
+
|
1676 |
+
return (bool) apply_filters( 'bp_activity_user_can_delete', $can_delete, $activity );
|
1677 |
}
|
1678 |
|
1679 |
/**
|
1810 |
function bp_get_activity_is_favorite() {
|
1811 |
global $activities_template;
|
1812 |
|
1813 |
+
return (bool) apply_filters( 'bp_get_activity_is_favorite', in_array( $activities_template->activity->id, (array) $activities_template->my_favs ) );
|
1814 |
}
|
1815 |
|
1816 |
/**
|
2150 |
}
|
2151 |
|
2152 |
/**
|
2153 |
+
* Return the comment count of an activity item.
|
|
|
|
|
|
|
|
|
|
|
2154 |
*
|
2155 |
* @since BuddyPress (1.2)
|
2156 |
*
|
2157 |
* @global object $activities_template {@link BP_Activity_Template}
|
2158 |
* @uses bp_activity_recurse_comment_count()
|
2159 |
* @uses apply_filters() To call the 'bp_activity_get_comment_count' hook.
|
|
|
2160 |
*
|
2161 |
+
* @param array $deprecated Deprecated.
|
2162 |
+
*
|
2163 |
* @return int $count The activity comment count.
|
2164 |
*/
|
2165 |
+
function bp_activity_get_comment_count( $deprecated = null ) {
|
2166 |
global $activities_template;
|
2167 |
|
2168 |
+
// Deprecated notice about $args
|
2169 |
+
if ( ! empty( $deprecated ) ) {
|
2170 |
+
_deprecated_argument( __FUNCTION__, '1.2', sprintf( __( '%1$s no longer accepts arguments. See the inline documentation at %2$s for more details.', 'buddypress' ), __FUNCTION__, __FILE__ ) );
|
2171 |
+
}
|
2172 |
|
2173 |
+
// Get the count using the purpose-built recursive function
|
2174 |
+
$count = ! empty( $activities_template->activity->children )
|
2175 |
+
? bp_activity_recurse_comment_count( $activities_template->activity )
|
2176 |
+
: 0;
|
2177 |
|
2178 |
return apply_filters( 'bp_activity_get_comment_count', (int) $count );
|
2179 |
}
|
2180 |
|
2181 |
/**
|
2182 |
+
* Return the total number of comments to the current comment.
|
2183 |
*
|
2184 |
+
* This function recursively adds the total number of comments each
|
2185 |
+
* activity child has, and returns them.
|
|
|
|
|
2186 |
*
|
2187 |
* @since BuddyPress (1.2)
|
2188 |
*
|
2189 |
* @uses bp_activity_recurse_comment_count()
|
2190 |
+
* @uses apply_filters() To call the 'bp_activity_recurse_comment_count' hook
|
|
|
2191 |
*
|
2192 |
* @param object $comment Activity comment object.
|
2193 |
* @param int $count The current iteration count.
|
2194 |
+
*
|
2195 |
* @return int $count The activity comment count.
|
2196 |
*/
|
2197 |
function bp_activity_recurse_comment_count( $comment, $count = 0 ) {
|
2198 |
|
2199 |
+
// Copy the count
|
2200 |
+
$new_count = $count;
|
2201 |
|
2202 |
+
// Loop through children and recursively count comments
|
2203 |
+
if ( ! empty( $comment->children ) ) {
|
2204 |
+
foreach ( (array) $comment->children as $comment ) {
|
2205 |
+
$new_count++;
|
2206 |
+
$new_count = bp_activity_recurse_comment_count( $comment, $new_count );
|
2207 |
+
}
|
2208 |
}
|
2209 |
|
2210 |
+
// Filter and return
|
2211 |
+
return apply_filters( 'bp_activity_recurse_comment_count', $new_count, $comment, $count );
|
2212 |
}
|
2213 |
|
2214 |
/**
|
2388 |
function bp_get_activity_comment_permalink() {
|
2389 |
global $activities_template;
|
2390 |
|
2391 |
+
// Check that comment exists
|
2392 |
+
$comment_id = isset( $activities_template->activity->current_comment->id )
|
2393 |
+
? $activities_template->activity->current_comment->id
|
2394 |
+
: 0;
|
2395 |
+
|
2396 |
+
// Setup the comment link
|
2397 |
+
$comment_link = ! empty( $comment_id )
|
2398 |
+
? '#acomment-' .$comment_id
|
2399 |
+
: false;
|
2400 |
|
2401 |
+
// Append comment ID to end of activity permalink
|
2402 |
+
$link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . $comment_link;
|
2403 |
+
|
2404 |
+
return apply_filters( 'bp_get_activity_comment_permalink', $link, $comment_id );
|
2405 |
}
|
2406 |
|
2407 |
/**
|
2539 |
* if on single activity page.
|
2540 |
*/
|
2541 |
function bp_get_activity_delete_link() {
|
|
|
2542 |
|
2543 |
+
$url = bp_get_activity_delete_url();
|
2544 |
$class = 'delete-activity';
|
2545 |
|
2546 |
// Determine if we're on a single activity page, and customize accordingly
|
2547 |
if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
|
|
|
2548 |
$class = 'delete-activity-single';
|
2549 |
}
|
2550 |
|
2551 |
+
$link = '<a href="' . esc_url( $url ) . '" class="button item-button bp-secondary-action ' . $class . ' confirm" rel="nofollow">' . __( 'Delete', 'buddypress' ) . '</a>';
|
2552 |
+
|
2553 |
return apply_filters( 'bp_get_activity_delete_link', $link );
|
2554 |
}
|
2555 |
|
2556 |
+
/**
|
2557 |
+
* Output the URL to delete a single activity stream item
|
2558 |
+
*
|
2559 |
+
* @since BuddyPress (2.1.0)
|
2560 |
+
*
|
2561 |
+
* @uses bp_get_activity_delete_link()
|
2562 |
+
*/
|
2563 |
+
function bp_activity_delete_url() {
|
2564 |
+
echo esc_url( bp_get_activity_delete_url() );
|
2565 |
+
}
|
2566 |
+
/**
|
2567 |
+
* Return the URL to delete a single activity item
|
2568 |
+
*
|
2569 |
+
* @since BuddyPress (2.1.0)
|
2570 |
+
*
|
2571 |
+
* @global object $activities_template {@link BP_Activity_Template}
|
2572 |
+
* @uses bp_get_root_domain()
|
2573 |
+
* @uses bp_get_activity_root_slug()
|
2574 |
+
* @uses bp_is_activity_component()
|
2575 |
+
* @uses bp_current_action()
|
2576 |
+
* @uses add_query_arg()
|
2577 |
+
* @uses wp_get_referer()
|
2578 |
+
* @uses wp_nonce_url()
|
2579 |
+
* @uses apply_filters() To call the 'bp_get_activity_delete_link' hook.
|
2580 |
+
*
|
2581 |
+
* @return string $link Activity delete link. Contains $redirect_to arg
|
2582 |
+
* if on single activity page.
|
2583 |
+
*/
|
2584 |
+
function bp_get_activity_delete_url() {
|
2585 |
+
global $activities_template;
|
2586 |
+
|
2587 |
+
$url = trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/delete/' . $activities_template->activity->id );
|
2588 |
+
|
2589 |
+
// Determine if we're on a single activity page, and customize accordingly
|
2590 |
+
if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
|
2591 |
+
$url = add_query_arg( array( 'redirect_to' => wp_get_referer() ), $url );
|
2592 |
+
}
|
2593 |
+
|
2594 |
+
$url = wp_nonce_url( $url, 'bp_activity_delete_link' );
|
2595 |
+
|
2596 |
+
return apply_filters( 'bp_get_activity_delete_url', $url );
|
2597 |
+
}
|
2598 |
+
|
2599 |
/**
|
2600 |
* Output the activity latest update link.
|
2601 |
*
|
2757 |
function bp_activity_can_comment() {
|
2758 |
global $activities_template;
|
2759 |
|
2760 |
+
// Assume activity can be commented on
|
2761 |
$can_comment = true;
|
2762 |
|
2763 |
+
// Determine ability to comment based on activity action name
|
2764 |
+
$activity_action = bp_get_activity_action_name();
|
2765 |
+
switch ( $activity_action ) {
|
2766 |
+
|
2767 |
+
// Maybe turn off for blog and forum updates
|
2768 |
+
case 'new_blog_post' :
|
2769 |
+
case 'new_blog_comment' :
|
2770 |
+
case 'new_forum_topic' :
|
2771 |
+
case 'new_forum_post' :
|
2772 |
+
if ( ! empty( $activities_template->disable_blogforum_replies ) ) {
|
2773 |
+
$can_comment = false;
|
2774 |
+
}
|
2775 |
+
break;
|
2776 |
+
|
2777 |
+
// Turn off for activity comments
|
2778 |
+
case 'activity_comment' :
|
2779 |
$can_comment = false;
|
2780 |
+
break;
|
2781 |
}
|
2782 |
|
2783 |
+
return apply_filters( 'bp_activity_can_comment', $can_comment, $activity_action );
|
|
|
|
|
|
|
2784 |
}
|
2785 |
|
2786 |
/**
|
2787 |
+
* Determine whether a comment can be made on an activity reply item.
|
2788 |
*
|
2789 |
+
* @since BuddyPress (1.5.0)
|
|
|
|
|
|
|
|
|
2790 |
*
|
2791 |
* @param object $comment Activity comment.
|
2792 |
+
* @return bool $can_comment True if comment can receive comments, otherwise
|
2793 |
+
* false.
|
2794 |
*/
|
2795 |
+
function bp_activity_can_comment_reply( $comment = '' ) {
|
2796 |
+
|
2797 |
+
// Assume activity can be commented on
|
2798 |
$can_comment = true;
|
2799 |
|
2800 |
+
// Check that comment exists
|
2801 |
+
if ( empty( $comment ) ) {
|
2802 |
+
$comment = bp_activity_current_comment();
|
2803 |
}
|
2804 |
|
2805 |
+
if ( ! empty( $comment ) ) {
|
2806 |
+
|
2807 |
+
// Fall back on current comment in activity loop
|
2808 |
+
$comment_depth = isset( $comment->depth )
|
2809 |
+
? intval( $comment->depth )
|
2810 |
+
: bp_activity_get_comment_depth();
|
2811 |
+
|
2812 |
+
// Threading is turned on, so check the depth
|
2813 |
+
if ( get_option( 'thread_comments' ) ) {
|
2814 |
+
$can_comment = (bool) ( $comment_depth < get_option( 'thread_comments_depth' ) );
|
2815 |
+
|
2816 |
+
// No threading for comment replies if no threading for comments
|
2817 |
+
} else {
|
2818 |
+
$can_comment = false;
|
2819 |
+
}
|
2820 |
+
}
|
2821 |
+
|
2822 |
+
return (bool) apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
|
2823 |
}
|
2824 |
|
2825 |
/**
|
2831 |
*
|
2832 |
* @uses apply_filters() To call the 'bp_activity_can_favorite' hook.
|
2833 |
*
|
2834 |
+
* @return bool True if comment can receive comments.
|
2835 |
*/
|
2836 |
function bp_activity_can_favorite() {
|
2837 |
+
return apply_filters( 'bp_activity_can_favorite', true );
|
|
|
|
|
2838 |
}
|
2839 |
|
2840 |
/**
|
2863 |
* @return int The total favorite count for the specified user.
|
2864 |
*/
|
2865 |
function bp_get_total_favorite_count_for_user( $user_id = 0 ) {
|
|
|
|
|
|
|
2866 |
|
2867 |
+
// Default to displayed user if none is passed
|
2868 |
+
$user_id = empty( $user_id )
|
2869 |
+
? bp_displayed_user_id()
|
2870 |
+
: $user_id;
|
2871 |
+
|
2872 |
+
// Get user meta if user ID exists
|
2873 |
+
$retval = ! empty( $user_id )
|
2874 |
+
? bp_activity_total_favorites_for_user( $user_id )
|
2875 |
+
: false;
|
2876 |
+
|
2877 |
+
return apply_filters( 'bp_get_total_favorite_count_for_user', $retval );
|
2878 |
}
|
2879 |
+
|
2880 |
|
2881 |
/**
|
2882 |
* Output the total mention count for a specified user.
|
2904 |
* @return int The total mention count for the specified user.
|
2905 |
*/
|
2906 |
function bp_get_total_mention_count_for_user( $user_id = 0 ) {
|
|
|
|
|
|
|
2907 |
|
2908 |
+
// Default to displayed user if none is passed
|
2909 |
+
$user_id = empty( $user_id )
|
2910 |
+
? bp_displayed_user_id()
|
2911 |
+
: $user_id;
|
2912 |
+
|
2913 |
+
// Get user meta if user ID exists
|
2914 |
+
$retval = ! empty( $user_id )
|
2915 |
+
? bp_get_user_meta( $user_id, 'bp_new_mention_count', true )
|
2916 |
+
: false;
|
2917 |
+
|
2918 |
+
return apply_filters( 'bp_get_total_mention_count_for_user', $retval );
|
2919 |
}
|
|
|
2920 |
|
2921 |
/**
|
2922 |
* Output the public message link for displayed user.
|
2945 |
*/
|
2946 |
function bp_get_send_public_message_link() {
|
2947 |
|
2948 |
+
// No link if not logged in, not looking at someone else's profile
|
2949 |
+
if ( ! is_user_logged_in() || ! bp_is_user() || bp_is_my_profile() ) {
|
2950 |
+
$retval = '';
|
2951 |
+
} else {
|
2952 |
+
$args = array( 'r' => bp_get_displayed_user_mentionname() );
|
2953 |
+
$url = add_query_arg( $args, bp_get_activity_directory_permalink() );
|
2954 |
+
$retval = wp_nonce_url( $url );
|
2955 |
+
}
|
2956 |
|
2957 |
+
return apply_filters( 'bp_get_send_public_message_link', $retval );
|
2958 |
}
|
2959 |
|
2960 |
/**
|
2994 |
*
|
2995 |
* @param int|string $user_id_or_username See {@link bp_get_mentioned_user_display_name()}.
|
2996 |
*/
|
2997 |
+
function bp_mentioned_user_display_name( $user_id_or_username = false ) {
|
2998 |
echo bp_get_mentioned_user_display_name( $user_id_or_username );
|
2999 |
}
|
3000 |
|
3009 |
* @param int|string User ID or username.
|
3010 |
* @return string The mentioned user's display name.
|
3011 |
*/
|
3012 |
+
function bp_get_mentioned_user_display_name( $user_id_or_username = false ) {
|
3013 |
+
|
3014 |
+
// Get user display name
|
3015 |
+
$name = bp_core_get_user_displayname( $user_id_or_username );
|
3016 |
+
|
3017 |
+
// If user somehow has no name, return this really lame string
|
3018 |
+
if ( empty( $name ) ) {
|
3019 |
$name = __( 'a user', 'buddypress' );
|
3020 |
+
}
|
3021 |
|
3022 |
return apply_filters( 'bp_get_mentioned_user_display_name', $name, $user_id_or_username );
|
3023 |
}
|
3064 |
* @return string The button for sending a public message.
|
3065 |
*/
|
3066 |
function bp_get_send_public_message_button( $args = '' ) {
|
3067 |
+
|
3068 |
+
$r = bp_parse_args( $args, array(
|
3069 |
'id' => 'public_message',
|
3070 |
'component' => 'activity',
|
3071 |
'must_be_logged_in' => true,
|
3075 |
'link_title' => __( 'Send a public message on your activity stream.', 'buddypress' ),
|
3076 |
'link_text' => __( 'Public Message', 'buddypress' ),
|
3077 |
'link_class' => 'activity-button mention'
|
3078 |
+
) );
|
|
|
|
|
3079 |
|
3080 |
// Filter and return the HTML button
|
3081 |
+
return bp_get_button( apply_filters( 'bp_get_send_public_message_button', $r ) );
|
3082 |
}
|
3083 |
|
3084 |
/**
|
3122 |
* @param array $args See {@link bp_core_fetch_avatar()}.
|
3123 |
*/
|
3124 |
function bp_activity_comments_user_avatars( $args = array() ) {
|
3125 |
+
|
3126 |
+
$r = bp_parse_args( $args, array(
|
3127 |
'height' => false,
|
3128 |
'html' => true,
|
3129 |
'type' => 'thumb',
|
3130 |
'width' => false,
|
3131 |
+
) );
|
|
|
|
|
|
|
3132 |
|
3133 |
// Get the user IDs of everyone who has left a comment to the current activity item
|
3134 |
$user_ids = bp_activity_get_comments_user_ids();
|
3135 |
+
$output = array();
|
3136 |
+
$retval = '';
|
3137 |
|
3138 |
+
if ( ! empty( $user_ids ) ) {
|
3139 |
+
foreach ( (array) $user_ids as $user_id ) {
|
3140 |
+
|
3141 |
+
// Skip an empty user ID
|
3142 |
+
if ( empty( $user_id ) ) {
|
3143 |
+
continue;
|
3144 |
+
}
|
3145 |
+
|
3146 |
+
// Get profile link for this user
|
3147 |
+
$profile_link = bp_core_get_user_domain( $user_id );
|
3148 |
+
|
3149 |
+
// Get avatar for this user
|
3150 |
+
$image_html = bp_core_fetch_avatar( array(
|
3151 |
+
'item_id' => $user_id,
|
3152 |
+
'height' => $r['height'],
|
3153 |
+
'html' => $r['html'],
|
3154 |
+
'type' => $r['type'],
|
3155 |
+
'width' => $r['width']
|
3156 |
+
) );
|
3157 |
|
3158 |
+
// If user has link & avatar, add them to the output array
|
3159 |
+
if ( ! empty( $profile_link ) && ! empty( $image_html ) ) {
|
3160 |
+
$output[] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $profile_link ), $image_html );
|
3161 |
+
}
|
3162 |
+
}
|
3163 |
+
|
3164 |
+
// If output array is not empty, wrap everything in some list items
|
3165 |
+
if ( ! empty( $output ) ) {
|
3166 |
+
$retval = '<li>' . implode( '</li><li>', $output ) . '</li>';
|
3167 |
+
}
|
3168 |
}
|
3169 |
|
3170 |
+
echo apply_filters( 'bp_activity_comments_user_avatars', $retval, $r, $output );
|
3171 |
}
|
3172 |
|
3173 |
/**
|
3178 |
* @return bool|array An array of IDs, or false if none are found.
|
3179 |
*/
|
3180 |
function bp_activity_get_comments_user_ids() {
|
3181 |
+
global $activities_template;
|
3182 |
+
|
3183 |
+
$user_ids = ! empty( $activities_template->activity->children )
|
3184 |
+
? (array) bp_activity_recurse_comments_user_ids( $activities_template->activity->children )
|
3185 |
+
: array();
|
3186 |
|
|
|
3187 |
return apply_filters( 'bp_activity_get_comments_user_ids', array_unique( $user_ids ) );
|
3188 |
}
|
3189 |
|
3195 |
* @param array $comments Array of {@link BP_Activity_Activity} items.
|
3196 |
* @return array Array of user IDs.
|
3197 |
*/
|
3198 |
+
function bp_activity_recurse_comments_user_ids( array $comments = array() ) {
|
3199 |
+
|
3200 |
+
// Default user ID's array
|
3201 |
$user_ids = array();
|
3202 |
|
3203 |
+
// Loop through comments and try to get user ID's
|
3204 |
+
if ( ! empty( $comments ) ) {
|
3205 |
+
foreach ( $comments as $comment ) {
|
3206 |
+
|
3207 |
+
// If a user is a spammer, their activity items will have been
|
3208 |
+
// automatically marked as spam. Skip these.
|
3209 |
+
if ( ! empty( $comment->is_spam ) ) {
|
3210 |
+
continue;
|
3211 |
+
}
|
3212 |
|
3213 |
+
// Add user ID to array
|
3214 |
+
$user_ids[] = $comment->user_id;
|
3215 |
|
3216 |
+
// Check for commentception
|
3217 |
+
if ( ! empty( $comment->children ) ) {
|
3218 |
+
$user_ids = array_merge( $user_ids, bp_activity_recurse_comments_user_ids( $comment->children ) );
|
3219 |
+
}
|
3220 |
+
}
|
3221 |
}
|
3222 |
|
3223 |
+
// Filter and return
|
3224 |
+
return apply_filters( 'bp_activity_recurse_comments_user_ids', $user_ids, $comments );
|
3225 |
}
|
3226 |
|
3227 |
/**
|
3258 |
* }
|
3259 |
*/
|
3260 |
function bp_activity_types_list( $output = 'select', $args = '' ) {
|
3261 |
+
|
3262 |
+
$args = bp_parse_args( $args, array(
|
3263 |
'checkbox_name' => 'bp_activity_types',
|
3264 |
'selected' => array(),
|
3265 |
+
) );
|
|
|
3266 |
|
3267 |
$activities = bp_activity_get_types();
|
3268 |
natsort( $activities );
|
3274 |
$checked = checked( true, in_array( $type, (array) $args['selected'] ), false );
|
3275 |
$selected = selected( true, in_array( $type, (array) $args['selected'] ), false );
|
3276 |
|
3277 |
+
// Switch output based on the element
|
3278 |
+
switch ( $output ) {
|
3279 |
+
case 'select' :
|
3280 |
+
printf( '<option value="%1$s" %2$s>%3$s</option>', esc_attr( $type ), $selected, esc_html( $description ) );
|
3281 |
+
break;
|
3282 |
+
case 'checkbox' :
|
3283 |
+
printf( '<label style="">%1$s<input type="checkbox" name="%2$s[]" value="%3$s" %4$s/></label>', esc_html( $description ), esc_attr( $args['checkbox_name'] ), esc_attr( $type ), $checked );
|
3284 |
+
break;
|
3285 |
+
}
|
3286 |
|
3287 |
// Allow custom markup
|
3288 |
do_action( 'bp_activity_types_list_' . $output, $args, $type, $description );
|
3289 |
}
|
3290 |
|
3291 |
// Backpat with BP-Default for dropdown boxes only
|
3292 |
+
if ( 'select' === $output ) {
|
3293 |
do_action( 'bp_activity_filter_options' );
|
3294 |
+
}
|
3295 |
}
|
3296 |
|
3297 |
|
3364 |
*/
|
3365 |
function bp_get_member_activity_feed_link() {
|
3366 |
|
3367 |
+
// Single member activity feed link
|
3368 |
+
if ( bp_is_profile_component() || bp_is_current_action( 'just-me' ) ) {
|
3369 |
$link = bp_displayed_user_domain() . bp_get_activity_slug() . '/feed/';
|
3370 |
+
|
3371 |
+
// Friend feed link
|
3372 |
+
} elseif ( bp_is_active( 'friends' ) && bp_is_current_action( bp_get_friends_slug() ) ) {
|
3373 |
$link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed/';
|
3374 |
+
|
3375 |
+
// Group feed link
|
3376 |
+
} elseif ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) {
|
3377 |
$link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/';
|
3378 |
+
|
3379 |
+
// Favorites activity feed link
|
3380 |
+
} elseif ( 'favorites' === bp_current_action() ) {
|
3381 |
$link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
|
3382 |
+
|
3383 |
+
// Mentions activity feed link
|
3384 |
+
} elseif ( ( 'mentions' === bp_current_action() ) && bp_activity_do_mentions() ) {
|
3385 |
$link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
|
3386 |
+
|
3387 |
+
// No feed link
|
3388 |
+
} else {
|
3389 |
$link = '';
|
3390 |
+
}
|
3391 |
|
3392 |
return apply_filters( 'bp_get_activities_member_rss_link', $link );
|
3393 |
}
|
3463 |
function bp_get_activity_feed_item_title() {
|
3464 |
global $activities_template;
|
3465 |
|
3466 |
+
if ( !empty( $activities_template->activity->action ) ) {
|
3467 |
$content = $activities_template->activity->action;
|
3468 |
+
} else {
|
3469 |
$content = $activities_template->activity->content;
|
3470 |
+
}
|
3471 |
|
3472 |
$content = explode( '<span', $content );
|
3473 |
+
$title = strip_tags( ent2ncr( trim( convert_chars( $content[0] ) ) ) );
|
3474 |
|
3475 |
+
if ( ':' === substr( $title, -1 ) ) {
|
3476 |
$title = substr( $title, 0, -1 );
|
3477 |
+
}
|
3478 |
|
3479 |
+
if ( 'activity_update' === $activities_template->activity->type ) {
|
3480 |
$title .= ': ' . strip_tags( ent2ncr( trim( convert_chars( bp_create_excerpt( $activities_template->activity->content, 70, array( 'ending' => " […]" ) ) ) ) ) );
|
3481 |
+
}
|
3482 |
|
3483 |
return apply_filters( 'bp_get_activity_feed_item_title', $title );
|
3484 |
}
|
3507 |
function bp_get_activity_feed_item_link() {
|
3508 |
global $activities_template;
|
3509 |
|
3510 |
+
$retval = ! empty( $activities_template->activity->primary_link )
|
3511 |
+
? $activities_template->activity->primary_link
|
3512 |
+
: '';
|
3513 |
+
|
3514 |
+
return apply_filters( 'bp_get_activity_feed_item_link', $retval );
|
3515 |
}
|
3516 |
|
3517 |
/**
|
3538 |
function bp_get_activity_feed_item_date() {
|
3539 |
global $activities_template;
|
3540 |
|
3541 |
+
$retval = ! empty( $activities_template->activity->date_recorded )
|
3542 |
+
? $activities_template->activity->date_recorded
|
3543 |
+
: '';
|
3544 |
+
|
3545 |
+
return apply_filters( 'bp_get_activity_feed_item_date', $retval );
|
3546 |
}
|
3547 |
|
3548 |
/**
|
3571 |
function bp_get_activity_feed_item_description() {
|
3572 |
global $activities_template;
|
3573 |
|
3574 |
+
// Get the content, if exists
|
3575 |
+
$content = ! empty( $activities_template->activity->content )
|
3576 |
+
? $activities_template->activity->content
|
3577 |
+
: '';
|
3578 |
|
3579 |
+
// Perform a few string conversions on the content, if it's not empty
|
3580 |
+
if ( ! empty( $content ) ) {
|
3581 |
+
$content = ent2ncr( convert_chars( str_replace( '%s', '', $content ) ) );
|
3582 |
+
}
|
3583 |
+
|
3584 |
+
return apply_filters( 'bp_get_activity_feed_item_description', $content );
|
3585 |
}
|
3586 |
|
3587 |
/**
|
3600 |
<?php
|
3601 |
}
|
3602 |
add_action( 'bp_head', 'bp_activity_sitewide_feed' );
|
3603 |
+
|
3604 |
+
/**
|
3605 |
+
* Display available filters depending on the scope.
|
3606 |
+
*
|
3607 |
+
* @since BuddyPress (2.1.0)
|
3608 |
+
*
|
3609 |
+
* @param string $context The current context. 'activity', 'member',
|
3610 |
+
* 'member_groups', 'group'.
|
3611 |
+
* @uses bp_get_activity_show_filters()
|
3612 |
+
*/
|
3613 |
+
function bp_activity_show_filters( $context = '' ) {
|
3614 |
+
echo bp_get_activity_show_filters( $context );
|
3615 |
+
}
|
3616 |
+
/**
|
3617 |
+
* Get available filters depending on the scope.
|
3618 |
+
*
|
3619 |
+
* @since BuddyPress (2.1.0)
|
3620 |
+
*
|
3621 |
+
* @param string $context The current context. 'activity', 'member',
|
3622 |
+
* 'member_groups', 'group'
|
3623 |
+
* @return string HTML for <option> values.
|
3624 |
+
*/
|
3625 |
+
function bp_get_activity_show_filters( $context = '' ) {
|
3626 |
+
// Set default context based on current page
|
3627 |
+
if ( empty( $context ) ) {
|
3628 |
+
|
3629 |
+
// On member pages, default to 'member', unless this
|
3630 |
+
// is a user's Groups activity
|
3631 |
+
if ( bp_is_user() ) {
|
3632 |
+
if ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) {
|
3633 |
+
$context = 'member_groups';
|
3634 |
+
} else {
|
3635 |
+
$context = 'member';
|
3636 |
+
}
|
3637 |
+
|
3638 |
+
// On individual group pages, default to 'group'
|
3639 |
+
} else if ( bp_is_active( 'groups' ) && bp_is_group() ) {
|
3640 |
+
$context = 'group';
|
3641 |
+
|
3642 |
+
// 'activity' everywhere else
|
3643 |
+
} else {
|
3644 |
+
$context = 'activity';
|
3645 |
+
}
|
3646 |
+
}
|
3647 |
+
|
3648 |
+
$filters = array();
|
3649 |
+
|
3650 |
+
// Walk through the registered actions, and prepare an the
|
3651 |
+
// select box options.
|
3652 |
+
foreach ( buddypress()->activity->actions as $actions ) {
|
3653 |
+
foreach ( $actions as $action ) {
|
3654 |
+
if ( ! in_array( $context, (array) $action['context'] ) ) {
|
3655 |
+
continue;
|
3656 |
+
}
|
3657 |
+
|
3658 |
+
// Friends activity collapses two filters into one
|
3659 |
+
if ( in_array( $action['key'], array( 'friendship_accepted', 'friendship_created' ) ) ) {
|
3660 |
+
$action['key'] = 'friendship_accepted,friendship_created';
|
3661 |
+
}
|
3662 |
+
|
3663 |
+
$filters[ $action['key'] ] = $action['label'];
|
3664 |
+
}
|
3665 |
+
}
|
3666 |
+
|
3667 |
+
/**
|
3668 |
+
* Modify the filter options available in the activity filter dropdown.
|
3669 |
+
*
|
3670 |
+
* @since BuddyPress (2.1.0)
|
3671 |
+
*
|
3672 |
+
* @param array $filters Array of filter options for the given
|
3673 |
+
* context, in the following format:
|
3674 |
+
* $option_value => $option_name
|
3675 |
+
* @param string $context Context for the filter. 'activity'
|
3676 |
+
* 'member', 'member_groups', 'group'.
|
3677 |
+
*/
|
3678 |
+
$filters = apply_filters( 'bp_get_activity_show_filters', $filters, $context );
|
3679 |
+
|
3680 |
+
// Build the options output
|
3681 |
+
$output = '';
|
3682 |
+
|
3683 |
+
if ( ! empty( $filters ) ) {
|
3684 |
+
foreach ( $filters as $value => $filter ) {
|
3685 |
+
$output .= '<option value="' . esc_attr( $value ) . '">' . esc_html( $filter ) . '</option>' . "\n";
|
3686 |
+
}
|
3687 |
+
}
|
3688 |
+
|
3689 |
+
return apply_filters( 'bp_get_activity_show_filters', $output, $filters, $context );
|
3690 |
+
}
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.atwho-view {
|
2 |
+
background: #FFF;
|
3 |
+
border-radius: 2px;
|
4 |
+
border: 1px solid rgb(204, 204, 204);
|
5 |
+
box-shadow: 0 0 5px rgba(204, 204, 204, 0.25), 0 0 1px #FFF;
|
6 |
+
color: #D84800;
|
7 |
+
display: none;
|
8 |
+
font-family: sans-serif;
|
9 |
+
right: 0;
|
10 |
+
margin-top: 18px;
|
11 |
+
position: absolute;
|
12 |
+
top: 0;
|
13 |
+
z-index: 1000; /* >999 for wp-admin */
|
14 |
+
}
|
15 |
+
.atwho-view ul {
|
16 |
+
list-style: none;
|
17 |
+
margin: auto;
|
18 |
+
padding: 0;
|
19 |
+
}
|
20 |
+
.atwho-view ul li {
|
21 |
+
border-bottom: 1px solid #EFEFEF;
|
22 |
+
box-sizing: content-box;
|
23 |
+
cursor: pointer;
|
24 |
+
display: block;
|
25 |
+
font-size: 14px;
|
26 |
+
height: 20px;
|
27 |
+
line-height: 20px;
|
28 |
+
margin: 0;
|
29 |
+
overflow: hidden;
|
30 |
+
padding: 5px 10px;
|
31 |
+
}
|
32 |
+
.atwho-view img {
|
33 |
+
border-radius: 2px;
|
34 |
+
float: left;
|
35 |
+
height: 20px;
|
36 |
+
width: 20px;
|
37 |
+
}
|
38 |
+
.atwho-view strong {
|
39 |
+
background: #EFEFEF;
|
40 |
+
font: bold;
|
41 |
+
}
|
42 |
+
.atwho-view .username strong {
|
43 |
+
color: #D54E21;
|
44 |
+
}
|
45 |
+
.atwho-view small {
|
46 |
+
color: #AAA;
|
47 |
+
float: left;
|
48 |
+
font-size: smaller;
|
49 |
+
font-weight: normal;
|
50 |
+
margin: 0 40px 0 10px;
|
51 |
+
}
|
52 |
+
.atwho-view .cur {
|
53 |
+
background: rgba(239, 239, 239, 0.5);
|
54 |
+
}
|
55 |
+
|
56 |
+
@media (max-width: 900px) {
|
57 |
+
.atwho-view img {
|
58 |
+
float: right;
|
59 |
+
margin: 0 0 0 10px;
|
60 |
+
}
|
61 |
+
.atwho-view small {
|
62 |
+
display: none;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
@media (max-width: 400px) {
|
66 |
+
.atwho-view ul li {
|
67 |
+
font-size: 16px;
|
68 |
+
line-height: 23px;
|
69 |
+
padding: 13px;
|
70 |
+
}
|
71 |
+
.atwho-view ul li img {
|
72 |
+
height: 30px;
|
73 |
+
margin-top: -5px;
|
74 |
+
width: 30px;
|
75 |
+
}
|
76 |
+
}
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
.atwho-view{background:#FFF;border-radius:2px;border:1px solid #ccc;box-shadow:0 0 5px rgba(204,204,204,.25),0 0 1px #FFF;color:#D84800;display:none;font-family:sans-serif;right:0;margin-top:18px;position:absolute;top:0;z-index:1000}.atwho-view ul{list-style:none;margin:auto;padding:0}.atwho-view ul li{border-bottom:1px solid #EFEFEF;box-sizing:content-box;cursor:pointer;display:block;font-size:14px;height:20px;line-height:20px;margin:0;overflow:hidden;padding:5px 10px}.atwho-view img{border-radius:2px;float:left;height:20px;width:20px}.atwho-view strong{background:#EFEFEF;font:700}.atwho-view .username strong{color:#D54E21}.atwho-view small{color:#AAA;float:left;font-size:smaller;font-weight:400;margin:0 40px 0 10px}.atwho-view .cur{background:rgba(239,239,239,.5)}@media (max-width:900px){.atwho-view img{float:right;margin:0 0 0 10px}.atwho-view small{display:none}}@media (max-width:400px){.atwho-view ul li{font-size:16px;line-height:23px;padding:13px}.atwho-view ul li img{height:30px;margin-top:-5px;width:30px}}
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.atwho-view {
|
2 |
+
background: #FFF;
|
3 |
+
border-radius: 2px;
|
4 |
+
border: 1px solid rgb(204, 204, 204);
|
5 |
+
box-shadow: 0 0 5px rgba(204, 204, 204, 0.25), 0 0 1px #FFF;
|
6 |
+
color: #D84800;
|
7 |
+
display: none;
|
8 |
+
font-family: sans-serif;
|
9 |
+
left: 0;
|
10 |
+
margin-top: 18px;
|
11 |
+
position: absolute;
|
12 |
+
top: 0;
|
13 |
+
z-index: 1000; /* >999 for wp-admin */
|
14 |
+
}
|
15 |
+
.atwho-view ul {
|
16 |
+
list-style: none;
|
17 |
+
margin: auto;
|
18 |
+
padding: 0;
|
19 |
+
}
|
20 |
+
.atwho-view ul li {
|
21 |
+
border-bottom: 1px solid #EFEFEF;
|
22 |
+
box-sizing: content-box;
|
23 |
+
cursor: pointer;
|
24 |
+
display: block;
|
25 |
+
font-size: 14px;
|
26 |
+
height: 20px;
|
27 |
+
line-height: 20px;
|
28 |
+
margin: 0;
|
29 |
+
overflow: hidden;
|
30 |
+
padding: 5px 10px;
|
31 |
+
}
|
32 |
+
.atwho-view img {
|
33 |
+
border-radius: 2px;
|
34 |
+
float: right;
|
35 |
+
height: 20px;
|
36 |
+
width: 20px;
|
37 |
+
}
|
38 |
+
.atwho-view strong {
|
39 |
+
background: #EFEFEF;
|
40 |
+
font: bold;
|
41 |
+
}
|
42 |
+
.atwho-view .username strong {
|
43 |
+
color: #D54E21;
|
44 |
+
}
|
45 |
+
.atwho-view small {
|
46 |
+
color: #AAA;
|
47 |
+
float: right;
|
48 |
+
font-size: smaller;
|
49 |
+
font-weight: normal;
|
50 |
+
margin: 0 10px 0 40px;
|
51 |
+
}
|
52 |
+
.atwho-view .cur {
|
53 |
+
background: rgba(239, 239, 239, 0.5);
|
54 |
+
}
|
55 |
+
|
56 |
+
@media (max-width: 900px) {
|
57 |
+
.atwho-view img {
|
58 |
+
float: left;
|
59 |
+
margin: 0 10px 0 0;
|
60 |
+
}
|
61 |
+
.atwho-view small {
|
62 |
+
display: none;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
@media (max-width: 400px) {
|
66 |
+
.atwho-view ul li {
|
67 |
+
font-size: 16px;
|
68 |
+
line-height: 23px;
|
69 |
+
padding: 13px;
|
70 |
+
}
|
71 |
+
.atwho-view ul li img {
|
72 |
+
height: 30px;
|
73 |
+
margin-top: -5px;
|
74 |
+
width: 30px;
|
75 |
+
}
|
76 |
+
}
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
.atwho-view{background:#FFF;border-radius:2px;border:1px solid #ccc;box-shadow:0 0 5px rgba(204,204,204,.25),0 0 1px #FFF;color:#D84800;display:none;font-family:sans-serif;left:0;margin-top:18px;position:absolute;top:0;z-index:1000}.atwho-view ul{list-style:none;margin:auto;padding:0}.atwho-view ul li{border-bottom:1px solid #EFEFEF;box-sizing:content-box;cursor:pointer;display:block;font-size:14px;height:20px;line-height:20px;margin:0;overflow:hidden;padding:5px 10px}.atwho-view img{border-radius:2px;float:right;height:20px;width:20px}.atwho-view strong{background:#EFEFEF;font:700}.atwho-view .username strong{color:#D54E21}.atwho-view small{color:#AAA;float:right;font-size:smaller;font-weight:400;margin:0 10px 0 40px}.atwho-view .cur{background:rgba(239,239,239,.5)}@media (max-width:900px){.atwho-view img{float:left;margin:0 10px 0 0}.atwho-view small{display:none}}@media (max-width:400px){.atwho-view ul li{font-size:16px;line-height:23px;padding:13px}.atwho-view ul li img{height:30px;margin-top:-5px;width:30px}}
|
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function( $, undefined ) {
|
2 |
+
var mentionsQueryCache = [],
|
3 |
+
mentionsItem;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Adds BuddyPress @mentions to form inputs.
|
7 |
+
*
|
8 |
+
* @param {array|object} options If array, becomes the suggestions' data source. If object, passed as config to $.atwho().
|
9 |
+
* @since BuddyPress (2.1.0)
|
10 |
+
*/
|
11 |
+
$.fn.bp_mentions = function( options ) {
|
12 |
+
if ( $.isArray( options ) ) {
|
13 |
+
options = { data: options };
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Default options for at.js; see https://github.com/ichord/At.js/.
|
18 |
+
*/
|
19 |
+
var suggestionsDefaults = {
|
20 |
+
delay: 200,
|
21 |
+
hide_without_suffix: true,
|
22 |
+
insert_tpl: '</>${atwho-data-value}</>', // For contentEditable, the fake tags make jQuery insert a textNode.
|
23 |
+
limit: 10,
|
24 |
+
start_with_space: false,
|
25 |
+
suffix: '',
|
26 |
+
|
27 |
+
callbacks: {
|
28 |
+
/**
|
29 |
+
* Custom filter to only match the start of spaced words.
|
30 |
+
* Based on the core/default one.
|
31 |
+
*
|
32 |
+
* @param {string} query
|
33 |
+
* @param {array} data
|
34 |
+
* @param {string} search_key
|
35 |
+
* @return {array}
|
36 |
+
* @since BuddyPress (2.1.0)
|
37 |
+
*/
|
38 |
+
filter: function( query, data, search_key ) {
|
39 |
+
var item, _i, _len, _results = [],
|
40 |
+
regxp = new RegExp( '^' + query + '| ' + query, 'ig' ); // start of string, or preceded by a space.
|
41 |
+
|
42 |
+
for ( _i = 0, _len = data.length; _i < _len; _i++ ) {
|
43 |
+
item = data[ _i ];
|
44 |
+
if ( item[ search_key ].toLowerCase().match( regxp ) ) {
|
45 |
+
_results.push( item );
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
return _results;
|
50 |
+
},
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Removes some spaces around highlighted string and tweaks regex to allow spaces
|
54 |
+
* (to match display_name). Based on the core default.
|
55 |
+
*
|
56 |
+
* @param {unknown} li
|
57 |
+
* @param {string} query
|
58 |
+
* @return {string}
|
59 |
+
* @since BuddyPress (2.1.0)
|
60 |
+
*/
|
61 |
+
highlighter: function( li, query ) {
|
62 |
+
if ( ! query ) {
|
63 |
+
return li;
|
64 |
+
}
|
65 |
+
|
66 |
+
var regexp = new RegExp( '>(\\s*|[\\w\\s]*)(' + this.at.replace( '+', '\\+') + '?' + query.replace( '+', '\\+' ) + ')([\\w ]*)\\s*<', 'ig' );
|
67 |
+
return li.replace( regexp, function( str, $1, $2, $3 ) {
|
68 |
+
return '>' + $1 + '<strong>' + $2 + '</strong>' + $3 + '<';
|
69 |
+
});
|
70 |
+
},
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Reposition the suggestion list dynamically.
|
74 |
+
*
|
75 |
+
* @param {unknown} offset
|
76 |
+
* @since BuddyPress (2.1.0)
|
77 |
+
*/
|
78 |
+
before_reposition: function( offset ) {
|
79 |
+
var $view = $( '#atwho-ground-' + this.id + ' .atwho-view' ),
|
80 |
+
caret = this.$inputor.caret( 'offset', { iframe: $( '#content_ifr' )[0] } ).left,
|
81 |
+
move;
|
82 |
+
|
83 |
+
// If the caret is past horizontal half, then flip it, yo.
|
84 |
+
if ( caret > ( $( 'body' ).width() / 2 ) ) {
|
85 |
+
$view.addClass( 'right' );
|
86 |
+
move = caret - offset.left - this.view.$el.width();
|
87 |
+
} else {
|
88 |
+
$view.removeClass( 'right' );
|
89 |
+
move = caret - offset.left + 1;
|
90 |
+
}
|
91 |
+
|
92 |
+
offset.top += 1;
|
93 |
+
offset.left += move;
|
94 |
+
},
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Override default behaviour which inserts junk tags in the WordPress Visual editor.
|
98 |
+
*
|
99 |
+
* @param {unknown} $inputor Element which we're inserting content into.
|
100 |
+
* @param {string) content The content that will be inserted.
|
101 |
+
* @param {string) suffix Applied to the end of the content string.
|
102 |
+
* @return {string}
|
103 |
+
* @since BuddyPress (2.1.0)
|
104 |
+
*/
|
105 |
+
inserting_wrapper: function( $inputor, content, suffix ) {
|
106 |
+
var new_suffix = ( suffix === '' ) ? suffix : suffix || ' ';
|
107 |
+
return '' + content + new_suffix;
|
108 |
+
}
|
109 |
+
}
|
110 |
+
},
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Default options for our @mentions; see https://github.com/ichord/At.js/.
|
114 |
+
*/
|
115 |
+
mentionsDefaults = {
|
116 |
+
callbacks: {
|
117 |
+
/**
|
118 |
+
* If there are no matches for the query in this.data, then query BuddyPress.
|
119 |
+
*
|
120 |
+
* @param {string} query Partial @mention to search for.
|
121 |
+
* @param {function} render_view Render page callback function.
|
122 |
+
* @since BuddyPress (2.1.0)
|
123 |
+
*/
|
124 |
+
remote_filter: function( query, render_view ) {
|
125 |
+
var self = $( this );
|
126 |
+
|
127 |
+
mentionsItem = mentionsQueryCache[ query ];
|
128 |
+
if ( typeof mentionsItem === 'object' ) {
|
129 |
+
render_view( mentionsItem );
|
130 |
+
return;
|
131 |
+
}
|
132 |
+
|
133 |
+
if ( self.xhr ) {
|
134 |
+
self.xhr.abort();
|
135 |
+
}
|
136 |
+
|
137 |
+
self.xhr = $.getJSON( ajaxurl, { 'action': 'bp_get_suggestions', 'term': query, 'type': 'members' } )
|
138 |
+
/**
|
139 |
+
* Success callback for the @suggestions lookup.
|
140 |
+
*
|
141 |
+
* @param {object} response Details of users matching the query.
|
142 |
+
* @since BuddyPress (2.1.0)
|
143 |
+
*/
|
144 |
+
.done(function( response ) {
|
145 |
+
if ( ! response.success ) {
|
146 |
+
return;
|
147 |
+
}
|
148 |
+
|
149 |
+
var data = $.map( response.data,
|
150 |
+
/**
|
151 |
+
* Create a composite index to determine ordering of results;
|
152 |
+
* nicename matches will appear on top.
|
153 |
+
*
|
154 |
+
* @param {array} suggestion A suggestion's original data.
|
155 |
+
* @return {array} A suggestion's new data.
|
156 |
+
* @since BuddyPress (2.1.0)
|
157 |
+
*/
|
158 |
+
function( suggestion ) {
|
159 |
+
suggestion.search = suggestion.search || suggestion.ID + ' ' + suggestion.name;
|
160 |
+
return suggestion;
|
161 |
+
}
|
162 |
+
);
|
163 |
+
|
164 |
+
mentionsQueryCache[ query ] = data;
|
165 |
+
render_view( data );
|
166 |
+
});
|
167 |
+
}
|
168 |
+
},
|
169 |
+
|
170 |
+
data: $.map( options.data,
|
171 |
+
/**
|
172 |
+
* Create a composite index to search against of nicename + display name.
|
173 |
+
* This will also determine ordering of results, so nicename matches will appear on top.
|
174 |
+
*
|
175 |
+
* @param {array} suggestion A suggestion's original data.
|
176 |
+
* @return {array} A suggestion's new data.
|
177 |
+
* @since BuddyPress (2.1.0)
|
178 |
+
*/
|
179 |
+
function( suggestion ) {
|
180 |
+
suggestion.search = suggestion.search || suggestion.ID + ' ' + suggestion.name;
|
181 |
+
return suggestion;
|
182 |
+
}
|
183 |
+
),
|
184 |
+
|
185 |
+
at: '@',
|
186 |
+
search_key: 'search',
|
187 |
+
tpl: '<li data-value="@${ID}"><img src="${image}" /><span class="username">@${ID}</span><small>${name}</small></li>'
|
188 |
+
},
|
189 |
+
|
190 |
+
opts = $.extend( true, {}, suggestionsDefaults, mentionsDefaults, options );
|
191 |
+
return $.fn.atwho.call( this, opts );
|
192 |
+
};
|
193 |
+
|
194 |
+
$( document ).ready(function() {
|
195 |
+
var users = [];
|
196 |
+
|
197 |
+
if ( typeof window.BP_Suggestions === 'object' ) {
|
198 |
+
users = window.BP_Suggestions.friends || users;
|
199 |
+
}
|
200 |
+
|
201 |
+
// Activity/reply, post comments, dashboard post 'text' editor.
|
202 |
+
$( '.bp-suggestions, #comments form textarea, .wp-editor-area' ).bp_mentions( users );
|
203 |
+
});
|
204 |
+
})( jQuery );
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
!function(a){var b,c=[];a.fn.bp_mentions=function(d){a.isArray(d)&&(d={data:d});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(b){var c,d=a("#atwho-ground-"+this.id+" .atwho-view"),e=this.$inputor.caret("offset",{iframe:a("#content_ifr")[0]}).left;e>a("body").width()/2?(d.addClass("right"),c=e-b.left-this.view.$el.width()):(d.removeClass("right"),c=e-b.left+1),b.top+=1,b.left+=c},inserting_wrapper:function(a,b,c){var d=""===c?c:c||" ";return""+b+d}}},f={callbacks:{remote_filter:function(d,e){var f=a(this);return b=c[d],"object"==typeof b?void e(b):(f.xhr&&f.xhr.abort(),void(f.xhr=a.getJSON(ajaxurl,{action:"bp_get_suggestions",term:d,type:"members"}).done(function(b){if(b.success){var f=a.map(b.data,function(a){return a.search=a.search||a.ID+" "+a.name,a});c[d]=f,e(f)}})))}},data:a.map(d.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=a.extend(!0,{},e,f,d);return a.fn.atwho.call(this,g)},a(document).ready(function(){var b=[];"object"==typeof window.BP_Suggestions&&(b=window.BP_Suggestions.friends||b),a(".bp-suggestions, #comments form textarea, .wp-editor-area").bp_mentions(b)})}(jQuery);
|
@@ -32,7 +32,8 @@ function bp_blogs_register_activity_actions() {
|
|
32 |
$bp->blogs->id,
|
33 |
'new_blog',
|
34 |
__( 'New site created', 'buddypress' ),
|
35 |
-
'bp_blogs_format_activity_action_new_blog'
|
|
|
36 |
);
|
37 |
}
|
38 |
|
@@ -40,14 +41,18 @@ function bp_blogs_register_activity_actions() {
|
|
40 |
$bp->blogs->id,
|
41 |
'new_blog_post',
|
42 |
__( 'New post published', 'buddypress' ),
|
43 |
-
'bp_blogs_format_activity_action_new_blog_post'
|
|
|
|
|
44 |
);
|
45 |
|
46 |
bp_activity_set_action(
|
47 |
$bp->blogs->id,
|
48 |
'new_blog_comment',
|
49 |
__( 'New post comment posted', 'buddypress' ),
|
50 |
-
'bp_blogs_format_activity_action_new_blog_comment'
|
|
|
|
|
51 |
);
|
52 |
|
53 |
do_action( 'bp_blogs_register_activity_actions' );
|
@@ -264,8 +269,9 @@ function bp_blogs_record_activity( $args = '' ) {
|
|
264 |
global $bp;
|
265 |
|
266 |
// Bail if activity is not active
|
267 |
-
if ( ! bp_is_active( 'activity' ) )
|
268 |
return false;
|
|
|
269 |
|
270 |
$defaults = array(
|
271 |
'user_id' => bp_loggedin_user_id(),
|
@@ -281,28 +287,30 @@ function bp_blogs_record_activity( $args = '' ) {
|
|
281 |
);
|
282 |
|
283 |
$r = wp_parse_args( $args, $defaults );
|
284 |
-
extract( $r, EXTR_SKIP );
|
285 |
|
286 |
// Remove large images and replace them with just one image thumbnail
|
287 |
-
|
288 |
-
$content = bp_activity_thumbnail_content_images( $content, $primary_link, $r );
|
|
|
289 |
|
290 |
-
if ( !empty( $action ) )
|
291 |
-
$action = apply_filters( 'bp_blogs_record_activity_action', $action );
|
|
|
292 |
|
293 |
-
if ( !empty( $content ) )
|
294 |
-
$content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $content ), $content );
|
|
|
295 |
|
296 |
// Check for an existing entry and update if one exists.
|
297 |
$id = bp_activity_get_activity_id( array(
|
298 |
-
'user_id' => $user_id,
|
299 |
-
'component' => $component,
|
300 |
-
'type' => $type,
|
301 |
-
'item_id' => $item_id,
|
302 |
-
'secondary_item_id' => $secondary_item_id
|
303 |
) );
|
304 |
|
305 |
-
return bp_activity_add( array( 'id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
|
306 |
}
|
307 |
|
308 |
/**
|
@@ -311,7 +319,6 @@ function bp_blogs_record_activity( $args = '' ) {
|
|
311 |
* @since BuddyPress (1.0.0)
|
312 |
*
|
313 |
* @see bp_activity_delete() for description of parameters.
|
314 |
-
* @global object $bp The BuddyPress global settings object.
|
315 |
*
|
316 |
* @param array $args {
|
317 |
* See {@link bp_activity_delete()} for complete description of arguments.
|
@@ -321,31 +328,22 @@ function bp_blogs_record_activity( $args = '' ) {
|
|
321 |
* }
|
322 |
* @return bool True on success, false on failure.
|
323 |
*/
|
324 |
-
function bp_blogs_delete_activity( $args =
|
325 |
-
global $bp;
|
326 |
|
327 |
// Bail if activity is not active
|
328 |
-
if ( ! bp_is_active( 'activity' ) )
|
329 |
return false;
|
|
|
330 |
|
331 |
-
$
|
332 |
'item_id' => false,
|
333 |
-
'component' =>
|
334 |
'type' => false,
|
335 |
'user_id' => false,
|
336 |
'secondary_item_id' => false
|
337 |
-
);
|
338 |
-
|
339 |
-
$params = wp_parse_args( $args, $defaults );
|
340 |
-
extract( $params, EXTR_SKIP );
|
341 |
-
|
342 |
-
bp_activity_delete_by_item_id( array(
|
343 |
-
'item_id' => $item_id,
|
344 |
-
'component' => $component,
|
345 |
-
'type' => $type,
|
346 |
-
'user_id' => $user_id,
|
347 |
-
'secondary_item_id' => $secondary_item_id
|
348 |
) );
|
|
|
|
|
349 |
}
|
350 |
|
351 |
/**
|
@@ -646,16 +644,86 @@ add_action( 'bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comm
|
|
646 |
* @since BuddyPress (2.0.0)
|
647 |
*
|
648 |
* @param int $post_id The post ID
|
649 |
-
* @param array $
|
650 |
* value is the $comment->comment_approved value.
|
651 |
*/
|
652 |
-
function bp_blogs_remove_activity_meta_for_trashed_comments( $post_id, $
|
653 |
-
|
654 |
-
|
|
|
|
|
655 |
}
|
656 |
}
|
657 |
add_action( 'trashed_post_comments', 'bp_blogs_remove_activity_meta_for_trashed_comments', 10, 2 );
|
658 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
659 |
/**
|
660 |
* Utility function to set up some variables for use in the activity loop.
|
661 |
*
|
@@ -842,10 +910,16 @@ add_filter( 'bp_activity_can_comment_reply', 'bp_blogs_can_comment_reply', 10, 2
|
|
842 |
* @param string $retval The activity comment permalink
|
843 |
* @return string
|
844 |
*/
|
845 |
-
function bp_blogs_activity_comment_permalink( $retval ) {
|
846 |
global $activities_template;
|
847 |
|
848 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
849 |
$retval = $activities_template->activity->current_comment->primary_link;
|
850 |
}
|
851 |
|
32 |
$bp->blogs->id,
|
33 |
'new_blog',
|
34 |
__( 'New site created', 'buddypress' ),
|
35 |
+
'bp_blogs_format_activity_action_new_blog',
|
36 |
+
__( 'New Sites', 'buddypress' )
|
37 |
);
|
38 |
}
|
39 |
|
41 |
$bp->blogs->id,
|
42 |
'new_blog_post',
|
43 |
__( 'New post published', 'buddypress' ),
|
44 |
+
'bp_blogs_format_activity_action_new_blog_post',
|
45 |
+
__( 'Posts', 'buddypress' ),
|
46 |
+
array( 'activity', 'member' )
|
47 |
);
|
48 |
|
49 |
bp_activity_set_action(
|
50 |
$bp->blogs->id,
|
51 |
'new_blog_comment',
|
52 |
__( 'New post comment posted', 'buddypress' ),
|
53 |
+
'bp_blogs_format_activity_action_new_blog_comment',
|
54 |
+
__( 'Comments', 'buddypress' ),
|
55 |
+
array( 'activity', 'member' )
|
56 |
);
|
57 |
|
58 |
do_action( 'bp_blogs_register_activity_actions' );
|
269 |
global $bp;
|
270 |
|
271 |
// Bail if activity is not active
|
272 |
+
if ( ! bp_is_active( 'activity' ) ) {
|
273 |
return false;
|
274 |
+
}
|
275 |
|
276 |
$defaults = array(
|
277 |
'user_id' => bp_loggedin_user_id(),
|
287 |
);
|
288 |
|
289 |
$r = wp_parse_args( $args, $defaults );
|
|
|
290 |
|
291 |
// Remove large images and replace them with just one image thumbnail
|
292 |
+
if ( ! empty( $r['content'] ) ) {
|
293 |
+
$r['content'] = bp_activity_thumbnail_content_images( $r['content'], $r['primary_link'], $r );
|
294 |
+
}
|
295 |
|
296 |
+
if ( ! empty( $r['action'] ) ) {
|
297 |
+
$r['action'] = apply_filters( 'bp_blogs_record_activity_action', $r['action'] );
|
298 |
+
}
|
299 |
|
300 |
+
if ( ! empty( $r['content'] ) ) {
|
301 |
+
$r['content'] = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $r['content'] ), $r['content'], $r );
|
302 |
+
}
|
303 |
|
304 |
// Check for an existing entry and update if one exists.
|
305 |
$id = bp_activity_get_activity_id( array(
|
306 |
+
'user_id' => $r['user_id'],
|
307 |
+
'component' => $r['component'],
|
308 |
+
'type' => $r['type'],
|
309 |
+
'item_id' => $r['item_id'],
|
310 |
+
'secondary_item_id' => $r['secondary_item_id'],
|
311 |
) );
|
312 |
|
313 |
+
return bp_activity_add( array( 'id' => $id, 'user_id' => $r['user_id'], 'action' => $r['action'], 'content' => $r['content'], 'primary_link' => $r['primary_link'], 'component' => $r['component'], 'type' => $r['type'], 'item_id' => $r['item_id'], 'secondary_item_id' => $r['secondary_item_id'], 'recorded_time' => $r['recorded_time'], 'hide_sitewide' => $r['hide_sitewide'] ) );
|
314 |
}
|
315 |
|
316 |
/**
|
319 |
* @since BuddyPress (1.0.0)
|
320 |
*
|
321 |
* @see bp_activity_delete() for description of parameters.
|
|
|
322 |
*
|
323 |
* @param array $args {
|
324 |
* See {@link bp_activity_delete()} for complete description of arguments.
|
328 |
* }
|
329 |
* @return bool True on success, false on failure.
|
330 |
*/
|
331 |
+
function bp_blogs_delete_activity( $args = '' ) {
|
|
|
332 |
|
333 |
// Bail if activity is not active
|
334 |
+
if ( ! bp_is_active( 'activity' ) ) {
|
335 |
return false;
|
336 |
+
}
|
337 |
|
338 |
+
$r = bp_parse_args( $args, array(
|
339 |
'item_id' => false,
|
340 |
+
'component' => buddypress()->blogs->id,
|
341 |
'type' => false,
|
342 |
'user_id' => false,
|
343 |
'secondary_item_id' => false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
) );
|
345 |
+
|
346 |
+
bp_activity_delete_by_item_id( $r );
|
347 |
}
|
348 |
|
349 |
/**
|
644 |
* @since BuddyPress (2.0.0)
|
645 |
*
|
646 |
* @param int $post_id The post ID
|
647 |
+
* @param array $comments Array of comment statuses. The key is comment ID, the
|
648 |
* value is the $comment->comment_approved value.
|
649 |
*/
|
650 |
+
function bp_blogs_remove_activity_meta_for_trashed_comments( $post_id = 0, $comments = array() ) {
|
651 |
+
if ( ! empty( $comments ) ) {
|
652 |
+
foreach ( array_keys( $comments ) as $comment_id ) {
|
653 |
+
delete_comment_meta( $comment_id, 'bp_activity_comment_id' );
|
654 |
+
}
|
655 |
}
|
656 |
}
|
657 |
add_action( 'trashed_post_comments', 'bp_blogs_remove_activity_meta_for_trashed_comments', 10, 2 );
|
658 |
|
659 |
+
/**
|
660 |
+
* Filter 'new_blog_comment' bp_has_activities() loop to include new- and old-style blog activity comment items.
|
661 |
+
*
|
662 |
+
* In BuddyPress 2.0, the schema for storing activity items related to blog
|
663 |
+
* posts changed. Instead creating new top-level 'new_blog_comment' activity
|
664 |
+
* items, blog comments are recorded in the activity stream as comments on the
|
665 |
+
* 'new_blog_post' activity items corresponding to the parent post. This filter
|
666 |
+
* ensures that the 'new_blog_comment' filter in bp_has_activities() (which
|
667 |
+
* powers the 'Comments' filter in the activity directory dropdown) includes
|
668 |
+
* both old-style and new-style activity comments.
|
669 |
+
*
|
670 |
+
* This implementation involves filtering the activity queries directly, and
|
671 |
+
* should be considered a stopgap. The proper solution would involve enabling
|
672 |
+
* multiple query condition clauses, connected by an OR, in the bp_has_activities()
|
673 |
+
* API.
|
674 |
+
*
|
675 |
+
* @since BuddyPress (2.1.0)
|
676 |
+
*
|
677 |
+
* @param array $args Arguments passed from bp_parse_args() in bp_has_activities().
|
678 |
+
* @return array $args
|
679 |
+
*/
|
680 |
+
function bp_blogs_new_blog_comment_query_backpat( $args ) {
|
681 |
+
// Bail if this is not a 'new_blog_comment' query
|
682 |
+
if ( 'new_blog_comment' !== $args['action'] ) {
|
683 |
+
return $args;
|
684 |
+
}
|
685 |
+
|
686 |
+
// display_comments=stream is required to show new-style
|
687 |
+
// 'activity_comment' items inline
|
688 |
+
$args['display_comments'] = 'stream';
|
689 |
+
|
690 |
+
// For the remaining clauses, we filter the SQL query directly
|
691 |
+
add_filter( 'bp_activity_paged_activities_sql', '_bp_blogs_new_blog_comment_query_backpat_filter' );
|
692 |
+
add_filter( 'bp_activity_total_activities_sql', '_bp_blogs_new_blog_comment_query_backpat_filter' );
|
693 |
+
|
694 |
+
// Return the original arguments
|
695 |
+
return $args;
|
696 |
+
}
|
697 |
+
add_filter( 'bp_after_has_activities_parse_args', 'bp_blogs_new_blog_comment_query_backpat' );
|
698 |
+
|
699 |
+
/**
|
700 |
+
* Filter activity SQL to include new- and old-style 'new_blog_comment' activity items.
|
701 |
+
*
|
702 |
+
* @since BuddyPress (2.1.0)
|
703 |
+
*
|
704 |
+
* @access private
|
705 |
+
* @see bp_blogs_new_blog_comment_query_backpat()
|
706 |
+
*
|
707 |
+
* @param string $query SQL query as assembled in BP_Activity_Activity::get().
|
708 |
+
* @return string $query Modified SQL query.
|
709 |
+
*/
|
710 |
+
function _bp_blogs_new_blog_comment_query_backpat_filter( $query ) {
|
711 |
+
$bp = buddypress();
|
712 |
+
|
713 |
+
// The query passed to the filter is for old-style 'new_blog_comment'
|
714 |
+
// items. We include new-style 'activity_comment' items by running a
|
715 |
+
// subquery inside of a large OR clause.
|
716 |
+
$activity_comment_subquery = "SELECT a.id FROM {$bp->activity->table_name} a INNER JOIN {$bp->activity->table_name_meta} am ON (a.id = am.activity_id) WHERE am.meta_key = 'bp_blogs_post_comment_id' AND a.type = 'activity_comment'";
|
717 |
+
|
718 |
+
// WHERE ( [original WHERE clauses] OR a.id IN (activity_comment subquery) )
|
719 |
+
$query = preg_replace( '|WHERE (.*?) ORDER|', 'WHERE ( ( $1 ) OR ( a.id IN ( ' . $activity_comment_subquery . ' ) ) ) ORDER', $query );
|
720 |
+
|
721 |
+
// Don't run this on future queries
|
722 |
+
remove_filter( current_filter(), '_bp_blogs_new_blog_comment_query_backpat_filter' );
|
723 |
+
|
724 |
+
return $query;
|
725 |
+
}
|
726 |
+
|
727 |
/**
|
728 |
* Utility function to set up some variables for use in the activity loop.
|
729 |
*
|
910 |
* @param string $retval The activity comment permalink
|
911 |
* @return string
|
912 |
*/
|
913 |
+
function bp_blogs_activity_comment_permalink( $retval = '' ) {
|
914 |
global $activities_template;
|
915 |
|
916 |
+
// Get the current comment ID
|
917 |
+
$item_id = isset( $activities_template->activity->current_comment->item_id )
|
918 |
+
? $activities_template->activity->current_comment->item_id
|
919 |
+
: false;
|
920 |
+
|
921 |
+
// Maybe adjust the link if item ID exists
|
922 |
+
if ( ( false !== $item_id ) && isset( buddypress()->blogs->allow_comments[ $item_id ] ) ) {
|
923 |
$retval = $activities_template->activity->current_comment->primary_link;
|
924 |
}
|
925 |
|
@@ -1,78 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* BuddyPress Blogs BuddyBar functions.
|
5 |
-
*
|
6 |
-
* @package BuddyPress
|
7 |
-
* @subpackage BlogsBuddyBar
|
8 |
-
*/
|
9 |
-
|
10 |
-
// Exit if accessed directly
|
11 |
-
if ( !defined( 'ABSPATH' ) ) exit;
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Add a Sites menu to the BuddyBar.
|
15 |
-
*
|
16 |
-
* @since BuddyPress (1.0.0)
|
17 |
-
*
|
18 |
-
* @global object $bp The BuddyPress global settings object.
|
19 |
-
*
|
20 |
-
* @return bool|null Returns false on failure. Otherwise echoes the menu item.
|
21 |
-
*/
|
22 |
-
function bp_adminbar_blogs_menu() {
|
23 |
-
global $bp;
|
24 |
-
|
25 |
-
if ( !is_user_logged_in() || !bp_is_active( 'blogs' ) )
|
26 |
-
return false;
|
27 |
-
|
28 |
-
if ( !is_multisite() )
|
29 |
-
return false;
|
30 |
-
|
31 |
-
$blogs = wp_cache_get( 'bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', 'bp' );
|
32 |
-
if ( empty( $blogs ) ) {
|
33 |
-
$blogs = bp_blogs_get_blogs_for_user( bp_loggedin_user_id(), true );
|
34 |
-
wp_cache_set( 'bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', $blogs, 'bp' );
|
35 |
-
}
|
36 |
-
|
37 |
-
$counter = 0;
|
38 |
-
if ( is_array( $blogs['blogs'] ) && (int) $blogs['count'] ) {
|
39 |
-
|
40 |
-
echo '<li id="bp-adminbar-blogs-menu"><a href="' . trailingslashit( bp_loggedin_user_domain() . bp_get_blogs_slug() ) . '">';
|
41 |
-
|
42 |
-
_e( 'My Sites', 'buddypress' );
|
43 |
-
|
44 |
-
echo '</a>';
|
45 |
-
echo '<ul>';
|
46 |
-
|
47 |
-
foreach ( (array) $blogs['blogs'] as $blog ) {
|
48 |
-
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
49 |
-
$site_url = esc_attr( $blog->siteurl );
|
50 |
-
|
51 |
-
echo '<li' . $alt . '>';
|
52 |
-
echo '<a href="' . $site_url . '">' . esc_html( $blog->name ) . '</a>';
|
53 |
-
echo '<ul>';
|
54 |
-
echo '<li class="alt"><a href="' . $site_url . 'wp-admin/">' . __( 'Dashboard', 'buddypress' ) . '</a></li>';
|
55 |
-
echo '<li><a href="' . $site_url . 'wp-admin/post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';
|
56 |
-
echo '<li class="alt"><a href="' . $site_url . 'wp-admin/edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
|
57 |
-
echo '<li><a href="' . $site_url . 'wp-admin/edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';
|
58 |
-
echo '</ul>';
|
59 |
-
|
60 |
-
do_action( 'bp_adminbar_blog_items', $blog );
|
61 |
-
|
62 |
-
echo '</li>';
|
63 |
-
$counter++;
|
64 |
-
}
|
65 |
-
|
66 |
-
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
67 |
-
|
68 |
-
if ( bp_blog_signup_enabled() ) {
|
69 |
-
echo '<li' . $alt . '>';
|
70 |
-
echo '<a href="' . bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create/">' . __( 'Create a Site!', 'buddypress' ) . '</a>';
|
71 |
-
echo '</li>';
|
72 |
-
}
|
73 |
-
|
74 |
-
echo '</ul>';
|
75 |
-
echo '</li>';
|
76 |
-
}
|
77 |
-
}
|
78 |
-
add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -156,9 +156,10 @@ class BP_Blogs_Blog {
|
|
156 |
}
|
157 |
|
158 |
if ( !empty( $search_terms ) ) {
|
159 |
-
$
|
160 |
-
$
|
161 |
-
$
|
|
|
162 |
} else {
|
163 |
$paged_blogs = $wpdb->get_results( "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, bm2.meta_value as name FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$wpdb->base_prefix}blogs wb, {$wpdb->users} u WHERE b.blog_id = wb.blog_id AND b.user_id = u.ID AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id {$user_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'last_activity' AND bm2.meta_key = 'name' {$include_sql} GROUP BY b.blog_id {$order_sql} {$pag_sql}" );
|
164 |
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id {$user_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$include_sql} {$hidden_sql}" );
|
@@ -342,7 +343,8 @@ class BP_Blogs_Blog {
|
|
342 |
public static function search_blogs( $filter, $limit = null, $page = null ) {
|
343 |
global $wpdb, $bp;
|
344 |
|
345 |
-
$
|
|
|
346 |
|
347 |
$hidden_sql = '';
|
348 |
if ( !bp_current_user_can( 'bp_moderate' ) )
|
@@ -353,8 +355,8 @@ class BP_Blogs_Blog {
|
|
353 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
354 |
}
|
355 |
|
356 |
-
$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
|
357 |
-
$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
|
358 |
|
359 |
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
360 |
}
|
@@ -403,17 +405,19 @@ class BP_Blogs_Blog {
|
|
403 |
public static function get_by_letter( $letter, $limit = null, $page = null ) {
|
404 |
global $bp, $wpdb;
|
405 |
|
406 |
-
$
|
|
|
407 |
|
408 |
$hidden_sql = '';
|
409 |
if ( !bp_current_user_can( 'bp_moderate' ) )
|
410 |
$hidden_sql = "AND wb.public = 1";
|
411 |
|
|
|
412 |
if ( $limit && $page )
|
413 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
414 |
|
415 |
-
$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
|
416 |
-
$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
|
417 |
|
418 |
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
419 |
}
|
156 |
}
|
157 |
|
158 |
if ( !empty( $search_terms ) ) {
|
159 |
+
$search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
|
160 |
+
$search_terms_sql = $wpdb->prepare( 'bm2.meta_value LIKE %s', $search_terms_like );
|
161 |
+
$paged_blogs = $wpdb->get_results( "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, bm2.meta_value as name FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$wpdb->base_prefix}blogs wb, {$wpdb->users} u WHERE b.blog_id = wb.blog_id AND b.user_id = u.ID AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'last_activity' AND bm2.meta_key = 'name' AND {$search_terms_sql} {$user_sql} {$include_sql} GROUP BY b.blog_id {$order_sql} {$pag_sql}" );
|
162 |
+
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2 WHERE b.blog_id = wb.blog_id AND bm.blog_id = b.blog_id AND bm2.blog_id = b.blog_id AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'name' AND bm2.meta_key = 'description' AND {$search_terms_sql} {$user_sql} {$include_sql}" );
|
163 |
} else {
|
164 |
$paged_blogs = $wpdb->get_results( "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, bm2.meta_value as name FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$wpdb->base_prefix}blogs wb, {$wpdb->users} u WHERE b.blog_id = wb.blog_id AND b.user_id = u.ID AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id {$user_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'last_activity' AND bm2.meta_key = 'name' {$include_sql} GROUP BY b.blog_id {$order_sql} {$pag_sql}" );
|
165 |
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id {$user_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$include_sql} {$hidden_sql}" );
|
343 |
public static function search_blogs( $filter, $limit = null, $page = null ) {
|
344 |
global $wpdb, $bp;
|
345 |
|
346 |
+
$search_terms_like = '%' . bp_esc_like( $filter ) . '%';
|
347 |
+
$search_terms_sql = $wpdb->prepare( 'bm.meta_value LIKE %s', $search_terms_like );
|
348 |
|
349 |
$hidden_sql = '';
|
350 |
if ( !bp_current_user_can( 'bp_moderate' ) )
|
355 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
356 |
}
|
357 |
|
358 |
+
$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}" );
|
359 |
+
$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" );
|
360 |
|
361 |
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
362 |
}
|
405 |
public static function get_by_letter( $letter, $limit = null, $page = null ) {
|
406 |
global $bp, $wpdb;
|
407 |
|
408 |
+
$letter_like = '%' . bp_esc_like( $letter ) . '%';
|
409 |
+
$letter_sql = $wpdb->prepare( 'bm.meta_value LIKE %s', $letter_like );
|
410 |
|
411 |
$hidden_sql = '';
|
412 |
if ( !bp_current_user_can( 'bp_moderate' ) )
|
413 |
$hidden_sql = "AND wb.public = 1";
|
414 |
|
415 |
+
$pag_sql = '';
|
416 |
if ( $limit && $page )
|
417 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
418 |
|
419 |
+
$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}" );
|
420 |
+
$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" );
|
421 |
|
422 |
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
423 |
}
|
@@ -36,3 +36,19 @@ function bp_blogs_creation_location( $url ) {
|
|
36 |
return apply_filters( 'bp_blogs_creation_location', trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create', $url ) );
|
37 |
}
|
38 |
add_filter( 'wp_signup_location', 'bp_blogs_creation_location' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
return apply_filters( 'bp_blogs_creation_location', trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create', $url ) );
|
37 |
}
|
38 |
add_filter( 'wp_signup_location', 'bp_blogs_creation_location' );
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Only select comments by ID instead of all fields when using get_comments().
|
42 |
+
*
|
43 |
+
* @since BuddyPress (2.1.0)
|
44 |
+
*
|
45 |
+
* @see bp_blogs_update_post()
|
46 |
+
*
|
47 |
+
* @param array Current SQL clauses in array format
|
48 |
+
* @return array
|
49 |
+
*/
|
50 |
+
function bp_blogs_comments_clauses_select_by_id( $retval ) {
|
51 |
+
$retval['fields'] = 'comment_ID';
|
52 |
+
|
53 |
+
return $retval;
|
54 |
+
}
|
@@ -44,57 +44,110 @@ function bp_blogs_has_directory() {
|
|
44 |
*/
|
45 |
function bp_blogs_get_blogs( $args = '' ) {
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
'
|
50 |
-
'include_blog_ids' => false,
|
51 |
-
'
|
|
|
52 |
'per_page' => 20, // The number of results to return per page
|
53 |
'page' => 1, // The page to return if limiting per page
|
54 |
-
'update_meta_cache' => true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
);
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
return apply_filters( 'bp_blogs_get_blogs', BP_Blogs_Blog::get( $type, $per_page, $page, $user_id, $search_terms, $update_meta_cache, $include_blog_ids ), $params );
|
61 |
}
|
62 |
|
63 |
/**
|
64 |
* Populate the BP blogs table with existing blogs.
|
65 |
*
|
66 |
-
* @
|
|
|
67 |
* @global object $wpdb WordPress database object
|
68 |
* @uses get_users()
|
69 |
* @uses bp_blogs_record_blog()
|
70 |
*/
|
71 |
function bp_blogs_record_existing_blogs() {
|
72 |
-
global $
|
73 |
-
|
74 |
-
// Truncate user blogs table and re-record.
|
75 |
-
$wpdb->query( "DELETE FROM {$bp->blogs->table_name} WHERE 1=1" );
|
76 |
|
|
|
77 |
if ( is_multisite() ) {
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
} else {
|
80 |
-
$blog_ids =
|
81 |
}
|
82 |
|
83 |
-
if
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
}
|
|
|
|
|
|
|
98 |
}
|
99 |
|
100 |
/**
|
@@ -295,7 +348,7 @@ add_action( 'update_option_close_comments_for_old_posts', 'bp_blogs_update_optio
|
|
295 |
* unused here.
|
296 |
* @param string $newvalue Value to change meta to.
|
297 |
*/
|
298 |
-
function
|
299 |
global $wpdb;
|
300 |
|
301 |
bp_blogs_update_blogmeta( $wpdb->blogid, 'close_comments_days_old', $newvalue );
|
@@ -470,7 +523,7 @@ function bp_blogs_record_post( $post_id, $post, $user_id = 0 ) {
|
|
470 |
|
471 |
$activity_content = $post->post_content;
|
472 |
|
473 |
-
bp_blogs_record_activity( array(
|
474 |
'user_id' => (int) $post->post_author,
|
475 |
'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, $post, $post_permalink ),
|
476 |
'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
|
@@ -478,7 +531,11 @@ function bp_blogs_record_post( $post_id, $post, $user_id = 0 ) {
|
|
478 |
'item_id' => $blog_id,
|
479 |
'secondary_item_id' => $post_id,
|
480 |
'recorded_time' => $post->post_date_gmt,
|
481 |
-
));
|
|
|
|
|
|
|
|
|
482 |
}
|
483 |
|
484 |
// Update the blogs last activity
|
@@ -518,9 +575,77 @@ function bp_blogs_update_post( $post ) {
|
|
518 |
|
519 |
// update the activity entry
|
520 |
$activity = new BP_Activity_Activity( $activity_id );
|
521 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
$activity->save();
|
523 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
524 |
// add post comment status to activity meta if closed
|
525 |
if( 'closed' == $post->comment_status ) {
|
526 |
bp_activity_update_meta( $activity_id, 'post_comment_status', $post->comment_status );
|
@@ -618,7 +743,11 @@ function bp_blogs_record_comment( $comment_id, $is_approved = true ) {
|
|
618 |
$args['secondary_item_id'] = $comment_id;
|
619 |
|
620 |
// record the activity entry
|
621 |
-
bp_blogs_record_activity( $args );
|
|
|
|
|
|
|
|
|
622 |
|
623 |
// record comment as BP activity comment under the parent 'new_blog_post'
|
624 |
// activity item
|
@@ -682,6 +811,8 @@ function bp_blogs_record_comment( $comment_id, $is_approved = true ) {
|
|
682 |
if ( empty( $args['id'] ) ) {
|
683 |
// add meta to activity comment
|
684 |
bp_activity_update_meta( $comment_activity_id, 'bp_blogs_post_comment_id', $comment_id );
|
|
|
|
|
685 |
|
686 |
// add meta to comment
|
687 |
add_comment_meta( $comment_id, 'bp_activity_comment_id', $comment_activity_id );
|
@@ -705,40 +836,77 @@ add_action( 'edit_comment', 'bp_blogs_record_comment', 10 );
|
|
705 |
* set/changed ('add_user_to_blog', 'profile_update', 'user_register'). It
|
706 |
* parses the changes, and records them as necessary in the BP blog tracker.
|
707 |
*
|
708 |
-
* BuddyPress does not track blogs for
|
|
|
|
|
|
|
|
|
|
|
|
|
709 |
*
|
710 |
-
* @param int $user_id The ID of the user.
|
711 |
-
* @param string|bool $role The WP role being assigned to the user
|
712 |
-
* ('subscriber', 'contributor', 'author', 'editor', 'administrator', or
|
713 |
-
* a custom role). Defaults to false.
|
714 |
-
* @param int $blog_id Default: the current blog ID.
|
715 |
* @return bool|null False on failure.
|
716 |
*/
|
717 |
function bp_blogs_add_user_to_blog( $user_id, $role = false, $blog_id = 0 ) {
|
718 |
global $wpdb;
|
719 |
|
|
|
720 |
if ( empty( $blog_id ) ) {
|
721 |
$blog_id = isset( $wpdb->blogid ) ? $wpdb->blogid : bp_get_root_blog_id();
|
722 |
}
|
723 |
|
|
|
724 |
if ( empty( $role ) ) {
|
725 |
-
$key = $wpdb->get_blog_prefix( $blog_id ). 'capabilities';
|
726 |
|
727 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
728 |
|
729 |
-
|
730 |
-
$
|
731 |
-
|
732 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
733 |
}
|
734 |
|
735 |
-
if
|
736 |
-
|
|
|
|
|
|
|
|
|
|
|
737 |
}
|
738 |
add_action( 'add_user_to_blog', 'bp_blogs_add_user_to_blog', 10, 3 );
|
739 |
add_action( 'profile_update', 'bp_blogs_add_user_to_blog' );
|
740 |
add_action( 'user_register', 'bp_blogs_add_user_to_blog' );
|
741 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
742 |
/**
|
743 |
* Remove a blog-user pair from BP's blog tracker.
|
744 |
*
|
@@ -748,8 +916,9 @@ add_action( 'user_register', 'bp_blogs_add_user_to_blog' );
|
|
748 |
function bp_blogs_remove_user_from_blog( $user_id, $blog_id = 0 ) {
|
749 |
global $wpdb;
|
750 |
|
751 |
-
if ( empty( $blog_id ) )
|
752 |
$blog_id = $wpdb->blogid;
|
|
|
753 |
|
754 |
bp_blogs_remove_blog_for_user( $user_id, $blog_id );
|
755 |
}
|
@@ -1050,16 +1219,24 @@ function bp_blogs_total_blogs() {
|
|
1050 |
/**
|
1051 |
* Get the total number of blogs being tracked by BP for a specific user.
|
1052 |
*
|
|
|
|
|
1053 |
* @param int $user_id ID of the user being queried. Default: on a user page,
|
1054 |
* the displayed user. Otherwise, the logged-in user.
|
1055 |
* @return int $count Total blog count for the user.
|
1056 |
*/
|
1057 |
function bp_blogs_total_blogs_for_user( $user_id = 0 ) {
|
1058 |
-
|
1059 |
-
if ( empty( $user_id ) )
|
1060 |
$user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
|
|
|
|
|
|
|
|
|
|
|
|
|
1061 |
|
1062 |
-
|
|
|
1063 |
$count = BP_Blogs_Blog::total_blog_count_for_user( $user_id );
|
1064 |
wp_cache_set( 'bp_total_blogs_for_user_' . $user_id, $count, 'bp' );
|
1065 |
}
|
@@ -1245,7 +1422,7 @@ function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value, $prev_value
|
|
1245 |
* @param int $blog_id ID of the blog.
|
1246 |
* @param string $meta_key Metadata key.
|
1247 |
* @param mixed $meta_value Metadata value.
|
1248 |
-
* @param bool $unique
|
1249 |
* for the given key. If true, and the object already has a value for
|
1250 |
* the key, no change will be made. Default: false.
|
1251 |
* @return int|bool The meta ID on successful update, false on failure.
|
44 |
*/
|
45 |
function bp_blogs_get_blogs( $args = '' ) {
|
46 |
|
47 |
+
// Parse query arguments
|
48 |
+
$r = bp_parse_args( $args, array(
|
49 |
+
'type' => 'active', // 'active', 'alphabetical', 'newest', or 'random'
|
50 |
+
'include_blog_ids' => false, // Array of blog IDs to include
|
51 |
+
'user_id' => false, // Limit to blogs this user can post to
|
52 |
+
'search_terms' => false, // Limit to blogs matching these search terms
|
53 |
'per_page' => 20, // The number of results to return per page
|
54 |
'page' => 1, // The page to return if limiting per page
|
55 |
+
'update_meta_cache' => true // Whether to pre-fetch blogmeta
|
56 |
+
), 'blogs_get_blogs' );
|
57 |
+
|
58 |
+
// Get the blogs
|
59 |
+
$blogs = BP_Blogs_Blog::get(
|
60 |
+
$r['type'],
|
61 |
+
$r['per_page'],
|
62 |
+
$r['page'],
|
63 |
+
$r['user_id'],
|
64 |
+
$r['search_terms'],
|
65 |
+
$r['update_meta_cache'],
|
66 |
+
$r['include_blog_ids']
|
67 |
);
|
68 |
|
69 |
+
// Filter and return
|
70 |
+
return apply_filters( 'bp_blogs_get_blogs', $blogs, $r );
|
|
|
|
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
* Populate the BP blogs table with existing blogs.
|
75 |
*
|
76 |
+
* @since BuddyPress (1.0.0)
|
77 |
+
*
|
78 |
* @global object $wpdb WordPress database object
|
79 |
* @uses get_users()
|
80 |
* @uses bp_blogs_record_blog()
|
81 |
*/
|
82 |
function bp_blogs_record_existing_blogs() {
|
83 |
+
global $wpdb;
|
|
|
|
|
|
|
84 |
|
85 |
+
// Query for all sites in network
|
86 |
if ( is_multisite() ) {
|
87 |
+
|
88 |
+
// Get blog ID's if not a large network
|
89 |
+
if ( ! wp_is_large_network() ) {
|
90 |
+
$blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE mature = 0 AND spam = 0 AND deleted = 0 AND site_id = %d", $wpdb->siteid ) );
|
91 |
+
|
92 |
+
// If error running this query, set blog ID's to false
|
93 |
+
if ( is_wp_error( $blog_ids ) ) {
|
94 |
+
$blog_ids = false;
|
95 |
+
}
|
96 |
+
|
97 |
+
// Large networks are not currently supported
|
98 |
+
} else {
|
99 |
+
$blog_ids = false;
|
100 |
+
}
|
101 |
+
|
102 |
+
// Record a single site
|
103 |
} else {
|
104 |
+
$blog_ids = $wpdb->blogid;
|
105 |
}
|
106 |
|
107 |
+
// Bail if there are no blogs in the network
|
108 |
+
if ( empty( $blog_ids ) ) {
|
109 |
+
return false;
|
110 |
+
}
|
111 |
+
|
112 |
+
// Get BuddyPress
|
113 |
+
$bp = buddypress();
|
114 |
+
|
115 |
+
// Truncate user blogs table
|
116 |
+
$truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name}" );
|
117 |
+
if ( is_wp_error( $truncate ) ) {
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
|
121 |
+
// Truncate user blogsmeta table
|
122 |
+
$truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name_blogmeta}" );
|
123 |
+
if ( is_wp_error( $truncate ) ) {
|
124 |
+
return false;
|
125 |
+
}
|
126 |
+
|
127 |
+
// Loop through users of blogs and record the relationship
|
128 |
+
foreach ( (array) $blog_ids as $blog_id ) {
|
129 |
+
|
130 |
+
// Ensure that the cache is clear after the table TRUNCATE above
|
131 |
+
wp_cache_delete( $blog_id, 'blog_meta' );
|
132 |
+
|
133 |
+
// Get all users
|
134 |
+
$users = get_users( array(
|
135 |
+
'blog_id' => $blog_id
|
136 |
+
) );
|
137 |
+
|
138 |
+
// Continue on if no users exist for this site (how did this happen?)
|
139 |
+
if ( empty( $users ) ) {
|
140 |
+
continue;
|
141 |
+
}
|
142 |
+
|
143 |
+
// Loop through users and record their relationship to this blog
|
144 |
+
foreach ( (array) $users as $user ) {
|
145 |
+
bp_blogs_add_user_to_blog( $user->ID, false, $blog_id );
|
146 |
}
|
147 |
}
|
148 |
+
|
149 |
+
// No errors
|
150 |
+
return true;
|
151 |
}
|
152 |
|
153 |
/**
|
348 |
* unused here.
|
349 |
* @param string $newvalue Value to change meta to.
|
350 |
*/
|
351 |
+
function bp_blogs_update_option_close_comments_days_old( $oldvalue, $newvalue ) {
|
352 |
global $wpdb;
|
353 |
|
354 |
bp_blogs_update_blogmeta( $wpdb->blogid, 'close_comments_days_old', $newvalue );
|
523 |
|
524 |
$activity_content = $post->post_content;
|
525 |
|
526 |
+
$activity_id = bp_blogs_record_activity( array(
|
527 |
'user_id' => (int) $post->post_author,
|
528 |
'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, $post, $post_permalink ),
|
529 |
'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
|
531 |
'item_id' => $blog_id,
|
532 |
'secondary_item_id' => $post_id,
|
533 |
'recorded_time' => $post->post_date_gmt,
|
534 |
+
) );
|
535 |
+
|
536 |
+
// save post title in activity meta
|
537 |
+
bp_activity_update_meta( $activity_id, 'post_title', $post->post_title );
|
538 |
+
bp_activity_update_meta( $activity_id, 'post_url', $post_permalink );
|
539 |
}
|
540 |
|
541 |
// Update the blogs last activity
|
575 |
|
576 |
// update the activity entry
|
577 |
$activity = new BP_Activity_Activity( $activity_id );
|
578 |
+
|
579 |
+
if ( ! empty( $post->post_content ) ) {
|
580 |
+
// Make sure to update the thumbnail image
|
581 |
+
$post_content = bp_activity_thumbnail_content_images( $post->post_content, $activity->primary_link, (array) $activity );
|
582 |
+
|
583 |
+
// Make sure to apply the blop post excerpt
|
584 |
+
$activity->content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $post_content ), $post_content, (array) $activity );
|
585 |
+
}
|
586 |
+
|
587 |
+
// Save the updated activity
|
588 |
$activity->save();
|
589 |
|
590 |
+
// update post title in activity meta
|
591 |
+
$existing_title = bp_activity_get_meta( $activity_id, 'post_title' );
|
592 |
+
if ( $post->post_title !== $existing_title ) {
|
593 |
+
bp_activity_update_meta( $activity_id, 'post_title', $post->post_title );
|
594 |
+
|
595 |
+
// now update activity meta for post comments... sigh
|
596 |
+
add_filter( 'comments_clauses', 'bp_blogs_comments_clauses_select_by_id' );
|
597 |
+
$comments = get_comments( array( 'post_id' => $post->ID ) );
|
598 |
+
remove_filter( 'comments_clauses', 'bp_blogs_comments_clauses_select_by_id' );
|
599 |
+
|
600 |
+
if ( ! empty( $comments ) ) {
|
601 |
+
$activity_ids = array();
|
602 |
+
$comment_ids = wp_list_pluck( $comments, 'comment_ID' );
|
603 |
+
|
604 |
+
// setup activity args
|
605 |
+
$args = array(
|
606 |
+
'update_meta_cache' => false,
|
607 |
+
'show_hidden' => true,
|
608 |
+
'per_page' => 99999,
|
609 |
+
);
|
610 |
+
|
611 |
+
// query for old-style "new_blog_comment" activity items
|
612 |
+
$args['filter'] = array(
|
613 |
+
'object' => buddypress()->blogs->id,
|
614 |
+
'action' => 'new_blog_comment',
|
615 |
+
'secondary_id' => implode( ',', $comment_ids ),
|
616 |
+
);
|
617 |
+
|
618 |
+
$activities = bp_activity_get( $args );
|
619 |
+
if ( ! empty( $activities['activities'] ) ) {
|
620 |
+
$activity_ids = (array) wp_list_pluck( $activities['activities'], 'id' );
|
621 |
+
}
|
622 |
+
|
623 |
+
// query for activity comments connected to a blog post
|
624 |
+
unset( $args['filter'] );
|
625 |
+
$args['meta_query'] = array( array(
|
626 |
+
'key' => 'bp_blogs_post_comment_id',
|
627 |
+
'value' => $comment_ids,
|
628 |
+
'compare' => 'IN',
|
629 |
+
) );
|
630 |
+
$args['type'] = 'activity_comment';
|
631 |
+
$args['display_comments'] = 'stream';
|
632 |
+
|
633 |
+
$activities = bp_activity_get( $args );
|
634 |
+
if ( ! empty( $activities['activities'] ) ) {
|
635 |
+
$activity_ids = array_merge( $activity_ids, (array) wp_list_pluck( $activities['activities'], 'id' ) );
|
636 |
+
}
|
637 |
+
|
638 |
+
// update activity meta for all found activity items
|
639 |
+
if ( ! empty( $activity_ids ) ) {
|
640 |
+
foreach ( $activity_ids as $aid ) {
|
641 |
+
bp_activity_update_meta( $aid, 'post_title', $post->post_title );
|
642 |
+
}
|
643 |
+
}
|
644 |
+
|
645 |
+
unset( $activities, $activity_ids, $comment_ids, $comments );
|
646 |
+
}
|
647 |
+
}
|
648 |
+
|
649 |
// add post comment status to activity meta if closed
|
650 |
if( 'closed' == $post->comment_status ) {
|
651 |
bp_activity_update_meta( $activity_id, 'post_comment_status', $post->comment_status );
|
743 |
$args['secondary_item_id'] = $comment_id;
|
744 |
|
745 |
// record the activity entry
|
746 |
+
$activity_id = bp_blogs_record_activity( $args );
|
747 |
+
|
748 |
+
// add some post info in activity meta
|
749 |
+
bp_activity_update_meta( $activity_id, 'post_title', $recorded_comment->post->post_title );
|
750 |
+
bp_activity_update_meta( $activity_id, 'post_url', add_query_arg( 'p', $recorded_comment->post->ID, home_url( '/' ) ) );
|
751 |
|
752 |
// record comment as BP activity comment under the parent 'new_blog_post'
|
753 |
// activity item
|
811 |
if ( empty( $args['id'] ) ) {
|
812 |
// add meta to activity comment
|
813 |
bp_activity_update_meta( $comment_activity_id, 'bp_blogs_post_comment_id', $comment_id );
|
814 |
+
bp_activity_update_meta( $comment_activity_id, 'post_title', $recorded_comment->post->post_title );
|
815 |
+
bp_activity_update_meta( $comment_activity_id, 'post_url', add_query_arg( 'p', $recorded_comment->post->ID, home_url( '/' ) ) );
|
816 |
|
817 |
// add meta to comment
|
818 |
add_comment_meta( $comment_id, 'bp_activity_comment_id', $comment_activity_id );
|
836 |
* set/changed ('add_user_to_blog', 'profile_update', 'user_register'). It
|
837 |
* parses the changes, and records them as necessary in the BP blog tracker.
|
838 |
*
|
839 |
+
* BuddyPress does not track blogs for users with the 'subscriber' role by
|
840 |
+
* default, though as of 2.1.0 you can filter 'bp_blogs_get_allowed_roles' to
|
841 |
+
* modify this behavior.
|
842 |
+
*
|
843 |
+
* @param int $user_id The ID of the user
|
844 |
+
* @param string|bool $role User's WordPress role for this blog ID
|
845 |
+
* @param int $blog_id Blog ID user is being added to
|
846 |
*
|
|
|
|
|
|
|
|
|
|
|
847 |
* @return bool|null False on failure.
|
848 |
*/
|
849 |
function bp_blogs_add_user_to_blog( $user_id, $role = false, $blog_id = 0 ) {
|
850 |
global $wpdb;
|
851 |
|
852 |
+
// If no blog ID was passed, use the root blog ID
|
853 |
if ( empty( $blog_id ) ) {
|
854 |
$blog_id = isset( $wpdb->blogid ) ? $wpdb->blogid : bp_get_root_blog_id();
|
855 |
}
|
856 |
|
857 |
+
// If no role was passed, try to find the blog role
|
858 |
if ( empty( $role ) ) {
|
|
|
859 |
|
860 |
+
// Get user capabilities
|
861 |
+
$key = $wpdb->get_blog_prefix( $blog_id ). 'capabilities';
|
862 |
+
$user_roles = array_keys( bp_get_user_meta( $user_id, $key, true ) );
|
863 |
+
|
864 |
+
// User has roles so lets
|
865 |
+
if ( ! empty( $user_roles ) ) {
|
866 |
+
|
867 |
+
// Get blog roles
|
868 |
+
$blog_roles = array_keys( bp_get_current_blog_roles() );
|
869 |
|
870 |
+
// Look for blog only roles of the user
|
871 |
+
$intersect_roles = array_intersect( $user_roles, $blog_roles );
|
872 |
+
|
873 |
+
// If there's a role in the array, use the first one. This isn't
|
874 |
+
// very smart, but since roles aren't exactly hierarchical, and
|
875 |
+
// WordPress does not yet have a UI for multiple user roles, it's
|
876 |
+
// fine for now.
|
877 |
+
if ( ! empty( $intersect_roles ) ) {
|
878 |
+
$role = array_shift( $intersect_roles );
|
879 |
+
}
|
880 |
+
}
|
881 |
}
|
882 |
|
883 |
+
// Bail if no role was found or role is not in the allowed roles array
|
884 |
+
if ( empty( $role ) || ! in_array( $role, bp_blogs_get_allowed_roles() ) ) {
|
885 |
+
return false;
|
886 |
+
}
|
887 |
+
|
888 |
+
// Record the blog activity for this user being added to this blog
|
889 |
+
bp_blogs_record_blog( $blog_id, $user_id, true );
|
890 |
}
|
891 |
add_action( 'add_user_to_blog', 'bp_blogs_add_user_to_blog', 10, 3 );
|
892 |
add_action( 'profile_update', 'bp_blogs_add_user_to_blog' );
|
893 |
add_action( 'user_register', 'bp_blogs_add_user_to_blog' );
|
894 |
|
895 |
+
/**
|
896 |
+
* The allowed blog roles a member must have to be recorded into the
|
897 |
+
* `bp_user_blogs` pointer table.
|
898 |
+
*
|
899 |
+
* This added and was made filterable in BuddyPress 2.1.0 to make it easier
|
900 |
+
* to extend the functionality of the Blogs component.
|
901 |
+
*
|
902 |
+
* @since BuddyPress (2.1.0)
|
903 |
+
*
|
904 |
+
* @return string
|
905 |
+
*/
|
906 |
+
function bp_blogs_get_allowed_roles() {
|
907 |
+
return apply_filters( 'bp_blogs_get_allowed_roles', array( 'contributor', 'author', 'editor', 'administrator' ) );
|
908 |
+
}
|
909 |
+
|
910 |
/**
|
911 |
* Remove a blog-user pair from BP's blog tracker.
|
912 |
*
|
916 |
function bp_blogs_remove_user_from_blog( $user_id, $blog_id = 0 ) {
|
917 |
global $wpdb;
|
918 |
|
919 |
+
if ( empty( $blog_id ) ) {
|
920 |
$blog_id = $wpdb->blogid;
|
921 |
+
}
|
922 |
|
923 |
bp_blogs_remove_blog_for_user( $user_id, $blog_id );
|
924 |
}
|
1219 |
/**
|
1220 |
* Get the total number of blogs being tracked by BP for a specific user.
|
1221 |
*
|
1222 |
+
* @since BuddyPress (1.2.0)
|
1223 |
+
*
|
1224 |
* @param int $user_id ID of the user being queried. Default: on a user page,
|
1225 |
* the displayed user. Otherwise, the logged-in user.
|
1226 |
* @return int $count Total blog count for the user.
|
1227 |
*/
|
1228 |
function bp_blogs_total_blogs_for_user( $user_id = 0 ) {
|
1229 |
+
if ( empty( $user_id ) ) {
|
|
|
1230 |
$user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
|
1231 |
+
}
|
1232 |
+
|
1233 |
+
// no user ID? do not attempt to look at cache
|
1234 |
+
if ( empty( $user_id ) ) {
|
1235 |
+
return 0;
|
1236 |
+
}
|
1237 |
|
1238 |
+
$count = wp_cache_get( 'bp_total_blogs_for_user_' . $user_id, 'bp' );
|
1239 |
+
if ( false === $count ) {
|
1240 |
$count = BP_Blogs_Blog::total_blog_count_for_user( $user_id );
|
1241 |
wp_cache_set( 'bp_total_blogs_for_user_' . $user_id, $count, 'bp' );
|
1242 |
}
|
1422 |
* @param int $blog_id ID of the blog.
|
1423 |
* @param string $meta_key Metadata key.
|
1424 |
* @param mixed $meta_value Metadata value.
|
1425 |
+
* @param bool $unique Optional. Whether to enforce a single metadata value
|
1426 |
* for the given key. If true, and the object already has a value for
|
1427 |
* the key, no change will be made. Default: false.
|
1428 |
* @return int|bool The meta ID on successful update, false on failure.
|
@@ -1,9 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* BuddyPress Blogs
|
5 |
*
|
6 |
-
*
|
|
|
|
|
7 |
*
|
8 |
* @package BuddyPress
|
9 |
* @subpackage Blogs Core
|
@@ -22,7 +24,7 @@ class BP_Blogs_Component extends BP_Component {
|
|
22 |
public function __construct() {
|
23 |
parent::start(
|
24 |
'blogs',
|
25 |
-
__( 'Site
|
26 |
buddypress()->plugin_dir,
|
27 |
array(
|
28 |
'adminbar_myaccount_order' => 30
|
@@ -45,8 +47,9 @@ class BP_Blogs_Component extends BP_Component {
|
|
45 |
public function setup_globals( $args = array() ) {
|
46 |
$bp = buddypress();
|
47 |
|
48 |
-
if ( !defined( 'BP_BLOGS_SLUG' ) )
|
49 |
define ( 'BP_BLOGS_SLUG', $this->id );
|
|
|
50 |
|
51 |
// Global tables for messaging component
|
52 |
$global_tables = array(
|
@@ -58,8 +61,7 @@ class BP_Blogs_Component extends BP_Component {
|
|
58 |
'blog' => $bp->table_prefix . 'bp_user_blogs_blogmeta',
|
59 |
);
|
60 |
|
61 |
-
// All globals for
|
62 |
-
// Note that global_tables is included in this array.
|
63 |
$args = array(
|
64 |
'slug' => BP_BLOGS_SLUG,
|
65 |
'root_slug' => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG,
|
@@ -83,6 +85,7 @@ class BP_Blogs_Component extends BP_Component {
|
|
83 |
* @param array $includes See {@link BP_Component::includes()}.
|
84 |
*/
|
85 |
public function includes( $includes = array() ) {
|
|
|
86 |
// Files to include
|
87 |
$includes = array(
|
88 |
'cache',
|
@@ -93,11 +96,11 @@ class BP_Blogs_Component extends BP_Component {
|
|
93 |
'filters',
|
94 |
'activity',
|
95 |
'functions',
|
96 |
-
'buddybar'
|
97 |
);
|
98 |
|
99 |
-
if ( is_multisite() )
|
100 |
$includes[] = 'widgets';
|
|
|
101 |
|
102 |
// Include the files
|
103 |
parent::includes( $includes );
|
@@ -121,12 +124,13 @@ class BP_Blogs_Component extends BP_Component {
|
|
121 |
* Although comments and posts made by users will still show on their
|
122 |
* activity stream.
|
123 |
*/
|
124 |
-
if ( !is_multisite() )
|
125 |
return false;
|
|
|
126 |
|
127 |
// Add 'Sites' to the main navigation
|
128 |
$main_nav = array(
|
129 |
-
'name' => sprintf( __( 'Sites <span>%d</span>', 'buddypress' ),
|
130 |
'slug' => $this->slug,
|
131 |
'position' => 30,
|
132 |
'screen_function' => 'bp_blogs_screen_my_blogs',
|
@@ -173,11 +177,12 @@ class BP_Blogs_Component extends BP_Component {
|
|
173 |
|
174 |
/**
|
175 |
* Site/post/comment menus should not appear on single WordPress setups.
|
176 |
-
*
|
177 |
-
* activity
|
178 |
*/
|
179 |
-
if ( !is_multisite() )
|
180 |
return false;
|
|
|
181 |
|
182 |
// Menus for logged in user
|
183 |
if ( is_user_logged_in() ) {
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* BuddyPress Blogs Loader
|
5 |
*
|
6 |
+
* The blogs component tracks posts and comments to member activity streams,
|
7 |
+
* shows blogs the member can post to in their profiles, and caches useful
|
8 |
+
* information from those blogs to make quering blogs in bulk more performant.
|
9 |
*
|
10 |
* @package BuddyPress
|
11 |
* @subpackage Blogs Core
|
24 |
public function __construct() {
|
25 |
parent::start(
|
26 |
'blogs',
|
27 |
+
__( 'Site Directory', 'buddypress' ),
|
28 |
buddypress()->plugin_dir,
|
29 |
array(
|
30 |
'adminbar_myaccount_order' => 30
|
47 |
public function setup_globals( $args = array() ) {
|
48 |
$bp = buddypress();
|
49 |
|
50 |
+
if ( ! defined( 'BP_BLOGS_SLUG' ) ) {
|
51 |
define ( 'BP_BLOGS_SLUG', $this->id );
|
52 |
+
}
|
53 |
|
54 |
// Global tables for messaging component
|
55 |
$global_tables = array(
|
61 |
'blog' => $bp->table_prefix . 'bp_user_blogs_blogmeta',
|
62 |
);
|
63 |
|
64 |
+
// All globals for blogs component.
|
|
|
65 |
$args = array(
|
66 |
'slug' => BP_BLOGS_SLUG,
|
67 |
'root_slug' => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG,
|
85 |
* @param array $includes See {@link BP_Component::includes()}.
|
86 |
*/
|
87 |
public function includes( $includes = array() ) {
|
88 |
+
|
89 |
// Files to include
|
90 |
$includes = array(
|
91 |
'cache',
|
96 |
'filters',
|
97 |
'activity',
|
98 |
'functions',
|
|
|
99 |
);
|
100 |
|
101 |
+
if ( is_multisite() ) {
|
102 |
$includes[] = 'widgets';
|
103 |
+
}
|
104 |
|
105 |
// Include the files
|
106 |
parent::includes( $includes );
|
124 |
* Although comments and posts made by users will still show on their
|
125 |
* activity stream.
|
126 |
*/
|
127 |
+
if ( ! is_multisite() ) {
|
128 |
return false;
|
129 |
+
}
|
130 |
|
131 |
// Add 'Sites' to the main navigation
|
132 |
$main_nav = array(
|
133 |
+
'name' => sprintf( __( 'Sites <span>%d</span>', 'buddypress' ), bp_get_total_blog_count_for_user() ),
|
134 |
'slug' => $this->slug,
|
135 |
'position' => 30,
|
136 |
'screen_function' => 'bp_blogs_screen_my_blogs',
|
177 |
|
178 |
/**
|
179 |
* Site/post/comment menus should not appear on single WordPress setups.
|
180 |
+
*
|
181 |
+
* Comments and posts made by users will still show in their activity.
|
182 |
*/
|
183 |
+
if ( ! is_multisite() ) {
|
184 |
return false;
|
185 |
+
}
|
186 |
|
187 |
// Menus for logged in user
|
188 |
if ( is_user_logged_in() ) {
|
@@ -149,7 +149,7 @@ class BP_Blogs_Theme_Compat {
|
|
149 |
'post_author' => 0,
|
150 |
'post_date' => 0,
|
151 |
'post_content' => '',
|
152 |
-
'post_type' => '
|
153 |
'post_status' => 'publish',
|
154 |
'is_page' => true,
|
155 |
'comment_status' => 'closed'
|
@@ -212,7 +212,7 @@ class BP_Blogs_Theme_Compat {
|
|
212 |
'post_author' => 0,
|
213 |
'post_date' => 0,
|
214 |
'post_content' => '',
|
215 |
-
'post_type' => '
|
216 |
'post_status' => 'publish',
|
217 |
'is_page' => true,
|
218 |
'comment_status' => 'closed'
|
149 |
'post_author' => 0,
|
150 |
'post_date' => 0,
|
151 |
'post_content' => '',
|
152 |
+
'post_type' => 'page',
|
153 |
'post_status' => 'publish',
|
154 |
'is_page' => true,
|
155 |
'comment_status' => 'closed'
|
212 |
'post_author' => 0,
|
213 |
'post_date' => 0,
|
214 |
'post_content' => '',
|
215 |
+
'post_type' => 'page',
|
216 |
'post_status' => 'publish',
|
217 |
'is_page' => true,
|
218 |
'comment_status' => 'closed'
|
@@ -90,7 +90,7 @@ class BP_Blogs_Template {
|
|
90 |
* @access public
|
91 |
* @var int
|
92 |
*/
|
93 |
-
|
94 |
|
95 |
/**
|
96 |
* The number of blogs returned by the paged query.
|
@@ -98,7 +98,7 @@ class BP_Blogs_Template {
|
|
98 |
* @access public
|
99 |
* @var int
|
100 |
*/
|
101 |
-
|
102 |
|
103 |
/**
|
104 |
* Array of blogs located by the query..
|
@@ -106,7 +106,7 @@ class BP_Blogs_Template {
|
|
106 |
* @access public
|
107 |
* @var array
|
108 |
*/
|
109 |
-
|
110 |
|
111 |
/**
|
112 |
* The blog object currently being iterated on.
|
@@ -114,7 +114,7 @@ class BP_Blogs_Template {
|
|
114 |
* @access public
|
115 |
* @var object
|
116 |
*/
|
117 |
-
|
118 |
|
119 |
/**
|
120 |
* A flag for whether the loop is currently being iterated.
|
@@ -122,7 +122,7 @@ class BP_Blogs_Template {
|
|
122 |
* @access public
|
123 |
* @var bool
|
124 |
*/
|
125 |
-
|
126 |
|
127 |
/**
|
128 |
* The page number being requested.
|
@@ -130,7 +130,7 @@ class BP_Blogs_Template {
|
|
130 |
* @access public
|
131 |
* @var public
|
132 |
*/
|
133 |
-
|
134 |
|
135 |
/**
|
136 |
* The number of items being requested per page.
|
@@ -138,7 +138,7 @@ class BP_Blogs_Template {
|
|
138 |
* @access public
|
139 |
* @var public
|
140 |
*/
|
141 |
-
|
142 |
|
143 |
/**
|
144 |
* An HTML string containing pagination links.
|
@@ -146,7 +146,7 @@ class BP_Blogs_Template {
|
|
146 |
* @access public
|
147 |
* @var string
|
148 |
*/
|
149 |
-
|
150 |
|
151 |
/**
|
152 |
* The total number of blogs matching the query parameters.
|
@@ -154,7 +154,7 @@ class BP_Blogs_Template {
|
|
154 |
* @access public
|
155 |
* @var int
|
156 |
*/
|
157 |
-
|
158 |
|
159 |
/**
|
160 |
* Constructor method.
|
@@ -173,13 +173,16 @@ class BP_Blogs_Template {
|
|
173 |
* queried blogs.
|
174 |
* @param array $include_blog_ids Array of blog IDs to include.
|
175 |
*/
|
176 |
-
function __construct( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg = 'bpage', $update_meta_cache = true, $include_blog_ids = false ) {
|
177 |
|
178 |
-
$this->pag_page = isset( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : $page;
|
179 |
-
$this->pag_num
|
180 |
|
181 |
-
|
|
|
182 |
$this->blogs = BP_Blogs_Blog::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page );
|
|
|
|
|
183 |
} else {
|
184 |
$this->blogs = bp_blogs_get_blogs( array(
|
185 |
'type' => $type,
|
@@ -192,31 +195,35 @@ class BP_Blogs_Template {
|
|
192 |
) );
|
193 |
}
|
194 |
|
195 |
-
|
|
|
196 |
$this->total_blog_count = (int) $this->blogs['total'];
|
197 |
-
else
|
198 |
$this->total_blog_count = (int) $max;
|
|
|
199 |
|
|
|
200 |
$this->blogs = $this->blogs['blogs'];
|
201 |
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
} else {
|
209 |
-
$this->blog_count =
|
210 |
}
|
211 |
|
212 |
-
|
|
|
213 |
$this->pag_links = paginate_links( array(
|
214 |
'base' => add_query_arg( $page_arg, '%#%' ),
|
215 |
'format' => '',
|
216 |
'total' => ceil( (int) $this->total_blog_count / (int) $this->pag_num ),
|
217 |
'current' => (int) $this->pag_page,
|
218 |
'prev_text' => _x( '←', 'Blog pagination previous text', 'buddypress' ),
|
219 |
-
'next_text' => _x( '→', 'Blog pagination next text',
|
220 |
'mid_size' => 1
|
221 |
) );
|
222 |
}
|
@@ -229,11 +236,8 @@ class BP_Blogs_Template {
|
|
229 |
*
|
230 |
* @return bool True if there are items in the loop, otherwise false.
|
231 |
*/
|
232 |
-
function has_blogs() {
|
233 |
-
|
234 |
-
return true;
|
235 |
-
|
236 |
-
return false;
|
237 |
}
|
238 |
|
239 |
/**
|
@@ -241,9 +245,9 @@ class BP_Blogs_Template {
|
|
241 |
*
|
242 |
* @return object The next blog to iterate over.
|
243 |
*/
|
244 |
-
function next_blog() {
|
245 |
$this->current_blog++;
|
246 |
-
$this->blog = $this->blogs[$this->current_blog];
|
247 |
|
248 |
return $this->blog;
|
249 |
}
|
@@ -251,7 +255,7 @@ class BP_Blogs_Template {
|
|
251 |
/**
|
252 |
* Rewind the blogs and reset blog index.
|
253 |
*/
|
254 |
-
function rewind_blogs() {
|
255 |
$this->current_blog = -1;
|
256 |
if ( $this->blog_count > 0 ) {
|
257 |
$this->blog = $this->blogs[0];
|
@@ -269,11 +273,11 @@ class BP_Blogs_Template {
|
|
269 |
*
|
270 |
* @return bool True if there are more blogs to show, otherwise false.
|
271 |
*/
|
272 |
-
function blogs() {
|
273 |
-
if ( $this->current_blog + 1 < $this->blog_count ) {
|
274 |
return true;
|
275 |
-
} elseif ( $this->current_blog + 1
|
276 |
-
do_action('blog_loop_end');
|
277 |
// Do some cleaning up after the loop
|
278 |
$this->rewind_blogs();
|
279 |
}
|
@@ -291,13 +295,15 @@ class BP_Blogs_Template {
|
|
291 |
*
|
292 |
* @see bp_the_blog()
|
293 |
*/
|
294 |
-
function the_blog() {
|
295 |
|
296 |
$this->in_the_loop = true;
|
297 |
$this->blog = $this->next_blog();
|
298 |
|
299 |
-
|
300 |
-
|
|
|
|
|
301 |
}
|
302 |
}
|
303 |
|
@@ -340,7 +346,8 @@ function bp_rewind_blogs() {
|
|
340 |
* 'active', 'alphabetical', 'newest', or 'random'.
|
341 |
* @type array $include_blog_ids Array of blog IDs to limit results to.
|
342 |
* @type string $sort 'ASC' or 'DESC'. Default: 'DESC'.
|
343 |
-
* @type string $search_terms Limit results by a search term. Default:
|
|
|
344 |
* @type int $user_id The ID of the user whose blogs should be retrieved.
|
345 |
* When viewing a user profile page, 'user_id' defaults to the ID of
|
346 |
* the displayed user. Otherwise the default is false.
|
@@ -350,51 +357,34 @@ function bp_rewind_blogs() {
|
|
350 |
function bp_has_blogs( $args = '' ) {
|
351 |
global $blogs_template;
|
352 |
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
*/
|
358 |
-
$type = 'active';
|
359 |
-
$user_id = 0;
|
360 |
-
$search_terms = null;
|
361 |
-
|
362 |
-
// User filtering
|
363 |
-
if ( bp_displayed_user_id() )
|
364 |
-
$user_id = bp_displayed_user_id();
|
365 |
|
366 |
-
|
367 |
-
|
|
|
|
|
368 |
'page' => 1,
|
369 |
'per_page' => 20,
|
370 |
'max' => false,
|
371 |
-
|
372 |
-
'page_arg' => 'bpage', // See https://buddypress.trac.wordpress.org/ticket/3679
|
373 |
-
|
374 |
-
'user_id' => $user_id, // Pass a user_id to limit to only blogs this user has higher than subscriber access to
|
375 |
'include_blog_ids' => false,
|
376 |
-
'search_terms' => $search_terms,
|
377 |
-
'update_meta_cache' => true
|
378 |
-
);
|
379 |
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
if ( is_null( $search_terms ) ) {
|
384 |
-
if ( isset( $_REQUEST['s'] ) && !empty( $_REQUEST['s'] ) )
|
385 |
-
$search_terms = $_REQUEST['s'];
|
386 |
-
else
|
387 |
-
$search_terms = false;
|
388 |
}
|
389 |
|
390 |
-
|
391 |
-
|
392 |
-
$per_page = $max;
|
393 |
-
}
|
394 |
-
}
|
395 |
|
396 |
-
|
397 |
-
return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), $blogs_template );
|
398 |
}
|
399 |
|
400 |
/**
|
@@ -436,7 +426,7 @@ function bp_blogs_pagination_count() {
|
|
436 |
$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 ) );
|
437 |
$total = bp_core_number_format( $blogs_template->total_blog_count );
|
438 |
|
439 |
-
echo sprintf( _n( 'Viewing
|
440 |
}
|
441 |
|
442 |
/**
|
@@ -488,25 +478,43 @@ function bp_blog_avatar( $args = '' ) {
|
|
488 |
* @type int|bool $width Default: false.
|
489 |
* @type int|bool $height Default: false.
|
490 |
* @type bool $id Currently unused.
|
491 |
-
* @type bool $no_grav Default:
|
492 |
* }
|
493 |
* @return string User avatar string.
|
494 |
*/
|
495 |
function bp_get_blog_avatar( $args = '' ) {
|
496 |
global $blogs_template;
|
497 |
|
498 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
499 |
'type' => 'full',
|
500 |
'width' => false,
|
501 |
'height' => false,
|
502 |
'class' => 'avatar',
|
503 |
'id' => false,
|
504 |
'alt' => sprintf( __( 'Profile picture of site author %s', 'buddypress' ), bp_core_get_user_displayname( $blogs_template->blog->admin_user_id ) ),
|
505 |
-
'no_grav' => true
|
506 |
-
);
|
507 |
-
|
508 |
-
|
509 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
510 |
|
511 |
/***
|
512 |
* In future BuddyPress versions you will be able to set the avatar for a blog.
|
@@ -516,9 +524,9 @@ function bp_blog_avatar( $args = '' ) {
|
|
516 |
* This filter is deprecated as of BuddyPress 1.5 and may be removed in a future version.
|
517 |
* Use the 'bp_get_blog_avatar' filter instead.
|
518 |
*/
|
519 |
-
$avatar = apply_filters( 'bp_get_blog_avatar_' . $blogs_template->blog->blog_id,
|
520 |
|
521 |
-
return apply_filters( 'bp_get_blog_avatar', $avatar, $blogs_template->blog->blog_id,
|
522 |
}
|
523 |
|
524 |
function bp_blog_permalink() {
|
@@ -633,39 +641,77 @@ function bp_blog_class() {
|
|
633 |
|
634 |
/**
|
635 |
* Output the last active date of the current blog in the loop.
|
|
|
|
|
636 |
*/
|
637 |
-
function bp_blog_last_active() {
|
638 |
-
echo bp_get_blog_last_active();
|
639 |
}
|
640 |
/**
|
641 |
* Return the last active date of the current blog in the loop.
|
642 |
*
|
|
|
|
|
|
|
|
|
|
|
643 |
* @return string Last active date.
|
644 |
*/
|
645 |
-
function bp_get_blog_last_active() {
|
646 |
global $blogs_template;
|
647 |
|
648 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
649 |
}
|
650 |
|
651 |
/**
|
652 |
* Output the latest post from the current blog in the loop.
|
|
|
|
|
653 |
*/
|
654 |
-
function bp_blog_latest_post() {
|
655 |
-
echo bp_get_blog_latest_post();
|
656 |
}
|
657 |
/**
|
658 |
* Return the latest post from the current blog in the loop.
|
659 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
660 |
* @return string $retval String of the form 'Latest Post: [link to post]'.
|
661 |
*/
|
662 |
-
function bp_get_blog_latest_post() {
|
663 |
global $blogs_template;
|
664 |
|
|
|
|
|
|
|
|
|
665 |
$retval = bp_get_blog_latest_post_title();
|
666 |
|
667 |
-
if ( ! empty( $retval ) )
|
668 |
-
|
|
|
|
|
|
|
|
|
|
|
669 |
|
670 |
return apply_filters( 'bp_get_blog_latest_post', $retval );
|
671 |
}
|
@@ -912,7 +958,7 @@ function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = ''
|
|
912 |
$errors = $filtered_results['errors'];
|
913 |
|
914 |
if ( $errors->get_error_code() ) {
|
915 |
-
echo "<p>" . __('There was a problem
|
916 |
}
|
917 |
?>
|
918 |
<p><?php printf(__("By filling out the form below, you can <strong>add a site to your account</strong>. There is no limit to the number of sites that you can have, so create to your heart's content, but blog responsibly!", 'buddypress'), $current_user->display_name) ?></p>
|
@@ -1006,27 +1052,6 @@ function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' )
|
|
1006 |
do_action('signup_blogform', $errors);
|
1007 |
}
|
1008 |
|
1009 |
-
/**
|
1010 |
-
* Output the base URL for subdomain installations of WordPress Multisite.
|
1011 |
-
*
|
1012 |
-
* @since BuddyPress (1.6.0)
|
1013 |
-
*/
|
1014 |
-
function bp_blogs_subdomain_base() {
|
1015 |
-
echo bp_blogs_get_subdomain_base();
|
1016 |
-
}
|
1017 |
-
/**
|
1018 |
-
* Return the base URL for subdomain installations of WordPress Multisite.
|
1019 |
-
*
|
1020 |
-
* @since BuddyPress (1.6.0)
|
1021 |
-
*
|
1022 |
-
* @return string The base URL - eg, 'example.com' for site_url() example.com or www.example.com.
|
1023 |
-
*/
|
1024 |
-
function bp_blogs_get_subdomain_base() {
|
1025 |
-
global $current_site;
|
1026 |
-
|
1027 |
-
return apply_filters( 'bp_blogs_subdomain_base', preg_replace( '|^www\.|', '', $current_site->domain ) . $current_site->path );
|
1028 |
-
}
|
1029 |
-
|
1030 |
/**
|
1031 |
* Process a blog registration submission.
|
1032 |
*
|
90 |
* @access public
|
91 |
* @var int
|
92 |
*/
|
93 |
+
public $current_blog = -1;
|
94 |
|
95 |
/**
|
96 |
* The number of blogs returned by the paged query.
|
98 |
* @access public
|
99 |
* @var int
|
100 |
*/
|
101 |
+
public $blog_count = 0;
|
102 |
|
103 |
/**
|
104 |
* Array of blogs located by the query..
|
106 |
* @access public
|
107 |
* @var array
|
108 |
*/
|
109 |
+
public $blogs = array();
|
110 |
|
111 |
/**
|
112 |
* The blog object currently being iterated on.
|
114 |
* @access public
|
115 |
* @var object
|
116 |
*/
|
117 |
+
public $blog;
|
118 |
|
119 |
/**
|
120 |
* A flag for whether the loop is currently being iterated.
|
122 |
* @access public
|
123 |
* @var bool
|
124 |
*/
|
125 |
+
public $in_the_loop = false;
|
126 |
|
127 |
/**
|
128 |
* The page number being requested.
|
130 |
* @access public
|
131 |
* @var public
|
132 |
*/
|
133 |
+
public $pag_page = 1;
|
134 |
|
135 |
/**
|
136 |
* The number of items being requested per page.
|
138 |
* @access public
|
139 |
* @var public
|
140 |
*/
|
141 |
+
public $pag_num = 20;
|
142 |
|
143 |
/**
|
144 |
* An HTML string containing pagination links.
|
146 |
* @access public
|
147 |
* @var string
|
148 |
*/
|
149 |
+
public $pag_links = '';
|
150 |
|
151 |
/**
|
152 |
* The total number of blogs matching the query parameters.
|
154 |
* @access public
|
155 |
* @var int
|
156 |
*/
|
157 |
+
public $total_blog_count = 0;
|
158 |
|
159 |
/**
|
160 |
* Constructor method.
|
173 |
* queried blogs.
|
174 |
* @param array $include_blog_ids Array of blog IDs to include.
|
175 |
*/
|
176 |
+
public function __construct( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg = 'bpage', $update_meta_cache = true, $include_blog_ids = false ) {
|
177 |
|
178 |
+
$this->pag_page = isset( $_REQUEST[ $page_arg ] ) ? intval( $_REQUEST[ $page_arg ] ) : $page;
|
179 |
+
$this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
|
180 |
|
181 |
+
// Backwards compatibility support for blogs by first letter
|
182 |
+
if ( ! empty( $_REQUEST['letter'] ) ) {
|
183 |
$this->blogs = BP_Blogs_Blog::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page );
|
184 |
+
|
185 |
+
// Typical blogs query
|
186 |
} else {
|
187 |
$this->blogs = bp_blogs_get_blogs( array(
|
188 |
'type' => $type,
|
195 |
) );
|
196 |
}
|
197 |
|
198 |
+
// Set the total blog count
|
199 |
+
if ( empty( $max ) || ( $max >= (int) $this->blogs['total'] ) ) {
|
200 |
$this->total_blog_count = (int) $this->blogs['total'];
|
201 |
+
} else {
|
202 |
$this->total_blog_count = (int) $max;
|
203 |
+
}
|
204 |
|
205 |
+
// Set the blogs array (to loop through later
|
206 |
$this->blogs = $this->blogs['blogs'];
|
207 |
|
208 |
+
// Get the current blog count to compare maximum against
|
209 |
+
$blog_count = count( $this->blogs );
|
210 |
+
|
211 |
+
// Set the current blog count
|
212 |
+
if ( empty( $max ) || ( $max >= (int) $blog_count ) ) {
|
213 |
+
$this->blog_count = (int) $blog_count;
|
214 |
} else {
|
215 |
+
$this->blog_count = (int) $max;
|
216 |
}
|
217 |
|
218 |
+
// Build pagination links based on total blogs and current page number
|
219 |
+
if ( ! empty( $this->total_blog_count ) && ! empty( $this->pag_num ) ) {
|
220 |
$this->pag_links = paginate_links( array(
|
221 |
'base' => add_query_arg( $page_arg, '%#%' ),
|
222 |
'format' => '',
|
223 |
'total' => ceil( (int) $this->total_blog_count / (int) $this->pag_num ),
|
224 |
'current' => (int) $this->pag_page,
|
225 |
'prev_text' => _x( '←', 'Blog pagination previous text', 'buddypress' ),
|
226 |
+
'next_text' => _x( '→', 'Blog pagination next text', 'buddypress' ),
|
227 |
'mid_size' => 1
|
228 |
) );
|
229 |
}
|
236 |
*
|
237 |
* @return bool True if there are items in the loop, otherwise false.
|
238 |
*/
|
239 |
+
public function has_blogs() {
|
240 |
+
return (bool) ! empty( $this->blog_count );
|
|
|
|
|
|
|
241 |
}
|
242 |
|
243 |
/**
|
245 |
*
|
246 |
* @return object The next blog to iterate over.
|
247 |
*/
|
248 |
+
public function next_blog() {
|
249 |
$this->current_blog++;
|
250 |
+
$this->blog = $this->blogs[ $this->current_blog ];
|
251 |
|
252 |
return $this->blog;
|
253 |
}
|
255 |
/**
|
256 |
* Rewind the blogs and reset blog index.
|
257 |
*/
|
258 |
+
public function rewind_blogs() {
|
259 |
$this->current_blog = -1;
|
260 |
if ( $this->blog_count > 0 ) {
|
261 |
$this->blog = $this->blogs[0];
|
273 |
*
|
274 |
* @return bool True if there are more blogs to show, otherwise false.
|
275 |
*/
|
276 |
+
public function blogs() {
|
277 |
+
if ( ( $this->current_blog + 1 ) < $this->blog_count ) {
|
278 |
return true;
|
279 |
+
} elseif ( ( $this->current_blog + 1 ) === $this->blog_count ) {
|
280 |
+
do_action( 'blog_loop_end' );
|
281 |
// Do some cleaning up after the loop
|
282 |
$this->rewind_blogs();
|
283 |
}
|
295 |
*
|
296 |
* @see bp_the_blog()
|
297 |
*/
|
298 |
+
public function the_blog() {
|
299 |
|
300 |
$this->in_the_loop = true;
|
301 |
$this->blog = $this->next_blog();
|
302 |
|
303 |
+
// loop has just started
|
304 |
+
if ( 0 === $this->current_blog ) {
|
305 |
+
do_action( 'blog_loop_start' );
|
306 |
+
}
|
307 |
}
|
308 |
}
|
309 |
|
346 |
* 'active', 'alphabetical', 'newest', or 'random'.
|
347 |
* @type array $include_blog_ids Array of blog IDs to limit results to.
|
348 |
* @type string $sort 'ASC' or 'DESC'. Default: 'DESC'.
|
349 |
+
* @type string $search_terms Limit results by a search term. Default: the
|
350 |
+
* value of $_REQUEST['s'], if present.
|
351 |
* @type int $user_id The ID of the user whose blogs should be retrieved.
|
352 |
* When viewing a user profile page, 'user_id' defaults to the ID of
|
353 |
* the displayed user. Otherwise the default is false.
|
357 |
function bp_has_blogs( $args = '' ) {
|
358 |
global $blogs_template;
|
359 |
|
360 |
+
// Checkfor and use search terms
|
361 |
+
$search_terms = ! empty( $_REQUEST['s'] )
|
362 |
+
? $_REQUEST['s']
|
363 |
+
: false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
|
365 |
+
// Parse arguments
|
366 |
+
$r = bp_parse_args( $args, array(
|
367 |
+
'type' => 'active',
|
368 |
+
'page_arg' => 'bpage', // See https://buddypress.trac.wordpress.org/ticket/3679
|
369 |
'page' => 1,
|
370 |
'per_page' => 20,
|
371 |
'max' => false,
|
372 |
+
'user_id' => bp_displayed_user_id(), // Pass a user_id to limit to only blogs this user is a member of
|
|
|
|
|
|
|
373 |
'include_blog_ids' => false,
|
374 |
+
'search_terms' => $search_terms, // Pass search terms to filter on the blog title or description.
|
375 |
+
'update_meta_cache' => true
|
376 |
+
), 'has_blogs' );
|
377 |
|
378 |
+
// Set per_page to maximum if max is enforced
|
379 |
+
if ( ! empty( $r['max'] ) && ( (int) $r['per_page'] > (int) $r['max'] ) ) {
|
380 |
+
$r['per_page'] = (int) $r['max'];
|
|
|
|
|
|
|
|
|
|
|
381 |
}
|
382 |
|
383 |
+
// Get the blogs
|
384 |
+
$blogs_template = new BP_Blogs_Template( $r['type'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['search_terms'], $r['page_arg'], $r['update_meta_cache'], $r['include_blog_ids'] );
|
|
|
|
|
|
|
385 |
|
386 |
+
// Filter and return
|
387 |
+
return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), $blogs_template, $r );
|
388 |
}
|
389 |
|
390 |
/**
|
426 |
$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 ) );
|
427 |
$total = bp_core_number_format( $blogs_template->total_blog_count );
|
428 |
|
429 |
+
echo sprintf( _n( 'Viewing 1 site', 'Viewing %1$s - %2$s of %3$s sites', $total, 'buddypress' ), $from_num, $to_num, $total );
|
430 |
}
|
431 |
|
432 |
/**
|
478 |
* @type int|bool $width Default: false.
|
479 |
* @type int|bool $height Default: false.
|
480 |
* @type bool $id Currently unused.
|
481 |
+
* @type bool $no_grav Default: true.
|
482 |
* }
|
483 |
* @return string User avatar string.
|
484 |
*/
|
485 |
function bp_get_blog_avatar( $args = '' ) {
|
486 |
global $blogs_template;
|
487 |
|
488 |
+
// Bail if avatars are turned off
|
489 |
+
// @todo Should we maybe still filter this?
|
490 |
+
if ( ! buddypress()->avatar->show_avatars ) {
|
491 |
+
return false;
|
492 |
+
}
|
493 |
+
|
494 |
+
// Parse the arguments
|
495 |
+
$r = bp_parse_args( $args, array(
|
496 |
'type' => 'full',
|
497 |
'width' => false,
|
498 |
'height' => false,
|
499 |
'class' => 'avatar',
|
500 |
'id' => false,
|
501 |
'alt' => sprintf( __( 'Profile picture of site author %s', 'buddypress' ), bp_core_get_user_displayname( $blogs_template->blog->admin_user_id ) ),
|
502 |
+
'no_grav' => true,
|
503 |
+
) );
|
504 |
+
|
505 |
+
// Fetch the avatar
|
506 |
+
$avatar = bp_core_fetch_avatar( array(
|
507 |
+
'item_id' => $blogs_template->blog->admin_user_id,
|
508 |
+
'title' => $blogs_template->blog->admin_user_email,
|
509 |
+
//'avatar_dir' => 'blog-avatars',
|
510 |
+
//'object' => 'blog',
|
511 |
+
'type' => $r['type'],
|
512 |
+
'alt' => $r['alt'],
|
513 |
+
'css_id' => $r['id'],
|
514 |
+
'class' => $r['class'],
|
515 |
+
'width' => $r['width'],
|
516 |
+
'height' => $r['height']
|
517 |
+
) );
|
518 |
|
519 |
/***
|
520 |
* In future BuddyPress versions you will be able to set the avatar for a blog.
|
524 |
* This filter is deprecated as of BuddyPress 1.5 and may be removed in a future version.
|
525 |
* Use the 'bp_get_blog_avatar' filter instead.
|
526 |
*/
|
527 |
+
$avatar = apply_filters( 'bp_get_blog_avatar_' . $blogs_template->blog->blog_id, $avatar );
|
528 |
|
529 |
+
return apply_filters( 'bp_get_blog_avatar', $avatar, $blogs_template->blog->blog_id, $r );
|
530 |
}
|
531 |
|
532 |
function bp_blog_permalink() {
|
641 |
|
642 |
/**
|
643 |
* Output the last active date of the current blog in the loop.
|
644 |
+
*
|
645 |
+
* @param array $args See {@link bp_get_blog_last_active()}.
|
646 |
*/
|
647 |
+
function bp_blog_last_active( $args = array() ) {
|
648 |
+
echo bp_get_blog_last_active( $args );
|
649 |
}
|
650 |
/**
|
651 |
* Return the last active date of the current blog in the loop.
|
652 |
*
|
653 |
+
* @param array $args {
|
654 |
+
* Array of optional arguments.
|
655 |
+
* @type bool $active_format If true, formatted "Active 5 minutes
|
656 |
+
* ago". If false, formatted "5 minutes ago". Default: true.
|
657 |
+
* }
|
658 |
* @return string Last active date.
|
659 |
*/
|
660 |
+
function bp_get_blog_last_active( $args = array() ) {
|
661 |
global $blogs_template;
|
662 |
|
663 |
+
$r = wp_parse_args( $args, array(
|
664 |
+
'active_format' => true,
|
665 |
+
) );
|
666 |
+
|
667 |
+
if ( isset( $blogs_template->blog->last_activity ) ) {
|
668 |
+
if ( ! empty( $r['active_format'] ) ) {
|
669 |
+
$last_activity = bp_core_get_last_activity( $blogs_template->blog->last_activity, __( 'active %s', 'buddypress' ) );
|
670 |
+
} else {
|
671 |
+
$last_activity = bp_core_time_since( $blogs_template->blog->last_activity );
|
672 |
+
}
|
673 |
+
} else {
|
674 |
+
$last_activity = __( 'Never active', 'buddypress' );
|
675 |
+
}
|
676 |
+
|
677 |
+
return apply_filters( 'bp_blog_last_active', $last_activity, $r );
|
678 |
}
|
679 |
|
680 |
/**
|
681 |
* Output the latest post from the current blog in the loop.
|
682 |
+
*
|
683 |
+
* @param array $args See {@link bp_get_blog_latest_post()}.
|
684 |
*/
|
685 |
+
function bp_blog_latest_post( $args = array() ) {
|
686 |
+
echo bp_get_blog_latest_post( $args );
|
687 |
}
|
688 |
/**
|
689 |
* Return the latest post from the current blog in the loop.
|
690 |
*
|
691 |
+
* @param array $args {
|
692 |
+
* Array of optional arguments.
|
693 |
+
* @type bool $latest_format If true, formatted "Latest post:
|
694 |
+
* [link to post]". If false, formatted "[link to post]".
|
695 |
+
* Default: true.
|
696 |
+
* }
|
697 |
* @return string $retval String of the form 'Latest Post: [link to post]'.
|
698 |
*/
|
699 |
+
function bp_get_blog_latest_post( $args = array() ) {
|
700 |
global $blogs_template;
|
701 |
|
702 |
+
$r = wp_parse_args( $args, array(
|
703 |
+
'latest_format' => true,
|
704 |
+
) );
|
705 |
+
|
706 |
$retval = bp_get_blog_latest_post_title();
|
707 |
|
708 |
+
if ( ! empty( $retval ) ) {
|
709 |
+
if ( ! empty( $r['latest_format'] ) ) {
|
710 |
+
$retval = sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>' );
|
711 |
+
} else {
|
712 |
+
$retval = '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>';
|
713 |
+
}
|
714 |
+
}
|
715 |
|
716 |
return apply_filters( 'bp_get_blog_latest_post', $retval );
|
717 |
}
|
958 |
$errors = $filtered_results['errors'];
|
959 |
|
960 |
if ( $errors->get_error_code() ) {
|
961 |
+
echo "<p>" . __('There was a problem; please correct the form below and try again.', 'buddypress') . "</p>";
|
962 |
}
|
963 |
?>
|
964 |
<p><?php printf(__("By filling out the form below, you can <strong>add a site to your account</strong>. There is no limit to the number of sites that you can have, so create to your heart's content, but blog responsibly!", 'buddypress'), $current_user->display_name) ?></p>
|
1052 |
do_action('signup_blogform', $errors);
|
1053 |
}
|
1054 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1055 |
/**
|
1056 |
* Process a blog registration submission.
|
1057 |
*
|
@@ -200,36 +200,35 @@ function bp_core_add_admin_notice( $notice = '' ) {
|
|
200 |
* @since BuddyPress (1.2)
|
201 |
*/
|
202 |
function bp_core_activation_notice() {
|
203 |
-
global $
|
204 |
-
|
205 |
-
$bp = buddypress();
|
206 |
|
207 |
// Only the super admin gets warnings
|
208 |
if ( ! bp_current_user_can( 'bp_moderate' ) ) {
|
209 |
return;
|
210 |
}
|
211 |
|
212 |
-
//
|
213 |
-
if (
|
214 |
return;
|
215 |
}
|
216 |
|
217 |
-
//
|
218 |
-
if (
|
219 |
return;
|
220 |
}
|
221 |
|
222 |
-
// Bail in network admin
|
223 |
-
if (
|
224 |
return;
|
225 |
}
|
226 |
|
227 |
/**
|
228 |
-
* Check to make sure that the blog setup routine has run. This can't
|
229 |
-
* wizard because of the order which the components
|
230 |
-
*
|
231 |
*/
|
232 |
if ( bp_is_active( 'blogs' ) ) {
|
|
|
233 |
$count = $wpdb->get_var( "SELECT COUNT(*) FROM {$bp->blogs->table_name}" );
|
234 |
|
235 |
if ( empty( $count ) ) {
|
@@ -237,17 +236,14 @@ function bp_core_activation_notice() {
|
|
237 |
}
|
238 |
}
|
239 |
|
240 |
-
|
241 |
-
* Are pretty permalinks enabled?
|
242 |
-
*/
|
243 |
-
if ( isset( $_POST['permalink_structure'] ) ) {
|
244 |
-
return;
|
245 |
-
}
|
246 |
-
|
247 |
if ( empty( $wp_rewrite->permalink_structure ) ) {
|
248 |
bp_core_add_admin_notice( sprintf( __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), admin_url( 'options-permalink.php' ) ) );
|
249 |
}
|
250 |
|
|
|
|
|
|
|
251 |
/**
|
252 |
* Check for orphaned BP components (BP component is enabled, no WP page exists)
|
253 |
*/
|
@@ -527,15 +523,15 @@ function bp_core_add_contextual_help_content( $tab = '' ) {
|
|
527 |
|
528 |
switch ( $tab ) {
|
529 |
case 'bp-comp-overview' :
|
530 |
-
$retval = __( 'By default, all BuddyPress components are enabled. You can selectively disable any of the components by using the form. Your BuddyPress installation will continue to function. However, the features of the disabled components will no longer be accessible to anyone using the site.', 'buddypress' );
|
531 |
break;
|
532 |
|
533 |
case 'bp-page-overview' :
|
534 |
-
$retval = __( 'BuddyPress Components use WordPress Pages for their root directory/archive pages.
|
535 |
break;
|
536 |
|
537 |
case 'bp-settings-overview' :
|
538 |
-
$retval = __( 'Extra configuration settings.', 'buddypress' );
|
539 |
break;
|
540 |
|
541 |
case 'bp-profile-overview' :
|
@@ -802,17 +798,37 @@ function bp_admin_wp_nav_menu_restrict_items() {
|
|
802 |
*/
|
803 |
function bp_core_admin_user_row_actions( $actions, $user_object ) {
|
804 |
|
805 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
806 |
|
|
|
807 |
$url = bp_get_admin_url( 'users.php' );
|
808 |
|
809 |
-
|
810 |
-
|
|
|
|
|
|
|
|
|
|
|
811 |
} else {
|
812 |
-
$
|
|
|
|
|
813 |
}
|
814 |
}
|
815 |
|
|
|
|
|
|
|
|
|
|
|
816 |
return $actions;
|
817 |
}
|
818 |
|
200 |
* @since BuddyPress (1.2)
|
201 |
*/
|
202 |
function bp_core_activation_notice() {
|
203 |
+
global $wp_rewrite, $wpdb;
|
|
|
|
|
204 |
|
205 |
// Only the super admin gets warnings
|
206 |
if ( ! bp_current_user_can( 'bp_moderate' ) ) {
|
207 |
return;
|
208 |
}
|
209 |
|
210 |
+
// Bail in user admin
|
211 |
+
if ( is_user_admin() ) {
|
212 |
return;
|
213 |
}
|
214 |
|
215 |
+
// On multisite installs, don't load on a non-root blog, unless do_network_admin is overridden
|
216 |
+
if ( is_multisite() && bp_core_do_network_admin() && ! bp_is_root_blog() ) {
|
217 |
return;
|
218 |
}
|
219 |
|
220 |
+
// Bail if in network admin, and BuddyPress is not network activated
|
221 |
+
if ( is_network_admin() && ! bp_is_network_activated() ) {
|
222 |
return;
|
223 |
}
|
224 |
|
225 |
/**
|
226 |
+
* Check to make sure that the blog setup routine has run. This can't
|
227 |
+
* happen during the wizard because of the order which the components
|
228 |
+
* are loaded.
|
229 |
*/
|
230 |
if ( bp_is_active( 'blogs' ) ) {
|
231 |
+
$bp = buddypress();
|
232 |
$count = $wpdb->get_var( "SELECT COUNT(*) FROM {$bp->blogs->table_name}" );
|
233 |
|
234 |
if ( empty( $count ) ) {
|
236 |
}
|
237 |
}
|
238 |
|
239 |
+
// Add notice if no rewrite rules are enabled
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
if ( empty( $wp_rewrite->permalink_structure ) ) {
|
241 |
bp_core_add_admin_notice( sprintf( __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), admin_url( 'options-permalink.php' ) ) );
|
242 |
}
|
243 |
|
244 |
+
// Get BuddyPress instance
|
245 |
+
$bp = buddypress();
|
246 |
+
|
247 |
/**
|
248 |
* Check for orphaned BP components (BP component is enabled, no WP page exists)
|
249 |
*/
|
523 |
|
524 |
switch ( $tab ) {
|
525 |
case 'bp-comp-overview' :
|
526 |
+
$retval = __( 'By default, all but four of the BuddyPress components are enabled. You can selectively enable or disable any of the components by using the form below. Your BuddyPress installation will continue to function. However, the features of the disabled components will no longer be accessible to anyone using the site.', 'buddypress' );
|
527 |
break;
|
528 |
|
529 |
case 'bp-page-overview' :
|
530 |
+
$retval = __( 'BuddyPress Components use WordPress Pages for their root directory/archive pages. You can change the page associations for each active component by using the form below.', 'buddypress' );
|
531 |
break;
|
532 |
|
533 |
case 'bp-settings-overview' :
|
534 |
+
$retval = __( 'Extra configuration settings are provided and activated. You can selectively enable or disable any setting by using the form on this screen.', 'buddypress' );
|
535 |
break;
|
536 |
|
537 |
case 'bp-profile-overview' :
|
798 |
*/
|
799 |
function bp_core_admin_user_row_actions( $actions, $user_object ) {
|
800 |
|
801 |
+
// Setup the $user_id variable from the current user object
|
802 |
+
$user_id = 0;
|
803 |
+
if ( !empty( $user_object->ID ) ) {
|
804 |
+
$user_id = absint( $user_object->ID );
|
805 |
+
}
|
806 |
+
|
807 |
+
// Bail early if user cannot perform this action, or is looking at themselves
|
808 |
+
if ( current_user_can( 'edit_user', $user_id ) && ( bp_loggedin_user_id() !== $user_id ) ) {
|
809 |
|
810 |
+
// Admin URL could be single site or network
|
811 |
$url = bp_get_admin_url( 'users.php' );
|
812 |
|
813 |
+
// If spammed, create unspam link
|
814 |
+
if ( bp_is_user_spammer( $user_id ) ) {
|
815 |
+
$url = add_query_arg( array( 'action' => 'ham', 'user' => $user_id ), $url );
|
816 |
+
$unspam_link = wp_nonce_url( $url, 'bp-spam-user' );
|
817 |
+
$actions['ham'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $unspam_link ), esc_html__( 'Not Spam', 'buddypress' ) );
|
818 |
+
|
819 |
+
// If not already spammed, create spam link
|
820 |
} else {
|
821 |
+
$url = add_query_arg( array( 'action' => 'spam', 'user' => $user_id ), $url );
|
822 |
+
$spam_link = wp_nonce_url( $url, 'bp-spam-user' );
|
823 |
+
$actions['spam'] = sprintf( '<a class="submitdelete" href="%1$s">%2$s</a>', esc_url( $spam_link ), esc_html__( 'Spam', 'buddypress' ) );
|
824 |
}
|
825 |
}
|
826 |
|
827 |
+
// Create a "View" link
|
828 |
+
$url = bp_core_get_user_domain( $user_id );
|
829 |
+
$actions['view'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $url ), esc_html__( 'View', 'buddypress' ) );
|
830 |
+
|
831 |
+
// Return new actions
|
832 |
return $actions;
|
833 |
}
|
834 |
|
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* BuddyPress DB schema
|
4 |
*
|
@@ -9,81 +10,121 @@
|
|
9 |
// Exit if accessed directly
|
10 |
if ( !defined( 'ABSPATH' ) ) exit;
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
function bp_core_set_charset() {
|
13 |
global $wpdb;
|
14 |
|
15 |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
16 |
|
17 |
-
// BuddyPress component DB schema
|
18 |
return !empty( $wpdb->charset ) ? "DEFAULT CHARACTER SET {$wpdb->charset}" : '';
|
19 |
}
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
function bp_core_install( $active_components = false ) {
|
22 |
|
23 |
-
|
|
|
24 |
$active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
|
|
|
25 |
|
26 |
-
// Activity Streams
|
27 |
-
// Install tables even when inactive, to store last_activity data
|
28 |
bp_core_install_activity_streams();
|
29 |
|
|
|
|
|
|
|
30 |
// Notifications
|
31 |
-
if ( !empty( $active_components['notifications'] ) )
|
32 |
bp_core_install_notifications();
|
|
|
33 |
|
34 |
// Friend Connections
|
35 |
-
if ( !empty( $active_components['friends'] ) )
|
36 |
bp_core_install_friends();
|
|
|
37 |
|
38 |
// Extensible Groups
|
39 |
-
if ( !empty( $active_components['groups'] ) )
|
40 |
bp_core_install_groups();
|
|
|
41 |
|
42 |
// Private Messaging
|
43 |
-
if ( !empty( $active_components['messages'] ) )
|
44 |
bp_core_install_private_messaging();
|
|
|
45 |
|
46 |
// Extended Profiles
|
47 |
-
if ( !empty( $active_components['xprofile'] ) )
|
48 |
bp_core_install_extended_profiles();
|
|
|
49 |
|
50 |
// Blog tracking
|
51 |
-
if ( !empty( $active_components['blogs'] ) )
|
52 |
bp_core_install_blog_tracking();
|
53 |
-
|
54 |
-
// Maybe install (or upgrade) the signups table
|
55 |
-
bp_core_maybe_install_signups();
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
function bp_core_install_notifications() {
|
59 |
-
|
60 |
$sql = array();
|
61 |
$charset_collate = bp_core_set_charset();
|
62 |
$bp_prefix = bp_core_get_table_prefix();
|
63 |
|
64 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_notifications (
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
|
82 |
dbDelta( $sql );
|
83 |
}
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
function bp_core_install_activity_streams() {
|
86 |
-
|
87 |
$sql = array();
|
88 |
$charset_collate = bp_core_set_charset();
|
89 |
$bp_prefix = bp_core_get_table_prefix();
|
@@ -122,52 +163,68 @@ function bp_core_install_activity_streams() {
|
|
122 |
meta_value longtext DEFAULT NULL,
|
123 |
KEY activity_id (activity_id),
|
124 |
KEY meta_key (meta_key)
|
125 |
-
|
126 |
|
127 |
dbDelta( $sql );
|
128 |
}
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
function bp_core_install_friends() {
|
131 |
-
|
132 |
$sql = array();
|
133 |
$charset_collate = bp_core_set_charset();
|
134 |
$bp_prefix = bp_core_get_table_prefix();
|
135 |
|
136 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_friends (
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
|
147 |
dbDelta( $sql );
|
148 |
}
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
function bp_core_install_groups() {
|
151 |
-
|
152 |
$sql = array();
|
153 |
$charset_collate = bp_core_set_charset();
|
154 |
$bp_prefix = bp_core_get_table_prefix();
|
155 |
|
156 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_groups (
|
157 |
-
|
158 |
creator_id bigint(20) NOT NULL,
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
status varchar(10) NOT NULL DEFAULT 'public',
|
163 |
enable_forum tinyint(1) NOT NULL DEFAULT '1',
|
164 |
date_created datetime NOT NULL,
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
|
169 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_groups_members (
|
170 |
-
|
171 |
group_id bigint(20) NOT NULL,
|
172 |
user_id bigint(20) NOT NULL,
|
173 |
inviter_id bigint(20) NOT NULL,
|
@@ -182,10 +239,10 @@ function bp_core_install_groups() {
|
|
182 |
KEY group_id (group_id),
|
183 |
KEY is_admin (is_admin),
|
184 |
KEY is_mod (is_mod),
|
185 |
-
|
186 |
KEY inviter_id (inviter_id),
|
187 |
KEY is_confirmed (is_confirmed)
|
188 |
-
|
189 |
|
190 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_groups_groupmeta (
|
191 |
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
@@ -194,54 +251,71 @@ function bp_core_install_groups() {
|
|
194 |
meta_value longtext DEFAULT NULL,
|
195 |
KEY group_id (group_id),
|
196 |
KEY meta_key (meta_key)
|
197 |
-
|
198 |
|
199 |
dbDelta( $sql );
|
200 |
}
|
201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
function bp_core_install_private_messaging() {
|
203 |
-
|
204 |
$sql = array();
|
205 |
$charset_collate = bp_core_set_charset();
|
206 |
$bp_prefix = bp_core_get_table_prefix();
|
207 |
|
208 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_messages_messages (
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
|
219 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_messages_recipients (
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
sender_only tinyint(1) NOT NULL DEFAULT '0',
|
225 |
is_deleted tinyint(1) NOT NULL DEFAULT '0',
|
226 |
-
|
227 |
-
|
228 |
KEY is_deleted (is_deleted),
|
229 |
KEY sender_only (sender_only),
|
230 |
-
|
231 |
-
|
232 |
|
233 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_messages_notices (
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
is_active tinyint(1) NOT NULL DEFAULT '0',
|
239 |
-
|
240 |
-
|
241 |
|
242 |
dbDelta( $sql );
|
243 |
}
|
244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
function bp_core_install_extended_profiles() {
|
246 |
global $wpdb;
|
247 |
|
@@ -259,43 +333,43 @@ function bp_core_install_extended_profiles() {
|
|
259 |
}
|
260 |
|
261 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_groups (
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
|
270 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_fields (
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
|
290 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_data (
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
|
300 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_meta (
|
301 |
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
@@ -305,35 +379,45 @@ function bp_core_install_extended_profiles() {
|
|
305 |
meta_value longtext DEFAULT NULL,
|
306 |
KEY object_id (object_id),
|
307 |
KEY meta_key (meta_key)
|
308 |
-
|
309 |
|
310 |
dbDelta( $sql );
|
311 |
|
312 |
// Insert the default group and fields
|
313 |
$insert_sql = array();
|
314 |
|
315 |
-
if (
|
316 |
$insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_groups ( name, description, can_delete ) VALUES ( " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-base-group-name' ) ) ) . ", '', 0 );";
|
|
|
317 |
|
318 |
-
if (
|
319 |
$insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-fullname-field-name' ) ) ) . ", '', 1, 0 );";
|
|
|
320 |
|
321 |
dbDelta( $insert_sql );
|
322 |
}
|
323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
function bp_core_install_blog_tracking() {
|
325 |
-
|
326 |
$sql = array();
|
327 |
$charset_collate = bp_core_set_charset();
|
328 |
$bp_prefix = bp_core_get_table_prefix();
|
329 |
|
330 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_user_blogs (
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
|
338 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_user_blogs_blogmeta (
|
339 |
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
@@ -342,7 +426,7 @@ function bp_core_install_blog_tracking() {
|
|
342 |
meta_value longtext DEFAULT NULL,
|
343 |
KEY blog_id (blog_id),
|
344 |
KEY meta_key (meta_key)
|
345 |
-
|
346 |
|
347 |
dbDelta( $sql );
|
348 |
}
|
@@ -407,6 +491,11 @@ function bp_core_install_signups() {
|
|
407 |
function bp_core_upgrade_signups() {
|
408 |
global $wpdb;
|
409 |
|
|
|
|
|
|
|
|
|
|
|
410 |
// Never use bp_core_get_table_prefix() for any global users tables
|
411 |
$wpdb->signups = $wpdb->base_prefix . 'signups';
|
412 |
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* BuddyPress DB schema
|
5 |
*
|
10 |
// Exit if accessed directly
|
11 |
if ( !defined( 'ABSPATH' ) ) exit;
|
12 |
|
13 |
+
/**
|
14 |
+
* Get the DB schema to use for BuddyPress components
|
15 |
+
*
|
16 |
+
* @since BuddyPress (1.1.0)
|
17 |
+
*
|
18 |
+
* @global $wpdb $wpdb
|
19 |
+
* @return string The default database character-set, if set
|
20 |
+
*/
|
21 |
function bp_core_set_charset() {
|
22 |
global $wpdb;
|
23 |
|
24 |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
25 |
|
|
|
26 |
return !empty( $wpdb->charset ) ? "DEFAULT CHARACTER SET {$wpdb->charset}" : '';
|
27 |
}
|
28 |
|
29 |
+
/**
|
30 |
+
* Main installer
|
31 |
+
*
|
32 |
+
* Can be passed an optional array of components to explicitly run installation
|
33 |
+
* routines on, typically the first time a component is activated in Settings.
|
34 |
+
*
|
35 |
+
* @since BuddyPress (1.0.0)
|
36 |
+
*
|
37 |
+
* @param array $active_components Components to install
|
38 |
+
*/
|
39 |
function bp_core_install( $active_components = false ) {
|
40 |
|
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 |
|
46 |
+
// Install Activity Streams even when inactive (to store last_activity data)
|
|
|
47 |
bp_core_install_activity_streams();
|
48 |
|
49 |
+
// Install the signups table
|
50 |
+
bp_core_maybe_install_signups();
|
51 |
+
|
52 |
// Notifications
|
53 |
+
if ( !empty( $active_components['notifications'] ) ) {
|
54 |
bp_core_install_notifications();
|
55 |
+
}
|
56 |
|
57 |
// Friend Connections
|
58 |
+
if ( !empty( $active_components['friends'] ) ) {
|
59 |
bp_core_install_friends();
|
60 |
+
}
|
61 |
|
62 |
// Extensible Groups
|
63 |
+
if ( !empty( $active_components['groups'] ) ) {
|
64 |
bp_core_install_groups();
|
65 |
+
}
|
66 |
|
67 |
// Private Messaging
|
68 |
+
if ( !empty( $active_components['messages'] ) ) {
|
69 |
bp_core_install_private_messaging();
|
70 |
+
}
|
71 |
|
72 |
// Extended Profiles
|
73 |
+
if ( !empty( $active_components['xprofile'] ) ) {
|
74 |
bp_core_install_extended_profiles();
|
75 |
+
}
|
76 |
|
77 |
// Blog tracking
|
78 |
+
if ( !empty( $active_components['blogs'] ) ) {
|
79 |
bp_core_install_blog_tracking();
|
80 |
+
}
|
|
|
|
|
81 |
}
|
82 |
|
83 |
+
/**
|
84 |
+
* Install database tables for the Notifications component
|
85 |
+
*
|
86 |
+
* @since BuddyPress (1.0.0)
|
87 |
+
*
|
88 |
+
* @uses bp_core_set_charset()
|
89 |
+
* @uses bp_core_get_table_prefix()
|
90 |
+
* @uses dbDelta()
|
91 |
+
*/
|
92 |
function bp_core_install_notifications() {
|
|
|
93 |
$sql = array();
|
94 |
$charset_collate = bp_core_set_charset();
|
95 |
$bp_prefix = bp_core_get_table_prefix();
|
96 |
|
97 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_notifications (
|
98 |
+
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
99 |
+
user_id bigint(20) NOT NULL,
|
100 |
+
item_id bigint(20) NOT NULL,
|
101 |
+
secondary_item_id bigint(20),
|
102 |
+
component_name varchar(75) NOT NULL,
|
103 |
+
component_action varchar(75) NOT NULL,
|
104 |
+
date_notified datetime NOT NULL,
|
105 |
+
is_new bool NOT NULL DEFAULT 0,
|
106 |
+
KEY item_id (item_id),
|
107 |
+
KEY secondary_item_id (secondary_item_id),
|
108 |
+
KEY user_id (user_id),
|
109 |
+
KEY is_new (is_new),
|
110 |
+
KEY component_name (component_name),
|
111 |
+
KEY component_action (component_action),
|
112 |
+
KEY useritem (user_id,is_new)
|
113 |
+
) {$charset_collate};";
|
114 |
|
115 |
dbDelta( $sql );
|
116 |
}
|
117 |
|
118 |
+
/**
|
119 |
+
* Install database tables for the Activity component
|
120 |
+
*
|
121 |
+
* @since BuddyPress (1.0.0)
|
122 |
+
*
|
123 |
+
* @uses bp_core_set_charset()
|
124 |
+
* @uses bp_core_get_table_prefix()
|
125 |
+
* @uses dbDelta()
|
126 |
+
*/
|
127 |
function bp_core_install_activity_streams() {
|
|
|
128 |
$sql = array();
|
129 |
$charset_collate = bp_core_set_charset();
|
130 |
$bp_prefix = bp_core_get_table_prefix();
|
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 );
|
169 |
}
|
170 |
|
171 |
+
/**
|
172 |
+
* Install database tables for the Notifications component
|
173 |
+
*
|
174 |
+
* @since BuddyPress (1.0.0)
|
175 |
+
*
|
176 |
+
* @uses bp_core_set_charset()
|
177 |
+
* @uses bp_core_get_table_prefix()
|
178 |
+
* @uses dbDelta()
|
179 |
+
*/
|
180 |
function bp_core_install_friends() {
|
|
|
181 |
$sql = array();
|
182 |
$charset_collate = bp_core_set_charset();
|
183 |
$bp_prefix = bp_core_get_table_prefix();
|
184 |
|
185 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_friends (
|
186 |
+
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
187 |
+
initiator_user_id bigint(20) NOT NULL,
|
188 |
+
friend_user_id bigint(20) NOT NULL,
|
189 |
+
is_confirmed bool DEFAULT 0,
|
190 |
+
is_limited bool DEFAULT 0,
|
191 |
+
date_created datetime NOT NULL,
|
192 |
+
KEY initiator_user_id (initiator_user_id),
|
193 |
+
KEY friend_user_id (friend_user_id)
|
194 |
+
) {$charset_collate};";
|
195 |
|
196 |
dbDelta( $sql );
|
197 |
}
|
198 |
|
199 |
+
/**
|
200 |
+
* Install database tables for the Groups component
|
201 |
+
*
|
202 |
+
* @since BuddyPress (1.0.0)
|
203 |
+
*
|
204 |
+
* @uses bp_core_set_charset()
|
205 |
+
* @uses bp_core_get_table_prefix()
|
206 |
+
* @uses dbDelta()
|
207 |
+
*/
|
208 |
function bp_core_install_groups() {
|
|
|
209 |
$sql = array();
|
210 |
$charset_collate = bp_core_set_charset();
|
211 |
$bp_prefix = bp_core_get_table_prefix();
|
212 |
|
213 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_groups (
|
214 |
+
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
215 |
creator_id bigint(20) NOT NULL,
|
216 |
+
name varchar(100) NOT NULL,
|
217 |
+
slug varchar(200) NOT NULL,
|
218 |
+
description longtext NOT NULL,
|
219 |
status varchar(10) NOT NULL DEFAULT 'public',
|
220 |
enable_forum tinyint(1) NOT NULL DEFAULT '1',
|
221 |
date_created datetime NOT NULL,
|
222 |
+
KEY creator_id (creator_id),
|
223 |
+
KEY status (status)
|
224 |
+
) {$charset_collate};";
|
225 |
|
226 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_groups_members (
|
227 |
+
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
228 |
group_id bigint(20) NOT NULL,
|
229 |
user_id bigint(20) NOT NULL,
|
230 |
inviter_id bigint(20) NOT NULL,
|
239 |
KEY group_id (group_id),
|
240 |
KEY is_admin (is_admin),
|
241 |
KEY is_mod (is_mod),
|
242 |
+
KEY user_id (user_id),
|
243 |
KEY inviter_id (inviter_id),
|
244 |
KEY is_confirmed (is_confirmed)
|
245 |
+
) {$charset_collate};";
|
246 |
|
247 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_groups_groupmeta (
|
248 |
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
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 );
|
257 |
}
|
258 |
|
259 |
+
/**
|
260 |
+
* Install database tables for the Messsages component
|
261 |
+
*
|
262 |
+
* @since BuddyPress (1.0.0)
|
263 |
+
*
|
264 |
+
* @uses bp_core_set_charset()
|
265 |
+
* @uses bp_core_get_table_prefix()
|
266 |
+
* @uses dbDelta()
|
267 |
+
*/
|
268 |
function bp_core_install_private_messaging() {
|
|
|
269 |
$sql = array();
|
270 |
$charset_collate = bp_core_set_charset();
|
271 |
$bp_prefix = bp_core_get_table_prefix();
|
272 |
|
273 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_messages_messages (
|
274 |
+
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
275 |
+
thread_id bigint(20) NOT NULL,
|
276 |
+
sender_id bigint(20) NOT NULL,
|
277 |
+
subject varchar(200) NOT NULL,
|
278 |
+
message longtext NOT NULL,
|
279 |
+
date_sent datetime NOT NULL,
|
280 |
+
KEY sender_id (sender_id),
|
281 |
+
KEY thread_id (thread_id)
|
282 |
+
) {$charset_collate};";
|
283 |
|
284 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_messages_recipients (
|
285 |
+
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
286 |
+
user_id bigint(20) NOT NULL,
|
287 |
+
thread_id bigint(20) NOT NULL,
|
288 |
+
unread_count int(10) NOT NULL DEFAULT '0',
|
289 |
sender_only tinyint(1) NOT NULL DEFAULT '0',
|
290 |
is_deleted tinyint(1) NOT NULL DEFAULT '0',
|
291 |
+
KEY user_id (user_id),
|
292 |
+
KEY thread_id (thread_id),
|
293 |
KEY is_deleted (is_deleted),
|
294 |
KEY sender_only (sender_only),
|
295 |
+
KEY unread_count (unread_count)
|
296 |
+
) {$charset_collate};";
|
297 |
|
298 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_messages_notices (
|
299 |
+
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
300 |
+
subject varchar(200) NOT NULL,
|
301 |
+
message longtext NOT NULL,
|
302 |
+
date_sent datetime NOT NULL,
|
303 |
is_active tinyint(1) NOT NULL DEFAULT '0',
|
304 |
+
KEY is_active (is_active)
|
305 |
+
) {$charset_collate};";
|
306 |
|
307 |
dbDelta( $sql );
|
308 |
}
|
309 |
|
310 |
+
/**
|
311 |
+
* Install database tables for the Profiles component
|
312 |
+
*
|
313 |
+
* @since BuddyPress (1.0.0)
|
314 |
+
*
|
315 |
+
* @uses bp_core_set_charset()
|
316 |
+
* @uses bp_core_get_table_prefix()
|
317 |
+
* @uses dbDelta()
|
318 |
+
*/
|
319 |
function bp_core_install_extended_profiles() {
|
320 |
global $wpdb;
|
321 |
|
333 |
}
|
334 |
|
335 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_groups (
|
336 |
+
id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
337 |
+
name varchar(150) NOT NULL,
|
338 |
+
description mediumtext NOT NULL,
|
339 |
+
group_order bigint(20) NOT NULL DEFAULT '0',
|
340 |
+
can_delete tinyint(1) NOT NULL,
|
341 |
+
KEY can_delete (can_delete)
|
342 |
+
) {$charset_collate};";
|
343 |
|
344 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_fields (
|
345 |
+
id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
346 |
+
group_id bigint(20) unsigned NOT NULL,
|
347 |
+
parent_id bigint(20) unsigned NOT NULL,
|
348 |
+
type varchar(150) NOT NULL,
|
349 |
+
name varchar(150) NOT NULL,
|
350 |
+
description longtext NOT NULL,
|
351 |
+
is_required tinyint(1) NOT NULL DEFAULT '0',
|
352 |
+
is_default_option tinyint(1) NOT NULL DEFAULT '0',
|
353 |
+
field_order bigint(20) NOT NULL DEFAULT '0',
|
354 |
+
option_order bigint(20) NOT NULL DEFAULT '0',
|
355 |
+
order_by varchar(15) NOT NULL DEFAULT '',
|
356 |
+
can_delete tinyint(1) NOT NULL DEFAULT '1',
|
357 |
+
KEY group_id (group_id),
|
358 |
+
KEY parent_id (parent_id),
|
359 |
+
KEY field_order (field_order),
|
360 |
+
KEY can_delete (can_delete),
|
361 |
+
KEY is_required (is_required)
|
362 |
+
) {$charset_collate};";
|
363 |
|
364 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_data (
|
365 |
+
id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
366 |
+
field_id bigint(20) unsigned NOT NULL,
|
367 |
+
user_id bigint(20) unsigned NOT NULL,
|
368 |
+
value longtext NOT NULL,
|
369 |
+
last_updated datetime NOT NULL,
|
370 |
+
KEY field_id (field_id),
|
371 |
+
KEY user_id (user_id)
|
372 |
+
) {$charset_collate};";
|
373 |
|
374 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_meta (
|
375 |
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
379 |
meta_value longtext DEFAULT NULL,
|
380 |
KEY object_id (object_id),
|
381 |
KEY meta_key (meta_key)
|
382 |
+
) {$charset_collate};";
|
383 |
|
384 |
dbDelta( $sql );
|
385 |
|
386 |
// Insert the default group and fields
|
387 |
$insert_sql = array();
|
388 |
|
389 |
+
if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_groups WHERE id = 1" ) ) {
|
390 |
$insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_groups ( name, description, can_delete ) VALUES ( " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-base-group-name' ) ) ) . ", '', 0 );";
|
391 |
+
}
|
392 |
|
393 |
+
if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE id = 1" ) ) {
|
394 |
$insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-fullname-field-name' ) ) ) . ", '', 1, 0 );";
|
395 |
+
}
|
396 |
|
397 |
dbDelta( $insert_sql );
|
398 |
}
|
399 |
|
400 |
+
/**
|
401 |
+
* Install database tables for the Sites component
|
402 |
+
*
|
403 |
+
* @since BuddyPress (1.0.0)
|
404 |
+
*
|
405 |
+
* @uses bp_core_set_charset()
|
406 |
+
* @uses bp_core_get_table_prefix()
|
407 |
+
* @uses dbDelta()
|
408 |
+
*/
|
409 |
function bp_core_install_blog_tracking() {
|
|
|
410 |
$sql = array();
|
411 |
$charset_collate = bp_core_set_charset();
|
412 |
$bp_prefix = bp_core_get_table_prefix();
|
413 |
|
414 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_user_blogs (
|
415 |
+
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
416 |
+
user_id bigint(20) NOT NULL,
|
417 |
+
blog_id bigint(20) NOT NULL,
|
418 |
+
KEY user_id (user_id),
|
419 |
+
KEY blog_id (blog_id)
|
420 |
+
) {$charset_collate};";
|
421 |
|
422 |
$sql[] = "CREATE TABLE {$bp_prefix}bp_user_blogs_blogmeta (
|
423 |
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
426 |
meta_value longtext DEFAULT NULL,
|
427 |
KEY blog_id (blog_id),
|
428 |
KEY meta_key (meta_key)
|
429 |
+
) {$charset_collate};";
|
430 |
|
431 |
dbDelta( $sql );
|
432 |
}
|
491 |
function bp_core_upgrade_signups() {
|
492 |
global $wpdb;
|
493 |
|
494 |
+
// Bail if global tables should not be upgraded
|
495 |
+
if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
|
496 |
+
return;
|
497 |
+
}
|
498 |
+
|
499 |
// Never use bp_core_get_table_prefix() for any global users tables
|
500 |
$wpdb->signups = $wpdb->base_prefix . 'signups';
|
501 |
|
@@ -49,21 +49,6 @@ function bp_admin_setting_callback_account_deletion() {
|
|
49 |
<?php
|
50 |
}
|
51 |
|
52 |
-
/**
|
53 |
-
* If user has upgraded to 1.6 and chose to retain their BuddyBar, offer then a switch to change over
|
54 |
-
* to the WP Toolbar.
|
55 |
-
*
|
56 |
-
* @since BuddyPress (1.6)
|
57 |
-
*/
|
58 |
-
function bp_admin_setting_callback_force_buddybar() {
|
59 |
-
?>
|
60 |
-
|
61 |
-
<input id="_bp_force_buddybar" name="_bp_force_buddybar" type="checkbox" value="1" <?php checked( ! bp_force_buddybar( true ) ); ?> />
|
62 |
-
<label for="_bp_force_buddybar"><?php _e( 'Switch to WordPress Toolbar', 'buddypress' ); ?></label>
|
63 |
-
|
64 |
-
<?php
|
65 |
-
}
|
66 |
-
|
67 |
/** Activity *******************************************************************/
|
68 |
|
69 |
/**
|
@@ -117,20 +102,6 @@ function bp_admin_setting_callback_heartbeat() {
|
|
117 |
<?php
|
118 |
}
|
119 |
|
120 |
-
/**
|
121 |
-
* Sanitization for _bp_force_buddyvar
|
122 |
-
*
|
123 |
-
* If upgraded to 1.6 and you chose to keep the BuddyBar, a checkbox asks if you want to switch to
|
124 |
-
* the WP Toolbar. The option we store is 1 if the BuddyBar is forced on, so we use this function
|
125 |
-
* to flip the boolean before saving the intval.
|
126 |
-
*
|
127 |
-
* @since BuddyPress (1.6)
|
128 |
-
* @access Private
|
129 |
-
*/
|
130 |
-
function bp_admin_sanitize_callback_force_buddybar( $value = false ) {
|
131 |
-
return $value ? 0 : 1;
|
132 |
-
}
|
133 |
-
|
134 |
/**
|
135 |
* Sanitization for bp-disable-blogforum-comments setting
|
136 |
*
|
49 |
<?php
|
50 |
}
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
/** Activity *******************************************************************/
|
53 |
|
54 |
/**
|
102 |
<?php
|
103 |
}
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
/**
|
106 |
* Sanitization for bp-disable-blogforum-comments setting
|
107 |
*
|
@@ -132,6 +132,16 @@ function bp_admin_repair_list() {
|
|
132 |
);
|
133 |
}
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
ksort( $repair_list );
|
136 |
|
137 |
return (array) apply_filters( 'bp_repair_list', $repair_list );
|
@@ -238,6 +248,38 @@ function bp_admin_repair_group_count() {
|
|
238 |
return array( 0, sprintf( $statement, __( 'Complete!', 'buddypress' ) ) );
|
239 |
}
|
240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
/**
|
242 |
* Recalculate the total number of active site members.
|
243 |
*
|
@@ -281,7 +323,6 @@ function bp_admin_tools_feedback( $message, $class = false ) {
|
|
281 |
switch ( count( $errors ) ) {
|
282 |
case 0:
|
283 |
return false;
|
284 |
-
break;
|
285 |
|
286 |
case 1:
|
287 |
$message = '<p>' . $errors[0] . '</p>';
|
132 |
);
|
133 |
}
|
134 |
|
135 |
+
// Blogs:
|
136 |
+
// - user blog count
|
137 |
+
if ( bp_is_active( 'blogs' ) ) {
|
138 |
+
$repair_list[90] = array(
|
139 |
+
'bp-blog-records',
|
140 |
+
__( 'Repopulate blogs records', 'buddypress' ),
|
141 |
+
'bp_admin_repair_blog_records',
|
142 |
+
);
|
143 |
+
}
|
144 |
+
|
145 |
ksort( $repair_list );
|
146 |
|
147 |
return (array) apply_filters( 'bp_repair_list', $repair_list );
|
248 |
return array( 0, sprintf( $statement, __( 'Complete!', 'buddypress' ) ) );
|
249 |
}
|
250 |
|
251 |
+
/**
|
252 |
+
* Recalculate user-to-blog relationships and useful blog meta data
|
253 |
+
*
|
254 |
+
* @since BuddyPress (2.1.0)
|
255 |
+
*
|
256 |
+
* @return array
|
257 |
+
*/
|
258 |
+
function bp_admin_repair_blog_records() {
|
259 |
+
|
260 |
+
// Description of this tool, dispalyed to the user
|
261 |
+
$statement = __( 'Repopulating Blogs records… %s', 'buddypress' );
|
262 |
+
|
263 |
+
// Default to failure text
|
264 |
+
$result = __( 'Failed!', 'buddypress' );
|
265 |
+
|
266 |
+
// Default to unrepaired
|
267 |
+
$repair = false;
|
268 |
+
|
269 |
+
// Run function if blogs component is active
|
270 |
+
if ( bp_is_active( 'blogs' ) ) {
|
271 |
+
$repair = bp_blogs_record_existing_blogs();
|
272 |
+
}
|
273 |
+
|
274 |
+
// Setup success/fail messaging
|
275 |
+
if ( true === $repair ) {
|
276 |
+
$result = __( 'Complete!', 'buddypress' );
|
277 |
+
}
|
278 |
+
|
279 |
+
// All done!
|
280 |
+
return array( 0, sprintf( $statement, $result ) );
|
281 |
+
}
|
282 |
+
|
283 |
/**
|
284 |
* Recalculate the total number of active site members.
|
285 |
*
|
323 |
switch ( count( $errors ) ) {
|
324 |
case 0:
|
325 |
return false;
|
|
|
326 |
|
327 |
case 1:
|
328 |
$message = '<p>' . $errors[0] . '</p>';
|
@@ -0,0 +1,432 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* CSS that is always loaded when in wp-admin
|
3 |
+
*
|
4 |
+
* @since BuddyPress (1.6)
|
5 |
+
*/
|
6 |
+
|
7 |
+
/* User's Lists
|
8 |
+
------------------------------------------------------------------------------*/
|
9 |
+
|
10 |
+
body.site-users-php th#role,
|
11 |
+
body.users-php th#role,
|
12 |
+
body.users_page_bp-signups th#count_sent {
|
13 |
+
width: 10%;
|
14 |
+
}
|
15 |
+
|
16 |
+
body.site-users-php th#name,
|
17 |
+
body.site-users-php th#email,
|
18 |
+
body.users-php th#name,
|
19 |
+
body.users-php th#registered,
|
20 |
+
body.users-php th#email,
|
21 |
+
body.users_page_bp-signups th#name,
|
22 |
+
body.users_page_bp-signups th#registered,
|
23 |
+
body.users_page_bp-signups th#email,
|
24 |
+
body.users_page_bp-signups th#date_sent {
|
25 |
+
width: 15%;
|
26 |
+
}
|
27 |
+
|
28 |
+
body.users-php th#blogs,
|
29 |
+
body.users_page_bp-signups th#blogs {
|
30 |
+
width: 20%;
|
31 |
+
}
|
32 |
+
|
33 |
+
body.users_page_bp-signups th.column-count_sent,
|
34 |
+
body.users_page_bp-signups td.count_sent {
|
35 |
+
text-align: center;
|
36 |
+
}
|
37 |
+
|
38 |
+
/* Icon 32's
|
39 |
+
------------------------------------------------------------------------------*/
|
40 |
+
|
41 |
+
body.branch-3-6 div#icon-buddypress,
|
42 |
+
body.branch-3-7 div#icon-buddypress {
|
43 |
+
background: url('../images/icons32.png') no-repeat -370px -6px;
|
44 |
+
}
|
45 |
+
|
46 |
+
body.branch-3-6 div#icon-buddypress-activity,
|
47 |
+
body.branch-3-7 div#icon-buddypress-activity {
|
48 |
+
background: url('../images/icons32.png') no-repeat -10px -6px;
|
49 |
+
}
|
50 |
+
|
51 |
+
body.branch-3-6 div#icon-buddypress-groups,
|
52 |
+
body.branch-3-7 div#icon-buddypress-groups {
|
53 |
+
background: url('../images/icons32.png') no-repeat -250px -6px;
|
54 |
+
}
|
55 |
+
|
56 |
+
/* Menu Icons
|
57 |
+
------------------------------------------------------------------------------*/
|
58 |
+
|
59 |
+
/* Backpat */
|
60 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,
|
61 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,
|
62 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,
|
63 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image {
|
64 |
+
background-image: url('../images/menu.png') !important;
|
65 |
+
background-position: -178px -34px;
|
66 |
+
}
|
67 |
+
|
68 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,
|
69 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,
|
70 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,
|
71 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image,
|
72 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components:hover .wp-menu-image,
|
73 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,
|
74 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components.wp-has-current-submenu .wp-menu-image,
|
75 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image {
|
76 |
+
background-position: -178px -2px;
|
77 |
+
}
|
78 |
+
|
79 |
+
/* Activity */
|
80 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,
|
81 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,
|
82 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,
|
83 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image {
|
84 |
+
background-image: url('../images/menu.png');
|
85 |
+
background-position: 0 -34px;
|
86 |
+
}
|
87 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,
|
88 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,
|
89 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,
|
90 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,
|
91 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,
|
92 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image,
|
93 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity:hover .wp-menu-image,
|
94 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.current .wp-menu-image,
|
95 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity.wp-has-current-submenu .wp-menu-image,
|
96 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network:hover .wp-menu-image,
|
97 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.current .wp-menu-image,
|
98 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network.wp-has-current-submenu .wp-menu-image {
|
99 |
+
background-position: 0 -2px;
|
100 |
+
}
|
101 |
+
|
102 |
+
/* Groups */
|
103 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,
|
104 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,
|
105 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,
|
106 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image {
|
107 |
+
background-image: url('../images/menu.png');
|
108 |
+
background-position: -61px -34px;
|
109 |
+
}
|
110 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,
|
111 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,
|
112 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,
|
113 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,
|
114 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,
|
115 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image,
|
116 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups:hover .wp-menu-image,
|
117 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.current .wp-menu-image,
|
118 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups.wp-has-current-submenu .wp-menu-image,
|
119 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network:hover .wp-menu-image,
|
120 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.current .wp-menu-image,
|
121 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-submenu .wp-menu-image {
|
122 |
+
background-position: -61px -2px;
|
123 |
+
}
|
124 |
+
|
125 |
+
/* Tools */
|
126 |
+
#adminmenu .toplevel_page_network-tools div.wp-menu-image:before {
|
127 |
+
content: "";
|
128 |
+
}
|
129 |
+
|
130 |
+
/* Components
|
131 |
+
------------------------------------------------------------------------------*/
|
132 |
+
|
133 |
+
/* Dashicons */
|
134 |
+
#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,
|
135 |
+
#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before,
|
136 |
+
#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before {
|
137 |
+
content: "\f452";
|
138 |
+
}
|
139 |
+
|
140 |
+
#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,
|
141 |
+
#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before,
|
142 |
+
#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before {
|
143 |
+
content: "\f456";
|
144 |
+
}
|
145 |
+
|
146 |
+
#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,
|
147 |
+
#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before,
|
148 |
+
#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before {
|
149 |
+
content: "\f439";
|
150 |
+
}
|
151 |
+
|
152 |
+
#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,
|
153 |
+
#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before,
|
154 |
+
#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before {
|
155 |
+
content: "\f457";
|
156 |
+
}
|
157 |
+
|
158 |
+
#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,
|
159 |
+
#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before,
|
160 |
+
#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before{
|
161 |
+
content: "\f454";
|
162 |
+
}
|
163 |
+
|
164 |
+
#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,
|
165 |
+
#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before,
|
166 |
+
#adminmenu #toplevel_page_bp-settings_network .wp-menu-image:before {
|
167 |
+
content: "\f108";
|
168 |
+
}
|
169 |
+
|
170 |
+
#adminmenu li.toplevel_page_bp-components .wp-menu-image,
|
171 |
+
#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image {
|
172 |
+
content: "\f448";
|
173 |
+
}
|
174 |
+
|
175 |
+
/* Dashicons overrides for backward compatibility */
|
176 |
+
body.branch-3-6 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,
|
177 |
+
body.branch-3-6 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,
|
178 |
+
body.branch-3-6 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,
|
179 |
+
body.branch-3-6 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,
|
180 |
+
body.branch-3-6 #adminmenu li.toplevel_page_bp-components .wp-menu-image,
|
181 |
+
body.branch-3-6 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,
|
182 |
+
body.branch-3-7 #adminmenu #toplevel_page_bp-activity .wp-menu-image:before,
|
183 |
+
body.branch-3-7 #adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before,
|
184 |
+
body.branch-3-7 #adminmenu #toplevel_page_bp-groups .wp-menu-image:before,
|
185 |
+
body.branch-3-7 #adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before,
|
186 |
+
body.branch-3-7 #adminmenu li.toplevel_page_bp-components .wp-menu-image,
|
187 |
+
body.branch-3-7 #adminmenu li.toplevel_page_bp-general-settings .wp-menu-image {
|
188 |
+
content: "";
|
189 |
+
}
|
190 |
+
|
191 |
+
/* Settings - Dashicons (WP 3.8+) */
|
192 |
+
.settings_page_bp-components td.plugin-title span {
|
193 |
+
float: right;
|
194 |
+
width: 18px;
|
195 |
+
height: 18px;
|
196 |
+
margin-left: 5px;
|
197 |
+
}
|
198 |
+
|
199 |
+
.settings_page_bp-components td.plugin-title span:before {
|
200 |
+
font-family: 'dashicons';
|
201 |
+
font-size: 18px;
|
202 |
+
}
|
203 |
+
|
204 |
+
.settings_page_bp-components tr.activity td.plugin-title span:before {
|
205 |
+
content: "\f452";
|
206 |
+
}
|
207 |
+
|
208 |
+
.settings_page_bp-components tr.notifications td.plugin-title span:before {
|
209 |
+
content: "\f339";
|
210 |
+
}
|
211 |
+
|
212 |
+
.settings_page_bp-components tr.xprofile td.plugin-title span:before {
|
213 |
+
content: "\f336";
|
214 |
+
}
|
215 |
+
|
216 |
+
.settings_page_bp-components tr.settings td.plugin-title span:before {
|
217 |
+
content: "\f108";
|
218 |
+
}
|
219 |
+
|
220 |
+
.settings_page_bp-components tr.groups td.plugin-title span:before {
|
221 |
+
content: "\f456";
|
222 |
+
}
|
223 |
+
|
224 |
+
.settings_page_bp-components tr.messages td.plugin-title span:before {
|
225 |
+
content: "\f457";
|
226 |
+
}
|
227 |
+
|
228 |
+
.settings_page_bp-components tr.forums td.plugin-title span:before {
|
229 |
+
content: "\f452";
|
230 |
+
}
|
231 |
+
|
232 |
+
.settings_page_bp-components tr.blogs td.plugin-title span:before {
|
233 |
+
content: "\f120";
|
234 |
+
}
|
235 |
+
|
236 |
+
.settings_page_bp-components tr.friends td.plugin-title span:before {
|
237 |
+
content: "\f454";
|
238 |
+
}
|
239 |
+
|
240 |
+
/* Settings - Legacy (< WP 3.8) */
|
241 |
+
body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span:before,
|
242 |
+
body.branch-3-6.settings_page_bp-components tr.notifications td.plugin-title span:before,
|
243 |
+
body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span:before,
|
244 |
+
body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span:before,
|
245 |
+
body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span:before,
|
246 |
+
body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span:before,
|
247 |
+
body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span:before,
|
248 |
+
body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span:before,
|
249 |
+
body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span:before,
|
250 |
+
body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span:before,
|
251 |
+
body.branch-3-7.settings_page_bp-components tr.notifications td.plugin-title span:before,
|
252 |
+
body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span:before,
|
253 |
+
body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span:before,
|
254 |
+
body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span:before,
|
255 |
+
body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span:before,
|
256 |
+
body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span:before,
|
257 |
+
body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span:before,
|
258 |
+
body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span:before {
|
259 |
+
content: "";
|
260 |
+
}
|
261 |
+
|
262 |
+
body.branch-3-6.settings_page_bp-components td.plugin-title span,
|
263 |
+
body.branch-3-7.settings_page_bp-components td.plugin-title span {
|
264 |
+
background-image: url('../images/menu.png');
|
265 |
+
background-position: -4px -40px;
|
266 |
+
background-repeat: no-repeat;
|
267 |
+
}
|
268 |
+
|
269 |
+
body.branch-3-6.settings_page_bp-components tr.active td.plugin-title span,
|
270 |
+
body.branch-3-7.settings_page_bp-components tr.active td.plugin-title span {
|
271 |
+
background-position-y: -7px;
|
272 |
+
}
|
273 |
+
|
274 |
+
body.branch-3-6.settings_page_bp-components tr.activity td.plugin-title span,
|
275 |
+
body.branch-3-7.settings_page_bp-components tr.activity td.plugin-title span {
|
276 |
+
background-position: -4px -40px;
|
277 |
+
}
|
278 |
+
|
279 |
+
body.branch-3-6.settings_page_bp-components tr.activity.active td.plugin-title span,
|
280 |
+
body.branch-3-7.settings_page_bp-components tr.activity.active td.plugin-title span {
|
281 |
+
background-position: -4px -7px;
|
282 |
+
}
|
283 |
+
|
284 |
+
body.branch-3-6.settings_page_bp-components tr.xprofile td.plugin-title span,
|
285 |
+
body.branch-3-7.settings_page_bp-components tr.xprofile td.plugin-title span {
|
286 |
+
background-image: url('../images/menu-wp.png');
|
287 |
+
background-position: -305px -40px;
|
288 |
+
}
|
289 |
+
|
290 |
+
body.branch-3-6.settings_page_bp-components tr.xprofile.active td.plugin-title span,
|
291 |
+
body.branch-3-7.settings_page_bp-components tr.xprofile.active td.plugin-title span {
|
292 |
+
background-position: -305px -7px;
|
293 |
+
}
|
294 |
+
|
295 |
+
body.branch-3-6.settings_page_bp-components tr.settings td.plugin-title span,
|
296 |
+
body.branch-3-7.settings_page_bp-components tr.settings td.plugin-title span {
|
297 |
+
background-image: url('../images/menu-wp.png');
|
298 |
+
background-position: -334px -40px;
|
299 |
+
}
|
300 |
+
|
301 |
+
body.branch-3-6.settings_page_bp-components tr.settings.active td.plugin-title span,
|
302 |
+
body.branch-3-7.settings_page_bp-components tr.settings.active td.plugin-title span {
|
303 |
+
background-position: -334px -7px;
|
304 |
+
}
|
305 |
+
|
306 |
+
body.branch-3-6.settings_page_bp-components tr.groups td.plugin-title span,
|
307 |
+
body.branch-3-7.settings_page_bp-components tr.groups td.plugin-title span {
|
308 |
+
background-position: -66px -40px;
|
309 |
+
}
|
310 |
+
|
311 |
+
body.branch-3-6.settings_page_bp-components tr.groups.active td.plugin-title span,
|
312 |
+
body.branch-3-7.settings_page_bp-components tr.groups.active td.plugin-title span {
|
313 |
+
background-position: -66px -7px;
|
314 |
+
}
|
315 |
+
|
316 |
+
body.branch-3-6.settings_page_bp-components tr.messages td.plugin-title span,
|
317 |
+
body.branch-3-7.settings_page_bp-components tr.messages td.plugin-title span {
|
318 |
+
background-position: -154px -40px;
|
319 |
+
}
|
320 |
+
|
321 |
+
body.branch-3-6.settings_page_bp-components tr.messages.active td.plugin-title span,
|
322 |
+
body.branch-3-7.settings_page_bp-components tr.messages.active td.plugin-title span {
|
323 |
+
background-position: -154px -7px;
|
324 |
+
}
|
325 |
+
|
326 |
+
body.branch-3-6.settings_page_bp-components tr.forums td.plugin-title span,
|
327 |
+
body.branch-3-7.settings_page_bp-components tr.forums td.plugin-title span {
|
328 |
+
background-image: url('../images/menu-wp.png');
|
329 |
+
background-position: -36px -40px;
|
330 |
+
}
|
331 |
+
|
332 |
+
body.branch-3-6.settings_page_bp-components tr.forums.active td.plugin-title span,
|
333 |
+
body.branch-3-7.settings_page_bp-components tr.forums.active td.plugin-title span {
|
334 |
+
background-position: -36px -7px;
|
335 |
+
}
|
336 |
+
|
337 |
+
body.branch-3-6.settings_page_bp-components tr.blogs td.plugin-title span,
|
338 |
+
body.branch-3-7.settings_page_bp-components tr.blogs td.plugin-title span {
|
339 |
+
background-position: -125px -40px;
|
340 |
+
}
|
341 |
+
|
342 |
+
body.branch-3-6.settings_page_bp-components tr.blogs.active td.plugin-title span,
|
343 |
+
body.branch-3-7.settings_page_bp-components tr.blogs.active td.plugin-title span {
|
344 |
+
background-position: -125px -7px;
|
345 |
+
}
|
346 |
+
|
347 |
+
body.branch-3-6.settings_page_bp-components tr.friends td.plugin-title span,
|
348 |
+
body.branch-3-7.settings_page_bp-components tr.friends td.plugin-title span {
|
349 |
+
background-position: -95px -40px;
|
350 |
+
}
|
351 |
+
|
352 |
+
body.branch-3-6.settings_page_bp-components tr.friends.active td.plugin-title span,
|
353 |
+
body.branch-3-7.settings_page_bp-components tr.friends.active td.plugin-title span {
|
354 |
+
background-position: -95px -7px;
|
355 |
+
}
|
356 |
+
|
357 |
+
body.branch-3-6.settings_page_bp-components tr.core td.plugin-title span,
|
358 |
+
body.branch-3-7.settings_page_bp-components tr.core td.plugin-title span {
|
359 |
+
background-position: -184px -40px;
|
360 |
+
}
|
361 |
+
|
362 |
+
body.branch-3-6.settings_page_bp-components tr.core.active td.plugin-title span,
|
363 |
+
body.branch-3-7.settings_page_bp-components tr.core.active td.plugin-title span {
|
364 |
+
background-position: -184px -7px;
|
365 |
+
}
|
366 |
+
|
367 |
+
body.branch-3-6.settings_page_bp-components tr.members td.plugin-title span,
|
368 |
+
body.branch-3-7.settings_page_bp-components tr.members td.plugin-title span {
|
369 |
+
background-position: -36px -40px;
|
370 |
+
}
|
371 |
+
|
372 |
+
body.branch-3-6.settings_page_bp-components tr.members.active td.plugin-title span,
|
373 |
+
body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title span {
|
374 |
+
background-position: -36px -7px;
|
375 |
+
}
|
376 |
+
|
377 |
+
#bp-admin-component-form .widefat th {
|
378 |
+
display: table-cell;
|
379 |
+
vertical-align: top;
|
380 |
+
}
|
381 |
+
|
382 |
+
/* Version Badge */
|
383 |
+
|
384 |
+
.bp-badge {
|
385 |
+
font: normal 150px/1 'dashicons' !important;
|
386 |
+
color: #D84800;
|
387 |
+
display: inline-block;
|
388 |
+
}
|
389 |
+
|
390 |
+
.bp-badge:before {
|
391 |
+
content: "\f448";
|
392 |
+
}
|
393 |
+
|
394 |
+
.about-wrap .bp-badge {
|
395 |
+
position: absolute;
|
396 |
+
top: 0;
|
397 |
+
left: 0;
|
398 |
+
}
|
399 |
+
|
400 |
+
/* HiDPI
|
401 |
+
------------------------------------------------------------------------------*/
|
402 |
+
|
403 |
+
@media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
|
404 |
+
|
405 |
+
/* Icon 32 */
|
406 |
+
body.branch-3-6 div#icon-buddypress,
|
407 |
+
body.branch-3-6 div#icon-buddypress-activity,
|
408 |
+
body.branch-3-6 div#icon-buddypress-groups,
|
409 |
+
body.branch-3-7 div#icon-buddypress,
|
410 |
+
body.branch-3-7 div#icon-buddypress-activity,
|
411 |
+
body.branch-3-7 div#icon-buddypress-groups {
|
412 |
+
background-image: url('../images/icons64.png');
|
413 |
+
background-size: 419px 45px;
|
414 |
+
}
|
415 |
+
|
416 |
+
/* Backpat */
|
417 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,
|
418 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,
|
419 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,
|
420 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,
|
421 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,
|
422 |
+
body.branch-3-6 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image,
|
423 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-components .wp-menu-image,
|
424 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image,
|
425 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity .wp-menu-image,
|
426 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-activity_network .wp-menu-image,
|
427 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups .wp-menu-image,
|
428 |
+
body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network .wp-menu-image {
|
429 |
+
background-image: url('../images/menu-2x.png') !important;
|
430 |
+
background-size: 209px 64px;
|
431 |
+
}
|
432 |
+
}
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
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}}
|
@@ -4,6 +4,37 @@
|
|
4 |
* @since BuddyPress (1.6)
|
5 |
*/
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
/* Icon 32's
|
8 |
------------------------------------------------------------------------------*/
|
9 |
|
@@ -96,28 +127,6 @@ body.branch-3-7 ul#adminmenu li.toplevel_page_bp-groups_network.wp-has-current-s
|
|
96 |
content: "";
|
97 |
}
|
98 |
|
99 |
-
th.column-gid {
|
100 |
-
width: 60px;
|
101 |
-
}
|
102 |
-
td.column-gid {
|
103 |
-
vertical-align: middle;
|
104 |
-
}
|
105 |
-
table.bp-group-members th,
|
106 |
-
table.bp-group-members td {
|
107 |
-
padding: 5px 0;
|
108 |
-
}
|
109 |
-
table.bp-group-members .uid-column {
|
110 |
-
padding-left: 20px;
|
111 |
-
padding-right: 20px;
|
112 |
-
}
|
113 |
-
table.bp-group-members .uname-column {
|
114 |
-
width: 70%;
|
115 |
-
}
|
116 |
-
table.bp-group-members .urole-column {
|
117 |
-
padding-left: 20px;
|
118 |
-
padding-right: 20px;
|
119 |
-
}
|
120 |
-
|
121 |
/* Components
|
122 |
------------------------------------------------------------------------------*/
|
123 |
|
@@ -374,7 +383,7 @@ body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title sp
|
|
374 |
|
375 |
.bp-badge {
|
376 |
font: normal 150px/1 'dashicons' !important;
|
377 |
-
color: #
|
378 |
display: inline-block;
|
379 |
}
|
380 |
|
@@ -387,10 +396,6 @@ body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title sp
|
|
387 |
top: 0;
|
388 |
right: 0;
|
389 |
}
|
390 |
-
body.rtl .about-wrap .bp-badge {
|
391 |
-
right: auto;
|
392 |
-
left: 0;
|
393 |
-
}
|
394 |
|
395 |
/* HiDPI
|
396 |
------------------------------------------------------------------------------*/
|
@@ -424,10 +429,4 @@ body.branch-3-7.settings_page_bp-components tr.members.active td.plugin-title sp
|
|
424 |
background-image: url('../images/menu-2x.png') !important;
|
425 |
background-size: 209px 64px;
|
426 |
}
|
427 |
-
|
428 |
-
/* Badge */
|
429 |
-
.bp-badge {
|
430 |
-
background-image: url('../images/badge-2x.png');
|
431 |
-
background-size: 173px 194px;
|
432 |
-
}
|
433 |
-
}
|
4 |
* @since BuddyPress (1.6)
|
5 |
*/
|
6 |
|
7 |
+
/* User's Lists
|
8 |
+
------------------------------------------------------------------------------*/
|
9 |
+
|
10 |
+
body.site-users-php th#role,
|
11 |
+
body.users-php th#role,
|
12 |
+
body.users_page_bp-signups th#count_sent {
|
13 |
+
width: 10%;
|
14 |
+
}
|
15 |
+
|
16 |
+
body.site-users-php th#name,
|
17 |
+
body.site-users-php th#email,
|
18 |
+
body.users-php th#name,
|
19 |
+
body.users-php th#registered,
|
20 |
+
body.users-php th#email,
|
21 |
+
body.users_page_bp-signups th#name,
|
22 |
+
body.users_page_bp-signups th#registered,
|
23 |
+
body.users_page_bp-signups th#email,
|
24 |
+
body.users_page_bp-signups th#date_sent {
|
25 |
+
width: 15%;
|
26 |
+
}
|
27 |
+
|
28 |
+
body.users-php th#blogs,
|
29 |
+
body.users_page_bp-signups th#blogs {
|
30 |
+
width: 20%;
|
31 |
+
}
|
32 |
+
|
33 |
+
body.users_page_bp-signups th.column-count_sent,
|
34 |
+
body.users_page_bp-signups td.count_sent {
|
35 |
+
text-align: center;
|
36 |
+
}
|
37 |
+
|
38 |
/* Icon 32's
|
39 |
------------------------------------------------------------------------------*/
|
40 |
|
127 |
content: "";
|
128 |
}
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
/* Components
|
131 |
------------------------------------------------------------------------------*/
|
132 |
|
383 |
|
384 |
.bp-badge {
|
385 |
font: normal 150px/1 'dashicons' !important;
|
386 |
+
color: #D84800;
|
387 |
display: inline-block;
|
388 |
}
|
389 |
|
396 |
top: 0;
|
397 |
right: 0;
|
398 |
}
|
|
|
|
|
|
|
|
|
399 |
|
400 |
/* HiDPI
|
401 |
------------------------------------------------------------------------------*/
|
429 |
background-image: url('../images/menu-2x.png') !important;
|
430 |
background-size: 209px 64px;
|
431 |
}
|
432 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1 +1,2 @@
|
|
1 |
-
body.branch-3-6 div#icon-buddypress,body.branch-3-7 div#icon-buddypress{background:url('../images/icons32.png') no-repeat -370px -6px}body.branch-3-6 div#icon-buddypress-activity,body.branch-3-7 div#icon-buddypress-activity{background:url('../images/icons32.png') no-repeat -10px -6px}body.branch-3-6 div#icon-buddypress-groups,body.branch-3-7 div#icon-buddypress-groups{background:url('../images/icons32.png') no-repeat -250px -6px}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:hover .wp-menu-image,body.branch-3-6 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image,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-general-settings.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: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-general-settings.wp-has-current-submenu .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:hover .wp-menu-image,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_network: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-7 ul#adminmenu li.toplevel_page_bp-activity: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_network: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{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:hover .wp-menu-image,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_network: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-7 ul#adminmenu li.toplevel_page_bp-groups: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_network: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{background-position:-61px -2px}#adminmenu .toplevel_page_network-tools div.wp-menu-image:before{content:""}th.column-gid{width:60px}td.column-gid{vertical-align:middle}table.bp-group-members th,table.bp-group-members td{padding:5px 0}table.bp-group-members .uid-column{padding-left:20px;padding-right:20px}table.bp-group-members .uname-column{width:70%}table.bp-group-members .urole-column{padding-left:20px;padding-right:20px}#adminmenu #toplevel_page_bp-activity .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_user .wp-menu-image:before,#adminmenu #toplevel_page_bp-activity_network .wp-menu-image:before{content:"\f452"}#adminmenu #toplevel_page_bp-groups .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_user .wp-menu-image:before,#adminmenu #toplevel_page_bp-groups_network .wp-menu-image:before{content:"\f456"}#adminmenu #toplevel_page_bp-notifications .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_user .wp-menu-image:before,#adminmenu #toplevel_page_bp-notifications_network .wp-menu-image:before{content:"\f439"}#adminmenu #toplevel_page_bp-messages .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_user .wp-menu-image:before,#adminmenu #toplevel_page_bp-messages_network .wp-menu-image:before{content:"\f457"}#adminmenu #toplevel_page_bp-friends .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_user .wp-menu-image:before,#adminmenu #toplevel_page_bp-friends_network .wp-menu-image:before{content:"\f454"}#adminmenu #toplevel_page_bp-settings .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_user .wp-menu-image:before,#adminmenu #toplevel_page_bp-settings_network .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.notifications td.plugin-title span:before,body.branch-3-6.settings_page_bp-components tr.xprofile 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.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.forums 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.friends 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.notifications td.plugin-title span:before,body.branch-3-7.settings_page_bp-components tr.xprofile 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.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.forums 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.friends 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:normal 150px/1 'dashicons' !important;color:#000;display:inline-block}.bp-badge:before{content:"\f448"}.about-wrap .bp-badge{position:absolute;top:0;right:0}body.rtl .about-wrap .bp-badge{right:auto;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-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-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-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-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-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-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-badge{background-image:url('../images/badge-2x.png');background-size:173px 194px}}
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
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}}
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -66,6 +66,7 @@ add_action( 'bp_loaded', 'bp_register_theme_directory', 14 );
|
|
66 |
*/
|
67 |
add_action( 'bp_init', 'bp_core_set_uri_globals', 2 );
|
68 |
add_action( 'bp_init', 'bp_setup_globals', 4 );
|
|
|
69 |
add_action( 'bp_init', 'bp_setup_nav', 6 );
|
70 |
add_action( 'bp_init', 'bp_setup_title', 8 );
|
71 |
add_action( 'bp_init', 'bp_core_load_admin_bar_css', 12 );
|
66 |
*/
|
67 |
add_action( 'bp_init', 'bp_core_set_uri_globals', 2 );
|
68 |
add_action( 'bp_init', 'bp_setup_globals', 4 );
|
69 |
+
add_action( 'bp_init', 'bp_setup_canonical_stack', 5 );
|
70 |
add_action( 'bp_init', 'bp_setup_nav', 6 );
|
71 |
add_action( 'bp_init', 'bp_setup_title', 8 );
|
72 |
add_action( 'bp_init', 'bp_core_load_admin_bar_css', 12 );
|
@@ -334,7 +334,7 @@ class BP_Admin {
|
|
334 |
if ( bp_is_active( 'xprofile' ) ) {
|
335 |
|
336 |
// Add the main section
|
337 |
-
add_settings_section( 'bp_xprofile',
|
338 |
|
339 |
$avatar_setting = 'bp_xprofile';
|
340 |
|
@@ -396,7 +396,7 @@ class BP_Admin {
|
|
396 |
|
397 |
if ( ! empty( $avatar_setting ) ) {
|
398 |
// Allow avatar uploads
|
399 |
-
add_settings_field( 'bp-disable-avatar-uploads', __( '
|
400 |
register_setting ( 'buddypress', 'bp-disable-avatar-uploads', 'intval' );
|
401 |
}
|
402 |
}
|
@@ -431,7 +431,7 @@ class BP_Admin {
|
|
431 |
public function modify_plugin_action_links( $links, $file ) {
|
432 |
|
433 |
// Return normal links if not BuddyPress
|
434 |
-
if ( plugin_basename( buddypress()->
|
435 |
return $links;
|
436 |
|
437 |
// Add a few links to the existing links array
|
@@ -466,12 +466,16 @@ class BP_Admin {
|
|
466 |
* @since BuddyPress (1.6.0)
|
467 |
*/
|
468 |
public function enqueue_scripts() {
|
469 |
-
|
470 |
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
471 |
|
472 |
$file = $this->css_url . "common{$min}.css";
|
473 |
$file = apply_filters( 'bp_core_admin_common_css', $file );
|
474 |
wp_enqueue_style( 'bp-admin-common-css', $file, array(), bp_get_version() );
|
|
|
|
|
|
|
|
|
|
|
475 |
}
|
476 |
|
477 |
/** About *****************************************************************/
|
@@ -496,9 +500,9 @@ class BP_Admin {
|
|
496 |
<h1><?php printf( __( 'Welcome to BuddyPress %s', 'buddypress' ), $display_version ); ?></h1>
|
497 |
<div class="about-text">
|
498 |
<?php if ( $is_new_install ) : ?>
|
499 |
-
<?php printf( __( '
|
500 |
<?php else : ?>
|
501 |
-
<?php printf( __( '
|
502 |
<?php endif; ?>
|
503 |
</div>
|
504 |
|
@@ -529,7 +533,7 @@ class BP_Admin {
|
|
529 |
|
530 |
<?php else : ?>
|
531 |
<p><?php printf(
|
532 |
-
__( 'BuddyPress’
|
533 |
bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), $this->settings_page ) )
|
534 |
); ?></p>
|
535 |
|
@@ -537,95 +541,108 @@ class BP_Admin {
|
|
537 |
|
538 |
<h4><?php _e( 'Community and Support', 'buddypress' ); ?></h4>
|
539 |
<p><?php _e( 'Looking for help? The <a href="http://codex.buddypress.org/">BuddyPress Codex</a> has you covered, with dozens of user-contributed guides on how to configure and use your BP site. Can’t find what you need? Stop by <a href="http://buddypress.org/support/">our support forums</a>, where a vibrant community of BuddyPress users and developers is waiting to share tips, show off their sites, talk about the future of BuddyPress, and much more.', 'buddypress' ) ?></p>
|
|
|
540 |
</div>
|
541 |
<hr />
|
542 |
|
543 |
<?php endif; ?>
|
544 |
|
545 |
<div class="changelog">
|
546 |
-
<h2 class="about-headline-callout"><?php _e( '
|
547 |
-
<
|
548 |
-
<p
|
549 |
-
|
550 |
|
551 |
<hr />
|
552 |
|
553 |
<div class="changelog">
|
554 |
-
<h2 class="about-headline-callout"><?php _e( '
|
555 |
|
556 |
-
<div class="feature-section col
|
557 |
-
<div>
|
558 |
-
<h4><?php esc_html_e( '
|
559 |
-
<p><?php esc_html_e( '
|
560 |
-
<
|
561 |
</div>
|
562 |
|
563 |
-
<div class="
|
564 |
-
<h4><?php esc_html_e( '
|
565 |
-
<p><?php esc_html_e( '
|
566 |
-
<
|
567 |
-
</div>
|
568 |
-
</div>
|
569 |
-
|
570 |
-
<div class="feature-section col two-col">
|
571 |
-
<div>
|
572 |
-
<h4><?php esc_html_e( 'BuddyPress Repair Tools', 'buddypress' ); ?></h4>
|
573 |
-
<p><?php esc_html_e( 'Dashboard > Tools > BuddyPress contains a number of tools for correcting data that occasionally gets out of sync on BP installs.', 'buddypress' ); ?></p>
|
574 |
-
<img src="<?php echo $image_base ?>tools-buddypress.jpg" style="width:90%" />
|
575 |
</div>
|
576 |
|
577 |
-
<div class="
|
578 |
-
<h4><?php esc_html_e( '
|
579 |
-
<p><?php
|
580 |
-
<
|
581 |
</div>
|
582 |
</div>
|
583 |
-
|
584 |
</div>
|
585 |
|
586 |
<hr />
|
587 |
|
588 |
<div class="changelog">
|
589 |
-
<h2 class="about-headline-callout"><?php esc_html_e( '
|
590 |
<div class="feature-section col two-col">
|
591 |
-
<div>
|
592 |
-
<p><?php
|
593 |
-
|
594 |
-
<p
|
595 |
-
|
596 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
597 |
</div>
|
598 |
|
599 |
-
<div class="
|
600 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
601 |
</div>
|
602 |
</div>
|
603 |
</div>
|
604 |
-
|
605 |
-
<hr />
|
606 |
-
|
607 |
-
<div class="changelog">
|
608 |
-
<h2 class="about-headline-callout"><?php esc_html_e( 'Developer Tools', 'buddypress' ); ?></h2>
|
609 |
-
|
610 |
-
<p><?php esc_html_e( 'BuddyPress 2.0 is full of new and improved tools for the theme and plugin developer. A few highlights:', 'buddypress' ) ?></p>
|
611 |
-
<ul>
|
612 |
-
<li><?php _e( 'The <code>BP_XProfile_Field_Type</code> class makes it a breeze to create new xProfile field types with custom display callbacks, validation, and more.', 'buddypress' ); ?></li>
|
613 |
-
<li><?php _e( 'Major improvements have taken place with respect to object caching throughout BuddyPress. If you use Memcached, APC, or some other persistent object caching backend on your BuddyPress site, you should notice huge performance boosts.', 'buddypress' ); ?></li>
|
614 |
-
<li><?php _e( 'Our internal metadata libraries have been rewritten to use WP’s <code>add_metadata()</code>, <code>update_metadata()</code>, and so on. This means greater consistency and parity between the components when storing and retrieving BuddyPress metadata.', 'buddypress' ); ?></li>
|
615 |
-
<li><?php printf( __( '<a href="%s">…and lots more!</a>', 'buddypress' ), 'http://codex.buddypress.org/releases/version-2-0' ); ?></li>
|
616 |
-
</ul>
|
617 |
-
</div>
|
618 |
-
|
619 |
-
<hr />
|
620 |
-
|
621 |
-
<?php if ( current_user_can( $this->capability ) ) :?>
|
622 |
-
<div class="return-to-dashboard">
|
623 |
-
<a href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), $this->settings_page ) ) ); ?>"><?php _e( 'Go to the BuddyPress Settings page', 'buddypress' ); ?></a>
|
624 |
-
</div>
|
625 |
-
<?php endif ;?>
|
626 |
-
|
627 |
-
</div>
|
628 |
-
|
629 |
<?php
|
630 |
}
|
631 |
|
@@ -647,18 +664,18 @@ class BP_Admin {
|
|
647 |
<h1><?php printf( __( 'Welcome to BuddyPress %s', 'buddypress' ), $display_version ); ?></h1>
|
648 |
<div class="about-text">
|
649 |
<?php if ( $is_new_install ) : ?>
|
650 |
-
<?php printf( __( '
|
651 |
<?php else : ?>
|
652 |
-
<?php printf( __( '
|
653 |
<?php endif; ?>
|
654 |
</div>
|
655 |
|
656 |
<div class="bp-badge"></div>
|
657 |
|
658 |
<h2 class="nav-tab-wrapper">
|
659 |
-
<a href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-about' ), 'index.php' ) ) ); ?>"
|
660 |
<?php _e( 'What’s New', 'buddypress' ); ?>
|
661 |
-
</a><a href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-credits' ), 'index.php' ) ) ); ?>"
|
662 |
<?php _e( 'Credits', 'buddypress' ); ?>
|
663 |
</a>
|
664 |
</h2>
|
@@ -715,50 +732,55 @@ class BP_Admin {
|
|
715 |
</li>
|
716 |
</ul>
|
717 |
|
718 |
-
<h4 class="wp-people-group"><?php
|
719 |
<p class="wp-credits-list">
|
720 |
-
<a href="https://profiles.wordpress.org/
|
721 |
-
<a href="https://profiles.wordpress.org/
|
722 |
-
<a href="https://profiles.wordpress.org/
|
723 |
-
<a href="https://profiles.wordpress.org/
|
724 |
-
<a href="https://profiles.wordpress.org/
|
|
|
|
|
|
|
|
|
725 |
<a href="https://profiles.wordpress.org/danbp/">danbp</a>,
|
726 |
-
<a href="https://profiles.wordpress.org/dcavins/">dcavins</a>,
|
727 |
-
<a href="https://profiles.wordpress.org/
|
728 |
-
<a href="https://profiles.wordpress.org/
|
729 |
-
<a href="https://profiles.wordpress.org/
|
730 |
-
<a href="https://profiles.wordpress.org/
|
731 |
-
<a href="https://profiles.wordpress.org/
|
732 |
-
<a href="https://profiles.wordpress.org/
|
733 |
-
<a href="https://profiles.wordpress.org/
|
734 |
-
<a href="https://profiles.wordpress.org/
|
735 |
-
<a href="https://profiles.wordpress.org/
|
736 |
-
<a href="https://profiles.wordpress.org/johnjamesjacoby/">johnjamesjacoby</a>,
|
737 |
-
<a href="https://profiles.wordpress.org/karmatosed/">karmatosed</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/
|
741 |
-
<a href="https://profiles.wordpress.org/
|
742 |
-
<a href="https://profiles.wordpress.org/modemlooper/">modemlooper</a>,
|
743 |
-
<a href="https://profiles.wordpress.org/mpa4hu/">mpa4hu</a>,
|
744 |
<a href="https://profiles.wordpress.org/needle/">needle</a>,
|
745 |
-
<a href="https://profiles.wordpress.org/
|
746 |
-
<a href="https://profiles.wordpress.org/
|
747 |
-
Pietro Oliva,
|
748 |
-
<a href="https://profiles.wordpress.org/pross/">pross</a>,
|
749 |
<a href="https://profiles.wordpress.org/r-a-y/">r-a-y</a>,
|
750 |
-
<a href="https://profiles.wordpress.org/
|
751 |
-
<a href="https://profiles.wordpress.org/
|
752 |
-
<a href="https://profiles.wordpress.org/rogercoathup/">rogercoathup</a>,
|
753 |
-
<a href="https://profiles.wordpress.org/rzen/">rzen</a>,
|
754 |
-
<a href="https://profiles.wordpress.org/SergeyBiryukov/">SergeyBiryukov</a>,
|
755 |
<a href="https://profiles.wordpress.org/shanebp/">shanebp</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/
|
760 |
-
<a href="https://profiles.wordpress.org/
|
761 |
-
<a href="https://profiles.wordpress.org/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
762 |
</p>
|
763 |
|
764 |
<?php if ( current_user_can( $this->capability ) ) :?>
|
@@ -782,5 +804,35 @@ endif; // class_exists check
|
|
782 |
* @uses BP_Admin
|
783 |
*/
|
784 |
function bp_admin() {
|
785 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
786 |
}
|
334 |
if ( bp_is_active( 'xprofile' ) ) {
|
335 |
|
336 |
// Add the main section
|
337 |
+
add_settings_section( 'bp_xprofile', _x( 'Profile Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress' );
|
338 |
|
339 |
$avatar_setting = 'bp_xprofile';
|
340 |
|
396 |
|
397 |
if ( ! empty( $avatar_setting ) ) {
|
398 |
// Allow avatar uploads
|
399 |
+
add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', $avatar_setting );
|
400 |
register_setting ( 'buddypress', 'bp-disable-avatar-uploads', 'intval' );
|
401 |
}
|
402 |
}
|
431 |
public function modify_plugin_action_links( $links, $file ) {
|
432 |
|
433 |
// Return normal links if not BuddyPress
|
434 |
+
if ( plugin_basename( buddypress()->basename ) != $file )
|
435 |
return $links;
|
436 |
|
437 |
// Add a few links to the existing links array
|
466 |
* @since BuddyPress (1.6.0)
|
467 |
*/
|
468 |
public function enqueue_scripts() {
|
|
|
469 |
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
470 |
|
471 |
$file = $this->css_url . "common{$min}.css";
|
472 |
$file = apply_filters( 'bp_core_admin_common_css', $file );
|
473 |
wp_enqueue_style( 'bp-admin-common-css', $file, array(), bp_get_version() );
|
474 |
+
|
475 |
+
wp_style_add_data( 'bp-admin-common-css', 'rtl', true );
|
476 |
+
if ( $min ) {
|
477 |
+
wp_style_add_data( 'bp-admin-common-css', 'suffix', $min );
|
478 |
+
}
|
479 |
}
|
480 |
|
481 |
/** About *****************************************************************/
|
500 |
<h1><?php printf( __( 'Welcome to BuddyPress %s', 'buddypress' ), $display_version ); ?></h1>
|
501 |
<div class="about-text">
|
502 |
<?php if ( $is_new_install ) : ?>
|
503 |
+
<?php printf( __( 'Thank you for installing BuddyPress! BuddyPress %s is our most streamlined and easy-to-use release to date, and we think you’re going to love it.', 'buddypress' ), $display_version ); ?>
|
504 |
<?php else : ?>
|
505 |
+
<?php printf( __( 'Howdy. BuddyPress %s is our most streamlined and easy-to-use release to date, and we think you’re going to love it.', 'buddypress' ), $display_version ); ?>
|
506 |
<?php endif; ?>
|
507 |
</div>
|
508 |
|
533 |
|
534 |
<?php else : ?>
|
535 |
<p><?php printf(
|
536 |
+
__( 'BuddyPress’ powerful features help your users connect and collaborate. Want to explore BP’s features? Visit the <a href="%s">Components panel</a>.', 'buddypress' ),
|
537 |
bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), $this->settings_page ) )
|
538 |
); ?></p>
|
539 |
|
541 |
|
542 |
<h4><?php _e( 'Community and Support', 'buddypress' ); ?></h4>
|
543 |
<p><?php _e( 'Looking for help? The <a href="http://codex.buddypress.org/">BuddyPress Codex</a> has you covered, with dozens of user-contributed guides on how to configure and use your BP site. Can’t find what you need? Stop by <a href="http://buddypress.org/support/">our support forums</a>, where a vibrant community of BuddyPress users and developers is waiting to share tips, show off their sites, talk about the future of BuddyPress, and much more.', 'buddypress' ) ?></p>
|
544 |
+
<p><?php _e( 'Read on to learn more about this version of BuddyPress.', 'buddypress' ); ?></p>
|
545 |
</div>
|
546 |
<hr />
|
547 |
|
548 |
<?php endif; ?>
|
549 |
|
550 |
<div class="changelog">
|
551 |
+
<h2 class="about-headline-callout"><?php _e( 'Revamped @mentions Interface', 'buddypress' ); ?></h2>
|
552 |
+
<p><?php _e( 'Forget the old days of trying to remember someone’s username when you want to @mention them in a conversation! With BuddyPress 2.1, type a <code>@</code> when leaving a status update or commenting on an activity item or blog post, and the new suggestions panel will open.', 'buddypress' ) ?></p>
|
553 |
+
<p>TODO: add GIF.</p>
|
554 |
+
</div>
|
555 |
|
556 |
<hr />
|
557 |
|
558 |
<div class="changelog">
|
559 |
+
<h2 class="about-headline-callout"><?php _e( 'Continuous Improvement', 'buddypress' ); ?></h2>
|
560 |
|
561 |
+
<div class="feature-section col three-col">
|
562 |
+
<div class="col-1">
|
563 |
+
<h4><?php esc_html_e( 'New Profile Field Type: URL', 'buddypress' ); ?></h4>
|
564 |
+
<p><?php esc_html_e( 'Built to hold the address of another website, this new field type automatically creates a link to that site.', 'buddypress' ); ?></p>
|
565 |
+
<p>TODO: image.</p>
|
566 |
</div>
|
567 |
|
568 |
+
<div class="col-2">
|
569 |
+
<h4><?php esc_html_e( 'Awesome Translations', 'buddypress' ); ?></h4>
|
570 |
+
<p><?php esc_html_e( 'BuddyPress supports high-quality translations that are automatically fetched by WordPress. Many thanks to our translation volunteers for making this possible.', 'buddypress' ); ?></p>
|
571 |
+
<p>TODO: image.</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
572 |
</div>
|
573 |
|
574 |
+
<div class="col-3 last-feature">
|
575 |
+
<h4><?php esc_html_e( 'Performance Improvements', 'buddypress' ); ?></h4>
|
576 |
+
<p><?php _e( 'Like we do with every release, we’ve made further optimizations to increase BuddyPress’ performance and reduce its query overhead.', 'buddypress' ); ?></p>
|
577 |
+
<p>TODO: image.</p>
|
578 |
</div>
|
579 |
</div>
|
|
|
580 |
</div>
|
581 |
|
582 |
<hr />
|
583 |
|
584 |
<div class="changelog">
|
585 |
+
<h2 class="about-headline-callout"><?php esc_html_e( 'Enhancements for Plugin & Theme Developers', 'buddypress' ); ?></h2>
|
586 |
<div class="feature-section col two-col">
|
587 |
+
<div class="col-1">
|
588 |
+
<p><?php _e( 'If you’re a plugin developer, or make custom themes, or want to contribute back to the BuddyPress project, here’s what you should know about this release:', 'buddypress' ); ?></p>
|
589 |
+
<p><?php _e( 'If you’ve used BuddyPress for a very long time, you might remember the <em>BuddyBar</em>; it was our toolbar before WordPress had its own toolbar. We started to deprecate it in BuddyPress 1.6. It is now formally deprecated, which means you should not use it for new sites.', 'buddypress' ); ?></p>
|
590 |
+
<p>
|
591 |
+
<?php printf(
|
592 |
+
__( 'The classic <a href="%s">BP Default theme has moved to Github</a>. We moved it because BuddyPress development is now focused on our <a href="%s">theme compatibility</a> templates, which were introduced in BuddyPress 1.7. Don’t worry, BP-Default is still bundled with BuddyPress releases.', 'buddypress' ),
|
593 |
+
esc_url( 'https://github.com/buddypress/BP-Default' ),
|
594 |
+
esc_url( 'http://codex.buddypress.org/themes/theme-compatibility-1-7/a-quick-look-at-1-7-theme-compatibility/' )
|
595 |
+
); ?>
|
596 |
+
</p>
|
597 |
+
<p>
|
598 |
+
<?php
|
599 |
+
/* translators: don't translate the insides of the <code> block */
|
600 |
+
_e( 'In BuddyPress 2.0, we added a new <code>BP_XProfile_Field_Type</code> API for managing profile field types. In this release, we’ve added a new <code>bp_core_get_suggestions</code> API which powers our new @mentions interface. Both are cool, and are worth checking out.', 'buddypress' );
|
601 |
+
?>
|
602 |
+
</p>
|
603 |
</div>
|
604 |
|
605 |
+
<div class="col-2 last-feature">
|
606 |
+
<p><?php esc_html_e( 'Other interesting changes:', 'buddypress' ); ?>
|
607 |
+
|
608 |
+
<ul>
|
609 |
+
<li>
|
610 |
+
<?php
|
611 |
+
/* translators: don't translate the insides of the <code> block */
|
612 |
+
_e( 'In <code>BP_Group_Extension</code>, the <code>visibility</code> and <code>enable_nav_item</code> properties have been phased out in favor of new <code>access</code> and <code>show_tab</code> parameters.', 'buddypress' );
|
613 |
+
?>
|
614 |
+
</li>
|
615 |
+
<li>
|
616 |
+
<?php
|
617 |
+
/* translators: don't translate the insides of the <code> block */
|
618 |
+
_e( 'A new <code>group_activity</code> sort order has been added for Groups queries, to let you query for recently active members.', 'buddypress' );
|
619 |
+
?>
|
620 |
+
</li>
|
621 |
+
<li>
|
622 |
+
<?php
|
623 |
+
/* translators: don't translate the insides of the <code> block */
|
624 |
+
_e( 'Extra CSS classes have been added to Profile Field visibility field elements, allowing greater CSS customization.', 'buddypress' );
|
625 |
+
?>
|
626 |
+
</li>
|
627 |
+
<li>
|
628 |
+
<?php
|
629 |
+
/* translators: don't translate the insides of the <code> block */
|
630 |
+
_e( 'A <code>no_access_url</code> parameter has been added to <code>bp_core_new_subnav_item()</code>. This allows you to set the URL that users are redirected to when they do not have permission to access a sub-navigation item.', 'buddypress' );
|
631 |
+
?>
|
632 |
+
</li>
|
633 |
+
<li>
|
634 |
+
<?php
|
635 |
+
/* translators: don't translate the insides of the <code> block */
|
636 |
+
_e( 'When making searches with <code>BP_User_Query</code>, a new <code>search_wildcard</code> parameter gives you finer control over how the search SQL is constructed.', 'buddypress' );
|
637 |
+
?>
|
638 |
+
</li>
|
639 |
+
|
640 |
+
|
641 |
+
<li><?php printf( __( '<a href="%s">…and lots more!</a>', 'buddypress' ), 'https://codex.buddypress.org/releases/version-2-1' ); ?></li>
|
642 |
+
</ul>
|
643 |
</div>
|
644 |
</div>
|
645 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
646 |
<?php
|
647 |
}
|
648 |
|
664 |
<h1><?php printf( __( 'Welcome to BuddyPress %s', 'buddypress' ), $display_version ); ?></h1>
|
665 |
<div class="about-text">
|
666 |
<?php if ( $is_new_install ) : ?>
|
667 |
+
<?php printf( __( 'Thank you for installing BuddyPress! BuddyPress %s is our most streamlined and easy-to-use release to date, and we think you’re going to love it.', 'buddypress' ), $display_version ); ?>
|
668 |
<?php else : ?>
|
669 |
+
<?php printf( __( 'Howdy. BuddyPress %s is our most streamlined and easy-to-use release to date, and we think you’re going to love it.', 'buddypress' ), $display_version ); ?>
|
670 |
<?php endif; ?>
|
671 |
</div>
|
672 |
|
673 |
<div class="bp-badge"></div>
|
674 |
|
675 |
<h2 class="nav-tab-wrapper">
|
676 |
+
<a class="nav-tab" href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-about' ), 'index.php' ) ) ); ?>">
|
677 |
<?php _e( 'What’s New', 'buddypress' ); ?>
|
678 |
+
</a><a class="nav-tab nav-tab-active" href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-credits' ), 'index.php' ) ) ); ?>">
|
679 |
<?php _e( 'Credits', 'buddypress' ); ?>
|
680 |
</a>
|
681 |
</h2>
|
732 |
</li>
|
733 |
</ul>
|
734 |
|
735 |
+
<h4 class="wp-people-group"><?php printf( __( 'Contributors to BuddyPress %s', 'buddypress' ), $display_version ); ?></h4>
|
736 |
<p class="wp-credits-list">
|
737 |
+
<a href="https://profiles.wordpress.org/adamt19/">adamt19</a>,
|
738 |
+
<a href="https://profiles.wordpress.org/Viper007Bond/">Alex Mills (Viper007Bond)</a>,
|
739 |
+
<a href="https://profiles.wordpress.org/allendav/">allendav</a>,
|
740 |
+
<a href="https://profiles.wordpress.org/alternatekev/">alternatekev</a>,
|
741 |
+
<a href="https://profiles.wordpress.org/automattic/">Automattic</a>,
|
742 |
+
<a href="https://profiles.wordpress.org/beaulebens/">Beau Lebens (beaulebens)</a>,
|
743 |
+
<a href="https://profiles.wordpress.org/boonebgorges/">Boone B Gorges (boonebgorges)</a>,
|
744 |
+
<a href="https://profiles.wordpress.org/williamsba1/">Brad Williams (williamsba1)</a>,
|
745 |
+
<a href="https://profiles.wordpress.org/sbrajesh/">Brajesh Singh (sbrajesh)</a>,
|
746 |
<a href="https://profiles.wordpress.org/danbp/">danbp</a>,
|
747 |
+
<a href="https://profiles.wordpress.org/dcavins/">David Cavins (dcavins)</a>,
|
748 |
+
<a href="https://profiles.wordpress.org/ebellempire/">Erin B. (ebellempire)</a>,
|
749 |
+
<a href="https://profiles.wordpress.org/esroyo/">esroyo</a>,
|
750 |
+
<a href="https://profiles.wordpress.org/godavid33">godavid33</a>
|
751 |
+
<a href="https://profiles.wordpress.org/hnla/">Hugo (hnla)</a>,
|
752 |
+
<a href="https://profiles.wordpress.org/imath/">Mathieu Viet (imath)</a>,
|
753 |
+
<a href="https://profiles.wordpress.org/johnjamesjacoby/">John James Jacoby (johnjamesjacoby)</a>,
|
754 |
+
<a href="https://profiles.wordpress.org/jconti/">Jose Conti (jconti)</a>,
|
755 |
+
<a href="https://profiles.wordpress.org/jreeve/">jreeve</a>,
|
756 |
+
<a href="https://profiles.wordpress.org/Offereins">Laurens Offereins (Offereins)</a>
|
|
|
|
|
757 |
<a href="https://profiles.wordpress.org/lenasterg/">lenasterg</a>,
|
758 |
+
<a href="https://profiles.wordpress.org/mercime/">mercime</a>,
|
759 |
+
<a href="https://profiles.wordpress.org/tw2113/">Michael Beckwith (tw2113)</a>,
|
760 |
+
<a href="https://profiles.wordpress.org/milesstewart88/">Miles Stewart (milesstewart88)</a>,
|
|
|
|
|
761 |
<a href="https://profiles.wordpress.org/needle/">needle</a>,
|
762 |
+
<a href="https://profiles.wordpress.org/sooskriszta/">OC2PS (sooskriszta)</a>,
|
763 |
+
<a href="https://profiles.wordpress.org/DJPaul/">Paul Gibbs (DJPaul)</a>,
|
|
|
|
|
764 |
<a href="https://profiles.wordpress.org/r-a-y/">r-a-y</a>,
|
765 |
+
<a href="https://profiles.wordpress.org/rogercoathup/">Roger Coathup (rogercoathup)</a>,
|
766 |
+
<a href="https://profiles.wordpress.org/SGr33n/">Sergio De Falco (SGr33n)</a>,
|
|
|
|
|
|
|
767 |
<a href="https://profiles.wordpress.org/shanebp/">shanebp</a>,
|
768 |
+
<a href="https://profiles.wordpress.org/slaFFik/">Slava UA (slaFFik)</a>,
|
769 |
+
<a href="https://profiles.wordpress.org/netweb/">Stephen Edgar (netweb)</a>,
|
770 |
+
<a href="https://profiles.wordpress.org/karmatosed/">Tammie (karmatosed)</a>,
|
771 |
+
<a href="https://profiles.wordpress.org/tomdxw/">tomdxw</a>,
|
772 |
+
<a href="https://profiles.wordpress.org/treyhunner/">treyhunner</a>,
|
773 |
+
<a href="https://profiles.wordpress.org/wbajzek/">wbajzek</a>,
|
774 |
+
<a href="https://profiles.wordpress.org/WCUADD/">WCUADD</a>,
|
775 |
+
<a href="https://profiles.wordpress.org/wpdennis/">wpdennis</a>,
|
776 |
+
<a href="https://profiles.wordpress.org/wolfhoundjesse/">wolfhoundjesse</a>.
|
777 |
+
</p>
|
778 |
+
|
779 |
+
<h4 class="wp-people-group"><?php _e( 'External Libraries', 'buddypress' ); ?></h4>
|
780 |
+
<p class="wp-credits-list">
|
781 |
+
<a href="https://github.com/ichord/At.js">At.js</a>,
|
782 |
+
<a href="https://github.com/ichord/Caret.js">Caret.js</a>,
|
783 |
+
<a href="https://github.com/carhartl/jquery-cookie">jquery.cookie</a>.
|
784 |
</p>
|
785 |
|
786 |
<?php if ( current_user_can( $this->capability ) ) :?>
|
804 |
* @uses BP_Admin
|
805 |
*/
|
806 |
function bp_admin() {
|
807 |
+
buddypress()->admin = new BP_Admin();
|
808 |
+
return;
|
809 |
+
|
810 |
+
|
811 |
+
// These are strings we may use to describe maintenance/security releases, where we aim for no new strings.
|
812 |
+
|
813 |
+
_n_noop( 'Maintenance Release', 'Maintenance Releases', 'buddypress' );
|
814 |
+
_n_noop( 'Security Release', 'Security Releases', 'buddypress' );
|
815 |
+
_n_noop( 'Maintenance and Security Release', 'Maintenance and Security Releases', 'buddypress' );
|
816 |
+
|
817 |
+
/* translators: 1: WordPress version number. */
|
818 |
+
_n_noop( '<strong>Version %1$s</strong> addressed a security issue.',
|
819 |
+
'<strong>Version %1$s</strong> addressed some security issues.',
|
820 |
+
'buddypress' );
|
821 |
+
|
822 |
+
/* translators: 1: WordPress version number, 2: plural number of bugs. */
|
823 |
+
_n_noop( '<strong>Version %1$s</strong> addressed %2$s bug.',
|
824 |
+
'<strong>Version %1$s</strong> addressed %2$s bugs.',
|
825 |
+
'buddypress' );
|
826 |
+
|
827 |
+
/* translators: 1: WordPress version number, 2: plural number of bugs. Singular security issue. */
|
828 |
+
_n_noop( '<strong>Version %1$s</strong> addressed a security issue and fixed %2$s bug.',
|
829 |
+
'<strong>Version %1$s</strong> addressed a security issue and fixed %2$s bugs.',
|
830 |
+
'buddypress' );
|
831 |
+
|
832 |
+
/* translators: 1: WordPress version number, 2: plural number of bugs. More than one security issue. */
|
833 |
+
_n_noop( '<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bug.',
|
834 |
+
'<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bugs.',
|
835 |
+
'buddypress' );
|
836 |
+
|
837 |
+
__( 'For more information, see <a href="%s">the release notes</a>.', 'buddypress' );
|
838 |
}
|
@@ -70,6 +70,7 @@ function bp_core_load_admin_bar() {
|
|
70 |
|
71 |
// Hide the WordPress Toolbar and show the BuddyBar
|
72 |
if ( ! bp_use_wp_admin_bar() ) {
|
|
|
73 |
|
74 |
// Keep the WP Toolbar from loading
|
75 |
show_admin_bar( false );
|
@@ -89,23 +90,35 @@ function bp_core_load_admin_bar() {
|
|
89 |
add_action( 'init', 'bp_core_load_admin_bar', 9 );
|
90 |
|
91 |
/**
|
92 |
-
* Handle the
|
|
|
|
|
|
|
|
|
93 |
*
|
94 |
* @since BuddyPress (1.5.0)
|
95 |
*/
|
96 |
function bp_core_load_admin_bar_css() {
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
return;
|
101 |
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
-
//
|
105 |
-
|
|
|
|
|
|
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
$wp_styles->add_data( 'bp-admin-bar', 'suffix', $min );
|
111 |
-
}
|
70 |
|
71 |
// Hide the WordPress Toolbar and show the BuddyBar
|
72 |
if ( ! bp_use_wp_admin_bar() ) {
|
73 |
+
_doing_it_wrong( __FUNCTION__, __( 'The BuddyBar is no longer supported. Please migrate to the WordPress toolbar as soon as possible.', 'buddypress' ), '2.1.0' );
|
74 |
|
75 |
// Keep the WP Toolbar from loading
|
76 |
show_admin_bar( false );
|
90 |
add_action( 'init', 'bp_core_load_admin_bar', 9 );
|
91 |
|
92 |
/**
|
93 |
+
* Handle the enqueuing of toolbar CSS.
|
94 |
+
*
|
95 |
+
* This function exists mostly for backwards compatibility reasons, so anyone
|
96 |
+
* previously unhooking this function can continue to do so. It's hooked to
|
97 |
+
* the `bp_init` action in `bp-core-actions.php`.
|
98 |
*
|
99 |
* @since BuddyPress (1.5.0)
|
100 |
*/
|
101 |
function bp_core_load_admin_bar_css() {
|
102 |
+
add_action( 'bp_enqueue_scripts', 'bp_core_enqueue_admin_bar_css', 1 );
|
103 |
+
add_action( 'bp_admin_enqueue_scripts', 'bp_core_enqueue_admin_bar_css', 1 );
|
104 |
+
}
|
|
|
105 |
|
106 |
+
/**
|
107 |
+
* Enqueue supplemental WordPress Toolbar styling
|
108 |
+
*
|
109 |
+
* @since BuddyPress (2.1.0)
|
110 |
+
*
|
111 |
+
* @see bp_core_register_common_styles()
|
112 |
+
* @see bp_core_load_admin_bar_css()
|
113 |
+
*/
|
114 |
+
function bp_core_enqueue_admin_bar_css() {
|
115 |
|
116 |
+
// Bail if not using WordPress's admin bar or it's not showing on this
|
117 |
+
// page request.
|
118 |
+
if ( ! bp_use_wp_admin_bar() || ! is_admin_bar_showing() ) {
|
119 |
+
return;
|
120 |
+
}
|
121 |
|
122 |
+
// Enqueue the additional adminbar css
|
123 |
+
wp_enqueue_style( 'bp-admin-bar' );
|
124 |
+
}
|
|
|
|
@@ -300,7 +300,7 @@ function bp_core_fetch_avatar( $args = '' ) {
|
|
300 |
|
301 |
// Get a fallback for the 'alt' parameter
|
302 |
if ( empty( $alt ) )
|
303 |
-
$alt = __( '
|
304 |
|
305 |
$html_alt = ' alt="' . esc_attr( $alt ) . '"';
|
306 |
|
@@ -670,6 +670,15 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
|
|
670 |
return false;
|
671 |
}
|
672 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
673 |
// Set the url value for the image
|
674 |
$bp->avatar_admin->image->url = bp_core_avatar_url() . $bp->avatar_admin->image->dir;
|
675 |
|
@@ -822,7 +831,11 @@ function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt = ''
|
|
822 |
|
823 |
// If passed an object, assume $user->user_id
|
824 |
if ( is_object( $user ) ) {
|
825 |
-
|
|
|
|
|
|
|
|
|
826 |
|
827 |
// If passed a number, assume it was a $user_id
|
828 |
} else if ( is_numeric( $user ) ) {
|
@@ -840,7 +853,7 @@ function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt = ''
|
|
840 |
|
841 |
// Image alt tag
|
842 |
if ( empty( $alt ) ) {
|
843 |
-
$alt = sprintf( __( '
|
844 |
}
|
845 |
|
846 |
// Use the 'thumb' type, unless the requested width is bigger than
|
300 |
|
301 |
// Get a fallback for the 'alt' parameter
|
302 |
if ( empty( $alt ) )
|
303 |
+
$alt = __( 'Profile Photo', 'buddypress' );
|
304 |
|
305 |
$html_alt = ' alt="' . esc_attr( $alt ) . '"';
|
306 |
|
670 |
return false;
|
671 |
}
|
672 |
|
673 |
+
// If the uploaded image is smaller than the "full" dimensions, throw
|
674 |
+
// a warning
|
675 |
+
$uploaded_image = @getimagesize( bp_core_avatar_upload_path() . buddypress()->avatar_admin->image->dir );
|
676 |
+
$full_width = bp_core_avatar_full_width();
|
677 |
+
$full_height = bp_core_avatar_full_height();
|
678 |
+
if ( isset( $uploaded_image[0] ) && $uploaded_image[0] < $full_width || $uploaded_image[1] < $full_height ) {
|
679 |
+
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' ), $full_width, $full_height ), 'error' );
|
680 |
+
}
|
681 |
+
|
682 |
// Set the url value for the image
|
683 |
$bp->avatar_admin->image->url = bp_core_avatar_url() . $bp->avatar_admin->image->dir;
|
684 |
|
831 |
|
832 |
// If passed an object, assume $user->user_id
|
833 |
if ( is_object( $user ) ) {
|
834 |
+
if ( isset( $user->user_id ) ) {
|
835 |
+
$id = $user->user_id;
|
836 |
+
} else {
|
837 |
+
$id = $user->ID;
|
838 |
+
}
|
839 |
|
840 |
// If passed a number, assume it was a $user_id
|
841 |
} else if ( is_numeric( $user ) ) {
|
853 |
|
854 |
// Image alt tag
|
855 |
if ( empty( $alt ) ) {
|
856 |
+
$alt = sprintf( __( 'Profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $id ) );
|
857 |
}
|
858 |
|
859 |
// Use the 'thumb' type, unless the requested width is bigger than
|
@@ -259,20 +259,20 @@ add_action( 'admin_head', 'bp_core_sort_nav_items' );
|
|
259 |
function bp_core_new_subnav_item( $args = '' ) {
|
260 |
global $bp;
|
261 |
|
262 |
-
$
|
263 |
'name' => false, // Display name for the nav item
|
264 |
'slug' => false, // URL slug for the nav item
|
265 |
'parent_slug' => false, // URL slug of the parent nav item
|
266 |
'parent_url' => false, // URL of the parent item
|
267 |
'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item
|
268 |
'user_has_access' => true, // Can the logged in user see this nav item?
|
|
|
269 |
'site_admin_only' => false, // Can only site admins see this nav item?
|
270 |
'position' => 90, // Index of where this nav item should be positioned
|
271 |
'screen_function' => false, // The name of the function to run when clicked
|
272 |
'link' => '' // The link for the subnav item; optional, not usually required.
|
273 |
-
);
|
274 |
|
275 |
-
$r = wp_parse_args( $args, $defaults );
|
276 |
extract( $r, EXTR_SKIP );
|
277 |
|
278 |
// If we don't have the required info we need, don't create this subnav item
|
@@ -296,15 +296,17 @@ function bp_core_new_subnav_item( $args = '' ) {
|
|
296 |
if ( empty( $item_css_id ) )
|
297 |
$item_css_id = $slug;
|
298 |
|
299 |
-
$
|
300 |
'name' => $name,
|
301 |
'link' => trailingslashit( $link ),
|
302 |
'slug' => $slug,
|
303 |
'css_id' => $item_css_id,
|
304 |
'position' => $position,
|
305 |
'user_has_access' => $user_has_access,
|
|
|
306 |
'screen_function' => &$screen_function
|
307 |
);
|
|
|
308 |
|
309 |
/**
|
310 |
* The last step is to hook the screen function for the added subnav item. But this only
|
@@ -330,46 +332,104 @@ function bp_core_new_subnav_item( $args = '' ) {
|
|
330 |
// If we *do* meet condition (2), then the added subnav item is currently being requested
|
331 |
if ( ( bp_current_action() && bp_is_current_action( $slug ) ) || ( bp_is_user() && ! bp_current_action() && ( $screen_function == $bp->bp_nav[$parent_slug]['screen_function'] ) ) ) {
|
332 |
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
|
341 |
-
|
342 |
-
// differently depending on whether the current user is logged in
|
343 |
-
if ( is_user_logged_in() ) {
|
344 |
-
if ( !bp_is_my_profile() && empty( $bp->bp_nav[$bp->default_component]['show_for_displayed_user'] ) ) {
|
345 |
|
346 |
-
|
347 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
if ( bp_is_active( 'activity' ) && isset( $bp->pages->activity ) ) {
|
349 |
$redirect_to = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() );
|
|
|
350 |
} else {
|
351 |
$redirect_to = trailingslashit( bp_displayed_user_domain() . ( 'xprofile' == $bp->profile->id ? 'profile' : $bp->profile->id ) );
|
352 |
}
|
353 |
|
354 |
$message = '';
|
355 |
-
} else {
|
356 |
-
$message = __( 'You do not have access to this page.', 'buddypress' );
|
357 |
-
$redirect_to = bp_displayed_user_domain();
|
358 |
}
|
359 |
|
360 |
-
|
361 |
-
bp_core_no_access( array(
|
362 |
-
'message' => $message,
|
363 |
-
'root' => $redirect_to,
|
364 |
-
'redirect' => false
|
365 |
-
) );
|
366 |
-
|
367 |
-
// Not logged in. Allow the user to log in, and attempt to redirect
|
368 |
} else {
|
369 |
-
|
|
|
370 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
}
|
372 |
}
|
|
|
|
|
373 |
}
|
374 |
|
375 |
/**
|
@@ -496,175 +556,6 @@ function bp_core_reset_subnav_items( $parent_slug ) {
|
|
496 |
unset( $bp->bp_options_nav[$parent_slug] );
|
497 |
}
|
498 |
|
499 |
-
/** BuddyBar Template functions ***********************************************/
|
500 |
-
|
501 |
-
/**
|
502 |
-
* Wrapper function for rendering the BuddyBar.
|
503 |
-
*
|
504 |
-
* @return bool|null Returns false if the BuddyBar is disabled.
|
505 |
-
*/
|
506 |
-
function bp_core_admin_bar() {
|
507 |
-
global $bp;
|
508 |
-
|
509 |
-
if ( defined( 'BP_DISABLE_ADMIN_BAR' ) && BP_DISABLE_ADMIN_BAR )
|
510 |
-
return false;
|
511 |
-
|
512 |
-
if ( (int) bp_get_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
|
513 |
-
return false;
|
514 |
-
|
515 |
-
$bp->doing_admin_bar = true;
|
516 |
-
|
517 |
-
echo '<div id="wp-admin-bar"><div class="padder">';
|
518 |
-
|
519 |
-
// **** Do bp-adminbar-logo Actions ********
|
520 |
-
do_action( 'bp_adminbar_logo' );
|
521 |
-
|
522 |
-
echo '<ul class="main-nav">';
|
523 |
-
|
524 |
-
// **** Do bp-adminbar-menus Actions ********
|
525 |
-
do_action( 'bp_adminbar_menus' );
|
526 |
-
|
527 |
-
echo '</ul>';
|
528 |
-
echo "</div></div><!-- #wp-admin-bar -->\n\n";
|
529 |
-
|
530 |
-
$bp->doing_admin_bar = false;
|
531 |
-
}
|
532 |
-
|
533 |
-
/**
|
534 |
-
* Output the BuddyBar logo.
|
535 |
-
*/
|
536 |
-
function bp_adminbar_logo() {
|
537 |
-
echo '<a href="' . bp_get_root_domain() . '" id="admin-bar-logo">' . get_blog_option( bp_get_root_blog_id(), 'blogname' ) . '</a>';
|
538 |
-
}
|
539 |
-
|
540 |
-
/**
|
541 |
-
* Output the "Log In" and "Sign Up" names to the BuddyBar.
|
542 |
-
*
|
543 |
-
* Visible only to visitors who are not logged in.
|
544 |
-
*
|
545 |
-
* @return bool|null Returns false if the current user is logged in.
|
546 |
-
*/
|
547 |
-
function bp_adminbar_login_menu() {
|
548 |
-
|
549 |
-
if ( is_user_logged_in() )
|
550 |
-
return false;
|
551 |
-
|
552 |
-
echo '<li class="bp-login no-arrow"><a href="' . wp_login_url() . '">' . __( 'Log In', 'buddypress' ) . '</a></li>';
|
553 |
-
|
554 |
-
// Show "Sign Up" link if user registrations are allowed
|
555 |
-
if ( bp_get_signup_allowed() )
|
556 |
-
echo '<li class="bp-signup no-arrow"><a href="' . bp_get_signup_page() . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
|
557 |
-
}
|
558 |
-
|
559 |
-
/**
|
560 |
-
* Output the My Account BuddyBar menu.
|
561 |
-
*
|
562 |
-
* @return bool|null Returns false on failure.
|
563 |
-
*/
|
564 |
-
function bp_adminbar_account_menu() {
|
565 |
-
global $bp;
|
566 |
-
|
567 |
-
if ( !$bp->bp_nav || !is_user_logged_in() )
|
568 |
-
return false;
|
569 |
-
|
570 |
-
echo '<li id="bp-adminbar-account-menu"><a href="' . bp_loggedin_user_domain() . '">';
|
571 |
-
echo __( 'My Account', 'buddypress' ) . '</a>';
|
572 |
-
echo '<ul>';
|
573 |
-
|
574 |
-
// Loop through each navigation item
|
575 |
-
$counter = 0;
|
576 |
-
foreach( (array) $bp->bp_nav as $nav_item ) {
|
577 |
-
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
578 |
-
|
579 |
-
if ( -1 == $nav_item['position'] )
|
580 |
-
continue;
|
581 |
-
|
582 |
-
echo '<li' . $alt . '>';
|
583 |
-
echo '<a id="bp-admin-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>';
|
584 |
-
|
585 |
-
if ( isset( $bp->bp_options_nav[$nav_item['slug']] ) && is_array( $bp->bp_options_nav[$nav_item['slug']] ) ) {
|
586 |
-
echo '<ul>';
|
587 |
-
$sub_counter = 0;
|
588 |
-
|
589 |
-
foreach( (array) $bp->bp_options_nav[$nav_item['slug']] as $subnav_item ) {
|
590 |
-
$link = $subnav_item['link'];
|
591 |
-
$name = $subnav_item['name'];
|
592 |
-
|
593 |
-
if ( bp_displayed_user_domain() )
|
594 |
-
$link = str_replace( bp_displayed_user_domain(), bp_loggedin_user_domain(), $subnav_item['link'] );
|
595 |
-
|
596 |
-
if ( isset( $bp->displayed_user->userdata->user_login ) )
|
597 |
-
$name = str_replace( $bp->displayed_user->userdata->user_login, $bp->loggedin_user->userdata->user_login, $subnav_item['name'] );
|
598 |
-
|
599 |
-
$alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
|
600 |
-
echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $link . '">' . $name . '</a></li>';
|
601 |
-
$sub_counter++;
|
602 |
-
}
|
603 |
-
echo '</ul>';
|
604 |
-
}
|
605 |
-
|
606 |
-
echo '</li>';
|
607 |
-
|
608 |
-
$counter++;
|
609 |
-
}
|
610 |
-
|
611 |
-
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
612 |
-
|
613 |
-
echo '<li' . $alt . '><a id="bp-admin-logout" class="logout" href="' . wp_logout_url( home_url() ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
|
614 |
-
echo '</ul>';
|
615 |
-
echo '</li>';
|
616 |
-
}
|
617 |
-
|
618 |
-
function bp_adminbar_thisblog_menu() {
|
619 |
-
if ( current_user_can( 'edit_posts' ) ) {
|
620 |
-
echo '<li id="bp-adminbar-thisblog-menu"><a href="' . admin_url() . '">';
|
621 |
-
_e( 'Dashboard', 'buddypress' );
|
622 |
-
echo '</a>';
|
623 |
-
echo '<ul>';
|
624 |
-
|
625 |
-
echo '<li class="alt"><a href="' . admin_url() . 'post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';
|
626 |
-
echo '<li><a href="' . admin_url() . 'edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
|
627 |
-
echo '<li class="alt"><a href="' . admin_url() . 'edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';
|
628 |
-
|
629 |
-
do_action( 'bp_adminbar_thisblog_items' );
|
630 |
-
|
631 |
-
echo '</ul>';
|
632 |
-
echo '</li>';
|
633 |
-
}
|
634 |
-
}
|
635 |
-
|
636 |
-
/**
|
637 |
-
* Output the Random BuddyBar menu.
|
638 |
-
*
|
639 |
-
* Not visible for logged-in users.
|
640 |
-
*/
|
641 |
-
function bp_adminbar_random_menu() {
|
642 |
-
?>
|
643 |
-
|
644 |
-
<li class="align-right" id="bp-adminbar-visitrandom-menu">
|
645 |
-
<a href="#"><?php _e( 'Visit', 'buddypress' ) ?></a>
|
646 |
-
<ul class="random-list">
|
647 |
-
<li><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) . '?random-member' ?>" rel="nofollow"><?php _e( 'Random Member', 'buddypress' ) ?></a></li>
|
648 |
-
|
649 |
-
<?php if ( bp_is_active( 'groups' ) ) : ?>
|
650 |
-
|
651 |
-
<li class="alt"><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() ) . '?random-group' ?>" rel="nofollow"><?php _e( 'Random Group', 'buddypress' ) ?></a></li>
|
652 |
-
|
653 |
-
<?php endif; ?>
|
654 |
-
|
655 |
-
<?php if ( is_multisite() && bp_is_active( 'blogs' ) ) : ?>
|
656 |
-
|
657 |
-
<li><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() ) . '?random-blog' ?>" rel="nofollow"><?php _e( 'Random Site', 'buddypress' ) ?></a></li>
|
658 |
-
|
659 |
-
<?php endif; ?>
|
660 |
-
|
661 |
-
<?php do_action( 'bp_adminbar_random_menu' ) ?>
|
662 |
-
|
663 |
-
</ul>
|
664 |
-
</li>
|
665 |
-
|
666 |
-
<?php
|
667 |
-
}
|
668 |
|
669 |
/**
|
670 |
* Retrieve the Toolbar display preference of a user based on context.
|
@@ -687,27 +578,3 @@ function bp_get_admin_bar_pref( $context, $user = 0 ) {
|
|
687 |
|
688 |
return 'true' === $pref;
|
689 |
}
|
690 |
-
|
691 |
-
/**
|
692 |
-
* Enqueue the BuddyBar CSS.
|
693 |
-
*/
|
694 |
-
function bp_core_load_buddybar_css() {
|
695 |
-
global $wp_styles;
|
696 |
-
|
697 |
-
if ( bp_use_wp_admin_bar() || ( (int) bp_get_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) || ( defined( 'BP_DISABLE_ADMIN_BAR' ) && BP_DISABLE_ADMIN_BAR ) )
|
698 |
-
return;
|
699 |
-
|
700 |
-
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
701 |
-
|
702 |
-
if ( file_exists( get_stylesheet_directory() . '/_inc/css/adminbar.css' ) ) { // Backwards compatibility
|
703 |
-
$stylesheet = get_stylesheet_directory_uri() . '/_inc/css/adminbar.css';
|
704 |
-
} else {
|
705 |
-
$stylesheet = buddypress()->plugin_url . "bp-core/css/buddybar{$min}.css";
|
706 |
-
}
|
707 |
-
|
708 |
-
wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_buddybar_rtl_css', $stylesheet ), array(), bp_get_version() );
|
709 |
-
$wp_styles->add_data( 'bp-admin-bar', 'rtl', true );
|
710 |
-
if ( $min )
|
711 |
-
$wp_styles->add_data( 'bp-admin-bar', 'suffix', $min );
|
712 |
-
}
|
713 |
-
add_action( 'bp_init', 'bp_core_load_buddybar_css' );
|
259 |
function bp_core_new_subnav_item( $args = '' ) {
|
260 |
global $bp;
|
261 |
|
262 |
+
$r = wp_parse_args( $args, array(
|
263 |
'name' => false, // Display name for the nav item
|
264 |
'slug' => false, // URL slug for the nav item
|
265 |
'parent_slug' => false, // URL slug of the parent nav item
|
266 |
'parent_url' => false, // URL of the parent item
|
267 |
'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item
|
268 |
'user_has_access' => true, // Can the logged in user see this nav item?
|
269 |
+
'no_access_url' => '',
|
270 |
'site_admin_only' => false, // Can only site admins see this nav item?
|
271 |
'position' => 90, // Index of where this nav item should be positioned
|
272 |
'screen_function' => false, // The name of the function to run when clicked
|
273 |
'link' => '' // The link for the subnav item; optional, not usually required.
|
274 |
+
) );
|
275 |
|
|
|
276 |
extract( $r, EXTR_SKIP );
|
277 |
|
278 |
// If we don't have the required info we need, don't create this subnav item
|
296 |
if ( empty( $item_css_id ) )
|
297 |
$item_css_id = $slug;
|
298 |
|
299 |
+
$subnav_item = array(
|
300 |
'name' => $name,
|
301 |
'link' => trailingslashit( $link ),
|
302 |
'slug' => $slug,
|
303 |
'css_id' => $item_css_id,
|
304 |
'position' => $position,
|
305 |
'user_has_access' => $user_has_access,
|
306 |
+
'no_access_url' => $no_access_url,
|
307 |
'screen_function' => &$screen_function
|
308 |
);
|
309 |
+
$bp->bp_options_nav[$parent_slug][$slug] = $subnav_item;
|
310 |
|
311 |
/**
|
312 |
* The last step is to hook the screen function for the added subnav item. But this only
|
332 |
// If we *do* meet condition (2), then the added subnav item is currently being requested
|
333 |
if ( ( bp_current_action() && bp_is_current_action( $slug ) ) || ( bp_is_user() && ! bp_current_action() && ( $screen_function == $bp->bp_nav[$parent_slug]['screen_function'] ) ) ) {
|
334 |
|
335 |
+
$hooked = bp_core_maybe_hook_new_subnav_screen_function( $subnav_item );
|
336 |
+
|
337 |
+
// If redirect args have been returned, perform the redirect now
|
338 |
+
if ( ! empty( $hooked['status'] ) && 'failure' === $hooked['status'] && isset( $hooked['redirect_args'] ) ) {
|
339 |
+
bp_core_no_access( $hooked['redirect_args'] );
|
340 |
+
}
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* For a given subnav item, either hook the screen function or generate redirect arguments, as necessary.
|
346 |
+
*
|
347 |
+
* @since BuddyPress (2.1.0)
|
348 |
+
*
|
349 |
+
* @param array $subnav_item The subnav array added to bp_options_nav in
|
350 |
+
* bp_core_new_subnav_item().
|
351 |
+
* @return array
|
352 |
+
*/
|
353 |
+
function bp_core_maybe_hook_new_subnav_screen_function( $subnav_item ) {
|
354 |
+
$retval = array(
|
355 |
+
'status' => '',
|
356 |
+
);
|
357 |
+
|
358 |
+
// User has access, so let's try to hook the display callback
|
359 |
+
if ( ! empty( $subnav_item['user_has_access'] ) ) {
|
360 |
+
|
361 |
+
// Screen function is invalid
|
362 |
+
if ( ! is_callable( $subnav_item['screen_function'] ) ) {
|
363 |
+
$retval['status'] = 'failure';
|
364 |
+
|
365 |
+
// Success - hook to bp_screens
|
366 |
} else {
|
367 |
+
add_action( 'bp_screens', $subnav_item['screen_function'], 3 );
|
368 |
+
$retval['status'] = 'success';
|
369 |
+
}
|
370 |
+
|
371 |
+
// User doesn't have access. Determine redirect arguments based on
|
372 |
+
// user status
|
373 |
+
} else {
|
374 |
+
$retval['status'] = 'failure';
|
375 |
+
|
376 |
+
if ( is_user_logged_in() ) {
|
377 |
|
378 |
+
$bp = buddypress();
|
|
|
|
|
|
|
379 |
|
380 |
+
// If a redirect URL has been passed to the subnav
|
381 |
+
// item, respect it
|
382 |
+
if ( ! empty( $subnav_item['no_access_url'] ) ) {
|
383 |
+
$message = __( 'You do not have access to this page.', 'buddypress' );
|
384 |
+
$redirect_to = trailingslashit( $subnav_item['no_access_url'] );
|
385 |
+
|
386 |
+
// In the case of a user page, we try to assume a
|
387 |
+
// redirect URL
|
388 |
+
} else if ( bp_is_user() ) {
|
389 |
+
|
390 |
+
// Redirect to the displayed user's default
|
391 |
+
// component, as long as that component is
|
392 |
+
// publicly accessible.
|
393 |
+
if ( bp_is_my_profile() || ! empty( $bp->bp_nav[ $bp->default_component ]['show_for_displayed_user'] ) ) {
|
394 |
+
$message = __( 'You do not have access to this page.', 'buddypress' );
|
395 |
+
$redirect_to = bp_displayed_user_domain();
|
396 |
+
|
397 |
+
// In some cases, the default tab is not accessible to
|
398 |
+
// the logged-in user. So we fall back on a tab that we
|
399 |
+
// know will be accessible.
|
400 |
+
} else {
|
401 |
+
// Try 'activity' first
|
402 |
if ( bp_is_active( 'activity' ) && isset( $bp->pages->activity ) ) {
|
403 |
$redirect_to = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() );
|
404 |
+
// Then try 'profile'
|
405 |
} else {
|
406 |
$redirect_to = trailingslashit( bp_displayed_user_domain() . ( 'xprofile' == $bp->profile->id ? 'profile' : $bp->profile->id ) );
|
407 |
}
|
408 |
|
409 |
$message = '';
|
|
|
|
|
|
|
410 |
}
|
411 |
|
412 |
+
// Fall back to the home page
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
413 |
} else {
|
414 |
+
$message = __( 'You do not have access to this page.', 'buddypress' );
|
415 |
+
$redirect_to = bp_get_root_domain();
|
416 |
}
|
417 |
+
|
418 |
+
$retval['redirect_args'] = array(
|
419 |
+
'message' => $message,
|
420 |
+
'root' => $redirect_to,
|
421 |
+
'redirect' => false,
|
422 |
+
);
|
423 |
+
|
424 |
+
} else {
|
425 |
+
// When the user is logged out, pass an empty array
|
426 |
+
// This indicates that the default arguments should be
|
427 |
+
// used in bp_core_no_access()
|
428 |
+
$retval['redirect_args'] = array();
|
429 |
}
|
430 |
}
|
431 |
+
|
432 |
+
return $retval;
|
433 |
}
|
434 |
|
435 |
/**
|
556 |
unset( $bp->bp_options_nav[$parent_slug] );
|
557 |
}
|
558 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
559 |
|
560 |
/**
|
561 |
* Retrieve the Toolbar display preference of a user based on context.
|
578 |
|
579 |
return 'true' === $pref;
|
580 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -10,6 +10,33 @@
|
|
10 |
// Exit if accessed directly
|
11 |
if ( !defined( 'ABSPATH' ) ) exit;
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Add capabilities to WordPress user roles.
|
15 |
*
|
10 |
// Exit if accessed directly
|
11 |
if ( !defined( 'ABSPATH' ) ) exit;
|
12 |
|
13 |
+
/**
|
14 |
+
* Return an array of roles from the currently loaded blog
|
15 |
+
*
|
16 |
+
* WordPress roles are dynamically flipped when calls to switch_to_blog() and
|
17 |
+
* restore_current_blog() are made, so we use and trust WordPress core to have
|
18 |
+
* loaded the correct results for us here. As enhancements are made to
|
19 |
+
* WordPresss's RBAC, so should our capability functions here.
|
20 |
+
*
|
21 |
+
* @since BuddyPress (2.1.0)
|
22 |
+
*
|
23 |
+
* @return array
|
24 |
+
*/
|
25 |
+
function bp_get_current_blog_roles() {
|
26 |
+
global $wp_roles;
|
27 |
+
|
28 |
+
// Sanity check on roles global variable
|
29 |
+
$roles = isset( $wp_roles->roles )
|
30 |
+
? $wp_roles->roles
|
31 |
+
: array();
|
32 |
+
|
33 |
+
// Apply WordPress core filter to editable roles
|
34 |
+
$roles = apply_filters( 'editable_roles', $roles );
|
35 |
+
|
36 |
+
// Return the editable roles
|
37 |
+
return apply_filters( 'bp_get_current_blog_roles', $roles, $wp_roles );
|
38 |
+
}
|
39 |
+
|
40 |
/**
|
41 |
* Add capabilities to WordPress user roles.
|
42 |
*
|
@@ -340,39 +340,58 @@ function bp_core_enable_root_profiles() {
|
|
340 |
* @return bool|null Returns false on failure.
|
341 |
*/
|
342 |
function bp_core_load_template( $templates ) {
|
343 |
-
global $
|
344 |
|
345 |
-
//
|
346 |
-
|
347 |
-
|
348 |
-
if (
|
349 |
-
|
|
|
350 |
}
|
351 |
}
|
352 |
|
353 |
-
// Set
|
354 |
-
$
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
}
|
359 |
-
}
|
360 |
|
361 |
-
//
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
|
|
|
|
|
|
|
|
366 |
}
|
367 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
368 |
// Fetch each template and add the php suffix
|
369 |
$filtered_templates = array();
|
370 |
foreach ( (array) $templates as $template ) {
|
371 |
$filtered_templates[] = $template . '.php';
|
372 |
}
|
373 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
374 |
// Filter the template locations so that plugins can alter where they are located
|
375 |
-
$located_template = apply_filters( 'bp_located_template',
|
376 |
if ( !empty( $located_template ) ) {
|
377 |
|
378 |
// Template was located, lets set this as a valid page and not a 404.
|
340 |
* @return bool|null Returns false on failure.
|
341 |
*/
|
342 |
function bp_core_load_template( $templates ) {
|
343 |
+
global $wp_query;
|
344 |
|
345 |
+
// check if BP page belongs to, or is a child of, a BP directory page
|
346 |
+
$page_id = false;
|
347 |
+
foreach ( (array) buddypress()->pages as $page ) {
|
348 |
+
if ( $page->name == buddypress()->unfiltered_uri[buddypress()->unfiltered_uri_offset] ) {
|
349 |
+
$page_id = $page->id;
|
350 |
+
break;
|
351 |
}
|
352 |
}
|
353 |
|
354 |
+
// Set up reset post args
|
355 |
+
$reset_post_args = array(
|
356 |
+
'is_404' => true,
|
357 |
+
'post_status' => 'publish',
|
358 |
+
);
|
|
|
|
|
359 |
|
360 |
+
// BP page exists - fill in the $wp_query->post object
|
361 |
+
//
|
362 |
+
// bp_theme_compat_reset_post() looks at the $wp_query->post object to fill in
|
363 |
+
// the post globals
|
364 |
+
if ( ! empty( $page_id ) ) {
|
365 |
+
$wp_query->post = get_post( $page_id );
|
366 |
+
$reset_post_args['ID'] = $page_id;
|
367 |
+
} else {
|
368 |
+
$reset_post_args['ID'] = 0;
|
369 |
}
|
370 |
|
371 |
+
// Reset the post
|
372 |
+
bp_theme_compat_reset_post( $reset_post_args );
|
373 |
+
|
374 |
+
// Set theme compat to false since the reset post function automatically sets
|
375 |
+
// theme compat to true
|
376 |
+
bp_set_theme_compat_active( false );
|
377 |
+
|
378 |
// Fetch each template and add the php suffix
|
379 |
$filtered_templates = array();
|
380 |
foreach ( (array) $templates as $template ) {
|
381 |
$filtered_templates[] = $template . '.php';
|
382 |
}
|
383 |
|
384 |
+
// Only perform template lookup for bp-default themes
|
385 |
+
if ( ! bp_use_theme_compat_with_current_theme() ) {
|
386 |
+
$template = locate_template( (array) $filtered_templates, false );
|
387 |
+
|
388 |
+
// Theme compat doesn't require a template lookup
|
389 |
+
} else {
|
390 |
+
$template = '';
|
391 |
+
}
|
392 |
+
|
393 |
// Filter the template locations so that plugins can alter where they are located
|
394 |
+
$located_template = apply_filters( 'bp_located_template', $template, $filtered_templates );
|
395 |
if ( !empty( $located_template ) ) {
|
396 |
|
397 |
// Template was located, lets set this as a valid page and not a 404.
|
@@ -30,6 +30,9 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|
30 |
* @type string|bool $search_terms Terms to search by. Search happens
|
31 |
* across xprofile fields. Requires XProfile component.
|
32 |
* Default: false.
|
|
|
|
|
|
|
33 |
* @type array|string|bool $include An array or comma-separated list of
|
34 |
* user IDs to which query should be limited.
|
35 |
* Default: false.
|
@@ -153,6 +156,7 @@ class BP_User_Query {
|
|
153 |
'page' => 1,
|
154 |
'user_id' => 0,
|
155 |
'search_terms' => false,
|
|
|
156 |
'include' => false,
|
157 |
'exclude' => false,
|
158 |
'user_ids' => false,
|
@@ -364,8 +368,26 @@ class BP_User_Query {
|
|
364 |
// 'search_terms' searches user_login and user_nicename
|
365 |
// xprofile field matches happen in bp_xprofile_bp_user_query_search()
|
366 |
if ( false !== $search_terms ) {
|
367 |
-
$
|
368 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
}
|
370 |
|
371 |
// 'meta_key', 'meta_value' allow usermeta search
|
@@ -810,9 +832,9 @@ class BP_Core_User {
|
|
810 |
wp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' );
|
811 |
wp_cache_set( 'bp_user_url_' . $this->id, $this->user_url, 'bp' );
|
812 |
|
813 |
-
$this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full', 'alt' => sprintf( __( '
|
814 |
-
$this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( '
|
815 |
-
$this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( '
|
816 |
$this->last_active = bp_core_get_last_activity( bp_get_user_last_activity( $this->id ), __( 'active %s', 'buddypress' ) );
|
817 |
}
|
818 |
|
@@ -967,8 +989,8 @@ class BP_Core_User {
|
|
967 |
}
|
968 |
|
969 |
if ( !empty( $search_terms ) && bp_is_active( 'xprofile' ) ) {
|
970 |
-
$
|
971 |
-
$sql['where_searchterms'] = "AND spd.value LIKE
|
972 |
}
|
973 |
|
974 |
if ( !empty( $meta_key ) ) {
|
@@ -1085,18 +1107,18 @@ class BP_Core_User {
|
|
1085 |
}
|
1086 |
}
|
1087 |
|
1088 |
-
$
|
1089 |
-
$status_sql
|
1090 |
|
1091 |
if ( !empty( $exclude ) ) {
|
1092 |
-
$exclude = implode( ',', wp_parse_id_list( $
|
1093 |
$exclude_sql = " AND u.id NOT IN ({$exclude})";
|
1094 |
} else {
|
1095 |
$exclude_sql = '';
|
1096 |
}
|
1097 |
|
1098 |
-
$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
|
1099 |
-
$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
|
1100 |
|
1101 |
$total_users = $wpdb->get_var( $total_users_sql );
|
1102 |
$paged_users = $wpdb->get_results( $paged_users_sql );
|
@@ -1184,11 +1206,11 @@ class BP_Core_User {
|
|
1184 |
$user_ids = array();
|
1185 |
$pag_sql = $limit && $page ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * intval( $limit ) ), intval( $limit ) ) : '';
|
1186 |
|
1187 |
-
$
|
1188 |
-
$status_sql
|
1189 |
|
1190 |
-
$total_users_sql = apply_filters( 'bp_core_search_users_count_sql', "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
|
1191 |
-
$paged_users_sql = apply_filters( 'bp_core_search_users_sql', "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
|
1192 |
|
1193 |
$total_users = $wpdb->get_var( $total_users_sql );
|
1194 |
$paged_users = $wpdb->get_results( $paged_users_sql );
|
@@ -1321,40 +1343,35 @@ class BP_Core_User {
|
|
1321 |
public static function get_last_activity( $user_id ) {
|
1322 |
global $wpdb;
|
1323 |
|
1324 |
-
|
1325 |
-
|
1326 |
-
} else {
|
1327 |
-
$user_ids = array( absint( $user_id ) );
|
1328 |
-
}
|
1329 |
|
1330 |
if ( empty( $user_ids ) ) {
|
1331 |
return false;
|
1332 |
}
|
1333 |
|
1334 |
-
|
1335 |
-
if ( !
|
1336 |
-
$
|
1337 |
-
|
1338 |
-
if ( false !== $cache ) {
|
1339 |
-
return $cache;
|
1340 |
-
}
|
1341 |
-
}
|
1342 |
|
1343 |
-
|
|
|
1344 |
|
1345 |
-
|
1346 |
-
$user_count = count( $user_ids );
|
1347 |
|
1348 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1349 |
|
1350 |
-
//
|
1351 |
$retval = array();
|
1352 |
-
foreach ( $
|
1353 |
-
$retval[ $
|
1354 |
-
'user_id' => $last_activity->user_id,
|
1355 |
-
'date_recorded' => $last_activity->date_recorded,
|
1356 |
-
'activity_id' => $last_activity->id,
|
1357 |
-
);
|
1358 |
}
|
1359 |
|
1360 |
return $retval;
|
@@ -1379,7 +1396,7 @@ class BP_Core_User {
|
|
1379 |
|
1380 |
$activity = self::get_last_activity( $user_id );
|
1381 |
|
1382 |
-
if ( ! empty( $activity ) ) {
|
1383 |
$updated = $wpdb->update(
|
1384 |
$table_name,
|
1385 |
|
@@ -1436,7 +1453,7 @@ class BP_Core_User {
|
|
1436 |
)
|
1437 |
);
|
1438 |
|
1439 |
-
//
|
1440 |
// view the foreach loop in the get_last_activity() method for format
|
1441 |
$activity = array();
|
1442 |
$activity[ $user_id ] = array(
|
@@ -1447,7 +1464,7 @@ class BP_Core_User {
|
|
1447 |
}
|
1448 |
|
1449 |
// set cache
|
1450 |
-
wp_cache_set( $user_id, $activity, 'bp_last_activity' );
|
1451 |
|
1452 |
return $updated;
|
1453 |
}
|
@@ -1490,6 +1507,60 @@ class BP_Core_User {
|
|
1490 |
}
|
1491 |
}
|
1492 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1493 |
|
1494 |
/**
|
1495 |
* BP_Core_Notification is deprecated.
|
@@ -1896,13 +1967,22 @@ class BP_Button {
|
|
1896 |
if ( true == $this->must_be_logged_in && ! is_user_logged_in() )
|
1897 |
return false;
|
1898 |
|
1899 |
-
//
|
1900 |
-
if ( true == $this->block_self
|
1901 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1902 |
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
|
|
|
|
|
|
1906 |
|
1907 |
// Wrapper properties
|
1908 |
if ( false !== $this->wrapper ) {
|
@@ -2412,3 +2492,209 @@ class BP_Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
|
|
2412 |
$output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="'. esc_attr( $item->xfn ) .'" />';
|
2413 |
}
|
2414 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
* @type string|bool $search_terms Terms to search by. Search happens
|
31 |
* across xprofile fields. Requires XProfile component.
|
32 |
* Default: false.
|
33 |
+
* @type string $search_wildcard When searching with $search_terms,
|
34 |
+
* set where wildcards around the term should be positioned.
|
35 |
+
* Default: 'both'. Other values: 'left', 'right'.
|
36 |
* @type array|string|bool $include An array or comma-separated list of
|
37 |
* user IDs to which query should be limited.
|
38 |
* Default: false.
|
156 |
'page' => 1,
|
157 |
'user_id' => 0,
|
158 |
'search_terms' => false,
|
159 |
+
'search_wildcard' => 'both',
|
160 |
'include' => false,
|
161 |
'exclude' => false,
|
162 |
'user_ids' => false,
|
368 |
// 'search_terms' searches user_login and user_nicename
|
369 |
// xprofile field matches happen in bp_xprofile_bp_user_query_search()
|
370 |
if ( false !== $search_terms ) {
|
371 |
+
$search_terms = bp_esc_like( wp_kses_normalize_entities( $search_terms ) );
|
372 |
+
|
373 |
+
if ( $search_wildcard === 'left' ) {
|
374 |
+
$search_terms_nospace = '%' . $search_terms;
|
375 |
+
$search_terms_space = '%' . $search_terms . ' %';
|
376 |
+
} elseif ( $search_wildcard === 'right' ) {
|
377 |
+
$search_terms_nospace = $search_terms . '%';
|
378 |
+
$search_terms_space = '% ' . $search_terms . '%';
|
379 |
+
} else {
|
380 |
+
$search_terms_nospace = '%' . $search_terms . '%';
|
381 |
+
$search_terms_space = '%' . $search_terms . '%';
|
382 |
+
}
|
383 |
+
|
384 |
+
$sql['where']['search'] = $wpdb->prepare(
|
385 |
+
"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 ) )",
|
386 |
+
$search_terms_nospace,
|
387 |
+
$search_terms_space,
|
388 |
+
$search_terms_nospace,
|
389 |
+
$search_terms_space
|
390 |
+
);
|
391 |
}
|
392 |
|
393 |
// 'meta_key', 'meta_value' allow usermeta search
|
832 |
wp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' );
|
833 |
wp_cache_set( 'bp_user_url_' . $this->id, $this->user_url, 'bp' );
|
834 |
|
835 |
+
$this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) );
|
836 |
+
$this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->fullname ) ) );
|
837 |
+
$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 ) );
|
838 |
$this->last_active = bp_core_get_last_activity( bp_get_user_last_activity( $this->id ), __( 'active %s', 'buddypress' ) );
|
839 |
}
|
840 |
|
989 |
}
|
990 |
|
991 |
if ( !empty( $search_terms ) && bp_is_active( 'xprofile' ) ) {
|
992 |
+
$search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
|
993 |
+
$sql['where_searchterms'] = $wpdb->prepare( "AND spd.value LIKE %s", $search_terms_like );
|
994 |
}
|
995 |
|
996 |
if ( !empty( $meta_key ) ) {
|
1107 |
}
|
1108 |
}
|
1109 |
|
1110 |
+
$letter_like = bp_esc_like( $letter ) . '%';
|
1111 |
+
$status_sql = bp_core_get_status_sql( 'u.' );
|
1112 |
|
1113 |
if ( !empty( $exclude ) ) {
|
1114 |
+
$exclude = implode( ',', wp_parse_id_list( $exclude ) );
|
1115 |
$exclude_sql = " AND u.id NOT IN ({$exclude})";
|
1116 |
} else {
|
1117 |
$exclude_sql = '';
|
1118 |
}
|
1119 |
|
1120 |
+
$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 ) );
|
1121 |
+
$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 ) );
|
1122 |
|
1123 |
$total_users = $wpdb->get_var( $total_users_sql );
|
1124 |
$paged_users = $wpdb->get_results( $paged_users_sql );
|
1206 |
$user_ids = array();
|
1207 |
$pag_sql = $limit && $page ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * intval( $limit ) ), intval( $limit ) ) : '';
|
1208 |
|
1209 |
+
$search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
|
1210 |
+
$status_sql = bp_core_get_status_sql( 'u.' );
|
1211 |
|
1212 |
+
$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 );
|
1213 |
+
$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 );
|
1214 |
|
1215 |
$total_users = $wpdb->get_var( $total_users_sql );
|
1216 |
$paged_users = $wpdb->get_results( $paged_users_sql );
|
1343 |
public static function get_last_activity( $user_id ) {
|
1344 |
global $wpdb;
|
1345 |
|
1346 |
+
// Sanitize and remove empty values
|
1347 |
+
$user_ids = array_filter( wp_parse_id_list( $user_id ) );
|
|
|
|
|
|
|
1348 |
|
1349 |
if ( empty( $user_ids ) ) {
|
1350 |
return false;
|
1351 |
}
|
1352 |
|
1353 |
+
$uncached_user_ids = bp_get_non_cached_ids( $user_ids, 'bp_last_activity' );
|
1354 |
+
if ( ! empty( $uncached_user_ids ) ) {
|
1355 |
+
$bp = buddypress();
|
|
|
|
|
|
|
|
|
|
|
1356 |
|
1357 |
+
$user_ids_sql = implode( ',', $uncached_user_ids );
|
1358 |
+
$user_count = count( $uncached_user_ids );
|
1359 |
|
1360 |
+
$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 ) );
|
|
|
1361 |
|
1362 |
+
foreach ( $last_activities as $last_activity ) {
|
1363 |
+
wp_cache_set( $last_activity->user_id, array(
|
1364 |
+
'user_id' => $last_activity->user_id,
|
1365 |
+
'date_recorded' => $last_activity->date_recorded,
|
1366 |
+
'activity_id' => $last_activity->id,
|
1367 |
+
), 'bp_last_activity' );
|
1368 |
+
}
|
1369 |
+
}
|
1370 |
|
1371 |
+
// Fetch all user data from the cache
|
1372 |
$retval = array();
|
1373 |
+
foreach ( $user_ids as $user_id ) {
|
1374 |
+
$retval[ $user_id ] = wp_cache_get( $user_id, 'bp_last_activity' );
|
|
|
|
|
|
|
|
|
1375 |
}
|
1376 |
|
1377 |
return $retval;
|
1396 |
|
1397 |
$activity = self::get_last_activity( $user_id );
|
1398 |
|
1399 |
+
if ( ! empty( $activity[ $user_id ] ) ) {
|
1400 |
$updated = $wpdb->update(
|
1401 |
$table_name,
|
1402 |
|
1453 |
)
|
1454 |
);
|
1455 |
|
1456 |
+
// set up activity array for caching
|
1457 |
// view the foreach loop in the get_last_activity() method for format
|
1458 |
$activity = array();
|
1459 |
$activity[ $user_id ] = array(
|
1464 |
}
|
1465 |
|
1466 |
// set cache
|
1467 |
+
wp_cache_set( $user_id, $activity[ $user_id ], 'bp_last_activity' );
|
1468 |
|
1469 |
return $updated;
|
1470 |
}
|
1507 |
}
|
1508 |
}
|
1509 |
|
1510 |
+
if ( class_exists( 'WP_Date_Query' ) ) :
|
1511 |
+
/**
|
1512 |
+
* BuddyPress date query class.
|
1513 |
+
*
|
1514 |
+
* Extends the {@link WP_Date_Query} class for use with BuddyPress.
|
1515 |
+
*
|
1516 |
+
* @since BuddyPress (2.1.0)
|
1517 |
+
*
|
1518 |
+
* @param array $date_query {
|
1519 |
+
* Date query arguments. See first parameter of {@link WP_Date_Query::__construct()}.
|
1520 |
+
* }
|
1521 |
+
* @param string $column The DB column to query against.
|
1522 |
+
*/
|
1523 |
+
class BP_Date_Query extends WP_Date_Query {
|
1524 |
+
/**
|
1525 |
+
* The column to query against. Can be changed via the query arguments.
|
1526 |
+
*
|
1527 |
+
* @var string
|
1528 |
+
*/
|
1529 |
+
public $column;
|
1530 |
+
|
1531 |
+
/**
|
1532 |
+
* Constructor.
|
1533 |
+
*
|
1534 |
+
* @see WP_Date_Query::__construct()
|
1535 |
+
*/
|
1536 |
+
public function __construct( $date_query, $column = '' ) {
|
1537 |
+
if ( ! empty( $column ) ) {
|
1538 |
+
$this->column = $column;
|
1539 |
+
add_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) );
|
1540 |
+
}
|
1541 |
+
|
1542 |
+
parent::__construct( $date_query, $column );
|
1543 |
+
}
|
1544 |
+
|
1545 |
+
/**
|
1546 |
+
* Destructor.
|
1547 |
+
*/
|
1548 |
+
public function __destruct() {
|
1549 |
+
remove_filter( 'date_query_valid_columns', array( $this, 'register_date_column' ) );
|
1550 |
+
}
|
1551 |
+
|
1552 |
+
/**
|
1553 |
+
* Registers our date column with WP Date Query to pass validation.
|
1554 |
+
*
|
1555 |
+
* @param array $retval Current DB columns
|
1556 |
+
* @return array
|
1557 |
+
*/
|
1558 |
+
public function register_date_column( $retval = array() ) {
|
1559 |
+
$retval[] = $this->column;
|
1560 |
+
return $retval;
|
1561 |
+
}
|
1562 |
+
}
|
1563 |
+
endif;
|
1564 |
|
1565 |
/**
|
1566 |
* BP_Core_Notification is deprecated.
|
1967 |
if ( true == $this->must_be_logged_in && ! is_user_logged_in() )
|
1968 |
return false;
|
1969 |
|
1970 |
+
// block_self
|
1971 |
+
if ( true == $this->block_self ) {
|
1972 |
+
// No button if you are the current user in a members loop
|
1973 |
+
// This condition takes precedence, because members loops
|
1974 |
+
// can be found on user profiles
|
1975 |
+
if ( bp_get_member_user_id() ) {
|
1976 |
+
if ( is_user_logged_in() && bp_loggedin_user_id() == bp_get_member_user_id() ) {
|
1977 |
+
return false;
|
1978 |
+
}
|
1979 |
|
1980 |
+
// No button if viewing your own profile (and not in
|
1981 |
+
// a members loop)
|
1982 |
+
} else if ( bp_is_my_profile() ) {
|
1983 |
+
return false;
|
1984 |
+
}
|
1985 |
+
}
|
1986 |
|
1987 |
// Wrapper properties
|
1988 |
if ( false !== $this->wrapper ) {
|
2492 |
$output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="'. esc_attr( $item->xfn ) .'" />';
|
2493 |
}
|
2494 |
}
|
2495 |
+
|
2496 |
+
/**
|
2497 |
+
* Base class for the BuddyPress Suggestions API.
|
2498 |
+
*
|
2499 |
+
* Originally built to power BuddyPress' at-mentions suggestions, it's flexible enough to be used
|
2500 |
+
* for similar kinds of future core requirements, or those desired by third-party developers.
|
2501 |
+
*
|
2502 |
+
* To implement a new suggestions service, create a new class that extends this one, and update
|
2503 |
+
* the list of default services in {@link bp_core_get_suggestions()}. If you're building a plugin,
|
2504 |
+
* it's recommend that you use the `bp_suggestions_services` filter to do this. :)
|
2505 |
+
*
|
2506 |
+
* While the implementation of the query logic is left to you, it should be as quick and efficient
|
2507 |
+
* as possible. When implementing the abstract methods in this class, pay close attention to the
|
2508 |
+
* recommendations provided in the phpDoc blocks, particularly the expected return types.
|
2509 |
+
*
|
2510 |
+
* @since BuddyPress (2.1.0)
|
2511 |
+
*/
|
2512 |
+
abstract class BP_Suggestions {
|
2513 |
+
|
2514 |
+
/**
|
2515 |
+
* Default arguments common to all suggestions services.
|
2516 |
+
*
|
2517 |
+
* If your custom service requires further defaults, add them here.
|
2518 |
+
*
|
2519 |
+
* @since BuddyPress (2.1.0)
|
2520 |
+
* @var array
|
2521 |
+
*/
|
2522 |
+
protected $default_args = array(
|
2523 |
+
'limit' => 16,
|
2524 |
+
'term' => '',
|
2525 |
+
'type' => '',
|
2526 |
+
);
|
2527 |
+
|
2528 |
+
/**
|
2529 |
+
* Holds the arguments for the query (about to made to the suggestions service).
|
2530 |
+
*
|
2531 |
+
* This includes `$default_args`, as well as the user-supplied values.
|
2532 |
+
*
|
2533 |
+
* @since BuddyPress (2.1.0)
|
2534 |
+
* @var array
|
2535 |
+
*/
|
2536 |
+
protected $args = array(
|
2537 |
+
);
|
2538 |
+
|
2539 |
+
|
2540 |
+
/**
|
2541 |
+
* Constructor.
|
2542 |
+
*
|
2543 |
+
* @param array $args Optional. If set, used as the parameters for the suggestions service query.
|
2544 |
+
* @since BuddyPress (2.1.0)
|
2545 |
+
*/
|
2546 |
+
public function __construct( array $args = array() ) {
|
2547 |
+
if ( ! empty( $args ) ) {
|
2548 |
+
$this->set_query( $args );
|
2549 |
+
}
|
2550 |
+
}
|
2551 |
+
|
2552 |
+
/**
|
2553 |
+
* Set the parameters for the suggestions service query.
|
2554 |
+
*
|
2555 |
+
* @param array $args {
|
2556 |
+
* @type int $limit Maximum number of results to display. Optional, default: 16.
|
2557 |
+
* @type string $type The name of the suggestion service to use for the request. Mandatory.
|
2558 |
+
* @type string $term The suggestion service will try to find results that contain this string.
|
2559 |
+
* Mandatory.
|
2560 |
+
* }
|
2561 |
+
* @since BuddyPress (2.1.0)
|
2562 |
+
*/
|
2563 |
+
public function set_query( array $args = array() ) {
|
2564 |
+
$this->args = wp_parse_args( $args, $this->default_args );
|
2565 |
+
}
|
2566 |
+
|
2567 |
+
/**
|
2568 |
+
* Validate and sanitise the parameters for the suggestion service query.
|
2569 |
+
*
|
2570 |
+
* Be sure to call this class' version of this method when implementing it in your own service.
|
2571 |
+
* If validation fails, you must return a WP_Error object.
|
2572 |
+
*
|
2573 |
+
* @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool).
|
2574 |
+
* @since BuddyPress (2.1.0)
|
2575 |
+
*/
|
2576 |
+
public function validate() {
|
2577 |
+
$this->args['limit'] = absint( $this->args['limit'] );
|
2578 |
+
$this->args['term'] = trim( sanitize_text_field( $this->args['term'] ) );
|
2579 |
+
$this->args = apply_filters( 'bp_suggestions_args', $this->args, $this );
|
2580 |
+
|
2581 |
+
|
2582 |
+
// Check for invalid or missing mandatory parameters.
|
2583 |
+
if ( ! $this->args['limit'] || ! $this->args['term'] ) {
|
2584 |
+
return new WP_Error( 'missing_parameter' );
|
2585 |
+
}
|
2586 |
+
|
2587 |
+
// Check for blocked users (e.g. deleted accounts, or spammers).
|
2588 |
+
if ( is_user_logged_in() && ! bp_is_user_active( get_current_user_id() ) ) {
|
2589 |
+
return new WP_Error( 'invalid_user' );
|
2590 |
+
}
|
2591 |
+
|
2592 |
+
return apply_filters( 'bp_suggestions_validate_args', true, $this );
|
2593 |
+
}
|
2594 |
+
|
2595 |
+
/**
|
2596 |
+
* Find and return a list of suggestions that match the query.
|
2597 |
+
*
|
2598 |
+
* The return type is important. If no matches are found, an empty array must be returned.
|
2599 |
+
* Matches must be returned as objects in an array.
|
2600 |
+
*
|
2601 |
+
* The object format for each match must be: { 'ID': string, 'image': string, 'name': string }
|
2602 |
+
* For example: { 'ID': 'admin', 'image': 'http://example.com/logo.png', 'name': 'Name Surname' }
|
2603 |
+
*
|
2604 |
+
* @return array|WP_Error Array of results. If there were problems, returns a WP_Error object.
|
2605 |
+
* @since BuddyPress (2.1.0)
|
2606 |
+
*/
|
2607 |
+
abstract public function get_suggestions();
|
2608 |
+
}
|
2609 |
+
|
2610 |
+
/**
|
2611 |
+
* Adds support for user at-mentions to the Suggestions API.
|
2612 |
+
*
|
2613 |
+
* This class is in the Core component because it's required by a class in the Groups component,
|
2614 |
+
* and Groups is loaded before Members (alphabetical order).
|
2615 |
+
*
|
2616 |
+
* @since BuddyPress (2.1.0)
|
2617 |
+
*/
|
2618 |
+
class BP_Members_Suggestions extends BP_Suggestions {
|
2619 |
+
|
2620 |
+
/**
|
2621 |
+
* Default arguments for this suggestions service.
|
2622 |
+
*
|
2623 |
+
* @since BuddyPress (2.1.0)
|
2624 |
+
* @var array $args {
|
2625 |
+
* @type int $limit Maximum number of results to display. Default: 16.
|
2626 |
+
* @type bool $only_friends If true, only match the current user's friends. Default: false.
|
2627 |
+
* @type string $term The suggestion service will try to find results that contain this string.
|
2628 |
+
* Mandatory.
|
2629 |
+
* }
|
2630 |
+
*/
|
2631 |
+
protected $default_args = array(
|
2632 |
+
'limit' => 10,
|
2633 |
+
'only_friends' => false,
|
2634 |
+
'term' => '',
|
2635 |
+
'type' => '',
|
2636 |
+
);
|
2637 |
+
|
2638 |
+
|
2639 |
+
/**
|
2640 |
+
* Validate and sanitise the parameters for the suggestion service query.
|
2641 |
+
*
|
2642 |
+
* @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool).
|
2643 |
+
* @since BuddyPress (2.1.0)
|
2644 |
+
*/
|
2645 |
+
public function validate() {
|
2646 |
+
$this->args['only_friends'] = (bool) $this->args['only_friends'];
|
2647 |
+
$this->args = apply_filters( 'bp_members_suggestions_args', $this->args, $this );
|
2648 |
+
|
2649 |
+
// Check for invalid or missing mandatory parameters.
|
2650 |
+
if ( $this->args['only_friends'] && ( ! bp_is_active( 'friends' ) || ! is_user_logged_in() ) ) {
|
2651 |
+
return new WP_Error( 'missing_requirement' );
|
2652 |
+
}
|
2653 |
+
|
2654 |
+
return apply_filters( 'bp_members_suggestions_validate_args', parent::validate(), $this );
|
2655 |
+
}
|
2656 |
+
|
2657 |
+
/**
|
2658 |
+
* Find and return a list of username suggestions that match the query.
|
2659 |
+
*
|
2660 |
+
* @return array|WP_Error Array of results. If there were problems, returns a WP_Error object.
|
2661 |
+
* @since BuddyPress (2.1.0)
|
2662 |
+
*/
|
2663 |
+
public function get_suggestions() {
|
2664 |
+
$user_query = array(
|
2665 |
+
'count_total' => '', // Prevents total count
|
2666 |
+
'populate_extras' => false,
|
2667 |
+
'type' => 'alphabetical',
|
2668 |
+
|
2669 |
+
'page' => 1,
|
2670 |
+
'per_page' => $this->args['limit'],
|
2671 |
+
'search_terms' => $this->args['term'],
|
2672 |
+
'search_wildcard' => is_rtl() ? 'left' : 'right',
|
2673 |
+
);
|
2674 |
+
|
2675 |
+
// Only return matches of friends of this user.
|
2676 |
+
if ( $this->args['only_friends'] && is_user_logged_in() ) {
|
2677 |
+
$user_query['user_id'] = get_current_user_id();
|
2678 |
+
}
|
2679 |
+
|
2680 |
+
$user_query = apply_filters( 'bp_members_suggestions_query_args', $user_query, $this );
|
2681 |
+
if ( is_wp_error( $user_query ) ) {
|
2682 |
+
return $user_query;
|
2683 |
+
}
|
2684 |
+
|
2685 |
+
|
2686 |
+
$user_query = new BP_User_Query( $user_query );
|
2687 |
+
$results = array();
|
2688 |
+
|
2689 |
+
foreach ( $user_query->results as $user ) {
|
2690 |
+
$result = new stdClass();
|
2691 |
+
$result->ID = $user->user_nicename;
|
2692 |
+
$result->image = bp_core_fetch_avatar( array( 'html' => false, 'item_id' => $user->ID ) );
|
2693 |
+
$result->name = bp_core_get_user_displayname( $user->ID );
|
2694 |
+
|
2695 |
+
$results[] = $result;
|
2696 |
+
}
|
2697 |
+
|
2698 |
+
return apply_filters( 'bp_members_suggestions_get_suggestions', $results, $this );
|
2699 |
+
}
|
2700 |
+
}
|
@@ -292,31 +292,30 @@ class BP_Component {
|
|
292 |
public function includes( $includes = array() ) {
|
293 |
|
294 |
// Bail if no files to include
|
295 |
-
if ( empty( $includes ) )
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
break;
|
320 |
}
|
321 |
}
|
322 |
}
|
@@ -338,6 +337,9 @@ class BP_Component {
|
|
338 |
// Setup globals
|
339 |
add_action( 'bp_setup_globals', array( $this, 'setup_globals' ), 10 );
|
340 |
|
|
|
|
|
|
|
341 |
// Include required files. Called early to ensure that BP core
|
342 |
// components are loaded before plugins that hook their loader functions
|
343 |
// to bp_include with the default priority of 10. This is for backwards
|
@@ -379,6 +381,13 @@ class BP_Component {
|
|
379 |
do_action( 'bp_' . $this->id . '_setup_actions' );
|
380 |
}
|
381 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
/**
|
383 |
* Set up component navigation.
|
384 |
*
|
@@ -426,12 +435,14 @@ class BP_Component {
|
|
426 |
public function setup_admin_bar( $wp_admin_nav = array() ) {
|
427 |
|
428 |
// Bail if this is an ajax request
|
429 |
-
if ( defined( 'DOING_AJAX' ) )
|
430 |
return;
|
|
|
431 |
|
432 |
// Do not proceed if BP_USE_WP_ADMIN_BAR constant is not set or is false
|
433 |
-
if ( !bp_use_wp_admin_bar() )
|
434 |
return;
|
|
|
435 |
|
436 |
// Filter the passed admin nav
|
437 |
$wp_admin_nav = apply_filters( 'bp_' . $this->id . '_admin_nav', $wp_admin_nav );
|
292 |
public function includes( $includes = array() ) {
|
293 |
|
294 |
// Bail if no files to include
|
295 |
+
if ( ! empty( $includes ) ) {
|
296 |
+
$slashed_path = trailingslashit( $this->path );
|
297 |
+
|
298 |
+
// Loop through files to be included
|
299 |
+
foreach ( (array) $includes as $file ) {
|
300 |
+
|
301 |
+
$paths = array(
|
302 |
+
|
303 |
+
// Passed with no extension
|
304 |
+
'bp-' . $this->id . '/bp-' . $this->id . '-' . $file . '.php',
|
305 |
+
'bp-' . $this->id . '-' . $file . '.php',
|
306 |
+
'bp-' . $this->id . '/' . $file . '.php',
|
307 |
+
|
308 |
+
// Passed with extension
|
309 |
+
$file,
|
310 |
+
'bp-' . $this->id . '-' . $file,
|
311 |
+
'bp-' . $this->id . '/' . $file,
|
312 |
+
);
|
313 |
+
|
314 |
+
foreach ( $paths as $path ) {
|
315 |
+
if ( @is_file( $slashed_path . $path ) ) {
|
316 |
+
require( $slashed_path . $path );
|
317 |
+
break;
|
318 |
+
}
|
|
|
319 |
}
|
320 |
}
|
321 |
}
|
337 |
// Setup globals
|
338 |
add_action( 'bp_setup_globals', array( $this, 'setup_globals' ), 10 );
|
339 |
|
340 |
+
// Set up canonical stack
|
341 |
+
add_action( 'bp_setup_canonical_stack', array( $this, 'setup_canonical_stack' ), 10 );
|
342 |
+
|
343 |
// Include required files. Called early to ensure that BP core
|
344 |
// components are loaded before plugins that hook their loader functions
|
345 |
// to bp_include with the default priority of 10. This is for backwards
|
381 |
do_action( 'bp_' . $this->id . '_setup_actions' );
|
382 |
}
|
383 |
|
384 |
+
/**
|
385 |
+
* Set up the canonical URL stack for this component.
|
386 |
+
*
|
387 |
+
* @since BuddyPress (2.1.0)
|
388 |
+
*/
|
389 |
+
public function setup_canonical_stack() {}
|
390 |
+
|
391 |
/**
|
392 |
* Set up component navigation.
|
393 |
*
|
435 |
public function setup_admin_bar( $wp_admin_nav = array() ) {
|
436 |
|
437 |
// Bail if this is an ajax request
|
438 |
+
if ( defined( 'DOING_AJAX' ) ) {
|
439 |
return;
|
440 |
+
}
|
441 |
|
442 |
// Do not proceed if BP_USE_WP_ADMIN_BAR constant is not set or is false
|
443 |
+
if ( ! bp_use_wp_admin_bar() ) {
|
444 |
return;
|
445 |
+
}
|
446 |
|
447 |
// Filter the passed admin nav
|
448 |
$wp_admin_nav = apply_filters( 'bp_' . $this->id . '_admin_nav', $wp_admin_nav );
|
@@ -9,6 +9,64 @@
|
|
9 |
// Exit if accessed directly
|
10 |
if ( !defined( 'ABSPATH' ) ) exit;
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Load the JS for "Are you sure?" .confirm links.
|
14 |
*/
|
@@ -17,15 +75,14 @@ function bp_core_confirmation_js() {
|
|
17 |
return false;
|
18 |
}
|
19 |
|
20 |
-
|
21 |
-
wp_enqueue_script( 'bp-confirm', buddypress()->plugin_url . "bp-core/js/confirm{$min}.js", array( 'jquery' ), bp_get_version() );
|
22 |
|
23 |
wp_localize_script( 'bp-confirm', 'BP_Confirm', array(
|
24 |
'are_you_sure' => __( 'Are you sure?', 'buddypress' ),
|
25 |
) );
|
26 |
|
27 |
}
|
28 |
-
add_action( '
|
29 |
add_action( 'admin_enqueue_scripts', 'bp_core_confirmation_js' );
|
30 |
|
31 |
/**
|
@@ -45,10 +102,11 @@ function bp_core_add_cropper_inline_js() {
|
|
45 |
|
46 |
// Bail if no image was uploaded
|
47 |
$image = apply_filters( 'bp_inline_cropper_image', getimagesize( bp_core_avatar_upload_path() . buddypress()->avatar_admin->image->dir ) );
|
48 |
-
if ( empty( $image ) )
|
49 |
return;
|
|
|
50 |
|
51 |
-
//
|
52 |
$full_height = bp_core_avatar_full_height();
|
53 |
$full_width = bp_core_avatar_full_width();
|
54 |
|
@@ -60,21 +118,52 @@ function bp_core_add_cropper_inline_js() {
|
|
60 |
}
|
61 |
|
62 |
// Default cropper coordinates
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
<script type="text/javascript">
|
69 |
jQuery(window).load( function(){
|
70 |
jQuery('#avatar-to-crop').Jcrop({
|
71 |
onChange: showPreview,
|
72 |
-
onSelect: showPreview,
|
73 |
onSelect: updateCoords,
|
74 |
-
aspectRatio: <?php echo $aspect_ratio; ?>,
|
75 |
-
setSelect: [ <?php echo $crop_left; ?>, <?php echo $crop_top; ?>, <?php echo $crop_right; ?>, <?php echo $crop_bottom; ?> ]
|
76 |
});
|
77 |
-
updateCoords({x: <?php echo $crop_left; ?>, y: <?php echo $crop_top; ?>, w: <?php echo $crop_right; ?>, h: <?php echo $crop_bottom; ?>});
|
78 |
});
|
79 |
|
80 |
function updateCoords(c) {
|
@@ -86,14 +175,14 @@ function bp_core_add_cropper_inline_js() {
|
|
86 |
|
87 |
function showPreview(coords) {
|
88 |
if ( parseInt(coords.w) > 0 ) {
|
89 |
-
var fw = <?php echo $full_width; ?>;
|
90 |
-
var fh = <?php echo $full_height; ?>;
|
91 |
var rx = fw / coords.w;
|
92 |
var ry = fh / coords.h;
|
93 |
|
94 |
jQuery( '#avatar-crop-preview' ).css({
|
95 |
-
width: Math.round(rx * <?php echo $image[0]; ?>) + 'px',
|
96 |
-
height: Math.round(ry * <?php echo $image[1]; ?>) + 'px',
|
97 |
marginLeft: '-' + Math.round(rx * coords.x) + 'px',
|
98 |
marginTop: '-' + Math.round(ry * coords.y) + 'px'
|
99 |
});
|
@@ -153,3 +242,23 @@ add_action( 'wp_head', 'bp_core_add_ajax_url_js' );
|
|
153 |
function bp_core_ajax_url() {
|
154 |
return apply_filters( 'bp_core_ajax_url', admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ) );
|
155 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
// Exit if accessed directly
|
10 |
if ( !defined( 'ABSPATH' ) ) exit;
|
11 |
|
12 |
+
/**
|
13 |
+
* Register scripts commonly used by BuddyPress.
|
14 |
+
*
|
15 |
+
* @since BuddyPress (2.1.0)
|
16 |
+
*/
|
17 |
+
function bp_core_register_common_scripts() {
|
18 |
+
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
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 );
|
40 |
+
add_action( 'bp_admin_enqueue_scripts', 'bp_core_register_common_scripts', 1 );
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Register styles commonly used by BuddyPress.
|
44 |
+
*
|
45 |
+
* @since BuddyPress (2.1.0)
|
46 |
+
*/
|
47 |
+
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' => apply_filters( 'bp_core_admin_bar_css', "{$url}admin-bar{$min}.css" ),
|
54 |
+
'dependencies' => array( 'admin-bar' )
|
55 |
+
)
|
56 |
+
) );
|
57 |
+
|
58 |
+
foreach ( $styles as $id => $style ) {
|
59 |
+
wp_register_style( $id, $style['file'], $style['dependencies'], bp_get_version() );
|
60 |
+
|
61 |
+
wp_style_add_data( $id, 'rtl', true );
|
62 |
+
if ( $min ) {
|
63 |
+
wp_style_add_data( $id, 'suffix', $min );
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
add_action( 'bp_enqueue_scripts', 'bp_core_register_common_styles', 1 );
|
68 |
+
add_action( 'bp_admin_enqueue_scripts', 'bp_core_register_common_styles', 1 );
|
69 |
+
|
70 |
/**
|
71 |
* Load the JS for "Are you sure?" .confirm links.
|
72 |
*/
|
75 |
return false;
|
76 |
}
|
77 |
|
78 |
+
wp_enqueue_script( 'bp-confirm' );
|
|
|
79 |
|
80 |
wp_localize_script( 'bp-confirm', 'BP_Confirm', array(
|
81 |
'are_you_sure' => __( 'Are you sure?', 'buddypress' ),
|
82 |
) );
|
83 |
|
84 |
}
|
85 |
+
add_action( 'bp_enqueue_scripts', 'bp_core_confirmation_js' );
|
86 |
add_action( 'admin_enqueue_scripts', 'bp_core_confirmation_js' );
|
87 |
|
88 |
/**
|
102 |
|
103 |
// Bail if no image was uploaded
|
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;
|
107 |
+
}
|
108 |
|
109 |
+
// Get avatar full width and height
|
110 |
$full_height = bp_core_avatar_full_height();
|
111 |
$full_width = bp_core_avatar_full_width();
|
112 |
|
118 |
}
|
119 |
|
120 |
// Default cropper coordinates
|
121 |
+
|
122 |
+
// Smaller than full-width: cropper defaults to entire image
|
123 |
+
if ( $image[0] < $full_width ) {
|
124 |
+
$crop_left = 0;
|
125 |
+
$crop_right = $image[0];
|
126 |
+
|
127 |
+
// Less than 2x full-width: cropper defaults to full-width
|
128 |
+
} else if ( $image[0] < ( $full_width * 2 ) ) {
|
129 |
+
$padding_w = round( ( $image[0] - $full_width ) / 2 );
|
130 |
+
$crop_left = $padding_w;
|
131 |
+
$crop_right = $image[0] - $padding_w;
|
132 |
+
|
133 |
+
// Larger than 2x full-width: cropper defaults to 1/2 image width
|
134 |
+
} else {
|
135 |
+
$crop_left = round( $image[0] / 4 );
|
136 |
+
$crop_right = $image[0] - $crop_left;
|
137 |
+
}
|
138 |
+
|
139 |
+
// Smaller than full-height: cropper defaults to entire image
|
140 |
+
if ( $image[1] < $full_height ) {
|
141 |
+
$crop_top = 0;
|
142 |
+
$crop_bottom = $image[1];
|
143 |
+
|
144 |
+
// Less than double full-height: cropper defaults to full-height
|
145 |
+
} else if ( $image[1] < ( $full_height * 2 ) ) {
|
146 |
+
$padding_h = round( ( $image[1] - $full_height ) / 2 );
|
147 |
+
$crop_top = $padding_h;
|
148 |
+
$crop_bottom = $image[1] - $padding_h;
|
149 |
+
|
150 |
+
// Larger than 2x full-height: cropper defaults to 1/2 image height
|
151 |
+
} else {
|
152 |
+
$crop_top = round( $image[1] / 4 );
|
153 |
+
$crop_bottom = $image[1] - $crop_top;
|
154 |
+
}
|
155 |
+
|
156 |
+
?>
|
157 |
|
158 |
<script type="text/javascript">
|
159 |
jQuery(window).load( function(){
|
160 |
jQuery('#avatar-to-crop').Jcrop({
|
161 |
onChange: showPreview,
|
|
|
162 |
onSelect: updateCoords,
|
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) {
|
175 |
|
176 |
function showPreview(coords) {
|
177 |
if ( parseInt(coords.w) > 0 ) {
|
178 |
+
var fw = <?php echo (int) $full_width; ?>;
|
179 |
+
var fh = <?php echo (int) $full_height; ?>;
|
180 |
var rx = fw / coords.w;
|
181 |
var ry = fh / coords.h;
|
182 |
|
183 |
jQuery( '#avatar-crop-preview' ).css({
|
184 |
+
width: Math.round(rx * <?php echo (int) $image[0]; ?>) + 'px',
|
185 |
+
height: Math.round(ry * <?php echo (int) $image[1]; ?>) + 'px',
|
186 |
marginLeft: '-' + Math.round(rx * coords.x) + 'px',
|
187 |
marginTop: '-' + Math.round(ry * coords.y) + 'px'
|
188 |
});
|
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 javascript dependencies for buddypress.js.
|
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 javascript dependencies.
|
254 |
+
*/
|
255 |
+
function bp_core_get_js_dependencies() {
|
256 |
+
return apply_filters( 'bp_core_get_js_dependencies', array(
|
257 |
+
'jquery',
|
258 |
+
'bp-confirm',
|
259 |
+
'bp-widget-members',
|
260 |
+
'bp-jquery-query',
|
261 |
+
'bp-jquery-cookie',
|
262 |
+
'bp-jquery-scroll-to'
|
263 |
+
) );
|
264 |
+
}
|
@@ -31,6 +31,13 @@ function bp_setup_components() {
|
|
31 |
do_action( 'bp_setup_components' );
|
32 |
}
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
/**
|
35 |
* Fire the 'bp_setup_globals' action, where plugins should initialize global settings.
|
36 |
*/
|
31 |
do_action( 'bp_setup_components' );
|
32 |
}
|
33 |
|
34 |
+
/**
|
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 |
+
|
41 |
/**
|
42 |
* Fire the 'bp_setup_globals' action, where plugins should initialize global settings.
|
43 |
*/
|
@@ -250,12 +250,18 @@ add_filter( 'bp_login_redirect', 'bp_core_login_redirect', 10, 3 );
|
|
250 |
function bp_core_filter_user_welcome_email( $welcome_email ) {
|
251 |
|
252 |
// Don't touch the email when a user is registered by the site admin
|
253 |
-
if ( is_admin() )
|
254 |
return $welcome_email;
|
|
|
|
|
|
|
|
|
|
|
255 |
|
256 |
// Don't touch the email if we don't have a custom registration template
|
257 |
-
if ( ! bp_has_custom_signup_page() )
|
258 |
return $welcome_email;
|
|
|
259 |
|
260 |
// [User Set] Replaces 'PASSWORD' in welcome email; Represents value set by user
|
261 |
return str_replace( 'PASSWORD', __( '[User Set]', 'buddypress' ), $welcome_email );
|
@@ -279,9 +285,10 @@ add_filter( 'update_welcome_user_email', 'bp_core_filter_user_welcome_email' );
|
|
279 |
*/
|
280 |
function bp_core_filter_blog_welcome_email( $welcome_email, $blog_id, $user_id, $password ) {
|
281 |
|
282 |
-
// Don't touch the email when a user is registered by the site admin
|
283 |
-
if ( is_admin() )
|
284 |
return $welcome_email;
|
|
|
285 |
|
286 |
// Don't touch the email if we don't have a custom registration template
|
287 |
if ( ! bp_has_custom_signup_page() )
|
@@ -317,7 +324,7 @@ function bp_core_activation_signup_blog_notification( $domain, $path, $title, $u
|
|
317 |
$activate_url = esc_url( $activate_url );
|
318 |
|
319 |
// Email contents
|
320 |
-
$message = sprintf( __( "
|
321 |
$subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Activate %s', 'buddypress' ), 'http://' . $domain . $path ) ) );
|
322 |
|
323 |
// Email filters
|
@@ -351,6 +358,32 @@ add_filter( 'wpmu_signup_blog_notification', 'bp_core_activation_signup_blog_not
|
|
351 |
*/
|
352 |
function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {
|
353 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
// Set up activation link
|
355 |
$activate_url = bp_get_activation_page() . "?key=$key";
|
356 |
$activate_url = esc_url( $activate_url );
|
@@ -503,7 +536,7 @@ function bp_setup_nav_menu_item( $menu_item ) {
|
|
503 |
if ( is_user_logged_in() ) {
|
504 |
$menu_item->_invalid = true;
|
505 |
} else {
|
506 |
-
$menu_item->url = wp_login_url(
|
507 |
}
|
508 |
|
509 |
break;
|
@@ -512,7 +545,7 @@ function bp_setup_nav_menu_item( $menu_item ) {
|
|
512 |
if ( ! is_user_logged_in() ) {
|
513 |
$menu_item->_invalid = true;
|
514 |
} else {
|
515 |
-
$menu_item->url = wp_logout_url(
|
516 |
}
|
517 |
|
518 |
break;
|
250 |
function bp_core_filter_user_welcome_email( $welcome_email ) {
|
251 |
|
252 |
// Don't touch the email when a user is registered by the site admin
|
253 |
+
if ( ( is_admin() || is_network_admin() ) && buddypress()->members->admin->signups_page != get_current_screen()->id ) {
|
254 |
return $welcome_email;
|
255 |
+
}
|
256 |
+
|
257 |
+
if ( strpos( bp_get_requested_url(), 'wp-activate.php' ) !== false ) {
|
258 |
+
return $welcome_email;
|
259 |
+
}
|
260 |
|
261 |
// Don't touch the email if we don't have a custom registration template
|
262 |
+
if ( ! bp_has_custom_signup_page() ) {
|
263 |
return $welcome_email;
|
264 |
+
}
|
265 |
|
266 |
// [User Set] Replaces 'PASSWORD' in welcome email; Represents value set by user
|
267 |
return str_replace( 'PASSWORD', __( '[User Set]', 'buddypress' ), $welcome_email );
|
285 |
*/
|
286 |
function bp_core_filter_blog_welcome_email( $welcome_email, $blog_id, $user_id, $password ) {
|
287 |
|
288 |
+
// Don't touch the email when a user is registered by the site admin
|
289 |
+
if ( ( is_admin() || is_network_admin() ) && buddypress()->members->admin->signups_page != get_current_screen()->id ) {
|
290 |
return $welcome_email;
|
291 |
+
}
|
292 |
|
293 |
// Don't touch the email if we don't have a custom registration template
|
294 |
if ( ! bp_has_custom_signup_page() )
|
324 |
$activate_url = esc_url( $activate_url );
|
325 |
|
326 |
// Email contents
|
327 |
+
$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}" ) );
|
328 |
$subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Activate %s', 'buddypress' ), 'http://' . $domain . $path ) ) );
|
329 |
|
330 |
// Email filters
|
358 |
*/
|
359 |
function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {
|
360 |
|
361 |
+
if ( is_admin() ) {
|
362 |
+
// If the user is created from the WordPress Add User screen, don't send BuddyPress signup notifications
|
363 |
+
if( in_array( get_current_screen()->id, array( 'user', 'user-network' ) ) ) {
|
364 |
+
// If the Super Admin want to skip confirmation email
|
365 |
+
if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
|
366 |
+
return false;
|
367 |
+
|
368 |
+
// WordPress will manage the signup process
|
369 |
+
} else {
|
370 |
+
return $user;
|
371 |
+
}
|
372 |
+
|
373 |
+
/**
|
374 |
+
* There can be a case where the user was created without the skip confirmation
|
375 |
+
* And the super admin goes in pending accounts to resend it. In this case, as the
|
376 |
+
* meta['password'] is not set, the activation url must be WordPress one
|
377 |
+
*/
|
378 |
+
} else if ( buddypress()->members->admin->signups_page == get_current_screen()->id ) {
|
379 |
+
$is_hashpass_in_meta = maybe_unserialize( $meta );
|
380 |
+
|
381 |
+
if ( empty( $is_hashpass_in_meta['password'] ) ) {
|
382 |
+
return $user;
|
383 |
+
}
|
384 |
+
}
|
385 |
+
}
|
386 |
+
|
387 |
// Set up activation link
|
388 |
$activate_url = bp_get_activation_page() . "?key=$key";
|
389 |
$activate_url = esc_url( $activate_url );
|
536 |
if ( is_user_logged_in() ) {
|
537 |
$menu_item->_invalid = true;
|
538 |
} else {
|
539 |
+
$menu_item->url = wp_login_url( bp_get_requested_url() );
|
540 |
}
|
541 |
|
542 |
break;
|
545 |
if ( ! is_user_logged_in() ) {
|
546 |
$menu_item->_invalid = true;
|
547 |
} else {
|
548 |
+
$menu_item->url = wp_logout_url( bp_get_requested_url() );
|
549 |
}
|
550 |
|
551 |
break;
|
@@ -146,11 +146,12 @@ function bp_alpha_sort_by_key( $items, $key ) {
|
|
146 |
* @param bool $decimals Whether to use decimals. See {@link number_format_i18n()}.
|
147 |
* @return string The formatted number.
|
148 |
*/
|
149 |
-
function bp_core_number_format( $number, $decimals = false ) {
|
150 |
|
151 |
// Force number to 0 if needed
|
152 |
-
if (
|
153 |
$number = 0;
|
|
|
154 |
|
155 |
return apply_filters( 'bp_core_number_format', number_format_i18n( $number, $decimals ), $number, $decimals );
|
156 |
}
|
@@ -264,6 +265,32 @@ function bp_esc_sql_order( $order = '' ) {
|
|
264 |
return 'DESC' === $order ? 'DESC' : 'ASC';
|
265 |
}
|
266 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
/**
|
268 |
* Are we running username compatibility mode?
|
269 |
*
|
@@ -289,25 +316,49 @@ function bp_is_username_compatibility_mode() {
|
|
289 |
*
|
290 |
* @uses apply_filters() Filter 'bp_use_wp_admin_bar' to alter.
|
291 |
*
|
292 |
-
* @return bool False when WP Toolbar support is disabled
|
293 |
-
* Default: true.
|
294 |
*/
|
295 |
function bp_use_wp_admin_bar() {
|
|
|
|
|
296 |
$use_admin_bar = true;
|
297 |
|
298 |
-
// Has the WP Toolbar constant been explicity
|
299 |
-
if ( defined( 'BP_USE_WP_ADMIN_BAR' )
|
300 |
-
$use_admin_bar =
|
301 |
|
302 |
-
//
|
303 |
-
elseif ( (
|
304 |
$use_admin_bar = false;
|
|
|
305 |
|
306 |
-
return apply_filters( 'bp_use_wp_admin_bar', $use_admin_bar );
|
307 |
}
|
308 |
|
309 |
/** Directory *****************************************************************/
|
310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
/**
|
312 |
* Fetch a list of BP directory pages from the appropriate meta table.
|
313 |
*
|
@@ -428,14 +479,16 @@ function bp_core_add_page_mappings( $components, $existing = 'keep' ) {
|
|
428 |
return;
|
429 |
}
|
430 |
|
431 |
-
// Make sure that the pages are created on the root blog no matter which
|
432 |
-
|
|
|
433 |
switch_to_blog( bp_get_root_blog_id() );
|
|
|
434 |
|
435 |
$pages = bp_core_get_directory_page_ids();
|
436 |
|
437 |
// Delete any existing pages
|
438 |
-
if ( 'delete'
|
439 |
foreach ( (array) $pages as $page_id ) {
|
440 |
wp_delete_post( $page_id, true );
|
441 |
}
|
@@ -444,11 +497,11 @@ function bp_core_add_page_mappings( $components, $existing = 'keep' ) {
|
|
444 |
}
|
445 |
|
446 |
$page_titles = array(
|
447 |
-
'activity' => _x( 'Activity', 'Page title for the Activity directory.',
|
448 |
-
'groups' => _x( 'Groups',
|
449 |
-
'sites' => _x( 'Sites',
|
450 |
-
'
|
451 |
-
'
|
452 |
'register' => _x( 'Register', 'Page title for the user registration screen.', 'buddypress' ),
|
453 |
);
|
454 |
|
@@ -481,21 +534,29 @@ function bp_core_add_page_mappings( $components, $existing = 'keep' ) {
|
|
481 |
|
482 |
// Create the pages
|
483 |
foreach ( $pages_to_create as $component_name => $page_name ) {
|
484 |
-
$
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
}
|
492 |
|
493 |
// Save the page mapping
|
494 |
bp_update_option( 'bp-pages', $pages );
|
495 |
|
496 |
// If we had to switch_to_blog, go back to the original site.
|
497 |
-
if ( ! bp_is_root_blog() )
|
498 |
restore_current_blog();
|
|
|
499 |
}
|
500 |
|
501 |
/**
|
@@ -561,7 +622,9 @@ function bp_core_add_root_component( $slug ) {
|
|
561 |
|
562 |
// If there was no match, add a page for this root component
|
563 |
if ( empty( $match ) ) {
|
564 |
-
$bp->add_root
|
|
|
|
|
565 |
}
|
566 |
|
567 |
// Make sure that this component is registered as requiring a top-level directory
|
@@ -663,13 +726,14 @@ function bp_core_get_root_domain() {
|
|
663 |
* @param int $status Optional. The numeric code to give in the redirect
|
664 |
* headers. Default: 302.
|
665 |
*/
|
666 |
-
function bp_core_redirect( $location, $status = 302 ) {
|
667 |
|
668 |
// On some setups, passing the value of wp_get_referer() may result in an
|
669 |
// empty value for $location, which results in an error. Ensure that we
|
670 |
// have a valid URL.
|
671 |
-
if ( empty( $location ) )
|
672 |
$location = bp_get_root_domain();
|
|
|
673 |
|
674 |
// Make sure we don't call status_header() in bp_core_do_catch_uri() as this
|
675 |
// conflicts with wp_redirect() and wp_safe_redirect().
|
@@ -700,23 +764,24 @@ function bp_core_referrer() {
|
|
700 |
function bp_core_get_site_path() {
|
701 |
global $current_site;
|
702 |
|
703 |
-
if ( is_multisite() )
|
704 |
$site_path = $current_site->path;
|
705 |
-
else {
|
706 |
$site_path = (array) explode( '/', home_url() );
|
707 |
|
708 |
-
if ( count( $site_path ) < 2 )
|
709 |
$site_path = '/';
|
710 |
-
else {
|
711 |
// Unset the first three segments (http(s)://domain.com part)
|
712 |
unset( $site_path[0] );
|
713 |
unset( $site_path[1] );
|
714 |
unset( $site_path[2] );
|
715 |
|
716 |
-
if ( !count( $site_path ) )
|
717 |
$site_path = '/';
|
718 |
-
else
|
719 |
$site_path = '/' . implode( '/', $site_path ) . '/';
|
|
|
720 |
}
|
721 |
}
|
722 |
|
@@ -731,13 +796,12 @@ function bp_core_get_site_path() {
|
|
731 |
* @since BuddyPress (1.2.6)
|
732 |
*
|
733 |
* @param bool $gmt True to use GMT (rather than local) time. Default: true.
|
|
|
|
|
734 |
* @return string Current time in 'Y-m-d h:i:s' format.
|
735 |
*/
|
736 |
-
function bp_core_current_time( $gmt = true ) {
|
737 |
-
|
738 |
-
$current_time = current_time( 'mysql', $gmt );
|
739 |
-
|
740 |
-
return apply_filters( 'bp_core_current_time', $current_time );
|
741 |
}
|
742 |
|
743 |
/**
|
@@ -769,7 +833,8 @@ function bp_core_current_time( $gmt = true ) {
|
|
769 |
function bp_core_time_since( $older_date, $newer_date = false ) {
|
770 |
|
771 |
// Use this filter to bypass BuddyPress's time_since calculations
|
772 |
-
|
|
|
773 |
return $pre_value;
|
774 |
}
|
775 |
|
@@ -800,7 +865,7 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
|
|
800 |
* a date and the current time. $newer_date will have a value if we want to
|
801 |
* work out time elapsed between two known dates.
|
802 |
*/
|
803 |
-
$newer_date = ( !$newer_date ) ?
|
804 |
|
805 |
// Difference in seconds
|
806 |
$since = $newer_date - $older_date;
|
@@ -1022,18 +1087,26 @@ function bp_core_render_message() {
|
|
1022 |
*/
|
1023 |
function bp_core_record_activity() {
|
1024 |
|
1025 |
-
if
|
|
|
1026 |
return false;
|
|
|
1027 |
|
|
|
1028 |
$user_id = bp_loggedin_user_id();
|
1029 |
|
1030 |
-
if
|
|
|
1031 |
return false;
|
|
|
1032 |
|
|
|
1033 |
$activity = bp_get_user_last_activity( $user_id );
|
1034 |
|
1035 |
-
|
|
|
1036 |
$activity = strtotime( $activity );
|
|
|
1037 |
|
1038 |
// Get current time
|
1039 |
$current_time = bp_core_current_time();
|
@@ -1043,7 +1116,8 @@ function bp_core_record_activity() {
|
|
1043 |
do_action( 'bp_first_activity_for_member', $user_id );
|
1044 |
}
|
1045 |
|
1046 |
-
|
|
|
1047 |
bp_update_user_last_activity( $user_id, $current_time );
|
1048 |
}
|
1049 |
}
|
@@ -1056,16 +1130,22 @@ add_action( 'wp_head', 'bp_core_record_activity' );
|
|
1056 |
* representation of the time elapsed.
|
1057 |
*
|
1058 |
* @param int|string $last_activity_date The date of last activity.
|
1059 |
-
* @param string $string A sprintf()-able statement of the form '%
|
1060 |
* @return string $last_active A string of the form '3 years ago'.
|
1061 |
*/
|
1062 |
-
function bp_core_get_last_activity( $last_activity_date, $string ) {
|
|
|
|
|
|
|
|
|
|
|
1063 |
|
1064 |
-
if
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
|
|
|
1069 |
return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
|
1070 |
}
|
1071 |
|
@@ -1294,8 +1374,9 @@ function bp_core_do_network_admin() {
|
|
1294 |
// Default
|
1295 |
$retval = bp_is_network_activated();
|
1296 |
|
1297 |
-
if ( bp_is_multiblog_mode() )
|
1298 |
$retval = false;
|
|
|
1299 |
|
1300 |
return (bool) apply_filters( 'bp_core_do_network_admin', $retval );
|
1301 |
}
|
@@ -1334,12 +1415,14 @@ function bp_is_root_blog( $blog_id = 0 ) {
|
|
1334 |
$is_root_blog = false;
|
1335 |
|
1336 |
// Use current blog if no ID is passed
|
1337 |
-
if ( empty( $blog_id ) )
|
1338 |
$blog_id = get_current_blog_id();
|
|
|
1339 |
|
1340 |
// Compare to root blog ID
|
1341 |
-
if ( $blog_id == bp_get_root_blog_id() )
|
1342 |
$is_root_blog = true;
|
|
|
1343 |
|
1344 |
return (bool) apply_filters( 'bp_is_root_blog', (bool) $is_root_blog );
|
1345 |
}
|
@@ -1431,8 +1514,9 @@ function bp_is_network_activated() {
|
|
1431 |
$plugins = get_site_option( 'active_sitewide_plugins' );
|
1432 |
|
1433 |
// Override is_multisite() if not network activated
|
1434 |
-
if ( ! is_array( $plugins ) || ! isset( $plugins[$base] ) )
|
1435 |
$retval = false;
|
|
|
1436 |
|
1437 |
return (bool) apply_filters( 'bp_is_network_activated', $retval );
|
1438 |
}
|
@@ -1630,8 +1714,9 @@ add_action ( 'bp_core_loaded', 'bp_core_load_buddypress_textdomain' );
|
|
1630 |
*/
|
1631 |
function bp_core_action_search_site( $slug = '' ) {
|
1632 |
|
1633 |
-
if ( !bp_is_current_component( bp_get_search_slug() ) )
|
1634 |
return;
|
|
|
1635 |
|
1636 |
if ( empty( $_POST['search-terms'] ) ) {
|
1637 |
bp_core_redirect( bp_get_root_domain() );
|
@@ -1700,6 +1785,25 @@ function bp_core_print_generation_time() {
|
|
1700 |
}
|
1701 |
add_action( 'wp_footer', 'bp_core_print_generation_time' );
|
1702 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1703 |
/** Nav Menu ******************************************************************/
|
1704 |
|
1705 |
/**
|
@@ -1875,15 +1979,52 @@ function bp_nav_menu_get_item_url( $slug ) {
|
|
1875 |
return $nav_item_url;
|
1876 |
}
|
1877 |
|
|
|
|
|
1878 |
/**
|
1879 |
-
*
|
1880 |
-
*
|
1881 |
-
* @since BuddyPress (2.0.0)
|
1882 |
*
|
1883 |
-
*
|
|
|
1884 |
*
|
1885 |
-
* @
|
|
|
|
|
1886 |
*/
|
1887 |
-
function
|
1888 |
-
|
1889 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
* @param bool $decimals Whether to use decimals. See {@link number_format_i18n()}.
|
147 |
* @return string The formatted number.
|
148 |
*/
|
149 |
+
function bp_core_number_format( $number = 0, $decimals = false ) {
|
150 |
|
151 |
// Force number to 0 if needed
|
152 |
+
if ( ! is_numeric( $number ) ) {
|
153 |
$number = 0;
|
154 |
+
}
|
155 |
|
156 |
return apply_filters( 'bp_core_number_format', number_format_i18n( $number, $decimals ), $number, $decimals );
|
157 |
}
|
265 |
return 'DESC' === $order ? 'DESC' : 'ASC';
|
266 |
}
|
267 |
|
268 |
+
/**
|
269 |
+
* Escape special characters in a SQL LIKE clause.
|
270 |
+
*
|
271 |
+
* In WordPress 4.0, like_escape() was deprecated, due to incorrect
|
272 |
+
* documentation and improper sanitization leading to a history of misuse. To
|
273 |
+
* maintain compatibility with versions of WP before 4.0, we duplicate the
|
274 |
+
* logic of the replacement, wpdb::esc_like().
|
275 |
+
*
|
276 |
+
* @since BuddyPress (2.1.0)
|
277 |
+
*
|
278 |
+
* @see wpdb::esc_like() for more details on proper use.
|
279 |
+
*
|
280 |
+
* @param string $text The raw text to be escaped.
|
281 |
+
* @return string Text in the form of a LIKE phrase. Not SQL safe. Run through
|
282 |
+
* wpdb::prepare() before use.
|
283 |
+
*/
|
284 |
+
function bp_esc_like( $text ) {
|
285 |
+
global $wpdb;
|
286 |
+
|
287 |
+
if ( method_exists( $wpdb, 'esc_like' ) ) {
|
288 |
+
return $wpdb->esc_like( $text );
|
289 |
+
} else {
|
290 |
+
return addcslashes( $text, '_%\\' );
|
291 |
+
}
|
292 |
+
}
|
293 |
+
|
294 |
/**
|
295 |
* Are we running username compatibility mode?
|
296 |
*
|
316 |
*
|
317 |
* @uses apply_filters() Filter 'bp_use_wp_admin_bar' to alter.
|
318 |
*
|
319 |
+
* @return bool Default: true. False when WP Toolbar support is disabled.
|
|
|
320 |
*/
|
321 |
function bp_use_wp_admin_bar() {
|
322 |
+
|
323 |
+
// Default to true (to avoid loading deprecated BuddyBar code)
|
324 |
$use_admin_bar = true;
|
325 |
|
326 |
+
// Has the WP Toolbar constant been explicity opted into?
|
327 |
+
if ( defined( 'BP_USE_WP_ADMIN_BAR' ) ) {
|
328 |
+
$use_admin_bar = (bool) BP_USE_WP_ADMIN_BAR;
|
329 |
|
330 |
+
// ...or is the old BuddyBar being forced back into use?
|
331 |
+
} elseif ( bp_force_buddybar( false ) ) {
|
332 |
$use_admin_bar = false;
|
333 |
+
}
|
334 |
|
335 |
+
return (bool) apply_filters( 'bp_use_wp_admin_bar', $use_admin_bar );
|
336 |
}
|
337 |
|
338 |
/** Directory *****************************************************************/
|
339 |
|
340 |
+
/**
|
341 |
+
* Returns an array of core component IDs.
|
342 |
+
*
|
343 |
+
* @since BuddyPress (2.1.0)
|
344 |
+
*
|
345 |
+
* @return array
|
346 |
+
*/
|
347 |
+
function bp_core_get_packaged_component_ids() {
|
348 |
+
return array(
|
349 |
+
'activity',
|
350 |
+
'members',
|
351 |
+
'groups',
|
352 |
+
'blogs',
|
353 |
+
'xprofile',
|
354 |
+
'friends',
|
355 |
+
'messages',
|
356 |
+
'settings',
|
357 |
+
'notifications',
|
358 |
+
'forums',
|
359 |
+
);
|
360 |
+
}
|
361 |
+
|
362 |
/**
|
363 |
* Fetch a list of BP directory pages from the appropriate meta table.
|
364 |
*
|
479 |
return;
|
480 |
}
|
481 |
|
482 |
+
// Make sure that the pages are created on the root blog no matter which
|
483 |
+
// dashboard the setup is being run on.
|
484 |
+
if ( ! bp_is_root_blog() ) {
|
485 |
switch_to_blog( bp_get_root_blog_id() );
|
486 |
+
}
|
487 |
|
488 |
$pages = bp_core_get_directory_page_ids();
|
489 |
|
490 |
// Delete any existing pages
|
491 |
+
if ( 'delete' === $existing ) {
|
492 |
foreach ( (array) $pages as $page_id ) {
|
493 |
wp_delete_post( $page_id, true );
|
494 |
}
|
497 |
}
|
498 |
|
499 |
$page_titles = array(
|
500 |
+
'activity' => _x( 'Activity', 'Page title for the Activity directory.', 'buddypress' ),
|
501 |
+
'groups' => _x( 'Groups', 'Page title for the Groups directory.', 'buddypress' ),
|
502 |
+
'sites' => _x( 'Sites', 'Page title for the Sites directory.', 'buddypress' ),
|
503 |
+
'members' => _x( 'Members', 'Page title for the Members directory.', 'buddypress' ),
|
504 |
+
'activate' => _x( 'Activate', 'Page title for the user activation screen.', 'buddypress' ),
|
505 |
'register' => _x( 'Register', 'Page title for the user registration screen.', 'buddypress' ),
|
506 |
);
|
507 |
|
534 |
|
535 |
// Create the pages
|
536 |
foreach ( $pages_to_create as $component_name => $page_name ) {
|
537 |
+
$exists = get_page_by_path( $component_name );
|
538 |
+
|
539 |
+
// If page already exists, use it
|
540 |
+
if ( ! empty( $exists ) ) {
|
541 |
+
$pages[ $component_name ] = $exists->ID;
|
542 |
+
} else {
|
543 |
+
$pages[ $component_name ] = wp_insert_post( array(
|
544 |
+
'comment_status' => 'closed',
|
545 |
+
'ping_status' => 'closed',
|
546 |
+
'post_status' => 'publish',
|
547 |
+
'post_title' => $page_name,
|
548 |
+
'post_type' => 'page',
|
549 |
+
) );
|
550 |
+
}
|
551 |
}
|
552 |
|
553 |
// Save the page mapping
|
554 |
bp_update_option( 'bp-pages', $pages );
|
555 |
|
556 |
// If we had to switch_to_blog, go back to the original site.
|
557 |
+
if ( ! bp_is_root_blog() ) {
|
558 |
restore_current_blog();
|
559 |
+
}
|
560 |
}
|
561 |
|
562 |
/**
|
622 |
|
623 |
// If there was no match, add a page for this root component
|
624 |
if ( empty( $match ) ) {
|
625 |
+
$add_root_items = $bp->add_root();
|
626 |
+
$add_root_items[] = $slug;
|
627 |
+
$bp->add_root = $add_root_items;
|
628 |
}
|
629 |
|
630 |
// Make sure that this component is registered as requiring a top-level directory
|
726 |
* @param int $status Optional. The numeric code to give in the redirect
|
727 |
* headers. Default: 302.
|
728 |
*/
|
729 |
+
function bp_core_redirect( $location = '', $status = 302 ) {
|
730 |
|
731 |
// On some setups, passing the value of wp_get_referer() may result in an
|
732 |
// empty value for $location, which results in an error. Ensure that we
|
733 |
// have a valid URL.
|
734 |
+
if ( empty( $location ) ) {
|
735 |
$location = bp_get_root_domain();
|
736 |
+
}
|
737 |
|
738 |
// Make sure we don't call status_header() in bp_core_do_catch_uri() as this
|
739 |
// conflicts with wp_redirect() and wp_safe_redirect().
|
764 |
function bp_core_get_site_path() {
|
765 |
global $current_site;
|
766 |
|
767 |
+
if ( is_multisite() ) {
|
768 |
$site_path = $current_site->path;
|
769 |
+
} else {
|
770 |
$site_path = (array) explode( '/', home_url() );
|
771 |
|
772 |
+
if ( count( $site_path ) < 2 ) {
|
773 |
$site_path = '/';
|
774 |
+
} else {
|
775 |
// Unset the first three segments (http(s)://domain.com part)
|
776 |
unset( $site_path[0] );
|
777 |
unset( $site_path[1] );
|
778 |
unset( $site_path[2] );
|
779 |
|
780 |
+
if ( !count( $site_path ) ) {
|
781 |
$site_path = '/';
|
782 |
+
} else {
|
783 |
$site_path = '/' . implode( '/', $site_path ) . '/';
|
784 |
+
}
|
785 |
}
|
786 |
}
|
787 |
|
796 |
* @since BuddyPress (1.2.6)
|
797 |
*
|
798 |
* @param bool $gmt True to use GMT (rather than local) time. Default: true.
|
799 |
+
* @param string $type See the 'type' parameter in {@link current_time()}.
|
800 |
+
Default: 'mysql'.
|
801 |
* @return string Current time in 'Y-m-d h:i:s' format.
|
802 |
*/
|
803 |
+
function bp_core_current_time( $gmt = true, $type = 'mysql' ) {
|
804 |
+
return apply_filters( 'bp_core_current_time', current_time( $type, $gmt ) );
|
|
|
|
|
|
|
805 |
}
|
806 |
|
807 |
/**
|
833 |
function bp_core_time_since( $older_date, $newer_date = false ) {
|
834 |
|
835 |
// Use this filter to bypass BuddyPress's time_since calculations
|
836 |
+
$pre_value = apply_filters( 'bp_core_time_since_pre', false, $older_date, $newer_date );
|
837 |
+
if ( false !== $pre_value ) {
|
838 |
return $pre_value;
|
839 |
}
|
840 |
|
865 |
* a date and the current time. $newer_date will have a value if we want to
|
866 |
* work out time elapsed between two known dates.
|
867 |
*/
|
868 |
+
$newer_date = ( !$newer_date ) ? bp_core_current_time( true, 'timestamp' ) : $newer_date;
|
869 |
|
870 |
// Difference in seconds
|
871 |
$since = $newer_date - $older_date;
|
1087 |
*/
|
1088 |
function bp_core_record_activity() {
|
1089 |
|
1090 |
+
// Bail if user is not logged in
|
1091 |
+
if ( ! is_user_logged_in() ) {
|
1092 |
return false;
|
1093 |
+
}
|
1094 |
|
1095 |
+
// Get the user ID
|
1096 |
$user_id = bp_loggedin_user_id();
|
1097 |
|
1098 |
+
// Bail if user is not active
|
1099 |
+
if ( bp_is_user_inactive( $user_id ) ) {
|
1100 |
return false;
|
1101 |
+
}
|
1102 |
|
1103 |
+
// Get the user's last activity
|
1104 |
$activity = bp_get_user_last_activity( $user_id );
|
1105 |
|
1106 |
+
// Make sure it's numeric
|
1107 |
+
if ( ! is_numeric( $activity ) ) {
|
1108 |
$activity = strtotime( $activity );
|
1109 |
+
}
|
1110 |
|
1111 |
// Get current time
|
1112 |
$current_time = bp_core_current_time();
|
1116 |
do_action( 'bp_first_activity_for_member', $user_id );
|
1117 |
}
|
1118 |
|
1119 |
+
// If it's been more than 5 minutes, record a newer last-activity time
|
1120 |
+
if ( empty( $activity ) || ( strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) ) ) {
|
1121 |
bp_update_user_last_activity( $user_id, $current_time );
|
1122 |
}
|
1123 |
}
|
1130 |
* representation of the time elapsed.
|
1131 |
*
|
1132 |
* @param int|string $last_activity_date The date of last activity.
|
1133 |
+
* @param string $string A sprintf()-able statement of the form 'active %s'
|
1134 |
* @return string $last_active A string of the form '3 years ago'.
|
1135 |
*/
|
1136 |
+
function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {
|
1137 |
+
|
1138 |
+
// Setup a default string if none was passed
|
1139 |
+
$string = empty( $string )
|
1140 |
+
? '%s' // Gettext placeholder
|
1141 |
+
: $string;
|
1142 |
|
1143 |
+
// Use the string if a last activity date was passed
|
1144 |
+
$last_active = empty( $last_activity_date )
|
1145 |
+
? __( 'Not recently active', 'buddypress' )
|
1146 |
+
: sprintf( $string, bp_core_time_since( $last_activity_date ) );
|
1147 |
|
1148 |
+
// Filter and return
|
1149 |
return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
|
1150 |
}
|
1151 |
|
1374 |
// Default
|
1375 |
$retval = bp_is_network_activated();
|
1376 |
|
1377 |
+
if ( bp_is_multiblog_mode() ) {
|
1378 |
$retval = false;
|
1379 |
+
}
|
1380 |
|
1381 |
return (bool) apply_filters( 'bp_core_do_network_admin', $retval );
|
1382 |
}
|
1415 |
$is_root_blog = false;
|
1416 |
|
1417 |
// Use current blog if no ID is passed
|
1418 |
+
if ( empty( $blog_id ) ) {
|
1419 |
$blog_id = get_current_blog_id();
|
1420 |
+
}
|
1421 |
|
1422 |
// Compare to root blog ID
|
1423 |
+
if ( $blog_id == bp_get_root_blog_id() ) {
|
1424 |
$is_root_blog = true;
|
1425 |
+
}
|
1426 |
|
1427 |
return (bool) apply_filters( 'bp_is_root_blog', (bool) $is_root_blog );
|
1428 |
}
|
1514 |
$plugins = get_site_option( 'active_sitewide_plugins' );
|
1515 |
|
1516 |
// Override is_multisite() if not network activated
|
1517 |
+
if ( ! is_array( $plugins ) || ! isset( $plugins[ $base ] ) ) {
|
1518 |
$retval = false;
|
1519 |
+
}
|
1520 |
|
1521 |
return (bool) apply_filters( 'bp_is_network_activated', $retval );
|
1522 |
}
|
1714 |
*/
|
1715 |
function bp_core_action_search_site( $slug = '' ) {
|
1716 |
|
1717 |
+
if ( ! bp_is_current_component( bp_get_search_slug() ) ) {
|
1718 |
return;
|
1719 |
+
}
|
1720 |
|
1721 |
if ( empty( $_POST['search-terms'] ) ) {
|
1722 |
bp_core_redirect( bp_get_root_domain() );
|
1785 |
}
|
1786 |
add_action( 'wp_footer', 'bp_core_print_generation_time' );
|
1787 |
|
1788 |
+
/**
|
1789 |
+
* Remove "prev" and "next" relational links from <head> on BuddyPress pages.
|
1790 |
+
*
|
1791 |
+
* WordPress automatically generates these relational links to the current
|
1792 |
+
* page. However, BuddyPress doesn't adhere to these links. In this
|
1793 |
+
* function, we remove these links when on a BuddyPress page. This also
|
1794 |
+
* prevents additional, unnecessary queries from running.
|
1795 |
+
*
|
1796 |
+
* @since BuddyPress (2.1.0)
|
1797 |
+
*/
|
1798 |
+
function bp_remove_adjacent_posts_rel_link() {
|
1799 |
+
if ( ! is_buddypress() ) {
|
1800 |
+
return;
|
1801 |
+
}
|
1802 |
+
|
1803 |
+
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
|
1804 |
+
}
|
1805 |
+
add_action( 'bp_init', 'bp_remove_adjacent_posts_rel_link' );
|
1806 |
+
|
1807 |
/** Nav Menu ******************************************************************/
|
1808 |
|
1809 |
/**
|
1979 |
return $nav_item_url;
|
1980 |
}
|
1981 |
|
1982 |
+
/** Suggestions***************************************************************/
|
1983 |
+
|
1984 |
/**
|
1985 |
+
* BuddyPress Suggestions API for types of at-mentions.
|
|
|
|
|
1986 |
*
|
1987 |
+
* This is used to power BuddyPress' at-mentions suggestions, but it is flexible enough to be used
|
1988 |
+
* for similar kinds of future requirements, or those implemented by third-party developers.
|
1989 |
*
|
1990 |
+
* @param array $args
|
1991 |
+
* @return array|WP_Error Array of results. If there were any problems, returns a WP_Error object.
|
1992 |
+
* @since BuddyPress (2.1.0)
|
1993 |
*/
|
1994 |
+
function bp_core_get_suggestions( $args ) {
|
1995 |
+
$args = wp_parse_args( $args );
|
1996 |
+
|
1997 |
+
if ( ! $args['type'] ) {
|
1998 |
+
return new WP_Error( 'missing_parameter' );
|
1999 |
+
}
|
2000 |
+
|
2001 |
+
// Members @name suggestions.
|
2002 |
+
if ( $args['type'] === 'members' ) {
|
2003 |
+
$class = 'BP_Members_Suggestions';
|
2004 |
+
|
2005 |
+
// Members @name suggestions for users in a specific Group.
|
2006 |
+
if ( isset( $args['group_id'] ) ) {
|
2007 |
+
$class = 'BP_Groups_Member_Suggestions';
|
2008 |
+
}
|
2009 |
+
|
2010 |
+
} else {
|
2011 |
+
// If you've built a custom suggestions service, use this to tell BP the name of your class.
|
2012 |
+
$class = apply_filters( 'bp_suggestions_services', '', $args );
|
2013 |
+
}
|
2014 |
+
|
2015 |
+
if ( ! $class || ! class_exists( $class ) ) {
|
2016 |
+
return new WP_Error( 'missing_parameter' );
|
2017 |
+
}
|
2018 |
+
|
2019 |
+
|
2020 |
+
$suggestions = new $class( $args );
|
2021 |
+
$validation = $suggestions->validate();
|
2022 |
+
|
2023 |
+
if ( is_wp_error( $validation ) ) {
|
2024 |
+
$retval = $validation;
|
2025 |
+
} else {
|
2026 |
+
$retval = $suggestions->get_suggestions();
|
2027 |
+
}
|
2028 |
+
|
2029 |
+
return apply_filters( 'bp_core_get_suggestions', $retval, $args );
|
2030 |
+
}
|
@@ -230,7 +230,7 @@ class BP_Core extends BP_Component {
|
|
230 |
|
231 |
// Add 'Profile' to the main navigation
|
232 |
$main_nav = array(
|
233 |
-
'name' =>
|
234 |
'slug' => $bp->core->profile->slug,
|
235 |
'position' => 20,
|
236 |
'screen_function' => 'bp_core_catch_profile_uri',
|
@@ -241,7 +241,7 @@ class BP_Core extends BP_Component {
|
|
241 |
|
242 |
// Add the subnav items to the profile
|
243 |
$sub_nav[] = array(
|
244 |
-
'name' =>
|
245 |
'slug' => 'public',
|
246 |
'parent_url' => $profile_link,
|
247 |
'parent_slug' => $bp->core->profile->slug,
|
@@ -263,4 +263,4 @@ class BP_Core extends BP_Component {
|
|
263 |
function bp_setup_core() {
|
264 |
buddypress()->core = new BP_Core();
|
265 |
}
|
266 |
-
add_action( '
|
230 |
|
231 |
// Add 'Profile' to the main navigation
|
232 |
$main_nav = array(
|
233 |
+
'name' => _x( 'Profile', 'Main navigation', 'buddypress' ),
|
234 |
'slug' => $bp->core->profile->slug,
|
235 |
'position' => 20,
|
236 |
'screen_function' => 'bp_core_catch_profile_uri',
|
241 |
|
242 |
// Add the subnav items to the profile
|
243 |
$sub_nav[] = array(
|
244 |
+
'name' => _x( 'View', 'Profile sub nav', 'buddypress' ),
|
245 |
'slug' => 'public',
|
246 |
'parent_url' => $profile_link,
|
247 |
'parent_slug' => $bp->core->profile->slug,
|
263 |
function bp_setup_core() {
|
264 |
buddypress()->core = new BP_Core();
|
265 |
}
|
266 |
+
add_action( 'bp_loaded', 'bp_setup_core', 0 );
|
@@ -149,8 +149,9 @@ function bp_delete_options() {
|
|
149 |
$options = bp_get_default_options();
|
150 |
|
151 |
// Add default options
|
152 |
-
foreach ( $options as $key
|
153 |
delete_option( $key );
|
|
|
154 |
|
155 |
// Allow previously activated plugins to append their own options.
|
156 |
do_action( 'bp_delete_options' );
|
@@ -173,8 +174,9 @@ function bp_setup_option_filters() {
|
|
173 |
$options = bp_get_default_options();
|
174 |
|
175 |
// Add filters to each BuddyPress option
|
176 |
-
foreach ( $options as $key
|
177 |
add_filter( 'pre_option_' . $key, 'bp_pre_get_option' );
|
|
|
178 |
|
179 |
// Allow previously activated plugins to append their own options.
|
180 |
do_action( 'bp_setup_option_filters' );
|
@@ -187,12 +189,11 @@ function bp_setup_option_filters() {
|
|
187 |
*
|
188 |
* @since BuddyPress (1.6)
|
189 |
*
|
190 |
-
* @global BuddyPress $bp
|
191 |
* @param bool $value Optional. Default value false
|
192 |
* @return mixed false if not overloaded, mixed if set
|
193 |
*/
|
194 |
function bp_pre_get_option( $value = false ) {
|
195 |
-
|
196 |
|
197 |
// Get the name of the current filter so we can manipulate it
|
198 |
$filter = current_filter();
|
@@ -201,8 +202,9 @@ function bp_pre_get_option( $value = false ) {
|
|
201 |
$option = str_replace( 'pre_option_', '', $filter );
|
202 |
|
203 |
// Check the options global for preset value
|
204 |
-
if ( !empty( $bp->options[$option] ) )
|
205 |
-
$value = $bp->options[$option];
|
|
|
206 |
|
207 |
// Always return a value, even if false
|
208 |
return $value;
|
@@ -240,6 +242,7 @@ function bp_get_option( $option_name, $default = '' ) {
|
|
240 |
*
|
241 |
* @param string $option_name The option key to be set.
|
242 |
* @param mixed $value The value to be set.
|
|
|
243 |
*/
|
244 |
function bp_add_option( $option_name, $value ) {
|
245 |
return add_blog_option( bp_get_root_blog_id(), $option_name, $value );
|
@@ -258,9 +261,10 @@ function bp_add_option( $option_name, $value ) {
|
|
258 |
*
|
259 |
* @param string $option_name The option key to be set.
|
260 |
* @param string $value The value to be set.
|
|
|
261 |
*/
|
262 |
function bp_update_option( $option_name, $value ) {
|
263 |
-
update_blog_option( bp_get_root_blog_id(), $option_name, $value );
|
264 |
}
|
265 |
|
266 |
/**
|
@@ -275,9 +279,10 @@ function bp_update_option( $option_name, $value ) {
|
|
275 |
* @uses bp_get_root_blog_id()
|
276 |
*
|
277 |
* @param string $option_name The option key to be deleted.
|
|
|
278 |
*/
|
279 |
function bp_delete_option( $option_name ) {
|
280 |
-
delete_blog_option( bp_get_root_blog_id(), $option_name );
|
281 |
}
|
282 |
|
283 |
/**
|
@@ -379,26 +384,29 @@ function bp_core_get_root_options() {
|
|
379 |
|
380 |
// Loop through options
|
381 |
foreach ( $root_blog_options as $old_meta_key => $old_meta_default ) {
|
382 |
-
// Clear out the value from the last time around
|
383 |
-
unset( $old_meta_value );
|
384 |
|
385 |
if ( isset( $existing_options[$old_meta_key] ) ) {
|
386 |
continue;
|
387 |
}
|
388 |
|
389 |
// Get old site option
|
390 |
-
if ( is_multisite() )
|
391 |
$old_meta_value = get_site_option( $old_meta_key );
|
|
|
392 |
|
393 |
// No site option so look in root blog
|
394 |
-
if ( empty( $old_meta_value ) )
|
395 |
$old_meta_value = bp_get_option( $old_meta_key, $old_meta_default );
|
|
|
396 |
|
397 |
// Update the root blog option
|
398 |
bp_update_option( $old_meta_key, $old_meta_value );
|
399 |
|
400 |
// Update the global array
|
401 |
$root_blog_options_meta[$old_meta_key] = $old_meta_value;
|
|
|
|
|
|
|
402 |
}
|
403 |
|
404 |
$root_blog_options_meta = array_merge( $root_blog_options_meta, $existing_options );
|
@@ -407,8 +415,9 @@ function bp_core_get_root_options() {
|
|
407 |
// We're all matched up
|
408 |
} else {
|
409 |
// Loop through our results and make them usable
|
410 |
-
foreach ( $root_blog_options_meta as $root_blog_option )
|
411 |
$root_blog_options[$root_blog_option->name] = $root_blog_option->value;
|
|
|
412 |
|
413 |
// Copy the options no the return val
|
414 |
$root_blog_options_meta = $root_blog_options;
|
@@ -436,7 +445,7 @@ function bp_core_get_root_options() {
|
|
436 |
* Default: true.
|
437 |
* @return bool True if profile sync is enabled, otherwise false.
|
438 |
*/
|
439 |
-
function bp_disable_profile_sync( $default =
|
440 |
return (bool) apply_filters( 'bp_disable_profile_sync', (bool) bp_get_option( 'bp-disable-profile-sync', $default ) );
|
441 |
}
|
442 |
|
149 |
$options = bp_get_default_options();
|
150 |
|
151 |
// Add default options
|
152 |
+
foreach ( array_keys( $options ) as $key ) {
|
153 |
delete_option( $key );
|
154 |
+
}
|
155 |
|
156 |
// Allow previously activated plugins to append their own options.
|
157 |
do_action( 'bp_delete_options' );
|
174 |
$options = bp_get_default_options();
|
175 |
|
176 |
// Add filters to each BuddyPress option
|
177 |
+
foreach ( array_keys( $options ) as $key ) {
|
178 |
add_filter( 'pre_option_' . $key, 'bp_pre_get_option' );
|
179 |
+
}
|
180 |
|
181 |
// Allow previously activated plugins to append their own options.
|
182 |
do_action( 'bp_setup_option_filters' );
|
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
|
194 |
*/
|
195 |
function bp_pre_get_option( $value = false ) {
|
196 |
+
$bp = buddypress();
|
197 |
|
198 |
// Get the name of the current filter so we can manipulate it
|
199 |
$filter = current_filter();
|
202 |
$option = str_replace( 'pre_option_', '', $filter );
|
203 |
|
204 |
// Check the options global for preset value
|
205 |
+
if ( ! empty( $bp->options[ $option ] ) ) {
|
206 |
+
$value = $bp->options[ $option ];
|
207 |
+
}
|
208 |
|
209 |
// Always return a value, even if false
|
210 |
return $value;
|
242 |
*
|
243 |
* @param string $option_name The option key to be set.
|
244 |
* @param mixed $value The value to be set.
|
245 |
+
* @return bool True on success, false on failure.
|
246 |
*/
|
247 |
function bp_add_option( $option_name, $value ) {
|
248 |
return add_blog_option( bp_get_root_blog_id(), $option_name, $value );
|
261 |
*
|
262 |
* @param string $option_name The option key to be set.
|
263 |
* @param string $value The value to be set.
|
264 |
+
* @return bool True on success, false on failure.
|
265 |
*/
|
266 |
function bp_update_option( $option_name, $value ) {
|
267 |
+
return update_blog_option( bp_get_root_blog_id(), $option_name, $value );
|
268 |
}
|
269 |
|
270 |
/**
|
279 |
* @uses bp_get_root_blog_id()
|
280 |
*
|
281 |
* @param string $option_name The option key to be deleted.
|
282 |
+
* @return bool True on success, false on failure.
|
283 |
*/
|
284 |
function bp_delete_option( $option_name ) {
|
285 |
+
return delete_blog_option( bp_get_root_blog_id(), $option_name );
|
286 |
}
|
287 |
|
288 |
/**
|
384 |
|
385 |
// Loop through options
|
386 |
foreach ( $root_blog_options as $old_meta_key => $old_meta_default ) {
|
|
|
|
|
387 |
|
388 |
if ( isset( $existing_options[$old_meta_key] ) ) {
|
389 |
continue;
|
390 |
}
|
391 |
|
392 |
// Get old site option
|
393 |
+
if ( is_multisite() ) {
|
394 |
$old_meta_value = get_site_option( $old_meta_key );
|
395 |
+
}
|
396 |
|
397 |
// No site option so look in root blog
|
398 |
+
if ( empty( $old_meta_value ) ) {
|
399 |
$old_meta_value = bp_get_option( $old_meta_key, $old_meta_default );
|
400 |
+
}
|
401 |
|
402 |
// Update the root blog option
|
403 |
bp_update_option( $old_meta_key, $old_meta_value );
|
404 |
|
405 |
// Update the global array
|
406 |
$root_blog_options_meta[$old_meta_key] = $old_meta_value;
|
407 |
+
|
408 |
+
// Clear out the value for the next time around
|
409 |
+
unset( $old_meta_value );
|
410 |
}
|
411 |
|
412 |
$root_blog_options_meta = array_merge( $root_blog_options_meta, $existing_options );
|
415 |
// We're all matched up
|
416 |
} else {
|
417 |
// Loop through our results and make them usable
|
418 |
+
foreach ( $root_blog_options_meta as $root_blog_option ) {
|
419 |
$root_blog_options[$root_blog_option->name] = $root_blog_option->value;
|
420 |
+
}
|
421 |
|
422 |
// Copy the options no the return val
|
423 |
$root_blog_options_meta = $root_blog_options;
|
445 |
* Default: true.
|
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 |
|
@@ -122,18 +122,17 @@ function bp_locate_template( $template_names, $load = false, $require_once = tru
|
|
122 |
*
|
123 |
* @since BuddyPress (1.7.0)
|
124 |
*
|
125 |
-
* @
|
126 |
-
*
|
127 |
-
* @param string $location Callback function that returns the stack location.
|
128 |
* @param int $priority Optional. The priority parameter as passed to
|
129 |
* add_filter(). Default: 10.
|
130 |
* @return bool See {@link add_filter()}.
|
131 |
*/
|
132 |
function bp_register_template_stack( $location_callback = '', $priority = 10 ) {
|
133 |
|
134 |
-
// Bail if no location, or function
|
135 |
-
if ( empty( $location_callback ) || !
|
136 |
return false;
|
|
|
137 |
|
138 |
// Add location callback to template stack
|
139 |
return add_filter( 'bp_template_stack', $location_callback, (int) $priority );
|
@@ -146,16 +145,17 @@ function bp_register_template_stack( $location_callback = '', $priority = 10 ) {
|
|
146 |
*
|
147 |
* @see bp_register_template_stack()
|
148 |
*
|
149 |
-
* @param string $
|
150 |
* @param int $priority Optional. The priority parameter passed to
|
151 |
* {@link bp_register_template_stack()}. Default: 10.
|
152 |
* @return bool See {@link remove_filter()}.
|
153 |
*/
|
154 |
function bp_deregister_template_stack( $location_callback = '', $priority = 10 ) {
|
155 |
|
156 |
-
// Bail if no location, or function
|
157 |
-
if ( empty( $location_callback ) || !
|
158 |
return false;
|
|
|
159 |
|
160 |
// Add location callback to template stack
|
161 |
return remove_filter( 'bp_template_stack', $location_callback, (int) $priority );
|
122 |
*
|
123 |
* @since BuddyPress (1.7.0)
|
124 |
*
|
125 |
+
* @param string $location_callback Callback function that returns the stack location.
|
|
|
|
|
126 |
* @param int $priority Optional. The priority parameter as passed to
|
127 |
* add_filter(). Default: 10.
|
128 |
* @return bool See {@link add_filter()}.
|
129 |
*/
|
130 |
function bp_register_template_stack( $location_callback = '', $priority = 10 ) {
|
131 |
|
132 |
+
// Bail if no location, or function/method is not callable
|
133 |
+
if ( empty( $location_callback ) || ! is_callable( $location_callback ) ) {
|
134 |
return false;
|
135 |
+
}
|
136 |
|
137 |
// Add location callback to template stack
|
138 |
return add_filter( 'bp_template_stack', $location_callback, (int) $priority );
|
145 |
*
|
146 |
* @see bp_register_template_stack()
|
147 |
*
|
148 |
+
* @param string $location_callback Callback function that returns the stack location.
|
149 |
* @param int $priority Optional. The priority parameter passed to
|
150 |
* {@link bp_register_template_stack()}. Default: 10.
|
151 |
* @return bool See {@link remove_filter()}.
|
152 |
*/
|
153 |
function bp_deregister_template_stack( $location_callback = '', $priority = 10 ) {
|
154 |
|
155 |
+
// Bail if no location, or function/method is not callable
|
156 |
+
if ( empty( $location_callback ) || ! is_callable( $location_callback ) ) {
|
157 |
return false;
|
158 |
+
}
|
159 |
|
160 |
// Add location callback to template stack
|
161 |
return remove_filter( 'bp_template_stack', $location_callback, (int) $priority );
|
@@ -23,18 +23,17 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|
23 |
* The function will also analyze the current action for the current component
|
24 |
* to determine whether or not to highlight a particular sub nav item.
|
25 |
*
|
26 |
-
* @global BuddyPress $bp The one true BuddyPress instance.
|
27 |
* @uses bp_get_user_nav() Renders the navigation for a profile of a currently
|
28 |
* viewed user.
|
29 |
*/
|
30 |
function bp_get_options_nav() {
|
31 |
-
|
32 |
|
33 |
-
// If we are looking at a member profile, then the we can use the current
|
34 |
-
// index. Otherwise we need to use the component's root_slug
|
35 |
$component_index = !empty( $bp->displayed_user ) ? bp_current_component() : bp_get_root_slug( bp_current_component() );
|
36 |
|
37 |
-
if ( !bp_is_single_item() ) {
|
38 |
if ( !isset( $bp->bp_options_nav[$component_index] ) || count( $bp->bp_options_nav[$component_index] ) < 1 ) {
|
39 |
return false;
|
40 |
} else {
|
@@ -50,8 +49,9 @@ function bp_get_options_nav() {
|
|
50 |
|
51 |
// Loop through each navigation item
|
52 |
foreach ( (array) $bp->bp_options_nav[$the_index] as $subnav_item ) {
|
53 |
-
if (
|
54 |
continue;
|
|
|
55 |
|
56 |
// If the current action or an action variable matches the nav item id, then add a highlight CSS class.
|
57 |
if ( $subnav_item['slug'] == bp_current_action() ) {
|
@@ -75,10 +75,11 @@ function bp_get_options_nav() {
|
|
75 |
* @todo Deprecate.
|
76 |
*/
|
77 |
function bp_get_options_title() {
|
78 |
-
|
79 |
|
80 |
-
if ( empty( $bp->bp_options_title ) )
|
81 |
$bp->bp_options_title = __( 'Options', 'buddypress' );
|
|
|
82 |
|
83 |
echo apply_filters( 'bp_get_options_title', esc_attr( $bp->bp_options_title ) );
|
84 |
}
|
@@ -101,7 +102,7 @@ function bp_get_directory_title( $component = '' ) {
|
|
101 |
$title = buddypress()->{$component}->directory_title;
|
102 |
|
103 |
// If none is found, concatenate
|
104 |
-
}
|
105 |
$title = sprintf( __( '%s Directory', 'buddypress' ), buddypress()->{$component}->name );
|
106 |
}
|
107 |
|
@@ -118,19 +119,10 @@ function bp_get_directory_title( $component = '' ) {
|
|
118 |
*
|
119 |
* Not currently used in BuddyPress.
|
120 |
*
|
121 |
-
* @
|
122 |
-
* @todo Deprecate.
|
123 |
-
*
|
124 |
-
* @return bool Returns true if an options avatar has been set, otherwise
|
125 |
-
* false.
|
126 |
*/
|
127 |
function bp_has_options_avatar() {
|
128 |
-
|
129 |
-
|
130 |
-
if ( empty( $bp->bp_options_avatar ) )
|
131 |
-
return false;
|
132 |
-
|
133 |
-
return true;
|
134 |
}
|
135 |
|
136 |
/**
|
@@ -141,41 +133,45 @@ function bp_has_options_avatar() {
|
|
141 |
* @todo Deprecate.
|
142 |
*/
|
143 |
function bp_get_options_avatar() {
|
144 |
-
|
145 |
-
|
146 |
-
echo apply_filters( 'bp_get_options_avatar', $bp->bp_options_avatar );
|
147 |
}
|
148 |
|
149 |
/**
|
150 |
* Output a comment author's avatar.
|
151 |
*
|
152 |
* Not currently used in BuddyPress.
|
153 |
-
*
|
154 |
-
* @todo Deprecate.
|
155 |
*/
|
156 |
function bp_comment_author_avatar() {
|
157 |
global $comment;
|
158 |
|
159 |
-
if ( function_exists( 'bp_core_fetch_avatar' ) )
|
160 |
-
echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array(
|
161 |
-
|
|
|
|
|
|
|
|
|
162 |
get_avatar();
|
|
|
163 |
}
|
164 |
|
165 |
/**
|
166 |
* Output a post author's avatar.
|
167 |
*
|
168 |
* Not currently used in BuddyPress.
|
169 |
-
*
|
170 |
-
* @todo Deprecate.
|
171 |
*/
|
172 |
function bp_post_author_avatar() {
|
173 |
global $post;
|
174 |
|
175 |
-
if ( function_exists( 'bp_core_fetch_avatar' ) )
|
176 |
-
echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array(
|
177 |
-
|
|
|
|
|
|
|
|
|
178 |
get_avatar();
|
|
|
179 |
}
|
180 |
|
181 |
/**
|
@@ -191,12 +187,10 @@ function bp_avatar_admin_step() {
|
|
191 |
* if none is found.
|
192 |
*/
|
193 |
function bp_get_avatar_admin_step() {
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
else
|
199 |
-
$step = 'upload-image';
|
200 |
|
201 |
return apply_filters( 'bp_get_avatar_admin_step', $step );
|
202 |
}
|
@@ -213,12 +207,10 @@ function bp_avatar_to_crop() {
|
|
213 |
* @return string URL of the avatar awaiting cropping.
|
214 |
*/
|
215 |
function bp_get_avatar_to_crop() {
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
$url =
|
220 |
-
else
|
221 |
-
$url = '';
|
222 |
|
223 |
return apply_filters( 'bp_get_avatar_to_crop', $url );
|
224 |
}
|
@@ -235,9 +227,7 @@ function bp_avatar_to_crop_src() {
|
|
235 |
* @return string Relative file path to the avatar.
|
236 |
*/
|
237 |
function bp_get_avatar_to_crop_src() {
|
238 |
-
|
239 |
-
|
240 |
-
return apply_filters( 'bp_get_avatar_to_crop_src', str_replace( WP_CONTENT_DIR, '', $bp->avatar_admin->image->dir ) );
|
241 |
}
|
242 |
|
243 |
/**
|
@@ -248,9 +238,9 @@ function bp_avatar_to_crop_src() {
|
|
248 |
* @todo Deprecate.
|
249 |
*/
|
250 |
function bp_avatar_cropper() {
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
}
|
255 |
|
256 |
/**
|
@@ -281,13 +271,16 @@ function bp_site_name() {
|
|
281 |
* 'date_format' and 'time_format' settings are). False on failure.
|
282 |
*/
|
283 |
function bp_format_time( $time, $just_date = false, $localize_time = true ) {
|
284 |
-
|
|
|
285 |
return false;
|
|
|
286 |
|
287 |
// Get GMT offset from root blog
|
288 |
$root_blog_offset = false;
|
289 |
-
if ( $localize_time )
|
290 |
$root_blog_offset = get_blog_option( bp_get_root_blog_id(), 'gmt_offset' );
|
|
|
291 |
|
292 |
// Calculate offset time
|
293 |
$time_offset = $time + ( $root_blog_offset * 3600 );
|
@@ -296,7 +289,7 @@ function bp_format_time( $time, $just_date = false, $localize_time = true ) {
|
|
296 |
$date = date_i18n( get_option( 'date_format' ), $time_offset );
|
297 |
|
298 |
// Should we show the time also?
|
299 |
-
if (
|
300 |
// Current time (9:50pm)
|
301 |
$time = date_i18n( get_option( 'time_format' ), $time_offset );
|
302 |
|
@@ -327,8 +320,9 @@ function bp_format_time( $time, $just_date = false, $localize_time = true ) {
|
|
327 |
*/
|
328 |
function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true ) {
|
329 |
|
330 |
-
if ( !empty( $capitalize ) )
|
331 |
$youtext = bp_core_ucfirst( $youtext );
|
|
|
332 |
|
333 |
if ( bp_displayed_user_id() == bp_loggedin_user_id() ) {
|
334 |
if ( true == $echo ) {
|
@@ -382,27 +376,32 @@ function bp_search_form_type_select() {
|
|
382 |
|
383 |
$options = array();
|
384 |
|
385 |
-
if ( bp_is_active( 'xprofile' ) )
|
386 |
-
$options['members'] =
|
|
|
387 |
|
388 |
-
if ( bp_is_active( 'groups' ) )
|
389 |
-
$options['groups'] =
|
|
|
390 |
|
391 |
-
if ( bp_is_active( 'blogs' ) && is_multisite() )
|
392 |
-
$options['blogs'] =
|
|
|
393 |
|
394 |
-
if ( bp_is_active( 'forums' ) && bp_forums_is_installed_correctly() && bp_forums_has_directory() )
|
395 |
-
$options['forums'] =
|
|
|
396 |
|
397 |
-
$options['posts'] =
|
398 |
|
399 |
// Eventually this won't be needed and a page will be built to integrate all search results.
|
400 |
-
$selection_box = '<label for="search-which" class="accessibly-hidden">' .
|
401 |
$selection_box .= '<select name="search-which" id="search-which" style="width: auto">';
|
402 |
|
403 |
$options = apply_filters( 'bp_search_form_type_select_options', $options );
|
404 |
-
foreach( (array) $options as $option_value => $option_title )
|
405 |
$selection_box .= sprintf( '<option value="%s">%s</option>', $option_value, $option_title );
|
|
|
406 |
|
407 |
$selection_box .= '</select>';
|
408 |
|
@@ -432,8 +431,9 @@ function bp_search_default_text( $component = '' ) {
|
|
432 |
function bp_get_search_default_text( $component = '' ) {
|
433 |
global $bp;
|
434 |
|
435 |
-
if ( empty( $component ) )
|
436 |
$component = bp_current_component();
|
|
|
437 |
|
438 |
$default_text = __( 'Search anything...', 'buddypress' );
|
439 |
|
@@ -446,8 +446,9 @@ function bp_search_default_text( $component = '' ) {
|
|
446 |
// name out of $bp->pages
|
447 |
if ( !empty( $bp->pages->{$component}->slug ) ) {
|
448 |
$key = $bp->pages->{$component}->slug;
|
449 |
-
if ( !empty( $bp->{$key}->search_string ) )
|
450 |
$default_text = $bp->{$key}->search_string;
|
|
|
451 |
}
|
452 |
}
|
453 |
}
|
@@ -533,32 +534,33 @@ function bp_button( $args = '' ) {
|
|
533 |
* @return string Trimmed string.
|
534 |
*/
|
535 |
function bp_create_excerpt( $text, $length = 225, $options = array() ) {
|
|
|
536 |
// Backward compatibility. The third argument used to be a boolean $filter_shortcodes
|
537 |
$filter_shortcodes_default = is_bool( $options ) ? $options : true;
|
538 |
|
539 |
-
$
|
540 |
'ending' => __( ' […]', 'buddypress' ),
|
541 |
'exact' => false,
|
542 |
'html' => true,
|
543 |
'filter_shortcodes' => $filter_shortcodes_default
|
544 |
-
);
|
545 |
-
$r = wp_parse_args( $options, $defaults );
|
546 |
-
extract( $r );
|
547 |
|
548 |
// Save the original text, to be passed along to the filter
|
549 |
$original_text = $text;
|
550 |
|
551 |
// Allow plugins to modify these values globally
|
552 |
-
$length = apply_filters( 'bp_excerpt_length',
|
553 |
-
$ending = apply_filters( 'bp_excerpt_append_text', $ending );
|
554 |
|
555 |
// Remove shortcodes if necessary
|
556 |
-
if ( !empty( $filter_shortcodes ) )
|
557 |
$text = strip_shortcodes( $text );
|
|
|
558 |
|
559 |
// When $html is true, the excerpt should be created without including HTML tags in the
|
560 |
// excerpt length
|
561 |
-
if ( !empty( $html ) ) {
|
|
|
562 |
// The text is short enough. No need to truncate
|
563 |
if ( mb_strlen( preg_replace( '/<.*?>/', '', $text ) ) <= $length ) {
|
564 |
return $text;
|
@@ -571,20 +573,22 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
|
|
571 |
// Find all the tags and put them in a stack for later use
|
572 |
preg_match_all( '/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER );
|
573 |
foreach ( $tags as $tag ) {
|
|
|
574 |
// Process tags that need to be closed
|
575 |
if ( !preg_match( '/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/s', $tag[2] ) ) {
|
576 |
if ( preg_match( '/<[\w]+[^>]*>/s', $tag[0] ) ) {
|
577 |
array_unshift( $openTags, $tag[2] );
|
578 |
-
}
|
579 |
$pos = array_search( $closeTag[1], $openTags );
|
580 |
if ( $pos !== false ) {
|
581 |
array_splice( $openTags, $pos, 1 );
|
582 |
}
|
583 |
}
|
584 |
}
|
585 |
-
$truncate .= $tag[1];
|
586 |
|
|
|
587 |
$contentLength = mb_strlen( preg_replace( '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i', ' ', $tag[3] ) );
|
|
|
588 |
if ( $contentLength + $totalLength > $length ) {
|
589 |
$left = $length - $totalLength;
|
590 |
$entitiesLength = 0;
|
@@ -618,10 +622,10 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
|
|
618 |
}
|
619 |
|
620 |
// If $exact is false, we can't break on words
|
621 |
-
if ( empty( $exact ) ) {
|
622 |
$spacepos = mb_strrpos( $truncate, ' ' );
|
623 |
if ( isset( $spacepos ) ) {
|
624 |
-
if ( $html ) {
|
625 |
$bits = mb_substr( $truncate, $spacepos );
|
626 |
preg_match_all( '/<\/([a-z]+)>/', $bits, $droppedTags, PREG_SET_ORDER );
|
627 |
if ( !empty( $droppedTags ) ) {
|
@@ -637,16 +641,15 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
|
|
637 |
}
|
638 |
$truncate .= $ending;
|
639 |
|
640 |
-
if ( $html ) {
|
641 |
foreach ( $openTags as $tag ) {
|
642 |
$truncate .= '</' . $tag . '>';
|
643 |
}
|
644 |
}
|
645 |
|
646 |
return apply_filters( 'bp_create_excerpt', $truncate, $original_text, $length, $options );
|
647 |
-
|
648 |
}
|
649 |
-
add_filter( 'bp_create_excerpt', 'stripslashes_deep'
|
650 |
add_filter( 'bp_create_excerpt', 'force_balance_tags' );
|
651 |
|
652 |
/**
|
@@ -691,14 +694,15 @@ function bp_blog_signup_allowed() {
|
|
691 |
* @return bool True if blog signup is allowed, otherwise false.
|
692 |
*/
|
693 |
function bp_get_blog_signup_allowed() {
|
694 |
-
global $bp;
|
695 |
|
696 |
-
if ( !is_multisite() )
|
697 |
return false;
|
|
|
698 |
|
699 |
-
$status =
|
700 |
-
if ( 'none'
|
701 |
return true;
|
|
|
702 |
|
703 |
return false;
|
704 |
}
|
@@ -710,9 +714,10 @@ function bp_blog_signup_allowed() {
|
|
710 |
* otherwise false.
|
711 |
*/
|
712 |
function bp_account_was_activated() {
|
713 |
-
|
714 |
-
|
715 |
-
|
|
|
716 |
|
717 |
return $activation_complete;
|
718 |
}
|
@@ -755,12 +760,12 @@ function bp_registration_needs_activation() {
|
|
755 |
*/
|
756 |
function bp_get_email_subject( $args = array() ) {
|
757 |
|
758 |
-
$r =
|
759 |
'before' => '[',
|
760 |
'after' => ']',
|
761 |
'default' => __( 'Community', 'buddypress' ),
|
762 |
'text' => ''
|
763 |
-
) );
|
764 |
|
765 |
$subject = $r['before'] . wp_specialchars_decode( bp_get_option( 'blogname', $r['default'] ), ENT_QUOTES ) . $r['after'] . ' ' . $r['text'];
|
766 |
|
@@ -781,10 +786,11 @@ function bp_get_email_subject( $args = array() ) {
|
|
781 |
* @return string The AJAX querystring.
|
782 |
*/
|
783 |
function bp_ajax_querystring( $object = false ) {
|
784 |
-
|
785 |
|
786 |
-
if ( !isset( $bp->ajax_querystring ) )
|
787 |
$bp->ajax_querystring = '';
|
|
|
788 |
|
789 |
return apply_filters( 'bp_ajax_querystring', $bp->ajax_querystring, $object );
|
790 |
}
|
@@ -797,8 +803,11 @@ function bp_ajax_querystring( $object = false ) {
|
|
797 |
* @return string Component name.
|
798 |
*/
|
799 |
function bp_current_component() {
|
800 |
-
|
801 |
-
$current_component = !empty( $bp->current_component )
|
|
|
|
|
|
|
802 |
return apply_filters( 'bp_current_component', $current_component );
|
803 |
}
|
804 |
|
@@ -808,8 +817,11 @@ function bp_current_component() {
|
|
808 |
* @return string Action name.
|
809 |
*/
|
810 |
function bp_current_action() {
|
811 |
-
|
812 |
-
$current_action = !empty( $bp->current_action )
|
|
|
|
|
|
|
813 |
return apply_filters( 'bp_current_action', $current_action );
|
814 |
}
|
815 |
|
@@ -819,8 +831,11 @@ function bp_current_action() {
|
|
819 |
* @return unknown
|
820 |
*/
|
821 |
function bp_current_item() {
|
822 |
-
|
823 |
-
$current_item = !empty( $bp->current_item )
|
|
|
|
|
|
|
824 |
return apply_filters( 'bp_current_item', $current_item );
|
825 |
}
|
826 |
|
@@ -831,8 +846,11 @@ function bp_current_item() {
|
|
831 |
* if the array is empty.
|
832 |
*/
|
833 |
function bp_action_variables() {
|
834 |
-
|
835 |
-
$action_variables = !empty( $bp->action_variables )
|
|
|
|
|
|
|
836 |
return apply_filters( 'bp_action_variables', $action_variables );
|
837 |
}
|
838 |
|
@@ -847,7 +865,9 @@ function bp_action_variables() {
|
|
847 |
*/
|
848 |
function bp_action_variable( $position = 0 ) {
|
849 |
$action_variables = bp_action_variables();
|
850 |
-
$action_variable = isset( $action_variables[$position] )
|
|
|
|
|
851 |
|
852 |
return apply_filters( 'bp_action_variable', $action_variable, $position );
|
853 |
}
|
@@ -864,9 +884,9 @@ function bp_root_domain() {
|
|
864 |
* @return string URL of the BP root blog.
|
865 |
*/
|
866 |
function bp_get_root_domain() {
|
867 |
-
|
868 |
|
869 |
-
if (
|
870 |
$domain = $bp->root_domain;
|
871 |
} else {
|
872 |
$domain = bp_core_get_root_domain();
|
@@ -913,35 +933,37 @@ function bp_root_slug( $component = '' ) {
|
|
913 |
*
|
914 |
* @since BuddyPress (1.5.0)
|
915 |
*
|
916 |
-
* @global BuddyPress $bp The one true BuddyPress instance.
|
917 |
-
*
|
918 |
* @param string $component Optional. Defaults to the current component.
|
919 |
* @return string $root_slug The root slug.
|
920 |
*/
|
921 |
function bp_get_root_slug( $component = '' ) {
|
922 |
-
|
923 |
-
|
924 |
$root_slug = '';
|
925 |
|
926 |
// Use current global component if none passed
|
927 |
-
if ( empty( $component ) )
|
928 |
$component = bp_current_component();
|
|
|
929 |
|
930 |
// Component is active
|
931 |
-
if ( !empty( $bp->active_components[$component] ) ) {
|
|
|
932 |
// Backward compatibility: in legacy plugins, the canonical component id
|
933 |
// was stored as an array value in $bp->active_components
|
934 |
-
$component_name = '1' == $bp->active_components[
|
|
|
|
|
935 |
|
936 |
// Component has specific root slug
|
937 |
-
if ( !empty( $bp->{$component_name}->root_slug ) ) {
|
938 |
$root_slug = $bp->{$component_name}->root_slug;
|
939 |
}
|
940 |
}
|
941 |
|
942 |
// No specific root slug, so fall back to component slug
|
943 |
-
if ( empty( $root_slug ) )
|
944 |
$root_slug = $component;
|
|
|
945 |
|
946 |
return apply_filters( 'bp_get_root_slug', $root_slug, $component );
|
947 |
}
|
@@ -951,25 +973,25 @@ function bp_root_slug( $component = '' ) {
|
|
951 |
*
|
952 |
* @since BuddyPress (1.5.0)
|
953 |
*
|
954 |
-
* @global BuddyPress $bp The one true BuddyPress instance.
|
955 |
-
*
|
956 |
* @param string $root_slug Needle to our active component haystack.
|
957 |
* @return mixed False if none found, component name if found.
|
958 |
*/
|
959 |
function bp_get_name_from_root_slug( $root_slug = '' ) {
|
960 |
-
|
961 |
|
962 |
// If no slug is passed, look at current_component
|
963 |
-
if ( empty( $root_slug ) )
|
964 |
$root_slug = bp_current_component();
|
|
|
965 |
|
966 |
// No current component or root slug, so flee
|
967 |
-
if ( empty( $root_slug ) )
|
968 |
return false;
|
|
|
969 |
|
970 |
// Loop through active components and look for a match
|
971 |
foreach ( array_keys( $bp->active_components ) as $component ) {
|
972 |
-
if ( ( !empty( $bp->{$component}->slug ) && ( $bp->{$component}->slug == $root_slug ) ) || ( !empty( $bp->{$component}->root_slug ) && ( $bp->{$component}->root_slug
|
973 |
return $bp->{$component}->name;
|
974 |
}
|
975 |
}
|
@@ -978,9 +1000,11 @@ function bp_get_name_from_root_slug( $root_slug = '' ) {
|
|
978 |
}
|
979 |
|
980 |
function bp_user_has_access() {
|
981 |
-
$has_access = ( bp_current_user_can( 'bp_moderate' ) || bp_is_my_profile() )
|
|
|
|
|
982 |
|
983 |
-
return apply_filters( 'bp_user_has_access', $has_access );
|
984 |
}
|
985 |
|
986 |
/**
|
@@ -1013,7 +1037,9 @@ function bp_search_slug() {
|
|
1013 |
*/
|
1014 |
function bp_displayed_user_id() {
|
1015 |
$bp = buddypress();
|
1016 |
-
$id = !empty( $bp->displayed_user->id )
|
|
|
|
|
1017 |
|
1018 |
return (int) apply_filters( 'bp_displayed_user_id', $id );
|
1019 |
}
|
@@ -1027,7 +1053,9 @@ function bp_displayed_user_id() {
|
|
1027 |
*/
|
1028 |
function bp_loggedin_user_id() {
|
1029 |
$bp = buddypress();
|
1030 |
-
$id = !empty( $bp->loggedin_user->id )
|
|
|
|
|
1031 |
|
1032 |
return (int) apply_filters( 'bp_loggedin_user_id', $id );
|
1033 |
}
|
@@ -1049,7 +1077,7 @@ function bp_loggedin_user_id() {
|
|
1049 |
* @return bool Returns true if the component matches, or else false.
|
1050 |
*/
|
1051 |
function bp_is_current_component( $component ) {
|
1052 |
-
global $
|
1053 |
|
1054 |
$is_current_component = false;
|
1055 |
|
@@ -1059,8 +1087,11 @@ function bp_is_current_component( $component ) {
|
|
1059 |
}
|
1060 |
|
1061 |
// Backward compatibility: 'xprofile' should be read as 'profile'
|
1062 |
-
if ( 'xprofile'
|
1063 |
$component = 'profile';
|
|
|
|
|
|
|
1064 |
|
1065 |
if ( ! empty( $bp->current_component ) ) {
|
1066 |
|
@@ -1081,7 +1112,7 @@ function bp_is_current_component( $component ) {
|
|
1081 |
// Next, check to see whether $component is a canonical,
|
1082 |
// non-translatable component name. If so, we can return its
|
1083 |
// corresponding slug from $bp->active_components.
|
1084 |
-
}
|
1085 |
if ( strstr( $bp->current_component, $key ) ) {
|
1086 |
$is_current_component = true;
|
1087 |
}
|
@@ -1106,13 +1137,16 @@ function bp_is_current_component( $component ) {
|
|
1106 |
// Page template fallback check if $bp->current_component is empty
|
1107 |
} elseif ( !is_admin() && is_a( $wp_query, 'WP_Query' ) && is_page() ) {
|
1108 |
global $wp_query;
|
1109 |
-
$page = $wp_query->get_queried_object();
|
1110 |
-
$custom_fields = get_post_custom_values( '_wp_page_template', $page->ID );
|
1111 |
-
$page_template = $custom_fields[0];
|
1112 |
|
1113 |
-
|
1114 |
-
if (
|
1115 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
1116 |
}
|
1117 |
}
|
1118 |
|
@@ -1137,10 +1171,7 @@ function bp_is_current_component( $component ) {
|
|
1137 |
* @return bool True if the current action matches $action.
|
1138 |
*/
|
1139 |
function bp_is_current_action( $action = '' ) {
|
1140 |
-
|
1141 |
-
return true;
|
1142 |
-
|
1143 |
-
return false;
|
1144 |
}
|
1145 |
|
1146 |
/**
|
@@ -1190,10 +1221,9 @@ function bp_is_action_variable( $action_variable = '', $position = false ) {
|
|
1190 |
* @return bool True if $item is the current item.
|
1191 |
*/
|
1192 |
function bp_is_current_item( $item = '' ) {
|
1193 |
-
|
1194 |
-
return true;
|
1195 |
|
1196 |
-
return
|
1197 |
}
|
1198 |
|
1199 |
/**
|
@@ -1202,12 +1232,14 @@ function bp_is_current_item( $item = '' ) {
|
|
1202 |
* @return bool True if looking at a single item, otherwise false.
|
1203 |
*/
|
1204 |
function bp_is_single_item() {
|
1205 |
-
|
|
|
1206 |
|
1207 |
-
if (
|
1208 |
-
|
|
|
1209 |
|
1210 |
-
return
|
1211 |
}
|
1212 |
|
1213 |
/**
|
@@ -1217,12 +1249,14 @@ function bp_is_single_item() {
|
|
1217 |
* otherwise false.
|
1218 |
*/
|
1219 |
function bp_is_item_admin() {
|
1220 |
-
|
|
|
1221 |
|
1222 |
-
if (
|
1223 |
-
|
|
|
1224 |
|
1225 |
-
return
|
1226 |
}
|
1227 |
|
1228 |
/**
|
@@ -1232,12 +1266,14 @@ function bp_is_item_admin() {
|
|
1232 |
* otherwise false.
|
1233 |
*/
|
1234 |
function bp_is_item_mod() {
|
1235 |
-
|
|
|
1236 |
|
1237 |
-
if (
|
1238 |
-
|
|
|
1239 |
|
1240 |
-
return
|
1241 |
}
|
1242 |
|
1243 |
/**
|
@@ -1247,34 +1283,47 @@ function bp_is_item_mod() {
|
|
1247 |
* false.
|
1248 |
*/
|
1249 |
function bp_is_directory() {
|
1250 |
-
|
|
|
1251 |
|
1252 |
-
if (
|
1253 |
-
|
|
|
1254 |
|
1255 |
-
return
|
1256 |
}
|
1257 |
|
1258 |
/**
|
1259 |
* Check to see if a component's URL should be in the root, not under a member page.
|
1260 |
*
|
1261 |
-
*
|
1262 |
-
*
|
|
|
|
|
|
|
1263 |
*
|
1264 |
* @return bool True if root component, else false.
|
1265 |
*/
|
1266 |
-
function bp_is_root_component( $component_name ) {
|
1267 |
-
|
|
|
1268 |
|
1269 |
-
|
1270 |
-
|
|
|
|
|
1271 |
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
|
|
|
|
|
|
|
|
|
|
1275 |
}
|
1276 |
|
1277 |
-
return
|
1278 |
}
|
1279 |
|
1280 |
/**
|
@@ -1284,26 +1333,37 @@ function bp_is_root_component( $component_name ) {
|
|
1284 |
*
|
1285 |
* @since BuddyPress (1.5.0)
|
1286 |
*
|
1287 |
-
* @global BuddyPress $bp The one true BuddyPress instance.
|
1288 |
* @global $current_blog WordPress global for the current blog.
|
1289 |
*
|
1290 |
* @param string $component Optional. Name of the component to check for.
|
1291 |
-
*
|
1292 |
* @return bool True if the specified component is set to be the site's front
|
1293 |
-
*
|
1294 |
*/
|
1295 |
function bp_is_component_front_page( $component = '' ) {
|
1296 |
-
global $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1297 |
|
1298 |
-
|
1299 |
-
|
|
|
|
|
1300 |
|
1301 |
-
|
|
|
|
|
1302 |
|
1303 |
-
if ( 'page'
|
1304 |
return false;
|
|
|
1305 |
|
1306 |
-
return apply_filters( 'bp_is_component_front_page', ( $bp->pages->{$component}->id ==
|
1307 |
}
|
1308 |
|
1309 |
/**
|
@@ -1318,13 +1378,14 @@ function bp_is_blog_page() {
|
|
1318 |
|
1319 |
$is_blog_page = false;
|
1320 |
|
1321 |
-
// Generally, we can just check to see that there's no current component.
|
1322 |
-
// is single user home tabs, where $bp->current_component
|
1323 |
-
// of the bp_is_user() check.
|
1324 |
-
if ( !bp_current_component() && !bp_is_user() )
|
1325 |
$is_blog_page = true;
|
|
|
1326 |
|
1327 |
-
return apply_filters( 'bp_is_blog_page', $is_blog_page );
|
1328 |
}
|
1329 |
|
1330 |
/**
|
@@ -1355,13 +1416,20 @@ function is_buddypress() {
|
|
1355 |
* @param string $component The component name.
|
1356 |
* @return bool True if the component is active, otherwise false.
|
1357 |
*/
|
1358 |
-
function bp_is_active( $component ) {
|
1359 |
-
|
1360 |
|
1361 |
-
|
1362 |
-
|
|
|
|
|
1363 |
|
1364 |
-
|
|
|
|
|
|
|
|
|
|
|
1365 |
}
|
1366 |
|
1367 |
/**
|
@@ -1370,10 +1438,7 @@ function bp_is_active( $component ) {
|
|
1370 |
* @return bool True if the current page is part of the Members component.
|
1371 |
*/
|
1372 |
function bp_is_members_component() {
|
1373 |
-
|
1374 |
-
return true;
|
1375 |
-
|
1376 |
-
return false;
|
1377 |
}
|
1378 |
|
1379 |
/**
|
@@ -1382,10 +1447,7 @@ function bp_is_members_component() {
|
|
1382 |
* @return bool True if the current page is part of the Profile component.
|
1383 |
*/
|
1384 |
function bp_is_profile_component() {
|
1385 |
-
|
1386 |
-
return true;
|
1387 |
-
|
1388 |
-
return false;
|
1389 |
}
|
1390 |
|
1391 |
/**
|
@@ -1394,10 +1456,7 @@ function bp_is_profile_component() {
|
|
1394 |
* @return bool True if the current page is part of the Activity component.
|
1395 |
*/
|
1396 |
function bp_is_activity_component() {
|
1397 |
-
|
1398 |
-
return true;
|
1399 |
-
|
1400 |
-
return false;
|
1401 |
}
|
1402 |
|
1403 |
/**
|
@@ -1406,10 +1465,7 @@ function bp_is_activity_component() {
|
|
1406 |
* @return bool True if the current page is part of the Blogs component.
|
1407 |
*/
|
1408 |
function bp_is_blogs_component() {
|
1409 |
-
|
1410 |
-
return true;
|
1411 |
-
|
1412 |
-
return false;
|
1413 |
}
|
1414 |
|
1415 |
/**
|
@@ -1418,10 +1474,7 @@ function bp_is_blogs_component() {
|
|
1418 |
* @return bool True if the current page is part of the Messages component.
|
1419 |
*/
|
1420 |
function bp_is_messages_component() {
|
1421 |
-
|
1422 |
-
return true;
|
1423 |
-
|
1424 |
-
return false;
|
1425 |
}
|
1426 |
|
1427 |
/**
|
@@ -1430,10 +1483,7 @@ function bp_is_messages_component() {
|
|
1430 |
* @return bool True if the current page is part of the Friends component.
|
1431 |
*/
|
1432 |
function bp_is_friends_component() {
|
1433 |
-
|
1434 |
-
return true;
|
1435 |
-
|
1436 |
-
return false;
|
1437 |
}
|
1438 |
|
1439 |
/**
|
@@ -1442,10 +1492,7 @@ function bp_is_friends_component() {
|
|
1442 |
* @return bool True if the current page is part of the Groups component.
|
1443 |
*/
|
1444 |
function bp_is_groups_component() {
|
1445 |
-
|
1446 |
-
return true;
|
1447 |
-
|
1448 |
-
return false;
|
1449 |
}
|
1450 |
|
1451 |
/**
|
@@ -1454,10 +1501,7 @@ function bp_is_groups_component() {
|
|
1454 |
* @return bool True if the current page is part of the Forums component.
|
1455 |
*/
|
1456 |
function bp_is_forums_component() {
|
1457 |
-
|
1458 |
-
return true;
|
1459 |
-
|
1460 |
-
return false;
|
1461 |
}
|
1462 |
|
1463 |
/**
|
@@ -1468,11 +1512,7 @@ function bp_is_forums_component() {
|
|
1468 |
* @return bool True if the current page is part of the Notifications component.
|
1469 |
*/
|
1470 |
function bp_is_notifications_component() {
|
1471 |
-
|
1472 |
-
return true;
|
1473 |
-
}
|
1474 |
-
|
1475 |
-
return false;
|
1476 |
}
|
1477 |
|
1478 |
/**
|
@@ -1481,10 +1521,7 @@ function bp_is_notifications_component() {
|
|
1481 |
* @return bool True if the current page is part of the Settings component.
|
1482 |
*/
|
1483 |
function bp_is_settings_component() {
|
1484 |
-
|
1485 |
-
return true;
|
1486 |
-
|
1487 |
-
return false;
|
1488 |
}
|
1489 |
|
1490 |
/**
|
@@ -1500,10 +1537,9 @@ function bp_is_settings_component() {
|
|
1500 |
* packaged components.
|
1501 |
*/
|
1502 |
function bp_is_current_component_core() {
|
1503 |
-
$retval
|
1504 |
-
$active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
|
1505 |
|
1506 |
-
foreach (
|
1507 |
if ( bp_is_current_component( $active_component ) ) {
|
1508 |
$retval = true;
|
1509 |
break;
|
@@ -1519,12 +1555,13 @@ function bp_is_current_component_core() {
|
|
1519 |
* Is the current page the activity directory ?
|
1520 |
*
|
1521 |
* @since BuddyPress (2.0.0)
|
1522 |
-
*
|
1523 |
* @return True if the current page is the activity directory.
|
1524 |
*/
|
1525 |
function bp_is_activity_directory() {
|
1526 |
-
if ( ! bp_displayed_user_id() && bp_is_activity_component() && ! bp_current_action() )
|
1527 |
return true;
|
|
|
1528 |
|
1529 |
return false;
|
1530 |
}
|
@@ -1535,10 +1572,7 @@ function bp_is_activity_directory() {
|
|
1535 |
* @return True if the current page is a single activity item permalink.
|
1536 |
*/
|
1537 |
function bp_is_single_activity() {
|
1538 |
-
|
1539 |
-
return true;
|
1540 |
-
|
1541 |
-
return false;
|
1542 |
}
|
1543 |
|
1544 |
/** User **********************************************************************/
|
@@ -1547,12 +1581,13 @@ function bp_is_single_activity() {
|
|
1547 |
* Is the current page the members directory ?
|
1548 |
*
|
1549 |
* @since BuddyPress (2.0.0)
|
1550 |
-
*
|
1551 |
* @return True if the current page is the members directory.
|
1552 |
*/
|
1553 |
function bp_is_members_directory() {
|
1554 |
-
if ( ! bp_is_user() && bp_is_members_component() )
|
1555 |
return true;
|
|
|
1556 |
|
1557 |
return false;
|
1558 |
}
|
@@ -1566,10 +1601,11 @@ function bp_is_members_directory() {
|
|
1566 |
* @return True if the current page is part of the profile of the logged-in user.
|
1567 |
*/
|
1568 |
function bp_is_my_profile() {
|
1569 |
-
if ( is_user_logged_in() && bp_loggedin_user_id() == bp_displayed_user_id() )
|
1570 |
$my_profile = true;
|
1571 |
-
else
|
1572 |
$my_profile = false;
|
|
|
1573 |
|
1574 |
return apply_filters( 'bp_is_my_profile', $my_profile );
|
1575 |
}
|
@@ -1582,10 +1618,7 @@ function bp_is_my_profile() {
|
|
1582 |
* @return True if the current page is a user page.
|
1583 |
*/
|
1584 |
function bp_is_user() {
|
1585 |
-
|
1586 |
-
return true;
|
1587 |
-
|
1588 |
-
return false;
|
1589 |
}
|
1590 |
|
1591 |
/**
|
@@ -1596,10 +1629,7 @@ function bp_is_user() {
|
|
1596 |
* @return True if the current page is a user's activity stream page.
|
1597 |
*/
|
1598 |
function bp_is_user_activity() {
|
1599 |
-
|
1600 |
-
return true;
|
1601 |
-
|
1602 |
-
return false;
|
1603 |
}
|
1604 |
|
1605 |
/**
|
@@ -1611,16 +1641,19 @@ function bp_is_user_activity() {
|
|
1611 |
*/
|
1612 |
function bp_is_user_friends_activity() {
|
1613 |
|
1614 |
-
if ( !bp_is_active( 'friends' ) )
|
1615 |
return false;
|
|
|
1616 |
|
1617 |
$slug = bp_get_friends_slug();
|
1618 |
|
1619 |
-
if ( empty( $slug ) )
|
1620 |
$slug = 'friends';
|
|
|
1621 |
|
1622 |
-
if ( bp_is_user_activity() && bp_is_current_action( $slug ) )
|
1623 |
return true;
|
|
|
1624 |
|
1625 |
return false;
|
1626 |
}
|
@@ -1634,16 +1667,17 @@ function bp_is_user_friends_activity() {
|
|
1634 |
*/
|
1635 |
function bp_is_user_groups_activity() {
|
1636 |
|
1637 |
-
if ( !bp_is_active( 'groups' ) )
|
1638 |
return false;
|
|
|
1639 |
|
1640 |
-
$slug = bp_get_groups_slug()
|
1641 |
-
|
1642 |
-
|
1643 |
-
$slug = 'groups';
|
1644 |
|
1645 |
-
if ( bp_is_user_activity() && bp_is_current_action( $slug ) )
|
1646 |
return true;
|
|
|
1647 |
|
1648 |
return false;
|
1649 |
}
|
@@ -1656,10 +1690,7 @@ function bp_is_user_groups_activity() {
|
|
1656 |
* @return True if the current page is part of a user's extended profile.
|
1657 |
*/
|
1658 |
function bp_is_user_profile() {
|
1659 |
-
|
1660 |
-
return true;
|
1661 |
-
|
1662 |
-
return false;
|
1663 |
}
|
1664 |
|
1665 |
/**
|
@@ -1670,17 +1701,11 @@ function bp_is_user_profile() {
|
|
1670 |
* @return True if the current page is a user's profile edit page.
|
1671 |
*/
|
1672 |
function bp_is_user_profile_edit() {
|
1673 |
-
|
1674 |
-
return true;
|
1675 |
-
|
1676 |
-
return false;
|
1677 |
}
|
1678 |
|
1679 |
function bp_is_user_change_avatar() {
|
1680 |
-
|
1681 |
-
return true;
|
1682 |
-
|
1683 |
-
return false;
|
1684 |
}
|
1685 |
|
1686 |
/**
|
@@ -1692,11 +1717,13 @@ function bp_is_user_change_avatar() {
|
|
1692 |
*/
|
1693 |
function bp_is_user_forums() {
|
1694 |
|
1695 |
-
if ( ! bp_is_active( 'forums' ) )
|
1696 |
return false;
|
|
|
1697 |
|
1698 |
-
if ( bp_is_user() && bp_is_forums_component() )
|
1699 |
return true;
|
|
|
1700 |
|
1701 |
return false;
|
1702 |
}
|
@@ -1711,10 +1738,7 @@ function bp_is_user_forums() {
|
|
1711 |
* @return bool True if the current page is a user's Topics Started page.
|
1712 |
*/
|
1713 |
function bp_is_user_forums_started() {
|
1714 |
-
|
1715 |
-
return true;
|
1716 |
-
|
1717 |
-
return false;
|
1718 |
}
|
1719 |
|
1720 |
/**
|
@@ -1727,10 +1751,7 @@ function bp_is_user_forums_started() {
|
|
1727 |
* @return bool True if the current page is a user's Replied To forums page.
|
1728 |
*/
|
1729 |
function bp_is_user_forums_replied_to() {
|
1730 |
-
|
1731 |
-
return true;
|
1732 |
-
|
1733 |
-
return false;
|
1734 |
}
|
1735 |
|
1736 |
/**
|
@@ -1741,10 +1762,7 @@ function bp_is_user_forums_replied_to() {
|
|
1741 |
* @return bool True if the current page is a user's Groups page.
|
1742 |
*/
|
1743 |
function bp_is_user_groups() {
|
1744 |
-
|
1745 |
-
return true;
|
1746 |
-
|
1747 |
-
return false;
|
1748 |
}
|
1749 |
|
1750 |
/**
|
@@ -1755,10 +1773,7 @@ function bp_is_user_groups() {
|
|
1755 |
* @return bool True if the current page is a user's Blogs page.
|
1756 |
*/
|
1757 |
function bp_is_user_blogs() {
|
1758 |
-
|
1759 |
-
return true;
|
1760 |
-
|
1761 |
-
return false;
|
1762 |
}
|
1763 |
|
1764 |
/**
|
@@ -1769,10 +1784,7 @@ function bp_is_user_blogs() {
|
|
1769 |
* @return bool True if the current page is a user's Recent Blog Posts page.
|
1770 |
*/
|
1771 |
function bp_is_user_recent_posts() {
|
1772 |
-
|
1773 |
-
return true;
|
1774 |
-
|
1775 |
-
return false;
|
1776 |
}
|
1777 |
|
1778 |
/**
|
@@ -1783,10 +1795,7 @@ function bp_is_user_recent_posts() {
|
|
1783 |
* @return bool True if the current page is a user's Recent Blog Comments page.
|
1784 |
*/
|
1785 |
function bp_is_user_recent_commments() {
|
1786 |
-
|
1787 |
-
return true;
|
1788 |
-
|
1789 |
-
return false;
|
1790 |
}
|
1791 |
|
1792 |
/**
|
@@ -1797,10 +1806,7 @@ function bp_is_user_recent_commments() {
|
|
1797 |
* @return bool True if the current page is a user's Friends page.
|
1798 |
*/
|
1799 |
function bp_is_user_friends() {
|
1800 |
-
|
1801 |
-
return true;
|
1802 |
-
|
1803 |
-
return false;
|
1804 |
}
|
1805 |
|
1806 |
/**
|
@@ -1811,10 +1817,7 @@ function bp_is_user_friends() {
|
|
1811 |
* @return bool True if the current page is a user's Friends Requests page.
|
1812 |
*/
|
1813 |
function bp_is_user_friend_requests() {
|
1814 |
-
|
1815 |
-
return true;
|
1816 |
-
|
1817 |
-
return false;
|
1818 |
}
|
1819 |
|
1820 |
/**
|
@@ -1827,11 +1830,7 @@ function bp_is_user_friend_requests() {
|
|
1827 |
* @return bool True if the current page is a user's Notifications page.
|
1828 |
*/
|
1829 |
function bp_is_user_notifications() {
|
1830 |
-
|
1831 |
-
return true;
|
1832 |
-
}
|
1833 |
-
|
1834 |
-
return false;
|
1835 |
}
|
1836 |
|
1837 |
/**
|
@@ -1842,10 +1841,7 @@ function bp_is_user_notifications() {
|
|
1842 |
* @return bool True if the current page is a user's Settings page.
|
1843 |
*/
|
1844 |
function bp_is_user_settings() {
|
1845 |
-
|
1846 |
-
return true;
|
1847 |
-
|
1848 |
-
return false;
|
1849 |
}
|
1850 |
|
1851 |
/**
|
@@ -1858,10 +1854,7 @@ function bp_is_user_settings() {
|
|
1858 |
* @return bool True if the current page is a user's General Settings page.
|
1859 |
*/
|
1860 |
function bp_is_user_settings_general() {
|
1861 |
-
|
1862 |
-
return true;
|
1863 |
-
|
1864 |
-
return false;
|
1865 |
}
|
1866 |
|
1867 |
/**
|
@@ -1874,10 +1867,7 @@ function bp_is_user_settings_general() {
|
|
1874 |
* @return bool True if the current page is a user's Notification Settings page.
|
1875 |
*/
|
1876 |
function bp_is_user_settings_notifications() {
|
1877 |
-
|
1878 |
-
return true;
|
1879 |
-
|
1880 |
-
return false;
|
1881 |
}
|
1882 |
|
1883 |
/**
|
@@ -1890,10 +1880,7 @@ function bp_is_user_settings_notifications() {
|
|
1890 |
* @return bool True if the current page is a user's Delete Account page.
|
1891 |
*/
|
1892 |
function bp_is_user_settings_account_delete() {
|
1893 |
-
|
1894 |
-
return true;
|
1895 |
-
|
1896 |
-
return false;
|
1897 |
}
|
1898 |
|
1899 |
/**
|
@@ -1906,10 +1893,7 @@ function bp_is_user_settings_account_delete() {
|
|
1906 |
* @return bool True if the current page is a user's Profile Settings page.
|
1907 |
*/
|
1908 |
function bp_is_user_settings_profile() {
|
1909 |
-
|
1910 |
-
return true;
|
1911 |
-
|
1912 |
-
return false;
|
1913 |
}
|
1914 |
|
1915 |
/** Groups ********************************************************************/
|
@@ -1918,12 +1902,13 @@ function bp_is_user_settings_profile() {
|
|
1918 |
* Is the current page the groups directory ?
|
1919 |
*
|
1920 |
* @since BuddyPress (2.0.0)
|
1921 |
-
*
|
1922 |
* @return True if the current page is the groups directory.
|
1923 |
*/
|
1924 |
function bp_is_groups_directory() {
|
1925 |
-
if ( bp_is_groups_component() && ! bp_current_action() && ! bp_current_item() )
|
1926 |
return true;
|
|
|
1927 |
|
1928 |
return false;
|
1929 |
}
|
@@ -1936,12 +1921,7 @@ function bp_is_groups_directory() {
|
|
1936 |
* @return bool True if the current page is part of a single group.
|
1937 |
*/
|
1938 |
function bp_is_group() {
|
1939 |
-
|
1940 |
-
|
1941 |
-
if ( bp_is_groups_component() && isset( $bp->groups->current_group ) && $bp->groups->current_group )
|
1942 |
-
return true;
|
1943 |
-
|
1944 |
-
return false;
|
1945 |
}
|
1946 |
|
1947 |
/**
|
@@ -1953,8 +1933,9 @@ function bp_is_group() {
|
|
1953 |
* @return bool True if the current page is a single group's home page.
|
1954 |
*/
|
1955 |
function bp_is_group_home() {
|
1956 |
-
if ( bp_is_single_item() && bp_is_groups_component() && ( !bp_current_action() || bp_is_current_action( 'home' ) ) )
|
1957 |
return true;
|
|
|
1958 |
|
1959 |
return false;
|
1960 |
}
|
@@ -1965,10 +1946,7 @@ function bp_is_group_home() {
|
|
1965 |
* @return bool True if the current page is part of the group creation process.
|
1966 |
*/
|
1967 |
function bp_is_group_create() {
|
1968 |
-
|
1969 |
-
return true;
|
1970 |
-
|
1971 |
-
return false;
|
1972 |
}
|
1973 |
|
1974 |
/**
|
@@ -1979,10 +1957,7 @@ function bp_is_group_create() {
|
|
1979 |
* @return bool True if the current page is part of a single group's admin.
|
1980 |
*/
|
1981 |
function bp_is_group_admin_page() {
|
1982 |
-
|
1983 |
-
return true;
|
1984 |
-
|
1985 |
-
return false;
|
1986 |
}
|
1987 |
|
1988 |
/**
|
@@ -2015,10 +1990,7 @@ function bp_is_group_forum() {
|
|
2015 |
* @return True if the current page is a group's activity page.
|
2016 |
*/
|
2017 |
function bp_is_group_activity() {
|
2018 |
-
|
2019 |
-
return true;
|
2020 |
-
|
2021 |
-
return false;
|
2022 |
}
|
2023 |
|
2024 |
/**
|
@@ -2029,10 +2001,7 @@ function bp_is_group_activity() {
|
|
2029 |
* @return bool True if the current page is part of a group forum topic.
|
2030 |
*/
|
2031 |
function bp_is_group_forum_topic() {
|
2032 |
-
|
2033 |
-
return true;
|
2034 |
-
|
2035 |
-
return false;
|
2036 |
}
|
2037 |
|
2038 |
/**
|
@@ -2043,10 +2012,7 @@ function bp_is_group_forum_topic() {
|
|
2043 |
* @return bool True if the current page is part of a group forum topic edit page.
|
2044 |
*/
|
2045 |
function bp_is_group_forum_topic_edit() {
|
2046 |
-
|
2047 |
-
return true;
|
2048 |
-
|
2049 |
-
return false;
|
2050 |
}
|
2051 |
|
2052 |
/**
|
@@ -2057,10 +2023,7 @@ function bp_is_group_forum_topic_edit() {
|
|
2057 |
* @return bool True if the current page is part of a group's Members page.
|
2058 |
*/
|
2059 |
function bp_is_group_members() {
|
2060 |
-
|
2061 |
-
return true;
|
2062 |
-
|
2063 |
-
return false;
|
2064 |
}
|
2065 |
|
2066 |
/**
|
@@ -2071,10 +2034,7 @@ function bp_is_group_members() {
|
|
2071 |
* @return bool True if the current page is a group's Send Invites page.
|
2072 |
*/
|
2073 |
function bp_is_group_invites() {
|
2074 |
-
|
2075 |
-
return true;
|
2076 |
-
|
2077 |
-
return false;
|
2078 |
}
|
2079 |
|
2080 |
/**
|
@@ -2085,10 +2045,7 @@ function bp_is_group_invites() {
|
|
2085 |
* @return bool True if the current page is a group's Request Membership page.
|
2086 |
*/
|
2087 |
function bp_is_group_membership_request() {
|
2088 |
-
|
2089 |
-
return true;
|
2090 |
-
|
2091 |
-
return false;
|
2092 |
}
|
2093 |
|
2094 |
/**
|
@@ -2097,11 +2054,7 @@ function bp_is_group_membership_request() {
|
|
2097 |
* @return bool True if the current page is a Leave Group attempt.
|
2098 |
*/
|
2099 |
function bp_is_group_leave() {
|
2100 |
-
|
2101 |
-
if ( bp_is_groups_component() && bp_is_single_item() && bp_is_current_action( 'leave-group' ) )
|
2102 |
-
return true;
|
2103 |
-
|
2104 |
-
return false;
|
2105 |
}
|
2106 |
|
2107 |
/**
|
@@ -2114,10 +2067,7 @@ function bp_is_group_leave() {
|
|
2114 |
* @return bool True if the current page is part of a single group.
|
2115 |
*/
|
2116 |
function bp_is_group_single() {
|
2117 |
-
|
2118 |
-
return true;
|
2119 |
-
|
2120 |
-
return false;
|
2121 |
}
|
2122 |
|
2123 |
/**
|
@@ -2128,22 +2078,20 @@ function bp_is_group_single() {
|
|
2128 |
* @return bool True if the current page is the Create a Blog page.
|
2129 |
*/
|
2130 |
function bp_is_create_blog() {
|
2131 |
-
|
2132 |
-
return true;
|
2133 |
-
|
2134 |
-
return false;
|
2135 |
}
|
2136 |
|
2137 |
/**
|
2138 |
* Is the current page the blogs directory ?
|
2139 |
*
|
2140 |
* @since BuddyPress (2.0.0)
|
2141 |
-
*
|
2142 |
* @return True if the current page is the blogs directory.
|
2143 |
*/
|
2144 |
function bp_is_blogs_directory() {
|
2145 |
-
if ( is_multisite() && bp_is_blogs_component() && ! bp_current_action() )
|
2146 |
return true;
|
|
|
2147 |
|
2148 |
return false;
|
2149 |
}
|
@@ -2158,10 +2106,7 @@ function bp_is_blogs_directory() {
|
|
2158 |
* @return bool True if the current page is part of a user's Messages pages.
|
2159 |
*/
|
2160 |
function bp_is_user_messages() {
|
2161 |
-
|
2162 |
-
return true;
|
2163 |
-
|
2164 |
-
return false;
|
2165 |
}
|
2166 |
|
2167 |
/**
|
@@ -2172,8 +2117,9 @@ function bp_is_user_messages() {
|
|
2172 |
* @return bool True if the current page is a user's Messages Inbox.
|
2173 |
*/
|
2174 |
function bp_is_messages_inbox() {
|
2175 |
-
if ( bp_is_user_messages() && ( !bp_current_action() || bp_is_current_action( 'inbox' ) ) )
|
2176 |
return true;
|
|
|
2177 |
|
2178 |
return false;
|
2179 |
}
|
@@ -2186,10 +2132,7 @@ function bp_is_messages_inbox() {
|
|
2186 |
* @return bool True if the current page is a user's Messages Sentbox.
|
2187 |
*/
|
2188 |
function bp_is_messages_sentbox() {
|
2189 |
-
|
2190 |
-
return true;
|
2191 |
-
|
2192 |
-
return false;
|
2193 |
}
|
2194 |
|
2195 |
/**
|
@@ -2200,10 +2143,7 @@ function bp_is_messages_sentbox() {
|
|
2200 |
* @return bool True if the current page is a user's Messages Compose screen.
|
2201 |
*/
|
2202 |
function bp_is_messages_compose_screen() {
|
2203 |
-
|
2204 |
-
return true;
|
2205 |
-
|
2206 |
-
return false;
|
2207 |
}
|
2208 |
|
2209 |
/**
|
@@ -2214,10 +2154,7 @@ function bp_is_messages_compose_screen() {
|
|
2214 |
* @return bool True if the current page is the Notices screen.
|
2215 |
*/
|
2216 |
function bp_is_notices() {
|
2217 |
-
|
2218 |
-
return true;
|
2219 |
-
|
2220 |
-
return false;
|
2221 |
}
|
2222 |
|
2223 |
/**
|
@@ -2226,10 +2163,7 @@ function bp_is_notices() {
|
|
2226 |
* @return bool True if the current page a single Messages conversation thread?
|
2227 |
*/
|
2228 |
function bp_is_messages_conversation() {
|
2229 |
-
|
2230 |
-
return true;
|
2231 |
-
|
2232 |
-
return false;
|
2233 |
}
|
2234 |
|
2235 |
/**
|
@@ -2238,10 +2172,7 @@ function bp_is_messages_conversation() {
|
|
2238 |
* @return bool
|
2239 |
*/
|
2240 |
function bp_is_single( $component, $callback ) {
|
2241 |
-
|
2242 |
-
return true;
|
2243 |
-
|
2244 |
-
return false;
|
2245 |
}
|
2246 |
|
2247 |
/** Registration **************************************************************/
|
@@ -2254,10 +2185,7 @@ function bp_is_single( $component, $callback ) {
|
|
2254 |
* @return bool True if the current page is the Activate page.
|
2255 |
*/
|
2256 |
function bp_is_activation_page() {
|
2257 |
-
|
2258 |
-
return true;
|
2259 |
-
|
2260 |
-
return false;
|
2261 |
}
|
2262 |
|
2263 |
/**
|
@@ -2268,10 +2196,7 @@ function bp_is_activation_page() {
|
|
2268 |
* @return bool True if the current page is the Register page.
|
2269 |
*/
|
2270 |
function bp_is_register_page() {
|
2271 |
-
|
2272 |
-
return true;
|
2273 |
-
|
2274 |
-
return false;
|
2275 |
}
|
2276 |
|
2277 |
/**
|
@@ -2292,125 +2217,161 @@ function bp_the_body_class() {
|
|
2292 |
|
2293 |
/** Pages *************************************************************/
|
2294 |
|
2295 |
-
if ( is_front_page() )
|
2296 |
$bp_classes[] = 'home-page';
|
|
|
2297 |
|
2298 |
-
if ( bp_is_directory() )
|
2299 |
$bp_classes[] = 'directory';
|
|
|
2300 |
|
2301 |
-
if ( bp_is_single_item() )
|
2302 |
$bp_classes[] = 'single-item';
|
|
|
2303 |
|
2304 |
/** Components ********************************************************/
|
2305 |
|
2306 |
-
if ( !bp_is_blog_page() )
|
2307 |
-
if ( bp_is_user_profile() )
|
2308 |
$bp_classes[] = 'xprofile';
|
|
|
2309 |
|
2310 |
-
if ( bp_is_activity_component() )
|
2311 |
$bp_classes[] = 'activity';
|
|
|
2312 |
|
2313 |
-
if ( bp_is_blogs_component() )
|
2314 |
$bp_classes[] = 'blogs';
|
|
|
2315 |
|
2316 |
-
if ( bp_is_messages_component() )
|
2317 |
$bp_classes[] = 'messages';
|
|
|
2318 |
|
2319 |
-
if ( bp_is_friends_component() )
|
2320 |
$bp_classes[] = 'friends';
|
|
|
2321 |
|
2322 |
-
if ( bp_is_groups_component() )
|
2323 |
$bp_classes[] = 'groups';
|
|
|
2324 |
|
2325 |
-
if ( bp_is_settings_component() )
|
2326 |
$bp_classes[] = 'settings';
|
2327 |
-
|
|
|
2328 |
|
2329 |
/** User **************************************************************/
|
2330 |
|
2331 |
-
if ( bp_is_user() )
|
2332 |
$bp_classes[] = 'bp-user';
|
|
|
2333 |
|
2334 |
-
if ( !bp_is_directory() )
|
2335 |
-
if ( bp_is_user_blogs() )
|
2336 |
$bp_classes[] = 'my-blogs';
|
|
|
2337 |
|
2338 |
-
if ( bp_is_user_groups() )
|
2339 |
$bp_classes[] = 'my-groups';
|
|
|
2340 |
|
2341 |
-
if ( bp_is_user_activity() )
|
2342 |
$bp_classes[] = 'my-activity';
|
2343 |
-
|
|
|
2344 |
|
2345 |
-
if ( bp_is_my_profile() )
|
2346 |
$bp_classes[] = 'my-account';
|
|
|
2347 |
|
2348 |
-
if ( bp_is_user_profile() )
|
2349 |
$bp_classes[] = 'my-profile';
|
|
|
2350 |
|
2351 |
-
if ( bp_is_user_friends() )
|
2352 |
$bp_classes[] = 'my-friends';
|
|
|
2353 |
|
2354 |
-
if ( bp_is_user_messages() )
|
2355 |
$bp_classes[] = 'my-messages';
|
|
|
2356 |
|
2357 |
-
if ( bp_is_user_recent_commments() )
|
2358 |
$bp_classes[] = 'recent-comments';
|
|
|
2359 |
|
2360 |
-
if ( bp_is_user_recent_posts() )
|
2361 |
$bp_classes[] = 'recent-posts';
|
|
|
2362 |
|
2363 |
-
if ( bp_is_user_change_avatar() )
|
2364 |
$bp_classes[] = 'change-avatar';
|
|
|
2365 |
|
2366 |
-
if ( bp_is_user_profile_edit() )
|
2367 |
$bp_classes[] = 'profile-edit';
|
|
|
2368 |
|
2369 |
-
if ( bp_is_user_friends_activity() )
|
2370 |
$bp_classes[] = 'friends-activity';
|
|
|
2371 |
|
2372 |
-
if ( bp_is_user_groups_activity() )
|
2373 |
$bp_classes[] = 'groups-activity';
|
|
|
2374 |
|
2375 |
/** Messages **********************************************************/
|
2376 |
|
2377 |
-
if ( bp_is_messages_inbox() )
|
2378 |
$bp_classes[] = 'inbox';
|
|
|
2379 |
|
2380 |
-
if ( bp_is_messages_sentbox() )
|
2381 |
$bp_classes[] = 'sentbox';
|
|
|
2382 |
|
2383 |
-
if ( bp_is_messages_compose_screen() )
|
2384 |
$bp_classes[] = 'compose';
|
|
|
2385 |
|
2386 |
-
if ( bp_is_notices() )
|
2387 |
$bp_classes[] = 'notices';
|
|
|
2388 |
|
2389 |
-
if ( bp_is_user_friend_requests() )
|
2390 |
$bp_classes[] = 'friend-requests';
|
|
|
2391 |
|
2392 |
-
if ( bp_is_create_blog() )
|
2393 |
$bp_classes[] = 'create-blog';
|
|
|
2394 |
|
2395 |
/** Groups ************************************************************/
|
2396 |
|
2397 |
-
if ( bp_is_group_leave() )
|
2398 |
$bp_classes[] = 'leave-group';
|
|
|
2399 |
|
2400 |
-
if ( bp_is_group_invites() )
|
2401 |
$bp_classes[] = 'group-invites';
|
|
|
2402 |
|
2403 |
-
if ( bp_is_group_members() )
|
2404 |
$bp_classes[] = 'group-members';
|
|
|
2405 |
|
2406 |
-
if ( bp_is_group_forum_topic() )
|
2407 |
$bp_classes[] = 'group-forum-topic';
|
|
|
2408 |
|
2409 |
-
if ( bp_is_group_forum_topic_edit() )
|
2410 |
$bp_classes[] = 'group-forum-topic-edit';
|
|
|
2411 |
|
2412 |
-
if ( bp_is_group_forum() )
|
2413 |
$bp_classes[] = 'group-forum';
|
|
|
2414 |
|
2415 |
if ( bp_is_group_admin_page() ) {
|
2416 |
$bp_classes[] = 'group-admin';
|
@@ -2422,23 +2383,27 @@ function bp_the_body_class() {
|
|
2422 |
$bp_classes[] = bp_get_groups_current_create_step();
|
2423 |
}
|
2424 |
|
2425 |
-
if ( bp_is_group_home() )
|
2426 |
$bp_classes[] = 'group-home';
|
|
|
2427 |
|
2428 |
-
if ( bp_is_single_activity() )
|
2429 |
$bp_classes[] = 'activity-permalink';
|
|
|
2430 |
|
2431 |
/** Registration ******************************************************/
|
2432 |
|
2433 |
-
if ( bp_is_register_page() )
|
2434 |
$bp_classes[] = 'registration';
|
|
|
2435 |
|
2436 |
-
if ( bp_is_activation_page() )
|
2437 |
$bp_classes[] = 'activation';
|
|
|
2438 |
|
2439 |
/** Current Component & Action ****************************************/
|
2440 |
|
2441 |
-
if ( !bp_is_blog_page() ) {
|
2442 |
$bp_classes[] = bp_current_component();
|
2443 |
$bp_classes[] = bp_current_action();
|
2444 |
}
|
@@ -2457,6 +2422,67 @@ function bp_the_body_class() {
|
|
2457 |
}
|
2458 |
add_filter( 'body_class', 'bp_get_the_body_class', 10, 2 );
|
2459 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2460 |
/**
|
2461 |
* Sort BuddyPress nav menu items by their position property.
|
2462 |
*
|
@@ -2472,14 +2498,13 @@ function bp_the_body_class() {
|
|
2472 |
* the first argument is considered to be respectively less than, equal to, or greater than the second.
|
2473 |
*/
|
2474 |
function _bp_nav_menu_sort( $a, $b ) {
|
2475 |
-
if ( $a[
|
2476 |
return 0;
|
2477 |
-
|
2478 |
-
else if ( $a["position"] < $b["position"] )
|
2479 |
return -1;
|
2480 |
-
|
2481 |
-
else
|
2482 |
return 1;
|
|
|
2483 |
}
|
2484 |
|
2485 |
/**
|
@@ -2496,8 +2521,9 @@ function bp_get_nav_menu_items() {
|
|
2496 |
foreach ( (array) buddypress()->bp_options_nav as $parent_menu => $sub_menus ) {
|
2497 |
|
2498 |
// The root menu's ID is "xprofile", but the Profile submenus are using "profile". See BP_Core::setup_nav().
|
2499 |
-
if ( 'profile'
|
2500 |
$parent_menu = 'xprofile';
|
|
|
2501 |
|
2502 |
// Sort the items in this menu's navigation by their position property
|
2503 |
$second_level_menus = (array) $sub_menus;
|
@@ -2507,12 +2533,13 @@ function bp_get_nav_menu_items() {
|
|
2507 |
foreach( $second_level_menus as $sub_nav ) {
|
2508 |
|
2509 |
// Skip items we don't have access to
|
2510 |
-
if (
|
2511 |
continue;
|
|
|
2512 |
|
2513 |
// Add this menu
|
2514 |
$menu = new stdClass;
|
2515 |
-
$menu->class = array();
|
2516 |
$menu->css_id = $sub_nav['css_id'];
|
2517 |
$menu->link = $sub_nav['link'];
|
2518 |
$menu->name = $sub_nav['name'];
|
@@ -2520,7 +2547,7 @@ function bp_get_nav_menu_items() {
|
|
2520 |
|
2521 |
// If we're viewing this item's screen, record that we need to mark its parent menu to be selected
|
2522 |
if ( $sub_nav['slug'] == bp_current_action() ) {
|
2523 |
-
$menu->class
|
2524 |
$selected_menus[] = $parent_menu;
|
2525 |
}
|
2526 |
|
@@ -2536,23 +2563,25 @@ function bp_get_nav_menu_items() {
|
|
2536 |
foreach ( $top_level_menus as $nav ) {
|
2537 |
|
2538 |
// Skip items marked as user-specific if you're not on your own profile
|
2539 |
-
if (
|
2540 |
continue;
|
|
|
2541 |
|
2542 |
// Get the correct menu link. See http://buddypress.trac.wordpress.org/ticket/4624
|
2543 |
$link = bp_loggedin_user_domain() ? str_replace( bp_loggedin_user_domain(), bp_displayed_user_domain(), $nav['link'] ) : trailingslashit( bp_displayed_user_domain() . $nav['link'] );
|
2544 |
|
2545 |
// Add this menu
|
2546 |
$menu = new stdClass;
|
2547 |
-
$menu->class = array();
|
2548 |
$menu->css_id = $nav['css_id'];
|
2549 |
$menu->link = $link;
|
2550 |
$menu->name = $nav['name'];
|
2551 |
$menu->parent = 0;
|
2552 |
|
2553 |
// Check if we need to mark this menu as selected
|
2554 |
-
if ( in_array( $nav['css_id'], $selected_menus ) )
|
2555 |
-
$menu->class =
|
|
|
2556 |
|
2557 |
$menus[] = $menu;
|
2558 |
}
|
@@ -2623,8 +2652,9 @@ function bp_nav_menu( $args = array() ) {
|
|
2623 |
$show_container = false;
|
2624 |
|
2625 |
// Create custom walker if one wasn't set
|
2626 |
-
if ( empty( $args->walker ) )
|
2627 |
$args->walker = new BP_Walker_Nav_Menu;
|
|
|
2628 |
|
2629 |
// Sanitise values for class and ID
|
2630 |
$args->container_class = sanitize_html_class( $args->container_class );
|
@@ -2657,10 +2687,11 @@ function bp_nav_menu( $args = array() ) {
|
|
2657 |
|
2658 |
// If a specific ID wasn't requested, and there are multiple menus on the same screen, make sure the autogenerated ID is unique
|
2659 |
while ( in_array( $wrap_id, $menu_id_slugs ) ) {
|
2660 |
-
if ( preg_match( '#-(\d+)$#', $wrap_id, $matches ) )
|
2661 |
$wrap_id = preg_replace('#-(\d+)$#', '-' . ++$matches[1], $wrap_id );
|
2662 |
-
else
|
2663 |
$wrap_id = $wrap_id . '-1';
|
|
|
2664 |
}
|
2665 |
}
|
2666 |
$menu_id_slugs[] = $wrap_id;
|
@@ -2674,14 +2705,16 @@ function bp_nav_menu( $args = array() ) {
|
|
2674 |
unset( $items );
|
2675 |
|
2676 |
// If we've wrapped the ul, close it
|
2677 |
-
if ( $show_container )
|
2678 |
$nav_menu .= '</' . $args->container . '>';
|
|
|
2679 |
|
2680 |
// Final chance to modify output
|
2681 |
$nav_menu = apply_filters( 'bp_nav_menu', $nav_menu, $args );
|
2682 |
|
2683 |
-
if ( $args->echo )
|
2684 |
echo $nav_menu;
|
2685 |
-
else
|
2686 |
return $nav_menu;
|
|
|
2687 |
}
|
23 |
* The function will also analyze the current action for the current component
|
24 |
* to determine whether or not to highlight a particular sub nav item.
|
25 |
*
|
|
|
26 |
* @uses bp_get_user_nav() Renders the navigation for a profile of a currently
|
27 |
* viewed user.
|
28 |
*/
|
29 |
function bp_get_options_nav() {
|
30 |
+
$bp = buddypress();
|
31 |
|
32 |
+
// If we are looking at a member profile, then the we can use the current
|
33 |
+
// component as an index. Otherwise we need to use the component's root_slug
|
34 |
$component_index = !empty( $bp->displayed_user ) ? bp_current_component() : bp_get_root_slug( bp_current_component() );
|
35 |
|
36 |
+
if ( ! bp_is_single_item() ) {
|
37 |
if ( !isset( $bp->bp_options_nav[$component_index] ) || count( $bp->bp_options_nav[$component_index] ) < 1 ) {
|
38 |
return false;
|
39 |
} else {
|
49 |
|
50 |
// Loop through each navigation item
|
51 |
foreach ( (array) $bp->bp_options_nav[$the_index] as $subnav_item ) {
|
52 |
+
if ( empty( $subnav_item['user_has_access'] ) ) {
|
53 |
continue;
|
54 |
+
}
|
55 |
|
56 |
// If the current action or an action variable matches the nav item id, then add a highlight CSS class.
|
57 |
if ( $subnav_item['slug'] == bp_current_action() ) {
|
75 |
* @todo Deprecate.
|
76 |
*/
|
77 |
function bp_get_options_title() {
|
78 |
+
$bp = buddypress();
|
79 |
|
80 |
+
if ( empty( $bp->bp_options_title ) ) {
|
81 |
$bp->bp_options_title = __( 'Options', 'buddypress' );
|
82 |
+
}
|
83 |
|
84 |
echo apply_filters( 'bp_get_options_title', esc_attr( $bp->bp_options_title ) );
|
85 |
}
|
102 |
$title = buddypress()->{$component}->directory_title;
|
103 |
|
104 |
// If none is found, concatenate
|
105 |
+
} elseif ( isset( buddypress()->{$component}->name ) ) {
|
106 |
$title = sprintf( __( '%s Directory', 'buddypress' ), buddypress()->{$component}->name );
|
107 |
}
|
108 |
|
119 |
*
|
120 |
* Not currently used in BuddyPress.
|
121 |
*
|
122 |
+
* @return bool Returns true if an options avatar has been set, otherwise false.
|
|
|
|
|
|
|
|
|
123 |
*/
|
124 |
function bp_has_options_avatar() {
|
125 |
+
return (bool) buddypress()->bp_options_avatar;
|
|
|
|
|
|
|
|
|
|
|
126 |
}
|
127 |
|
128 |
/**
|
133 |
* @todo Deprecate.
|
134 |
*/
|
135 |
function bp_get_options_avatar() {
|
136 |
+
echo apply_filters( 'bp_get_options_avatar', buddypress()->bp_options_avatar );
|
|
|
|
|
137 |
}
|
138 |
|
139 |
/**
|
140 |
* Output a comment author's avatar.
|
141 |
*
|
142 |
* Not currently used in BuddyPress.
|
|
|
|
|
143 |
*/
|
144 |
function bp_comment_author_avatar() {
|
145 |
global $comment;
|
146 |
|
147 |
+
if ( function_exists( 'bp_core_fetch_avatar' ) ) {
|
148 |
+
echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array(
|
149 |
+
'item_id' => $comment->user_id,
|
150 |
+
'type' => 'thumb',
|
151 |
+
'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $comment->user_id ) )
|
152 |
+
) ) );
|
153 |
+
} elseif ( function_exists( 'get_avatar' ) ) {
|
154 |
get_avatar();
|
155 |
+
}
|
156 |
}
|
157 |
|
158 |
/**
|
159 |
* Output a post author's avatar.
|
160 |
*
|
161 |
* Not currently used in BuddyPress.
|
|
|
|
|
162 |
*/
|
163 |
function bp_post_author_avatar() {
|
164 |
global $post;
|
165 |
|
166 |
+
if ( function_exists( 'bp_core_fetch_avatar' ) ) {
|
167 |
+
echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array(
|
168 |
+
'item_id' => $post->post_author,
|
169 |
+
'type' => 'thumb',
|
170 |
+
'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $post->post_author ) )
|
171 |
+
) ) );
|
172 |
+
} elseif ( function_exists( 'get_avatar' ) ) {
|
173 |
get_avatar();
|
174 |
+
}
|
175 |
}
|
176 |
|
177 |
/**
|
187 |
* if none is found.
|
188 |
*/
|
189 |
function bp_get_avatar_admin_step() {
|
190 |
+
$bp = buddypress();
|
191 |
+
$step = isset( $bp->avatar_admin->step )
|
192 |
+
? $step = $bp->avatar_admin->step
|
193 |
+
: 'upload-image';
|
|
|
|
|
194 |
|
195 |
return apply_filters( 'bp_get_avatar_admin_step', $step );
|
196 |
}
|
207 |
* @return string URL of the avatar awaiting cropping.
|
208 |
*/
|
209 |
function bp_get_avatar_to_crop() {
|
210 |
+
$bp = buddypress();
|
211 |
+
$url = isset( $bp->avatar_admin->image->url )
|
212 |
+
? $bp->avatar_admin->image->url
|
213 |
+
: $url = '';
|
|
|
|
|
214 |
|
215 |
return apply_filters( 'bp_get_avatar_to_crop', $url );
|
216 |
}
|
227 |
* @return string Relative file path to the avatar.
|
228 |
*/
|
229 |
function bp_get_avatar_to_crop_src() {
|
230 |
+
return apply_filters( 'bp_get_avatar_to_crop_src', str_replace( WP_CONTENT_DIR, '', buddypress()->avatar_admin->image->dir ) );
|
|
|
|
|
231 |
}
|
232 |
|
233 |
/**
|
238 |
* @todo Deprecate.
|
239 |
*/
|
240 |
function bp_avatar_cropper() {
|
241 |
+
?>
|
242 |
+
<img id="avatar-to-crop" class="avatar" src="<?php echo esc_url( buddypress()->avatar_admin->image ); ?>" />
|
243 |
+
<?php
|
244 |
}
|
245 |
|
246 |
/**
|
271 |
* 'date_format' and 'time_format' settings are). False on failure.
|
272 |
*/
|
273 |
function bp_format_time( $time, $just_date = false, $localize_time = true ) {
|
274 |
+
|
275 |
+
if ( ! isset( $time ) || ! is_numeric( $time ) ) {
|
276 |
return false;
|
277 |
+
}
|
278 |
|
279 |
// Get GMT offset from root blog
|
280 |
$root_blog_offset = false;
|
281 |
+
if ( ! empty( $localize_time ) ) {
|
282 |
$root_blog_offset = get_blog_option( bp_get_root_blog_id(), 'gmt_offset' );
|
283 |
+
}
|
284 |
|
285 |
// Calculate offset time
|
286 |
$time_offset = $time + ( $root_blog_offset * 3600 );
|
289 |
$date = date_i18n( get_option( 'date_format' ), $time_offset );
|
290 |
|
291 |
// Should we show the time also?
|
292 |
+
if ( empty( $just_date ) ) {
|
293 |
// Current time (9:50pm)
|
294 |
$time = date_i18n( get_option( 'time_format' ), $time_offset );
|
295 |
|
320 |
*/
|
321 |
function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true ) {
|
322 |
|
323 |
+
if ( ! empty( $capitalize ) ) {
|
324 |
$youtext = bp_core_ucfirst( $youtext );
|
325 |
+
}
|
326 |
|
327 |
if ( bp_displayed_user_id() == bp_loggedin_user_id() ) {
|
328 |
if ( true == $echo ) {
|
376 |
|
377 |
$options = array();
|
378 |
|
379 |
+
if ( bp_is_active( 'xprofile' ) ) {
|
380 |
+
$options['members'] = _x( 'Members', 'search form', 'buddypress' );
|
381 |
+
}
|
382 |
|
383 |
+
if ( bp_is_active( 'groups' ) ) {
|
384 |
+
$options['groups'] = _x( 'Groups', 'search form', 'buddypress' );
|
385 |
+
}
|
386 |
|
387 |
+
if ( bp_is_active( 'blogs' ) && is_multisite() ) {
|
388 |
+
$options['blogs'] = _x( 'Blogs', 'search form', 'buddypress' );
|
389 |
+
}
|
390 |
|
391 |
+
if ( bp_is_active( 'forums' ) && bp_forums_is_installed_correctly() && bp_forums_has_directory() ) {
|
392 |
+
$options['forums'] = _x( 'Forums', 'search form', 'buddypress' );
|
393 |
+
}
|
394 |
|
395 |
+
$options['posts'] = _x( 'Posts', 'search form', 'buddypress' );
|
396 |
|
397 |
// Eventually this won't be needed and a page will be built to integrate all search results.
|
398 |
+
$selection_box = '<label for="search-which" class="accessibly-hidden">' . _x( 'Search these:', 'search form', 'buddypress' ) . '</label>';
|
399 |
$selection_box .= '<select name="search-which" id="search-which" style="width: auto">';
|
400 |
|
401 |
$options = apply_filters( 'bp_search_form_type_select_options', $options );
|
402 |
+
foreach( (array) $options as $option_value => $option_title ) {
|
403 |
$selection_box .= sprintf( '<option value="%s">%s</option>', $option_value, $option_title );
|
404 |
+
}
|
405 |
|
406 |
$selection_box .= '</select>';
|
407 |
|
431 |
function bp_get_search_default_text( $component = '' ) {
|
432 |
global $bp;
|
433 |
|
434 |
+
if ( empty( $component ) ) {
|
435 |
$component = bp_current_component();
|
436 |
+
}
|
437 |
|
438 |
$default_text = __( 'Search anything...', 'buddypress' );
|
439 |
|
446 |
// name out of $bp->pages
|
447 |
if ( !empty( $bp->pages->{$component}->slug ) ) {
|
448 |
$key = $bp->pages->{$component}->slug;
|
449 |
+
if ( !empty( $bp->{$key}->search_string ) ) {
|
450 |
$default_text = $bp->{$key}->search_string;
|
451 |
+
}
|
452 |
}
|
453 |
}
|
454 |
}
|
534 |
* @return string Trimmed string.
|
535 |
*/
|
536 |
function bp_create_excerpt( $text, $length = 225, $options = array() ) {
|
537 |
+
|
538 |
// Backward compatibility. The third argument used to be a boolean $filter_shortcodes
|
539 |
$filter_shortcodes_default = is_bool( $options ) ? $options : true;
|
540 |
|
541 |
+
$r = bp_parse_args( $options, array(
|
542 |
'ending' => __( ' […]', 'buddypress' ),
|
543 |
'exact' => false,
|
544 |
'html' => true,
|
545 |
'filter_shortcodes' => $filter_shortcodes_default
|
546 |
+
), 'create_excerpt' );
|
|
|
|
|
547 |
|
548 |
// Save the original text, to be passed along to the filter
|
549 |
$original_text = $text;
|
550 |
|
551 |
// Allow plugins to modify these values globally
|
552 |
+
$length = apply_filters( 'bp_excerpt_length', $length );
|
553 |
+
$ending = apply_filters( 'bp_excerpt_append_text', $r['ending'] );
|
554 |
|
555 |
// Remove shortcodes if necessary
|
556 |
+
if ( ! empty( $r['filter_shortcodes'] ) ) {
|
557 |
$text = strip_shortcodes( $text );
|
558 |
+
}
|
559 |
|
560 |
// When $html is true, the excerpt should be created without including HTML tags in the
|
561 |
// excerpt length
|
562 |
+
if ( ! empty( $r['html'] ) ) {
|
563 |
+
|
564 |
// The text is short enough. No need to truncate
|
565 |
if ( mb_strlen( preg_replace( '/<.*?>/', '', $text ) ) <= $length ) {
|
566 |
return $text;
|
573 |
// Find all the tags and put them in a stack for later use
|
574 |
preg_match_all( '/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER );
|
575 |
foreach ( $tags as $tag ) {
|
576 |
+
|
577 |
// Process tags that need to be closed
|
578 |
if ( !preg_match( '/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/s', $tag[2] ) ) {
|
579 |
if ( preg_match( '/<[\w]+[^>]*>/s', $tag[0] ) ) {
|
580 |
array_unshift( $openTags, $tag[2] );
|
581 |
+
} elseif ( preg_match('/<\/([\w]+)[^>]*>/s', $tag[0], $closeTag ) ) {
|
582 |
$pos = array_search( $closeTag[1], $openTags );
|
583 |
if ( $pos !== false ) {
|
584 |
array_splice( $openTags, $pos, 1 );
|
585 |
}
|
586 |
}
|
587 |
}
|
|
|
588 |
|
589 |
+
$truncate .= $tag[1];
|
590 |
$contentLength = mb_strlen( preg_replace( '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i', ' ', $tag[3] ) );
|
591 |
+
|
592 |
if ( $contentLength + $totalLength > $length ) {
|
593 |
$left = $length - $totalLength;
|
594 |
$entitiesLength = 0;
|
622 |
}
|
623 |
|
624 |
// If $exact is false, we can't break on words
|
625 |
+
if ( empty( $r['exact'] ) ) {
|
626 |
$spacepos = mb_strrpos( $truncate, ' ' );
|
627 |
if ( isset( $spacepos ) ) {
|
628 |
+
if ( $r['html'] ) {
|
629 |
$bits = mb_substr( $truncate, $spacepos );
|
630 |
preg_match_all( '/<\/([a-z]+)>/', $bits, $droppedTags, PREG_SET_ORDER );
|
631 |
if ( !empty( $droppedTags ) ) {
|
641 |
}
|
642 |
$truncate .= $ending;
|
643 |
|
644 |
+
if ( !empty( $r['html'] ) ) {
|
645 |
foreach ( $openTags as $tag ) {
|
646 |
$truncate .= '</' . $tag . '>';
|
647 |
}
|
648 |
}
|
649 |
|
650 |
return apply_filters( 'bp_create_excerpt', $truncate, $original_text, $length, $options );
|
|
|
651 |
}
|
652 |
+
add_filter( 'bp_create_excerpt', 'stripslashes_deep' );
|
653 |
add_filter( 'bp_create_excerpt', 'force_balance_tags' );
|
654 |
|
655 |
/**
|
694 |
* @return bool True if blog signup is allowed, otherwise false.
|
695 |
*/
|
696 |
function bp_get_blog_signup_allowed() {
|
|
|
697 |
|
698 |
+
if ( ! is_multisite() ) {
|
699 |
return false;
|
700 |
+
}
|
701 |
|
702 |
+
$status = buddypress()->site_options['registration'];
|
703 |
+
if ( ( 'none' !== $status ) && ( 'user' !== $status ) ) {
|
704 |
return true;
|
705 |
+
}
|
706 |
|
707 |
return false;
|
708 |
}
|
714 |
* otherwise false.
|
715 |
*/
|
716 |
function bp_account_was_activated() {
|
717 |
+
$bp = buddypress();
|
718 |
+
$activation_complete = !empty( $bp->activation_complete )
|
719 |
+
? $bp->activation_complete
|
720 |
+
: false;
|
721 |
|
722 |
return $activation_complete;
|
723 |
}
|
760 |
*/
|
761 |
function bp_get_email_subject( $args = array() ) {
|
762 |
|
763 |
+
$r = bp_parse_args( $args, array(
|
764 |
'before' => '[',
|
765 |
'after' => ']',
|
766 |
'default' => __( 'Community', 'buddypress' ),
|
767 |
'text' => ''
|
768 |
+
), 'get_email_subject' );
|
769 |
|
770 |
$subject = $r['before'] . wp_specialchars_decode( bp_get_option( 'blogname', $r['default'] ), ENT_QUOTES ) . $r['after'] . ' ' . $r['text'];
|
771 |
|
786 |
* @return string The AJAX querystring.
|
787 |
*/
|
788 |
function bp_ajax_querystring( $object = false ) {
|
789 |
+
$bp = buddypress();
|
790 |
|
791 |
+
if ( ! isset( $bp->ajax_querystring ) ) {
|
792 |
$bp->ajax_querystring = '';
|
793 |
+
}
|
794 |
|
795 |
return apply_filters( 'bp_ajax_querystring', $bp->ajax_querystring, $object );
|
796 |
}
|
803 |
* @return string Component name.
|
804 |
*/
|
805 |
function bp_current_component() {
|
806 |
+
$bp = buddypress();
|
807 |
+
$current_component = !empty( $bp->current_component )
|
808 |
+
? $bp->current_component
|
809 |
+
: false;
|
810 |
+
|
811 |
return apply_filters( 'bp_current_component', $current_component );
|
812 |
}
|
813 |
|
817 |
* @return string Action name.
|
818 |
*/
|
819 |
function bp_current_action() {
|
820 |
+
$bp = buddypress();
|
821 |
+
$current_action = !empty( $bp->current_action )
|
822 |
+
? $bp->current_action
|
823 |
+
: '';
|
824 |
+
|
825 |
return apply_filters( 'bp_current_action', $current_action );
|
826 |
}
|
827 |
|
831 |
* @return unknown
|
832 |
*/
|
833 |
function bp_current_item() {
|
834 |
+
$bp = buddypress();
|
835 |
+
$current_item = !empty( $bp->current_item )
|
836 |
+
? $bp->current_item
|
837 |
+
: false;
|
838 |
+
|
839 |
return apply_filters( 'bp_current_item', $current_item );
|
840 |
}
|
841 |
|
846 |
* if the array is empty.
|
847 |
*/
|
848 |
function bp_action_variables() {
|
849 |
+
$bp = buddypress();
|
850 |
+
$action_variables = !empty( $bp->action_variables )
|
851 |
+
? $bp->action_variables
|
852 |
+
: false;
|
853 |
+
|
854 |
return apply_filters( 'bp_action_variables', $action_variables );
|
855 |
}
|
856 |
|
865 |
*/
|
866 |
function bp_action_variable( $position = 0 ) {
|
867 |
$action_variables = bp_action_variables();
|
868 |
+
$action_variable = isset( $action_variables[ $position ] )
|
869 |
+
? $action_variables[ $position ]
|
870 |
+
: false;
|
871 |
|
872 |
return apply_filters( 'bp_action_variable', $action_variable, $position );
|
873 |
}
|
884 |
* @return string URL of the BP root blog.
|
885 |
*/
|
886 |
function bp_get_root_domain() {
|
887 |
+
$bp = buddypress();
|
888 |
|
889 |
+
if ( ! empty( $bp->root_domain ) ) {
|
890 |
$domain = $bp->root_domain;
|
891 |
} else {
|
892 |
$domain = bp_core_get_root_domain();
|
933 |
*
|
934 |
* @since BuddyPress (1.5.0)
|
935 |
*
|
|
|
|
|
936 |
* @param string $component Optional. Defaults to the current component.
|
937 |
* @return string $root_slug The root slug.
|
938 |
*/
|
939 |
function bp_get_root_slug( $component = '' ) {
|
940 |
+
$bp = buddypress();
|
|
|
941 |
$root_slug = '';
|
942 |
|
943 |
// Use current global component if none passed
|
944 |
+
if ( empty( $component ) ) {
|
945 |
$component = bp_current_component();
|
946 |
+
}
|
947 |
|
948 |
// Component is active
|
949 |
+
if ( ! empty( $bp->active_components[ $component ] ) ) {
|
950 |
+
|
951 |
// Backward compatibility: in legacy plugins, the canonical component id
|
952 |
// was stored as an array value in $bp->active_components
|
953 |
+
$component_name = ( '1' == $bp->active_components[ $component ] )
|
954 |
+
? $component
|
955 |
+
: $bp->active_components[$component];
|
956 |
|
957 |
// Component has specific root slug
|
958 |
+
if ( ! empty( $bp->{$component_name}->root_slug ) ) {
|
959 |
$root_slug = $bp->{$component_name}->root_slug;
|
960 |
}
|
961 |
}
|
962 |
|
963 |
// No specific root slug, so fall back to component slug
|
964 |
+
if ( empty( $root_slug ) ) {
|
965 |
$root_slug = $component;
|
966 |
+
}
|
967 |
|
968 |
return apply_filters( 'bp_get_root_slug', $root_slug, $component );
|
969 |
}
|
973 |
*
|
974 |
* @since BuddyPress (1.5.0)
|
975 |
*
|
|
|
|
|
976 |
* @param string $root_slug Needle to our active component haystack.
|
977 |
* @return mixed False if none found, component name if found.
|
978 |
*/
|
979 |
function bp_get_name_from_root_slug( $root_slug = '' ) {
|
980 |
+
$bp = buddypress();
|
981 |
|
982 |
// If no slug is passed, look at current_component
|
983 |
+
if ( empty( $root_slug ) ) {
|
984 |
$root_slug = bp_current_component();
|
985 |
+
}
|
986 |
|
987 |
// No current component or root slug, so flee
|
988 |
+
if ( empty( $root_slug ) ) {
|
989 |
return false;
|
990 |
+
}
|
991 |
|
992 |
// Loop through active components and look for a match
|
993 |
foreach ( array_keys( $bp->active_components ) as $component ) {
|
994 |
+
if ( ( ! empty( $bp->{$component}->slug ) && ( $bp->{$component}->slug == $root_slug ) ) || ( ! empty( $bp->{$component}->root_slug ) && ( $bp->{$component}->root_slug === $root_slug ) ) ) {
|
995 |
return $bp->{$component}->name;
|
996 |
}
|
997 |
}
|
1000 |
}
|
1001 |
|
1002 |
function bp_user_has_access() {
|
1003 |
+
$has_access = ( bp_current_user_can( 'bp_moderate' ) || bp_is_my_profile() )
|
1004 |
+
? true
|
1005 |
+
: false;
|
1006 |
|
1007 |
+
return (bool) apply_filters( 'bp_user_has_access', $has_access );
|
1008 |
}
|
1009 |
|
1010 |
/**
|
1037 |
*/
|
1038 |
function bp_displayed_user_id() {
|
1039 |
$bp = buddypress();
|
1040 |
+
$id = !empty( $bp->displayed_user->id )
|
1041 |
+
? $bp->displayed_user->id
|
1042 |
+
: 0;
|
1043 |
|
1044 |
return (int) apply_filters( 'bp_displayed_user_id', $id );
|
1045 |
}
|
1053 |
*/
|
1054 |
function bp_loggedin_user_id() {
|
1055 |
$bp = buddypress();
|
1056 |
+
$id = !empty( $bp->loggedin_user->id )
|
1057 |
+
? $bp->loggedin_user->id
|
1058 |
+
: 0;
|
1059 |
|
1060 |
return (int) apply_filters( 'bp_loggedin_user_id', $id );
|
1061 |
}
|
1077 |
* @return bool Returns true if the component matches, or else false.
|
1078 |
*/
|
1079 |
function bp_is_current_component( $component ) {
|
1080 |
+
global $wp_query;
|
1081 |
|
1082 |
$is_current_component = false;
|
1083 |
|
1087 |
}
|
1088 |
|
1089 |
// Backward compatibility: 'xprofile' should be read as 'profile'
|
1090 |
+
if ( 'xprofile' === $component ) {
|
1091 |
$component = 'profile';
|
1092 |
+
}
|
1093 |
+
|
1094 |
+
$bp = buddypress();
|
1095 |
|
1096 |
if ( ! empty( $bp->current_component ) ) {
|
1097 |
|
1112 |
// Next, check to see whether $component is a canonical,
|
1113 |
// non-translatable component name. If so, we can return its
|
1114 |
// corresponding slug from $bp->active_components.
|
1115 |
+
} elseif ( $key = array_search( $component, $bp->active_components ) ) {
|
1116 |
if ( strstr( $bp->current_component, $key ) ) {
|
1117 |
$is_current_component = true;
|
1118 |
}
|
1137 |
// Page template fallback check if $bp->current_component is empty
|
1138 |
} elseif ( !is_admin() && is_a( $wp_query, 'WP_Query' ) && is_page() ) {
|
1139 |
global $wp_query;
|
|
|
|
|
|
|
1140 |
|
1141 |
+
$page = $wp_query->get_queried_object();
|
1142 |
+
if ( isset( $page->ID ) ) {
|
1143 |
+
$custom_fields = get_post_custom_values( '_wp_page_template', $page->ID );
|
1144 |
+
$page_template = $custom_fields[0];
|
1145 |
+
|
1146 |
+
// Component name is in the page template name
|
1147 |
+
if ( !empty( $page_template ) && strstr( strtolower( $page_template ), strtolower( $component ) ) ) {
|
1148 |
+
$is_current_component = true;
|
1149 |
+
}
|
1150 |
}
|
1151 |
}
|
1152 |
|
1171 |
* @return bool True if the current action matches $action.
|
1172 |
*/
|
1173 |
function bp_is_current_action( $action = '' ) {
|
1174 |
+
return (bool) ( $action === bp_current_action() );
|
|
|
|
|
|
|
1175 |
}
|
1176 |
|
1177 |
/**
|
1221 |
* @return bool True if $item is the current item.
|
1222 |
*/
|
1223 |
function bp_is_current_item( $item = '' ) {
|
1224 |
+
$retval = ( $item === bp_current_item() );
|
|
|
1225 |
|
1226 |
+
return (bool) apply_filters( 'bp_is_current_item', $retval, $item );
|
1227 |
}
|
1228 |
|
1229 |
/**
|
1232 |
* @return bool True if looking at a single item, otherwise false.
|
1233 |
*/
|
1234 |
function bp_is_single_item() {
|
1235 |
+
$bp = buddypress();
|
1236 |
+
$retval = false;
|
1237 |
|
1238 |
+
if ( isset( $bp->is_single_item ) ) {
|
1239 |
+
$retval = $bp->is_single_item;
|
1240 |
+
}
|
1241 |
|
1242 |
+
return (bool) apply_filters( 'bp_is_single_item', $retval );
|
1243 |
}
|
1244 |
|
1245 |
/**
|
1249 |
* otherwise false.
|
1250 |
*/
|
1251 |
function bp_is_item_admin() {
|
1252 |
+
$bp = buddypress();
|
1253 |
+
$retval = false;
|
1254 |
|
1255 |
+
if ( isset( $bp->is_item_admin ) ) {
|
1256 |
+
$retval = $bp->is_item_admin;
|
1257 |
+
}
|
1258 |
|
1259 |
+
return (bool) apply_filters( 'bp_is_item_admin', $retval );
|
1260 |
}
|
1261 |
|
1262 |
/**
|
1266 |
* otherwise false.
|
1267 |
*/
|
1268 |
function bp_is_item_mod() {
|
1269 |
+
$bp = buddypress();
|
1270 |
+
$retval = false;
|
1271 |
|
1272 |
+
if ( isset( $bp->is_item_mod ) ) {
|
1273 |
+
$retval = $bp->is_item_mod;
|
1274 |
+
}
|
1275 |
|
1276 |
+
return (bool) apply_filters( 'bp_is_item_mod', $retval );
|
1277 |
}
|
1278 |
|
1279 |
/**
|
1283 |
* false.
|
1284 |
*/
|
1285 |
function bp_is_directory() {
|
1286 |
+
$bp = buddypress();
|
1287 |
+
$retval = false;
|
1288 |
|
1289 |
+
if ( isset( $bp->is_directory ) ) {
|
1290 |
+
$retval = $bp->is_directory;
|
1291 |
+
}
|
1292 |
|
1293 |
+
return (bool) apply_filters( 'bp_is_directory', $retval );
|
1294 |
}
|
1295 |
|
1296 |
/**
|
1297 |
* Check to see if a component's URL should be in the root, not under a member page.
|
1298 |
*
|
1299 |
+
* - Yes ('groups' is root) : http://domain.com/groups/the-group
|
1300 |
+
* - No ('groups' is not-root): http://domain.com/members/andy/groups/the-group
|
1301 |
+
*
|
1302 |
+
* This function is on the chopping block. It's currently only used by a few
|
1303 |
+
* already deprecated functions.
|
1304 |
*
|
1305 |
* @return bool True if root component, else false.
|
1306 |
*/
|
1307 |
+
function bp_is_root_component( $component_name = '' ) {
|
1308 |
+
$bp = buddypress();
|
1309 |
+
$retval = false;
|
1310 |
|
1311 |
+
// Default to the current component if none is passed
|
1312 |
+
if ( empty( $component_name ) ) {
|
1313 |
+
$component_name = bp_current_component();
|
1314 |
+
}
|
1315 |
|
1316 |
+
// Loop through active components and check for key/slug matches
|
1317 |
+
if ( ! empty( $bp->active_components ) ) {
|
1318 |
+
foreach ( (array) $bp->active_components as $key => $slug ) {
|
1319 |
+
if ( ( $key === $component_name ) || ( $slug === $component_name ) ) {
|
1320 |
+
$retval = true;
|
1321 |
+
break;
|
1322 |
+
}
|
1323 |
+
}
|
1324 |
}
|
1325 |
|
1326 |
+
return (bool) apply_filters( 'bp_is_root_component', $retval );
|
1327 |
}
|
1328 |
|
1329 |
/**
|
1333 |
*
|
1334 |
* @since BuddyPress (1.5.0)
|
1335 |
*
|
|
|
1336 |
* @global $current_blog WordPress global for the current blog.
|
1337 |
*
|
1338 |
* @param string $component Optional. Name of the component to check for.
|
1339 |
+
* Default: current component.
|
1340 |
* @return bool True if the specified component is set to be the site's front
|
1341 |
+
* page, otherwise false.
|
1342 |
*/
|
1343 |
function bp_is_component_front_page( $component = '' ) {
|
1344 |
+
global $current_blog;
|
1345 |
+
|
1346 |
+
$bp = buddypress();
|
1347 |
+
|
1348 |
+
// Default to the current component if none is passed
|
1349 |
+
if ( empty( $component ) ) {
|
1350 |
+
$component = bp_current_component();
|
1351 |
+
}
|
1352 |
|
1353 |
+
// Get the path for the current blog/site
|
1354 |
+
$path = is_main_site()
|
1355 |
+
? bp_core_get_site_path()
|
1356 |
+
: $current_blog->path;
|
1357 |
|
1358 |
+
// Get the front page variables
|
1359 |
+
$show_on_front = get_option( 'show_on_front' );
|
1360 |
+
$page_on_front = get_option( 'page_on_front' );
|
1361 |
|
1362 |
+
if ( ( 'page' !== $show_on_front ) || empty( $component ) || empty( $bp->pages->{$component} ) || ( $_SERVER['REQUEST_URI'] !== $path ) ) {
|
1363 |
return false;
|
1364 |
+
}
|
1365 |
|
1366 |
+
return (bool) apply_filters( 'bp_is_component_front_page', ( $bp->pages->{$component}->id == $page_on_front ), $component );
|
1367 |
}
|
1368 |
|
1369 |
/**
|
1378 |
|
1379 |
$is_blog_page = false;
|
1380 |
|
1381 |
+
// Generally, we can just check to see that there's no current component.
|
1382 |
+
// The one exception is single user home tabs, where $bp->current_component
|
1383 |
+
// is unset. Thus the addition of the bp_is_user() check.
|
1384 |
+
if ( ! bp_current_component() && ! bp_is_user() ) {
|
1385 |
$is_blog_page = true;
|
1386 |
+
}
|
1387 |
|
1388 |
+
return (bool) apply_filters( 'bp_is_blog_page', $is_blog_page );
|
1389 |
}
|
1390 |
|
1391 |
/**
|
1416 |
* @param string $component The component name.
|
1417 |
* @return bool True if the component is active, otherwise false.
|
1418 |
*/
|
1419 |
+
function bp_is_active( $component = '' ) {
|
1420 |
+
$retval = false;
|
1421 |
|
1422 |
+
// Default to the current component if none is passed
|
1423 |
+
if ( empty( $component ) ) {
|
1424 |
+
$component = bp_current_component();
|
1425 |
+
}
|
1426 |
|
1427 |
+
// Is component in either the active or required components arrays
|
1428 |
+
if ( isset( buddypress()->active_components[ $component ] ) || isset( buddypress()->required_components[ $component ] ) ) {
|
1429 |
+
$retval = true;
|
1430 |
+
}
|
1431 |
+
|
1432 |
+
return apply_filters( 'bp_is_active', $retval, $component );
|
1433 |
}
|
1434 |
|
1435 |
/**
|
1438 |
* @return bool True if the current page is part of the Members component.
|
1439 |
*/
|
1440 |
function bp_is_members_component() {
|
1441 |
+
return (bool) bp_is_current_component( 'members' );
|
|
|
|
|
|
|
1442 |
}
|
1443 |
|
1444 |
/**
|
1447 |
* @return bool True if the current page is part of the Profile component.
|
1448 |
*/
|
1449 |
function bp_is_profile_component() {
|
1450 |
+
return (bool) bp_is_current_component( 'xprofile' );
|
|
|
|
|
|
|
1451 |
}
|
1452 |
|
1453 |
/**
|
1456 |
* @return bool True if the current page is part of the Activity component.
|
1457 |
*/
|
1458 |
function bp_is_activity_component() {
|
1459 |
+
return (bool) bp_is_current_component( 'activity' );
|
|
|
|
|
|
|
1460 |
}
|
1461 |
|
1462 |
/**
|
1465 |
* @return bool True if the current page is part of the Blogs component.
|
1466 |
*/
|
1467 |
function bp_is_blogs_component() {
|
1468 |
+
return (bool) ( is_multisite() && bp_is_current_component( 'blogs' ) );
|
|
|
|
|
|
|
1469 |
}
|
1470 |
|
1471 |
/**
|
1474 |
* @return bool True if the current page is part of the Messages component.
|
1475 |
*/
|
1476 |
function bp_is_messages_component() {
|
1477 |
+
return (bool) bp_is_current_component( 'messages' );
|
|
|
|
|
|
|
1478 |
}
|
1479 |
|
1480 |
/**
|
1483 |
* @return bool True if the current page is part of the Friends component.
|
1484 |
*/
|
1485 |
function bp_is_friends_component() {
|
1486 |
+
return (bool) bp_is_current_component( 'friends' );
|
|
|
|
|
|
|
1487 |
}
|
1488 |
|
1489 |
/**
|
1492 |
* @return bool True if the current page is part of the Groups component.
|
1493 |
*/
|
1494 |
function bp_is_groups_component() {
|
1495 |
+
return (bool) bp_is_current_component( 'groups' );
|
|
|
|
|
|
|
1496 |
}
|
1497 |
|
1498 |
/**
|
1501 |
* @return bool True if the current page is part of the Forums component.
|
1502 |
*/
|
1503 |
function bp_is_forums_component() {
|
1504 |
+
return (bool) bp_is_current_component( 'forums' );
|
|
|
|
|
|
|
1505 |
}
|
1506 |
|
1507 |
/**
|
1512 |
* @return bool True if the current page is part of the Notifications component.
|
1513 |
*/
|
1514 |
function bp_is_notifications_component() {
|
1515 |
+
return (bool) bp_is_current_component( 'notifications' );
|
|
|
|
|
|
|
|
|
1516 |
}
|
1517 |
|
1518 |
/**
|
1521 |
* @return bool True if the current page is part of the Settings component.
|
1522 |
*/
|
1523 |
function bp_is_settings_component() {
|
1524 |
+
return (bool) bp_is_current_component( 'settings' );
|
|
|
|
|
|
|
1525 |
}
|
1526 |
|
1527 |
/**
|
1537 |
* packaged components.
|
1538 |
*/
|
1539 |
function bp_is_current_component_core() {
|
1540 |
+
$retval = false;
|
|
|
1541 |
|
1542 |
+
foreach ( bp_core_get_packaged_component_ids() as $active_component ) {
|
1543 |
if ( bp_is_current_component( $active_component ) ) {
|
1544 |
$retval = true;
|
1545 |
break;
|
1555 |
* Is the current page the activity directory ?
|
1556 |
*
|
1557 |
* @since BuddyPress (2.0.0)
|
1558 |
+
*
|
1559 |
* @return True if the current page is the activity directory.
|
1560 |
*/
|
1561 |
function bp_is_activity_directory() {
|
1562 |
+
if ( ! bp_displayed_user_id() && bp_is_activity_component() && ! bp_current_action() ) {
|
1563 |
return true;
|
1564 |
+
}
|
1565 |
|
1566 |
return false;
|
1567 |
}
|
1572 |
* @return True if the current page is a single activity item permalink.
|
1573 |
*/
|
1574 |
function bp_is_single_activity() {
|
1575 |
+
return (bool) ( bp_is_activity_component() && is_numeric( bp_current_action() ) );
|
|
|
|
|
|
|
1576 |
}
|
1577 |
|
1578 |
/** User **********************************************************************/
|
1581 |
* Is the current page the members directory ?
|
1582 |
*
|
1583 |
* @since BuddyPress (2.0.0)
|
1584 |
+
*
|
1585 |
* @return True if the current page is the members directory.
|
1586 |
*/
|
1587 |
function bp_is_members_directory() {
|
1588 |
+
if ( ! bp_is_user() && bp_is_members_component() ) {
|
1589 |
return true;
|
1590 |
+
}
|
1591 |
|
1592 |
return false;
|
1593 |
}
|
1601 |
* @return True if the current page is part of the profile of the logged-in user.
|
1602 |
*/
|
1603 |
function bp_is_my_profile() {
|
1604 |
+
if ( is_user_logged_in() && bp_loggedin_user_id() == bp_displayed_user_id() ) {
|
1605 |
$my_profile = true;
|
1606 |
+
} else {
|
1607 |
$my_profile = false;
|
1608 |
+
}
|
1609 |
|
1610 |
return apply_filters( 'bp_is_my_profile', $my_profile );
|
1611 |
}
|
1618 |
* @return True if the current page is a user page.
|
1619 |
*/
|
1620 |
function bp_is_user() {
|
1621 |
+
return (bool) bp_displayed_user_id();
|
|
|
|
|
|
|
1622 |
}
|
1623 |
|
1624 |
/**
|
1629 |
* @return True if the current page is a user's activity stream page.
|
1630 |
*/
|
1631 |
function bp_is_user_activity() {
|
1632 |
+
return (bool) ( bp_is_user() && bp_is_activity_component() );
|
|
|
|
|
|
|
1633 |
}
|
1634 |
|
1635 |
/**
|
1641 |
*/
|
1642 |
function bp_is_user_friends_activity() {
|
1643 |
|
1644 |
+
if ( ! bp_is_active( 'friends' ) ) {
|
1645 |
return false;
|
1646 |
+
}
|
1647 |
|
1648 |
$slug = bp_get_friends_slug();
|
1649 |
|
1650 |
+
if ( empty( $slug ) ) {
|
1651 |
$slug = 'friends';
|
1652 |
+
}
|
1653 |
|
1654 |
+
if ( bp_is_user_activity() && bp_is_current_action( $slug ) ) {
|
1655 |
return true;
|
1656 |
+
}
|
1657 |
|
1658 |
return false;
|
1659 |
}
|
1667 |
*/
|
1668 |
function bp_is_user_groups_activity() {
|
1669 |
|
1670 |
+
if ( ! bp_is_active( 'groups' ) ) {
|
1671 |
return false;
|
1672 |
+
}
|
1673 |
|
1674 |
+
$slug = ( bp_get_groups_slug() )
|
1675 |
+
? bp_get_groups_slug()
|
1676 |
+
: 'groups';
|
|
|
1677 |
|
1678 |
+
if ( bp_is_user_activity() && bp_is_current_action( $slug ) ) {
|
1679 |
return true;
|
1680 |
+
}
|
1681 |
|
1682 |
return false;
|
1683 |
}
|
1690 |
* @return True if the current page is part of a user's extended profile.
|
1691 |
*/
|
1692 |
function bp_is_user_profile() {
|
1693 |
+
return (bool) ( bp_is_profile_component() || bp_is_current_component( 'profile' ) );
|
|
|
|
|
|
|
1694 |
}
|
1695 |
|
1696 |
/**
|
1701 |
* @return True if the current page is a user's profile edit page.
|
1702 |
*/
|
1703 |
function bp_is_user_profile_edit() {
|
1704 |
+
return (bool) ( bp_is_profile_component() && bp_is_current_action( 'edit' ) );
|
|
|
|
|
|
|
1705 |
}
|
1706 |
|
1707 |
function bp_is_user_change_avatar() {
|
1708 |
+
return (bool) ( bp_is_profile_component() && bp_is_current_action( 'change-avatar' ) );
|
|
|
|
|
|
|
1709 |
}
|
1710 |
|
1711 |
/**
|
1717 |
*/
|
1718 |
function bp_is_user_forums() {
|
1719 |
|
1720 |
+
if ( ! bp_is_active( 'forums' ) ) {
|
1721 |
return false;
|
1722 |
+
}
|
1723 |
|
1724 |
+
if ( bp_is_user() && bp_is_forums_component() ) {
|
1725 |
return true;
|
1726 |
+
}
|
1727 |
|
1728 |
return false;
|
1729 |
}
|
1738 |
* @return bool True if the current page is a user's Topics Started page.
|
1739 |
*/
|
1740 |
function bp_is_user_forums_started() {
|
1741 |
+
return (bool) ( bp_is_user_forums() && bp_is_current_action( 'topics' ) );
|
|
|
|
|
|
|
1742 |
}
|
1743 |
|
1744 |
/**
|
1751 |
* @return bool True if the current page is a user's Replied To forums page.
|
1752 |
*/
|
1753 |
function bp_is_user_forums_replied_to() {
|
1754 |
+
return (bool) ( bp_is_user_forums() && bp_is_current_action( 'replies' ) );
|
|
|
|
|
|
|
1755 |
}
|
1756 |
|
1757 |
/**
|
1762 |
* @return bool True if the current page is a user's Groups page.
|
1763 |
*/
|
1764 |
function bp_is_user_groups() {
|
1765 |
+
return (bool) ( bp_is_user() && bp_is_groups_component() );
|
|
|
|
|
|
|
1766 |
}
|
1767 |
|
1768 |
/**
|
1773 |
* @return bool True if the current page is a user's Blogs page.
|
1774 |
*/
|
1775 |
function bp_is_user_blogs() {
|
1776 |
+
return (bool) ( bp_is_user() && bp_is_blogs_component() );
|
|
|
|
|
|
|
1777 |
}
|
1778 |
|
1779 |
/**
|
1784 |
* @return bool True if the current page is a user's Recent Blog Posts page.
|
1785 |
*/
|
1786 |
function bp_is_user_recent_posts() {
|
1787 |
+
return (bool) ( bp_is_user_blogs() && bp_is_current_action( 'recent-posts' ) );
|
|
|
|
|
|
|
1788 |
}
|
1789 |
|
1790 |
/**
|
1795 |
* @return bool True if the current page is a user's Recent Blog Comments page.
|
1796 |
*/
|
1797 |
function bp_is_user_recent_commments() {
|
1798 |
+
return (bool) ( bp_is_user_blogs() && bp_is_current_action( 'recent-comments' ) );
|
|
|
|
|
|
|
1799 |
}
|
1800 |
|
1801 |
/**
|
1806 |
* @return bool True if the current page is a user's Friends page.
|
1807 |
*/
|
1808 |
function bp_is_user_friends() {
|
1809 |
+
return (bool) ( bp_is_user() && bp_is_friends_component() );
|
|
|
|
|
|
|
1810 |
}
|
1811 |
|
1812 |
/**
|
1817 |
* @return bool True if the current page is a user's Friends Requests page.
|
1818 |
*/
|
1819 |
function bp_is_user_friend_requests() {
|
1820 |
+
return (bool) ( bp_is_user_friends() && bp_is_current_action( 'requests' ) );
|
|
|
|
|
|
|
1821 |
}
|
1822 |
|
1823 |
/**
|
1830 |
* @return bool True if the current page is a user's Notifications page.
|
1831 |
*/
|
1832 |
function bp_is_user_notifications() {
|
1833 |
+
return (bool) ( bp_is_user() && bp_is_notifications_component() );
|
|
|
|
|
|
|
|
|
1834 |
}
|
1835 |
|
1836 |
/**
|
1841 |
* @return bool True if the current page is a user's Settings page.
|
1842 |
*/
|
1843 |
function bp_is_user_settings() {
|
1844 |
+
return (bool) ( bp_is_user() && bp_is_settings_component() );
|
|
|
|
|
|
|
1845 |
}
|
1846 |
|
1847 |
/**
|
1854 |
* @return bool True if the current page is a user's General Settings page.
|
1855 |
*/
|
1856 |
function bp_is_user_settings_general() {
|
1857 |
+
return (bool) ( bp_is_user_settings() && bp_is_current_action( 'general' ) );
|
|
|
|
|
|
|
1858 |
}
|
1859 |
|
1860 |
/**
|
1867 |
* @return bool True if the current page is a user's Notification Settings page.
|
1868 |
*/
|
1869 |
function bp_is_user_settings_notifications() {
|
1870 |
+
return (bool) ( bp_is_user_settings() && bp_is_current_action( 'notifications' ) );
|
|
|
|
|
|
|
1871 |
}
|
1872 |
|
1873 |
/**
|
1880 |
* @return bool True if the current page is a user's Delete Account page.
|
1881 |
*/
|
1882 |
function bp_is_user_settings_account_delete() {
|
1883 |
+
return (bool) ( bp_is_user_settings() && bp_is_current_action( 'delete-account' ) );
|
|
|
|
|
|
|
1884 |
}
|
1885 |
|
1886 |
/**
|
1893 |
* @return bool True if the current page is a user's Profile Settings page.
|
1894 |
*/
|
1895 |
function bp_is_user_settings_profile() {
|
1896 |
+
return (bool) ( bp_is_user_settings() && bp_is_current_action( 'profile' ) );
|
|
|
|
|
|
|
1897 |
}
|
1898 |
|
1899 |
/** Groups ********************************************************************/
|
1902 |
* Is the current page the groups directory ?
|
1903 |
*
|
1904 |
* @since BuddyPress (2.0.0)
|
1905 |
+
*
|
1906 |
* @return True if the current page is the groups directory.
|
1907 |
*/
|
1908 |
function bp_is_groups_directory() {
|
1909 |
+
if ( bp_is_groups_component() && ! bp_current_action() && ! bp_current_item() ) {
|
1910 |
return true;
|
1911 |
+
}
|
1912 |
|
1913 |
return false;
|
1914 |
}
|
1921 |
* @return bool True if the current page is part of a single group.
|
1922 |
*/
|
1923 |
function bp_is_group() {
|
1924 |
+
return (bool) ( bp_is_groups_component() && groups_get_current_group() );
|
|
|
|
|
|
|
|
|
|
|
1925 |
}
|
1926 |
|
1927 |
/**
|
1933 |
* @return bool True if the current page is a single group's home page.
|
1934 |
*/
|
1935 |
function bp_is_group_home() {
|
1936 |
+
if ( bp_is_single_item() && bp_is_groups_component() && ( ! bp_current_action() || bp_is_current_action( 'home' ) ) ) {
|
1937 |
return true;
|
1938 |
+
}
|
1939 |
|
1940 |
return false;
|
1941 |
}
|
1946 |
* @return bool True if the current page is part of the group creation process.
|
1947 |
*/
|
1948 |
function bp_is_group_create() {
|
1949 |
+
return (bool) ( bp_is_groups_component() && bp_is_current_action( 'create' ) );
|
|
|
|
|
|
|
1950 |
}
|
1951 |
|
1952 |
/**
|
1957 |
* @return bool True if the current page is part of a single group's admin.
|
1958 |
*/
|
1959 |
function bp_is_group_admin_page() {
|
1960 |
+
return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'admin' ) );
|
|
|
|
|
|
|
1961 |
}
|
1962 |
|
1963 |
/**
|
1990 |
* @return True if the current page is a group's activity page.
|
1991 |
*/
|
1992 |
function bp_is_group_activity() {
|
1993 |
+
return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) );
|
|
|
|
|
|
|
1994 |
}
|
1995 |
|
1996 |
/**
|
2001 |
* @return bool True if the current page is part of a group forum topic.
|
2002 |
*/
|
2003 |
function bp_is_group_forum_topic() {
|
2004 |
+
return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) );
|
|
|
|
|
|
|
2005 |
}
|
2006 |
|
2007 |
/**
|
2012 |
* @return bool True if the current page is part of a group forum topic edit page.
|
2013 |
*/
|
2014 |
function bp_is_group_forum_topic_edit() {
|
2015 |
+
return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) && bp_is_action_variable( 'edit', 2 ) );
|
|
|
|
|
|
|
2016 |
}
|
2017 |
|
2018 |
/**
|
2023 |
* @return bool True if the current page is part of a group's Members page.
|
2024 |
*/
|
2025 |
function bp_is_group_members() {
|
2026 |
+
return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) );
|
|
|
|
|
|
|
2027 |
}
|
2028 |
|
2029 |
/**
|
2034 |
* @return bool True if the current page is a group's Send Invites page.
|
2035 |
*/
|
2036 |
function bp_is_group_invites() {
|
2037 |
+
return (bool) ( bp_is_groups_component() && bp_is_current_action( 'send-invites' ) );
|
|
|
|
|
|
|
2038 |
}
|
2039 |
|
2040 |
/**
|
2045 |
* @return bool True if the current page is a group's Request Membership page.
|
2046 |
*/
|
2047 |
function bp_is_group_membership_request() {
|
2048 |
+
return (bool) ( bp_is_groups_component() && bp_is_current_action( 'request-membership' ) );
|
|
|
|
|
|
|
2049 |
}
|
2050 |
|
2051 |
/**
|
2054 |
* @return bool True if the current page is a Leave Group attempt.
|
2055 |
*/
|
2056 |
function bp_is_group_leave() {
|
2057 |
+
return (bool) ( bp_is_groups_component() && bp_is_single_item() && bp_is_current_action( 'leave-group' ) );
|
|
|
|
|
|
|
|
|
2058 |
}
|
2059 |
|
2060 |
/**
|
2067 |
* @return bool True if the current page is part of a single group.
|
2068 |
*/
|
2069 |
function bp_is_group_single() {
|
2070 |
+
return (bool) ( bp_is_groups_component() && bp_is_single_item() );
|
|
|
|
|
|
|
2071 |
}
|
2072 |
|
2073 |
/**
|
2078 |
* @return bool True if the current page is the Create a Blog page.
|
2079 |
*/
|
2080 |
function bp_is_create_blog() {
|
2081 |
+
return (bool) ( bp_is_blogs_component() && bp_is_current_action( 'create' ) );
|
|
|
|
|
|
|
2082 |
}
|
2083 |
|
2084 |
/**
|
2085 |
* Is the current page the blogs directory ?
|
2086 |
*
|
2087 |
* @since BuddyPress (2.0.0)
|
2088 |
+
*
|
2089 |
* @return True if the current page is the blogs directory.
|
2090 |
*/
|
2091 |
function bp_is_blogs_directory() {
|
2092 |
+
if ( is_multisite() && bp_is_blogs_component() && ! bp_current_action() ) {
|
2093 |
return true;
|
2094 |
+
}
|
2095 |
|
2096 |
return false;
|
2097 |
}
|
2106 |
* @return bool True if the current page is part of a user's Messages pages.
|
2107 |
*/
|
2108 |
function bp_is_user_messages() {
|
2109 |
+
return (bool) ( bp_is_user() && bp_is_messages_component() );
|
|
|
|
|
|
|
2110 |
}
|
2111 |
|
2112 |
/**
|
2117 |
* @return bool True if the current page is a user's Messages Inbox.
|
2118 |
*/
|
2119 |
function bp_is_messages_inbox() {
|
2120 |
+
if ( bp_is_user_messages() && ( ! bp_current_action() || bp_is_current_action( 'inbox' ) ) ) {
|
2121 |
return true;
|
2122 |
+
}
|
2123 |
|
2124 |
return false;
|
2125 |
}
|
2132 |
* @return bool True if the current page is a user's Messages Sentbox.
|
2133 |
*/
|
2134 |
function bp_is_messages_sentbox() {
|
2135 |
+
return (bool) ( bp_is_user_messages() && bp_is_current_action( 'sentbox' ) );
|
|
|
|
|
|
|
2136 |
}
|
2137 |
|
2138 |
/**
|
2143 |
* @return bool True if the current page is a user's Messages Compose screen.
|
2144 |
*/
|
2145 |
function bp_is_messages_compose_screen() {
|
2146 |
+
return (bool) ( bp_is_user_messages() && bp_is_current_action( 'compose' ) );
|
|
|
|
|
|
|
2147 |
}
|
2148 |
|
2149 |
/**
|
2154 |
* @return bool True if the current page is the Notices screen.
|
2155 |
*/
|
2156 |
function bp_is_notices() {
|
2157 |
+
return (bool) ( bp_is_user_messages() && bp_is_current_action( 'notices' ) );
|
|
|
|
|
|
|
2158 |
}
|
2159 |
|
2160 |
/**
|
2163 |
* @return bool True if the current page a single Messages conversation thread?
|
2164 |
*/
|
2165 |
function bp_is_messages_conversation() {
|
2166 |
+
return (bool) ( bp_is_user_messages() && ( bp_is_current_action( 'view' ) ) );
|
|
|
|
|
|
|
2167 |
}
|
2168 |
|
2169 |
/**
|
2172 |
* @return bool
|
2173 |
*/
|
2174 |
function bp_is_single( $component, $callback ) {
|
2175 |
+
return (bool) ( bp_is_current_component( $component ) && ( true === call_user_func( $callback ) ) );
|
|
|
|
|
|
|
2176 |
}
|
2177 |
|
2178 |
/** Registration **************************************************************/
|
2185 |
* @return bool True if the current page is the Activate page.
|
2186 |
*/
|
2187 |
function bp_is_activation_page() {
|
2188 |
+
return (bool) bp_is_current_component( 'activate' );
|
|
|
|
|
|
|
2189 |
}
|
2190 |
|
2191 |
/**
|
2196 |
* @return bool True if the current page is the Register page.
|
2197 |
*/
|
2198 |
function bp_is_register_page() {
|
2199 |
+
return (bool) bp_is_current_component( 'register' );
|
|
|
|
|
|
|
2200 |
}
|
2201 |
|
2202 |
/**
|
2217 |
|
2218 |
/** Pages *************************************************************/
|
2219 |
|
2220 |
+
if ( is_front_page() ) {
|
2221 |
$bp_classes[] = 'home-page';
|
2222 |
+
}
|
2223 |
|
2224 |
+
if ( bp_is_directory() ) {
|
2225 |
$bp_classes[] = 'directory';
|
2226 |
+
}
|
2227 |
|
2228 |
+
if ( bp_is_single_item() ) {
|
2229 |
$bp_classes[] = 'single-item';
|
2230 |
+
}
|
2231 |
|
2232 |
/** Components ********************************************************/
|
2233 |
|
2234 |
+
if ( ! bp_is_blog_page() ) {
|
2235 |
+
if ( bp_is_user_profile() ) {
|
2236 |
$bp_classes[] = 'xprofile';
|
2237 |
+
}
|
2238 |
|
2239 |
+
if ( bp_is_activity_component() ) {
|
2240 |
$bp_classes[] = 'activity';
|
2241 |
+
}
|
2242 |
|
2243 |
+
if ( bp_is_blogs_component() ) {
|
2244 |
$bp_classes[] = 'blogs';
|
2245 |
+
}
|
2246 |
|
2247 |
+
if ( bp_is_messages_component() ) {
|
2248 |
$bp_classes[] = 'messages';
|
2249 |
+
}
|
2250 |
|
2251 |
+
if ( bp_is_friends_component() ) {
|
2252 |
$bp_classes[] = 'friends';
|
2253 |
+
}
|
2254 |
|
2255 |
+
if ( bp_is_groups_component() ) {
|
2256 |
$bp_classes[] = 'groups';
|
2257 |
+
}
|
2258 |
|
2259 |
+
if ( bp_is_settings_component() ) {
|
2260 |
$bp_classes[] = 'settings';
|
2261 |
+
}
|
2262 |
+
}
|
2263 |
|
2264 |
/** User **************************************************************/
|
2265 |
|
2266 |
+
if ( bp_is_user() ) {
|
2267 |
$bp_classes[] = 'bp-user';
|
2268 |
+
}
|
2269 |
|
2270 |
+
if ( ! bp_is_directory() ) {
|
2271 |
+
if ( bp_is_user_blogs() ) {
|
2272 |
$bp_classes[] = 'my-blogs';
|
2273 |
+
}
|
2274 |
|
2275 |
+
if ( bp_is_user_groups() ) {
|
2276 |
$bp_classes[] = 'my-groups';
|
2277 |
+
}
|
2278 |
|
2279 |
+
if ( bp_is_user_activity() ) {
|
2280 |
$bp_classes[] = 'my-activity';
|
2281 |
+
}
|
2282 |
+
}
|
2283 |
|
2284 |
+
if ( bp_is_my_profile() ) {
|
2285 |
$bp_classes[] = 'my-account';
|
2286 |
+
}
|
2287 |
|
2288 |
+
if ( bp_is_user_profile() ) {
|
2289 |
$bp_classes[] = 'my-profile';
|
2290 |
+
}
|
2291 |
|
2292 |
+
if ( bp_is_user_friends() ) {
|
2293 |
$bp_classes[] = 'my-friends';
|
2294 |
+
}
|
2295 |
|
2296 |
+
if ( bp_is_user_messages() ) {
|
2297 |
$bp_classes[] = 'my-messages';
|
2298 |
+
}
|
2299 |
|
2300 |
+
if ( bp_is_user_recent_commments() ) {
|
2301 |
$bp_classes[] = 'recent-comments';
|
2302 |
+
}
|
2303 |
|
2304 |
+
if ( bp_is_user_recent_posts() ) {
|
2305 |
$bp_classes[] = 'recent-posts';
|
2306 |
+
}
|
2307 |
|
2308 |
+
if ( bp_is_user_change_avatar() ) {
|
2309 |
$bp_classes[] = 'change-avatar';
|
2310 |
+
}
|
2311 |
|
2312 |
+
if ( bp_is_user_profile_edit() ) {
|
2313 |
$bp_classes[] = 'profile-edit';
|
2314 |
+
}
|
2315 |
|
2316 |
+
if ( bp_is_user_friends_activity() ) {
|
2317 |
$bp_classes[] = 'friends-activity';
|
2318 |
+
}
|
2319 |
|
2320 |
+
if ( bp_is_user_groups_activity() ) {
|
2321 |
$bp_classes[] = 'groups-activity';
|
2322 |
+
}
|
2323 |
|
2324 |
/** Messages **********************************************************/
|
2325 |
|
2326 |
+
if ( bp_is_messages_inbox() ) {
|
2327 |
$bp_classes[] = 'inbox';
|
2328 |
+
}
|
2329 |
|
2330 |
+
if ( bp_is_messages_sentbox() ) {
|
2331 |
$bp_classes[] = 'sentbox';
|
2332 |
+
}
|
2333 |
|
2334 |
+
if ( bp_is_messages_compose_screen() ) {
|
2335 |
$bp_classes[] = 'compose';
|
2336 |
+
}
|
2337 |
|
2338 |
+
if ( bp_is_notices() ) {
|
2339 |
$bp_classes[] = 'notices';
|
2340 |
+
}
|
2341 |
|
2342 |
+
if ( bp_is_user_friend_requests() ) {
|
2343 |
$bp_classes[] = 'friend-requests';
|
2344 |
+
}
|
2345 |
|
2346 |
+
if ( bp_is_create_blog() ) {
|
2347 |
$bp_classes[] = 'create-blog';
|
2348 |
+
}
|
2349 |
|
2350 |
/** Groups ************************************************************/
|
2351 |
|
2352 |
+
if ( bp_is_group_leave() ) {
|
2353 |
$bp_classes[] = 'leave-group';
|
2354 |
+
}
|
2355 |
|
2356 |
+
if ( bp_is_group_invites() ) {
|
2357 |
$bp_classes[] = 'group-invites';
|
2358 |
+
}
|
2359 |
|
2360 |
+
if ( bp_is_group_members() ) {
|
2361 |
$bp_classes[] = 'group-members';
|
2362 |
+
}
|
2363 |
|
2364 |
+
if ( bp_is_group_forum_topic() ) {
|
2365 |
$bp_classes[] = 'group-forum-topic';
|
2366 |
+
}
|
2367 |
|
2368 |
+
if ( bp_is_group_forum_topic_edit() ) {
|
2369 |
$bp_classes[] = 'group-forum-topic-edit';
|
2370 |
+
}
|
2371 |
|
2372 |
+
if ( bp_is_group_forum() ) {
|
2373 |
$bp_classes[] = 'group-forum';
|
2374 |
+
}
|
2375 |
|
2376 |
if ( bp_is_group_admin_page() ) {
|
2377 |
$bp_classes[] = 'group-admin';
|
2383 |
$bp_classes[] = bp_get_groups_current_create_step();
|
2384 |
}
|
2385 |
|
2386 |
+
if ( bp_is_group_home() ) {
|
2387 |
$bp_classes[] = 'group-home';
|
2388 |
+
}
|
2389 |
|
2390 |
+
if ( bp_is_single_activity() ) {
|
2391 |
$bp_classes[] = 'activity-permalink';
|
2392 |
+
}
|
2393 |
|
2394 |
/** Registration ******************************************************/
|
2395 |
|
2396 |
+
if ( bp_is_register_page() ) {
|
2397 |
$bp_classes[] = 'registration';
|
2398 |
+
}
|
2399 |
|
2400 |
+
if ( bp_is_activation_page() ) {
|
2401 |
$bp_classes[] = 'activation';
|
2402 |
+
}
|
2403 |
|
2404 |
/** Current Component & Action ****************************************/
|
2405 |
|
2406 |
+
if ( ! bp_is_blog_page() ) {
|
2407 |
$bp_classes[] = bp_current_component();
|
2408 |
$bp_classes[] = bp_current_action();
|
2409 |
}
|
2422 |
}
|
2423 |
add_filter( 'body_class', 'bp_get_the_body_class', 10, 2 );
|
2424 |
|
2425 |
+
/**
|
2426 |
+
* Customizes the post CSS class according to BuddyPress content.
|
2427 |
+
*
|
2428 |
+
* Hooked to the 'post_class' filter.
|
2429 |
+
*
|
2430 |
+
* @since BuddyPress (2.1.0)
|
2431 |
+
*
|
2432 |
+
* @param array $wp_classes The post classes coming from WordPress.
|
2433 |
+
* @return array
|
2434 |
+
*/
|
2435 |
+
function bp_get_the_post_class( $wp_classes = array() ) {
|
2436 |
+
// don't do anything if we're not on a BP page
|
2437 |
+
if ( ! is_buddypress() ) {
|
2438 |
+
return $wp_classes;
|
2439 |
+
}
|
2440 |
+
|
2441 |
+
$bp_classes = array();
|
2442 |
+
|
2443 |
+
if ( bp_is_user() || bp_is_single_activity() ) {
|
2444 |
+
$bp_classes[] = 'bp_members';
|
2445 |
+
|
2446 |
+
} elseif ( bp_is_group() ) {
|
2447 |
+
$bp_classes[] = 'bp_group';
|
2448 |
+
|
2449 |
+
} elseif ( bp_is_activity_component() ) {
|
2450 |
+
$bp_classes[] = 'bp_activity';
|
2451 |
+
|
2452 |
+
} elseif ( bp_is_blogs_component() ) {
|
2453 |
+
$bp_classes[] = 'bp_blogs';
|
2454 |
+
|
2455 |
+
} elseif ( bp_is_register_page() ) {
|
2456 |
+
$bp_classes[] = 'bp_register';
|
2457 |
+
|
2458 |
+
} elseif ( bp_is_activation_page() ) {
|
2459 |
+
$bp_classes[] = 'bp_activate';
|
2460 |
+
|
2461 |
+
} elseif ( bp_is_forums_component() && bp_is_directory() ) {
|
2462 |
+
$bp_classes[] = 'bp_forum';
|
2463 |
+
}
|
2464 |
+
|
2465 |
+
if ( empty( $bp_classes ) ) {
|
2466 |
+
return $wp_classes;
|
2467 |
+
}
|
2468 |
+
|
2469 |
+
// emulate post type css class
|
2470 |
+
foreach ( $bp_classes as $bp_class ) {
|
2471 |
+
$bp_classes[] = "type-{$bp_class}";
|
2472 |
+
}
|
2473 |
+
|
2474 |
+
// removes the 'page' and 'type-page' post classes
|
2475 |
+
// we need to remove these classes since they did not exist before we switched
|
2476 |
+
// theme compat to use the 'page' post type
|
2477 |
+
$page_key = array_search( 'page', $wp_classes );
|
2478 |
+
$page_type_key = array_search( 'type-page', $wp_classes );
|
2479 |
+
unset( $wp_classes[$page_key], $wp_classes[$page_type_key] );
|
2480 |
+
|
2481 |
+
// okay let's merge!
|
2482 |
+
return array_unique( array_merge( $bp_classes, $wp_classes ) );
|
2483 |
+
}
|
2484 |
+
add_filter( 'post_class', 'bp_get_the_post_class' );
|
2485 |
+
|
2486 |
/**
|
2487 |
* Sort BuddyPress nav menu items by their position property.
|
2488 |
*
|
2498 |
* the first argument is considered to be respectively less than, equal to, or greater than the second.
|
2499 |
*/
|
2500 |
function _bp_nav_menu_sort( $a, $b ) {
|
2501 |
+
if ( $a['position'] == $b['position'] ) {
|
2502 |
return 0;
|
2503 |
+
} elseif ( $a['position'] < $b['position'] ) {
|
|
|
2504 |
return -1;
|
2505 |
+
} else {
|
|
|
2506 |
return 1;
|
2507 |
+
}
|
2508 |
}
|
2509 |
|
2510 |
/**
|
2521 |
foreach ( (array) buddypress()->bp_options_nav as $parent_menu => $sub_menus ) {
|
2522 |
|
2523 |
// The root menu's ID is "xprofile", but the Profile submenus are using "profile". See BP_Core::setup_nav().
|
2524 |
+
if ( 'profile' === $parent_menu ) {
|
2525 |
$parent_menu = 'xprofile';
|
2526 |
+
}
|
2527 |
|
2528 |
// Sort the items in this menu's navigation by their position property
|
2529 |
$second_level_menus = (array) $sub_menus;
|
2533 |
foreach( $second_level_menus as $sub_nav ) {
|
2534 |
|
2535 |
// Skip items we don't have access to
|
2536 |
+
if ( empty( $sub_nav['user_has_access'] ) ) {
|
2537 |
continue;
|
2538 |
+
}
|
2539 |
|
2540 |
// Add this menu
|
2541 |
$menu = new stdClass;
|
2542 |
+
$menu->class = array( 'menu-child' );
|
2543 |
$menu->css_id = $sub_nav['css_id'];
|
2544 |
$menu->link = $sub_nav['link'];
|
2545 |
$menu->name = $sub_nav['name'];
|
2547 |
|
2548 |
// If we're viewing this item's screen, record that we need to mark its parent menu to be selected
|
2549 |
if ( $sub_nav['slug'] == bp_current_action() ) {
|
2550 |
+
$menu->class[] = 'current-menu-item';
|
2551 |
$selected_menus[] = $parent_menu;
|
2552 |
}
|
2553 |
|
2563 |
foreach ( $top_level_menus as $nav ) {
|
2564 |
|
2565 |
// Skip items marked as user-specific if you're not on your own profile
|
2566 |
+
if ( empty( $nav['show_for_displayed_user'] ) && ! bp_core_can_edit_settings() ) {
|
2567 |
continue;
|
2568 |
+
}
|
2569 |
|
2570 |
// Get the correct menu link. See http://buddypress.trac.wordpress.org/ticket/4624
|
2571 |
$link = bp_loggedin_user_domain() ? str_replace( bp_loggedin_user_domain(), bp_displayed_user_domain(), $nav['link'] ) : trailingslashit( bp_displayed_user_domain() . $nav['link'] );
|
2572 |
|
2573 |
// Add this menu
|
2574 |
$menu = new stdClass;
|
2575 |
+
$menu->class = array( 'menu-parent' );
|
2576 |
$menu->css_id = $nav['css_id'];
|
2577 |
$menu->link = $link;
|
2578 |
$menu->name = $nav['name'];
|
2579 |
$menu->parent = 0;
|
2580 |
|
2581 |
// Check if we need to mark this menu as selected
|
2582 |
+
if ( in_array( $nav['css_id'], $selected_menus ) ) {
|
2583 |
+
$menu->class[] = 'current-menu-parent';
|
2584 |
+
}
|
2585 |
|
2586 |
$menus[] = $menu;
|
2587 |
}
|
2652 |
$show_container = false;
|
2653 |
|
2654 |
// Create custom walker if one wasn't set
|
2655 |
+
if ( empty( $args->walker ) ) {
|
2656 |
$args->walker = new BP_Walker_Nav_Menu;
|
2657 |
+
}
|
2658 |
|
2659 |
// Sanitise values for class and ID
|
2660 |
$args->container_class = sanitize_html_class( $args->container_class );
|
2687 |
|
2688 |
// If a specific ID wasn't requested, and there are multiple menus on the same screen, make sure the autogenerated ID is unique
|
2689 |
while ( in_array( $wrap_id, $menu_id_slugs ) ) {
|
2690 |
+
if ( preg_match( '#-(\d+)$#', $wrap_id, $matches ) ) {
|
2691 |
$wrap_id = preg_replace('#-(\d+)$#', '-' . ++$matches[1], $wrap_id );
|
2692 |
+
} else {
|
2693 |
$wrap_id = $wrap_id . '-1';
|
2694 |
+
}
|
2695 |
}
|
2696 |
}
|
2697 |
$menu_id_slugs[] = $wrap_id;
|
2705 |
unset( $items );
|
2706 |
|
2707 |
// If we've wrapped the ul, close it
|
2708 |
+
if ( ! empty( $show_container ) ) {
|
2709 |
$nav_menu .= '</' . $args->container . '>';
|
2710 |
+
}
|
2711 |
|
2712 |
// Final chance to modify output
|
2713 |
$nav_menu = apply_filters( 'bp_nav_menu', $nav_menu, $args );
|
2714 |
|
2715 |
+
if ( ! empty( $args->echo ) ) {
|
2716 |
echo $nav_menu;
|
2717 |
+
} else {
|
2718 |
return $nav_menu;
|
2719 |
+
}
|
2720 |
}
|
@@ -163,8 +163,9 @@ function bp_version_bump() {
|
|
163 |
function bp_setup_updater() {
|
164 |
|
165 |
// Are we running an outdated version of BuddyPress?
|
166 |
-
if ( ! bp_is_update() )
|
167 |
return;
|
|
|
168 |
|
169 |
bp_version_updater();
|
170 |
}
|
@@ -400,8 +401,9 @@ function bp_update_to_2_0_1() {
|
|
400 |
function bp_add_activation_redirect() {
|
401 |
|
402 |
// Bail if activating from network, or bulk
|
403 |
-
if ( isset( $_GET['activate-multi'] ) )
|
404 |
return;
|
|
|
405 |
|
406 |
// Record that this is a new installation, so we show the right
|
407 |
// welcome message
|
@@ -416,7 +418,7 @@ function bp_add_activation_redirect() {
|
|
416 |
/** Signups *******************************************************************/
|
417 |
|
418 |
/**
|
419 |
-
* Check if the signups table needs to be created.
|
420 |
*
|
421 |
* @since BuddyPress (2.0.0)
|
422 |
*
|
@@ -425,12 +427,6 @@ function bp_add_activation_redirect() {
|
|
425 |
* @return bool If signups table exists
|
426 |
*/
|
427 |
function bp_core_maybe_install_signups() {
|
428 |
-
|
429 |
-
// Bail if we are explicitly not upgrading global tables
|
430 |
-
if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
|
431 |
-
return false;
|
432 |
-
}
|
433 |
-
|
434 |
global $wpdb;
|
435 |
|
436 |
// The table to run queries against
|
163 |
function bp_setup_updater() {
|
164 |
|
165 |
// Are we running an outdated version of BuddyPress?
|
166 |
+
if ( ! bp_is_update() ) {
|
167 |
return;
|
168 |
+
}
|
169 |
|
170 |
bp_version_updater();
|
171 |
}
|
401 |
function bp_add_activation_redirect() {
|
402 |
|
403 |
// Bail if activating from network, or bulk
|
404 |
+
if ( isset( $_GET['activate-multi'] ) ) {
|
405 |
return;
|
406 |
+
}
|
407 |
|
408 |
// Record that this is a new installation, so we show the right
|
409 |
// welcome message
|
418 |
/** Signups *******************************************************************/
|
419 |
|
420 |
/**
|
421 |
+
* Check if the signups table needs to be created or upgraded.
|
422 |
*
|
423 |
* @since BuddyPress (2.0.0)
|
424 |
*
|
427 |
* @return bool If signups table exists
|
428 |
*/
|
429 |
function bp_core_maybe_install_signups() {
|
|
|
|
|
|
|
|
|
|
|
|
|
430 |
global $wpdb;
|
431 |
|
432 |
// The table to run queries against
|
@@ -69,7 +69,7 @@ class BP_Core_Login_Widget extends WP_Widget {
|
|
69 |
|
70 |
<div class="bp-login-widget-user-links">
|
71 |
<div class="bp-login-widget-user-link"><?php echo bp_core_get_userlink( bp_loggedin_user_id() ); ?></div>
|
72 |
-
<div class="bp-login-widget-user-logout"><a class="logout" href="<?php echo wp_logout_url(
|
73 |
</div>
|
74 |
|
75 |
<?php do_action( 'bp_after_login_widget_loggedin' ); ?>
|
@@ -154,8 +154,7 @@ class BP_Core_Members_Widget extends WP_Widget {
|
|
154 |
parent::__construct( false, $name = _x( '(BuddyPress) Members', 'widget name', 'buddypress' ), $widget_ops );
|
155 |
|
156 |
if ( is_active_widget( false, false, $this->id_base ) && !is_admin() && !is_network_admin() ) {
|
157 |
-
|
158 |
-
wp_enqueue_script( 'bp_core_widget_members-js', buddypress()->plugin_url . "bp-core/js/widget-members{$min}.js", array( 'jquery' ), bp_get_version() );
|
159 |
}
|
160 |
}
|
161 |
|
@@ -315,7 +314,7 @@ class BP_Core_Whos_Online_Widget extends WP_Widget {
|
|
315 |
*/
|
316 |
function __construct() {
|
317 |
$widget_ops = array(
|
318 |
-
'description' => __( '
|
319 |
'classname' => 'widget_bp_core_whos_online_widget buddypress widget',
|
320 |
);
|
321 |
parent::__construct( false, $name = _x( "(BuddyPress) Who's Online", 'widget name', 'buddypress' ), $widget_ops );
|
@@ -418,7 +417,7 @@ class BP_Core_Recently_Active_Widget extends WP_Widget {
|
|
418 |
*/
|
419 |
function __construct() {
|
420 |
$widget_ops = array(
|
421 |
-
'description' => __( '
|
422 |
'classname' => 'widget_bp_core_recently_active_widget buddypress widget',
|
423 |
);
|
424 |
parent::__construct( false, $name = _x( '(BuddyPress) Recently Active Members', 'widget name', 'buddypress' ), $widget_ops );
|
69 |
|
70 |
<div class="bp-login-widget-user-links">
|
71 |
<div class="bp-login-widget-user-link"><?php echo bp_core_get_userlink( bp_loggedin_user_id() ); ?></div>
|
72 |
+
<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>
|
73 |
</div>
|
74 |
|
75 |
<?php do_action( 'bp_after_login_widget_loggedin' ); ?>
|
154 |
parent::__construct( false, $name = _x( '(BuddyPress) Members', 'widget name', 'buddypress' ), $widget_ops );
|
155 |
|
156 |
if ( is_active_widget( false, false, $this->id_base ) && !is_admin() && !is_network_admin() ) {
|
157 |
+
wp_enqueue_script( 'bp-widget-members' );
|
|
|
158 |
}
|
159 |
}
|
160 |
|
314 |
*/
|
315 |
function __construct() {
|
316 |
$widget_ops = array(
|
317 |
+
'description' => __( 'Profile photos of online users', 'buddypress' ),
|
318 |
'classname' => 'widget_bp_core_whos_online_widget buddypress widget',
|
319 |
);
|
320 |
parent::__construct( false, $name = _x( "(BuddyPress) Who's Online", 'widget name', 'buddypress' ), $widget_ops );
|
417 |
*/
|
418 |
function __construct() {
|
419 |
$widget_ops = array(
|
420 |
+
'description' => __( 'Profile photos of recently active members', 'buddypress' ),
|
421 |
'classname' => 'widget_bp_core_recently_active_widget buddypress widget',
|
422 |
);
|
423 |
parent::__construct( false, $name = _x( '(BuddyPress) Recently Active Members', 'widget name', 'buddypress' ), $widget_ops );
|
@@ -1,27 +1,58 @@
|
|
1 |
-
|
2 |
-
#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar ul {
|
3 |
-
left: auto;
|
4 |
-
right: 0;
|
5 |
-
}
|
6 |
#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar > a img,
|
7 |
#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar > a img {
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
}
|
10 |
-
|
|
|
11 |
#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul {
|
12 |
-
|
13 |
-
right: 30px;
|
14 |
}
|
15 |
-
#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar ul ul,
|
16 |
#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul ul {
|
17 |
-
left: auto;
|
18 |
right: 0;
|
19 |
}
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
-
#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul ul {
|
25 |
-
left: auto;
|
26 |
-
right: 0;
|
27 |
-
}
|
1 |
+
/* Displayed User */
|
|
|
|
|
|
|
|
|
2 |
#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar > a img,
|
3 |
#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar > a img {
|
4 |
+
width: 16px;
|
5 |
+
height: 16px;
|
6 |
+
display: inline;
|
7 |
+
border: 1px solid #999;
|
8 |
+
vertical-align: middle;
|
9 |
+
margin: -2px -5px 0 10px;
|
10 |
+
padding: 0;
|
11 |
+
background: #eee;
|
12 |
+
float: none;
|
13 |
}
|
14 |
+
|
15 |
+
/* Displayed Group */
|
16 |
#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul {
|
17 |
+
right: 0;
|
|
|
18 |
}
|
|
|
19 |
#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul ul {
|
|
|
20 |
right: 0;
|
21 |
}
|
22 |
+
|
23 |
+
/* Notifications */
|
24 |
+
#wpadminbar .quicklinks li#wp-admin-bar-my-account a span.count,
|
25 |
+
#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar a span.count,
|
26 |
+
#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications {
|
27 |
+
background: #21759B;
|
28 |
+
color: #fff;
|
29 |
+
text-shadow: none;
|
30 |
+
display: inline;
|
31 |
+
padding: 2px 5px;
|
32 |
+
font-size: 10px;
|
33 |
+
font-weight: bold;
|
34 |
+
-moz-border-radius: 10px;
|
35 |
+
-khtml-border-radius: 10px;
|
36 |
+
-webkit-border-radius: 10px;
|
37 |
+
border-radius: 10px;
|
38 |
+
}
|
39 |
+
|
40 |
+
#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications {
|
41 |
+
background: #ddd;
|
42 |
+
color: #333;
|
43 |
+
margin: 0
|
44 |
+
}
|
45 |
+
|
46 |
+
#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications.alert {
|
47 |
+
background-color: #1fb3dd;
|
48 |
+
color: #fff;
|
49 |
+
}
|
50 |
+
|
51 |
+
#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications > a {
|
52 |
+
padding: 0 .5em;
|
53 |
+
}
|
54 |
+
|
55 |
+
#wp-admin-bar-user-info img.avatar {
|
56 |
+
height: 64px;
|
57 |
+
width: 64px;
|
58 |
}
|
|
|
|
|
|
|
|
@@ -1 +1,2 @@
|
|
1 |
-
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar>a img,#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar>a img{width:16px;height:16px;display:inline;border:1px solid #999;vertical-align:middle;margin:-2px -5px 0 10px;padding:0;background:#eee;float:none}#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul,#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul ul{right:0}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications,#wpadminbar .quicklinks li#wp-admin-bar-my-account a span.count,#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar a span.count{background:#21759B;color:#fff;text-shadow:none;display:inline;padding:2px 5px;font-size:10px;font-weight:700;-moz-border-radius:10px;-khtml-border-radius:10px;-webkit-border-radius:10px;border-radius:10px}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications{background:#ddd;color:#333;margin:0}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications.alert{background-color:#1fb3dd;color:#fff}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications>a{padding:0 .5em}#wp-admin-bar-user-info img.avatar{height:64px;width:64px}
|
@@ -55,4 +55,4 @@
|
|
55 |
#wp-admin-bar-user-info img.avatar {
|
56 |
height: 64px;
|
57 |
width: 64px;
|
58 |
-
}
|
55 |
#wp-admin-bar-user-info img.avatar {
|
56 |
height: 64px;
|
57 |
width: 64px;
|
58 |
+
}
|
@@ -1 +1,2 @@
|
|
1 |
-
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar>a img,#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar>a img{width:16px;height:16px;display:inline;border:1px solid #999;vertical-align:middle;margin:-2px 10px 0 -5px;padding:0;background:#eee;float:none}#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul,#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul ul{left:0}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications,#wpadminbar .quicklinks li#wp-admin-bar-my-account a span.count,#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar a span.count{background:#21759B;color:#fff;text-shadow:none;display:inline;padding:2px 5px;font-size:10px;font-weight:700;-moz-border-radius:10px;-khtml-border-radius:10px;-webkit-border-radius:10px;border-radius:10px}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications{background:#ddd;color:#333;margin:0}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications.alert{background-color:#1fb3dd;color:#fff}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications>a{padding:0 .5em}#wp-admin-bar-user-info img.avatar{height:64px;width:64px}
|
@@ -1,77 +1,203 @@
|
|
|
|
|
|
|
|
1 |
#wp-admin-bar {
|
|
|
|
|
2 |
right: 0;
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
}
|
5 |
#wp-admin-bar div#admin-bar-logo {
|
|
|
|
|
6 |
right: 10px;
|
7 |
-
|
|
|
|
|
8 |
}
|
9 |
#wp-admin-bar li {
|
|
|
|
|
|
|
|
|
10 |
text-align: right;
|
11 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
#wp-admin-bar li.no-arrow a {
|
13 |
padding-left: 15px;
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
#admin-bar-logo {
|
17 |
float: right;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
float: right;
|
|
|
22 |
background: url('../images/admin-menu-arrow.gif') 12% 53% no-repeat;
|
23 |
padding-left: 11px;
|
24 |
-
padding-right: 0;
|
25 |
}
|
26 |
#wp-admin-bar ul li.no-arrow {
|
|
|
27 |
padding-left: 0;
|
28 |
}
|
|
|
|
|
|
|
29 |
#wp-admin-bar ul li.align-right {
|
|
|
30 |
left: 0;
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
}
|
33 |
|
34 |
/* second-level lists */
|
35 |
#wp-admin-bar ul li ul {
|
|
|
|
|
36 |
right: -999em;
|
37 |
-
left: auto;
|
38 |
margin-right: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
#wp-admin-bar ul li ul li {
|
41 |
float: right;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
}
|
43 |
|
44 |
/* third-and-above-level lists */
|
45 |
#wp-admin-bar ul li ul ul {
|
46 |
margin: -25px 184px 0 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
#wp-admin-bar ul li:hover ul,
|
49 |
-
#wp-admin-bar ul li li:hover ul,
|
50 |
#wp-admin-bar ul li.sfhover ul,
|
51 |
-
#wp-admin-bar ul li ul li.sfhover ul {
|
52 |
right: auto;
|
53 |
}
|
54 |
#wp-admin-bar ul li.align-right:hover ul {
|
55 |
left: 0;
|
56 |
-
right: auto;
|
57 |
}
|
58 |
#wp-admin-bar ul li:hover ul ul,
|
59 |
#wp-admin-bar li.sfhover ul li ul {
|
60 |
right: -999em;
|
61 |
-
left: auto;
|
62 |
}
|
63 |
|
64 |
/* Menu item css */
|
65 |
#wp-admin-bar img.avatar {
|
66 |
float: right;
|
67 |
margin-left: 8px;
|
68 |
-
margin-right: 0;
|
69 |
}
|
70 |
#wp-admin-bar span.activity {
|
|
|
71 |
margin-right: 34px;
|
72 |
-
|
|
|
|
|
|
|
73 |
}
|
74 |
#wp-admin-bar ul li#bp-adminbar-notifications-menu a span {
|
|
|
75 |
margin-right: 2px;
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
body:not(.wp-admin) {
|
2 |
+
padding-top: 25px !important;
|
3 |
+
}
|
4 |
#wp-admin-bar {
|
5 |
+
position: fixed;
|
6 |
+
top: 0;
|
7 |
right: 0;
|
8 |
+
height: 25px;
|
9 |
+
font-size: 11px;
|
10 |
+
width: 100%;
|
11 |
+
z-index: 9999;
|
12 |
+
}
|
13 |
+
#wp-admin-bar .padder {
|
14 |
+
position: relative;
|
15 |
+
padding: 0;
|
16 |
+
width: 100%;
|
17 |
+
margin: 0 auto;
|
18 |
+
background: url('../images/60pc_black.png');
|
19 |
+
height: 25px;
|
20 |
+
}
|
21 |
+
body#bp-default #wp-admin-bar .padder {
|
22 |
+
max-width: 1250px;
|
23 |
+
}
|
24 |
+
#wp-admin-bar * {
|
25 |
+
z-index: 999;
|
26 |
}
|
27 |
#wp-admin-bar div#admin-bar-logo {
|
28 |
+
position: absolute;
|
29 |
+
top: 5px;
|
30 |
right: 10px;
|
31 |
+
}
|
32 |
+
#wp-admin-bar a img {
|
33 |
+
border: none;
|
34 |
}
|
35 |
#wp-admin-bar li {
|
36 |
+
list-style: none;
|
37 |
+
margin: 0;
|
38 |
+
padding: 0;
|
39 |
+
line-height: 100%;
|
40 |
text-align: right;
|
41 |
}
|
42 |
+
#wp-admin-bar li a {
|
43 |
+
padding: 7px 15px 7px 15px;
|
44 |
+
color: #eee;
|
45 |
+
text-decoration: none;
|
46 |
+
font-size: 11px;
|
47 |
+
}
|
48 |
+
#wp-admin-bar li.alt {
|
49 |
+
border: none;
|
50 |
+
}
|
51 |
#wp-admin-bar li.no-arrow a {
|
52 |
padding-left: 15px;
|
53 |
+
}
|
54 |
+
#wp-admin-bar ul li ul li a span {
|
55 |
+
display: none;
|
56 |
+
}
|
57 |
+
#wp-admin-bar li:hover,
|
58 |
+
#wp-admin-bar li.hover {
|
59 |
+
position: static;
|
60 |
}
|
61 |
#admin-bar-logo {
|
62 |
float: right;
|
63 |
+
font-weight: bold;
|
64 |
+
font-size: 11px;
|
65 |
+
padding: 5px 8px;
|
66 |
+
margin: 0;
|
67 |
+
text-decoration: none;
|
68 |
+
color: #fff;
|
69 |
+
}
|
70 |
+
body#bp-default #admin-bar-logo {
|
71 |
+
padding: 2px 8px;
|
72 |
}
|
73 |
|
74 |
+
/* all lists */
|
75 |
+
#wp-admin-bar ul {
|
76 |
+
margin: 0;
|
77 |
+
list-style: none;
|
78 |
+
line-height: 1;
|
79 |
+
cursor: pointer;
|
80 |
+
height: auto;
|
81 |
+
padding: 0;
|
82 |
+
}
|
83 |
+
|
84 |
+
/* all list items */
|
85 |
+
#wp-admin-bar ul li {
|
86 |
+
padding: 0;
|
87 |
float: right;
|
88 |
+
position: relative;
|
89 |
background: url('../images/admin-menu-arrow.gif') 12% 53% no-repeat;
|
90 |
padding-left: 11px;
|
|
|
91 |
}
|
92 |
#wp-admin-bar ul li.no-arrow {
|
93 |
+
background: none;
|
94 |
padding-left: 0;
|
95 |
}
|
96 |
+
#wp-admin-bar ul li ul li {
|
97 |
+
background-image: none;
|
98 |
+
}
|
99 |
#wp-admin-bar ul li.align-right {
|
100 |
+
position: absolute;
|
101 |
left: 0;
|
102 |
+
}
|
103 |
+
#wp-admin-bar ul li a {
|
104 |
+
display: block;
|
105 |
+
}
|
106 |
+
#wp-admin-bar ul.main-nav li:hover,
|
107 |
+
#wp-admin-bar ul.main-nav li.sfhover,
|
108 |
+
#wp-admin-bar ul.main-nav li ul li.sfhover {
|
109 |
+
background-color: #333;
|
110 |
}
|
111 |
|
112 |
/* second-level lists */
|
113 |
#wp-admin-bar ul li ul {
|
114 |
+
position: absolute;
|
115 |
+
width: 185px;
|
116 |
right: -999em;
|
|
|
117 |
margin-right: 0;
|
118 |
+
background: #333;
|
119 |
+
border: 1px solid #222;
|
120 |
+
-moz-box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
121 |
+
-webkit-box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
122 |
+
-moz-border-radius: 3px;
|
123 |
+
-webkit-border-radius: 3px;
|
124 |
+
-moz-border-radius-topleft: 0;
|
125 |
+
-webkit-border-top-right-radius: 0;
|
126 |
+
-moz-border-radius-topright: 0;
|
127 |
+
-webkit-border-top-left-radius: 0;
|
128 |
+
}
|
129 |
+
#wp-admin-bar ul li > ul {
|
130 |
+
border-top: none;
|
131 |
+
}
|
132 |
+
#wp-admin-bar ul li ul a {
|
133 |
+
color: #eee;
|
134 |
}
|
135 |
#wp-admin-bar ul li ul li {
|
136 |
float: right;
|
137 |
+
width: 174px;
|
138 |
+
margin: 0;
|
139 |
+
}
|
140 |
+
#wp-admin-bar ul li ul li:hover a {
|
141 |
+
color: #fff;
|
142 |
+
}
|
143 |
+
#wp-admin-bar ul li div.admin-bar-clear {
|
144 |
+
clear: both;
|
145 |
+
}
|
146 |
+
#wp-admin-bar ul.main-nav li ul li:hover,
|
147 |
+
#wp-admin-bar ul.main-nav li ul li.sfhover,
|
148 |
+
#wp-admin-bar ul.main-nav li ul li.sfhover {
|
149 |
+
background-color: #222;
|
150 |
}
|
151 |
|
152 |
/* third-and-above-level lists */
|
153 |
#wp-admin-bar ul li ul ul {
|
154 |
margin: -25px 184px 0 0;
|
155 |
+
-moz-border-radius: 3px;
|
156 |
+
-webkit-border-radius: 3px;
|
157 |
+
}
|
158 |
+
#wp-admin-bar ul li ul li:hover ul li a {
|
159 |
+
color: #eee;
|
160 |
+
}
|
161 |
+
#wp-admin-bar ul li ul li ul li:hover a {
|
162 |
+
color: #fff;
|
163 |
}
|
164 |
#wp-admin-bar ul li:hover ul,
|
165 |
+
#wp-admin-bar ul li ul li:hover ul,
|
166 |
#wp-admin-bar ul li.sfhover ul,
|
167 |
+
#wp-admin-bar ul li ul li.sfhover ul {
|
168 |
right: auto;
|
169 |
}
|
170 |
#wp-admin-bar ul li.align-right:hover ul {
|
171 |
left: 0;
|
|
|
172 |
}
|
173 |
#wp-admin-bar ul li:hover ul ul,
|
174 |
#wp-admin-bar li.sfhover ul li ul {
|
175 |
right: -999em;
|
|
|
176 |
}
|
177 |
|
178 |
/* Menu item css */
|
179 |
#wp-admin-bar img.avatar {
|
180 |
float: right;
|
181 |
margin-left: 8px;
|
|
|
182 |
}
|
183 |
#wp-admin-bar span.activity {
|
184 |
+
display: block;
|
185 |
margin-right: 34px;
|
186 |
+
padding: 0;
|
187 |
+
}
|
188 |
+
#wp-admin-bar ul.author-list li a {
|
189 |
+
height: 17px;
|
190 |
}
|
191 |
#wp-admin-bar ul li#bp-adminbar-notifications-menu a span {
|
192 |
+
padding: 0 6px;
|
193 |
margin-right: 2px;
|
194 |
+
background: #fff;
|
195 |
+
color: #000;
|
196 |
+
-moz-border-radius: 3px;
|
197 |
+
-webkit-border-radius: 3px;
|
198 |
+
border-radius: 3px;
|
199 |
+
}
|
200 |
+
#wp-admin-bar-user-info img.avatar {
|
201 |
+
height: 64px;
|
202 |
+
width: 64px;
|
203 |
+
}
|
@@ -1 +1,2 @@
|
|
1 |
-
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
body:not(.wp-admin){padding-top:25px!important}#wp-admin-bar{position:fixed;top:0;right:0;height:25px;font-size:11px;width:100%;z-index:9999}#wp-admin-bar .padder{position:relative;padding:0;width:100%;margin:0 auto;background:url(../images/60pc_black.png);height:25px}body#bp-default #wp-admin-bar .padder{max-width:1250px}#wp-admin-bar *{z-index:999}#wp-admin-bar div#admin-bar-logo{position:absolute;top:5px;right:10px}#wp-admin-bar a img{border:none}#wp-admin-bar li{list-style:none;margin:0;padding:0;line-height:100%;text-align:right}#wp-admin-bar li a{padding:7px 15px;color:#eee;text-decoration:none;font-size:11px}#wp-admin-bar li.alt{border:none}#wp-admin-bar li.no-arrow a{padding-left:15px}#wp-admin-bar ul li ul li a span{display:none}#wp-admin-bar li.hover,#wp-admin-bar li:hover{position:static}#admin-bar-logo{float:right;font-weight:700;font-size:11px;padding:5px 8px;margin:0;text-decoration:none;color:#fff}body#bp-default #admin-bar-logo{padding:2px 8px}#wp-admin-bar ul{margin:0;list-style:none;line-height:1;cursor:pointer;height:auto;padding:0}#wp-admin-bar ul li{padding:0 0 0 11px;float:right;position:relative;background:url(../images/admin-menu-arrow.gif) 12% 53% no-repeat}#wp-admin-bar ul li.no-arrow{background:0 0;padding-left:0}#wp-admin-bar ul li ul li{background-image:none}#wp-admin-bar ul li.align-right{position:absolute;left:0}#wp-admin-bar ul li a{display:block}#wp-admin-bar ul.main-nav li ul li.sfhover,#wp-admin-bar ul.main-nav li.sfhover,#wp-admin-bar ul.main-nav li:hover{background-color:#333}#wp-admin-bar ul li ul{position:absolute;width:185px;right:-999em;margin-right:0;background:#333;border:1px solid #222;-moz-box-shadow:0 4px 8px rgba(0,0,0,.1);-webkit-box-shadow:0 4px 8px rgba(0,0,0,.1);-moz-border-radius:3px;-webkit-border-radius:0 0 3px 3px;-moz-border-radius-topleft:0;-moz-border-radius-topright:0}#wp-admin-bar ul li>ul{border-top:none}#wp-admin-bar ul li ul a{color:#eee}#wp-admin-bar ul li ul li{float:right;width:174px;margin:0}#wp-admin-bar ul li ul li:hover a{color:#fff}#wp-admin-bar ul li div.admin-bar-clear{clear:both}#wp-admin-bar ul.main-nav li ul li.sfhover,#wp-admin-bar ul.main-nav li ul li:hover{background-color:#222}#wp-admin-bar ul li ul ul{margin:-25px 184px 0 0;-moz-border-radius:3px;-webkit-border-radius:3px}#wp-admin-bar ul li ul li:hover ul li a{color:#eee}#wp-admin-bar ul li ul li ul li:hover a{color:#fff}#wp-admin-bar ul li ul li.sfhover ul,#wp-admin-bar ul li ul li:hover ul,#wp-admin-bar ul li.sfhover ul,#wp-admin-bar ul li:hover ul{right:auto}#wp-admin-bar ul li.align-right:hover ul{left:0}#wp-admin-bar li.sfhover ul li ul,#wp-admin-bar ul li:hover ul ul{right:-999em}#wp-admin-bar img.avatar{float:right;margin-left:8px}#wp-admin-bar span.activity{display:block;margin-right:34px;padding:0}#wp-admin-bar ul.author-list li a{height:17px}#wp-admin-bar ul li#bp-adminbar-notifications-menu a span{padding:0 6px;margin-right:2px;background:#fff;color:#000;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px}#wp-admin-bar-user-info img.avatar{height:64px;width:64px}
|
@@ -197,7 +197,7 @@ body#bp-default #admin-bar-logo {
|
|
197 |
-webkit-border-radius: 3px;
|
198 |
border-radius: 3px;
|
199 |
}
|
200 |
-
#wp-admin-bar-user-info img.avatar {
|
201 |
-
height: 64px;
|
202 |
-
width: 64px;
|
203 |
-
}
|
197 |
-webkit-border-radius: 3px;
|
198 |
border-radius: 3px;
|
199 |
}
|
200 |
+
#wp-admin-bar-user-info img.avatar {
|
201 |
+
height: 64px;
|
202 |
+
width: 64px;
|
203 |
+
}
|
@@ -1 +1,2 @@
|
|
1 |
-
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
body:not(.wp-admin){padding-top:25px!important}#wp-admin-bar{position:fixed;top:0;left:0;height:25px;font-size:11px;width:100%;z-index:9999}#wp-admin-bar .padder{position:relative;padding:0;width:100%;margin:0 auto;background:url(../images/60pc_black.png);height:25px}body#bp-default #wp-admin-bar .padder{max-width:1250px}#wp-admin-bar *{z-index:999}#wp-admin-bar div#admin-bar-logo{position:absolute;top:5px;left:10px}#wp-admin-bar a img{border:none}#wp-admin-bar li{list-style:none;margin:0;padding:0;line-height:100%;text-align:left}#wp-admin-bar li a{padding:7px 15px;color:#eee;text-decoration:none;font-size:11px}#wp-admin-bar li.alt{border:none}#wp-admin-bar li.no-arrow a{padding-right:15px}#wp-admin-bar ul li ul li a span{display:none}#wp-admin-bar li.hover,#wp-admin-bar li:hover{position:static}#admin-bar-logo{float:left;font-weight:700;font-size:11px;padding:5px 8px;margin:0;text-decoration:none;color:#fff}body#bp-default #admin-bar-logo{padding:2px 8px}#wp-admin-bar ul{margin:0;list-style:none;line-height:1;cursor:pointer;height:auto;padding:0}#wp-admin-bar ul li{padding:0 11px 0 0;float:left;position:relative;background:url(../images/admin-menu-arrow.gif) 88% 53% no-repeat}#wp-admin-bar ul li.no-arrow{background:0 0;padding-right:0}#wp-admin-bar ul li ul li{background-image:none}#wp-admin-bar ul li.align-right{position:absolute;right:0}#wp-admin-bar ul li a{display:block}#wp-admin-bar ul.main-nav li ul li.sfhover,#wp-admin-bar ul.main-nav li.sfhover,#wp-admin-bar ul.main-nav li:hover{background-color:#333}#wp-admin-bar ul li ul{position:absolute;width:185px;left:-999em;margin-left:0;background:#333;border:1px solid #222;-moz-box-shadow:0 4px 8px rgba(0,0,0,.1);-webkit-box-shadow:0 4px 8px rgba(0,0,0,.1);-moz-border-radius:3px;-webkit-border-radius:0 0 3px 3px;-moz-border-radius-topleft:0;-moz-border-radius-topright:0}#wp-admin-bar ul li>ul{border-top:none}#wp-admin-bar ul li ul a{color:#eee}#wp-admin-bar ul li ul li{float:left;width:174px;margin:0}#wp-admin-bar ul li ul li:hover a{color:#fff}#wp-admin-bar ul li div.admin-bar-clear{clear:both}#wp-admin-bar ul.main-nav li ul li.sfhover,#wp-admin-bar ul.main-nav li ul li:hover{background-color:#222}#wp-admin-bar ul li ul ul{margin:-25px 0 0 184px;-moz-border-radius:3px;-webkit-border-radius:3px}#wp-admin-bar ul li ul li:hover ul li a{color:#eee}#wp-admin-bar ul li ul li ul li:hover a{color:#fff}#wp-admin-bar ul li ul li.sfhover ul,#wp-admin-bar ul li ul li:hover ul,#wp-admin-bar ul li.sfhover ul,#wp-admin-bar ul li:hover ul{left:auto}#wp-admin-bar ul li.align-right:hover ul{right:0}#wp-admin-bar li.sfhover ul li ul,#wp-admin-bar ul li:hover ul ul{left:-999em}#wp-admin-bar img.avatar{float:left;margin-right:8px}#wp-admin-bar span.activity{display:block;margin-left:34px;padding:0}#wp-admin-bar ul.author-list li a{height:17px}#wp-admin-bar ul li#bp-adminbar-notifications-menu a span{padding:0 6px;margin-left:2px;background:#fff;color:#000;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px}#wp-admin-bar-user-info img.avatar{height:64px;width:64px}
|
@@ -14,12 +14,12 @@
|
|
14 |
if ( !defined( 'ABSPATH' ) ) exit;
|
15 |
|
16 |
/**
|
17 |
-
* Add a notification for a specific user, from a specific component
|
18 |
*
|
19 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
20 |
-
*
|
21 |
*
|
22 |
-
* @since BuddyPress (1.0)
|
23 |
* @param string $item_id
|
24 |
* @param int $user_id
|
25 |
* @param string $component_name
|
@@ -27,7 +27,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|
27 |
* @param string $secondary_item_id
|
28 |
* @param string $date_notified
|
29 |
* @param int $is_new
|
30 |
-
* @return boolean True on success, false on
|
31 |
*/
|
32 |
function bp_core_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = 0, $date_notified = false, $is_new = 1 ) {
|
33 |
|
@@ -57,14 +57,14 @@ function bp_core_add_notification( $item_id, $user_id, $component_name, $compone
|
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
-
* Delete a specific notification by its ID
|
61 |
*
|
62 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
63 |
-
*
|
64 |
*
|
65 |
-
* @since BuddyPress (1.0)
|
66 |
-
* @param int $id
|
67 |
-
* @return boolean True on success, false on
|
68 |
*/
|
69 |
function bp_core_delete_notification( $id ) {
|
70 |
|
@@ -80,13 +80,13 @@ function bp_core_delete_notification( $id ) {
|
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
-
* Get a specific notification by its ID
|
84 |
*
|
85 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
86 |
-
*
|
87 |
*
|
88 |
-
* @since BuddyPress (1.0)
|
89 |
-
* @param int $id
|
90 |
* @return BP_Core_Notification
|
91 |
*/
|
92 |
function bp_core_get_notification( $id ) {
|
@@ -103,16 +103,15 @@ function bp_core_get_notification( $id ) {
|
|
103 |
}
|
104 |
|
105 |
/**
|
106 |
-
* Get notifications for a specific user
|
107 |
*
|
108 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
109 |
-
*
|
110 |
*
|
111 |
-
* @since BuddyPress (1.0)
|
112 |
-
* @
|
113 |
-
* @param int $user_id
|
114 |
* @param string $format
|
115 |
-
* @return boolean Object or array on success, false on
|
116 |
*/
|
117 |
function bp_core_get_notifications_for_user( $user_id, $format = 'string' ) {
|
118 |
|
@@ -124,27 +123,25 @@ function bp_core_get_notifications_for_user( $user_id, $format = 'string' ) {
|
|
124 |
// Trigger the deprecated function notice
|
125 |
_deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_get_notifications_for_user()' );
|
126 |
|
127 |
-
|
128 |
-
|
129 |
-
return apply_filters( 'bp_core_get_notifications_for_user', $renderable, $user_id, $format );
|
130 |
}
|
131 |
|
132 |
/** Delete ********************************************************************/
|
133 |
|
134 |
/**
|
135 |
-
* Delete notifications for a user by type
|
136 |
*
|
137 |
* Used when clearing out notifications for a specific component when the user
|
138 |
* has visited that component.
|
139 |
*
|
140 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
141 |
-
*
|
142 |
*
|
143 |
-
* @since BuddyPress (1.0)
|
144 |
* @param int $user_id
|
145 |
* @param string $component_name
|
146 |
* @param string $component_action
|
147 |
-
* @return boolean True on success, false on
|
148 |
*/
|
149 |
function bp_core_delete_notifications_by_type( $user_id, $component_name, $component_action ) {
|
150 |
|
@@ -160,19 +157,19 @@ function bp_core_delete_notifications_by_type( $user_id, $component_name, $compo
|
|
160 |
}
|
161 |
|
162 |
/**
|
163 |
-
* Delete notifications for an item ID
|
164 |
*
|
165 |
* Used when clearing out notifications for a specific component when the user
|
166 |
* has visited that component.
|
167 |
*
|
168 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
169 |
-
*
|
170 |
*
|
171 |
-
* @since BuddyPress (1.0)
|
172 |
* @param int $user_id
|
173 |
* @param string $component_name
|
174 |
* @param string $component_action
|
175 |
-
* @return boolean True on success, false on
|
176 |
*/
|
177 |
function bp_core_delete_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) {
|
178 |
|
@@ -188,16 +185,16 @@ function bp_core_delete_notifications_by_item_id( $user_id, $item_id, $component
|
|
188 |
}
|
189 |
|
190 |
/**
|
191 |
-
* Delete all notifications for by type
|
192 |
*
|
193 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
194 |
-
*
|
195 |
*
|
196 |
-
* @since BuddyPress (1.0)
|
197 |
* @param int $user_id
|
198 |
* @param string $component_name
|
199 |
* @param string $component_action
|
200 |
-
* @return boolean True on success, false on
|
201 |
*/
|
202 |
function bp_core_delete_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false ) {
|
203 |
|
@@ -213,18 +210,18 @@ function bp_core_delete_all_notifications_by_type( $item_id, $component_name, $c
|
|
213 |
}
|
214 |
|
215 |
/**
|
216 |
-
* Delete all notifications for a user
|
217 |
*
|
218 |
* Used when clearing out all notifications for a user, whene deleted or spammed
|
219 |
*
|
220 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
221 |
-
*
|
222 |
*
|
223 |
-
* @since BuddyPress (1.0)
|
224 |
* @param int $user_id
|
225 |
* @param string $component_name
|
226 |
* @param string $component_action
|
227 |
-
* @return boolean True on success, false on
|
228 |
*/
|
229 |
function bp_core_delete_notifications_from_user( $user_id, $component_name, $component_action ) {
|
230 |
|
@@ -242,17 +239,17 @@ function bp_core_delete_notifications_from_user( $user_id, $component_name, $com
|
|
242 |
/** Helpers *******************************************************************/
|
243 |
|
244 |
/**
|
245 |
-
* Check if a user has access to a specific notification
|
246 |
*
|
247 |
-
* Used before deleting a notification for a user
|
248 |
*
|
249 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
250 |
-
*
|
251 |
*
|
252 |
-
* @since BuddyPress (1.0)
|
253 |
* @param int $user_id
|
254 |
* @param int $notification_id
|
255 |
-
* @return boolean True on success, false on
|
256 |
*/
|
257 |
function bp_core_check_notification_access( $user_id, $notification_id ) {
|
258 |
|
14 |
if ( !defined( 'ABSPATH' ) ) exit;
|
15 |
|
16 |
/**
|
17 |
+
* Add a notification for a specific user, from a specific component.
|
18 |
*
|
19 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
20 |
+
* bp_notifications_add_notification() instead.
|
21 |
*
|
22 |
+
* @since BuddyPress (1.0.0)
|
23 |
* @param string $item_id
|
24 |
* @param int $user_id
|
25 |
* @param string $component_name
|
27 |
* @param string $secondary_item_id
|
28 |
* @param string $date_notified
|
29 |
* @param int $is_new
|
30 |
+
* @return boolean True on success, false on failure.
|
31 |
*/
|
32 |
function bp_core_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = 0, $date_notified = false, $is_new = 1 ) {
|
33 |
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
+
* Delete a specific notification by its ID.
|
61 |
*
|
62 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
63 |
+
* bp_notifications_delete_notification() instead.
|
64 |
*
|
65 |
+
* @since BuddyPress (1.0.0)
|
66 |
+
* @param int $id ID of notification.
|
67 |
+
* @return boolean True on success, false on failure.
|
68 |
*/
|
69 |
function bp_core_delete_notification( $id ) {
|
70 |
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
+
* Get a specific notification by its ID.
|
84 |
*
|
85 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
86 |
+
* bp_notifications_get_notification() instead.
|
87 |
*
|
88 |
+
* @since BuddyPress (1.0.0)
|
89 |
+
* @param int $id ID of notification.
|
90 |
* @return BP_Core_Notification
|
91 |
*/
|
92 |
function bp_core_get_notification( $id ) {
|
103 |
}
|
104 |
|
105 |
/**
|
106 |
+
* Get notifications for a specific user.
|
107 |
*
|
108 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
109 |
+
* bp_notifications_get_notifications_for_user() instead.
|
110 |
*
|
111 |
+
* @since BuddyPress (1.0.0)
|
112 |
+
* @param int $user_id ID of user.
|
|
|
113 |
* @param string $format
|
114 |
+
* @return boolean Object or array on success, false on failure.
|
115 |
*/
|
116 |
function bp_core_get_notifications_for_user( $user_id, $format = 'string' ) {
|
117 |
|
123 |
// Trigger the deprecated function notice
|
124 |
_deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_get_notifications_for_user()' );
|
125 |
|
126 |
+
return bp_notifications_get_notifications_for_user( $user_id, $format );
|
|
|
|
|
127 |
}
|
128 |
|
129 |
/** Delete ********************************************************************/
|
130 |
|
131 |
/**
|
132 |
+
* Delete notifications for a user by type.
|
133 |
*
|
134 |
* Used when clearing out notifications for a specific component when the user
|
135 |
* has visited that component.
|
136 |
*
|
137 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
138 |
+
* bp_notifications_delete_notifications_by_type() instead.
|
139 |
*
|
140 |
+
* @since BuddyPress (1.0.0)
|
141 |
* @param int $user_id
|
142 |
* @param string $component_name
|
143 |
* @param string $component_action
|
144 |
+
* @return boolean True on success, false on failure.
|
145 |
*/
|
146 |
function bp_core_delete_notifications_by_type( $user_id, $component_name, $component_action ) {
|
147 |
|
157 |
}
|
158 |
|
159 |
/**
|
160 |
+
* Delete notifications for an item ID.
|
161 |
*
|
162 |
* Used when clearing out notifications for a specific component when the user
|
163 |
* has visited that component.
|
164 |
*
|
165 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
166 |
+
* bp_notifications_delete_notifications_by_item_id() instead.
|
167 |
*
|
168 |
+
* @since BuddyPress (1.0.0)
|
169 |
* @param int $user_id
|
170 |
* @param string $component_name
|
171 |
* @param string $component_action
|
172 |
+
* @return boolean True on success, false on failure.
|
173 |
*/
|
174 |
function bp_core_delete_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) {
|
175 |
|
185 |
}
|
186 |
|
187 |
/**
|
188 |
+
* Delete all notifications for by type.
|
189 |
*
|
190 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
191 |
+
* bp_notifications_delete_all_notifications_by_type() instead.
|
192 |
*
|
193 |
+
* @since BuddyPress (1.0.0)
|
194 |
* @param int $user_id
|
195 |
* @param string $component_name
|
196 |
* @param string $component_action
|
197 |
+
* @return boolean True on success, false on failure.
|
198 |
*/
|
199 |
function bp_core_delete_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false ) {
|
200 |
|
210 |
}
|
211 |
|
212 |
/**
|
213 |
+
* Delete all notifications for a user.
|
214 |
*
|
215 |
* Used when clearing out all notifications for a user, whene deleted or spammed
|
216 |
*
|
217 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
218 |
+
* bp_notifications_delete_notifications_from_user() instead.
|
219 |
*
|
220 |
+
* @since BuddyPress (1.0.0)
|
221 |
* @param int $user_id
|
222 |
* @param string $component_name
|
223 |
* @param string $component_action
|
224 |
+
* @return boolean True on success, false on failure.
|
225 |
*/
|
226 |
function bp_core_delete_notifications_from_user( $user_id, $component_name, $component_action ) {
|
227 |
|
239 |
/** Helpers *******************************************************************/
|
240 |
|
241 |
/**
|
242 |
+
* Check if a user has access to a specific notification.
|
243 |
*
|
244 |
+
* Used before deleting a notification for a user.
|
245 |
*
|
246 |
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
247 |
+
* bp_notifications_check_notification_access() instead.
|
248 |
*
|
249 |
+
* @since BuddyPress (1.0.0)
|
250 |
* @param int $user_id
|
251 |
* @param int $notification_id
|
252 |
+
* @return boolean True on success, false on failure.
|
253 |
*/
|
254 |
function bp_core_check_notification_access( $user_id, $notification_id ) {
|
255 |
|
@@ -0,0 +1,625 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Deprecated functions
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
* @subpackage Core
|
7 |
+
* @deprecated 2.1.0
|
8 |
+
*/
|
9 |
+
|
10 |
+
// Exit if accessed directly
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Register (not enqueue) scripts that used to be used by BuddyPress.
|
15 |
+
*
|
16 |
+
* @since BuddyPress (2.1.0)
|
17 |
+
*/
|
18 |
+
function bp_core_register_deprecated_scripts() {
|
19 |
+
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
20 |
+
$url = buddypress()->plugin_url . 'bp-core/deprecated/js/';
|
21 |
+
|
22 |
+
$scripts = apply_filters( 'bp_core_register_deprecated_scripts', array(
|
23 |
+
|
24 |
+
// Core
|
25 |
+
'bp-jquery-scroll-to' => array(
|
26 |
+
'file' => "{$url}jquery-scroll-to{$min}.js",
|
27 |
+
'dependencies' => array( 'jquery' ),
|
28 |
+
),
|
29 |
+
|
30 |
+
// Messages
|
31 |
+
'bp-jquery-autocomplete' => array(
|
32 |
+
'file' => "{$url}autocomplete/jquery.autocomplete{$min}.js",
|
33 |
+
'dependencies' => array( 'jquery' ),
|
34 |
+
),
|
35 |
+
|
36 |
+
'bp-jquery-autocomplete-fb' => array(
|
37 |
+
'file' => "{$url}autocomplete/jquery.autocompletefb{$min}.js",
|
38 |
+
'dependencies' => array( 'jquery' ),
|
39 |
+
),
|
40 |
+
|
41 |
+
'bp-jquery-bgiframe' => array(
|
42 |
+
'file' => "{$url}autocomplete/jquery.bgiframe{$min}.js",
|
43 |
+
'dependencies' => array( 'jquery' ),
|
44 |
+
),
|
45 |
+
|
46 |
+
'bp-jquery-dimensions' => array(
|
47 |
+
'file' => "{$url}autocomplete/jquery.dimensions{$min}.js",
|
48 |
+
'dependencies' => array( 'jquery' ),
|
49 |
+
),
|
50 |
+
) );
|
51 |
+
|
52 |
+
foreach ( $scripts as $id => $script ) {
|
53 |
+
wp_register_script( $id, $script['file'], $script['dependencies'], bp_get_version(), true );
|
54 |
+
}
|
55 |
+
}
|
56 |
+
add_action( 'bp_enqueue_scripts', 'bp_core_register_deprecated_scripts', 1 );
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Register (not enqueue) styles that used to be used by BuddyPress.
|
60 |
+
*
|
61 |
+
* @since BuddyPress (2.1.0)
|
62 |
+
*/
|
63 |
+
function bp_core_register_deprecated_styles() {
|
64 |
+
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
65 |
+
$url = buddypress()->plugin_url . 'bp-core/deprecated/css/';
|
66 |
+
|
67 |
+
$styles = apply_filters( 'bp_core_register_deprecated_styles', array(
|
68 |
+
// Messages
|
69 |
+
'bp-messages-autocomplete' => array(
|
70 |
+
'file' => "{$url}autocomplete/jquery.autocompletefb{$min}.css",
|
71 |
+
'dependencies' => array(),
|
72 |
+
)
|
73 |
+
) );
|
74 |
+
|
75 |
+
foreach ( $styles as $id => $style ) {
|
76 |
+
wp_register_style( $id, $style['file'], $style['dependencies'], bp_get_version() );
|
77 |
+
|
78 |
+
wp_style_add_data( $id, 'rtl', true );
|
79 |
+
if ( $min ) {
|
80 |
+
wp_style_add_data( $id, 'suffix', $min );
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}
|
84 |
+
add_action( 'bp_enqueue_scripts', 'bp_core_register_deprecated_styles', 1 );
|
85 |
+
|
86 |
+
/** BuddyBar *****************************************************************/
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Add a Sites menu to the BuddyBar.
|
90 |
+
*
|
91 |
+
* @since BuddyPress (1.0.0)
|
92 |
+
* @deprecated BuddyPress (2.1.0)
|
93 |
+
*
|
94 |
+
* @global object $bp The BuddyPress global settings object.
|
95 |
+
*
|
96 |
+
* @return bool|null Returns false on failure. Otherwise echoes the menu item.
|
97 |
+
*/
|
98 |
+
function bp_adminbar_blogs_menu() {
|
99 |
+
global $bp;
|
100 |
+
|
101 |
+
if ( !is_user_logged_in() || !bp_is_active( 'blogs' ) )
|
102 |
+
return false;
|
103 |
+
|
104 |
+
if ( !is_multisite() )
|
105 |
+
return false;
|
106 |
+
|
107 |
+
$blogs = wp_cache_get( 'bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', 'bp' );
|
108 |
+
if ( empty( $blogs ) ) {
|
109 |
+
$blogs = bp_blogs_get_blogs_for_user( bp_loggedin_user_id(), true );
|
110 |
+
wp_cache_set( 'bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', $blogs, 'bp' );
|
111 |
+
}
|
112 |
+
|
113 |
+
$counter = 0;
|
114 |
+
if ( is_array( $blogs['blogs'] ) && (int) $blogs['count'] ) {
|
115 |
+
|
116 |
+
echo '<li id="bp-adminbar-blogs-menu"><a href="' . trailingslashit( bp_loggedin_user_domain() . bp_get_blogs_slug() ) . '">';
|
117 |
+
|
118 |
+
_e( 'My Sites', 'buddypress' );
|
119 |
+
|
120 |
+
echo '</a>';
|
121 |
+
echo '<ul>';
|
122 |
+
|
123 |
+
foreach ( (array) $blogs['blogs'] as $blog ) {
|
124 |
+
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
125 |
+
$site_url = esc_attr( $blog->siteurl );
|
126 |
+
|
127 |
+
echo '<li' . $alt . '>';
|
128 |
+
echo '<a href="' . $site_url . '">' . esc_html( $blog->name ) . '</a>';
|
129 |
+
echo '<ul>';
|
130 |
+
echo '<li class="alt"><a href="' . $site_url . 'wp-admin/">' . __( 'Dashboard', 'buddypress' ) . '</a></li>';
|
131 |
+
echo '<li><a href="' . $site_url . 'wp-admin/post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';
|
132 |
+
echo '<li class="alt"><a href="' . $site_url . 'wp-admin/edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
|
133 |
+
echo '<li><a href="' . $site_url . 'wp-admin/edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';
|
134 |
+
echo '</ul>';
|
135 |
+
|
136 |
+
do_action( 'bp_adminbar_blog_items', $blog );
|
137 |
+
|
138 |
+
echo '</li>';
|
139 |
+
$counter++;
|
140 |
+
}
|
141 |
+
|
142 |
+
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
143 |
+
|
144 |
+
if ( bp_blog_signup_enabled() ) {
|
145 |
+
echo '<li' . $alt . '>';
|
146 |
+
echo '<a href="' . bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create/">' . __( 'Create a Site!', 'buddypress' ) . '</a>';
|
147 |
+
echo '</li>';
|
148 |
+
}
|
149 |
+
|
150 |
+
echo '</ul>';
|
151 |
+
echo '</li>';
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* If user has upgraded to 1.6 and chose to retain their BuddyBar, offer then a switch to change over
|
157 |
+
* to the WP Toolbar.
|
158 |
+
*
|
159 |
+
* @since BuddyPress (1.6)
|
160 |
+
* @deprecated BuddyPress (2.1.0)
|
161 |
+
*/
|
162 |
+
function bp_admin_setting_callback_force_buddybar() {
|
163 |
+
?>
|
164 |
+
|
165 |
+
<input id="_bp_force_buddybar" name="_bp_force_buddybar" type="checkbox" value="1" <?php checked( ! bp_force_buddybar( true ) ); ?> />
|
166 |
+
<label for="_bp_force_buddybar"><?php _e( 'Switch to WordPress Toolbar', 'buddypress' ); ?></label>
|
167 |
+
|
168 |
+
<?php
|
169 |
+
}
|
170 |
+
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Sanitization for _bp_force_buddyvar
|
174 |
+
*
|
175 |
+
* If upgraded to 1.6 and you chose to keep the BuddyBar, a checkbox asks if you want to switch to
|
176 |
+
* the WP Toolbar. The option we store is 1 if the BuddyBar is forced on, so we use this function
|
177 |
+
* to flip the boolean before saving the intval.
|
178 |
+
*
|
179 |
+
* @since BuddyPress (1.6)
|
180 |
+
* @deprecated BuddyPress (2.1.0)
|
181 |
+
* @access Private
|
182 |
+
*/
|
183 |
+
function bp_admin_sanitize_callback_force_buddybar( $value = false ) {
|
184 |
+
return $value ? 0 : 1;
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Wrapper function for rendering the BuddyBar.
|
189 |
+
*
|
190 |
+
* @return bool|null Returns false if the BuddyBar is disabled.
|
191 |
+
* @deprecated BuddyPress (2.1.0)
|
192 |
+
*/
|
193 |
+
function bp_core_admin_bar() {
|
194 |
+
global $bp;
|
195 |
+
|
196 |
+
if ( defined( 'BP_DISABLE_ADMIN_BAR' ) && BP_DISABLE_ADMIN_BAR )
|
197 |
+
return false;
|
198 |
+
|
199 |
+
if ( (int) bp_get_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
|
200 |
+
return false;
|
201 |
+
|
202 |
+
$bp->doing_admin_bar = true;
|
203 |
+
|
204 |
+
echo '<div id="wp-admin-bar"><div class="padder">';
|
205 |
+
|
206 |
+
// **** Do bp-adminbar-logo Actions ********
|
207 |
+
do_action( 'bp_adminbar_logo' );
|
208 |
+
|
209 |
+
echo '<ul class="main-nav">';
|
210 |
+
|
211 |
+
// **** Do bp-adminbar-menus Actions ********
|
212 |
+
do_action( 'bp_adminbar_menus' );
|
213 |
+
|
214 |
+
echo '</ul>';
|
215 |
+
echo "</div></div><!-- #wp-admin-bar -->\n\n";
|
216 |
+
|
217 |
+
$bp->doing_admin_bar = false;
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Output the BuddyBar logo.
|
222 |
+
*
|
223 |
+
* @deprecated BuddyPress (2.1.0)
|
224 |
+
*/
|
225 |
+
function bp_adminbar_logo() {
|
226 |
+
echo '<a href="' . bp_get_root_domain() . '" id="admin-bar-logo">' . get_blog_option( bp_get_root_blog_id(), 'blogname' ) . '</a>';
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Output the "Log In" and "Sign Up" names to the BuddyBar.
|
231 |
+
*
|
232 |
+
* Visible only to visitors who are not logged in.
|
233 |
+
*
|
234 |
+
* @deprecated BuddyPress (2.1.0)
|
235 |
+
*
|
236 |
+
* @return bool|null Returns false if the current user is logged in.
|
237 |
+
*/
|
238 |
+
function bp_adminbar_login_menu() {
|
239 |
+
|
240 |
+
if ( is_user_logged_in() )
|
241 |
+
return false;
|
242 |
+
|
243 |
+
echo '<li class="bp-login no-arrow"><a href="' . wp_login_url() . '">' . __( 'Log In', 'buddypress' ) . '</a></li>';
|
244 |
+
|
245 |
+
// Show "Sign Up" link if user registrations are allowed
|
246 |
+
if ( bp_get_signup_allowed() )
|
247 |
+
echo '<li class="bp-signup no-arrow"><a href="' . bp_get_signup_page() . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Output the My Account BuddyBar menu.
|
252 |
+
*
|
253 |
+
* @deprecated BuddyPress (2.1.0)
|
254 |
+
*
|
255 |
+
* @return bool|null Returns false on failure.
|
256 |
+
*/
|
257 |
+
function bp_adminbar_account_menu() {
|
258 |
+
global $bp;
|
259 |
+
|
260 |
+
if ( !$bp->bp_nav || !is_user_logged_in() )
|
261 |
+
return false;
|
262 |
+
|
263 |
+
echo '<li id="bp-adminbar-account-menu"><a href="' . bp_loggedin_user_domain() . '">';
|
264 |
+
echo __( 'My Account', 'buddypress' ) . '</a>';
|
265 |
+
echo '<ul>';
|
266 |
+
|
267 |
+
// Loop through each navigation item
|
268 |
+
$counter = 0;
|
269 |
+
foreach( (array) $bp->bp_nav as $nav_item ) {
|
270 |
+
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
271 |
+
|
272 |
+
if ( -1 == $nav_item['position'] )
|
273 |
+
continue;
|
274 |
+
|
275 |
+
echo '<li' . $alt . '>';
|
276 |
+
echo '<a id="bp-admin-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>';
|
277 |
+
|
278 |
+
if ( isset( $bp->bp_options_nav[$nav_item['slug']] ) && is_array( $bp->bp_options_nav[$nav_item['slug']] ) ) {
|
279 |
+
echo '<ul>';
|
280 |
+
$sub_counter = 0;
|
281 |
+
|
282 |
+
foreach( (array) $bp->bp_options_nav[$nav_item['slug']] as $subnav_item ) {
|
283 |
+
$link = $subnav_item['link'];
|
284 |
+
$name = $subnav_item['name'];
|
285 |
+
|
286 |
+
if ( bp_displayed_user_domain() )
|
287 |
+
$link = str_replace( bp_displayed_user_domain(), bp_loggedin_user_domain(), $subnav_item['link'] );
|
288 |
+
|
289 |
+
if ( isset( $bp->displayed_user->userdata->user_login ) )
|
290 |
+
$name = str_replace( $bp->displayed_user->userdata->user_login, $bp->loggedin_user->userdata->user_login, $subnav_item['name'] );
|
291 |
+
|
292 |
+
$alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
|
293 |
+
echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $link . '">' . $name . '</a></li>';
|
294 |
+
$sub_counter++;
|
295 |
+
}
|
296 |
+
echo '</ul>';
|
297 |
+
}
|
298 |
+
|
299 |
+
echo '</li>';
|
300 |
+
|
301 |
+
$counter++;
|
302 |
+
}
|
303 |
+
|
304 |
+
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
305 |
+
|
306 |
+
echo '<li' . $alt . '><a id="bp-admin-logout" class="logout" href="' . wp_logout_url( home_url() ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
|
307 |
+
echo '</ul>';
|
308 |
+
echo '</li>';
|
309 |
+
}
|
310 |
+
|
311 |
+
function bp_adminbar_thisblog_menu() {
|
312 |
+
if ( current_user_can( 'edit_posts' ) ) {
|
313 |
+
echo '<li id="bp-adminbar-thisblog-menu"><a href="' . admin_url() . '">';
|
314 |
+
_e( 'Dashboard', 'buddypress' );
|
315 |
+
echo '</a>';
|
316 |
+
echo '<ul>';
|
317 |
+
|
318 |
+
echo '<li class="alt"><a href="' . admin_url() . 'post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';
|
319 |
+
echo '<li><a href="' . admin_url() . 'edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
|
320 |
+
echo '<li class="alt"><a href="' . admin_url() . 'edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';
|
321 |
+
|
322 |
+
do_action( 'bp_adminbar_thisblog_items' );
|
323 |
+
|
324 |
+
echo '</ul>';
|
325 |
+
echo '</li>';
|
326 |
+
}
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Output the Random BuddyBar menu.
|
331 |
+
*
|
332 |
+
* Not visible for logged-in users.
|
333 |
+
*
|
334 |
+
* @deprecated BuddyPress (2.1.0)
|
335 |
+
*/
|
336 |
+
function bp_adminbar_random_menu() {
|
337 |
+
?>
|
338 |
+
|
339 |
+
<li class="align-right" id="bp-adminbar-visitrandom-menu">
|
340 |
+
<a href="#"><?php _e( 'Visit', 'buddypress' ) ?></a>
|
341 |
+
<ul class="random-list">
|
342 |
+
<li><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) . '?random-member' ?>" rel="nofollow"><?php _e( 'Random Member', 'buddypress' ) ?></a></li>
|
343 |
+
|
344 |
+
<?php if ( bp_is_active( 'groups' ) ) : ?>
|
345 |
+
|
346 |
+
<li class="alt"><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() ) . '?random-group' ?>" rel="nofollow"><?php _e( 'Random Group', 'buddypress' ) ?></a></li>
|
347 |
+
|
348 |
+
<?php endif; ?>
|
349 |
+
|
350 |
+
<?php if ( is_multisite() && bp_is_active( 'blogs' ) ) : ?>
|
351 |
+
|
352 |
+
<li><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() ) . '?random-blog' ?>" rel="nofollow"><?php _e( 'Random Site', 'buddypress' ) ?></a></li>
|
353 |
+
|
354 |
+
<?php endif; ?>
|
355 |
+
|
356 |
+
<?php do_action( 'bp_adminbar_random_menu' ) ?>
|
357 |
+
|
358 |
+
</ul>
|
359 |
+
</li>
|
360 |
+
|
361 |
+
<?php
|
362 |
+
}
|
363 |
+
|
364 |
+
/**
|
365 |
+
* Enqueue the BuddyBar CSS.
|
366 |
+
*
|
367 |
+
* @deprecated BuddyPress (2.1.0)
|
368 |
+
*/
|
369 |
+
function bp_core_load_buddybar_css() {
|
370 |
+
if ( bp_use_wp_admin_bar() || ( (int) bp_get_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) || ( defined( 'BP_DISABLE_ADMIN_BAR' ) && BP_DISABLE_ADMIN_BAR ) )
|
371 |
+
return;
|
372 |
+
|
373 |
+
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
374 |
+
|
375 |
+
if ( file_exists( get_stylesheet_directory() . '/_inc/css/adminbar.css' ) ) { // Backwards compatibility
|
376 |
+
$stylesheet = get_stylesheet_directory_uri() . '/_inc/css/adminbar.css';
|
377 |
+
} else {
|
378 |
+
$stylesheet = buddypress()->plugin_url . "bp-core/css/buddybar{$min}.css";
|
379 |
+
}
|
380 |
+
|
381 |
+
wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_buddybar_rtl_css', $stylesheet ), array(), bp_get_version() );
|
382 |
+
|
383 |
+
wp_style_add_data( 'bp-admin-bar', 'rtl', true );
|
384 |
+
if ( $min ) {
|
385 |
+
wp_style_add_data( 'bp-admin-bar', 'suffix', $min );
|
386 |
+
}
|
387 |
+
}
|
388 |
+
add_action( 'bp_init', 'bp_core_load_buddybar_css' );
|
389 |
+
|
390 |
+
/**
|
391 |
+
* Add menu items to the BuddyBar.
|
392 |
+
*
|
393 |
+
* @since BuddyPress (1.0.0)
|
394 |
+
*
|
395 |
+
* @deprecated BuddyPress (2.1.0)
|
396 |
+
*
|
397 |
+
* @global BuddyPress $bp
|
398 |
+
*/
|
399 |
+
function bp_groups_adminbar_admin_menu() {
|
400 |
+
global $bp;
|
401 |
+
|
402 |
+
if ( empty( $bp->groups->current_group ) )
|
403 |
+
return false;
|
404 |
+
|
405 |
+
// Only group admins and site admins can see this menu
|
406 |
+
if ( !current_user_can( 'edit_users' ) && !bp_current_user_can( 'bp_moderate' ) && !bp_is_item_admin() )
|
407 |
+
return false; ?>
|
408 |
+
|
409 |
+
<li id="bp-adminbar-adminoptions-menu">
|
410 |
+
<a href="<?php bp_groups_action_link( 'admin' ); ?>"><?php _e( 'Admin Options', 'buddypress' ); ?></a>
|
411 |
+
|
412 |
+
<ul>
|
413 |
+
<li><a href="<?php bp_groups_action_link( 'admin/edit-details' ); ?>"><?php _e( 'Edit Details', 'buddypress' ); ?></a></li>
|
414 |
+
|
415 |
+
<li><a href="<?php bp_groups_action_link( 'admin/group-settings' ); ?>"><?php _e( 'Group Settings', 'buddypress' ); ?></a></li>
|
416 |
+
|
417 |
+
<?php if ( !(int)bp_get_option( 'bp-disable-avatar-uploads' ) && $bp->avatar->show_avatars ) : ?>
|
418 |
+
|
419 |
+
<li><a href="<?php bp_groups_action_link( 'admin/group-avatar' ); ?>"><?php _e( 'Group Profile Photo', 'buddypress' ); ?></a></li>
|
420 |
+
|
421 |
+
<?php endif; ?>
|
422 |
+
|
423 |
+
<?php if ( bp_is_active( 'friends' ) ) : ?>
|
424 |
+
|
425 |
+
<li><a href="<?php bp_groups_action_link( 'send-invites' ); ?>"><?php _e( 'Manage Invitations', 'buddypress' ); ?></a></li>
|
426 |
+
|
427 |
+
<?php endif; ?>
|
428 |
+
|
429 |
+
<li><a href="<?php bp_groups_action_link( 'admin/manage-members' ); ?>"><?php _e( 'Manage Members', 'buddypress' ); ?></a></li>
|
430 |
+
|
431 |
+
<?php if ( $bp->groups->current_group->status == 'private' ) : ?>
|
432 |
+
|
433 |
+
<li><a href="<?php bp_groups_action_link( 'admin/membership-requests' ); ?>"><?php _e( 'Membership Requests', 'buddypress' ); ?></a></li>
|
434 |
+
|
435 |
+
<?php endif; ?>
|
436 |
+
|
437 |
+
<li><a class="confirm" href="<?php echo wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/delete-group/', 'groups_delete_group' ); ?>&delete-group-button=1&delete-group-understand=1"><?php _e( "Delete Group", 'buddypress' ) ?></a></li>
|
438 |
+
|
439 |
+
<?php do_action( 'bp_groups_adminbar_admin_menu' ) ?>
|
440 |
+
|
441 |
+
</ul>
|
442 |
+
</li>
|
443 |
+
|
444 |
+
<?php
|
445 |
+
}
|
446 |
+
add_action( 'bp_adminbar_menus', 'bp_groups_adminbar_admin_menu', 20 );
|
447 |
+
|
448 |
+
/**
|
449 |
+
* Add the Notifications menu to the BuddyBar.
|
450 |
+
*
|
451 |
+
* @deprecated BuddyPress (2.1.0)
|
452 |
+
*/
|
453 |
+
function bp_adminbar_notifications_menu() {
|
454 |
+
|
455 |
+
// Bail if notifications is not active
|
456 |
+
if ( ! bp_is_active( 'notifications' ) ) {
|
457 |
+
return false;
|
458 |
+
}
|
459 |
+
|
460 |
+
bp_notifications_buddybar_menu();
|
461 |
+
}
|
462 |
+
add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );
|
463 |
+
|
464 |
+
/**
|
465 |
+
* Add the Blog Authors menu to the BuddyBar (visible when not logged in).
|
466 |
+
*
|
467 |
+
* @deprecated BuddyPress (2.1.0)
|
468 |
+
*/
|
469 |
+
function bp_adminbar_authors_menu() {
|
470 |
+
global $wpdb;
|
471 |
+
|
472 |
+
// Only for multisite
|
473 |
+
if ( !is_multisite() )
|
474 |
+
return false;
|
475 |
+
|
476 |
+
// Hide on root blog
|
477 |
+
if ( $wpdb->blogid == bp_get_root_blog_id() || !bp_is_active( 'blogs' ) )
|
478 |
+
return false;
|
479 |
+
|
480 |
+
$blog_prefix = $wpdb->get_blog_prefix( $wpdb->blogid );
|
481 |
+
$authors = $wpdb->get_results( "SELECT user_id, user_login, user_nicename, display_name, user_email, meta_value as caps FROM $wpdb->users u, $wpdb->usermeta um WHERE u.ID = um.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY um.user_id" );
|
482 |
+
|
483 |
+
if ( !empty( $authors ) ) {
|
484 |
+
// This is a blog, render a menu with links to all authors
|
485 |
+
echo '<li id="bp-adminbar-authors-menu"><a href="/">';
|
486 |
+
_e('Blog Authors', 'buddypress');
|
487 |
+
echo '</a>';
|
488 |
+
|
489 |
+
echo '<ul class="author-list">';
|
490 |
+
foreach( (array) $authors as $author ) {
|
491 |
+
$caps = maybe_unserialize( $author->caps );
|
492 |
+
if ( isset( $caps['subscriber'] ) || isset( $caps['contributor'] ) ) continue;
|
493 |
+
|
494 |
+
echo '<li>';
|
495 |
+
echo '<a href="' . bp_core_get_user_domain( $author->user_id, $author->user_nicename, $author->user_login ) . '">';
|
496 |
+
echo bp_core_fetch_avatar( array(
|
497 |
+
'item_id' => $author->user_id,
|
498 |
+
'email' => $author->user_email,
|
499 |
+
'width' => 15,
|
500 |
+
'height' => 15,
|
501 |
+
'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), $author->display_name )
|
502 |
+
) );
|
503 |
+
echo ' ' . $author->display_name . '</a>';
|
504 |
+
echo '<div class="admin-bar-clear"></div>';
|
505 |
+
echo '</li>';
|
506 |
+
}
|
507 |
+
echo '</ul>';
|
508 |
+
echo '</li>';
|
509 |
+
}
|
510 |
+
}
|
511 |
+
add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
|
512 |
+
|
513 |
+
/**
|
514 |
+
* Add a member admin menu to the BuddyBar.
|
515 |
+
*
|
516 |
+
* Adds an Toolbar menu to any profile page providing site moderator actions
|
517 |
+
* that allow capable users to clean up a users account.
|
518 |
+
*
|
519 |
+
* @deprecated BuddyPress (2.1.0)
|
520 |
+
*/
|
521 |
+
function bp_members_adminbar_admin_menu() {
|
522 |
+
|
523 |
+
// Only show if viewing a user
|
524 |
+
if ( !bp_displayed_user_id() )
|
525 |
+
return false;
|
526 |
+
|
527 |
+
// Don't show this menu to non site admins or if you're viewing your own profile
|
528 |
+
if ( !current_user_can( 'edit_users' ) || bp_is_my_profile() )
|
529 |
+
return false; ?>
|
530 |
+
|
531 |
+
<li id="bp-adminbar-adminoptions-menu">
|
532 |
+
|
533 |
+
<a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
|
534 |
+
|
535 |
+
<ul>
|
536 |
+
<?php if ( bp_is_active( 'xprofile' ) ) : ?>
|
537 |
+
|
538 |
+
<li><a href="<?php bp_members_component_link( 'profile', 'edit' ); ?>"><?php printf( __( "Edit %s's Profile", 'buddypress' ), esc_attr( bp_get_displayed_user_fullname() ) ) ?></a></li>
|
539 |
+
|
540 |
+
<?php endif ?>
|
541 |
+
|
542 |
+
<li><a href="<?php bp_members_component_link( 'profile', 'change-avatar' ); ?>"><?php printf( __( "Edit %s's Profile Photo", 'buddypress' ), esc_attr( bp_get_displayed_user_fullname() ) ) ?></a></li>
|
543 |
+
|
544 |
+
<li><a href="<?php bp_members_component_link( 'settings', 'capabilities' ); ?>"><?php _e( 'User Capabilities', 'buddypress' ); ?></a></li>
|
545 |
+
|
546 |
+
<li><a href="<?php bp_members_component_link( 'settings', 'delete-account' ); ?>"><?php printf( __( "Delete %s's Account", 'buddypress' ), esc_attr( bp_get_displayed_user_fullname() ) ); ?></a></li>
|
547 |
+
|
548 |
+
<?php do_action( 'bp_members_adminbar_admin_menu' ) ?>
|
549 |
+
|
550 |
+
</ul>
|
551 |
+
</li>
|
552 |
+
|
553 |
+
<?php
|
554 |
+
}
|
555 |
+
add_action( 'bp_adminbar_menus', 'bp_members_adminbar_admin_menu', 20 );
|
556 |
+
|
557 |
+
/**
|
558 |
+
* Create the Notifications menu for the BuddyBar.
|
559 |
+
*
|
560 |
+
* @since BuddyPress (1.9.0)
|
561 |
+
* @deprecated BuddyPress (2.1.0)
|
562 |
+
*/
|
563 |
+
function bp_notifications_buddybar_menu() {
|
564 |
+
|
565 |
+
if ( ! is_user_logged_in() ) {
|
566 |
+
return false;
|
567 |
+
}
|
568 |
+
|
569 |
+
echo '<li id="bp-adminbar-notifications-menu"><a href="' . esc_url( bp_loggedin_user_domain() ) . '">';
|
570 |
+
_e( 'Notifications', 'buddypress' );
|
571 |
+
|
572 |
+
if ( $notification_count = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) ) : ?>
|
573 |
+
<span><?php echo bp_core_number_format( $notification_count ); ?></span>
|
574 |
+
<?php
|
575 |
+
endif;
|
576 |
+
|
577 |
+
echo '</a>';
|
578 |
+
echo '<ul>';
|
579 |
+
|
580 |
+
if ( $notifications = bp_notifications_get_notifications_for_user( bp_loggedin_user_id() ) ) {
|
581 |
+
$counter = 0;
|
582 |
+
for ( $i = 0, $count = count( $notifications ); $i < $count; ++$i ) {
|
583 |
+
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
|
584 |
+
|
585 |
+
<li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>
|
586 |
+
|
587 |
+
<?php $counter++;
|
588 |
+
}
|
589 |
+
} else { ?>
|
590 |
+
|
591 |
+
<li><a href="<?php echo esc_url( bp_loggedin_user_domain() ); ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
|
592 |
+
|
593 |
+
<?php
|
594 |
+
}
|
595 |
+
|
596 |
+
echo '</ul>';
|
597 |
+
echo '</li>';
|
598 |
+
}
|
599 |
+
add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );
|
600 |
+
|
601 |
+
/**
|
602 |
+
* Output the base URL for subdomain installations of WordPress Multisite.
|
603 |
+
*
|
604 |
+
* @since BuddyPress (1.6.0)
|
605 |
+
*
|
606 |
+
* @deprecated BuddyPress (2.1.0)
|
607 |
+
*/
|
608 |
+
function bp_blogs_subdomain_base() {
|
609 |
+
_deprecated_function( __FUNCTION__, '2.1', 'bp_signup_subdomain_base()' );
|
610 |
+
echo bp_signup_get_subdomain_base();
|
611 |
+
}
|
612 |
+
|
613 |
+
/**
|
614 |
+
* Return the base URL for subdomain installations of WordPress Multisite.
|
615 |
+
*
|
616 |
+
* @since BuddyPress (1.6.0)
|
617 |
+
*
|
618 |
+
* @return string The base URL - eg, 'example.com' for site_url() example.com or www.example.com.
|
619 |
+
*
|
620 |
+
* @deprecated BuddyPress (2.1.0)
|
621 |
+
*/
|
622 |
+
function bp_blogs_get_subdomain_base() {
|
623 |
+
_deprecated_function( __FUNCTION__, '2.1', 'bp_signup_get_subdomain_base()' );
|
624 |
+
return bp_signup_get_subdomain_base();
|
625 |
+
}
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.ac_results {
|
2 |
+
padding: 0px;
|
3 |
+
overflow: hidden;
|
4 |
+
z-index: 99999;
|
5 |
+
background: #fff;
|
6 |
+
border: 1px solid #ccc;
|
7 |
+
-moz-border-radius-bottomleft: 3px;
|
8 |
+
-khtml-border-bottom-right-radius: 3px;
|
9 |
+
-webkit-border-bottom-right-radius: 3px;
|
10 |
+
border-bottom-right-radius: 3px;
|
11 |
+
-moz-border-radius-bottomright: 3px;
|
12 |
+
-khtml-border-bottom-left-radius: 3px;
|
13 |
+
-webkit-border-bottom-left-radius: 3px;
|
14 |
+
border-bottom-left-radius: 3px;
|
15 |
+
}
|
16 |
+
.ac_results ul {
|
17 |
+
width: 100%;
|
18 |
+
list-style-position: outside;
|
19 |
+
list-style: none;
|
20 |
+
padding: 0;
|
21 |
+
margin: 0;
|
22 |
+
}
|
23 |
+
|
24 |
+
.ac_results li {
|
25 |
+
margin: 0px;
|
26 |
+
padding: 5px 10px;
|
27 |
+
cursor: pointer;
|
28 |
+
display: block;
|
29 |
+
font-size: 1em;
|
30 |
+
line-height: 16px;
|
31 |
+
overflow: hidden;
|
32 |
+
}
|
33 |
+
.ac_results li img {
|
34 |
+
margin-left: 5px;
|
35 |
+
}
|
36 |
+
|
37 |
+
.ac_odd {
|
38 |
+
background-color: #f0f0f0;
|
39 |
+
}
|
40 |
+
|
41 |
+
.ac_over {
|
42 |
+
background-color: #888;
|
43 |
+
color: #fff;
|
44 |
+
}
|
45 |
+
|
46 |
+
ul.acfb-holder {
|
47 |
+
margin : 0;
|
48 |
+
height : auto !important;
|
49 |
+
height : 1%;
|
50 |
+
overflow: hidden;
|
51 |
+
padding: 0;
|
52 |
+
list-style: none;
|
53 |
+
}
|
54 |
+
ul.acfb-holder li {
|
55 |
+
float : right;
|
56 |
+
margin : 0 0 4px 5px;
|
57 |
+
list-style-type: none;
|
58 |
+
}
|
59 |
+
|
60 |
+
ul.acfb-holder li.friend-tab {
|
61 |
+
border-radius : 3px;
|
62 |
+
-moz-border-radius : 3px;
|
63 |
+
-webkit-border-radius : 3px;
|
64 |
+
border : 1px solid #ffe7c7;
|
65 |
+
padding : 2px 7px 2px;
|
66 |
+
background : #FFF9DF;
|
67 |
+
font-size: 1em;
|
68 |
+
}
|
69 |
+
li.friend-tab img.avatar {
|
70 |
+
border-width: 2px !important;
|
71 |
+
vertical-align: middle;
|
72 |
+
}
|
73 |
+
|
74 |
+
li.friend-tab span.p {
|
75 |
+
padding-right: 5px;
|
76 |
+
font-size: 0.8em;
|
77 |
+
cursor: pointer;
|
78 |
+
}
|
79 |
+
|
80 |
+
input#send-to-input { width: 275px; }
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
.ac_results{padding:0;overflow:hidden;z-index:99999;background:#fff;border:1px solid #ccc;-moz-border-radius-bottomleft:3px;-khtml-border-bottom-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px;-moz-border-radius-bottomright:3px;-khtml-border-bottom-left-radius:3px;-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px}.ac_results ul{width:100%;list-style:none;padding:0;margin:0}.ac_results li{margin:0;padding:5px 10px;cursor:pointer;display:block;font-size:1em;line-height:16px;overflow:hidden}.ac_results li img{margin-left:5px}.ac_odd{background-color:#f0f0f0}.ac_over{background-color:#888;color:#fff}ul.acfb-holder{margin:0;height:auto!important;height:1%;overflow:hidden;padding:0;list-style:none}ul.acfb-holder li{float:right;margin:0 0 4px 5px;list-style-type:none}ul.acfb-holder li.friend-tab{border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;border:1px solid #ffe7c7;padding:2px 7px;background:#FFF9DF;font-size:1em}li.friend-tab img.avatar{border-width:2px!important;vertical-align:middle}li.friend-tab span.p{padding-right:5px;font-size:.8em;cursor:pointer}input#send-to-input{width:275px}
|
@@ -34,10 +34,6 @@
|
|
34 |
margin-right: 5px;
|
35 |
}
|
36 |
|
37 |
-
.ac_loading {
|
38 |
-
background : url('../../../bp-themes/bp-default/_inc/images/ajax-loader.gif') right center no-repeat;
|
39 |
-
}
|
40 |
-
|
41 |
.ac_odd {
|
42 |
background-color: #f0f0f0;
|
43 |
}
|
@@ -82,4 +78,3 @@ ul.acfb-holder {
|
|
82 |
}
|
83 |
|
84 |
input#send-to-input { width: 275px; }
|
85 |
-
|
34 |
margin-right: 5px;
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
37 |
.ac_odd {
|
38 |
background-color: #f0f0f0;
|
39 |
}
|
78 |
}
|
79 |
|
80 |
input#send-to-input { width: 275px; }
|
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
.ac_results{padding:0;overflow:hidden;z-index:99999;background:#fff;border:1px solid #ccc;-moz-border-radius-bottomleft:3px;-khtml-border-bottom-left-radius:3px;-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px;-moz-border-radius-bottomright:3px;-khtml-border-bottom-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px}.ac_results ul{width:100%;list-style:none;padding:0;margin:0}.ac_results li{margin:0;padding:5px 10px;cursor:pointer;display:block;font-size:1em;line-height:16px;overflow:hidden}.ac_results li img{margin-right:5px}.ac_odd{background-color:#f0f0f0}.ac_over{background-color:#888;color:#fff}ul.acfb-holder{margin:0;height:auto!important;height:1%;overflow:hidden;padding:0;list-style:none}ul.acfb-holder li{float:left;margin:0 5px 4px 0;list-style-type:none}ul.acfb-holder li.friend-tab{border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;border:1px solid #ffe7c7;padding:2px 7px;background:#FFF9DF;font-size:1em}li.friend-tab img.avatar{border-width:2px!important;vertical-align:middle}li.friend-tab span.p{padding-left:5px;font-size:.8em;cursor:pointer}input#send-to-input{width:275px}
|
File without changes
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
!function(a){a.fn.extend({autocomplete:function(b,c){var d="string"==typeof b;return c=a.extend({},a.Autocompleter.defaults,{url:d?b:null,data:d?null:b,delay:d?a.Autocompleter.defaults.delay:10,max:c&&!c.scroll?10:150},c),c.highlight=c.highlight||function(a){return a},this.each(function(){new a.Autocompleter(this,c)})},result:function(a){return this.bind("result",a)},search:function(a){return this.trigger("search",[a])},flushCache:function(){return this.trigger("flushCache")},setOptions:function(a){return this.trigger("setOptions",[a])},unautocomplete:function(){return this.trigger("unautocomplete")}}),a.Autocompleter=function(b,c){function d(){var a=w.selected();if(!a)return!1;var b=a.result;if(s=b,c.multiple){var d=f(r.val());d.length>1&&(b=d.slice(0,d.length-1).join(c.multipleSeparator)+c.multipleSeparator+b),b+=c.multipleSeparator}return r.val(b),j(),r.trigger("result",[a.data,a.value]),!0}function e(a,b){if(p==q.DEL)return void w.hide();var d=r.val();(b||d!=s)&&(s=d,d=g(d),d.length>=c.minChars?(r.addClass(c.loadingClass),jQuery("#send-to-input").addClass("loading"),c.matchCase||(d=d.toLowerCase()),l(d,k,j)):(n(),w.hide()))}function f(b){if(!b)return[""];var d=b.split(a.trim(c.multipleSeparator)),e=[];return a.each(d,function(b,c){a.trim(c)&&(e[b]=a.trim(c))}),e}function g(a){if(!c.multiple)return a;var b=f(a);return b[b.length-1]}function h(d,e){c.autoFill&&g(r.val()).toLowerCase()==d.toLowerCase()&&8!=p&&(r.val(r.val()+e.substring(g(s).length)),a.Autocompleter.Selection(b,s.length,s.length+e.length))}function i(){clearTimeout(o),o=setTimeout(j,200)}function j(){w.hide(),clearTimeout(o),n(),c.mustMatch&&r.search(function(a){a||r.val("")})}function k(a,b){if(b&&b.length&&u){n(),w.display(b,a);var c=b[0].value.split(";");b.value=c[0],h(a,b.value),w.show()}else j()}function l(d,e,f){c.matchCase||(d=d.toLowerCase());var h=t.load(d);if(h&&h.length)e(d,h);else if("string"==typeof c.url&&c.url.length>0){var i={};a.each(c.extraParams,function(a,b){i[a]="function"==typeof b?b():b}),a.ajax({mode:"abort",port:"autocomplete"+b.name,dataType:c.dataType,url:c.url,data:a.extend({q:g(d),limit:c.max,action:"messages_autocomplete_results",cookie:encodeURIComponent(document.cookie)},i),success:function(a){var b=c.parse&&c.parse(a)||m(a);t.add(d,b),e(d,b)}})}else f(d)}function m(b){for(var d=[],e=b.split("\n"),f=0;f<e.length;f++){var g=a.trim(e[f]);g&&(g=g.split("|"),d[d.length]={data:g,value:g[0],result:c.formatResult&&c.formatResult(g,g[0])||g[0]})}return d}function n(){r.removeClass(c.loadingClass),jQuery("#send-to-input").removeClass("loading")}var o,p,q={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34},r=a(b).attr("autocomplete","off").addClass(c.inputClass),s="",t=a.Autocompleter.Cache(c),u=0,v={mouseDownOnSelect:!1},w=a.Autocompleter.Select(c,b,d,v);r.keydown(function(b){switch(p=b.keyCode,b.keyCode){case q.UP:b.preventDefault(),w.visible()?w.prev():e(0,!0);break;case q.DOWN:b.preventDefault(),w.visible()?w.next():e(0,!0);break;case q.PAGEUP:b.preventDefault(),w.visible()?w.pageUp():e(0,!0);break;case q.PAGEDOWN:b.preventDefault(),w.visible()?w.pageDown():e(0,!0);break;case c.multiple&&","==a.trim(c.multipleSeparator)&&q.COMMA:case q.TAB:case q.RETURN:d()&&(c.multiple||r.blur(),b.preventDefault(),r.focus());break;case q.ESC:w.hide();break;default:clearTimeout(o),o=setTimeout(e,c.delay)}}).keypress(function(){}).focus(function(){u++}).blur(function(){u=0,v.mouseDownOnSelect||i()}).click(function(){u++>1&&!w.visible()&&e(0,!0)}).bind("search",function(){function b(a,b){var d;if(b&&b.length)for(var e=0;e<b.length;e++)if(b[e].result.toLowerCase()==a.toLowerCase()){d=b[e];break}"function"==typeof c?c(d):r.trigger("result",d&&[d.data,d.value])}var c=arguments.length>1?arguments[1]:null;a.each(f(r.val()),function(a,c){l(c,b,b)})}).bind("flushCache",function(){t.flush()}).bind("setOptions",function(){a.extend(c,arguments[1]),"data"in arguments[1]&&t.populate()}).bind("unautocomplete",function(){w.unbind(),r.unbind()})},a.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:!1,matchSubset:!0,matchContains:!1,cacheLength:10,max:100,mustMatch:!1,extraParams:{},selectFirst:!0,formatItem:function(a){return a[0]},autoFill:!1,width:0,multiple:!1,multipleSeparator:", ",highlight:function(a,b){return a.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+b.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>")},scroll:!0,scrollHeight:250,attachTo:"body"},a.Autocompleter.Cache=function(b){function c(a,c){b.matchCase||(a=a.toLowerCase());var d=a.indexOf(c);return-1==d?!1:0==d||b.matchContains}function d(a,c){h>b.cacheLength&&f(),g[a]||h++,g[a]=c}function e(){if(!b.data)return!1;var c={},e=0;b.url||(b.cacheLength=1),c[""]=[];for(var f=0,g=b.data.length;g>f;f++){var h=b.data[f];h="string"==typeof h?[h]:h;var i=b.formatItem(h,f+1,b.data.length);if(i!==!1){var j=i.charAt(0).toLowerCase();c[j]||(c[j]=[]);var k={value:i,data:h,result:b.formatResult&&b.formatResult(h)||i};c[j].push(k),e++<b.max&&c[""].push(k)}}a.each(c,function(a,c){b.cacheLength++,d(a,c)})}function f(){g={},h=0}var g={},h=0;return setTimeout(e,25),{flush:f,add:d,populate:e,load:function(d){if(!b.cacheLength||!h)return null;if(!b.url&&b.matchContains){var e=[];for(var f in g)if(f.length>0){var i=g[f];a.each(i,function(a,b){c(b.value,d)&&e.push(b)})}return e}if(g[d])return g[d];if(b.matchSubset)for(var j=d.length-1;j>=b.minChars;j--){var i=g[d.substr(0,j)];if(i){var e=[];return a.each(i,function(a,b){c(b.value,d)&&(e[e.length]=b)}),e}}return null}}},a.Autocompleter.Select=function(b,c,d,e){function f(){s&&(n=a("<div/>").hide().addClass(b.resultsClass).css("position","absolute").appendTo(b.attachTo),o=a("<ul>").appendTo(n).mouseover(function(b){g(b).nodeName&&"LI"==g(b).nodeName.toUpperCase()&&(q=a("li",o).removeClass(p.ACTIVE).index(g(b)),a(g(b)).addClass(p.ACTIVE))}).click(function(b){return a(g(b)).addClass(p.ACTIVE),d(),c.focus(),!1}).mousedown(function(){e.mouseDownOnSelect=!0}).mouseup(function(){e.mouseDownOnSelect=!1}),b.width>0&&n.css("width",b.width),s=!1)}function g(a){for(var b=a.target;b&&"LI"!=b.tagName;)b=b.parentNode;return b?b:[]}function h(a){l.slice(q,q+1).removeClass(),i(a);var c=l.slice(q,q+1).addClass(p.ACTIVE);if(b.scroll){var d=0;l.slice(0,q).each(function(){d+=this.offsetHeight}),d+c[0].offsetHeight-o.scrollTop()>o[0].clientHeight?o.scrollTop(d+c[0].offsetHeight-o.innerHeight()):d<o.scrollTop()&&o.scrollTop(d)}}function i(a){q+=a,0>q?q=l.size()-1:q>=l.size()&&(q=0)}function j(a){return b.max&&b.max<a?b.max:a}function k(){o.empty();for(var c=j(m.length),d=0;c>d;d++)if(m[d]){var e=b.formatItem(m[d].data,d+1,c,m[d].value,r);if(e!==!1){var f=a("<li>").html(b.highlight(e,r)).addClass(d%2==0?"ac_event":"ac_odd").appendTo(o)[0];a.data(f,"ac_data",m[d])}}l=o.find("li"),b.selectFirst&&(l.slice(0,1).addClass(p.ACTIVE),q=0),o.bgiframe()}var l,m,n,o,p={ACTIVE:"ac_over"},q=-1,r="",s=!0;return{display:function(a,b){f(),m=a,r=b,k()},next:function(){h(1)},prev:function(){h(-1)},pageUp:function(){h(0!=q&&0>q-8?-q:-8)},pageDown:function(){h(q!=l.size()-1&&q+8>l.size()?l.size()-1-q:8)},hide:function(){n&&n.hide(),q=-1},visible:function(){return n&&n.is(":visible")},current:function(){return this.visible()&&(l.filter("."+p.ACTIVE)[0]||b.selectFirst&&l[0])},show:function(){var d=a(c).offset();if(n.css({width:"string"==typeof b.width||b.width>0?b.width:a(c).width(),top:d.top+c.offsetHeight,left:d.left}).show(),b.scroll&&(o.scrollTop(0),o.css({maxHeight:b.scrollHeight,overflow:"auto"}),a.browser.msie&&"undefined"==typeof document.body.style.maxHeight)){var e=0;l.each(function(){e+=this.offsetHeight});var f=e>b.scrollHeight;o.css("height",f?b.scrollHeight:e),f||l.width(o.width()-parseInt(l.css("padding-left"))-parseInt(l.css("padding-right")))}},selected:function(){var b=l&&l.filter("."+p.ACTIVE).removeClass(p.ACTIVE);return b&&b.length&&a.data(b[0],"ac_data")},unbind:function(){n&&n.remove()}}},a.Autocompleter.Selection=function(a,b,c){if(a.createTextRange){var d=a.createTextRange();d.collapse(!0),d.moveStart("character",b),d.moveEnd("character",c),d.select()}else a.setSelectionRange?a.setSelectionRange(b,c):a.selectionStart&&(a.selectionStart=b,a.selectionEnd=c);a.focus()}}(jQuery);
|
File without changes
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
jQuery.fn.autoCompletefb=function(a){var b=this,c={ul:b,urlLookup:[""],acOptions:{},foundClass:".friend-tab",inputClass:".send-to-input"};a&&jQuery.extend(c,a);var d={params:c,removeFind:function(a){return d.removeUsername(a),jQuery(a).unbind("click").parent().remove(),jQuery(c.inputClass,b).focus(),b.acfb},removeUsername:function(a){var b=a.parentNode.id.substr(a.parentNode.id.indexOf("-")+1);jQuery("#send-to-usernames").removeClass(b)}};return jQuery(c.foundClass+" img.p").click(function(){d.removeFind(this)}),jQuery(c.inputClass,b).autocomplete(c.urlLookup,c.acOptions),jQuery(c.inputClass,b).result(function(a,e,f){var f=c.foundClass.replace(/\./,""),e=String(e).split(" ("),g=e[1].substr(0,e[1].length-1);if(0===jQuery(c.inputClass).siblings("#un-"+g).length){var h="#link-"+g,i=jQuery(h).attr("href"),j='<li class="'+f+'" id="un-'+g+'"><span><a href="'+i+'">'+e[0]+'</a></span> <span class="p">X</span></li>',k=jQuery(c.inputClass,b).before(j);jQuery("#send-to-usernames").addClass(g),jQuery(".p",k[0].previousSibling).click(function(){d.removeFind(this)})}jQuery(c.inputClass,b).val("")}),jQuery(c.inputClass,b).focus(),d};
|
File without changes
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
!function(a){function b(a){return a&&a.constructor===Number?a+"px":a}a.fn.bgiframe=a.browser.msie&&/msie 6\.0/i.test(navigator.userAgent)?function(c){c=a.extend({top:"auto",left:"auto",width:"auto",height:"auto",opacity:!0,src:"javascript:false;"},c);var d='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+c.src+'"style="display:block;position:absolute;z-index:-1;'+(c.opacity!==!1?"filter:Alpha(Opacity='0');":"")+"top:"+("auto"==c.top?"expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+'px')":b(c.top))+";left:"+("auto"==c.left?"expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+'px')":b(c.left))+";width:"+("auto"==c.width?"expression(this.parentNode.offsetWidth+'px')":b(c.width))+";height:"+("auto"==c.height?"expression(this.parentNode.offsetHeight+'px')":b(c.height))+';"/>';return this.each(function(){0===a(this).children("iframe.bgiframe").length&&this.insertBefore(document.createElement(d),this.firstChild)})}:function(){return this},a.fn.bgIframe=a.fn.bgiframe}(jQuery);
|
File without changes
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
!function(a){a.dimensions={version:"@VERSION"},a.each(["Height","Width"],function(c,d){a.fn["inner"+d]=function(){if(this[0]){var a="Height"==d?"Top":"Left",c="Height"==d?"Bottom":"Right";return this[d.toLowerCase()]()+b(this,"padding"+a)+b(this,"padding"+c)}},a.fn["outer"+d]=function(c){if(this[0]){var e="Height"==d?"Top":"Left",f="Height"==d?"Bottom":"Right";return c=a.extend({margin:!1},c||{}),this[d.toLowerCase()]()+b(this,"border"+e+"Width")+b(this,"border"+f+"Width")+b(this,"padding"+e)+b(this,"padding"+f)+(c.margin?b(this,"margin"+e)+b(this,"margin"+f):0)}}}),a.each(["Left","Top"],function(b,c){a.fn["scroll"+c]=function(b){return this[0]?void 0!=b?this.each(function(){this==window||this==document?window.scrollTo("Left"==c?b:a(window).scrollLeft(),"Top"==c?b:a(window).scrollTop()):this["scroll"+c]=b}):this[0]==window||this[0]==document?self["Left"==c?"pageXOffset":"pageYOffset"]||a.boxModel&&document.documentElement["scroll"+c]||document.body["scroll"+c]:this[0]["scroll"+c]:void 0}}),a.fn.extend({position:function(){var a,c,d,e,f=this[0];return f&&(d=this.offsetParent(),a=this.offset(),c=d.offset(),a.top-=b(f,"marginTop"),a.left-=b(f,"marginLeft"),c.top+=b(d,"borderTopWidth"),c.left+=b(d,"borderLeftWidth"),e={top:a.top-c.top,left:a.left-c.left}),e},offsetParent:function(){for(var b=this[0].offsetParent;b&&!/^body|html$/i.test(b.tagName)&&"static"==a.css(b,"position");)b=b.offsetParent;return a(b)}});var b=function(b,c){return parseInt(a.css(b.jquery?b[0]:b,c))||0}}(jQuery);
|
File without changes
|
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* jshint undef: false */
|
2 |
+
/* jshint -W065 */
|
3 |
+
|
4 |
+
/*!
|
5 |
+
* jQuery.ScrollTo
|
6 |
+
* Copyright (c) 2007-2014 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
|
7 |
+
* Licensed under MIT
|
8 |
+
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
|
9 |
+
* @projectDescription Easy element scrolling using jQuery.
|
10 |
+
* @author Ariel Flesler
|
11 |
+
* @version 1.4.12
|
12 |
+
*/
|
13 |
+
|
14 |
+
(function(factory) {
|
15 |
+
// AMD
|
16 |
+
if (typeof define === 'function' && define.amd) {
|
17 |
+
define(['jquery'], factory);
|
18 |
+
// CommonJS
|
19 |
+
} else if (typeof exports === 'object') {
|
20 |
+
factory(require('jquery'));
|
21 |
+
// Browser globals
|
22 |
+
} else {
|
23 |
+
factory(jQuery);
|
24 |
+
}
|
25 |
+
}(function($) {
|
26 |
+
|
27 |
+
var $scrollTo = $.scrollTo = function(target, duration, settings) {
|
28 |
+
return $(window).scrollTo(target, duration, settings);
|
29 |
+
};
|
30 |
+
|
31 |
+
$scrollTo.defaults = {
|
32 |
+
axis: 'xy',
|
33 |
+
duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1,
|
34 |
+
limit: true
|
35 |
+
};
|
36 |
+
|
37 |
+
// Returns the element that needs to be animated to scroll the window.
|
38 |
+
// Kept for backwards compatibility (specially for localScroll & serialScroll)
|
39 |
+
$scrollTo.window = function() {
|
40 |
+
return $(window)._scrollable();
|
41 |
+
};
|
42 |
+
|
43 |
+
// Hack, hack, hack :)
|
44 |
+
// Returns the real elements to scroll (supports window/iframes, documents and regular nodes)
|
45 |
+
$.fn._scrollable = function() {
|
46 |
+
return this.map(function() {
|
47 |
+
var elem = this,
|
48 |
+
isWin = !elem.nodeName || $.inArray(elem.nodeName.toLowerCase(), ['iframe', '#document', 'html', 'body']) !== -1;
|
49 |
+
|
50 |
+
if (!isWin) {
|
51 |
+
return elem;
|
52 |
+
}
|
53 |
+
|
54 |
+
var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem;
|
55 |
+
|
56 |
+
return /webkit/i.test(navigator.userAgent) || doc.compatMode === 'BackCompat' ?
|
57 |
+
doc.body :
|
58 |
+
doc.documentElement;
|
59 |
+
});
|
60 |
+
};
|
61 |
+
|
62 |
+
$.fn.scrollTo = function(target, duration, settings) {
|
63 |
+
if (typeof duration === 'object') {
|
64 |
+
settings = duration;
|
65 |
+
duration = 0;
|
66 |
+
}
|
67 |
+
if (typeof settings === 'function') {
|
68 |
+
settings = {onAfter: settings};
|
69 |
+
}
|
70 |
+
|
71 |
+
if (target === 'max') {
|
72 |
+
target = 9e9;
|
73 |
+
}
|
74 |
+
|
75 |
+
settings = $.extend({}, $scrollTo.defaults, settings);
|
76 |
+
// Speed is still recognized for backwards compatibility
|
77 |
+
duration = duration || settings.duration;
|
78 |
+
// Make sure the settings are given right
|
79 |
+
settings.queue = settings.queue && settings.axis.length > 1;
|
80 |
+
|
81 |
+
// Let's keep the overall duration
|
82 |
+
if (settings.queue) {
|
83 |
+
duration /= 2;
|
84 |
+
}
|
85 |
+
|
86 |
+
settings.offset = both(settings.offset);
|
87 |
+
settings.over = both(settings.over);
|
88 |
+
|
89 |
+
return this._scrollable().each(function() {
|
90 |
+
|
91 |
+
// Null target yields nothing, just like jQuery does
|
92 |
+
if (target === null) {
|
93 |
+
return;
|
94 |
+
}
|
95 |
+
|
96 |
+
var elem = this,
|
97 |
+
$elem = $(elem),
|
98 |
+
targ = target, toff, attr = {},
|
99 |
+
win = $elem.is('html,body');
|
100 |
+
|
101 |
+
switch (typeof targ) {
|
102 |
+
// A number will pass the regex
|
103 |
+
case 'number':
|
104 |
+
case 'string':
|
105 |
+
if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
|
106 |
+
targ = both(targ);
|
107 |
+
// We are done
|
108 |
+
break;
|
109 |
+
}
|
110 |
+
// Relative/Absolute selector, no break!
|
111 |
+
targ = win ? $(targ) : $(targ, this);
|
112 |
+
if (!targ.length) {
|
113 |
+
return;
|
114 |
+
}
|
115 |
+
/* falls through */
|
116 |
+
case 'object':
|
117 |
+
// DOMElement / jQuery
|
118 |
+
if (targ.is || targ.style) {
|
119 |
+
// Get the real position of the target
|
120 |
+
toff = (targ = $(targ)).offset();
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
var offset = $.isFunction(settings.offset) && settings.offset(elem, targ) || settings.offset;
|
125 |
+
|
126 |
+
$.each(settings.axis.split(''), function(i, axis) {
|
127 |
+
var Pos = axis === 'x' ? 'Left' : 'Top',
|
128 |
+
pos = Pos.toLowerCase(),
|
129 |
+
key = 'scroll' + Pos,
|
130 |
+
old = elem[key],
|
131 |
+
max = $scrollTo.max(elem, axis);
|
132 |
+
|
133 |
+
if (toff) {// jQuery / DOMElement
|
134 |
+
attr[key] = toff[pos] + (win ? 0 : old - $elem.offset()[pos]);
|
135 |
+
|
136 |
+
// If it's a dom element, reduce the margin
|
137 |
+
if (settings.margin) {
|
138 |
+
attr[key] -= parseInt(targ.css('margin' + Pos)) || 0;
|
139 |
+
attr[key] -= parseInt(targ.css('border' + Pos + 'Width')) || 0;
|
140 |
+
}
|
141 |
+
|
142 |
+
attr[key] += offset[pos] || 0;
|
143 |
+
|
144 |
+
// Scroll to a fraction of its width/height
|
145 |
+
if (settings.over[pos]) {
|
146 |
+
attr[key] += targ[axis === 'x' ? 'width' : 'height']() * settings.over[pos];
|
147 |
+
}
|
148 |
+
} else {
|
149 |
+
var val = targ[pos];
|
150 |
+
// Handle percentage values
|
151 |
+
attr[key] = val.slice && val.slice(-1) === '%' ?
|
152 |
+
parseFloat(val) / 100 * max
|
153 |
+
: val;
|
154 |
+
}
|
155 |
+
|
156 |
+
// Number or 'number'
|
157 |
+
if (settings.limit && /^\d+$/.test(attr[key])) {
|
158 |
+
// Check the limits
|
159 |
+
attr[key] = attr[key] <= 0 ? 0 : Math.min(attr[key], max);
|
160 |
+
}
|
161 |
+
|
162 |
+
// Queueing axes
|
163 |
+
if (!i && settings.queue) {
|
164 |
+
// Don't waste time animating, if there's no need.
|
165 |
+
if (old !== attr[key]) {
|
166 |
+
// Intermediate animation
|
167 |
+
animate(settings.onAfterFirst);
|
168 |
+
}
|
169 |
+
// Don't animate this axis again in the next iteration.
|
170 |
+
delete attr[key];
|
171 |
+
}
|
172 |
+
});
|
173 |
+
|
174 |
+
animate(settings.onAfter);
|
175 |
+
|
176 |
+
function animate(callback) {
|
177 |
+
$elem.animate(attr, duration, settings.easing, callback && function() {
|
178 |
+
callback.call(this, targ, settings);
|
179 |
+
});
|
180 |
+
}
|
181 |
+
|
182 |
+
}).end();
|
183 |
+
};
|
184 |
+
|
185 |
+
// Max scrolling position, works on quirks mode
|
186 |
+
// It only fails (not too badly) on IE, quirks mode.
|
187 |
+
$scrollTo.max = function(elem, axis) {
|
188 |
+
var Dim = axis === 'x' ? 'Width' : 'Height',
|
189 |
+
scroll = 'scroll' + Dim;
|
190 |
+
|
191 |
+
if (!$(elem).is('html,body')) {
|
192 |
+
return elem[scroll] - $(elem)[Dim.toLowerCase()]();
|
193 |
+
}
|
194 |
+
|
195 |
+
var size = 'client' + Dim,
|
196 |
+
html = elem.ownerDocument.documentElement,
|
197 |
+
body = elem.ownerDocument.body;
|
198 |
+
|
199 |
+
return Math.max(html[scroll], body[scroll]) - Math.min(html[size], body[size]);
|
200 |
+
};
|
201 |
+
|
202 |
+
function both(val) {
|
203 |
+
return $.isFunction(val) || typeof val === 'object' ? val : {top: val, left: val};
|
204 |
+
}
|
205 |
+
|
206 |
+
// AMD requirement
|
207 |
+
return $scrollTo;
|
208 |
+
}));
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){function b(b){return a.isFunction(b)||"object"==typeof b?b:{top:b,left:b}}var c=a.scrollTo=function(b,c,d){return a(window).scrollTo(b,c,d)};return c.defaults={axis:"xy",duration:parseFloat(a.fn.jquery)>=1.3?0:1,limit:!0},c.window=function(){return a(window)._scrollable()},a.fn._scrollable=function(){return this.map(function(){var b=this,c=!b.nodeName||-1!==a.inArray(b.nodeName.toLowerCase(),["iframe","#document","html","body"]);if(!c)return b;var d=(b.contentWindow||b).document||b.ownerDocument||b;return/webkit/i.test(navigator.userAgent)||"BackCompat"===d.compatMode?d.body:d.documentElement})},a.fn.scrollTo=function(d,e,f){return"object"==typeof e&&(f=e,e=0),"function"==typeof f&&(f={onAfter:f}),"max"===d&&(d=9e9),f=a.extend({},c.defaults,f),e=e||f.duration,f.queue=f.queue&&f.axis.length>1,f.queue&&(e/=2),f.offset=b(f.offset),f.over=b(f.over),this._scrollable().each(function(){function g(a){j.animate(l,e,f.easing,a&&function(){a.call(this,k,f)})}if(null!==d){var h,i=this,j=a(i),k=d,l={},m=j.is("html,body");switch(typeof k){case"number":case"string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(k)){k=b(k);break}if(k=m?a(k):a(k,this),!k.length)return;case"object":(k.is||k.style)&&(h=(k=a(k)).offset())}var n=a.isFunction(f.offset)&&f.offset(i,k)||f.offset;a.each(f.axis.split(""),function(a,b){var d="x"===b?"Left":"Top",e=d.toLowerCase(),o="scroll"+d,p=i[o],q=c.max(i,b);if(h)l[o]=h[e]+(m?0:p-j.offset()[e]),f.margin&&(l[o]-=parseInt(k.css("margin"+d))||0,l[o]-=parseInt(k.css("border"+d+"Width"))||0),l[o]+=n[e]||0,f.over[e]&&(l[o]+=k["x"===b?"width":"height"]()*f.over[e]);else{var r=k[e];l[o]=r.slice&&"%"===r.slice(-1)?parseFloat(r)/100*q:r}f.limit&&/^\d+$/.test(l[o])&&(l[o]=l[o]<=0?0:Math.min(l[o],q)),!a&&f.queue&&(p!==l[o]&&g(f.onAfterFirst),delete l[o])}),g(f.onAfter)}}).end()},c.max=function(b,c){var d="x"===c?"Width":"Height",e="scroll"+d;if(!a(b).is("html,body"))return b[e]-a(b)[d.toLowerCase()]();var f="client"+d,g=b.ownerDocument.documentElement,h=b.ownerDocument.body;return Math.max(g[e],h[e])-Math.min(g[f],h[f])},c});
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,7 +1,12 @@
|
|
|
|
|
|
|
|
1 |
jQuery( document ).ready( function() {
|
2 |
jQuery( 'a.confirm').click( function() {
|
3 |
-
if ( confirm( BP_Confirm.are_you_sure ) )
|
4 |
-
return true;
|
|
|
|
|
|
|
5 |
});
|
6 |
});
|
7 |
-
|
1 |
+
/* jshint devel: true */
|
2 |
+
/* global BP_Confirm */
|
3 |
+
|
4 |
jQuery( document ).ready( function() {
|
5 |
jQuery( 'a.confirm').click( function() {
|
6 |
+
if ( confirm( BP_Confirm.are_you_sure ) ) {
|
7 |
+
return true;
|
8 |
+
} else {
|
9 |
+
return false;
|
10 |
+
}
|
11 |
});
|
12 |
});
|
|
@@ -1 +1,2 @@
|
|
1 |
-
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
jQuery(document).ready(function(){jQuery("a.confirm").click(function(){return confirm(BP_Confirm.are_you_sure)?!0:!1})});
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* jshint undef: false */
|
2 |
+
|
3 |
+
/*!
|
4 |
+
* jQuery Cookie Plugin v1.4.1
|
5 |
+
* https://github.com/carhartl/jquery-cookie
|
6 |
+
*
|
7 |
+
* Copyright 2013 Klaus Hartl
|
8 |
+
* Released under the MIT license
|
9 |
+
*/
|
10 |
+
(function(factory) {
|
11 |
+
// AMD
|
12 |
+
if (typeof define === 'function' && define.amd) {
|
13 |
+
define(['jquery'], factory);
|
14 |
+
// CommonJS
|
15 |
+
} else if (typeof exports === 'object') {
|
16 |
+
factory(require('jquery'));
|
17 |
+
// Browser globals
|
18 |
+
} else {
|
19 |
+
factory(jQuery);
|
20 |
+
}
|
21 |
+
}(function($) {
|
22 |
+
|
23 |
+
var pluses = /\+/g;
|
24 |
+
|
25 |
+
function encode(s) {
|
26 |
+
return config.raw ? s : encodeURIComponent(s);
|
27 |
+
}
|
28 |
+
|
29 |
+
function decode(s) {
|
30 |
+
return config.raw ? s : decodeURIComponent(s);
|
31 |
+
}
|
32 |
+
|
33 |
+
function stringifyCookieValue(value) {
|
34 |
+
return encode(config.json ? JSON.stringify(value) : String(value));
|
35 |
+
}
|
36 |
+
|
37 |
+
function parseCookieValue(s) {
|
38 |
+
if (s.indexOf('"') === 0) {
|
39 |
+
// This is a quoted cookie as according to RFC2068, unescape...
|
40 |
+
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
41 |
+
}
|
42 |
+
|
43 |
+
try {
|
44 |
+
// Replace server-side written pluses with spaces.
|
45 |
+
// If we can't decode the cookie, ignore it, it's unusable.
|
46 |
+
// If we can't parse the cookie, ignore it, it's unusable.
|
47 |
+
s = decodeURIComponent(s.replace(pluses, ' '));
|
48 |
+
return config.json ? JSON.parse(s) : s;
|
49 |
+
} catch (e) {
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
function read(s, converter) {
|
54 |
+
var value = config.raw ? s : parseCookieValue(s);
|
55 |
+
return $.isFunction(converter) ? converter(value) : value;
|
56 |
+
}
|
57 |
+
|
58 |
+
var config = $.cookie = function(key, value, options) {
|
59 |
+
|
60 |
+
// Write
|
61 |
+
|
62 |
+
if (value !== undefined && !$.isFunction(value)) {
|
63 |
+
options = $.extend({}, config.defaults, options);
|
64 |
+
|
65 |
+
if (typeof options.expires === 'number') {
|
66 |
+
var days = options.expires, t = options.expires = new Date();
|
67 |
+
t.setTime(+t + days * 864e+5);
|
68 |
+
}
|
69 |
+
|
70 |
+
return (document.cookie = [
|
71 |
+
encode(key), '=', stringifyCookieValue(value),
|
72 |
+
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
73 |
+
options.path ? '; path=' + options.path : '',
|
74 |
+
options.domain ? '; domain=' + options.domain : '',
|
75 |
+
options.secure ? '; secure' : ''
|
76 |
+
].join(''));
|
77 |
+
}
|
78 |
+
|
79 |
+
// Read
|
80 |
+
|
81 |
+
var result = key ? undefined : {};
|
82 |
+
|
83 |
+
// To prevent the for loop in the first place assign an empty array
|
84 |
+
// in case there are no cookies at all. Also prevents odd result when
|
85 |
+
// calling $.cookie().
|
86 |
+
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
87 |
+
|
88 |
+
for (var i = 0, l = cookies.length; i < l; i++) {
|
89 |
+
var parts = cookies[i].split('=');
|
90 |
+
var name = decode(parts.shift());
|
91 |
+
var cookie = parts.join('=');
|
92 |
+
|
93 |
+
if (key && key === name) {
|
94 |
+
// If second argument (value) is a function it's a converter...
|
95 |
+
result = read(cookie, value);
|
96 |
+
break;
|
97 |
+
}
|
98 |
+
|
99 |
+
// Prevent storing a cookie that we couldn't decode.
|
100 |
+
if (!key && (cookie = read(cookie)) !== undefined) {
|
101 |
+
result[name] = cookie;
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
return result;
|
106 |
+
};
|
107 |
+
|
108 |
+
config.defaults = {};
|
109 |
+
|
110 |
+
$.removeCookie = function(key, options) {
|
111 |
+
if ($.cookie(key) === undefined) {
|
112 |
+
return false;
|
113 |
+
}
|
114 |
+
|
115 |
+
// Must not alter options, thus extending a fresh object...
|
116 |
+
$.cookie(key, '', $.extend({}, options, {expires: -1}));
|
117 |
+
return !$.cookie(key);
|
118 |
+
};
|
119 |
+
|
120 |
+
}));
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){function b(a){return h.raw?a:encodeURIComponent(a)}function c(a){return h.raw?a:decodeURIComponent(a)}function d(a){return b(h.json?JSON.stringify(a):String(a))}function e(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return a=decodeURIComponent(a.replace(g," ")),h.json?JSON.parse(a):a}catch(b){}}function f(b,c){var d=h.raw?b:e(b);return a.isFunction(c)?c(d):d}var g=/\+/g,h=a.cookie=function(e,g,i){if(void 0!==g&&!a.isFunction(g)){if(i=a.extend({},h.defaults,i),"number"==typeof i.expires){var j=i.expires,k=i.expires=new Date;k.setTime(+k+864e5*j)}return document.cookie=[b(e),"=",d(g),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}for(var l=e?void 0:{},m=document.cookie?document.cookie.split("; "):[],n=0,o=m.length;o>n;n++){var p=m[n].split("="),q=c(p.shift()),r=p.join("=");if(e&&e===q){l=f(r,g);break}e||void 0===(r=f(r))||(l[q]=r)}return l};h.defaults={},a.removeCookie=function(b,c){return void 0===a.cookie(b)?!1:(a.cookie(b,"",a.extend({},c,{expires:-1})),!a.cookie(b))}});
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* jshint unused: false */
|
2 |
+
|
3 |
+
function bp_get_querystring( n ) {
|
4 |
+
var half = location.search.split( n + '=' )[1];
|
5 |
+
return half ? decodeURIComponent( half.split('&')[0] ) : null;
|
6 |
+
}
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
function bp_get_querystring(a){var b=location.search.split(a+"=")[1];return b?decodeURIComponent(b.split("&")[0]):null}
|
@@ -0,0 +1,824 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*! jquery.atwho - v0.5.0 - 2014-07-14
|
2 |
+
* Copyright (c) 2014 chord.luo <chord.luo@gmail.com>;
|
3 |
+
* homepage: http://ichord.github.com/At.js
|
4 |
+
* Licensed MIT
|
5 |
+
*/
|
6 |
+
|
7 |
+
(function() {
|
8 |
+
(function(factory) {
|
9 |
+
if (typeof define === 'function' && define.amd) {
|
10 |
+
return define(['jquery'], factory);
|
11 |
+
} else {
|
12 |
+
return factory(window.jQuery);
|
13 |
+
}
|
14 |
+
})(function($) {
|
15 |
+
|
16 |
+
var $CONTAINER, Api, App, Controller, DEFAULT_CALLBACKS, KEY_CODE, Model, View,
|
17 |
+
__slice = [].slice;
|
18 |
+
|
19 |
+
App = (function() {
|
20 |
+
function App(inputor) {
|
21 |
+
this.current_flag = null;
|
22 |
+
this.controllers = {};
|
23 |
+
this.alias_maps = {};
|
24 |
+
this.$inputor = $(inputor);
|
25 |
+
this.iframe = null;
|
26 |
+
this.setIframe();
|
27 |
+
this.listen();
|
28 |
+
}
|
29 |
+
|
30 |
+
App.prototype.setIframe = function(iframe) {
|
31 |
+
if (iframe) {
|
32 |
+
this.window = iframe.contentWindow;
|
33 |
+
this.document = iframe.contentDocument || this.window.document;
|
34 |
+
return this.iframe = iframe;
|
35 |
+
} else {
|
36 |
+
this.document = document;
|
37 |
+
this.window = window;
|
38 |
+
return this.iframe = null;
|
39 |
+
}
|
40 |
+
};
|
41 |
+
|
42 |
+
App.prototype.controller = function(at) {
|
43 |
+
var c, current, current_flag, _ref;
|
44 |
+
if (this.alias_maps[at]) {
|
45 |
+
current = this.controllers[this.alias_maps[at]];
|
46 |
+
} else {
|
47 |
+
_ref = this.controllers;
|
48 |
+
for (current_flag in _ref) {
|
49 |
+
c = _ref[current_flag];
|
50 |
+
if (current_flag === at) {
|
51 |
+
current = c;
|
52 |
+
break;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
if (current) {
|
57 |
+
return current;
|
58 |
+
} else {
|
59 |
+
return this.controllers[this.current_flag];
|
60 |
+
}
|
61 |
+
};
|
62 |
+
|
63 |
+
App.prototype.set_context_for = function(at) {
|
64 |
+
this.current_flag = at;
|
65 |
+
return this;
|
66 |
+
};
|
67 |
+
|
68 |
+
App.prototype.reg = function(flag, setting) {
|
69 |
+
var controller, _base;
|
70 |
+
controller = (_base = this.controllers)[flag] || (_base[flag] = new Controller(this, flag));
|
71 |
+
if (setting.alias) {
|
72 |
+
this.alias_maps[setting.alias] = flag;
|
73 |
+
}
|
74 |
+
controller.init(setting);
|
75 |
+
return this;
|
76 |
+
};
|
77 |
+
|
78 |
+
App.prototype.listen = function() {
|
79 |
+
return this.$inputor.on('keyup.atwhoInner', (function(_this) {
|
80 |
+
return function(e) {
|
81 |
+
return _this.on_keyup(e);
|
82 |
+
};
|
83 |
+
})(this)).on('keydown.atwhoInner', (function(_this) {
|
84 |
+
return function(e) {
|
85 |
+
return _this.on_keydown(e);
|
86 |
+
};
|
87 |
+
})(this)).on('scroll.atwhoInner', (function(_this) {
|
88 |
+
return function(e) {
|
89 |
+
var _ref;
|
90 |
+
return (_ref = _this.controller()) != null ? _ref.view.hide(e) : void 0;
|
91 |
+
};
|
92 |
+
})(this)).on('blur.atwhoInner', (function(_this) {
|
93 |
+
return function(e) {
|
94 |
+
var c;
|
95 |
+
if (c = _this.controller()) {
|
96 |
+
return c.view.hide(e, c.get_opt("display_timeout"));
|
97 |
+
}
|
98 |
+
};
|
99 |
+
})(this)).on('click.atwhoInner', (function(_this) {
|
100 |
+
return function(e) {
|
101 |
+
var _ref;
|
102 |
+
return (_ref = _this.controller()) != null ? _ref.view.hide(e) : void 0;
|
103 |
+
};
|
104 |
+
})(this));
|
105 |
+
};
|
106 |
+
|
107 |
+
App.prototype.shutdown = function() {
|
108 |
+
var c, _, _ref;
|
109 |
+
_ref = this.controllers;
|
110 |
+
for (_ in _ref) {
|
111 |
+
c = _ref[_];
|
112 |
+
c.destroy();
|
113 |
+
delete this.controllers[_];
|
114 |
+
}
|
115 |
+
return this.$inputor.off('.atwhoInner');
|
116 |
+
};
|
117 |
+
|
118 |
+
App.prototype.dispatch = function() {
|
119 |
+
return $.map(this.controllers, (function(_this) {
|
120 |
+
return function(c) {
|
121 |
+
var delay;
|
122 |
+
if (delay = c.get_opt('delay')) {
|
123 |
+
clearTimeout(_this.delayedCallback);
|
124 |
+
return _this.delayedCallback = setTimeout(function() {
|
125 |
+
if (c.look_up()) {
|
126 |
+
return _this.set_context_for(c.at);
|
127 |
+
}
|
128 |
+
}, delay);
|
129 |
+
} else {
|
130 |
+
if (c.look_up()) {
|
131 |
+
return _this.set_context_for(c.at);
|
132 |
+
}
|
133 |
+
}
|
134 |
+
};
|
135 |
+
})(this));
|
136 |
+
};
|
137 |
+
|
138 |
+
App.prototype.on_keyup = function(e) {
|
139 |
+
var _ref;
|
140 |
+
switch (e.keyCode) {
|
141 |
+
case KEY_CODE.ESC:
|
142 |
+
e.preventDefault();
|
143 |
+
if ((_ref = this.controller()) != null) {
|
144 |
+
_ref.view.hide();
|
145 |
+
}
|
146 |
+
break;
|
147 |
+
case KEY_CODE.DOWN:
|
148 |
+
case KEY_CODE.UP:
|
149 |
+
case KEY_CODE.CTRL:
|
150 |
+
$.noop();
|
151 |
+
break;
|
152 |
+
case KEY_CODE.P:
|
153 |
+
case KEY_CODE.N:
|
154 |
+
if (!e.ctrlKey) {
|
155 |
+
this.dispatch();
|
156 |
+
}
|
157 |
+
break;
|
158 |
+
default:
|
159 |
+
this.dispatch();
|
160 |
+
}
|
161 |
+
};
|
162 |
+
|
163 |
+
App.prototype.on_keydown = function(e) {
|
164 |
+
var view, _ref;
|
165 |
+
view = (_ref = this.controller()) != null ? _ref.view : void 0;
|
166 |
+
if (!(view && view.visible())) {
|
167 |
+
return;
|
168 |
+
}
|
169 |
+
switch (e.keyCode) {
|
170 |
+
case KEY_CODE.ESC:
|
171 |
+
e.preventDefault();
|
172 |
+
view.hide(e);
|
173 |
+
break;
|
174 |
+
case KEY_CODE.UP:
|
175 |
+
e.preventDefault();
|
176 |
+
view.prev();
|
177 |
+
break;
|
178 |
+
case KEY_CODE.DOWN:
|
179 |
+
e.preventDefault();
|
180 |
+
view.next();
|
181 |
+
break;
|
182 |
+
case KEY_CODE.P:
|
183 |
+
if (!e.ctrlKey) {
|
184 |
+
return;
|
185 |
+
}
|
186 |
+
e.preventDefault();
|
187 |
+
view.prev();
|
188 |
+
break;
|
189 |
+
case KEY_CODE.N:
|
190 |
+
if (!e.ctrlKey) {
|
191 |
+
return;
|
192 |
+
}
|
193 |
+
e.preventDefault();
|
194 |
+
view.next();
|
195 |
+
break;
|
196 |
+
case KEY_CODE.TAB:
|
197 |
+
case KEY_CODE.ENTER:
|
198 |
+
if (!view.visible()) {
|
199 |
+
return;
|
200 |
+
}
|
201 |
+
e.preventDefault();
|
202 |
+
view.choose(e);
|
203 |
+
break;
|
204 |
+
default:
|
205 |
+
$.noop();
|
206 |
+
}
|
207 |
+
};
|
208 |
+
|
209 |
+
return App;
|
210 |
+
|
211 |
+
})();
|
212 |
+
|
213 |
+
Controller = (function() {
|
214 |
+
Controller.prototype.uid = function() {
|
215 |
+
return (Math.random().toString(16) + "000000000").substr(2, 8) + (new Date().getTime());
|
216 |
+
};
|
217 |
+
|
218 |
+
function Controller(app, at) {
|
219 |
+
this.app = app;
|
220 |
+
this.at = at;
|
221 |
+
this.$inputor = this.app.$inputor;
|
222 |
+
this.id = this.$inputor[0].id || this.uid();
|
223 |
+
this.setting = null;
|
224 |
+
this.query = null;
|
225 |
+
this.pos = 0;
|
226 |
+
this.cur_rect = null;
|
227 |
+
this.range = null;
|
228 |
+
$CONTAINER.append(this.$el = $("<div id='atwho-ground-" + this.id + "'></div>"));
|
229 |
+
this.model = new Model(this);
|
230 |
+
this.view = new View(this);
|
231 |
+
}
|
232 |
+
|
233 |
+
Controller.prototype.init = function(setting) {
|
234 |
+
this.setting = $.extend({}, this.setting || $.fn.atwho["default"], setting);
|
235 |
+
this.view.init();
|
236 |
+
return this.model.reload(this.setting.data);
|
237 |
+
};
|
238 |
+
|
239 |
+
Controller.prototype.destroy = function() {
|
240 |
+
this.trigger('beforeDestroy');
|
241 |
+
this.model.destroy();
|
242 |
+
this.view.destroy();
|
243 |
+
return this.$el.remove();
|
244 |
+
};
|
245 |
+
|
246 |
+
Controller.prototype.call_default = function() {
|
247 |
+
var args, error, func_name;
|
248 |
+
func_name = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
249 |
+
try {
|
250 |
+
return DEFAULT_CALLBACKS[func_name].apply(this, args);
|
251 |
+
} catch (_error) {
|
252 |
+
error = _error;
|
253 |
+
return $.error("" + error + " Or maybe At.js doesn't have function " + func_name);
|
254 |
+
}
|
255 |
+
};
|
256 |
+
|
257 |
+
Controller.prototype.trigger = function(name, data) {
|
258 |
+
var alias, event_name;
|
259 |
+
if (data == null) {
|
260 |
+
data = [];
|
261 |
+
}
|
262 |
+
data.push(this);
|
263 |
+
alias = this.get_opt('alias');
|
264 |
+
event_name = alias ? "" + name + "-" + alias + ".atwho" : "" + name + ".atwho";
|
265 |
+
return this.$inputor.trigger(event_name, data);
|
266 |
+
};
|
267 |
+
|
268 |
+
Controller.prototype.callbacks = function(func_name) {
|
269 |
+
return this.get_opt("callbacks")[func_name] || DEFAULT_CALLBACKS[func_name];
|
270 |
+
};
|
271 |
+
|
272 |
+
Controller.prototype.get_opt = function(at, default_value) {
|
273 |
+
var e;
|
274 |
+
try {
|
275 |
+
return this.setting[at];
|
276 |
+
} catch (_error) {
|
277 |
+
e = _error;
|
278 |
+
return null;
|
279 |
+
}
|
280 |
+
};
|
281 |
+
|
282 |
+
Controller.prototype.content = function() {
|
283 |
+
if (this.$inputor.is('textarea, input')) {
|
284 |
+
return this.$inputor.val();
|
285 |
+
} else {
|
286 |
+
return this.$inputor.text();
|
287 |
+
}
|
288 |
+
};
|
289 |
+
|
290 |
+
Controller.prototype.catch_query = function() {
|
291 |
+
var caret_pos, content, end, query, start, subtext;
|
292 |
+
content = this.content();
|
293 |
+
caret_pos = this.$inputor.caret('pos', {
|
294 |
+
iframe: this.app.iframe
|
295 |
+
});
|
296 |
+
subtext = content.slice(0, caret_pos);
|
297 |
+
query = this.callbacks("matcher").call(this, this.at, subtext, this.get_opt('start_with_space'));
|
298 |
+
if (typeof query === "string" && query.length <= this.get_opt('max_len', 20)) {
|
299 |
+
start = caret_pos - query.length;
|
300 |
+
end = start + query.length;
|
301 |
+
this.pos = start;
|
302 |
+
query = {
|
303 |
+
'text': query,
|
304 |
+
'head_pos': start,
|
305 |
+
'end_pos': end
|
306 |
+
};
|
307 |
+
this.trigger("matched", [this.at, query.text]);
|
308 |
+
} else {
|
309 |
+
query = null;
|
310 |
+
this.view.hide();
|
311 |
+
}
|
312 |
+
return this.query = query;
|
313 |
+
};
|
314 |
+
|
315 |
+
Controller.prototype.rect = function() {
|
316 |
+
var c, scale_bottom;
|
317 |
+
if (!(c = this.$inputor.caret('offset', this.pos - 1, {
|
318 |
+
iframe: this.app.iframe
|
319 |
+
}))) {
|
320 |
+
return;
|
321 |
+
}
|
322 |
+
if (this.$inputor.attr('contentEditable') === 'true') {
|
323 |
+
c = (this.cur_rect || (this.cur_rect = c)) || c;
|
324 |
+
}
|
325 |
+
scale_bottom = this.app.document.selection ? 0 : 2;
|
326 |
+
return {
|
327 |
+
left: c.left,
|
328 |
+
top: c.top,
|
329 |
+
bottom: c.top + c.height + scale_bottom
|
330 |
+
};
|
331 |
+
};
|
332 |
+
|
333 |
+
Controller.prototype.reset_rect = function() {
|
334 |
+
if (this.$inputor.attr('contentEditable') === 'true') {
|
335 |
+
return this.cur_rect = null;
|
336 |
+
}
|
337 |
+
};
|
338 |
+
|
339 |
+
Controller.prototype.mark_range = function() {
|
340 |
+
if (this.$inputor.attr('contentEditable') === 'true') {
|
341 |
+
if (this.app.window.getSelection) {
|
342 |
+
this.range = this.app.window.getSelection().getRangeAt(0);
|
343 |
+
}
|
344 |
+
if (this.app.document.selection) {
|
345 |
+
return this.ie8_range = this.app.document.selection.createRange();
|
346 |
+
}
|
347 |
+
}
|
348 |
+
};
|
349 |
+
|
350 |
+
Controller.prototype.insert_content_for = function($li) {
|
351 |
+
var data, data_value, tpl;
|
352 |
+
data_value = $li.data('value');
|
353 |
+
tpl = this.get_opt('insert_tpl');
|
354 |
+
if (this.$inputor.is('textarea, input') || !tpl) {
|
355 |
+
return data_value;
|
356 |
+
}
|
357 |
+
data = $.extend({}, $li.data('item-data'), {
|
358 |
+
'atwho-data-value': data_value,
|
359 |
+
'atwho-at': this.at
|
360 |
+
});
|
361 |
+
return this.callbacks("tpl_eval").call(this, tpl, data);
|
362 |
+
};
|
363 |
+
|
364 |
+
Controller.prototype.insert = function(content, $li) {
|
365 |
+
var $inputor, content_node, pos, range, sel, source, start_str, text, wrapped_content;
|
366 |
+
$inputor = this.$inputor;
|
367 |
+
wrapped_content = this.callbacks('inserting_wrapper').call(this, $inputor, content, this.get_opt("suffix"));
|
368 |
+
if ($inputor.is('textarea, input')) {
|
369 |
+
source = $inputor.val();
|
370 |
+
start_str = source.slice(0, Math.max(this.query.head_pos - this.at.length, 0));
|
371 |
+
text = "" + start_str + wrapped_content + (source.slice(this.query['end_pos'] || 0));
|
372 |
+
$inputor.val(text);
|
373 |
+
$inputor.caret('pos', start_str.length + wrapped_content.length, {
|
374 |
+
iframe: this.app.iframe
|
375 |
+
});
|
376 |
+
} else if (range = this.range) {
|
377 |
+
pos = range.startOffset - (this.query.end_pos - this.query.head_pos) - this.at.length;
|
378 |
+
range.setStart(range.endContainer, Math.max(pos, 0));
|
379 |
+
range.setEnd(range.endContainer, range.endOffset);
|
380 |
+
range.deleteContents();
|
381 |
+
content_node = $(wrapped_content, this.app.document)[0];
|
382 |
+
range.insertNode(content_node);
|
383 |
+
range.setEndAfter(content_node);
|
384 |
+
range.collapse(false);
|
385 |
+
sel = this.app.window.getSelection();
|
386 |
+
sel.removeAllRanges();
|
387 |
+
sel.addRange(range);
|
388 |
+
} else if (range = this.ie8_range) {
|
389 |
+
range.moveStart('character', this.query.end_pos - this.query.head_pos - this.at.length);
|
390 |
+
range.pasteHTML(wrapped_content);
|
391 |
+
range.collapse(false);
|
392 |
+
range.select();
|
393 |
+
}
|
394 |
+
if (!$inputor.is(':focus')) {
|
395 |
+
$inputor.focus();
|
396 |
+
}
|
397 |
+
return $inputor.change();
|
398 |
+
};
|
399 |
+
|
400 |
+
Controller.prototype.render_view = function(data) {
|
401 |
+
var search_key;
|
402 |
+
search_key = this.get_opt("search_key");
|
403 |
+
data = this.callbacks("sorter").call(this, this.query.text, data.slice(0, 1001), search_key);
|
404 |
+
return this.view.render(data.slice(0, this.get_opt('limit')));
|
405 |
+
};
|
406 |
+
|
407 |
+
Controller.prototype.look_up = function() {
|
408 |
+
var query, _callback;
|
409 |
+
if (!(query = this.catch_query())) {
|
410 |
+
return;
|
411 |
+
}
|
412 |
+
_callback = function(data) {
|
413 |
+
if (data && data.length > 0) {
|
414 |
+
return this.render_view(data);
|
415 |
+
} else {
|
416 |
+
return this.view.hide();
|
417 |
+
}
|
418 |
+
};
|
419 |
+
this.model.query(query.text, $.proxy(_callback, this));
|
420 |
+
return query;
|
421 |
+
};
|
422 |
+
|
423 |
+
return Controller;
|
424 |
+
|
425 |
+
})();
|
426 |
+
|
427 |
+
Model = (function() {
|
428 |
+
function Model(context) {
|
429 |
+
this.context = context;
|
430 |
+
this.at = this.context.at;
|
431 |
+
this.storage = this.context.$inputor;
|
432 |
+
}
|
433 |
+
|
434 |
+
Model.prototype.destroy = function() {
|
435 |
+
return this.storage.data(this.at, null);
|
436 |
+
};
|
437 |
+
|
438 |
+
Model.prototype.saved = function() {
|
439 |
+
return this.fetch() > 0;
|
440 |
+
};
|
441 |
+
|
442 |
+
Model.prototype.query = function(query, callback) {
|
443 |
+
var data, search_key, _remote_filter;
|
444 |
+
data = this.fetch();
|
445 |
+
search_key = this.context.get_opt("search_key");
|
446 |
+
data = this.context.callbacks('filter').call(this.context, query, data, search_key) || [];
|
447 |
+
_remote_filter = this.context.callbacks('remote_filter');
|
448 |
+
if (data.length > 0 || (!_remote_filter && data.length === 0)) {
|
449 |
+
return callback(data);
|
450 |
+
} else {
|
451 |
+
return _remote_filter.call(this.context, query, callback);
|
452 |
+
}
|
453 |
+
};
|
454 |
+
|
455 |
+
Model.prototype.fetch = function() {
|
456 |
+
return this.storage.data(this.at) || [];
|
457 |
+
};
|
458 |
+
|
459 |
+
Model.prototype.save = function(data) {
|
460 |
+
return this.storage.data(this.at, this.context.callbacks("before_save").call(this.context, data || []));
|
461 |
+
};
|
462 |
+
|
463 |
+
Model.prototype.load = function(data) {
|
464 |
+
if (!(this.saved() || !data)) {
|
465 |
+
return this._load(data);
|
466 |
+
}
|
467 |
+
};
|
468 |
+
|
469 |
+
Model.prototype.reload = function(data) {
|
470 |
+
return this._load(data);
|
471 |
+
};
|
472 |
+
|
473 |
+
Model.prototype._load = function(data) {
|
474 |
+
if (typeof data === "string") {
|
475 |
+
return $.ajax(data, {
|
476 |
+
dataType: "json"
|
477 |
+
}).done((function(_this) {
|
478 |
+
return function(data) {
|
479 |
+
return _this.save(data);
|
480 |
+
};
|
481 |
+
})(this));
|
482 |
+
} else {
|
483 |
+
return this.save(data);
|
484 |
+
}
|
485 |
+
};
|
486 |
+
|
487 |
+
return Model;
|
488 |
+
|
489 |
+
})();
|
490 |
+
|
491 |
+
View = (function() {
|
492 |
+
function View(context) {
|
493 |
+
this.context = context;
|
494 |
+
this.$el = $("<div class='atwho-view'><ul class='atwho-view-ul'></ul></div>");
|
495 |
+
this.timeout_id = null;
|
496 |
+
this.context.$el.append(this.$el);
|
497 |
+
this.bind_event();
|
498 |
+
}
|
499 |
+
|
500 |
+
View.prototype.init = function() {
|
501 |
+
var id;
|
502 |
+
id = this.context.get_opt("alias") || this.context.at.charCodeAt(0);
|
503 |
+
return this.$el.attr({
|
504 |
+
'id': "at-view-" + id
|
505 |
+
});
|
506 |
+
};
|
507 |
+
|
508 |
+
View.prototype.destroy = function() {
|
509 |
+
return this.$el.remove();
|
510 |
+
};
|
511 |
+
|
512 |
+
View.prototype.bind_event = function() {
|
513 |
+
var $menu;
|
514 |
+
$menu = this.$el.find('ul');
|
515 |
+
return $menu.on('mouseenter.atwho-view', 'li', function(e) {
|
516 |
+
$menu.find('.cur').removeClass('cur');
|
517 |
+
return $(e.currentTarget).addClass('cur');
|
518 |
+
}).on('click', (function(_this) {
|
519 |
+
return function(e) {
|
520 |
+
_this.choose(e);
|
521 |
+
return e.preventDefault();
|
522 |
+
};
|
523 |
+
})(this));
|
524 |
+
};
|
525 |
+
|
526 |
+
View.prototype.visible = function() {
|
527 |
+
return this.$el.is(":visible");
|
528 |
+
};
|
529 |
+
|
530 |
+
View.prototype.choose = function(e) {
|
531 |
+
var $li, content;
|
532 |
+
if (($li = this.$el.find(".cur")).length) {
|
533 |
+
content = this.context.insert_content_for($li);
|
534 |
+
this.context.insert(this.context.callbacks("before_insert").call(this.context, content, $li), $li);
|
535 |
+
this.context.trigger("inserted", [$li, e]);
|
536 |
+
this.hide(e);
|
537 |
+
}
|
538 |
+
if (this.context.get_opt("hide_without_suffix")) {
|
539 |
+
return this.stop_showing = true;
|
540 |
+
}
|
541 |
+
};
|
542 |
+
|
543 |
+
View.prototype.reposition = function(rect) {
|
544 |
+
var offset, _ref;
|
545 |
+
if (rect.bottom + this.$el.height() - $(window).scrollTop() > $(window).height()) {
|
546 |
+
rect.bottom = rect.top - this.$el.height();
|
547 |
+
}
|
548 |
+
offset = {
|
549 |
+
left: rect.left,
|
550 |
+
top: rect.bottom
|
551 |
+
};
|
552 |
+
if ((_ref = this.context.callbacks("before_reposition")) != null) {
|
553 |
+
_ref.call(this.context, offset);
|
554 |
+
}
|
555 |
+
this.$el.offset(offset);
|
556 |
+
return this.context.trigger("reposition", [offset]);
|
557 |
+
};
|
558 |
+
|
559 |
+
View.prototype.next = function() {
|
560 |
+
var cur, next;
|
561 |
+
cur = this.$el.find('.cur').removeClass('cur');
|
562 |
+
next = cur.next();
|
563 |
+
if (!next.length) {
|
564 |
+
next = this.$el.find('li:first');
|
565 |
+
}
|
566 |
+
return next.addClass('cur');
|
567 |
+
};
|
568 |
+
|
569 |
+
View.prototype.prev = function() {
|
570 |
+
var cur, prev;
|
571 |
+
cur = this.$el.find('.cur').removeClass('cur');
|
572 |
+
prev = cur.prev();
|
573 |
+
if (!prev.length) {
|
574 |
+
prev = this.$el.find('li:last');
|
575 |
+
}
|
576 |
+
return prev.addClass('cur');
|
577 |
+
};
|
578 |
+
|
579 |
+
View.prototype.show = function() {
|
580 |
+
var rect;
|
581 |
+
if (this.stop_showing) {
|
582 |
+
this.stop_showing = false;
|
583 |
+
return;
|
584 |
+
}
|
585 |
+
this.context.mark_range();
|
586 |
+
if (!this.visible()) {
|
587 |
+
this.$el.show();
|
588 |
+
this.context.trigger('shown');
|
589 |
+
}
|
590 |
+
if (rect = this.context.rect()) {
|
591 |
+
return this.reposition(rect);
|
592 |
+
}
|
593 |
+
};
|
594 |
+
|
595 |
+
View.prototype.hide = function(e, time) {
|
596 |
+
var callback;
|
597 |
+
if (!this.visible()) {
|
598 |
+
return;
|
599 |
+
}
|
600 |
+
if (isNaN(time)) {
|
601 |
+
this.context.reset_rect();
|
602 |
+
this.$el.hide();
|
603 |
+
return this.context.trigger('hidden', [e]);
|
604 |
+
} else {
|
605 |
+
callback = (function(_this) {
|
606 |
+
return function() {
|
607 |
+
return _this.hide();
|
608 |
+
};
|
609 |
+
})(this);
|
610 |
+
clearTimeout(this.timeout_id);
|
611 |
+
return this.timeout_id = setTimeout(callback, time);
|
612 |
+
}
|
613 |
+
};
|
614 |
+
|
615 |
+
View.prototype.render = function(list) {
|
616 |
+
var $li, $ul, item, li, tpl, _i, _len;
|
617 |
+
if (!($.isArray(list) && list.length > 0)) {
|
618 |
+
this.hide();
|
619 |
+
return;
|
620 |
+
}
|
621 |
+
this.$el.find('ul').empty();
|
622 |
+
$ul = this.$el.find('ul');
|
623 |
+
tpl = this.context.get_opt('tpl');
|
624 |
+
for (_i = 0, _len = list.length; _i < _len; _i++) {
|
625 |
+
item = list[_i];
|
626 |
+
item = $.extend({}, item, {
|
627 |
+
'atwho-at': this.context.at
|
628 |
+
});
|
629 |
+
li = this.context.callbacks("tpl_eval").call(this.context, tpl, item);
|
630 |
+
$li = $(this.context.callbacks("highlighter").call(this.context, li, this.context.query.text));
|
631 |
+
$li.data("item-data", item);
|
632 |
+
$ul.append($li);
|
633 |
+
}
|
634 |
+
this.show();
|
635 |
+
if (this.context.get_opt('highlight_first')) {
|
636 |
+
return $ul.find("li:first").addClass("cur");
|
637 |
+
}
|
638 |
+
};
|
639 |
+
|
640 |
+
return View;
|
641 |
+
|
642 |
+
})();
|
643 |
+
|
644 |
+
KEY_CODE = {
|
645 |
+
DOWN: 40,
|
646 |
+
UP: 38,
|
647 |
+
ESC: 27,
|
648 |
+
TAB: 9,
|
649 |
+
ENTER: 13,
|
650 |
+
CTRL: 17,
|
651 |
+
P: 80,
|
652 |
+
N: 78
|
653 |
+
};
|
654 |
+
|
655 |
+
DEFAULT_CALLBACKS = {
|
656 |
+
before_save: function(data) {
|
657 |
+
var item, _i, _len, _results;
|
658 |
+
if (!$.isArray(data)) {
|
659 |
+
return data;
|
660 |
+
}
|
661 |
+
_results = [];
|
662 |
+
for (_i = 0, _len = data.length; _i < _len; _i++) {
|
663 |
+
item = data[_i];
|
664 |
+
if ($.isPlainObject(item)) {
|
665 |
+
_results.push(item);
|
666 |
+
} else {
|
667 |
+
_results.push({
|
668 |
+
name: item
|
669 |
+
});
|
670 |
+
}
|
671 |
+
}
|
672 |
+
return _results;
|
673 |
+
},
|
674 |
+
matcher: function(flag, subtext, should_start_with_space) {
|
675 |
+
var match, regexp;
|
676 |
+
flag = flag.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
677 |
+
if (should_start_with_space) {
|
678 |
+
flag = '(?:^|\\s)' + flag;
|
679 |
+
}
|
680 |
+
regexp = new RegExp(flag + '([A-Za-z0-9_\+\-]*)$|' + flag + '([^\\x00-\\xff]*)$', 'gi');
|
681 |
+
match = regexp.exec(subtext);
|
682 |
+
if (match) {
|
683 |
+
return match[2] || match[1];
|
684 |
+
} else {
|
685 |
+
return null;
|
686 |
+
}
|
687 |
+
},
|
688 |
+
filter: function(query, data, search_key) {
|
689 |
+
var item, _i, _len, _results;
|
690 |
+
_results = [];
|
691 |
+
for (_i = 0, _len = data.length; _i < _len; _i++) {
|
692 |
+
item = data[_i];
|
693 |
+
if (~item[search_key].toLowerCase().indexOf(query.toLowerCase())) {
|
694 |
+
_results.push(item);
|
695 |
+
}
|
696 |
+
}
|
697 |
+
return _results;
|
698 |
+
},
|
699 |
+
remote_filter: null,
|
700 |
+
sorter: function(query, items, search_key) {
|
701 |
+
var item, _i, _len, _results;
|
702 |
+
if (!query) {
|
703 |
+
return items;
|
704 |
+
}
|
705 |
+
_results = [];
|
706 |
+
for (_i = 0, _len = items.length; _i < _len; _i++) {
|
707 |
+
item = items[_i];
|
708 |
+
item.atwho_order = item[search_key].toLowerCase().indexOf(query.toLowerCase());
|
709 |
+
if (item.atwho_order > -1) {
|
710 |
+
_results.push(item);
|
711 |
+
}
|
712 |
+
}
|
713 |
+
return _results.sort(function(a, b) {
|
714 |
+
return a.atwho_order - b.atwho_order;
|
715 |
+
});
|
716 |
+
},
|
717 |
+
tpl_eval: function(tpl, map) {
|
718 |
+
var error;
|
719 |
+
try {
|
720 |
+
return tpl.replace(/\$\{([^\}]*)\}/g, function(tag, key, pos) {
|
721 |
+
return map[key];
|
722 |
+
});
|
723 |
+
} catch (_error) {
|
724 |
+
error = _error;
|
725 |
+
return "";
|
726 |
+
}
|
727 |
+
},
|
728 |
+
highlighter: function(li, query) {
|
729 |
+
var regexp;
|
730 |
+
if (!query) {
|
731 |
+
return li;
|
732 |
+
}
|
733 |
+
regexp = new RegExp(">\\s*(\\w*?)(" + query.replace("+", "\\+") + ")(\\w*)\\s*<", 'ig');
|
734 |
+
return li.replace(regexp, function(str, $1, $2, $3) {
|
735 |
+
return '> ' + $1 + '<strong>' + $2 + '</strong>' + $3 + ' <';
|
736 |
+
});
|
737 |
+
},
|
738 |
+
before_insert: function(value, $li) {
|
739 |
+
return value;
|
740 |
+
},
|
741 |
+
inserting_wrapper: function($inputor, content, suffix) {
|
742 |
+
var new_suffix, wrapped_content;
|
743 |
+
new_suffix = suffix === "" ? suffix : suffix || " ";
|
744 |
+
if ($inputor.is('textarea, input')) {
|
745 |
+
return '' + content + new_suffix;
|
746 |
+
} else if ($inputor.attr('contentEditable') === 'true') {
|
747 |
+
new_suffix = suffix === "" ? suffix : suffix || " ";
|
748 |
+
if (/firefox/i.test(navigator.userAgent)) {
|
749 |
+
wrapped_content = "<span>" + content + new_suffix + "</span>";
|
750 |
+
} else {
|
751 |
+
suffix = "<span contenteditable='false'>" + new_suffix + "<span>";
|
752 |
+
wrapped_content = "<span contenteditable='false'>" + content + suffix + "</span>";
|
753 |
+
}
|
754 |
+
if (this.app.document.selection) {
|
755 |
+
wrapped_content = "<span contenteditable='true'>" + content + "</span>";
|
756 |
+
}
|
757 |
+
return wrapped_content;
|
758 |
+
}
|
759 |
+
}
|
760 |
+
};
|
761 |
+
|
762 |
+
Api = {
|
763 |
+
load: function(at, data) {
|
764 |
+
var c;
|
765 |
+
if (c = this.controller(at)) {
|
766 |
+
return c.model.load(data);
|
767 |
+
}
|
768 |
+
},
|
769 |
+
setIframe: function(iframe) {
|
770 |
+
this.setIframe(iframe);
|
771 |
+
return null;
|
772 |
+
},
|
773 |
+
run: function() {
|
774 |
+
return this.dispatch();
|
775 |
+
},
|
776 |
+
destroy: function() {
|
777 |
+
this.shutdown();
|
778 |
+
return this.$inputor.data('atwho', null);
|
779 |
+
}
|
780 |
+
};
|
781 |
+
|
782 |
+
$CONTAINER = $("<div id='atwho-container'></div>");
|
783 |
+
|
784 |
+
$.fn.atwho = function(method) {
|
785 |
+
var result, _args;
|
786 |
+
_args = arguments;
|
787 |
+
$('body').append($CONTAINER);
|
788 |
+
result = null;
|
789 |
+
this.filter('textarea, input, [contenteditable=true]').each(function() {
|
790 |
+
var $this, app;
|
791 |
+
if (!(app = ($this = $(this)).data("atwho"))) {
|
792 |
+
$this.data('atwho', (app = new App(this)));
|
793 |
+
}
|
794 |
+
if (typeof method === 'object' || !method) {
|
795 |
+
return app.reg(method.at, method);
|
796 |
+
} else if (Api[method] && app) {
|
797 |
+
return result = Api[method].apply(app, Array.prototype.slice.call(_args, 1));
|
798 |
+
} else {
|
799 |
+
return $.error("Method " + method + " does not exist on jQuery.caret");
|
800 |
+
}
|
801 |
+
});
|
802 |
+
return result || this;
|
803 |
+
};
|
804 |
+
|
805 |
+
$.fn.atwho["default"] = {
|
806 |
+
at: void 0,
|
807 |
+
alias: void 0,
|
808 |
+
data: null,
|
809 |
+
tpl: "<li data-value='${atwho-at}${name}'>${name}</li>",
|
810 |
+
insert_tpl: "<span id='${id}'>${atwho-data-value}</span>",
|
811 |
+
callbacks: DEFAULT_CALLBACKS,
|
812 |
+
search_key: "name",
|
813 |
+
suffix: void 0,
|
814 |
+
hide_without_suffix: false,
|
815 |
+
start_with_space: true,
|
816 |
+
highlight_first: true,
|
817 |
+
limit: 5,
|
818 |
+
max_len: 20,
|
819 |
+
display_timeout: 300,
|
820 |
+
delay: null
|
821 |
+
};
|
822 |
+
|
823 |
+
});
|
824 |
+
}).call(this);
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
(function(){!function(a){return"function"==typeof define&&define.amd?define(["jquery"],a):a(window.jQuery)}(function(a){var b,c,d,e,f,g,h,i,j=[].slice;d=function(){function b(b){this.current_flag=null,this.controllers={},this.alias_maps={},this.$inputor=a(b),this.iframe=null,this.setIframe(),this.listen()}return b.prototype.setIframe=function(a){return a?(this.window=a.contentWindow,this.document=a.contentDocument||this.window.document,this.iframe=a):(this.document=document,this.window=window,this.iframe=null)},b.prototype.controller=function(a){var b,c,d,e;if(this.alias_maps[a])c=this.controllers[this.alias_maps[a]];else{e=this.controllers;for(d in e)if(b=e[d],d===a){c=b;break}}return c?c:this.controllers[this.current_flag]},b.prototype.set_context_for=function(a){return this.current_flag=a,this},b.prototype.reg=function(a,b){var c,d;return c=(d=this.controllers)[a]||(d[a]=new e(this,a)),b.alias&&(this.alias_maps[b.alias]=a),c.init(b),this},b.prototype.listen=function(){return this.$inputor.on("keyup.atwhoInner",function(a){return function(b){return a.on_keyup(b)}}(this)).on("keydown.atwhoInner",function(a){return function(b){return a.on_keydown(b)}}(this)).on("scroll.atwhoInner",function(a){return function(b){var c;return null!=(c=a.controller())?c.view.hide(b):void 0}}(this)).on("blur.atwhoInner",function(a){return function(b){var c;return(c=a.controller())?c.view.hide(b,c.get_opt("display_timeout")):void 0}}(this)).on("click.atwhoInner",function(a){return function(b){var c;return null!=(c=a.controller())?c.view.hide(b):void 0}}(this))},b.prototype.shutdown=function(){var a,b,c;c=this.controllers;for(b in c)a=c[b],a.destroy(),delete this.controllers[b];return this.$inputor.off(".atwhoInner")},b.prototype.dispatch=function(){return a.map(this.controllers,function(a){return function(b){var c;return(c=b.get_opt("delay"))?(clearTimeout(a.delayedCallback),a.delayedCallback=setTimeout(function(){return b.look_up()?a.set_context_for(b.at):void 0},c)):b.look_up()?a.set_context_for(b.at):void 0}}(this))},b.prototype.on_keyup=function(b){var c;switch(b.keyCode){case g.ESC:b.preventDefault(),null!=(c=this.controller())&&c.view.hide();break;case g.DOWN:case g.UP:case g.CTRL:a.noop();break;case g.P:case g.N:b.ctrlKey||this.dispatch();break;default:this.dispatch()}},b.prototype.on_keydown=function(b){var c,d;if(c=null!=(d=this.controller())?d.view:void 0,c&&c.visible())switch(b.keyCode){case g.ESC:b.preventDefault(),c.hide(b);break;case g.UP:b.preventDefault(),c.prev();break;case g.DOWN:b.preventDefault(),c.next();break;case g.P:if(!b.ctrlKey)return;b.preventDefault(),c.prev();break;case g.N:if(!b.ctrlKey)return;b.preventDefault(),c.next();break;case g.TAB:case g.ENTER:if(!c.visible())return;b.preventDefault(),c.choose(b);break;default:a.noop()}},b}(),e=function(){function c(c,d){this.app=c,this.at=d,this.$inputor=this.app.$inputor,this.id=this.$inputor[0].id||this.uid(),this.setting=null,this.query=null,this.pos=0,this.cur_rect=null,this.range=null,b.append(this.$el=a("<div id='atwho-ground-"+this.id+"'></div>")),this.model=new h(this),this.view=new i(this)}return c.prototype.uid=function(){return(Math.random().toString(16)+"000000000").substr(2,8)+(new Date).getTime()},c.prototype.init=function(b){return this.setting=a.extend({},this.setting||a.fn.atwho["default"],b),this.view.init(),this.model.reload(this.setting.data)},c.prototype.destroy=function(){return this.trigger("beforeDestroy"),this.model.destroy(),this.view.destroy(),this.$el.remove()},c.prototype.call_default=function(){var b,c,d;d=arguments[0],b=2<=arguments.length?j.call(arguments,1):[];try{return f[d].apply(this,b)}catch(e){return c=e,a.error(""+c+" Or maybe At.js doesn't have function "+d)}},c.prototype.trigger=function(a,b){var c,d;return null==b&&(b=[]),b.push(this),c=this.get_opt("alias"),d=c?""+a+"-"+c+".atwho":""+a+".atwho",this.$inputor.trigger(d,b)},c.prototype.callbacks=function(a){return this.get_opt("callbacks")[a]||f[a]},c.prototype.get_opt=function(a){var b;try{return this.setting[a]}catch(c){return b=c,null}},c.prototype.content=function(){return this.$inputor.is("textarea, input")?this.$inputor.val():this.$inputor.text()},c.prototype.catch_query=function(){var a,b,c,d,e,f;return b=this.content(),a=this.$inputor.caret("pos",{iframe:this.app.iframe}),f=b.slice(0,a),d=this.callbacks("matcher").call(this,this.at,f,this.get_opt("start_with_space")),"string"==typeof d&&d.length<=this.get_opt("max_len",20)?(e=a-d.length,c=e+d.length,this.pos=e,d={text:d,head_pos:e,end_pos:c},this.trigger("matched",[this.at,d.text])):(d=null,this.view.hide()),this.query=d},c.prototype.rect=function(){var a,b;if(a=this.$inputor.caret("offset",this.pos-1,{iframe:this.app.iframe}))return"true"===this.$inputor.attr("contentEditable")&&(a=this.cur_rect||(this.cur_rect=a)||a),b=this.app.document.selection?0:2,{left:a.left,top:a.top,bottom:a.top+a.height+b}},c.prototype.reset_rect=function(){return"true"===this.$inputor.attr("contentEditable")?this.cur_rect=null:void 0},c.prototype.mark_range=function(){return"true"===this.$inputor.attr("contentEditable")&&(this.app.window.getSelection&&(this.range=this.app.window.getSelection().getRangeAt(0)),this.app.document.selection)?this.ie8_range=this.app.document.selection.createRange():void 0},c.prototype.insert_content_for=function(b){var c,d,e;return d=b.data("value"),e=this.get_opt("insert_tpl"),this.$inputor.is("textarea, input")||!e?d:(c=a.extend({},b.data("item-data"),{"atwho-data-value":d,"atwho-at":this.at}),this.callbacks("tpl_eval").call(this,e,c))},c.prototype.insert=function(b){var c,d,e,f,g,h,i,j,k;return c=this.$inputor,k=this.callbacks("inserting_wrapper").call(this,c,b,this.get_opt("suffix")),c.is("textarea, input")?(h=c.val(),i=h.slice(0,Math.max(this.query.head_pos-this.at.length,0)),j=""+i+k+h.slice(this.query.end_pos||0),c.val(j),c.caret("pos",i.length+k.length,{iframe:this.app.iframe})):(f=this.range)?(e=f.startOffset-(this.query.end_pos-this.query.head_pos)-this.at.length,f.setStart(f.endContainer,Math.max(e,0)),f.setEnd(f.endContainer,f.endOffset),f.deleteContents(),d=a(k,this.app.document)[0],f.insertNode(d),f.setEndAfter(d),f.collapse(!1),g=this.app.window.getSelection(),g.removeAllRanges(),g.addRange(f)):(f=this.ie8_range)&&(f.moveStart("character",this.query.end_pos-this.query.head_pos-this.at.length),f.pasteHTML(k),f.collapse(!1),f.select()),c.is(":focus")||c.focus(),c.change()},c.prototype.render_view=function(a){var b;return b=this.get_opt("search_key"),a=this.callbacks("sorter").call(this,this.query.text,a.slice(0,1001),b),this.view.render(a.slice(0,this.get_opt("limit")))},c.prototype.look_up=function(){var b,c;if(b=this.catch_query())return c=function(a){return a&&a.length>0?this.render_view(a):this.view.hide()},this.model.query(b.text,a.proxy(c,this)),b},c}(),h=function(){function b(a){this.context=a,this.at=this.context.at,this.storage=this.context.$inputor}return b.prototype.destroy=function(){return this.storage.data(this.at,null)},b.prototype.saved=function(){return this.fetch()>0},b.prototype.query=function(a,b){var c,d,e;return c=this.fetch(),d=this.context.get_opt("search_key"),c=this.context.callbacks("filter").call(this.context,a,c,d)||[],e=this.context.callbacks("remote_filter"),c.length>0||!e&&0===c.length?b(c):e.call(this.context,a,b)},b.prototype.fetch=function(){return this.storage.data(this.at)||[]},b.prototype.save=function(a){return this.storage.data(this.at,this.context.callbacks("before_save").call(this.context,a||[]))},b.prototype.load=function(a){return!this.saved()&&a?this._load(a):void 0},b.prototype.reload=function(a){return this._load(a)},b.prototype._load=function(b){return"string"==typeof b?a.ajax(b,{dataType:"json"}).done(function(a){return function(b){return a.save(b)}}(this)):this.save(b)},b}(),i=function(){function b(b){this.context=b,this.$el=a("<div class='atwho-view'><ul class='atwho-view-ul'></ul></div>"),this.timeout_id=null,this.context.$el.append(this.$el),this.bind_event()}return b.prototype.init=function(){var a;return a=this.context.get_opt("alias")||this.context.at.charCodeAt(0),this.$el.attr({id:"at-view-"+a})},b.prototype.destroy=function(){return this.$el.remove()},b.prototype.bind_event=function(){var b;return b=this.$el.find("ul"),b.on("mouseenter.atwho-view","li",function(c){return b.find(".cur").removeClass("cur"),a(c.currentTarget).addClass("cur")}).on("click",function(a){return function(b){return a.choose(b),b.preventDefault()}}(this))},b.prototype.visible=function(){return this.$el.is(":visible")},b.prototype.choose=function(a){var b,c;return(b=this.$el.find(".cur")).length&&(c=this.context.insert_content_for(b),this.context.insert(this.context.callbacks("before_insert").call(this.context,c,b),b),this.context.trigger("inserted",[b,a]),this.hide(a)),this.context.get_opt("hide_without_suffix")?this.stop_showing=!0:void 0},b.prototype.reposition=function(b){var c,d;return b.bottom+this.$el.height()-a(window).scrollTop()>a(window).height()&&(b.bottom=b.top-this.$el.height()),c={left:b.left,top:b.bottom},null!=(d=this.context.callbacks("before_reposition"))&&d.call(this.context,c),this.$el.offset(c),this.context.trigger("reposition",[c])},b.prototype.next=function(){var a,b;return a=this.$el.find(".cur").removeClass("cur"),b=a.next(),b.length||(b=this.$el.find("li:first")),b.addClass("cur")},b.prototype.prev=function(){var a,b;return a=this.$el.find(".cur").removeClass("cur"),b=a.prev(),b.length||(b=this.$el.find("li:last")),b.addClass("cur")},b.prototype.show=function(){var a;return this.stop_showing?void(this.stop_showing=!1):(this.context.mark_range(),this.visible()||(this.$el.show(),this.context.trigger("shown")),(a=this.context.rect())?this.reposition(a):void 0)},b.prototype.hide=function(a,b){var c;if(this.visible())return isNaN(b)?(this.context.reset_rect(),this.$el.hide(),this.context.trigger("hidden",[a])):(c=function(a){return function(){return a.hide()}}(this),clearTimeout(this.timeout_id),this.timeout_id=setTimeout(c,b))},b.prototype.render=function(b){var c,d,e,f,g,h,i;if(!(a.isArray(b)&&b.length>0))return void this.hide();for(this.$el.find("ul").empty(),d=this.$el.find("ul"),g=this.context.get_opt("tpl"),h=0,i=b.length;i>h;h++)e=b[h],e=a.extend({},e,{"atwho-at":this.context.at}),f=this.context.callbacks("tpl_eval").call(this.context,g,e),c=a(this.context.callbacks("highlighter").call(this.context,f,this.context.query.text)),c.data("item-data",e),d.append(c);return this.show(),this.context.get_opt("highlight_first")?d.find("li:first").addClass("cur"):void 0},b}(),g={DOWN:40,UP:38,ESC:27,TAB:9,ENTER:13,CTRL:17,P:80,N:78},f={before_save:function(b){var c,d,e,f;if(!a.isArray(b))return b;for(f=[],d=0,e=b.length;e>d;d++)c=b[d],f.push(a.isPlainObject(c)?c:{name:c});return f},matcher:function(a,b,c){var d,e;return a=a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),c&&(a="(?:^|\\s)"+a),e=new RegExp(a+"([A-Za-z0-9_+-]*)$|"+a+"([^\\x00-\\xff]*)$","gi"),d=e.exec(b),d?d[2]||d[1]:null},filter:function(a,b,c){var d,e,f,g;for(g=[],e=0,f=b.length;f>e;e++)d=b[e],~d[c].toLowerCase().indexOf(a.toLowerCase())&&g.push(d);return g},remote_filter:null,sorter:function(a,b,c){var d,e,f,g;if(!a)return b;for(g=[],e=0,f=b.length;f>e;e++)d=b[e],d.atwho_order=d[c].toLowerCase().indexOf(a.toLowerCase()),d.atwho_order>-1&&g.push(d);return g.sort(function(a,b){return a.atwho_order-b.atwho_order})},tpl_eval:function(a,b){var c;try{return a.replace(/\$\{([^\}]*)\}/g,function(a,c){return b[c]})}catch(d){return c=d,""}},highlighter:function(a,b){var c;return b?(c=new RegExp(">\\s*(\\w*?)("+b.replace("+","\\+")+")(\\w*)\\s*<","ig"),a.replace(c,function(a,b,c,d){return"> "+b+"<strong>"+c+"</strong>"+d+" <"})):a},before_insert:function(a){return a},inserting_wrapper:function(a,b,c){var d,e;return d=""===c?c:c||" ",a.is("textarea, input")?""+b+d:"true"===a.attr("contentEditable")?(d=""===c?c:c||" ",/firefox/i.test(navigator.userAgent)?e="<span>"+b+d+"</span>":(c="<span contenteditable='false'>"+d+"<span>",e="<span contenteditable='false'>"+b+c+"</span>"),this.app.document.selection&&(e="<span contenteditable='true'>"+b+"</span>"),e):void 0}},c={load:function(a,b){var c;return(c=this.controller(a))?c.model.load(b):void 0},setIframe:function(a){return this.setIframe(a),null},run:function(){return this.dispatch()},destroy:function(){return this.shutdown(),this.$inputor.data("atwho",null)}},b=a("<div id='atwho-container'></div>"),a.fn.atwho=function(e){var f,g;return g=arguments,a("body").append(b),f=null,this.filter("textarea, input, [contenteditable=true]").each(function(){var b,h;return(h=(b=a(this)).data("atwho"))||b.data("atwho",h=new d(this)),"object"!=typeof e&&e?c[e]&&h?f=c[e].apply(h,Array.prototype.slice.call(g,1)):a.error("Method "+e+" does not exist on jQuery.caret"):h.reg(e.at,e)}),f||this},a.fn.atwho["default"]={at:void 0,alias:void 0,data:null,tpl:"<li data-value='${atwho-at}${name}'>${name}</li>",insert_tpl:"<span id='${id}'>${atwho-data-value}</span>",callbacks:f,search_key:"name",suffix:void 0,hide_without_suffix:!1,start_with_space:!0,highlight_first:!0,limit:5,max_len:20,display_timeout:300,delay:null}})}).call(this);
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright (c) 2013 chord.luo@gmail.com
|
2 |
+
|
3 |
+
Permission is hereby granted, free of charge, to any person
|
4 |
+
obtaining a copy of this software and associated documentation
|
5 |
+
files (the "Software"), to deal in the Software without
|
6 |
+
restriction, including without limitation the rights to use,
|
7 |
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8 |
+
copies of the Software, and to permit persons to whom the
|
9 |
+
Software is furnished to do so, subject to the following
|
10 |
+
conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be
|
13 |
+
included in all copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17 |
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18 |
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19 |
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20 |
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22 |
+
OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,366 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
Implement Github like autocomplete mentions
|
3 |
+
http://ichord.github.com/At.js
|
4 |
+
|
5 |
+
Copyright (c) 2013 chord.luo@gmail.com
|
6 |
+
Licensed under the MIT license.
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
/*
|
11 |
+
本插件操作 textarea 或者 input 内的插入符
|
12 |
+
只实现了获得插入符在文本框中的位置,我设置
|
13 |
+
插入符的位置.
|
14 |
+
*/
|
15 |
+
|
16 |
+
|
17 |
+
(function() {
|
18 |
+
(function(factory) {
|
19 |
+
if (typeof define === 'function' && define.amd) {
|
20 |
+
return define(['jquery'], factory);
|
21 |
+
} else {
|
22 |
+
return factory(window.jQuery);
|
23 |
+
}
|
24 |
+
})(function($) {
|
25 |
+
"use strict";
|
26 |
+
var EditableCaret, InputCaret, Mirror, Utils, discoveryIframeOf, methods, oDocument, oFrame, oWindow, pluginName, setContextBy;
|
27 |
+
pluginName = 'caret';
|
28 |
+
EditableCaret = (function() {
|
29 |
+
function EditableCaret($inputor) {
|
30 |
+
this.$inputor = $inputor;
|
31 |
+
this.domInputor = this.$inputor[0];
|
32 |
+
}
|
33 |
+
|
34 |
+
EditableCaret.prototype.setPos = function(pos) {
|
35 |
+
return this.domInputor;
|
36 |
+
};
|
37 |
+
|
38 |
+
EditableCaret.prototype.getIEPosition = function() {
|
39 |
+
return $.noop();
|
40 |
+
};
|
41 |
+
|
42 |
+
EditableCaret.prototype.getPosition = function() {
|
43 |
+
return $.noop();
|
44 |
+
};
|
45 |
+
|
46 |
+
EditableCaret.prototype.getOldIEPos = function() {
|
47 |
+
var preCaretTextRange, textRange;
|
48 |
+
textRange = oDocument.selection.createRange();
|
49 |
+
preCaretTextRange = oDocument.body.createTextRange();
|
50 |
+
preCaretTextRange.moveToElementText(this.domInputor);
|
51 |
+
preCaretTextRange.setEndPoint("EndToEnd", textRange);
|
52 |
+
return preCaretTextRange.text.length;
|
53 |
+
};
|
54 |
+
|
55 |
+
EditableCaret.prototype.getPos = function() {
|
56 |
+
var clonedRange, pos, range;
|
57 |
+
if (range = this.range()) {
|
58 |
+
clonedRange = range.cloneRange();
|
59 |
+
clonedRange.selectNodeContents(this.domInputor);
|
60 |
+
clonedRange.setEnd(range.endContainer, range.endOffset);
|
61 |
+
pos = clonedRange.toString().length;
|
62 |
+
clonedRange.detach();
|
63 |
+
return pos;
|
64 |
+
} else if (oDocument.selection) {
|
65 |
+
return this.getOldIEPos();
|
66 |
+
}
|
67 |
+
};
|
68 |
+
|
69 |
+
EditableCaret.prototype.getOldIEOffset = function() {
|
70 |
+
var range, rect;
|
71 |
+
range = oDocument.selection.createRange().duplicate();
|
72 |
+
range.moveStart("character", -1);
|
73 |
+
rect = range.getBoundingClientRect();
|
74 |
+
return {
|
75 |
+
height: rect.bottom - rect.top,
|
76 |
+
left: rect.left,
|
77 |
+
top: rect.top
|
78 |
+
};
|
79 |
+
};
|
80 |
+
|
81 |
+
EditableCaret.prototype.getOffset = function(pos) {
|
82 |
+
var clonedRange, offset, range, rect;
|
83 |
+
if (oWindow.getSelection && (range = this.range())) {
|
84 |
+
if (range.endOffset - 1 < 0) {
|
85 |
+
return null;
|
86 |
+
}
|
87 |
+
clonedRange = range.cloneRange();
|
88 |
+
clonedRange.setStart(range.endContainer, range.endOffset - 1);
|
89 |
+
clonedRange.setEnd(range.endContainer, range.endOffset);
|
90 |
+
rect = clonedRange.getBoundingClientRect();
|
91 |
+
offset = {
|
92 |
+
height: rect.height,
|
93 |
+
left: rect.left + rect.width,
|
94 |
+
top: rect.top
|
95 |
+
};
|
96 |
+
clonedRange.detach();
|
97 |
+
} else if (oDocument.selection) {
|
98 |
+
offset = this.getOldIEOffset();
|
99 |
+
}
|
100 |
+
if (offset && !oFrame) {
|
101 |
+
offset.top += $(oWindow).scrollTop();
|
102 |
+
offset.left += $(oWindow).scrollLeft();
|
103 |
+
}
|
104 |
+
return offset;
|
105 |
+
};
|
106 |
+
|
107 |
+
EditableCaret.prototype.range = function() {
|
108 |
+
var sel;
|
109 |
+
if (!oWindow.getSelection) {
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
sel = oWindow.getSelection();
|
113 |
+
if (sel.rangeCount > 0) {
|
114 |
+
return sel.getRangeAt(0);
|
115 |
+
} else {
|
116 |
+
return null;
|
117 |
+
}
|
118 |
+
};
|
119 |
+
|
120 |
+
return EditableCaret;
|
121 |
+
|
122 |
+
})();
|
123 |
+
InputCaret = (function() {
|
124 |
+
function InputCaret($inputor) {
|
125 |
+
this.$inputor = $inputor;
|
126 |
+
this.domInputor = this.$inputor[0];
|
127 |
+
}
|
128 |
+
|
129 |
+
InputCaret.prototype.getIEPos = function() {
|
130 |
+
var endRange, inputor, len, normalizedValue, pos, range, textInputRange;
|
131 |
+
inputor = this.domInputor;
|
132 |
+
range = oDocument.selection.createRange();
|
133 |
+
pos = 0;
|
134 |
+
if (range && range.parentElement() === inputor) {
|
135 |
+
normalizedValue = inputor.value.replace(/\r\n/g, "\n");
|
136 |
+
len = normalizedValue.length;
|
137 |
+
textInputRange = inputor.createTextRange();
|
138 |
+
textInputRange.moveToBookmark(range.getBookmark());
|
139 |
+
endRange = inputor.createTextRange();
|
140 |
+
endRange.collapse(false);
|
141 |
+
if (textInputRange.compareEndPoints("StartToEnd", endRange) > -1) {
|
142 |
+
pos = len;
|
143 |
+
} else {
|
144 |
+
pos = -textInputRange.moveStart("character", -len);
|
145 |
+
}
|
146 |
+
}
|
147 |
+
return pos;
|
148 |
+
};
|
149 |
+
|
150 |
+
InputCaret.prototype.getPos = function() {
|
151 |
+
if (oDocument.selection) {
|
152 |
+
return this.getIEPos();
|
153 |
+
} else {
|
154 |
+
return this.domInputor.selectionStart;
|
155 |
+
}
|
156 |
+
};
|
157 |
+
|
158 |
+
InputCaret.prototype.setPos = function(pos) {
|
159 |
+
var inputor, range;
|
160 |
+
inputor = this.domInputor;
|
161 |
+
if (oDocument.selection) {
|
162 |
+
range = inputor.createTextRange();
|
163 |
+
range.move("character", pos);
|
164 |
+
range.select();
|
165 |
+
} else if (inputor.setSelectionRange) {
|
166 |
+
inputor.setSelectionRange(pos, pos);
|
167 |
+
}
|
168 |
+
return inputor;
|
169 |
+
};
|
170 |
+
|
171 |
+
InputCaret.prototype.getIEOffset = function(pos) {
|
172 |
+
var h, textRange, x, y;
|
173 |
+
textRange = this.domInputor.createTextRange();
|
174 |
+
pos || (pos = this.getPos());
|
175 |
+
textRange.move('character', pos);
|
176 |
+
x = textRange.boundingLeft;
|
177 |
+
y = textRange.boundingTop;
|
178 |
+
h = textRange.boundingHeight;
|
179 |
+
return {
|
180 |
+
left: x,
|
181 |
+
top: y,
|
182 |
+
height: h
|
183 |
+
};
|
184 |
+
};
|
185 |
+
|
186 |
+
InputCaret.prototype.getOffset = function(pos) {
|
187 |
+
var $inputor, offset, position;
|
188 |
+
$inputor = this.$inputor;
|
189 |
+
if (oDocument.selection) {
|
190 |
+
offset = this.getIEOffset(pos);
|
191 |
+
offset.top += $(oWindow).scrollTop() + $inputor.scrollTop();
|
192 |
+
offset.left += $(oWindow).scrollLeft() + $inputor.scrollLeft();
|
193 |
+
return offset;
|
194 |
+
} else {
|
195 |
+
offset = $inputor.offset();
|
196 |
+
position = this.getPosition(pos);
|
197 |
+
return offset = {
|
198 |
+
left: offset.left + position.left - $inputor.scrollLeft(),
|
199 |
+
top: offset.top + position.top - $inputor.scrollTop(),
|
200 |
+
height: position.height
|
201 |
+
};
|
202 |
+
}
|
203 |
+
};
|
204 |
+
|
205 |
+
InputCaret.prototype.getPosition = function(pos) {
|
206 |
+
var $inputor, at_rect, end_range, format, html, mirror, start_range;
|
207 |
+
$inputor = this.$inputor;
|
208 |
+
format = function(value) {
|
209 |
+
return value.replace(/</g, '<').replace(/>/g, '>').replace(/`/g, '`').replace(/"/g, '"').replace(/\r\n|\r|\n/g, "<br />");
|
210 |
+
};
|
211 |
+
if (pos === void 0) {
|
212 |
+
pos = this.getPos();
|
213 |
+
}
|
214 |
+
start_range = $inputor.val().slice(0, pos);
|
215 |
+
end_range = $inputor.val().slice(pos);
|
216 |
+
html = "<span style='position: relative; display: inline;'>" + format(start_range) + "</span>";
|
217 |
+
html += "<span id='caret' style='position: relative; display: inline;'>|</span>";
|
218 |
+
html += "<span style='position: relative; display: inline;'>" + format(end_range) + "</span>";
|
219 |
+
mirror = new Mirror($inputor);
|
220 |
+
return at_rect = mirror.create(html).rect();
|
221 |
+
};
|
222 |
+
|
223 |
+
InputCaret.prototype.getIEPosition = function(pos) {
|
224 |
+
var h, inputorOffset, offset, x, y;
|
225 |
+
offset = this.getIEOffset(pos);
|
226 |
+
inputorOffset = this.$inputor.offset();
|
227 |
+
x = offset.left - inputorOffset.left;
|
228 |
+
y = offset.top - inputorOffset.top;
|
229 |
+
h = offset.height;
|
230 |
+
return {
|
231 |
+
left: x,
|
232 |
+
top: y,
|
233 |
+
height: h
|
234 |
+
};
|
235 |
+
};
|
236 |
+
|
237 |
+
return InputCaret;
|
238 |
+
|
239 |
+
})();
|
240 |
+
Mirror = (function() {
|
241 |
+
Mirror.prototype.css_attr = ["borderBottomWidth", "borderLeftWidth", "borderRightWidth", "borderTopStyle", "borderRightStyle", "borderBottomStyle", "borderLeftStyle", "borderTopWidth", "boxSizing", "fontFamily", "fontSize", "fontWeight", "height", "letterSpacing", "lineHeight", "marginBottom", "marginLeft", "marginRight", "marginTop", "outlineWidth", "overflow", "overflowX", "overflowY", "paddingBottom", "paddingLeft", "paddingRight", "paddingTop", "textAlign", "textOverflow", "textTransform", "whiteSpace", "wordBreak", "wordWrap"];
|
242 |
+
|
243 |
+
function Mirror($inputor) {
|
244 |
+
this.$inputor = $inputor;
|
245 |
+
}
|
246 |
+
|
247 |
+
Mirror.prototype.mirrorCss = function() {
|
248 |
+
var css,
|
249 |
+
_this = this;
|
250 |
+
css = {
|
251 |
+
position: 'absolute',
|
252 |
+
left: -9999,
|
253 |
+
top: 0,
|
254 |
+
zIndex: -20000
|
255 |
+
};
|
256 |
+
if (this.$inputor.prop('tagName') === 'TEXTAREA') {
|
257 |
+
this.css_attr.push('width');
|
258 |
+
}
|
259 |
+
$.each(this.css_attr, function(i, p) {
|
260 |
+
return css[p] = _this.$inputor.css(p);
|
261 |
+
});
|
262 |
+
return css;
|
263 |
+
};
|
264 |
+
|
265 |
+
Mirror.prototype.create = function(html) {
|
266 |
+
this.$mirror = $('<div></div>');
|
267 |
+
this.$mirror.css(this.mirrorCss());
|
268 |
+
this.$mirror.html(html);
|
269 |
+
this.$inputor.after(this.$mirror);
|
270 |
+
return this;
|
271 |
+
};
|
272 |
+
|
273 |
+
Mirror.prototype.rect = function() {
|
274 |
+
var $flag, pos, rect;
|
275 |
+
$flag = this.$mirror.find("#caret");
|
276 |
+
pos = $flag.position();
|
277 |
+
rect = {
|
278 |
+
left: pos.left,
|
279 |
+
top: pos.top,
|
280 |
+
height: $flag.height()
|
281 |
+
};
|
282 |
+
this.$mirror.remove();
|
283 |
+
return rect;
|
284 |
+
};
|
285 |
+
|
286 |
+
return Mirror;
|
287 |
+
|
288 |
+
})();
|
289 |
+
Utils = {
|
290 |
+
contentEditable: function($inputor) {
|
291 |
+
return !!($inputor[0].contentEditable && $inputor[0].contentEditable === 'true');
|
292 |
+
}
|
293 |
+
};
|
294 |
+
methods = {
|
295 |
+
pos: function(pos) {
|
296 |
+
if (pos || pos === 0) {
|
297 |
+
return this.setPos(pos);
|
298 |
+
} else {
|
299 |
+
return this.getPos();
|
300 |
+
}
|
301 |
+
},
|
302 |
+
position: function(pos) {
|
303 |
+
if (oDocument.selection) {
|
304 |
+
return this.getIEPosition(pos);
|
305 |
+
} else {
|
306 |
+
return this.getPosition(pos);
|
307 |
+
}
|
308 |
+
},
|
309 |
+
offset: function(pos) {
|
310 |
+
var iOffset, offset;
|
311 |
+
offset = this.getOffset(pos);
|
312 |
+
if (oFrame) {
|
313 |
+
iOffset = $(oFrame).offset();
|
314 |
+
offset.top += iOffset.top;
|
315 |
+
offset.left += iOffset.left;
|
316 |
+
}
|
317 |
+
return offset;
|
318 |
+
}
|
319 |
+
};
|
320 |
+
oDocument = null;
|
321 |
+
oWindow = null;
|
322 |
+
oFrame = null;
|
323 |
+
setContextBy = function(settings) {
|
324 |
+
var iframe;
|
325 |
+
if (iframe = settings != null ? settings.iframe : void 0) {
|
326 |
+
oFrame = iframe;
|
327 |
+
oWindow = iframe.contentWindow;
|
328 |
+
return oDocument = iframe.contentDocument || oWindow.document;
|
329 |
+
} else {
|
330 |
+
oFrame = void 0;
|
331 |
+
oWindow = window;
|
332 |
+
return oDocument = document;
|
333 |
+
}
|
334 |
+
};
|
335 |
+
discoveryIframeOf = function($dom) {
|
336 |
+
var error;
|
337 |
+
oDocument = $dom[0].ownerDocument;
|
338 |
+
oWindow = oDocument.defaultView || oDocument.parentWindow;
|
339 |
+
try {
|
340 |
+
return oFrame = oWindow.frameElement;
|
341 |
+
} catch (_error) {
|
342 |
+
error = _error;
|
343 |
+
}
|
344 |
+
};
|
345 |
+
$.fn.caret = function(method, value, settings) {
|
346 |
+
var caret;
|
347 |
+
if (methods[method]) {
|
348 |
+
if ($.isPlainObject(value)) {
|
349 |
+
setContextBy(value);
|
350 |
+
value = void 0;
|
351 |
+
} else {
|
352 |
+
setContextBy(settings);
|
353 |
+
}
|
354 |
+
caret = Utils.contentEditable(this) ? new EditableCaret(this) : new InputCaret(this);
|
355 |
+
return methods[method].apply(caret, [value]);
|
356 |
+
} else {
|
357 |
+
return $.error("Method " + method + " does not exist on jQuery.caret");
|
358 |
+
}
|
359 |
+
};
|
360 |
+
$.fn.caret.EditableCaret = EditableCaret;
|
361 |
+
$.fn.caret.InputCaret = InputCaret;
|
362 |
+
$.fn.caret.Utils = Utils;
|
363 |
+
return $.fn.caret.apis = methods;
|
364 |
+
});
|
365 |
+
|
366 |
+
}).call(this);
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
(function(){!function(a){return"function"==typeof define&&define.amd?define(["jquery"],a):a(window.jQuery)}(function(a){"use strict";var b,c,d,e,f,g,h,i,j,k,l;return k="caret",b=function(){function b(a){this.$inputor=a,this.domInputor=this.$inputor[0]}return b.prototype.setPos=function(){return this.domInputor},b.prototype.getIEPosition=function(){return a.noop()},b.prototype.getPosition=function(){return a.noop()},b.prototype.getOldIEPos=function(){var a,b;return b=h.selection.createRange(),a=h.body.createTextRange(),a.moveToElementText(this.domInputor),a.setEndPoint("EndToEnd",b),a.text.length},b.prototype.getPos=function(){var a,b,c;return(c=this.range())?(a=c.cloneRange(),a.selectNodeContents(this.domInputor),a.setEnd(c.endContainer,c.endOffset),b=a.toString().length,a.detach(),b):h.selection?this.getOldIEPos():void 0},b.prototype.getOldIEOffset=function(){var a,b;return a=h.selection.createRange().duplicate(),a.moveStart("character",-1),b=a.getBoundingClientRect(),{height:b.bottom-b.top,left:b.left,top:b.top}},b.prototype.getOffset=function(){var b,c,d,e;if(j.getSelection&&(d=this.range())){if(d.endOffset-1<0)return null;b=d.cloneRange(),b.setStart(d.endContainer,d.endOffset-1),b.setEnd(d.endContainer,d.endOffset),e=b.getBoundingClientRect(),c={height:e.height,left:e.left+e.width,top:e.top},b.detach()}else h.selection&&(c=this.getOldIEOffset());return c&&!i&&(c.top+=a(j).scrollTop(),c.left+=a(j).scrollLeft()),c},b.prototype.range=function(){var a;if(j.getSelection)return a=j.getSelection(),a.rangeCount>0?a.getRangeAt(0):null},b}(),c=function(){function b(a){this.$inputor=a,this.domInputor=this.$inputor[0]}return b.prototype.getIEPos=function(){var a,b,c,d,e,f,g;return b=this.domInputor,f=h.selection.createRange(),e=0,f&&f.parentElement()===b&&(d=b.value.replace(/\r\n/g,"\n"),c=d.length,g=b.createTextRange(),g.moveToBookmark(f.getBookmark()),a=b.createTextRange(),a.collapse(!1),e=g.compareEndPoints("StartToEnd",a)>-1?c:-g.moveStart("character",-c)),e},b.prototype.getPos=function(){return h.selection?this.getIEPos():this.domInputor.selectionStart},b.prototype.setPos=function(a){var b,c;return b=this.domInputor,h.selection?(c=b.createTextRange(),c.move("character",a),c.select()):b.setSelectionRange&&b.setSelectionRange(a,a),b},b.prototype.getIEOffset=function(a){var b,c,d,e;return c=this.domInputor.createTextRange(),a||(a=this.getPos()),c.move("character",a),d=c.boundingLeft,e=c.boundingTop,b=c.boundingHeight,{left:d,top:e,height:b}},b.prototype.getOffset=function(b){var c,d,e;return c=this.$inputor,h.selection?(d=this.getIEOffset(b),d.top+=a(j).scrollTop()+c.scrollTop(),d.left+=a(j).scrollLeft()+c.scrollLeft(),d):(d=c.offset(),e=this.getPosition(b),d={left:d.left+e.left-c.scrollLeft(),top:d.top+e.top-c.scrollTop(),height:e.height})},b.prototype.getPosition=function(a){var b,c,e,f,g,h,i;return b=this.$inputor,f=function(a){return a.replace(/</g,"<").replace(/>/g,">").replace(/`/g,"`").replace(/"/g,""").replace(/\r\n|\r|\n/g,"<br />")},void 0===a&&(a=this.getPos()),i=b.val().slice(0,a),e=b.val().slice(a),g="<span style='position: relative; display: inline;'>"+f(i)+"</span>",g+="<span id='caret' style='position: relative; display: inline;'>|</span>",g+="<span style='position: relative; display: inline;'>"+f(e)+"</span>",h=new d(b),c=h.create(g).rect()},b.prototype.getIEPosition=function(a){var b,c,d,e,f;return d=this.getIEOffset(a),c=this.$inputor.offset(),e=d.left-c.left,f=d.top-c.top,b=d.height,{left:e,top:f,height:b}},b}(),d=function(){function b(a){this.$inputor=a}return b.prototype.css_attr=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","boxSizing","fontFamily","fontSize","fontWeight","height","letterSpacing","lineHeight","marginBottom","marginLeft","marginRight","marginTop","outlineWidth","overflow","overflowX","overflowY","paddingBottom","paddingLeft","paddingRight","paddingTop","textAlign","textOverflow","textTransform","whiteSpace","wordBreak","wordWrap"],b.prototype.mirrorCss=function(){var b,c=this;return b={position:"absolute",left:-9999,top:0,zIndex:-2e4},"TEXTAREA"===this.$inputor.prop("tagName")&&this.css_attr.push("width"),a.each(this.css_attr,function(a,d){return b[d]=c.$inputor.css(d)}),b},b.prototype.create=function(b){return this.$mirror=a("<div></div>"),this.$mirror.css(this.mirrorCss()),this.$mirror.html(b),this.$inputor.after(this.$mirror),this},b.prototype.rect=function(){var a,b,c;return a=this.$mirror.find("#caret"),b=a.position(),c={left:b.left,top:b.top,height:a.height()},this.$mirror.remove(),c},b}(),e={contentEditable:function(a){return!(!a[0].contentEditable||"true"!==a[0].contentEditable)}},g={pos:function(a){return a||0===a?this.setPos(a):this.getPos()},position:function(a){return h.selection?this.getIEPosition(a):this.getPosition(a)},offset:function(b){var c,d;return d=this.getOffset(b),i&&(c=a(i).offset(),d.top+=c.top,d.left+=c.left),d}},h=null,j=null,i=null,l=function(a){var b;return(b=null!=a?a.iframe:void 0)?(i=b,j=b.contentWindow,h=b.contentDocument||j.document):(i=void 0,j=window,h=document)},f=function(a){var b;h=a[0].ownerDocument,j=h.defaultView||h.parentWindow;try{return i=j.frameElement}catch(c){b=c}},a.fn.caret=function(d,f,h){var i;return g[d]?(a.isPlainObject(f)?(l(f),f=void 0):l(h),i=e.contentEditable(this)?new b(this):new c(this),g[d].apply(i,[f])):a.error("Method "+d+" does not exist on jQuery.caret")},a.fn.caret.EditableCaret=b,a.fn.caret.InputCaret=c,a.fn.caret.Utils=e,a.fn.caret.apis=g})}).call(this);
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright (c) 2013 chord.luo@gmail.com
|
2 |
+
|
3 |
+
Permission is hereby granted, free of charge, to any person
|
4 |
+
obtaining a copy of this software and associated documentation
|
5 |
+
files (the "Software"), to deal in the Software without
|
6 |
+
restriction, including without limitation the rights to use,
|
7 |
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8 |
+
copies of the Software, and to permit persons to whom the
|
9 |
+
Software is furnished to do so, subject to the following
|
10 |
+
conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be
|
13 |
+
included in all copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17 |
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18 |
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19 |
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20 |
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22 |
+
OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,17 +1,17 @@
|
|
1 |
jQuery(document).ready( function() {
|
2 |
-
jQuery(
|
3 |
function() {
|
4 |
var link = this;
|
5 |
jQuery(link).addClass('loading');
|
6 |
|
7 |
-
jQuery(
|
8 |
jQuery(this).addClass('selected');
|
9 |
|
10 |
jQuery.post( ajaxurl, {
|
11 |
action: 'widget_members',
|
12 |
'cookie': encodeURIComponent(document.cookie),
|
13 |
-
'_wpnonce': jQuery(
|
14 |
-
'max-members': jQuery(
|
15 |
'filter': jQuery(this).attr('id')
|
16 |
},
|
17 |
function(response)
|
@@ -29,20 +29,20 @@ function member_wiget_response(response) {
|
|
29 |
response = response.substr(0, response.length-1);
|
30 |
response = response.split('[[SPLIT]]');
|
31 |
|
32 |
-
if ( response[0]
|
33 |
-
jQuery(
|
34 |
function() {
|
35 |
-
jQuery(
|
36 |
-
jQuery(
|
37 |
}
|
38 |
);
|
39 |
|
40 |
} else {
|
41 |
-
jQuery(
|
42 |
function() {
|
43 |
var message = '<p>' + response[1] + '</p>';
|
44 |
-
jQuery(
|
45 |
-
jQuery(
|
46 |
}
|
47 |
);
|
48 |
}
|
1 |
jQuery(document).ready( function() {
|
2 |
+
jQuery('.widget div#members-list-options a').on('click',
|
3 |
function() {
|
4 |
var link = this;
|
5 |
jQuery(link).addClass('loading');
|
6 |
|
7 |
+
jQuery('.widget div#members-list-options a').removeClass('selected');
|
8 |
jQuery(this).addClass('selected');
|
9 |
|
10 |
jQuery.post( ajaxurl, {
|
11 |
action: 'widget_members',
|
12 |
'cookie': encodeURIComponent(document.cookie),
|
13 |
+
'_wpnonce': jQuery('input#_wpnonce-members').val(),
|
14 |
+
'max-members': jQuery('input#members_widget_max').val(),
|
15 |
'filter': jQuery(this).attr('id')
|
16 |
},
|
17 |
function(response)
|
29 |
response = response.substr(0, response.length-1);
|
30 |
response = response.split('[[SPLIT]]');
|
31 |
|
32 |
+
if ( response[0] !== '-1' ) {
|
33 |
+
jQuery('.widget ul#members-list').fadeOut(200,
|
34 |
function() {
|
35 |
+
jQuery('.widget ul#members-list').html(response[1]);
|
36 |
+
jQuery('.widget ul#members-list').fadeIn(200);
|
37 |
}
|
38 |
);
|
39 |
|
40 |
} else {
|
41 |
+
jQuery('.widget ul#members-list').fadeOut(200,
|
42 |
function() {
|
43 |
var message = '<p>' + response[1] + '</p>';
|
44 |
+
jQuery('.widget ul#members-list').html(message);
|
45 |
+
jQuery('.widget ul#members-list').fadeIn(200);
|
46 |
}
|
47 |
);
|
48 |
}
|
@@ -1 +1,2 @@
|
|
1 |
-
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
function member_wiget_response(a){a=a.substr(0,a.length-1),a=a.split("[[SPLIT]]"),"-1"!==a[0]?jQuery(".widget ul#members-list").fadeOut(200,function(){jQuery(".widget ul#members-list").html(a[1]),jQuery(".widget ul#members-list").fadeIn(200)}):jQuery(".widget ul#members-list").fadeOut(200,function(){var b="<p>"+a[1]+"</p>";jQuery(".widget ul#members-list").html(b),jQuery(".widget ul#members-list").fadeIn(200)})}jQuery(document).ready(function(){jQuery(".widget div#members-list-options a").on("click",function(){var a=this;return jQuery(a).addClass("loading"),jQuery(".widget div#members-list-options a").removeClass("selected"),jQuery(this).addClass("selected"),jQuery.post(ajaxurl,{action:"widget_members",cookie:encodeURIComponent(document.cookie),_wpnonce:jQuery("input#_wpnonce-members").val(),"max-members":jQuery("input#members_widget_max").val(),filter:jQuery(this).attr("id")},function(b){jQuery(a).removeClass("loading"),member_wiget_response(b)}),!1})});
|
@@ -216,7 +216,7 @@ class BP_Forum_Legacy_Theme_Compat {
|
|
216 |
'post_author' => 0,
|
217 |
'post_date' => 0,
|
218 |
'post_content' => '',
|
219 |
-
'post_type' => '
|
220 |
'post_status' => 'publish',
|
221 |
'is_page' => true,
|
222 |
'comment_status' => 'closed'
|
216 |
'post_author' => 0,
|
217 |
'post_date' => 0,
|
218 |
'post_content' => '',
|
219 |
+
'post_type' => 'page',
|
220 |
'post_status' => 'publish',
|
221 |
'is_page' => true,
|
222 |
'comment_status' => 'closed'
|
@@ -1524,7 +1524,7 @@ function bp_forum_pagination_count() {
|
|
1524 |
if ( 'tags' == $forum_template->type && !empty( $forum_template->search_terms ) )
|
1525 |
$pag_filter = sprintf( __( ' matching tag "%s"', 'buddypress' ), $forum_template->search_terms );
|
1526 |
|
1527 |
-
return apply_filters( 'bp_get_forum_pagination_count', sprintf( _n( 'Viewing
|
1528 |
}
|
1529 |
|
1530 |
/**
|
@@ -2163,7 +2163,7 @@ function bp_the_topic_pagination_count() {
|
|
2163 |
$to_num = bp_core_number_format( ( $start_num + ( $topic_template->pag_num - 1 ) > $topic_template->total_post_count ) ? $topic_template->total_post_count : $start_num + ( $topic_template->pag_num - 1 ) );
|
2164 |
$total = bp_core_number_format( $topic_template->total_post_count );
|
2165 |
|
2166 |
-
echo apply_filters( 'bp_the_topic_pagination_count', sprintf( _n( 'Viewing
|
2167 |
}
|
2168 |
|
2169 |
/**
|
1524 |
if ( 'tags' == $forum_template->type && !empty( $forum_template->search_terms ) )
|
1525 |
$pag_filter = sprintf( __( ' matching tag "%s"', 'buddypress' ), $forum_template->search_terms );
|
1526 |
|
1527 |
+
return apply_filters( 'bp_get_forum_pagination_count', sprintf( _n( 'Viewing 1 topic', 'Viewing %1$s - %2$s of %3$s topics', (int) $forum_template->total_topic_count, 'buddypress' ), $from_num, $to_num, $total, $pag_filter ), $from_num, $to_num, $total );
|
1528 |
}
|
1529 |
|
1530 |
/**
|
2163 |
$to_num = bp_core_number_format( ( $start_num + ( $topic_template->pag_num - 1 ) > $topic_template->total_post_count ) ? $topic_template->total_post_count : $start_num + ( $topic_template->pag_num - 1 ) );
|
2164 |
$total = bp_core_number_format( $topic_template->total_post_count );
|
2165 |
|
2166 |
+
echo apply_filters( 'bp_the_topic_pagination_count', sprintf( _n( 'Viewing 1 post', 'Viewing %1$s - %2$s of %3$s posts', (int) $topic_template->total_post_count, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
|
2167 |
}
|
2168 |
|
2169 |
/**
|
@@ -96,14 +96,18 @@ function friends_register_activity_actions() {
|
|
96 |
$bp->friends->id,
|
97 |
'friendship_accepted',
|
98 |
__( 'Friendships accepted', 'buddypress' ),
|
99 |
-
'bp_friends_format_activity_action_friendship_accepted'
|
|
|
|
|
100 |
);
|
101 |
|
102 |
bp_activity_set_action(
|
103 |
$bp->friends->id,
|
104 |
'friendship_created',
|
105 |
__( 'New friendships', 'buddypress' ),
|
106 |
-
'bp_friends_format_activity_action_friendship_created'
|
|
|
|
|
107 |
);
|
108 |
|
109 |
// < BP 1.6 backpat
|
96 |
$bp->friends->id,
|
97 |
'friendship_accepted',
|
98 |
__( 'Friendships accepted', 'buddypress' ),
|
99 |
+
'bp_friends_format_activity_action_friendship_accepted',
|
100 |
+
__( 'Friendships', 'buddypress' ),
|
101 |
+
array( 'activity', 'member' )
|
102 |
);
|
103 |
|
104 |
bp_activity_set_action(
|
105 |
$bp->friends->id,
|
106 |
'friendship_created',
|
107 |
__( 'New friendships', 'buddypress' ),
|
108 |
+
'bp_friends_format_activity_action_friendship_created',
|
109 |
+
__( 'Friendships', 'buddypress' ),
|
110 |
+
array( 'activity', 'member' )
|
111 |
);
|
112 |
|
113 |
// < BP 1.6 backpat
|
@@ -290,7 +290,9 @@ class BP_Friends_Friendship {
|
|
290 |
if ( empty( $user_id ) )
|
291 |
$user_id = bp_loggedin_user_id();
|
292 |
|
293 |
-
|
|
|
|
|
294 |
|
295 |
$pag_sql = '';
|
296 |
if ( !empty( $limit ) && !empty( $page ) )
|
@@ -307,11 +309,11 @@ class BP_Friends_Friendship {
|
|
307 |
|
308 |
// filter the user_ids based on the search criteria.
|
309 |
if ( bp_is_active( 'xprofile' ) ) {
|
310 |
-
$sql = "SELECT DISTINCT user_id FROM {$bp->profile->table_name_data} WHERE user_id IN ({$fids}) AND value LIKE
|
311 |
-
$total_sql = "SELECT COUNT(DISTINCT user_id) FROM {$bp->profile->table_name_data} WHERE user_id IN ({$fids}) AND value LIKE
|
312 |
} else {
|
313 |
-
$sql = "SELECT DISTINCT user_id FROM {$wpdb->usermeta} WHERE user_id IN ({$fids}) AND meta_key = 'nickname' AND meta_value LIKE '
|
314 |
-
$total_sql = "SELECT COUNT(DISTINCT user_id) FROM {$wpdb->usermeta} WHERE user_id IN ({$fids}) AND meta_key = 'nickname' AND meta_value LIKE
|
315 |
}
|
316 |
|
317 |
$filtered_friend_ids = $wpdb->get_col( $sql );
|
@@ -443,7 +445,9 @@ class BP_Friends_Friendship {
|
|
443 |
public static function search_users( $filter, $user_id, $limit = null, $page = null ) {
|
444 |
global $wpdb, $bp;
|
445 |
|
446 |
-
|
|
|
|
|
447 |
|
448 |
$usermeta_table = $wpdb->base_prefix . 'usermeta';
|
449 |
$users_table = $wpdb->base_prefix . 'users';
|
@@ -454,9 +458,9 @@ class BP_Friends_Friendship {
|
|
454 |
|
455 |
// filter the user_ids based on the search criteria.
|
456 |
if ( bp_is_active( 'xprofile' ) ) {
|
457 |
-
$sql = "SELECT DISTINCT d.user_id as id FROM {$bp->profile->table_name_data} d, {$users_table} u WHERE d.user_id = u.id AND d.value LIKE
|
458 |
} else {
|
459 |
-
$sql = "SELECT DISTINCT user_id as id FROM {$usermeta_table} WHERE meta_value LIKE
|
460 |
}
|
461 |
|
462 |
$filtered_fids = $wpdb->get_col($sql);
|
@@ -478,16 +482,18 @@ class BP_Friends_Friendship {
|
|
478 |
public static function search_users_count( $filter ) {
|
479 |
global $wpdb, $bp;
|
480 |
|
481 |
-
|
|
|
|
|
482 |
|
483 |
$usermeta_table = $wpdb->prefix . 'usermeta';
|
484 |
$users_table = $wpdb->base_prefix . 'users';
|
485 |
|
486 |
// filter the user_ids based on the search criteria.
|
487 |
if ( bp_is_active( 'xprofile' ) ) {
|
488 |
-
$sql = "SELECT COUNT(DISTINCT d.user_id) FROM {$bp->profile->table_name_data} d, {$users_table} u WHERE d.user_id = u.id AND d.value LIKE
|
489 |
} else {
|
490 |
-
$sql = "SELECT COUNT(DISTINCT user_id) FROM {$usermeta_table} WHERE meta_value LIKE
|
491 |
}
|
492 |
|
493 |
$user_count = $wpdb->get_col($sql);
|
290 |
if ( empty( $user_id ) )
|
291 |
$user_id = bp_loggedin_user_id();
|
292 |
|
293 |
+
// Only search for matching strings at the beginning of the
|
294 |
+
// name (@todo - figure out why this restriction)
|
295 |
+
$search_terms_like = bp_esc_like( $filter ) . '%';
|
296 |
|
297 |
$pag_sql = '';
|
298 |
if ( !empty( $limit ) && !empty( $page ) )
|
309 |
|
310 |
// filter the user_ids based on the search criteria.
|
311 |
if ( bp_is_active( 'xprofile' ) ) {
|
312 |
+
$sql = $wpdb->prepare( "SELECT DISTINCT user_id FROM {$bp->profile->table_name_data} WHERE user_id IN ({$fids}) AND value LIKE %s {$pag_sql}", $search_terms_like );
|
313 |
+
$total_sql = $wpdb->prepare( "SELECT COUNT(DISTINCT user_id) FROM {$bp->profile->table_name_data} WHERE user_id IN ({$fids}) AND value LIKE %s", $search_terms_like );
|
314 |
} else {
|
315 |
+
$sql = $wpdb->prepare( "SELECT DISTINCT user_id FROM {$wpdb->usermeta} WHERE user_id IN ({$fids}) AND meta_key = 'nickname' AND meta_value LIKE %s' {$pag_sql}", $search_terms_like );
|
316 |
+
$total_sql = $wpdb->prepare( "SELECT COUNT(DISTINCT user_id) FROM {$wpdb->usermeta} WHERE user_id IN ({$fids}) AND meta_key = 'nickname' AND meta_value LIKE %s", $search_terms_like );
|
317 |
}
|
318 |
|
319 |
$filtered_friend_ids = $wpdb->get_col( $sql );
|
445 |
public static function search_users( $filter, $user_id, $limit = null, $page = null ) {
|
446 |
global $wpdb, $bp;
|
447 |
|
448 |
+
// Only search for matching strings at the beginning of the
|
449 |
+
// name (@todo - figure out why this restriction)
|
450 |
+
$search_terms_like = bp_esc_like( $filter ) . '%';
|
451 |
|
452 |
$usermeta_table = $wpdb->base_prefix . 'usermeta';
|
453 |
$users_table = $wpdb->base_prefix . 'users';
|
458 |
|
459 |
// filter the user_ids based on the search criteria.
|
460 |
if ( bp_is_active( 'xprofile' ) ) {
|
461 |
+
$sql = $wpdb->prepare( "SELECT DISTINCT d.user_id as id FROM {$bp->profile->table_name_data} d, {$users_table} u WHERE d.user_id = u.id AND d.value LIKE %s ORDER BY d.value DESC {$pag_sql}", $search_terms_like );
|
462 |
} else {
|
463 |
+
$sql = $wpdb->prepare( "SELECT DISTINCT user_id as id FROM {$usermeta_table} WHERE meta_value LIKE %s ORDER BY d.value DESC {$pag_sql}", $search_terms_like );
|
464 |
}
|
465 |
|
466 |
$filtered_fids = $wpdb->get_col($sql);
|
482 |
public static function search_users_count( $filter ) {
|
483 |
global $wpdb, $bp;
|
484 |
|
485 |
+
// Only search for matching strings at the beginning of the
|
486 |
+
// name (@todo - figure out why this restriction)
|
487 |
+
$search_terms_like = bp_esc_like( $filter ) . '%';
|
488 |
|
489 |
$usermeta_table = $wpdb->prefix . 'usermeta';
|
490 |
$users_table = $wpdb->base_prefix . 'users';
|
491 |
|
492 |
// filter the user_ids based on the search criteria.
|
493 |
if ( bp_is_active( 'xprofile' ) ) {
|
494 |
+
$sql = $wpdb->prepare( "SELECT COUNT(DISTINCT d.user_id) FROM {$bp->profile->table_name_data} d, {$users_table} u WHERE d.user_id = u.id AND d.value LIKE %s", $search_terms_like );
|
495 |
} else {
|
496 |
+
$sql = $wpdb->prepare( "SELECT COUNT(DISTINCT user_id) FROM {$usermeta_table} WHERE meta_value LIKE %s", $search_terms_like );
|
497 |
}
|
498 |
|
499 |
$user_count = $wpdb->get_col($sql);
|
@@ -38,7 +38,14 @@ function bp_friends_filter_user_query_populate_extras( BP_User_Query $user_query
|
|
38 |
$friend_id = bp_loggedin_user_id() == $fs->initiator_user_id ? $fs->friend_user_id : $fs->initiator_user_id;
|
39 |
|
40 |
if ( isset( $user_query->results[ $friend_id ] ) ) {
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
}
|
43 |
}
|
44 |
}
|
38 |
$friend_id = bp_loggedin_user_id() == $fs->initiator_user_id ? $fs->friend_user_id : $fs->initiator_user_id;
|
39 |
|
40 |
if ( isset( $user_query->results[ $friend_id ] ) ) {
|
41 |
+
if ( 0 == $fs->is_confirmed ) {
|
42 |
+
$status = $fs->initiator_user_id == bp_loggedin_user_id() ? 'pending' : 'awaiting_response';
|
43 |
+
} else {
|
44 |
+
$status = 'is_friend';
|
45 |
+
}
|
46 |
+
|
47 |
+
$user_query->results[ $friend_id ]->is_friend = $fs->is_confirmed;
|
48 |
+
$user_query->results[ $friend_id ]->friendship_status = $status;
|
49 |
}
|
50 |
}
|
51 |
}
|
@@ -195,13 +195,28 @@ function friends_check_friendship( $user_id, $possible_friend_id ) {
|
|
195 |
/**
|
196 |
* Get the friendship status of two friends.
|
197 |
*
|
198 |
-
* Will return 'is_friends', 'not_friends', or '
|
199 |
*
|
200 |
* @param int $user_id ID of the first user.
|
201 |
* @param int $possible_friend_id ID of the other user.
|
202 |
* @return string Friend status of the two users.
|
203 |
*/
|
204 |
function friends_check_friendship_status( $user_id, $possible_friend_id ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
return BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id );
|
206 |
}
|
207 |
|
@@ -551,3 +566,41 @@ function friends_remove_data( $user_id ) {
|
|
551 |
add_action( 'wpmu_delete_user', 'friends_remove_data' );
|
552 |
add_action( 'delete_user', 'friends_remove_data' );
|
553 |
add_action( 'bp_make_spam_user', 'friends_remove_data' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
/**
|
196 |
* Get the friendship status of two friends.
|
197 |
*
|
198 |
+
* Will return 'is_friends', 'not_friends', 'pending' or 'awaiting_response'.
|
199 |
*
|
200 |
* @param int $user_id ID of the first user.
|
201 |
* @param int $possible_friend_id ID of the other user.
|
202 |
* @return string Friend status of the two users.
|
203 |
*/
|
204 |
function friends_check_friendship_status( $user_id, $possible_friend_id ) {
|
205 |
+
global $members_template;
|
206 |
+
|
207 |
+
// check the BP_User_Query first
|
208 |
+
// @see bp_friends_filter_user_query_populate_extras()
|
209 |
+
if ( ! empty( $members_template->in_the_loop ) ) {
|
210 |
+
if ( isset( $members_template->member->friendship_status ) ) {
|
211 |
+
return $members_template->member->friendship_status;
|
212 |
+
|
213 |
+
// make sure that the friends BP_User_Query was registered before assuming
|
214 |
+
// status as 'not_friends'
|
215 |
+
} elseif ( has_filter( 'bp_user_query_populate_extras', 'bp_friends_filter_user_query_populate_extras' ) ) {
|
216 |
+
return 'not_friends';
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
return BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id );
|
221 |
}
|
222 |
|
566 |
add_action( 'wpmu_delete_user', 'friends_remove_data' );
|
567 |
add_action( 'delete_user', 'friends_remove_data' );
|
568 |
add_action( 'bp_make_spam_user', 'friends_remove_data' );
|
569 |
+
|
570 |
+
/**
|
571 |
+
* Used by the Activity component's @mentions to print a JSON list of the current user's friends.
|
572 |
+
*
|
573 |
+
* This is intended to speed up @mentions lookups for a majority of use cases.
|
574 |
+
*
|
575 |
+
* @see bp_activity_mentions_script()
|
576 |
+
*/
|
577 |
+
function bp_friends_prime_mentions_results() {
|
578 |
+
if ( ! bp_activity_maybe_load_mentions_scripts() ) {
|
579 |
+
return;
|
580 |
+
}
|
581 |
+
|
582 |
+
$friends_query = array(
|
583 |
+
'count_total' => '', // Prevents total count
|
584 |
+
'populate_extras' => false,
|
585 |
+
|
586 |
+
'type' => 'alphabetical',
|
587 |
+
'user_id' => get_current_user_id(),
|
588 |
+
);
|
589 |
+
|
590 |
+
$friends_query = new BP_User_Query( $friends_query );
|
591 |
+
$results = array();
|
592 |
+
|
593 |
+
foreach ( $friends_query->results as $user ) {
|
594 |
+
$result = new stdClass();
|
595 |
+
$result->ID = $user->user_nicename;
|
596 |
+
$result->image = bp_core_fetch_avatar( array( 'html' => false, 'item_id' => $user->ID ) );
|
597 |
+
$result->name = bp_core_get_user_displayname( $user->ID );
|
598 |
+
|
599 |
+
$results[] = $result;
|
600 |
+
}
|
601 |
+
|
602 |
+
wp_localize_script( 'bp-mentions', 'BP_Suggestions', array(
|
603 |
+
'friends' => $results,
|
604 |
+
) );
|
605 |
+
}
|
606 |
+
add_action( 'bp_activity_mentions_prime_results', 'bp_friends_prime_mentions_results' );
|
@@ -21,7 +21,7 @@ class BP_Friends_Component extends BP_Component {
|
|
21 |
public function __construct() {
|
22 |
parent::start(
|
23 |
'friends',
|
24 |
-
|
25 |
buddypress()->plugin_dir,
|
26 |
array(
|
27 |
'adminbar_myaccount_order' => 60
|
@@ -137,7 +137,7 @@ class BP_Friends_Component extends BP_Component {
|
|
137 |
|
138 |
// Add the subnav items to the friends nav item
|
139 |
$sub_nav[] = array(
|
140 |
-
'name' =>
|
141 |
'slug' => 'my-friends',
|
142 |
'parent_url' => $friends_link,
|
143 |
'parent_slug' => bp_get_friends_slug(),
|
@@ -147,7 +147,7 @@ class BP_Friends_Component extends BP_Component {
|
|
147 |
);
|
148 |
|
149 |
$sub_nav[] = array(
|
150 |
-
'name' =>
|
151 |
'slug' => 'requests',
|
152 |
'parent_url' => $friends_link,
|
153 |
'parent_slug' => bp_get_friends_slug(),
|
@@ -182,11 +182,11 @@ class BP_Friends_Component extends BP_Component {
|
|
182 |
// Pending friend requests
|
183 |
$count = count( friends_get_friendship_request_user_ids( bp_loggedin_user_id() ) );
|
184 |
if ( !empty( $count ) ) {
|
185 |
-
$title = sprintf(
|
186 |
-
$pending = sprintf(
|
187 |
} else {
|
188 |
-
$title =
|
189 |
-
$pending =
|
190 |
}
|
191 |
|
192 |
// Add the "My Account" sub menus
|
@@ -197,11 +197,11 @@ class BP_Friends_Component extends BP_Component {
|
|
197 |
'href' => trailingslashit( $friends_link )
|
198 |
);
|
199 |
|
200 |
-
// My
|
201 |
$wp_admin_nav[] = array(
|
202 |
'parent' => 'my-account-' . $this->id,
|
203 |
'id' => 'my-account-' . $this->id . '-friendships',
|
204 |
-
'title' =>
|
205 |
'href' => trailingslashit( $friends_link )
|
206 |
);
|
207 |
|
21 |
public function __construct() {
|
22 |
parent::start(
|
23 |
'friends',
|
24 |
+
_x( 'Friend Connections', 'Friends screen page <title>', 'buddypress' ),
|
25 |
buddypress()->plugin_dir,
|
26 |
array(
|
27 |
'adminbar_myaccount_order' => 60
|
137 |
|
138 |
// Add the subnav items to the friends nav item
|
139 |
$sub_nav[] = array(
|
140 |
+
'name' => _x( 'Friendships', 'Friends screen sub nav', 'buddypress' ),
|
141 |
'slug' => 'my-friends',
|
142 |
'parent_url' => $friends_link,
|
143 |
'parent_slug' => bp_get_friends_slug(),
|
147 |
);
|
148 |
|
149 |
$sub_nav[] = array(
|
150 |
+
'name' => _x( 'Requests', 'Friends screen sub nav', 'buddypress' ),
|
151 |
'slug' => 'requests',
|
152 |
'parent_url' => $friends_link,
|
153 |
'parent_slug' => bp_get_friends_slug(),
|
182 |
// Pending friend requests
|
183 |
$count = count( friends_get_friendship_request_user_ids( bp_loggedin_user_id() ) );
|
184 |
if ( !empty( $count ) ) {
|
185 |
+
$title = sprintf( _x( 'Friends <span class="count">%s</span>', 'My Account Friends menu', 'buddypress' ), number_format_i18n( $count ) );
|
186 |
+
$pending = sprintf( _x( 'Pending Requests <span class="count">%s</span>', 'My Account Friends menu sub nav', 'buddypress' ), number_format_i18n( $count ) );
|
187 |
} else {
|
188 |
+
$title = _x( 'Friends', 'My Account Friends menu', 'buddypress' );
|
189 |
+
$pending = _x( 'No Pending Requests','My Account Friends menu sub nav', 'buddypress' );
|
190 |
}
|
191 |
|
192 |
// Add the "My Account" sub menus
|
197 |
'href' => trailingslashit( $friends_link )
|
198 |
);
|
199 |
|
200 |
+
// My Friends
|
201 |
$wp_admin_nav[] = array(
|
202 |
'parent' => 'my-account-' . $this->id,
|
203 |
'id' => 'my-account-' . $this->id . '-friendships',
|
204 |
+
'title' => _x( 'Friendships', 'My Account Friends menu sub nav', 'buddypress' ),
|
205 |
'href' => trailingslashit( $friends_link )
|
206 |
);
|
207 |
|
@@ -82,7 +82,7 @@ function friends_screen_notification_settings() {
|
|
82 |
<thead>
|
83 |
<tr>
|
84 |
<th class="icon"></th>
|
85 |
-
<th class="title"><?php
|
86 |
<th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
|
87 |
<th class="no"><?php _e( 'No', 'buddypress' )?></th>
|
88 |
</tr>
|
@@ -91,13 +91,13 @@ function friends_screen_notification_settings() {
|
|
91 |
<tbody>
|
92 |
<tr id="friends-notification-settings-request">
|
93 |
<td></td>
|
94 |
-
<td><?php
|
95 |
<td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" value="yes" <?php checked( $send_requests, 'yes', true ) ?>/></td>
|
96 |
<td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" value="no" <?php checked( $send_requests, 'no', true ) ?>/></td>
|
97 |
</tr>
|
98 |
<tr id="friends-notification-settings-accepted">
|
99 |
<td></td>
|
100 |
-
<td><?php
|
101 |
<td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php checked( $accept_requests, 'yes', true ) ?>/></td>
|
102 |
<td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php checked( $accept_requests, 'no', true ) ?>/></td>
|
103 |
</tr>
|
82 |
<thead>
|
83 |
<tr>
|
84 |
<th class="icon"></th>
|
85 |
+
<th class="title"><?php _ex( 'Friends', 'Friend settings on notification settings page', 'buddypress' ) ?></th>
|
86 |
<th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
|
87 |
<th class="no"><?php _e( 'No', 'buddypress' )?></th>
|
88 |
</tr>
|
91 |
<tbody>
|
92 |
<tr id="friends-notification-settings-request">
|
93 |
<td></td>
|
94 |
+
<td><?php _ex( 'A member sends you a friendship request', 'Friend settings on notification settings page', 'buddypress' ) ?></td>
|
95 |
<td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" value="yes" <?php checked( $send_requests, 'yes', true ) ?>/></td>
|
96 |
<td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" value="no" <?php checked( $send_requests, 'no', true ) ?>/></td>
|
97 |
</tr>
|
98 |
<tr id="friends-notification-settings-accepted">
|
99 |
<td></td>
|
100 |
+
<td><?php _ex( 'A member accepts your friendship request', 'Friend settings on notification settings page', 'buddypress' ) ?></td>
|
101 |
<td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php checked( $accept_requests, 'yes', true ) ?>/></td>
|
102 |
<td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php checked( $accept_requests, 'no', true ) ?>/></td>
|
103 |
</tr>
|
@@ -187,17 +187,12 @@ function bp_friend_search_form() {
|
|
187 |
}
|
188 |
|
189 |
/**
|
190 |
-
* Output the Add Friend button in member
|
|
|
|
|
191 |
*/
|
192 |
function bp_member_add_friend_button() {
|
193 |
-
|
194 |
-
|
195 |
-
if ( !isset( $members_template->member->is_friend ) || null === $members_template->member->is_friend )
|
196 |
-
$friend_status = 'not_friends';
|
197 |
-
else
|
198 |
-
$friend_status = ( 0 == $members_template->member->is_friend ) ? 'pending' : 'is_friend';
|
199 |
-
|
200 |
-
echo bp_get_add_friend_button( $members_template->member->id, $friend_status );
|
201 |
}
|
202 |
add_action( 'bp_directory_members_actions', 'bp_member_add_friend_button' );
|
203 |
|
187 |
}
|
188 |
|
189 |
/**
|
190 |
+
* Output the "Add Friend" button in the member loop.
|
191 |
+
*
|
192 |
+
* @since BuddyPress (1.2.6)
|
193 |
*/
|
194 |
function bp_member_add_friend_button() {
|
195 |
+
bp_add_friend_button( bp_get_member_user_id() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
}
|
197 |
add_action( 'bp_directory_members_actions', 'bp_member_add_friend_button' );
|
198 |
|
@@ -20,6 +20,13 @@ function bp_friends_register_widgets() {
|
|
20 |
return;
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Core_Friends_Widget");' ) );
|
24 |
}
|
25 |
add_action( 'bp_register_widgets', 'bp_friends_register_widgets' );
|
20 |
return;
|
21 |
}
|
22 |
|
23 |
+
// The Friends widget works only when looking an a displayed user,
|
24 |
+
// and the concept of "displayed user" doesn't exist on non-root blogs,
|
25 |
+
// so we don't register the widget there.
|
26 |
+
if ( ! bp_is_root_blog() ) {
|
27 |
+
return;
|
28 |
+
}
|
29 |
+
|
30 |
add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Core_Friends_Widget");' ) );
|
31 |
}
|
32 |
add_action( 'bp_register_widgets', 'bp_friends_register_widgets' );
|
@@ -1,17 +1,17 @@
|
|
1 |
jQuery(document).ready( function() {
|
2 |
-
jQuery(
|
3 |
function() {
|
4 |
var link = this;
|
5 |
jQuery(link).addClass('loading');
|
6 |
|
7 |
-
jQuery(
|
8 |
jQuery(this).addClass('selected');
|
9 |
|
10 |
jQuery.post( ajaxurl, {
|
11 |
action: 'widget_friends',
|
12 |
'cookie': encodeURIComponent(document.cookie),
|
13 |
-
'_wpnonce': jQuery(
|
14 |
-
'max-friends': jQuery(
|
15 |
'filter': jQuery(this).attr('id')
|
16 |
},
|
17 |
function(response)
|
@@ -29,21 +29,21 @@ function friend_wiget_response(response) {
|
|
29 |
response = response.substr(0, response.length-1);
|
30 |
response = response.split('[[SPLIT]]');
|
31 |
|
32 |
-
if ( response[0]
|
33 |
-
jQuery(
|
34 |
function() {
|
35 |
-
jQuery(
|
36 |
-
jQuery(
|
37 |
}
|
38 |
);
|
39 |
|
40 |
} else {
|
41 |
-
jQuery(
|
42 |
function() {
|
43 |
var message = '<p>' + response[1] + '</p>';
|
44 |
-
jQuery(
|
45 |
-
jQuery(
|
46 |
}
|
47 |
);
|
48 |
}
|
49 |
-
}
|
1 |
jQuery(document).ready( function() {
|
2 |
+
jQuery('.widget div#friends-list-options a').on('click',
|
3 |
function() {
|
4 |
var link = this;
|
5 |
jQuery(link).addClass('loading');
|
6 |
|
7 |
+
jQuery('.widget div#friends-list-options a').removeClass('selected');
|
8 |
jQuery(this).addClass('selected');
|
9 |
|
10 |
jQuery.post( ajaxurl, {
|
11 |
action: 'widget_friends',
|
12 |
'cookie': encodeURIComponent(document.cookie),
|
13 |
+
'_wpnonce': jQuery('input#_wpnonce-friends').val(),
|
14 |
+
'max-friends': jQuery('input#friends_widget_max').val(),
|
15 |
'filter': jQuery(this).attr('id')
|
16 |
},
|
17 |
function(response)
|
29 |
response = response.substr(0, response.length-1);
|
30 |
response = response.split('[[SPLIT]]');
|
31 |
|
32 |
+
if ( response[0] !== '-1' ) {
|
33 |
+
jQuery('.widget ul#friends-list').fadeOut(200,
|
34 |
function() {
|
35 |
+
jQuery('.widget ul#friends-list').html(response[1]);
|
36 |
+
jQuery('.widget ul#friends-list').fadeIn(200);
|
37 |
}
|
38 |
);
|
39 |
|
40 |
} else {
|
41 |
+
jQuery('.widget ul#friends-list').fadeOut(200,
|
42 |
function() {
|
43 |
var message = '<p>' + response[1] + '</p>';
|
44 |
+
jQuery('.widget ul#friends-list').html(message);
|
45 |
+
jQuery('.widget ul#friends-list').fadeIn(200);
|
46 |
}
|
47 |
);
|
48 |
}
|
49 |
+
}
|
@@ -1 +1,2 @@
|
|
1 |
-
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
function friend_wiget_response(a){a=a.substr(0,a.length-1),a=a.split("[[SPLIT]]"),"-1"!==a[0]?jQuery(".widget ul#friends-list").fadeOut(200,function(){jQuery(".widget ul#friends-list").html(a[1]),jQuery(".widget ul#friends-list").fadeIn(200)}):jQuery(".widget ul#friends-list").fadeOut(200,function(){var b="<p>"+a[1]+"</p>";jQuery(".widget ul#friends-list").html(b),jQuery(".widget ul#friends-list").fadeIn(200)})}jQuery(document).ready(function(){jQuery(".widget div#friends-list-options a").on("click",function(){var a=this;return jQuery(a).addClass("loading"),jQuery(".widget div#friends-list-options a").removeClass("selected"),jQuery(this).addClass("selected"),jQuery.post(ajaxurl,{action:"widget_friends",cookie:encodeURIComponent(document.cookie),_wpnonce:jQuery("input#_wpnonce-friends").val(),"max-friends":jQuery("input#friends_widget_max").val(),filter:jQuery(this).attr("id")},function(b){jQuery(a).removeClass("loading"),friend_wiget_response(b)}),!1})});
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
body.toplevel_page_bp-groups table.groups th#status,
|
2 |
+
body.toplevel_page_bp-groups table.groups th#members {
|
3 |
+
width: 10%;
|
4 |
+
}
|
5 |
+
|
6 |
+
body.toplevel_page_bp-groups table.groups th#last_active {
|
7 |
+
width: 15%;
|
8 |
+
}
|
9 |
+
|
10 |
+
#bp-groups-form .avatar {
|
11 |
+
float: right;
|
12 |
+
margin-left: 10px;
|
13 |
+
margin-top: 1px;
|
14 |
+
}
|
15 |
+
#bp-groups-edit-form input {
|
16 |
+
outline: medium none;
|
17 |
+
}
|
18 |
+
#bp-groups-edit-form input#bp-groups-name {
|
19 |
+
font-size: 1.7em;
|
20 |
+
width: 100%;
|
21 |
+
margin-bottom: 6px;
|
22 |
+
}
|
23 |
+
#bp-groups-edit-form input#bp-groups-new-members {
|
24 |
+
width: 100%;
|
25 |
+
max-width: 90%;
|
26 |
+
border: 0;
|
27 |
+
}
|
28 |
+
#bp-groups-new-members-list {
|
29 |
+
margin: 0;
|
30 |
+
}
|
31 |
+
#bp_group_settings legend {
|
32 |
+
margin: 10px 0;
|
33 |
+
font-weight: bold;
|
34 |
+
}
|
35 |
+
#bp_group_settings ul {
|
36 |
+
margin: 0;
|
37 |
+
}
|
38 |
+
.bp-groups-settings-section {
|
39 |
+
margin-top: 10px;
|
40 |
+
}
|
41 |
+
#bp-groups-permalink-box {
|
42 |
+
line-height: 24px;
|
43 |
+
color: #666;
|
44 |
+
}
|
45 |
+
.bp-groups-member-type {
|
46 |
+
position: relative;
|
47 |
+
}
|
48 |
+
.bp-groups-member-type > h4 {
|
49 |
+
margin-bottom: .5em;
|
50 |
+
}
|
51 |
+
ul.bp-group-delete-list {
|
52 |
+
list-style-type: disc;
|
53 |
+
margin: 4px 26px;
|
54 |
+
}
|
55 |
+
.bp-group-admin-pagination {
|
56 |
+
position: absolute;
|
57 |
+
text-align: left;
|
58 |
+
width: 100%;
|
59 |
+
}
|
60 |
+
.bp-group-admin-pagination.table-top {
|
61 |
+
top: 0;
|
62 |
+
}
|
63 |
+
.bp-group-admin-pagination.table-bottom {
|
64 |
+
bottom: 0;
|
65 |
+
}
|
66 |
+
.bp-group-admin-pagination-viewing {
|
67 |
+
color: #777;
|
68 |
+
font-size: 12px;
|
69 |
+
font-style: italic;
|
70 |
+
}
|
71 |
+
.bp-group-admin-pagination-links {
|
72 |
+
white-space: nowrap;
|
73 |
+
padding-right: 15px;
|
74 |
+
}
|
75 |
+
|
76 |
+
table.bp-group-members .uid-column {
|
77 |
+
padding-right: 20px;
|
78 |
+
padding-left: 20px;
|
79 |
+
}
|
80 |
+
table.bp-group-members .uname-column {
|
81 |
+
width: 70%;
|
82 |
+
}
|
83 |
+
table.bp-group-members .urole-column {
|
84 |
+
padding-right: 20px;
|
85 |
+
padding-left: 20px;
|
86 |
+
}
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
body.toplevel_page_bp-groups table.groups th#members,body.toplevel_page_bp-groups table.groups th#status{width:10%}body.toplevel_page_bp-groups table.groups th#last_active{width:15%}#bp-groups-form .avatar{float:right;margin-left:10px;margin-top:1px}#bp-groups-edit-form input{outline:0}#bp-groups-edit-form input#bp-groups-name{font-size:1.7em;width:100%;margin-bottom:6px}#bp-groups-edit-form input#bp-groups-new-members{width:100%;max-width:90%;border:0}#bp-groups-new-members-list{margin:0}#bp_group_settings legend{margin:10px 0;font-weight:700}#bp_group_settings ul{margin:0}.bp-groups-settings-section{margin-top:10px}#bp-groups-permalink-box{line-height:24px;color:#666}.bp-groups-member-type{position:relative}.bp-groups-member-type>h4{margin-bottom:.5em}ul.bp-group-delete-list{list-style-type:disc;margin:4px 26px}.bp-group-admin-pagination{position:absolute;text-align:left;width:100%}.bp-group-admin-pagination.table-top{top:0}.bp-group-admin-pagination.table-bottom{bottom:0}.bp-group-admin-pagination-viewing{color:#777;font-size:12px;font-style:italic}.bp-group-admin-pagination-links{white-space:nowrap;padding-right:15px}table.bp-group-members .uid-column{padding-right:20px;padding-left:20px}table.bp-group-members .uname-column{width:70%}table.bp-group-members .urole-column{padding-right:20px;padding-left:20px}
|
@@ -7,25 +7,43 @@ body.toplevel_page_bp-groups table.groups th#last_active {
|
|
7 |
width: 15%;
|
8 |
}
|
9 |
|
|
|
|
|
|
|
|
|
|
|
10 |
#bp-groups-edit-form input {
|
11 |
outline: medium none;
|
12 |
-
padding: 3px 8px;
|
13 |
}
|
14 |
#bp-groups-edit-form input#bp-groups-name {
|
15 |
font-size: 1.7em;
|
16 |
width: 100%;
|
|
|
17 |
}
|
18 |
#bp-groups-edit-form input#bp-groups-new-members {
|
19 |
width: 100%;
|
20 |
max-width: 90%;
|
21 |
border: 0;
|
22 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
.bp-groups-settings-section {
|
24 |
-
margin-
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
.bp-groups-member-type {
|
27 |
position: relative;
|
28 |
-
padding-bottom: 1.7em;
|
29 |
}
|
30 |
.bp-groups-member-type > h4 {
|
31 |
margin-bottom: .5em;
|
@@ -54,3 +72,15 @@ ul.bp-group-delete-list {
|
|
54 |
white-space: nowrap;
|
55 |
padding-left: 15px;
|
56 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
width: 15%;
|
8 |
}
|
9 |
|
10 |
+
#bp-groups-form .avatar {
|
11 |
+
float: left;
|
12 |
+
margin-right: 10px;
|
13 |
+
margin-top: 1px;
|
14 |
+
}
|
15 |
#bp-groups-edit-form input {
|
16 |
outline: medium none;
|
|
|
17 |
}
|
18 |
#bp-groups-edit-form input#bp-groups-name {
|
19 |
font-size: 1.7em;
|
20 |
width: 100%;
|
21 |
+
margin-bottom: 6px;
|
22 |
}
|
23 |
#bp-groups-edit-form input#bp-groups-new-members {
|
24 |
width: 100%;
|
25 |
max-width: 90%;
|
26 |
border: 0;
|
27 |
}
|
28 |
+
#bp-groups-new-members-list {
|
29 |
+
margin: 0;
|
30 |
+
}
|
31 |
+
#bp_group_settings legend {
|
32 |
+
margin: 10px 0;
|
33 |
+
font-weight: bold;
|
34 |
+
}
|
35 |
+
#bp_group_settings ul {
|
36 |
+
margin: 0;
|
37 |
+
}
|
38 |
.bp-groups-settings-section {
|
39 |
+
margin-top: 10px;
|
40 |
+
}
|
41 |
+
#bp-groups-permalink-box {
|
42 |
+
line-height: 24px;
|
43 |
+
color: #666;
|
44 |
}
|
45 |
.bp-groups-member-type {
|
46 |
position: relative;
|
|
|
47 |
}
|
48 |
.bp-groups-member-type > h4 {
|
49 |
margin-bottom: .5em;
|
72 |
white-space: nowrap;
|
73 |
padding-left: 15px;
|
74 |
}
|
75 |
+
|
76 |
+
table.bp-group-members .uid-column {
|
77 |
+
padding-left: 20px;
|
78 |
+
padding-right: 20px;
|
79 |
+
}
|
80 |
+
table.bp-group-members .uname-column {
|
81 |
+
width: 70%;
|
82 |
+
}
|
83 |
+
table.bp-group-members .urole-column {
|
84 |
+
padding-left: 20px;
|
85 |
+
padding-right: 20px;
|
86 |
+
}
|
@@ -1 +1,2 @@
|
|
1 |
-
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
body.toplevel_page_bp-groups table.groups th#members,body.toplevel_page_bp-groups table.groups th#status{width:10%}body.toplevel_page_bp-groups table.groups th#last_active{width:15%}#bp-groups-form .avatar{float:left;margin-right:10px;margin-top:1px}#bp-groups-edit-form input{outline:0}#bp-groups-edit-form input#bp-groups-name{font-size:1.7em;width:100%;margin-bottom:6px}#bp-groups-edit-form input#bp-groups-new-members{width:100%;max-width:90%;border:0}#bp-groups-new-members-list{margin:0}#bp_group_settings legend{margin:10px 0;font-weight:700}#bp_group_settings ul{margin:0}.bp-groups-settings-section{margin-top:10px}#bp-groups-permalink-box{line-height:24px;color:#666}.bp-groups-member-type{position:relative}.bp-groups-member-type>h4{margin-bottom:.5em}ul.bp-group-delete-list{list-style-type:disc;margin:4px 26px}.bp-group-admin-pagination{position:absolute;text-align:right;width:100%}.bp-group-admin-pagination.table-top{top:0}.bp-group-admin-pagination.table-bottom{bottom:0}.bp-group-admin-pagination-viewing{color:#777;font-size:12px;font-style:italic}.bp-group-admin-pagination-links{white-space:nowrap;padding-left:15px}table.bp-group-members .uid-column{padding-left:20px;padding-right:20px}table.bp-group-members .uname-column{width:70%}table.bp-group-members .urole-column{padding-left:20px;padding-right:20px}
|
@@ -1,14 +1,8 @@
|
|
|
|
|
|
1 |
(function($) {
|
2 |
function add_member_to_list( e, ui ) {
|
3 |
-
|
4 |
-
$('#bp-groups-new-members-list').append('<li><a href="#" class="bp-groups-remove-new-member" id="' + remove_id + '">x</a> ' + ui.item.label + '</li>');
|
5 |
-
$('#' + remove_id).bind('click', function(e) { remove_member_from_list(e); return false; });
|
6 |
-
|
7 |
-
$('#bp-groups-new-members-list').after('<input name="new_members[]" type="hidden" value="' + ui.item.value + '" />');
|
8 |
-
}
|
9 |
-
|
10 |
-
function remove_member_from_list( e ) {
|
11 |
-
$(e.target).closest('li').remove();
|
12 |
}
|
13 |
|
14 |
var id = 'undefined' !== typeof group_id ? '&group_id=' + group_id : '';
|
@@ -25,9 +19,15 @@
|
|
25 |
close: function() { $(this).removeClass('open'); $(this).val(''); },
|
26 |
select: function( event, ui ) { add_member_to_list( event, ui ); }
|
27 |
});
|
28 |
-
|
29 |
/* Replace noscript placeholder */
|
30 |
-
$( '#bp-groups-new-members' ).
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
/* Warn before leaving unsaved changes */
|
33 |
$(document).on( 'change', 'input#bp-groups-name, input#bp-groups-description, select.bp-groups-role, #bp-groups-settings-section-status input[type="radio"]', function() {
|
@@ -35,10 +35,22 @@
|
|
35 |
});
|
36 |
|
37 |
$( 'input#save' ).on( 'click', function() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
window.warn_on_leave = false;
|
39 |
});
|
40 |
|
41 |
-
window.onbeforeunload = function(
|
42 |
if ( window.warn_on_leave ) {
|
43 |
return BP_Group_Admin.warn_on_leave;
|
44 |
}
|
1 |
+
/* global BP_Group_Admin, group_id, isRtl */
|
2 |
+
|
3 |
(function($) {
|
4 |
function add_member_to_list( e, ui ) {
|
5 |
+
$('#bp-groups-new-members-list').append('<li data-login="' + ui.item.value + '"><a href="#" class="bp-groups-remove-new-member">x</a> ' + ui.item.label + '</li>');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
}
|
7 |
|
8 |
var id = 'undefined' !== typeof group_id ? '&group_id=' + group_id : '';
|
19 |
close: function() { $(this).removeClass('open'); $(this).val(''); },
|
20 |
select: function( event, ui ) { add_member_to_list( event, ui ); }
|
21 |
});
|
22 |
+
|
23 |
/* Replace noscript placeholder */
|
24 |
+
$( '#bp-groups-new-members' ).prop( 'placeholder', BP_Group_Admin.add_member_placeholder );
|
25 |
+
|
26 |
+
/* Remove a member on 'x' click */
|
27 |
+
$( '#bp_group_add_members' ).on( 'click', '.bp-groups-remove-new-member', function( e ) {
|
28 |
+
e.preventDefault();
|
29 |
+
$( e.target.parentNode ).remove();
|
30 |
+
} );
|
31 |
|
32 |
/* Warn before leaving unsaved changes */
|
33 |
$(document).on( 'change', 'input#bp-groups-name, input#bp-groups-description, select.bp-groups-role, #bp-groups-settings-section-status input[type="radio"]', function() {
|
35 |
});
|
36 |
|
37 |
$( 'input#save' ).on( 'click', function() {
|
38 |
+
/* Check for users to add */
|
39 |
+
var users_to_add = [];
|
40 |
+
|
41 |
+
$( '#bp-groups-new-members-list li' ).each( function() {
|
42 |
+
users_to_add.push( $(this).data('login' ) );
|
43 |
+
} );
|
44 |
+
|
45 |
+
/* There are users to add, include a comma separated list of users login in the main field */
|
46 |
+
if ( users_to_add.length ) {
|
47 |
+
$( '#bp-groups-new-members' ).val( '' ).val( users_to_add.join( ', ' ) );
|
48 |
+
}
|
49 |
+
|
50 |
window.warn_on_leave = false;
|
51 |
});
|
52 |
|
53 |
+
window.onbeforeunload = function() {
|
54 |
if ( window.warn_on_leave ) {
|
55 |
return BP_Group_Admin.warn_on_leave;
|
56 |
}
|
@@ -1 +1,2 @@
|
|
1 |
-
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
!function(a){function b(b,c){a("#bp-groups-new-members-list").append('<li data-login="'+c.item.value+'"><a href="#" class="bp-groups-remove-new-member">x</a> '+c.item.label+"</li>")}var c="undefined"!=typeof group_id?"&group_id="+group_id:"";a(document).ready(function(){window.warn_on_leave=!1,a(".bp-suggest-user").autocomplete({source:ajaxurl+"?action=bp_group_admin_member_autocomplete"+c,delay:500,minLength:2,position:"undefined"!=typeof isRtl&&isRtl?{my:"right top",at:"right bottom",offset:"0, -1"}:{offset:"0, -1"},open:function(){a(this).addClass("open")},close:function(){a(this).removeClass("open"),a(this).val("")},select:function(a,c){b(a,c)}}),a("#bp-groups-new-members").prop("placeholder",BP_Group_Admin.add_member_placeholder),a("#bp_group_add_members").on("click",".bp-groups-remove-new-member",function(b){b.preventDefault(),a(b.target.parentNode).remove()}),a(document).on("change",'input#bp-groups-name, input#bp-groups-description, select.bp-groups-role, #bp-groups-settings-section-status input[type="radio"]',function(){window.warn_on_leave=!0}),a("input#save").on("click",function(){var b=[];a("#bp-groups-new-members-list li").each(function(){b.push(a(this).data("login"))}),b.length&&a("#bp-groups-new-members").val("").val(b.join(", ")),window.warn_on_leave=!1}),window.onbeforeunload=function(){return window.warn_on_leave?BP_Group_Admin.warn_on_leave:void 0}})}(jQuery);
|
@@ -14,6 +14,83 @@
|
|
14 |
// Exit if accessed directly
|
15 |
if ( !defined( 'ABSPATH' ) ) exit;
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
/**
|
18 |
* Catch and process group creation form submissions.
|
19 |
*/
|
@@ -229,9 +306,9 @@ function groups_action_create_group() {
|
|
229 |
// Normally we would check a nonce here, but the group save nonce is used instead
|
230 |
|
231 |
if ( !bp_core_avatar_handle_crop( array( 'object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
|
232 |
-
bp_core_add_message( __( 'There was an error saving the group
|
233 |
else
|
234 |
-
bp_core_add_message( __( 'The group
|
235 |
}
|
236 |
}
|
237 |
|
14 |
// Exit if accessed directly
|
15 |
if ( !defined( 'ABSPATH' ) ) exit;
|
16 |
|
17 |
+
/**
|
18 |
+
* Protect access to single groups.
|
19 |
+
*
|
20 |
+
* @since BuddyPress (2.1.0)
|
21 |
+
*/
|
22 |
+
function bp_groups_group_access_protection() {
|
23 |
+
if ( ! bp_is_group() ) {
|
24 |
+
return;
|
25 |
+
}
|
26 |
+
|
27 |
+
$current_group = groups_get_current_group();
|
28 |
+
$user_has_access = $current_group->user_has_access;
|
29 |
+
$no_access_args = array();
|
30 |
+
|
31 |
+
if ( ! $user_has_access && 'hidden' !== $current_group->status ) {
|
32 |
+
// Always allow access to home and request-membership
|
33 |
+
if ( bp_is_current_action( 'home' ) || bp_is_current_action( 'request-membership' ) ) {
|
34 |
+
$user_has_access = true;
|
35 |
+
|
36 |
+
// User doesn't have access, so set up redirect args
|
37 |
+
} else if ( is_user_logged_in() ) {
|
38 |
+
$no_access_args = array(
|
39 |
+
'message' => __( 'You do not have access to this group.', 'buddypress' ),
|
40 |
+
'root' => bp_get_group_permalink( $current_group ) . 'home/',
|
41 |
+
'redirect' => false
|
42 |
+
);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
// Protect the admin tab from non-admins
|
47 |
+
if ( bp_is_current_action( 'admin' ) && ! bp_is_item_admin() ) {
|
48 |
+
$user_has_access = false;
|
49 |
+
$no_access_args = array(
|
50 |
+
'message' => __( 'You are not an admin of this group.', 'buddypress' ),
|
51 |
+
'root' => bp_get_group_permalink( $current_group ),
|
52 |
+
'redirect' => false
|
53 |
+
);
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Allow plugins to filter whether the current user has access to this group content.
|
58 |
+
*
|
59 |
+
* Note that if a plugin sets $user_has_access to false, it may also
|
60 |
+
* want to change the $no_access_args, to avoid problems such as
|
61 |
+
* logged-in users being redirected to wp-login.php.
|
62 |
+
*
|
63 |
+
* @since BuddyPress (2.1.0)
|
64 |
+
*
|
65 |
+
* @param bool $user_has_access True if the user has access to the
|
66 |
+
* content, otherwise false.
|
67 |
+
* @param array $no_access_args Arguments to be passed to
|
68 |
+
* bp_core_no_access() in case of no access. Note that this
|
69 |
+
* value is passed by reference, so it can be modified by the
|
70 |
+
* filter callback.
|
71 |
+
*/
|
72 |
+
$user_has_access = apply_filters_ref_array( 'bp_group_user_has_access', array( $user_has_access, &$no_access_args ) );
|
73 |
+
|
74 |
+
// If user has access, we return rather than redirect
|
75 |
+
if ( $user_has_access ) {
|
76 |
+
return;
|
77 |
+
}
|
78 |
+
|
79 |
+
// Hidden groups should return a 404 for non-members.
|
80 |
+
// Unset the current group so that you're not redirected
|
81 |
+
// to the default group tab
|
82 |
+
if ( 'hidden' == $current_group->status ) {
|
83 |
+
buddypress()->groups->current_group = 0;
|
84 |
+
buddypress()->is_single_item = false;
|
85 |
+
bp_do_404();
|
86 |
+
return;
|
87 |
+
} else {
|
88 |
+
bp_core_no_access( $no_access_args );
|
89 |
+
}
|
90 |
+
|
91 |
+
}
|
92 |
+
add_action( 'bp_actions', 'bp_groups_group_access_protection' );
|
93 |
+
|
94 |
/**
|
95 |
* Catch and process group creation form submissions.
|
96 |
*/
|
306 |
// Normally we would check a nonce here, but the group save nonce is used instead
|
307 |
|
308 |
if ( !bp_core_avatar_handle_crop( array( 'object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
|
309 |
+
bp_core_add_message( __( 'There was an error saving the group profile photo, please try uploading again.', 'buddypress' ), 'error' );
|
310 |
else
|
311 |
+
bp_core_add_message( __( 'The group profile photo was uploaded successfully!', 'buddypress' ) );
|
312 |
}
|
313 |
}
|
314 |
|
@@ -17,7 +17,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|
17 |
* Register activity actions for the Groups component.
|
18 |
*/
|
19 |
function groups_register_activity_actions() {
|
20 |
-
|
21 |
|
22 |
if ( ! bp_is_active( 'activity' ) ) {
|
23 |
return false;
|
@@ -27,22 +27,41 @@ function groups_register_activity_actions() {
|
|
27 |
$bp->groups->id,
|
28 |
'created_group',
|
29 |
__( 'Created a group', 'buddypress' ),
|
30 |
-
'bp_groups_format_activity_action_created_group'
|
|
|
|
|
31 |
);
|
32 |
|
33 |
bp_activity_set_action(
|
34 |
$bp->groups->id,
|
35 |
'joined_group',
|
36 |
__( 'Joined a group', 'buddypress' ),
|
37 |
-
'bp_groups_format_activity_action_joined_group'
|
|
|
|
|
38 |
);
|
39 |
|
40 |
// These actions are for the legacy forums
|
41 |
// Since the bbPress plugin also shares the same 'forums' identifier, we also
|
42 |
// check for the legacy forums loader class to be extra cautious
|
43 |
if ( bp_is_active( 'forums' ) && class_exists( 'BP_Forums_Component' ) ) {
|
44 |
-
bp_activity_set_action(
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
}
|
47 |
|
48 |
do_action( 'groups_register_activity_actions' );
|
@@ -144,7 +163,8 @@ function bp_groups_prefetch_activity_object_data( $activities ) {
|
|
144 |
}
|
145 |
|
146 |
if ( ! empty( $uncached_ids ) ) {
|
147 |
-
global $wpdb
|
|
|
148 |
$uncached_ids_sql = implode( ',', wp_parse_id_list( $uncached_ids ) );
|
149 |
$groups = $wpdb->get_results( "SELECT * FROM {$bp->groups->table_name} WHERE id IN ({$uncached_ids_sql})" );
|
150 |
foreach ( $groups as $group ) {
|
17 |
* Register activity actions for the Groups component.
|
18 |
*/
|
19 |
function groups_register_activity_actions() {
|
20 |
+
$bp = buddypress();
|
21 |
|
22 |
if ( ! bp_is_active( 'activity' ) ) {
|
23 |
return false;
|
27 |
$bp->groups->id,
|
28 |
'created_group',
|
29 |
__( 'Created a group', 'buddypress' ),
|
30 |
+
'bp_groups_format_activity_action_created_group',
|
31 |
+
__( 'New Groups', 'buddypress' ),
|
32 |
+
array( 'activity', 'member', 'member_groups' )
|
33 |
);
|
34 |
|
35 |
bp_activity_set_action(
|
36 |
$bp->groups->id,
|
37 |
'joined_group',
|
38 |
__( 'Joined a group', 'buddypress' ),
|
39 |
+
'bp_groups_format_activity_action_joined_group',
|
40 |
+
__( 'Group Memberships', 'buddypress' ),
|
41 |
+
array( 'activity', 'group', 'member', 'member_groups' )
|
42 |
);
|
43 |
|
44 |
// These actions are for the legacy forums
|
45 |
// Since the bbPress plugin also shares the same 'forums' identifier, we also
|
46 |
// check for the legacy forums loader class to be extra cautious
|
47 |
if ( bp_is_active( 'forums' ) && class_exists( 'BP_Forums_Component' ) ) {
|
48 |
+
bp_activity_set_action(
|
49 |
+
$bp->groups->id,
|
50 |
+
'new_forum_topic',
|
51 |
+
__( 'New group forum topic', 'buddypress' ),
|
52 |
+
false,
|
53 |
+
__( 'Forum Topics', 'buddypress' ),
|
54 |
+
array( 'activity', 'group', 'member', 'member_groups' )
|
55 |
+
);
|
56 |
+
|
57 |
+
bp_activity_set_action(
|
58 |
+
$bp->groups->id,
|
59 |
+
'new_forum_post',
|
60 |
+
__( 'New group forum post', 'buddypress' ),
|
61 |
+
false,
|
62 |
+
__( 'Forum Replies', 'buddypress' ),
|
63 |
+
array( 'activity', 'group', 'member', 'member_groups' )
|
64 |
+
);
|
65 |
}
|
66 |
|
67 |
do_action( 'groups_register_activity_actions' );
|
163 |
}
|
164 |
|
165 |
if ( ! empty( $uncached_ids ) ) {
|
166 |
+
global $wpdb;
|
167 |
+
$bp = buddypress();
|
168 |
$uncached_ids_sql = implode( ',', wp_parse_id_list( $uncached_ids ) );
|
169 |
$groups = $wpdb->get_results( "SELECT * FROM {$bp->groups->table_name} WHERE id IN ({$uncached_ids_sql})" );
|
170 |
foreach ( $groups as $group ) {
|
@@ -29,8 +29,8 @@ function bp_groups_add_admin_menu() {
|
|
29 |
|
30 |
// Add our screen
|
31 |
$hook = add_menu_page(
|
32 |
-
|
33 |
-
|
34 |
'bp_moderate',
|
35 |
'bp-groups',
|
36 |
'bp_groups_admin',
|
@@ -168,12 +168,17 @@ function bp_groups_admin_load() {
|
|
168 |
|
169 |
// Enqueue CSS and JavaScript
|
170 |
wp_enqueue_script( 'bp_groups_admin_js', $bp->plugin_url . "bp-groups/admin/js/admin.{$min}js", array( 'jquery', 'wp-ajax-response', 'jquery-ui-autocomplete' ), bp_get_version(), true );
|
171 |
-
wp_enqueue_style( 'bp_groups_admin_css', $bp->plugin_url . "bp-groups/admin/css/admin.{$min}css", array(), bp_get_version() );
|
172 |
-
|
173 |
wp_localize_script( 'bp_groups_admin_js', 'BP_Group_Admin', array(
|
174 |
'add_member_placeholder' => __( 'Start typing a username to add a new member.', 'buddypress' ),
|
175 |
'warn_on_leave' => __( 'If you leave this page, you will lose any unsaved changes you have made to the group.', 'buddypress' ),
|
176 |
) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
if ( $doaction && 'save' == $doaction ) {
|
179 |
// Get group ID
|
@@ -230,10 +235,6 @@ function bp_groups_admin_load() {
|
|
230 |
$user_names = array_merge( $user_names, explode( ',', $_POST['bp-groups-new-members'] ) );
|
231 |
}
|
232 |
|
233 |
-
if ( ! empty( $_POST['new_members'] ) ) {
|
234 |
-
$user_names = array_merge( $user_names, $_POST['new_members'] );
|
235 |
-
}
|
236 |
-
|
237 |
if ( ! empty( $user_names ) ) {
|
238 |
|
239 |
foreach( array_values( $user_names ) as $user_name ) {
|
@@ -503,7 +504,7 @@ function bp_groups_admin_edit() {
|
|
503 |
|
504 |
<?php // If the user has just made a change to an group, display the status messages ?>
|
505 |
<?php if ( !empty( $messages ) ) : ?>
|
506 |
-
<div id="moderated" class="<?php echo ( $is_error ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "
|
507 |
<?php endif; ?>
|
508 |
|
509 |
<?php if ( ! empty( $group ) ) : ?>
|
@@ -518,6 +519,10 @@ function bp_groups_admin_edit() {
|
|
518 |
<h3><?php _e( 'Name and Description', 'buddypress' ); ?></h3>
|
519 |
<div class="inside">
|
520 |
<input type="text" name="bp-groups-name" id="bp-groups-name" value="<?php echo esc_attr( stripslashes( $group_name ) ) ?>" />
|
|
|
|
|
|
|
|
|
521 |
|
522 |
<?php wp_editor( stripslashes( $group->description ), 'bp-groups-description', array( 'media_buttons' => false, 'teeny' => true, 'textarea_rows' => 5, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ) ) ); ?>
|
523 |
</div>
|
@@ -560,8 +565,9 @@ function bp_groups_admin_edit() {
|
|
560 |
*/
|
561 |
function bp_groups_admin_delete() {
|
562 |
|
563 |
-
if ( !
|
564 |
die( '-1' );
|
|
|
565 |
|
566 |
$group_ids = isset( $_REQUEST['gid'] ) ? $_REQUEST['gid'] : 0;
|
567 |
if ( ! is_array( $group_ids ) ) {
|
@@ -731,7 +737,6 @@ function bp_groups_admin_edit_metabox_add_new_members( $item ) {
|
|
731 |
* group.
|
732 |
*/
|
733 |
function bp_groups_admin_edit_metabox_members( $item ) {
|
734 |
-
global $members_template;
|
735 |
|
736 |
// Pull up a list of group members, so we can separate out the types
|
737 |
// We'll also keep track of group members here to place them into a
|
@@ -751,7 +756,7 @@ function bp_groups_admin_edit_metabox_members( $item ) {
|
|
751 |
);
|
752 |
|
753 |
foreach ( $members as $type => &$member_type_users ) {
|
754 |
-
$page_qs_key
|
755 |
$current_type_page = isset( $_GET[ $page_qs_key ] ) ? absint( $_GET[ $page_qs_key ] ) : 1;
|
756 |
$member_type_query = new BP_Group_Member_Query( array(
|
757 |
'group_id' => $item->id,
|
@@ -761,27 +766,24 @@ function bp_groups_admin_edit_metabox_members( $item ) {
|
|
761 |
'page' => $current_type_page,
|
762 |
) );
|
763 |
|
764 |
-
$member_type_users
|
765 |
-
|
766 |
$pagination[ $type ] = bp_groups_admin_create_pagination_links( $member_type_query, $type );
|
767 |
}
|
768 |
|
769 |
// Echo out the javascript variable
|
770 |
-
echo '<script type="text/javascript">var group_id = "' . $item->id . '";</script>';
|
771 |
|
772 |
// Loop through each member type
|
773 |
foreach ( $members as $member_type => $type_users ) : ?>
|
774 |
|
775 |
<div class="bp-groups-member-type" id="bp-groups-member-type-<?php echo esc_attr( $member_type ) ?>">
|
776 |
|
777 |
-
<h4
|
778 |
-
|
779 |
-
case '
|
780 |
-
case '
|
781 |
-
case '
|
782 |
-
|
783 |
-
endswitch; ?>
|
784 |
-
</h4>
|
785 |
|
786 |
<div class="bp-group-admin-pagination table-top">
|
787 |
<?php echo $pagination[ $member_type ] ?>
|
@@ -791,11 +793,11 @@ function bp_groups_admin_edit_metabox_members( $item ) {
|
|
791 |
|
792 |
<table class="widefat bp-group-members">
|
793 |
<thead>
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
</thead>
|
800 |
|
801 |
<tbody>
|
@@ -811,16 +813,25 @@ function bp_groups_admin_edit_metabox_members( $item ) {
|
|
811 |
'height' => '32'
|
812 |
) ); ?></a>
|
813 |
|
814 |
-
<span style="margin: 8px; float: left;"><?php echo bp_core_get_userlink( $type_user->ID ) ?></span>
|
815 |
</td>
|
816 |
|
817 |
<td class="urole-column">
|
818 |
<select class="bp-groups-role" id="bp-groups-role-<?php echo esc_attr( $type_user->ID ); ?>" name="bp-groups-role[<?php echo esc_attr( $type_user->ID ); ?>]">
|
819 |
-
<
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
824 |
</select>
|
825 |
|
826 |
<?php
|
@@ -829,7 +840,8 @@ function bp_groups_admin_edit_metabox_members( $item ) {
|
|
829 |
* so we can easily detect changes.
|
830 |
*
|
831 |
* @todo remove this, and do database detection on save
|
832 |
-
*/
|
|
|
833 |
<input type="hidden" name="bp-groups-existing-role[<?php echo esc_attr( $type_user->ID ); ?>]" value="<?php echo esc_attr( $member_type ); ?>" />
|
834 |
</td>
|
835 |
</tr>
|
@@ -848,19 +860,18 @@ function bp_groups_admin_edit_metabox_members( $item ) {
|
|
848 |
</table>
|
849 |
|
850 |
<div class="bp-group-admin-pagination table-bottom">
|
851 |
-
<?php echo $pagination[ $member_type ] ?>
|
852 |
</div>
|
853 |
|
854 |
<?php else : ?>
|
855 |
|
856 |
-
<p class="bp-groups-no-members description"><?php
|
857 |
|
858 |
<?php endif; ?>
|
859 |
|
860 |
</div><!-- .bp-groups-member-type -->
|
861 |
|
862 |
<?php endforeach;
|
863 |
-
|
864 |
}
|
865 |
|
866 |
/**
|
@@ -939,10 +950,10 @@ function bp_groups_admin_create_pagination_links( BP_Group_Member_Query $query,
|
|
939 |
) );
|
940 |
|
941 |
$viewing_text = sprintf(
|
942 |
-
|
943 |
number_format_i18n( $current_page_start ),
|
944 |
number_format_i18n( $current_page_end ),
|
945 |
-
|
946 |
);
|
947 |
|
948 |
$pagination .= '<span class="bp-group-admin-pagination-viewing">' . $viewing_text . '</span>';
|
@@ -979,41 +990,38 @@ function bp_groups_admin_get_usernames_from_ids( $user_ids = array() ) {
|
|
979 |
function bp_groups_admin_autocomplete_handler() {
|
980 |
|
981 |
// Bail if user user shouldn't be here, or is a large network
|
982 |
-
if ( ! current_user_can( 'bp_moderate' ) || ( is_multisite() && wp_is_large_network( 'users' ) ) )
|
983 |
wp_die( -1 );
|
|
|
984 |
|
985 |
-
$
|
|
|
|
|
|
|
|
|
|
|
986 |
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
'
|
991 |
-
'
|
992 |
-
'group_role' => array( 'member', 'mod', 'admin', ),
|
993 |
-
'populate_extras' => false,
|
994 |
-
'count_total' => false,
|
995 |
) );
|
996 |
|
997 |
-
$
|
998 |
|
999 |
-
$
|
1000 |
-
|
1001 |
-
'type' => 'alphabetical',
|
1002 |
-
'search_terms' => $terms,
|
1003 |
-
'exclude' => $group_members,
|
1004 |
-
'per_page' => 10,
|
1005 |
-
'populate_extras' => false
|
1006 |
-
) );
|
1007 |
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
}
|
1015 |
|
1016 |
-
wp_die( json_encode( $
|
1017 |
}
|
1018 |
add_action( 'wp_ajax_bp_group_admin_member_autocomplete', 'bp_groups_admin_autocomplete_handler' );
|
1019 |
|
@@ -1069,7 +1077,7 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1069 |
*
|
1070 |
* @since BuddyPress (1.7.0)
|
1071 |
*/
|
1072 |
-
function prepare_items() {
|
1073 |
global $groups_template;
|
1074 |
|
1075 |
$screen = get_current_screen();
|
@@ -1176,7 +1184,7 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1176 |
*
|
1177 |
* @return array Array of column headers.
|
1178 |
*/
|
1179 |
-
function get_column_info() {
|
1180 |
$this->_column_headers = array(
|
1181 |
$this->get_columns(),
|
1182 |
array(),
|
@@ -1191,7 +1199,7 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1191 |
*
|
1192 |
* @since BuddyPress (1.7.0)
|
1193 |
*/
|
1194 |
-
function no_items() {
|
1195 |
_e( 'No groups found.', 'buddypress' );
|
1196 |
}
|
1197 |
|
@@ -1200,9 +1208,7 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1200 |
*
|
1201 |
* @since BuddyPress (1.7.0)
|
1202 |
*/
|
1203 |
-
function display() {
|
1204 |
-
extract( $this->_args );
|
1205 |
-
|
1206 |
$this->display_tablenav( 'top' ); ?>
|
1207 |
|
1208 |
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
|
@@ -1234,7 +1240,7 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1234 |
*
|
1235 |
* @param object $item The current group item in the loop.
|
1236 |
*/
|
1237 |
-
function single_row( $item = array() ) {
|
1238 |
static $even = false;
|
1239 |
|
1240 |
$row_classes = array();
|
@@ -1260,7 +1266,7 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1260 |
*
|
1261 |
* @since BuddyPress (1.7.0)
|
1262 |
*/
|
1263 |
-
function get_views() {
|
1264 |
$url_base = bp_get_admin_url( 'admin.php?page=bp-groups' ); ?>
|
1265 |
|
1266 |
<ul class="subsubsub">
|
@@ -1281,7 +1287,7 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1281 |
*
|
1282 |
* @return array Key/value pairs for the bulk actions dropdown.
|
1283 |
*/
|
1284 |
-
function get_bulk_actions() {
|
1285 |
return apply_filters( 'bp_groups_list_table_get_bulk_actions', array(
|
1286 |
'delete' => __( 'Delete', 'buddypress' )
|
1287 |
) );
|
@@ -1296,7 +1302,7 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1296 |
*
|
1297 |
* @return array Array of column titles.
|
1298 |
*/
|
1299 |
-
function get_columns() {
|
1300 |
return apply_filters( 'bp_groups_list_table_get_columns', array(
|
1301 |
'cb' => '<input name type="checkbox" />',
|
1302 |
'comment' => _x( 'Name', 'Groups admin Group Name column header', 'buddypress' ),
|
@@ -1323,7 +1329,7 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1323 |
*
|
1324 |
* @return array Array of sortable column names.
|
1325 |
*/
|
1326 |
-
function get_sortable_columns() {
|
1327 |
return array(
|
1328 |
'gid' => array( 'gid', false ),
|
1329 |
'comment' => array( 'name', false ),
|
@@ -1341,7 +1347,7 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1341 |
*
|
1342 |
* @param array $item A singular item (one full row).
|
1343 |
*/
|
1344 |
-
function column_cb( $item = array() ) {
|
1345 |
printf( '<label class="screen-reader-text" for="gid-%1$d">' . __( 'Select group %1$d', 'buddypress' ) . '</label><input type="checkbox" name="gid[]" value="%1$d" id="gid-%1$d" />', $item['id'] );
|
1346 |
}
|
1347 |
|
@@ -1354,8 +1360,8 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1354 |
*
|
1355 |
* @param array $item A singular item (one full row).
|
1356 |
*/
|
1357 |
-
function column_gid( $item = array() ) {
|
1358 |
-
echo '<strong>' . $item['id'] . '</strong>';
|
1359 |
}
|
1360 |
|
1361 |
/**
|
@@ -1369,13 +1375,13 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1369 |
*
|
1370 |
* @param array $item A singular item (one full row).
|
1371 |
*/
|
1372 |
-
function column_comment( $item = array() ) {
|
1373 |
|
1374 |
-
// Preorder items:
|
1375 |
$actions = array(
|
1376 |
-
'visit' => '',
|
1377 |
'edit' => '',
|
1378 |
'delete' => '',
|
|
|
1379 |
);
|
1380 |
|
1381 |
// We need the group object for some BP functions
|
@@ -1385,35 +1391,40 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1385 |
$base_url = bp_get_admin_url( 'admin.php?page=bp-groups&gid=' . $item['id'] );
|
1386 |
$delete_url = wp_nonce_url( $base_url . "&action=delete", 'bp-groups-delete' );
|
1387 |
$edit_url = $base_url . '&action=edit';
|
1388 |
-
$
|
|
|
1389 |
|
1390 |
// Rollover actions
|
1391 |
|
1392 |
-
// Visit
|
1393 |
-
$actions['visit'] = sprintf( '<a href="%s">%s</a>', esc_url( $visit_url ), __( 'Visit', 'buddypress' ) );
|
1394 |
-
|
1395 |
// Edit
|
1396 |
-
$actions['edit']
|
1397 |
|
1398 |
// Delete
|
1399 |
$actions['delete'] = sprintf( '<a href="%s">%s</a>', esc_url( $delete_url ), __( 'Delete', 'buddypress' ) );
|
1400 |
|
|
|
|
|
|
|
1401 |
// Other plugins can filter which actions are shown
|
1402 |
$actions = apply_filters( 'bp_groups_admin_comment_row_actions', array_filter( $actions ), $item );
|
1403 |
|
1404 |
// Get group name and avatar
|
1405 |
-
$avatar
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
|
|
|
|
|
|
|
|
1415 |
|
1416 |
-
$content =
|
1417 |
|
1418 |
echo $avatar . ' ' . $content . ' ' . $this->row_actions( $actions );
|
1419 |
}
|
@@ -1425,7 +1436,7 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1425 |
*
|
1426 |
* @param array Information about the current row.
|
1427 |
*/
|
1428 |
-
function column_description( $item = array() ) {
|
1429 |
echo apply_filters_ref_array( 'bp_get_group_description', array( $item['description'], $item ) );
|
1430 |
}
|
1431 |
|
@@ -1436,7 +1447,7 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1436 |
*
|
1437 |
* @param array Information about the current row.
|
1438 |
*/
|
1439 |
-
function column_status( $item = array() ) {
|
1440 |
$status = $item['status'];
|
1441 |
$status_desc = '';
|
1442 |
|
@@ -1464,7 +1475,7 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1464 |
*
|
1465 |
* @param array Information about the current row.
|
1466 |
*/
|
1467 |
-
function column_members( $item = array() ) {
|
1468 |
$count = groups_get_groupmeta( $item['id'], 'total_member_count' );
|
1469 |
echo apply_filters_ref_array( 'bp_groups_admin_get_group_member_count', array( (int) $count, $item ) );
|
1470 |
}
|
@@ -1476,7 +1487,7 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1476 |
*
|
1477 |
* @param array Information about the current row.
|
1478 |
*/
|
1479 |
-
function column_last_active( $item = array() ) {
|
1480 |
$last_active = groups_get_groupmeta( $item['id'], 'last_activity' );
|
1481 |
echo apply_filters_ref_array( 'bp_groups_admin_get_group_last_active', array( $last_active, $item ) );
|
1482 |
}
|
@@ -1489,7 +1500,7 @@ class BP_Groups_List_Table extends WP_List_Table {
|
|
1489 |
* @param array Information about the current row.
|
1490 |
* @param string the column name.
|
1491 |
*/
|
1492 |
-
function column_default( $item = array(), $column_name = '' ) {
|
1493 |
return apply_filters( 'bp_groups_admin_get_group_custom_column', '', $column_name, $item );
|
1494 |
}
|
1495 |
}
|
29 |
|
30 |
// Add our screen
|
31 |
$hook = add_menu_page(
|
32 |
+
_x( 'Groups', 'Admin Groups page title', 'buddypress' ),
|
33 |
+
_x( 'Groups', 'Admin Groups menu', 'buddypress' ),
|
34 |
'bp_moderate',
|
35 |
'bp-groups',
|
36 |
'bp_groups_admin',
|
168 |
|
169 |
// Enqueue CSS and JavaScript
|
170 |
wp_enqueue_script( 'bp_groups_admin_js', $bp->plugin_url . "bp-groups/admin/js/admin.{$min}js", array( 'jquery', 'wp-ajax-response', 'jquery-ui-autocomplete' ), bp_get_version(), true );
|
|
|
|
|
171 |
wp_localize_script( 'bp_groups_admin_js', 'BP_Group_Admin', array(
|
172 |
'add_member_placeholder' => __( 'Start typing a username to add a new member.', 'buddypress' ),
|
173 |
'warn_on_leave' => __( 'If you leave this page, you will lose any unsaved changes you have made to the group.', 'buddypress' ),
|
174 |
) );
|
175 |
+
wp_enqueue_style( 'bp_groups_admin_css', $bp->plugin_url . "bp-groups/admin/css/admin.{$min}css", array(), bp_get_version() );
|
176 |
+
|
177 |
+
wp_style_add_data( 'bp_groups_admin_css', 'rtl', true );
|
178 |
+
if ( $min ) {
|
179 |
+
wp_style_add_data( 'bp_groups_admin_css', 'suffix', $min );
|
180 |
+
}
|
181 |
+
|
182 |
|
183 |
if ( $doaction && 'save' == $doaction ) {
|
184 |
// Get group ID
|
235 |
$user_names = array_merge( $user_names, explode( ',', $_POST['bp-groups-new-members'] ) );
|
236 |
}
|
237 |
|
|
|
|
|
|
|
|
|
238 |
if ( ! empty( $user_names ) ) {
|
239 |
|
240 |
foreach( array_values( $user_names ) as $user_name ) {
|
504 |
|
505 |
<?php // If the user has just made a change to an group, display the status messages ?>
|
506 |
<?php if ( !empty( $messages ) ) : ?>
|
507 |
+
<div id="moderated" class="<?php echo ( $is_error ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "</p><p>", $messages ); ?></p></div>
|
508 |
<?php endif; ?>
|
509 |
|
510 |
<?php if ( ! empty( $group ) ) : ?>
|
519 |
<h3><?php _e( 'Name and Description', 'buddypress' ); ?></h3>
|
520 |
<div class="inside">
|
521 |
<input type="text" name="bp-groups-name" id="bp-groups-name" value="<?php echo esc_attr( stripslashes( $group_name ) ) ?>" />
|
522 |
+
<div id="bp-groups-permalink-box">
|
523 |
+
<strong><?php esc_html_e( 'Permalink:', 'buddypress' ) ?></strong> <span id="sample-permalink"><?php bp_group_permalink( $group ) ?></span> <a href="<?php echo bp_group_permalink( $group ) ?>" class="button button-small" id="bp-groups-visit-group"><?php esc_html_e( 'Visit Group', 'buddypress' ) ?></a>
|
524 |
+
</div>
|
525 |
+
|
526 |
|
527 |
<?php wp_editor( stripslashes( $group->description ), 'bp-groups-description', array( 'media_buttons' => false, 'teeny' => true, 'textarea_rows' => 5, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ) ) ); ?>
|
528 |
</div>
|
565 |
*/
|
566 |
function bp_groups_admin_delete() {
|
567 |
|
568 |
+
if ( ! bp_current_user_can( 'bp_moderate' ) ) {
|
569 |
die( '-1' );
|
570 |
+
}
|
571 |
|
572 |
$group_ids = isset( $_REQUEST['gid'] ) ? $_REQUEST['gid'] : 0;
|
573 |
if ( ! is_array( $group_ids ) ) {
|
737 |
* group.
|
738 |
*/
|
739 |
function bp_groups_admin_edit_metabox_members( $item ) {
|
|
|
740 |
|
741 |
// Pull up a list of group members, so we can separate out the types
|
742 |
// We'll also keep track of group members here to place them into a
|
756 |
);
|
757 |
|
758 |
foreach ( $members as $type => &$member_type_users ) {
|
759 |
+
$page_qs_key = $type . '_page';
|
760 |
$current_type_page = isset( $_GET[ $page_qs_key ] ) ? absint( $_GET[ $page_qs_key ] ) : 1;
|
761 |
$member_type_query = new BP_Group_Member_Query( array(
|
762 |
'group_id' => $item->id,
|
766 |
'page' => $current_type_page,
|
767 |
) );
|
768 |
|
769 |
+
$member_type_users = $member_type_query->results;
|
|
|
770 |
$pagination[ $type ] = bp_groups_admin_create_pagination_links( $member_type_query, $type );
|
771 |
}
|
772 |
|
773 |
// Echo out the javascript variable
|
774 |
+
echo '<script type="text/javascript">var group_id = "' . esc_js( $item->id ) . '";</script>';
|
775 |
|
776 |
// Loop through each member type
|
777 |
foreach ( $members as $member_type => $type_users ) : ?>
|
778 |
|
779 |
<div class="bp-groups-member-type" id="bp-groups-member-type-<?php echo esc_attr( $member_type ) ?>">
|
780 |
|
781 |
+
<h4><?php switch ( $member_type ) :
|
782 |
+
case 'admin' : esc_html_e( 'Administrators', 'buddypress' ); break;
|
783 |
+
case 'mod' : esc_html_e( 'Moderators', 'buddypress' ); break;
|
784 |
+
case 'member' : esc_html_e( 'Members', 'buddypress' ); break;
|
785 |
+
case 'banned' : esc_html_e( 'Banned Members', 'buddypress' ); break;
|
786 |
+
endswitch; ?></h4>
|
|
|
|
|
787 |
|
788 |
<div class="bp-group-admin-pagination table-top">
|
789 |
<?php echo $pagination[ $member_type ] ?>
|
793 |
|
794 |
<table class="widefat bp-group-members">
|
795 |
<thead>
|
796 |
+
<tr>
|
797 |
+
<th scope="col" class="uid-column"><?php _ex( 'ID', 'Group member user_id in group admin', 'buddypress' ); ?></th>
|
798 |
+
<th scope="col" class="uname-column"><?php _ex( 'Name', 'Group member name in group admin', 'buddypress' ); ?></th>
|
799 |
+
<th scope="col" class="urole-column"><?php _ex( 'Group Role', 'Group member role in group admin', 'buddypress' ); ?></th>
|
800 |
+
</tr>
|
801 |
</thead>
|
802 |
|
803 |
<tbody>
|
813 |
'height' => '32'
|
814 |
) ); ?></a>
|
815 |
|
816 |
+
<span style="margin: 8px; float: left;"><?php echo bp_core_get_userlink( $type_user->ID ); ?></span>
|
817 |
</td>
|
818 |
|
819 |
<td class="urole-column">
|
820 |
<select class="bp-groups-role" id="bp-groups-role-<?php echo esc_attr( $type_user->ID ); ?>" name="bp-groups-role[<?php echo esc_attr( $type_user->ID ); ?>]">
|
821 |
+
<optgroup label="<?php esc_attr_e( 'Roles', 'buddypress' ); ?>">
|
822 |
+
<option class="admin" value="admin" <?php selected( 'admin', $member_type ); ?>><?php esc_html_e( 'Administrator', 'buddypress' ); ?></option>
|
823 |
+
<option class="mod" value="mod" <?php selected( 'mod', $member_type ); ?>><?php esc_html_e( 'Moderator', 'buddypress' ); ?></option>
|
824 |
+
<option class="member" value="member" <?php selected( 'member', $member_type ); ?>><?php esc_html_e( 'Member', 'buddypress' ); ?></option>
|
825 |
+
<?php if ( 'banned' === $member_type ) : ?>
|
826 |
+
<option class="banned" value="banned" <?php selected( 'banned', $member_type ); ?>><?php esc_html_e( 'Banned', 'buddypress' ); ?></option>
|
827 |
+
<?php endif; ?>
|
828 |
+
</optgroup>
|
829 |
+
<optgroup label="<?php esc_attr_e( 'Actions', 'buddypress' ); ?>">
|
830 |
+
<option class="remove" value="remove"><?php esc_html_e( 'Remove', 'buddypress' ); ?></option>
|
831 |
+
<?php if ( 'banned' !== $member_type ) : ?>
|
832 |
+
<option class="banned" value="banned"><?php esc_html_e( 'Ban', 'buddypress' ); ?></option>
|
833 |
+
<?php endif; ?>
|
834 |
+
</optgroup>
|
835 |
</select>
|
836 |
|
837 |
<?php
|
840 |
* so we can easily detect changes.
|
841 |
*
|
842 |
* @todo remove this, and do database detection on save
|
843 |
+
*/
|
844 |
+
?>
|
845 |
<input type="hidden" name="bp-groups-existing-role[<?php echo esc_attr( $type_user->ID ); ?>]" value="<?php echo esc_attr( $member_type ); ?>" />
|
846 |
</td>
|
847 |
</tr>
|
860 |
</table>
|
861 |
|
862 |
<div class="bp-group-admin-pagination table-bottom">
|
863 |
+
<?php echo $pagination[ $member_type ]; ?>
|
864 |
</div>
|
865 |
|
866 |
<?php else : ?>
|
867 |
|
868 |
+
<p class="bp-groups-no-members description"><?php esc_html_e( 'No members of this type', 'buddypress' ); ?></p>
|
869 |
|
870 |
<?php endif; ?>
|
871 |
|
872 |
</div><!-- .bp-groups-member-type -->
|
873 |
|
874 |
<?php endforeach;
|
|
|
875 |
}
|
876 |
|
877 |
/**
|
950 |
) );
|
951 |
|
952 |
$viewing_text = sprintf(
|
953 |
+
_n( 'Viewing 1 member', 'Viewing %1$s - %2$s of %3$s members', $query->total_users, 'buddypress' ),
|
954 |
number_format_i18n( $current_page_start ),
|
955 |
number_format_i18n( $current_page_end ),
|
956 |
+
(int) $query->total_users
|
957 |
);
|
958 |
|
959 |
$pagination .= '<span class="bp-group-admin-pagination-viewing">' . $viewing_text . '</span>';
|
990 |
function bp_groups_admin_autocomplete_handler() {
|
991 |
|
992 |
// Bail if user user shouldn't be here, or is a large network
|
993 |
+
if ( ! current_user_can( 'bp_moderate' ) || ( is_multisite() && wp_is_large_network( 'users' ) ) ) {
|
994 |
wp_die( -1 );
|
995 |
+
}
|
996 |
|
997 |
+
$term = isset( $_GET['term'] ) ? sanitize_text_field( $_GET['term'] ) : '';
|
998 |
+
$group_id = isset( $_GET['group_id'] ) ? absint( $_GET['group_id'] ) : 0;
|
999 |
+
|
1000 |
+
if ( ! $term || ! $group_id ) {
|
1001 |
+
wp_die( -1 );
|
1002 |
+
}
|
1003 |
|
1004 |
+
$suggestions = bp_core_get_suggestions( array(
|
1005 |
+
'group_id' => -$group_id, // A negative value will exclude this group's members from the suggestions.
|
1006 |
+
'limit' => 10,
|
1007 |
+
'term' => $term,
|
1008 |
+
'type' => 'members',
|
|
|
|
|
|
|
1009 |
) );
|
1010 |
|
1011 |
+
$matches = array();
|
1012 |
|
1013 |
+
if ( $suggestions && ! is_wp_error( $suggestions ) ) {
|
1014 |
+
foreach ( $suggestions as $user ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
1015 |
|
1016 |
+
$matches[] = array(
|
1017 |
+
// translators: 1: user_login, 2: user_email
|
1018 |
+
'label' => sprintf( __( '%1$s (%2$s)', 'buddypress' ), $user->name, $user->ID ),
|
1019 |
+
'value' => $user->ID,
|
1020 |
+
);
|
1021 |
+
}
|
1022 |
}
|
1023 |
|
1024 |
+
wp_die( json_encode( $matches ) );
|
1025 |
}
|
1026 |
add_action( 'wp_ajax_bp_group_admin_member_autocomplete', 'bp_groups_admin_autocomplete_handler' );
|
1027 |
|
1077 |
*
|
1078 |
* @since BuddyPress (1.7.0)
|
1079 |
*/
|
1080 |
+
public function prepare_items() {
|
1081 |
global $groups_template;
|
1082 |
|
1083 |
$screen = get_current_screen();
|
1184 |
*
|
1185 |
* @return array Array of column headers.
|
1186 |
*/
|
1187 |
+
public function get_column_info() {
|
1188 |
$this->_column_headers = array(
|
1189 |
$this->get_columns(),
|
1190 |
array(),
|
1199 |
*
|
1200 |
* @since BuddyPress (1.7.0)
|
1201 |
*/
|
1202 |
+
public function no_items() {
|
1203 |
_e( 'No groups found.', 'buddypress' );
|
1204 |
}
|
1205 |
|
1208 |
*
|
1209 |
* @since BuddyPress (1.7.0)
|
1210 |
*/
|
1211 |
+
public function display() {
|
|
|
|
|
1212 |
$this->display_tablenav( 'top' ); ?>
|
1213 |
|
1214 |
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
|
1240 |
*
|
1241 |
* @param object $item The current group item in the loop.
|
1242 |
*/
|
1243 |
+
public function single_row( $item = array() ) {
|
1244 |
static $even = false;
|
1245 |
|
1246 |
$row_classes = array();
|
1266 |
*
|
1267 |
* @since BuddyPress (1.7.0)
|
1268 |
*/
|
1269 |
+
public function get_views() {
|
1270 |
$url_base = bp_get_admin_url( 'admin.php?page=bp-groups' ); ?>
|
1271 |
|
1272 |
<ul class="subsubsub">
|
1287 |
*
|
1288 |
* @return array Key/value pairs for the bulk actions dropdown.
|
1289 |
*/
|
1290 |
+
public function get_bulk_actions() {
|
1291 |
return apply_filters( 'bp_groups_list_table_get_bulk_actions', array(
|
1292 |
'delete' => __( 'Delete', 'buddypress' )
|
1293 |
) );
|
1302 |
*
|
1303 |
* @return array Array of column titles.
|
1304 |
*/
|
1305 |
+
public function get_columns() {
|
1306 |
return apply_filters( 'bp_groups_list_table_get_columns', array(
|
1307 |
'cb' => '<input name type="checkbox" />',
|
1308 |
'comment' => _x( 'Name', 'Groups admin Group Name column header', 'buddypress' ),
|
1329 |
*
|
1330 |
* @return array Array of sortable column names.
|
1331 |
*/
|
1332 |
+
public function get_sortable_columns() {
|
1333 |
return array(
|
1334 |
'gid' => array( 'gid', false ),
|
1335 |
'comment' => array( 'name', false ),
|
1347 |
*
|
1348 |
* @param array $item A singular item (one full row).
|
1349 |
*/
|
1350 |
+
public function column_cb( $item = array() ) {
|
1351 |
printf( '<label class="screen-reader-text" for="gid-%1$d">' . __( 'Select group %1$d', 'buddypress' ) . '</label><input type="checkbox" name="gid[]" value="%1$d" id="gid-%1$d" />', $item['id'] );
|
1352 |
}
|
1353 |
|
1360 |
*
|
1361 |
* @param array $item A singular item (one full row).
|
1362 |
*/
|
1363 |
+
public function column_gid( $item = array() ) {
|
1364 |
+
echo '<strong>' . absint( $item['id'] ) . '</strong>';
|
1365 |
}
|
1366 |
|
1367 |
/**
|
1375 |
*
|
1376 |
* @param array $item A singular item (one full row).
|
1377 |
*/
|
1378 |
+
public function column_comment( $item = array() ) {
|
1379 |
|
1380 |
+
// Preorder items: Edit | Delete | View
|
1381 |
$actions = array(
|
|
|
1382 |
'edit' => '',
|
1383 |
'delete' => '',
|
1384 |
+
'view' => '',
|
1385 |
);
|
1386 |
|
1387 |
// We need the group object for some BP functions
|
1391 |
$base_url = bp_get_admin_url( 'admin.php?page=bp-groups&gid=' . $item['id'] );
|
1392 |
$delete_url = wp_nonce_url( $base_url . "&action=delete", 'bp-groups-delete' );
|
1393 |
$edit_url = $base_url . '&action=edit';
|
1394 |
+
$view_url = bp_get_group_permalink( $item_obj );
|
1395 |
+
$group_name = apply_filters_ref_array( 'bp_get_group_name', array( $item['name'] ), $item );
|
1396 |
|
1397 |
// Rollover actions
|
1398 |
|
|
|
|
|
|
|
1399 |
// Edit
|
1400 |
+
$actions['edit'] = sprintf( '<a href="%s">%s</a>', esc_url( $edit_url ), __( 'Edit', 'buddypress' ) );
|
1401 |
|
1402 |
// Delete
|
1403 |
$actions['delete'] = sprintf( '<a href="%s">%s</a>', esc_url( $delete_url ), __( 'Delete', 'buddypress' ) );
|
1404 |
|
1405 |
+
// Visit
|
1406 |
+
$actions['view'] = sprintf( '<a href="%s">%s</a>', esc_url( $view_url ), __( 'View', 'buddypress' ) );
|
1407 |
+
|
1408 |
// Other plugins can filter which actions are shown
|
1409 |
$actions = apply_filters( 'bp_groups_admin_comment_row_actions', array_filter( $actions ), $item );
|
1410 |
|
1411 |
// Get group name and avatar
|
1412 |
+
$avatar = '';
|
1413 |
+
|
1414 |
+
if ( buddypress()->avatar->show_avatars ) {
|
1415 |
+
$avatar = bp_core_fetch_avatar( array(
|
1416 |
+
'item_id' => $item['id'],
|
1417 |
+
'object' => 'group',
|
1418 |
+
'type' => 'thumb',
|
1419 |
+
'avatar_dir' => 'group-avatars',
|
1420 |
+
'alt' => sprintf( __( 'Group logo of %s', 'buddypress' ), $group_name ),
|
1421 |
+
'width' => '32',
|
1422 |
+
'height' => '32',
|
1423 |
+
'title' => $group_name
|
1424 |
+
) );
|
1425 |
+
}
|
1426 |
|
1427 |
+
$content = sprintf( '<strong><a href="%s">%s</a></strong>', esc_url( $edit_url ), $group_name );
|
1428 |
|
1429 |
echo $avatar . ' ' . $content . ' ' . $this->row_actions( $actions );
|
1430 |
}
|
1436 |
*
|
1437 |
* @param array Information about the current row.
|
1438 |
*/
|
1439 |
+
public function column_description( $item = array() ) {
|
1440 |
echo apply_filters_ref_array( 'bp_get_group_description', array( $item['description'], $item ) );
|
1441 |
}
|
1442 |
|
1447 |
*
|
1448 |
* @param array Information about the current row.
|
1449 |
*/
|
1450 |
+
public function column_status( $item = array() ) {
|
1451 |
$status = $item['status'];
|
1452 |
$status_desc = '';
|
1453 |
|
1475 |
*
|
1476 |
* @param array Information about the current row.
|
1477 |
*/
|
1478 |
+
public function column_members( $item = array() ) {
|
1479 |
$count = groups_get_groupmeta( $item['id'], 'total_member_count' );
|
1480 |
echo apply_filters_ref_array( 'bp_groups_admin_get_group_member_count', array( (int) $count, $item ) );
|
1481 |
}
|
1487 |
*
|
1488 |
* @param array Information about the current row.
|
1489 |
*/
|
1490 |
+
public function column_last_active( $item = array() ) {
|
1491 |
$last_active = groups_get_groupmeta( $item['id'], 'last_activity' );
|
1492 |
echo apply_filters_ref_array( 'bp_groups_admin_get_group_last_active', array( $last_active, $item ) );
|
1493 |
}
|
1500 |
* @param array Information about the current row.
|
1501 |
* @param string the column name.
|
1502 |
*/
|
1503 |
+
public function column_default( $item = array(), $column_name = '' ) {
|
1504 |
return apply_filters( 'bp_groups_admin_get_group_custom_column', '', $column_name, $item );
|
1505 |
}
|
1506 |
}
|
@@ -57,11 +57,11 @@ function bp_groups_group_admin_menu() {
|
|
57 |
) );
|
58 |
|
59 |
// Group Admin > Group avatar
|
60 |
-
if ( !(int)bp_get_option( 'bp-disable-avatar-uploads' ) ) {
|
61 |
$wp_admin_bar->add_menu( array(
|
62 |
'parent' => $bp->group_admin_menu_id,
|
63 |
'id' => 'group-avatar',
|
64 |
-
'title' => __( 'Edit
|
65 |
'href' => bp_get_groups_action_link( 'admin/group-avatar' )
|
66 |
) );
|
67 |
}
|
57 |
) );
|
58 |
|
59 |
// Group Admin > Group avatar
|
60 |
+
if ( !(int)bp_get_option( 'bp-disable-avatar-uploads' ) && $bp->avatar->show_avatars ) {
|
61 |
$wp_admin_bar->add_menu( array(
|
62 |
'parent' => $bp->group_admin_menu_id,
|
63 |
'id' => 'group-avatar',
|
64 |
+
'title' => __( 'Edit Profile Photo', 'buddypress' ),
|
65 |
'href' => bp_get_groups_action_link( 'admin/group-avatar' )
|
66 |
) );
|
67 |
}
|
@@ -1,67 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* BuddyPress Groups BuddyBar
|
5 |
-
*
|
6 |
-
* @package BuddyPress
|
7 |
-
* @subpackage GroupsBuddyBar
|
8 |
-
*/
|
9 |
-
|
10 |
-
// Exit if accessed directly
|
11 |
-
if ( !defined( 'ABSPATH' ) ) exit;
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Add menu items to the BuddyBar.
|
15 |
-
*
|
16 |
-
* @since BuddyPress (1.0.0)
|
17 |
-
*
|
18 |
-
* @global BuddyPress $bp
|
19 |
-
*/
|
20 |
-
function bp_groups_adminbar_admin_menu() {
|
21 |
-
global $bp;
|
22 |
-
|
23 |
-
if ( empty( $bp->groups->current_group ) )
|
24 |
-
return false;
|
25 |
-
|
26 |
-
// Only group admins and site admins can see this menu
|
27 |
-
if ( !current_user_can( 'edit_users' ) && !bp_current_user_can( 'bp_moderate' ) && !bp_is_item_admin() )
|
28 |
-
return false; ?>
|
29 |
-
|
30 |
-
<li id="bp-adminbar-adminoptions-menu">
|
31 |
-
<a href="<?php bp_groups_action_link( 'admin' ); ?>"><?php _e( 'Admin Options', 'buddypress' ); ?></a>
|
32 |
-
|
33 |
-
<ul>
|
34 |
-
<li><a href="<?php bp_groups_action_link( 'admin/edit-details' ); ?>"><?php _e( 'Edit Details', 'buddypress' ); ?></a></li>
|
35 |
-
|
36 |
-
<li><a href="<?php bp_groups_action_link( 'admin/group-settings' ); ?>"><?php _e( 'Group Settings', 'buddypress' ); ?></a></li>
|
37 |
-
|
38 |
-
<?php if ( !(int)bp_get_option( 'bp-disable-avatar-uploads' ) ) : ?>
|
39 |
-
|
40 |
-
<li><a href="<?php bp_groups_action_link( 'admin/group-avatar' ); ?>"><?php _e( 'Group Avatar', 'buddypress' ); ?></a></li>
|
41 |
-
|
42 |
-
<?php endif; ?>
|
43 |
-
|
44 |
-
<?php if ( bp_is_active( 'friends' ) ) : ?>
|
45 |
-
|
46 |
-
<li><a href="<?php bp_groups_action_link( 'send-invites' ); ?>"><?php _e( 'Manage Invitations', 'buddypress' ); ?></a></li>
|
47 |
-
|
48 |
-
<?php endif; ?>
|
49 |
-
|
50 |
-
<li><a href="<?php bp_groups_action_link( 'admin/manage-members' ); ?>"><?php _e( 'Manage Members', 'buddypress' ); ?></a></li>
|
51 |
-
|
52 |
-
<?php if ( $bp->groups->current_group->status == 'private' ) : ?>
|
53 |
-
|
54 |
-
<li><a href="<?php bp_groups_action_link( 'admin/membership-requests' ); ?>"><?php _e( 'Membership Requests', 'buddypress' ); ?></a></li>
|
55 |
-
|
56 |
-
<?php endif; ?>
|
57 |
-
|
58 |
-
<li><a class="confirm" href="<?php echo wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/delete-group/', 'groups_delete_group' ); ?>&delete-group-button=1&delete-group-understand=1"><?php _e( "Delete Group", 'buddypress' ) ?></a></li>
|
59 |
-
|
60 |
-
<?php do_action( 'bp_groups_adminbar_admin_menu' ) ?>
|
61 |
-
|
62 |
-
</ul>
|
63 |
-
</li>
|
64 |
-
|
65 |
-
<?php
|
66 |
-
}
|
67 |
-
add_action( 'bp_adminbar_menus', 'bp_groups_adminbar_admin_menu', 20 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -173,6 +173,35 @@ add_action( 'groups_unban_member', 'groups_clear_group_user_object_cache', 10,
|
|
173 |
add_action( 'groups_uninvite_user', 'groups_clear_group_user_object_cache', 10, 2 );
|
174 |
add_action( 'groups_remove_member', 'groups_clear_group_user_object_cache', 10, 2 );
|
175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
/* List actions to clear super cached pages on, if super cache is installed */
|
177 |
add_action( 'groups_join_group', 'bp_core_clear_cache' );
|
178 |
add_action( 'groups_leave_group', 'bp_core_clear_cache' );
|
173 |
add_action( 'groups_uninvite_user', 'groups_clear_group_user_object_cache', 10, 2 );
|
174 |
add_action( 'groups_remove_member', 'groups_clear_group_user_object_cache', 10, 2 );
|
175 |
|
176 |
+
/**
|
177 |
+
* Clear group administrator cache.
|
178 |
+
*
|
179 |
+
* @since BuddyPress (2.1.0)
|
180 |
+
*
|
181 |
+
* @param int $group_id The group ID.
|
182 |
+
*/
|
183 |
+
function groups_clear_group_administrator_cache( $group_id ) {
|
184 |
+
wp_cache_delete( $group_id, 'bp_group_admins' );
|
185 |
+
}
|
186 |
+
add_action( 'groups_promote_member', 'groups_clear_group_administrator_cache' );
|
187 |
+
add_action( 'groups_demote_member', 'groups_clear_group_administrator_cache' );
|
188 |
+
add_action( 'groups_delete_group', 'groups_clear_group_administrator_cache' );
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Clear group administrator cache when a group member is saved.
|
192 |
+
*
|
193 |
+
* This accounts for situations where group administrators are added manually
|
194 |
+
* using {@link BP_Groups_Member::save()}. Usually via a plugin.
|
195 |
+
*
|
196 |
+
* @since BuddyPress (2.1.0)
|
197 |
+
*
|
198 |
+
* @param BP_Groups_Member $member
|
199 |
+
*/
|
200 |
+
function groups_clear_group_administrator_cache_on_member_save( BP_Groups_Member $member ) {
|
201 |
+
groups_clear_group_administrator_cache( $member->group_id );
|
202 |
+
}
|
203 |
+
add_action( 'groups_member_after_save', 'groups_clear_group_administrator_cache_on_member_save' );
|
204 |
+
|
205 |
/* List actions to clear super cached pages on, if super cache is installed */
|
206 |
add_action( 'groups_join_group', 'bp_core_clear_cache' );
|
207 |
add_action( 'groups_leave_group', 'bp_core_clear_cache' );
|
@@ -445,7 +445,7 @@ class BP_Groups_Group {
|
|
445 |
if ( empty( $user_id ) )
|
446 |
$user_id = bp_displayed_user_id();
|
447 |
|
448 |
-
$
|
449 |
|
450 |
$pag_sql = $order_sql = $hidden_sql = '';
|
451 |
|
@@ -460,8 +460,8 @@ class BP_Groups_Group {
|
|
460 |
|
461 |
$gids = esc_sql( implode( ',', wp_parse_id_list( $gids['groups'] ) ) );
|
462 |
|
463 |
-
$paged_groups = $wpdb->get_results( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE ( name LIKE
|
464 |
-
$total_groups = $wpdb->get_var( "SELECT COUNT(id) FROM {$bp->groups->table_name} WHERE ( name LIKE
|
465 |
|
466 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
467 |
}
|
@@ -486,7 +486,7 @@ class BP_Groups_Group {
|
|
486 |
public static function search_groups( $filter, $limit = null, $page = null, $sort_by = false, $order = false ) {
|
487 |
global $wpdb, $bp;
|
488 |
|
489 |
-
$
|
490 |
|
491 |
$pag_sql = $order_sql = $hidden_sql = '';
|
492 |
|
@@ -502,8 +502,8 @@ class BP_Groups_Group {
|
|
502 |
if ( !bp_current_user_can( 'bp_moderate' ) )
|
503 |
$hidden_sql = "AND status != 'hidden'";
|
504 |
|
505 |
-
$paged_groups = $wpdb->get_results( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE ( name LIKE
|
506 |
-
$total_groups = $wpdb->get_var( "SELECT COUNT(id) FROM {$bp->groups->table_name} WHERE ( name LIKE
|
507 |
|
508 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
509 |
}
|
@@ -702,8 +702,8 @@ class BP_Groups_Group {
|
|
702 |
}
|
703 |
|
704 |
if ( ! empty( $r['search_terms'] ) ) {
|
705 |
-
$
|
706 |
-
$sql['search'] = " AND ( g.name LIKE
|
707 |
}
|
708 |
|
709 |
$meta_query_sql = self::get_meta_query_sql( $r['meta_query'] );
|
@@ -738,7 +738,7 @@ class BP_Groups_Group {
|
|
738 |
// If a 'type' parameter was passed, parse it and overwrite
|
739 |
// 'order' and 'orderby' params passed to the function
|
740 |
if ( ! empty( $r['type'] ) ) {
|
741 |
-
$order_orderby = self::convert_type_to_order_orderby( $r['type'] );
|
742 |
|
743 |
// If an invalid type is passed, $order_orderby will be
|
744 |
// an array with empty values. In this case, we stick
|
@@ -756,7 +756,7 @@ class BP_Groups_Group {
|
|
756 |
$order = bp_esc_sql_order( $order );
|
757 |
|
758 |
// Convert 'orderby' into the proper ORDER BY term
|
759 |
-
$orderby = self::convert_orderby_to_order_by_term( $orderby );
|
760 |
|
761 |
// Random order is a special case
|
762 |
if ( 'rand()' === $orderby ) {
|
@@ -765,7 +765,7 @@ class BP_Groups_Group {
|
|
765 |
$sql[] = "ORDER BY {$orderby} {$order}";
|
766 |
}
|
767 |
|
768 |
-
if ( ! empty( $r['per_page'] ) && ! empty( $r['page'] ) ) {
|
769 |
$sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $r['page'] - 1 ) * $r['per_page']), intval( $r['per_page'] ) );
|
770 |
}
|
771 |
|
@@ -784,7 +784,7 @@ class BP_Groups_Group {
|
|
784 |
}
|
785 |
|
786 |
if ( ! empty( $sql['search'] ) ) {
|
787 |
-
$total_sql['where'][] = "( g.name LIKE
|
788 |
}
|
789 |
|
790 |
if ( ! empty( $r['user_id'] ) ) {
|
@@ -891,15 +891,8 @@ class BP_Groups_Group {
|
|
891 |
preg_match_all( '/ON \((.*)\)/', $meta_sql['join'], $matches_b );
|
892 |
|
893 |
if ( ! empty( $matches_a[1] ) && ! empty( $matches_b[1] ) ) {
|
894 |
-
$sql_array['join'] = implode( ',', $matches_a[1] ). ', ';
|
895 |
-
|
896 |
-
$sql_array['where'] = '';
|
897 |
-
|
898 |
-
$meta_query_where_clauses = explode( "\n", $meta_sql['where'] );
|
899 |
-
foreach( $matches_b[1] as $key => $group_id_clause ) {
|
900 |
-
$sql_array['where'] .= ' ' . preg_replace( '/^(AND\s+[\(\s]+)/', '$1' . $group_id_clause . ' AND ', ltrim( $meta_query_where_clauses[ $key ] ) );
|
901 |
-
}
|
902 |
-
|
903 |
}
|
904 |
}
|
905 |
|
@@ -1025,8 +1018,8 @@ class BP_Groups_Group {
|
|
1025 |
$hidden_sql = " AND g.status != 'hidden'";
|
1026 |
|
1027 |
if ( !empty( $search_terms ) ) {
|
1028 |
-
$
|
1029 |
-
$search_sql
|
1030 |
}
|
1031 |
|
1032 |
if ( !empty( $exclude ) ) {
|
@@ -1089,8 +1082,8 @@ class BP_Groups_Group {
|
|
1089 |
$hidden_sql = " AND g.status != 'hidden'";
|
1090 |
|
1091 |
if ( !empty( $search_terms ) ) {
|
1092 |
-
$
|
1093 |
-
$search_sql
|
1094 |
}
|
1095 |
|
1096 |
if ( !empty( $exclude ) ) {
|
@@ -1160,15 +1153,15 @@ class BP_Groups_Group {
|
|
1160 |
if ( !bp_current_user_can( 'bp_moderate' ) )
|
1161 |
$hidden_sql = " AND status != 'hidden'";
|
1162 |
|
1163 |
-
$
|
1164 |
|
1165 |
if ( !empty( $limit ) && !empty( $page ) ) {
|
1166 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
1167 |
}
|
1168 |
|
1169 |
-
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE
|
1170 |
|
1171 |
-
$paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE
|
1172 |
|
1173 |
if ( !empty( $populate_extras ) ) {
|
1174 |
foreach ( (array) $paged_groups as $group ) {
|
@@ -1216,8 +1209,8 @@ class BP_Groups_Group {
|
|
1216 |
$hidden_sql = "AND g.status != 'hidden'";
|
1217 |
|
1218 |
if ( !empty( $search_terms ) ) {
|
1219 |
-
$
|
1220 |
-
$search_sql = " AND ( g.name LIKE
|
1221 |
}
|
1222 |
|
1223 |
if ( !empty( $exclude ) ) {
|
@@ -1433,8 +1426,8 @@ class BP_Groups_Group {
|
|
1433 |
$sql['where'] = "WHERE gm.meta_key = 'forum_id' {$status_sql} AND t.topic_status = '0' AND t.topic_sticky != '2'";
|
1434 |
|
1435 |
if ( !empty( $search_terms ) ) {
|
1436 |
-
$
|
1437 |
-
$sql['where'] .= " AND (
|
1438 |
}
|
1439 |
|
1440 |
return $wpdb->get_var( implode( ' ', $sql ) );
|
@@ -1707,11 +1700,20 @@ class BP_Group_Member_Query extends BP_User_Query {
|
|
1707 |
$gm_ids = array( 0 );
|
1708 |
}
|
1709 |
|
1710 |
-
// For 'last_joined'
|
1711 |
-
//
|
1712 |
-
//
|
1713 |
-
//
|
1714 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1715 |
|
1716 |
// The first param in the FIELD() clause is the sort column id
|
1717 |
$gm_ids = array_merge( array( 'u.id' ), wp_parse_id_list( $gm_ids ) );
|
@@ -1766,6 +1768,49 @@ class BP_Group_Member_Query extends BP_User_Query {
|
|
1766 |
// Don't filter other BP_User_Query objects on the same page
|
1767 |
remove_action( 'bp_user_query_populate_extras', array( $this, 'populate_group_member_extras' ), 10, 2 );
|
1768 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1769 |
}
|
1770 |
|
1771 |
/**
|
@@ -2205,21 +2250,23 @@ class BP_Groups_Member {
|
|
2205 |
public static function get_recently_joined( $user_id, $limit = false, $page = false, $filter = false ) {
|
2206 |
global $wpdb, $bp;
|
2207 |
|
2208 |
-
$pag_sql = $hidden_sql = $filter_sql = '';
|
|
|
|
|
2209 |
|
2210 |
if ( !empty( $limit ) && !empty( $page ) )
|
2211 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
2212 |
|
2213 |
if ( !empty( $filter ) ) {
|
2214 |
-
$
|
2215 |
-
$filter_sql = " AND ( g.name LIKE
|
2216 |
}
|
2217 |
|
2218 |
if ( $user_id != bp_loggedin_user_id() )
|
2219 |
$hidden_sql = " AND g.status != 'hidden'";
|
2220 |
|
2221 |
-
$paged_groups = $wpdb->get_results(
|
2222 |
-
$total_groups = $wpdb->get_var(
|
2223 |
|
2224 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
2225 |
}
|
@@ -2242,21 +2289,23 @@ class BP_Groups_Member {
|
|
2242 |
public static function get_is_admin_of( $user_id, $limit = false, $page = false, $filter = false ) {
|
2243 |
global $wpdb, $bp;
|
2244 |
|
2245 |
-
$pag_sql = $hidden_sql = $filter_sql = '';
|
|
|
|
|
2246 |
|
2247 |
if ( !empty( $limit ) && !empty( $page ) )
|
2248 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
2249 |
|
2250 |
if ( !empty( $filter ) ) {
|
2251 |
-
$
|
2252 |
-
$filter_sql = " AND ( g.name LIKE
|
2253 |
}
|
2254 |
|
2255 |
if ( $user_id != bp_loggedin_user_id() )
|
2256 |
$hidden_sql = " AND g.status != 'hidden'";
|
2257 |
|
2258 |
-
$paged_groups = $wpdb->get_results(
|
2259 |
-
$total_groups = $wpdb->get_var(
|
2260 |
|
2261 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
2262 |
}
|
@@ -2279,21 +2328,23 @@ class BP_Groups_Member {
|
|
2279 |
public static function get_is_mod_of( $user_id, $limit = false, $page = false, $filter = false ) {
|
2280 |
global $wpdb, $bp;
|
2281 |
|
2282 |
-
$pag_sql = $hidden_sql = $filter_sql = '';
|
|
|
|
|
2283 |
|
2284 |
if ( !empty( $limit ) && !empty( $page ) )
|
2285 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
2286 |
|
2287 |
if ( !empty( $filter ) ) {
|
2288 |
-
$
|
2289 |
-
$filter_sql = " AND ( g.name LIKE
|
2290 |
}
|
2291 |
|
2292 |
if ( $user_id != bp_loggedin_user_id() )
|
2293 |
$hidden_sql = " AND g.status != 'hidden'";
|
2294 |
|
2295 |
-
$paged_groups = $wpdb->get_results(
|
2296 |
-
$total_groups = $wpdb->get_var(
|
2297 |
|
2298 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
2299 |
}
|
@@ -2570,7 +2621,15 @@ class BP_Groups_Member {
|
|
2570 |
public static function get_group_administrator_ids( $group_id ) {
|
2571 |
global $bp, $wpdb;
|
2572 |
|
2573 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2574 |
}
|
2575 |
|
2576 |
/**
|
@@ -2809,6 +2868,14 @@ class BP_Group_Extension {
|
|
2809 |
*/
|
2810 |
public $params = array();
|
2811 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2812 |
/**
|
2813 |
* The ID of the current group.
|
2814 |
*
|
@@ -2852,6 +2919,22 @@ class BP_Group_Extension {
|
|
2852 |
*/
|
2853 |
public $enable_nav_item = true;
|
2854 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2855 |
/**
|
2856 |
* The text of the nav item. Defaults to self::name.
|
2857 |
*
|
@@ -2906,6 +2989,14 @@ class BP_Group_Extension {
|
|
2906 |
*/
|
2907 |
protected $legacy_properties_converted = array();
|
2908 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2909 |
/**
|
2910 |
* Miscellaneous data as set by the __set() magic method.
|
2911 |
*
|
@@ -2990,6 +3081,8 @@ class BP_Group_Extension {
|
|
2990 |
* }
|
2991 |
*/
|
2992 |
public function init( $args = array() ) {
|
|
|
|
|
2993 |
|
2994 |
// Before this init() method was introduced, plugins were
|
2995 |
// encouraged to set their config directly. For backward
|
@@ -3010,6 +3103,8 @@ class BP_Group_Extension {
|
|
3010 |
'display_hook' => $this->display_hook,
|
3011 |
'template_file' => $this->template_file,
|
3012 |
'screens' => $this->get_default_screens(),
|
|
|
|
|
3013 |
) );
|
3014 |
|
3015 |
$this->initialized = true;
|
@@ -3053,6 +3148,9 @@ class BP_Group_Extension {
|
|
3053 |
// Configure 'screens': create, admin, and edit contexts
|
3054 |
$this->setup_screens();
|
3055 |
|
|
|
|
|
|
|
3056 |
// Mirror configuration data so it's accessible to plugins
|
3057 |
// that look for it in its old locations
|
3058 |
$this->setup_legacy_properties();
|
@@ -3171,6 +3269,148 @@ class BP_Group_Extension {
|
|
3171 |
}
|
3172 |
}
|
3173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3174 |
/** Display ***********************************************************/
|
3175 |
|
3176 |
/**
|
@@ -3185,25 +3425,31 @@ class BP_Group_Extension {
|
|
3185 |
return;
|
3186 |
}
|
3187 |
|
3188 |
-
//
|
3189 |
if ( ( 'public' !== $this->visibility ) && ! buddypress()->groups->current_group->user_has_access ) {
|
3190 |
return;
|
3191 |
}
|
3192 |
|
3193 |
-
|
|
|
|
|
|
|
|
|
3194 |
bp_core_new_subnav_item( array(
|
3195 |
'name' => ! $this->nav_item_name ? $this->name : $this->nav_item_name,
|
3196 |
'slug' => $this->slug,
|
3197 |
'parent_slug' => bp_get_current_group_slug(),
|
3198 |
-
'parent_url' =>
|
3199 |
'position' => $this->nav_item_position,
|
3200 |
'item_css_id' => 'nav-' . $this->slug,
|
3201 |
'screen_function' => array( &$this, '_display_hook' ),
|
3202 |
-
'user_has_access' => $
|
|
|
3203 |
) );
|
3204 |
|
3205 |
// When we are viewing the extension display page, set the title and options title
|
3206 |
if ( bp_is_current_action( $this->slug ) ) {
|
|
|
3207 |
add_action( 'bp_template_content_header', create_function( '', 'echo "' . esc_attr( $this->name ) . '";' ) );
|
3208 |
add_action( 'bp_template_title', create_function( '', 'echo "' . esc_attr( $this->name ) . '";' ) );
|
3209 |
}
|
@@ -3223,6 +3469,69 @@ class BP_Group_Extension {
|
|
3223 |
bp_core_load_template( apply_filters( 'bp_core_template_plugin', $this->template_file ) );
|
3224 |
}
|
3225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3226 |
/** Create ************************************************************/
|
3227 |
|
3228 |
/**
|
@@ -3377,7 +3686,24 @@ class BP_Group_Extension {
|
|
3377 |
}
|
3378 |
|
3379 |
$this->check_nonce( 'edit' );
|
|
|
|
|
|
|
|
|
|
|
|
|
3380 |
call_user_func( $this->screens['edit']['screen_save_callback'], $this->group_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3381 |
}
|
3382 |
|
3383 |
/**
|
@@ -3441,6 +3767,22 @@ class BP_Group_Extension {
|
|
3441 |
return ! empty( $matches[0] );
|
3442 |
}
|
3443 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3444 |
/** Admin *************************************************************/
|
3445 |
|
3446 |
/**
|
@@ -4006,3 +4348,134 @@ function bp_register_group_extension( $group_extension_class = '' ) {
|
|
4006 |
add_action( "admin_init", array( &$extension, "_register" ) );
|
4007 |
' ), 11 );
|
4008 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
445 |
if ( empty( $user_id ) )
|
446 |
$user_id = bp_displayed_user_id();
|
447 |
|
448 |
+
$search_terms_like = bp_esc_like( $filter ) . '%';
|
449 |
|
450 |
$pag_sql = $order_sql = $hidden_sql = '';
|
451 |
|
460 |
|
461 |
$gids = esc_sql( implode( ',', wp_parse_id_list( $gids['groups'] ) ) );
|
462 |
|
463 |
+
$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE ( name LIKE %s OR description LIKE %s ) AND id IN ({$gids}) {$pag_sql}", $search_terms_like, $search_terms_like ) );
|
464 |
+
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} WHERE ( name LIKE %s OR description LIKE %s ) AND id IN ({$gids})", $search_terms_like, $search_terms_like ) );
|
465 |
|
466 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
467 |
}
|
486 |
public static function search_groups( $filter, $limit = null, $page = null, $sort_by = false, $order = false ) {
|
487 |
global $wpdb, $bp;
|
488 |
|
489 |
+
$search_terms_like = '%' . bp_esc_like( $filter ) . '%';
|
490 |
|
491 |
$pag_sql = $order_sql = $hidden_sql = '';
|
492 |
|
502 |
if ( !bp_current_user_can( 'bp_moderate' ) )
|
503 |
$hidden_sql = "AND status != 'hidden'";
|
504 |
|
505 |
+
$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE ( name LIKE %s OR description LIKE %s ) {$hidden_sql} {$order_sql} {$pag_sql}", $search_terms_like, $search_terms_like ) );
|
506 |
+
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} WHERE ( name LIKE %s OR description LIKE %s ) {$hidden_sql}", $search_terms_like, $search_terms_like ) );
|
507 |
|
508 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
509 |
}
|
702 |
}
|
703 |
|
704 |
if ( ! empty( $r['search_terms'] ) ) {
|
705 |
+
$search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
|
706 |
+
$sql['search'] = $wpdb->prepare( " AND ( g.name LIKE %s OR g.description LIKE %s )", $search_terms_like, $search_terms_like );
|
707 |
}
|
708 |
|
709 |
$meta_query_sql = self::get_meta_query_sql( $r['meta_query'] );
|
738 |
// If a 'type' parameter was passed, parse it and overwrite
|
739 |
// 'order' and 'orderby' params passed to the function
|
740 |
if ( ! empty( $r['type'] ) ) {
|
741 |
+
$order_orderby = apply_filters( 'bp_groups_get_orderby', self::convert_type_to_order_orderby( $r['type'] ), $r['type'] );
|
742 |
|
743 |
// If an invalid type is passed, $order_orderby will be
|
744 |
// an array with empty values. In this case, we stick
|
756 |
$order = bp_esc_sql_order( $order );
|
757 |
|
758 |
// Convert 'orderby' into the proper ORDER BY term
|
759 |
+
$orderby = apply_filters( 'bp_groups_get_orderby_converted_by_term', self::convert_orderby_to_order_by_term( $orderby ), $orderby, $r['type'] );
|
760 |
|
761 |
// Random order is a special case
|
762 |
if ( 'rand()' === $orderby ) {
|
765 |
$sql[] = "ORDER BY {$orderby} {$order}";
|
766 |
}
|
767 |
|
768 |
+
if ( ! empty( $r['per_page'] ) && ! empty( $r['page'] ) && $r['per_page'] != -1 ) {
|
769 |
$sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $r['page'] - 1 ) * $r['per_page']), intval( $r['per_page'] ) );
|
770 |
}
|
771 |
|
784 |
}
|
785 |
|
786 |
if ( ! empty( $sql['search'] ) ) {
|
787 |
+
$total_sql['where'][] = $wpdb->prepare( "( g.name LIKE %s OR g.description LIKE %s )", $search_terms_like, $search_terms_like );
|
788 |
}
|
789 |
|
790 |
if ( ! empty( $r['user_id'] ) ) {
|
891 |
preg_match_all( '/ON \((.*)\)/', $meta_sql['join'], $matches_b );
|
892 |
|
893 |
if ( ! empty( $matches_a[1] ) && ! empty( $matches_b[1] ) ) {
|
894 |
+
$sql_array['join'] = implode( ',', $matches_a[1] ) . ', ';
|
895 |
+
$sql_array['where'] = $meta_sql['where'] . ' AND ' . implode ( ' AND ', $matches_b[1] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
896 |
}
|
897 |
}
|
898 |
|
1018 |
$hidden_sql = " AND g.status != 'hidden'";
|
1019 |
|
1020 |
if ( !empty( $search_terms ) ) {
|
1021 |
+
$search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
|
1022 |
+
$search_sql = $wpdb->prepare( ' AND ( g.name LIKE %s OR g.description LIKE %s ) ', $search_terms_like, $search_terms_like );
|
1023 |
}
|
1024 |
|
1025 |
if ( !empty( $exclude ) ) {
|
1082 |
$hidden_sql = " AND g.status != 'hidden'";
|
1083 |
|
1084 |
if ( !empty( $search_terms ) ) {
|
1085 |
+
$search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
|
1086 |
+
$search_sql = $wpdb->prepare( ' AND ( g.name LIKE %s OR g.description LIKE %s ) ', $search_terms_like, $search_terms_like );
|
1087 |
}
|
1088 |
|
1089 |
if ( !empty( $exclude ) ) {
|
1153 |
if ( !bp_current_user_can( 'bp_moderate' ) )
|
1154 |
$hidden_sql = " AND status != 'hidden'";
|
1155 |
|
1156 |
+
$letter_like = bp_esc_like( $letter ) . '%';
|
1157 |
|
1158 |
if ( !empty( $limit ) && !empty( $page ) ) {
|
1159 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
1160 |
}
|
1161 |
|
1162 |
+
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE %s {$hidden_sql} {$exclude_sql}", $letter_like ) );
|
1163 |
|
1164 |
+
$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE %s {$hidden_sql} {$exclude_sql} ORDER BY g.name ASC {$pag_sql}", $letter_like ) );
|
1165 |
|
1166 |
if ( !empty( $populate_extras ) ) {
|
1167 |
foreach ( (array) $paged_groups as $group ) {
|
1209 |
$hidden_sql = "AND g.status != 'hidden'";
|
1210 |
|
1211 |
if ( !empty( $search_terms ) ) {
|
1212 |
+
$search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
|
1213 |
+
$search_sql = $wpdb->prepare( " AND ( g.name LIKE %s OR g.description LIKE %s )", $search_terms_like, $search_terms_like );
|
1214 |
}
|
1215 |
|
1216 |
if ( !empty( $exclude ) ) {
|
1426 |
$sql['where'] = "WHERE gm.meta_key = 'forum_id' {$status_sql} AND t.topic_status = '0' AND t.topic_sticky != '2'";
|
1427 |
|
1428 |
if ( !empty( $search_terms ) ) {
|
1429 |
+
$search_terms_like = '%' . bp_esc_like( $search_terms ) . '%';
|
1430 |
+
$sql['where'] .= $wpdb->prepare( " AND ( t.topic_title LIKE %s )", $search_terms_like );
|
1431 |
}
|
1432 |
|
1433 |
return $wpdb->get_var( implode( ' ', $sql ) );
|
1700 |
$gm_ids = array( 0 );
|
1701 |
}
|
1702 |
|
1703 |
+
// For 'last_joined', 'first_joined', and 'group_activity'
|
1704 |
+
// types, we override the default orderby clause of
|
1705 |
+
// BP_User_Query. In the case of 'group_activity', we perform
|
1706 |
+
// a separate query to get the necessary order. In the case of
|
1707 |
+
// 'last_joined' and 'first_joined', we can trust the order of
|
1708 |
+
// results from BP_Group_Member_Query::get_group_members().
|
1709 |
+
// In all other cases, we fall through and let BP_User_Query
|
1710 |
+
// do its own (non-group-specific) ordering.
|
1711 |
+
if ( in_array( $query->query_vars['type'], array( 'last_joined', 'first_joined', 'group_activity' ) ) ) {
|
1712 |
+
|
1713 |
+
// Group Activity DESC
|
1714 |
+
if ( 'group_activity' == $query->query_vars['type'] ) {
|
1715 |
+
$gm_ids = $this->get_gm_ids_ordered_by_activity( $query, $gm_ids );
|
1716 |
+
}
|
1717 |
|
1718 |
// The first param in the FIELD() clause is the sort column id
|
1719 |
$gm_ids = array_merge( array( 'u.id' ), wp_parse_id_list( $gm_ids ) );
|
1768 |
// Don't filter other BP_User_Query objects on the same page
|
1769 |
remove_action( 'bp_user_query_populate_extras', array( $this, 'populate_group_member_extras' ), 10, 2 );
|
1770 |
}
|
1771 |
+
|
1772 |
+
/**
|
1773 |
+
* Sort user IDs by how recently they have generated activity within a given group.
|
1774 |
+
*
|
1775 |
+
* @since BuddyPress (2.1.0)
|
1776 |
+
*
|
1777 |
+
* @param BP_User_Query $query BP_User_Query object.
|
1778 |
+
* @param array $gm_ids array of group member ids.
|
1779 |
+
* @return array
|
1780 |
+
*/
|
1781 |
+
public function get_gm_ids_ordered_by_activity( $query, $gm_ids = array() ) {
|
1782 |
+
global $wpdb;
|
1783 |
+
|
1784 |
+
if ( empty( $gm_ids ) ) {
|
1785 |
+
return $gm_ids;
|
1786 |
+
}
|
1787 |
+
|
1788 |
+
if ( ! bp_is_active( 'activity' ) ) {
|
1789 |
+
return $gm_ids;
|
1790 |
+
}
|
1791 |
+
|
1792 |
+
$activity_table = buddypress()->activity->table_name;
|
1793 |
+
|
1794 |
+
$sql = array(
|
1795 |
+
'select' => "SELECT user_id, max( date_recorded ) as date_recorded FROM {$activity_table}",
|
1796 |
+
'where' => array(),
|
1797 |
+
'groupby' => 'GROUP BY user_id',
|
1798 |
+
'orderby' => 'ORDER BY date_recorded',
|
1799 |
+
'order' => 'DESC',
|
1800 |
+
);
|
1801 |
+
|
1802 |
+
$sql['where'] = array(
|
1803 |
+
'user_id IN (' . implode( ',', wp_parse_id_list( $gm_ids ) ) . ')',
|
1804 |
+
'item_id = ' . absint( $query->query_vars['group_id'] ),
|
1805 |
+
$wpdb->prepare( "component = %s", buddypress()->groups->id ),
|
1806 |
+
);
|
1807 |
+
|
1808 |
+
$sql['where'] = 'WHERE ' . implode( ' AND ', $sql['where'] );
|
1809 |
+
|
1810 |
+
$group_user_ids = $wpdb->get_results( "{$sql['select']} {$sql['where']} {$sql['groupby']} {$sql['orderby']} {$sql['order']}" );
|
1811 |
+
|
1812 |
+
return wp_list_pluck( $group_user_ids, 'user_id' );
|
1813 |
+
}
|
1814 |
}
|
1815 |
|
1816 |
/**
|
2250 |
public static function get_recently_joined( $user_id, $limit = false, $page = false, $filter = false ) {
|
2251 |
global $wpdb, $bp;
|
2252 |
|
2253 |
+
$user_id_sql = $pag_sql = $hidden_sql = $filter_sql = '';
|
2254 |
+
|
2255 |
+
$user_id_sql = $wpdb->prepare( 'm.user_id = %d', $user_id );
|
2256 |
|
2257 |
if ( !empty( $limit ) && !empty( $page ) )
|
2258 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
2259 |
|
2260 |
if ( !empty( $filter ) ) {
|
2261 |
+
$search_terms_like = '%' . bp_esc_like( $filter ) . '%';
|
2262 |
+
$filter_sql = $wpdb->prepare( " AND ( g.name LIKE %s OR g.description LIKE %s )", $search_terms_like, $search_terms_like );
|
2263 |
}
|
2264 |
|
2265 |
if ( $user_id != bp_loggedin_user_id() )
|
2266 |
$hidden_sql = " AND g.status != 'hidden'";
|
2267 |
|
2268 |
+
$paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND {$user_id_sql} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY m.date_modified DESC {$pag_sql}" );
|
2269 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND {$user_id_sql} AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC" );
|
2270 |
|
2271 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
2272 |
}
|
2289 |
public static function get_is_admin_of( $user_id, $limit = false, $page = false, $filter = false ) {
|
2290 |
global $wpdb, $bp;
|
2291 |
|
2292 |
+
$user_id_sql = $pag_sql = $hidden_sql = $filter_sql = '';
|
2293 |
+
|
2294 |
+
$user_id_sql = $wpdb->prepare( 'm.user_id = %d', $user_id );
|
2295 |
|
2296 |
if ( !empty( $limit ) && !empty( $page ) )
|
2297 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
2298 |
|
2299 |
if ( !empty( $filter ) ) {
|
2300 |
+
$search_terms_like = '%' . bp_esc_like( $filter ) . '%';
|
2301 |
+
$filter_sql = $wpdb->prepare( " AND ( g.name LIKE %s OR g.description LIKE %s )", $search_terms_like, $search_terms_like );
|
2302 |
}
|
2303 |
|
2304 |
if ( $user_id != bp_loggedin_user_id() )
|
2305 |
$hidden_sql = " AND g.status != 'hidden'";
|
2306 |
|
2307 |
+
$paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND {$user_id_sql} AND m.is_confirmed = 1 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY m.date_modified ASC {$pag_sql}" );
|
2308 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND {$user_id_sql} AND m.is_confirmed = 1 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY date_modified ASC" );
|
2309 |
|
2310 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
2311 |
}
|
2328 |
public static function get_is_mod_of( $user_id, $limit = false, $page = false, $filter = false ) {
|
2329 |
global $wpdb, $bp;
|
2330 |
|
2331 |
+
$user_id_sql = $pag_sql = $hidden_sql = $filter_sql = '';
|
2332 |
+
|
2333 |
+
$user_id_sql = $wpdb->prepare( 'm.user_id = %d', $user_id );
|
2334 |
|
2335 |
if ( !empty( $limit ) && !empty( $page ) )
|
2336 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
2337 |
|
2338 |
if ( !empty( $filter ) ) {
|
2339 |
+
$search_terms_like = '%' . bp_esc_like( $filter ) . '%';
|
2340 |
+
$filter_sql = $wpdb->prepare( " AND ( g.name LIKE %s OR g.description LIKE %s )", $search_terms_like, $search_terms_like );
|
2341 |
}
|
2342 |
|
2343 |
if ( $user_id != bp_loggedin_user_id() )
|
2344 |
$hidden_sql = " AND g.status != 'hidden'";
|
2345 |
|
2346 |
+
$paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND {$user_id_sql} AND m.is_confirmed = 1 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY m.date_modified ASC {$pag_sql}" );
|
2347 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND {$user_id_sql} AND m.is_confirmed = 1 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC" );
|
2348 |
|
2349 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
2350 |
}
|
2621 |
public static function get_group_administrator_ids( $group_id ) {
|
2622 |
global $bp, $wpdb;
|
2623 |
|
2624 |
+
$group_admins = wp_cache_get( $group_id, 'bp_group_admins' );
|
2625 |
+
|
2626 |
+
if ( false === $group_admins ) {
|
2627 |
+
$group_admins = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_admin = 1 AND is_banned = 0", $group_id ) );
|
2628 |
+
|
2629 |
+
wp_cache_set( $group_id, $group_admins, 'bp_group_admins' );
|
2630 |
+
}
|
2631 |
+
|
2632 |
+
return $group_admins;
|
2633 |
}
|
2634 |
|
2635 |
/**
|
2868 |
*/
|
2869 |
public $params = array();
|
2870 |
|
2871 |
+
/**
|
2872 |
+
* Raw config params, as passed by the extending class.
|
2873 |
+
*
|
2874 |
+
* @since BuddyPress (2.1.0)
|
2875 |
+
* @var array
|
2876 |
+
*/
|
2877 |
+
public $params_raw = array();
|
2878 |
+
|
2879 |
/**
|
2880 |
* The ID of the current group.
|
2881 |
*
|
2919 |
*/
|
2920 |
public $enable_nav_item = true;
|
2921 |
|
2922 |
+
/**
|
2923 |
+
* Whether the current user should see the navigation item.
|
2924 |
+
*
|
2925 |
+
* @since BuddyPress (2.1.0)
|
2926 |
+
* @var bool
|
2927 |
+
*/
|
2928 |
+
public $user_can_see_nav_item;
|
2929 |
+
|
2930 |
+
/**
|
2931 |
+
* Whether the current user can visit the tab.
|
2932 |
+
*
|
2933 |
+
* @since BuddyPress (2.1.0)
|
2934 |
+
* @var bool
|
2935 |
+
*/
|
2936 |
+
public $user_can_visit;
|
2937 |
+
|
2938 |
/**
|
2939 |
* The text of the nav item. Defaults to self::name.
|
2940 |
*
|
2989 |
*/
|
2990 |
protected $legacy_properties_converted = array();
|
2991 |
|
2992 |
+
/**
|
2993 |
+
* Redirect location as defined by post-edit save callback.
|
2994 |
+
*
|
2995 |
+
* @since BuddyPress (2.1.0)
|
2996 |
+
* @var string
|
2997 |
+
*/
|
2998 |
+
protected $post_save_redirect;
|
2999 |
+
|
3000 |
/**
|
3001 |
* Miscellaneous data as set by the __set() magic method.
|
3002 |
*
|
3081 |
* }
|
3082 |
*/
|
3083 |
public function init( $args = array() ) {
|
3084 |
+
// Store the raw arguments
|
3085 |
+
$this->params_raw = $args;
|
3086 |
|
3087 |
// Before this init() method was introduced, plugins were
|
3088 |
// encouraged to set their config directly. For backward
|
3103 |
'display_hook' => $this->display_hook,
|
3104 |
'template_file' => $this->template_file,
|
3105 |
'screens' => $this->get_default_screens(),
|
3106 |
+
'access' => null,
|
3107 |
+
'show_tab' => null,
|
3108 |
) );
|
3109 |
|
3110 |
$this->initialized = true;
|
3148 |
// Configure 'screens': create, admin, and edit contexts
|
3149 |
$this->setup_screens();
|
3150 |
|
3151 |
+
// Configure access-related settings
|
3152 |
+
$this->setup_access_settings();
|
3153 |
+
|
3154 |
// Mirror configuration data so it's accessible to plugins
|
3155 |
// that look for it in its old locations
|
3156 |
$this->setup_legacy_properties();
|
3269 |
}
|
3270 |
}
|
3271 |
|
3272 |
+
/**
|
3273 |
+
* Set up access-related settings for this extension.
|
3274 |
+
*
|
3275 |
+
* @since BuddyPress (2.1.0)
|
3276 |
+
*/
|
3277 |
+
protected function setup_access_settings() {
|
3278 |
+
// Bail if no gruop ID is available
|
3279 |
+
if ( empty( $this->group_id ) ) {
|
3280 |
+
return;
|
3281 |
+
}
|
3282 |
+
|
3283 |
+
// Backward compatibility
|
3284 |
+
if ( isset( $this->params['enable_nav_item'] ) ) {
|
3285 |
+
$this->enable_nav_item = (bool) $this->params['enable_nav_item'];
|
3286 |
+
}
|
3287 |
+
|
3288 |
+
// Tab Access
|
3289 |
+
$this->user_can_visit = false;
|
3290 |
+
|
3291 |
+
// Backward compatibility for components that do not provide
|
3292 |
+
// explicit 'access' parameter
|
3293 |
+
if ( empty( $this->params['access'] ) ) {
|
3294 |
+
if ( false === $this->enable_nav_item ) {
|
3295 |
+
$this->params['access'] = 'noone';
|
3296 |
+
} else {
|
3297 |
+
$group = groups_get_group( array(
|
3298 |
+
'group_id' => $this->group_id,
|
3299 |
+
) );
|
3300 |
+
|
3301 |
+
if ( ! empty( $group->status ) && 'public' === $group->status ) {
|
3302 |
+
// Tabs in public groups are accessible to anyone by default
|
3303 |
+
$this->params['access'] = 'anyone';
|
3304 |
+
} else {
|
3305 |
+
// All other groups have members-only as the default
|
3306 |
+
$this->params['access'] = 'member';
|
3307 |
+
}
|
3308 |
+
}
|
3309 |
+
}
|
3310 |
+
|
3311 |
+
// Parse multiple access conditions into an array
|
3312 |
+
$access_conditions = $this->params['access'];
|
3313 |
+
if ( ! is_array( $access_conditions ) ) {
|
3314 |
+
$access_conditions = explode( ',', $access_conditions );
|
3315 |
+
}
|
3316 |
+
|
3317 |
+
// If the current user meets at least one condition, the
|
3318 |
+
// get access
|
3319 |
+
foreach ( $access_conditions as $access_condition ) {
|
3320 |
+
if ( $this->user_meets_access_condition( $access_condition ) ) {
|
3321 |
+
$this->user_can_visit = true;
|
3322 |
+
break;
|
3323 |
+
}
|
3324 |
+
}
|
3325 |
+
|
3326 |
+
// Tab Visibility
|
3327 |
+
$this->user_can_see_nav_item = false;
|
3328 |
+
|
3329 |
+
// Backward compatibility for components that do not provide
|
3330 |
+
// explicit 'show_tab' parameter
|
3331 |
+
if ( empty( $this->params['show_tab'] ) ) {
|
3332 |
+
if ( false === $this->params['enable_nav_item'] ) {
|
3333 |
+
// enable_nav_item is only false if it's been
|
3334 |
+
// defined explicitly as such in the
|
3335 |
+
// constructor. So we always trust this value
|
3336 |
+
$this->params['show_tab'] = 'noone';
|
3337 |
+
|
3338 |
+
} else if ( isset( $this->params_raw['enable_nav_item'] ) || isset( $this->params_raw['visibility'] ) ) {
|
3339 |
+
// If enable_nav_item or visibility is passed,
|
3340 |
+
// we assume this is a legacy extension.
|
3341 |
+
// Legacy behavior is that enable_nav_item=true +
|
3342 |
+
// visibility=private implies members-only
|
3343 |
+
if ( 'public' !== $this->visibility ) {
|
3344 |
+
$this->params['show_tab'] = 'member';
|
3345 |
+
} else {
|
3346 |
+
$this->params['show_tab'] = 'anyone';
|
3347 |
+
}
|
3348 |
+
|
3349 |
+
} else {
|
3350 |
+
// No show_tab or enable_nav_item value is
|
3351 |
+
// available, so match the value of 'access'
|
3352 |
+
$this->params['show_tab'] = $this->params['access'];
|
3353 |
+
}
|
3354 |
+
}
|
3355 |
+
|
3356 |
+
// Parse multiple access conditions into an array
|
3357 |
+
$access_conditions = $this->params['show_tab'];
|
3358 |
+
if ( ! is_array( $access_conditions ) ) {
|
3359 |
+
$access_conditions = explode( ',', $access_conditions );
|
3360 |
+
}
|
3361 |
+
|
3362 |
+
// If the current user meets at least one condition, the
|
3363 |
+
// get access
|
3364 |
+
foreach ( $access_conditions as $access_condition ) {
|
3365 |
+
if ( $this->user_meets_access_condition( $access_condition ) ) {
|
3366 |
+
$this->user_can_see_nav_item = true;
|
3367 |
+
break;
|
3368 |
+
}
|
3369 |
+
}
|
3370 |
+
}
|
3371 |
+
|
3372 |
+
/**
|
3373 |
+
* Check whether the current user meets an access condition.
|
3374 |
+
*
|
3375 |
+
* @param string $access_condition 'anyone', 'loggedin', 'member',
|
3376 |
+
* 'mod', 'admin' or 'noone'.
|
3377 |
+
* @return bool
|
3378 |
+
*/
|
3379 |
+
protected function user_meets_access_condition( $access_condition ) {
|
3380 |
+
$group = groups_get_group( array(
|
3381 |
+
'group_id' => $this->group_id,
|
3382 |
+
) );
|
3383 |
+
|
3384 |
+
switch ( $access_condition ) {
|
3385 |
+
case 'admin' :
|
3386 |
+
$meets_condition = groups_is_user_admin( bp_loggedin_user_id(), $this->group_id );
|
3387 |
+
break;
|
3388 |
+
|
3389 |
+
case 'mod' :
|
3390 |
+
$meets_condition = groups_is_user_mod( bp_loggedin_user_id(), $this->group_id );
|
3391 |
+
break;
|
3392 |
+
|
3393 |
+
case 'member' :
|
3394 |
+
$meets_condition = groups_is_user_member( bp_loggedin_user_id(), $this->group_id );
|
3395 |
+
break;
|
3396 |
+
|
3397 |
+
case 'loggedin' :
|
3398 |
+
$meets_condition = is_user_logged_in();
|
3399 |
+
break;
|
3400 |
+
|
3401 |
+
case 'noone' :
|
3402 |
+
$meets_condition = false;
|
3403 |
+
break;
|
3404 |
+
|
3405 |
+
case 'anyone' :
|
3406 |
+
default :
|
3407 |
+
$meets_condition = true;
|
3408 |
+
break;
|
3409 |
+
}
|
3410 |
+
|
3411 |
+
return $meets_condition;
|
3412 |
+
}
|
3413 |
+
|
3414 |
/** Display ***********************************************************/
|
3415 |
|
3416 |
/**
|
3425 |
return;
|
3426 |
}
|
3427 |
|
3428 |
+
// Backward compatibility only
|
3429 |
if ( ( 'public' !== $this->visibility ) && ! buddypress()->groups->current_group->user_has_access ) {
|
3430 |
return;
|
3431 |
}
|
3432 |
|
3433 |
+
$user_can_see_nav_item = $this->user_can_see_nav_item();
|
3434 |
+
|
3435 |
+
if ( $user_can_see_nav_item ) {
|
3436 |
+
$group_permalink = bp_get_group_permalink( groups_get_current_group() );
|
3437 |
+
|
3438 |
bp_core_new_subnav_item( array(
|
3439 |
'name' => ! $this->nav_item_name ? $this->name : $this->nav_item_name,
|
3440 |
'slug' => $this->slug,
|
3441 |
'parent_slug' => bp_get_current_group_slug(),
|
3442 |
+
'parent_url' => $group_permalink,
|
3443 |
'position' => $this->nav_item_position,
|
3444 |
'item_css_id' => 'nav-' . $this->slug,
|
3445 |
'screen_function' => array( &$this, '_display_hook' ),
|
3446 |
+
'user_has_access' => $user_can_see_nav_item,
|
3447 |
+
'no_access_url' => $group_permalink,
|
3448 |
) );
|
3449 |
|
3450 |
// When we are viewing the extension display page, set the title and options title
|
3451 |
if ( bp_is_current_action( $this->slug ) ) {
|
3452 |
+
add_filter( 'bp_group_user_has_access', array( $this, 'group_access_protection' ), 10, 2 );
|
3453 |
add_action( 'bp_template_content_header', create_function( '', 'echo "' . esc_attr( $this->name ) . '";' ) );
|
3454 |
add_action( 'bp_template_title', create_function( '', 'echo "' . esc_attr( $this->name ) . '";' ) );
|
3455 |
}
|
3469 |
bp_core_load_template( apply_filters( 'bp_core_template_plugin', $this->template_file ) );
|
3470 |
}
|
3471 |
|
3472 |
+
/**
|
3473 |
+
* Determine whether the current user should see this nav tab.
|
3474 |
+
*
|
3475 |
+
* Note that this controls only the display of the navigation item.
|
3476 |
+
* Access to the tab is controlled by the user_can_visit() check.
|
3477 |
+
*
|
3478 |
+
* @since BuddyPress (2.1.0)
|
3479 |
+
*
|
3480 |
+
* @return bool
|
3481 |
+
*/
|
3482 |
+
public function user_can_see_nav_item( $user_can_see_nav_item = false ) {
|
3483 |
+
if ( 'noone' !== $this->params['show_tab'] && current_user_can( 'bp_moderate' ) ) {
|
3484 |
+
return true;
|
3485 |
+
}
|
3486 |
+
|
3487 |
+
return $this->user_can_see_nav_item;
|
3488 |
+
}
|
3489 |
+
|
3490 |
+
/**
|
3491 |
+
* Determine whether the current user has access to visit this tab.
|
3492 |
+
*
|
3493 |
+
* @since BuddyPress (2.1.0)
|
3494 |
+
*
|
3495 |
+
* @return bool
|
3496 |
+
*/
|
3497 |
+
public function user_can_visit( $user_can_visit = false ) {
|
3498 |
+
if ( 'noone' !== $this->params['access'] && current_user_can( 'bp_moderate' ) ) {
|
3499 |
+
return true;
|
3500 |
+
}
|
3501 |
+
|
3502 |
+
return $this->user_can_visit;
|
3503 |
+
}
|
3504 |
+
|
3505 |
+
/**
|
3506 |
+
* Filter the access check in bp_groups_group_access_protection() for this extension.
|
3507 |
+
*
|
3508 |
+
* Note that $no_access_args is passed by reference, as there are some
|
3509 |
+
* circumstances where the bp_core_no_access() arguments need to be
|
3510 |
+
* modified before the redirect takes place.
|
3511 |
+
*
|
3512 |
+
* @since BuddyPress (2.1.0)
|
3513 |
+
*
|
3514 |
+
* @param bool $user_can_visit
|
3515 |
+
* @param array $no_access_args
|
3516 |
+
* @return bool
|
3517 |
+
*/
|
3518 |
+
public function group_access_protection( $user_can_visit, &$no_access_args ) {
|
3519 |
+
$user_can_visit = $this->user_can_visit();
|
3520 |
+
|
3521 |
+
if ( ! $user_can_visit && is_user_logged_in() ) {
|
3522 |
+
$current_group = groups_get_group( array(
|
3523 |
+
'group_id' => $this->group_id,
|
3524 |
+
) );
|
3525 |
+
|
3526 |
+
$no_access_args['message'] = __( 'You do not have access to this content.', 'buddypress' );
|
3527 |
+
$no_access_args['root'] = bp_get_group_permalink( $current_group ) . 'home/';
|
3528 |
+
$no_access_args['redirect'] = false;
|
3529 |
+
}
|
3530 |
+
|
3531 |
+
return $user_can_visit;
|
3532 |
+
}
|
3533 |
+
|
3534 |
+
|
3535 |
/** Create ************************************************************/
|
3536 |
|
3537 |
/**
|
3686 |
}
|
3687 |
|
3688 |
$this->check_nonce( 'edit' );
|
3689 |
+
|
3690 |
+
// Detect whether the screen_save_callback is performing a
|
3691 |
+
// redirect, so that we don't do one of our own
|
3692 |
+
add_filter( 'wp_redirect', array( $this, 'detect_post_save_redirect' ) );
|
3693 |
+
|
3694 |
+
// Call the extension's save routine
|
3695 |
call_user_func( $this->screens['edit']['screen_save_callback'], $this->group_id );
|
3696 |
+
|
3697 |
+
// Clean up detection filters
|
3698 |
+
remove_filter( 'wp_redirect', array( $this, 'detect_post_save_redirect' ) );
|
3699 |
+
|
3700 |
+
// Perform a redirect only if one has not already taken place
|
3701 |
+
if ( empty( $this->post_save_redirect ) ) {
|
3702 |
+
$redirect_to = apply_filters( 'bp_group_extension_edit_screen_save_redirect', bp_get_requested_url( ) );
|
3703 |
+
|
3704 |
+
bp_core_redirect( $redirect_to );
|
3705 |
+
die();
|
3706 |
+
}
|
3707 |
}
|
3708 |
|
3709 |
/**
|
3767 |
return ! empty( $matches[0] );
|
3768 |
}
|
3769 |
|
3770 |
+
/**
|
3771 |
+
* Detect redirects hardcoded into edit_screen_save() callbacks.
|
3772 |
+
*
|
3773 |
+
* @since BuddyPress (2.1.0)
|
3774 |
+
*
|
3775 |
+
* @param string $location
|
3776 |
+
* @return string
|
3777 |
+
*/
|
3778 |
+
public function detect_post_save_redirect( $redirect = '' ) {
|
3779 |
+
if ( ! empty( $redirect ) ) {
|
3780 |
+
$this->post_save_redirect = $redirect;
|
3781 |
+
}
|
3782 |
+
|
3783 |
+
return $redirect;
|
3784 |
+
}
|
3785 |
+
|
3786 |
/** Admin *************************************************************/
|
3787 |
|
3788 |
/**
|
4348 |
add_action( "admin_init", array( &$extension, "_register" ) );
|
4349 |
' ), 11 );
|
4350 |
}
|
4351 |
+
|
4352 |
+
/**
|
4353 |
+
* Adds support for user at-mentions (for users in a specific Group) to the Suggestions API.
|
4354 |
+
*
|
4355 |
+
* @since BuddyPress (2.1.0)
|
4356 |
+
*/
|
4357 |
+
class BP_Groups_Member_Suggestions extends BP_Members_Suggestions {
|
4358 |
+
|
4359 |
+
/**
|
4360 |
+
* Default arguments for this suggestions service.
|
4361 |
+
*
|
4362 |
+
* @since BuddyPress (2.1.0)
|
4363 |
+
* @var array $args {
|
4364 |
+
* @type int $group_id Positive integers will restrict the search to members in that group.
|
4365 |
+
* Negative integers will restrict the search to members in every other group.
|
4366 |
+
* @type int $limit Maximum number of results to display. Default: 16.
|
4367 |
+
* @type bool $only_friends If true, only match the current user's friends. Default: false.
|
4368 |
+
* @type string $term The suggestion service will try to find results that contain this string.
|
4369 |
+
* Mandatory.
|
4370 |
+
* }
|
4371 |
+
*/
|
4372 |
+
protected $default_args = array(
|
4373 |
+
'group_id' => 0,
|
4374 |
+
'limit' => 16,
|
4375 |
+
'only_friends' => false,
|
4376 |
+
'term' => '',
|
4377 |
+
'type' => '',
|
4378 |
+
);
|
4379 |
+
|
4380 |
+
|
4381 |
+
/**
|
4382 |
+
* Validate and sanitise the parameters for the suggestion service query.
|
4383 |
+
*
|
4384 |
+
* @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool).
|
4385 |
+
* @since BuddyPress (2.1.0)
|
4386 |
+
*/
|
4387 |
+
public function validate() {
|
4388 |
+
$this->args['group_id'] = (int) $this->args['group_id'];
|
4389 |
+
$this->args = apply_filters( 'bp_groups_member_suggestions_args', $this->args, $this );
|
4390 |
+
|
4391 |
+
// Check for invalid or missing mandatory parameters.
|
4392 |
+
if ( ! $this->args['group_id'] || ! bp_is_active( 'groups' ) ) {
|
4393 |
+
return new WP_Error( 'missing_requirement' );
|
4394 |
+
}
|
4395 |
+
|
4396 |
+
// Check that the specified group_id exists, and that the current user can access it.
|
4397 |
+
$the_group = groups_get_group( array(
|
4398 |
+
'group_id' => absint( $this->args['group_id'] ),
|
4399 |
+
'populate_extras' => true,
|
4400 |
+
) );
|
4401 |
+
|
4402 |
+
if ( $the_group->id === 0 || ! $the_group->user_has_access ) {
|
4403 |
+
return new WP_Error( 'access_denied' );
|
4404 |
+
}
|
4405 |
+
|
4406 |
+
return apply_filters( 'bp_groups_member_suggestions_validate_args', parent::validate(), $this );
|
4407 |
+
}
|
4408 |
+
|
4409 |
+
/**
|
4410 |
+
* Find and return a list of username suggestions that match the query.
|
4411 |
+
*
|
4412 |
+
* @return array|WP_Error Array of results. If there were problems, returns a WP_Error object.
|
4413 |
+
* @since BuddyPress (2.1.0)
|
4414 |
+
*/
|
4415 |
+
public function get_suggestions() {
|
4416 |
+
$user_query = array(
|
4417 |
+
'count_total' => '', // Prevents total count
|
4418 |
+
'populate_extras' => false,
|
4419 |
+
'type' => 'alphabetical',
|
4420 |
+
|
4421 |
+
'group_role' => array( 'admin', 'member', 'mod' ),
|
4422 |
+
'page' => 1,
|
4423 |
+
'per_page' => $this->args['limit'],
|
4424 |
+
'search_terms' => $this->args['term'],
|
4425 |
+
'search_wildcard' => 'right',
|
4426 |
+
);
|
4427 |
+
|
4428 |
+
// Only return matches of friends of this user.
|
4429 |
+
if ( $this->args['only_friends'] && is_user_logged_in() ) {
|
4430 |
+
$user_query['user_id'] = get_current_user_id();
|
4431 |
+
}
|
4432 |
+
|
4433 |
+
// Positive Group IDs will restrict the search to members in that group.
|
4434 |
+
if ( $this->args['group_id'] > 0 ) {
|
4435 |
+
$user_query['group_id'] = $this->args['group_id'];
|
4436 |
+
|
4437 |
+
// Negative Group IDs will restrict the search to members in every other group.
|
4438 |
+
} else {
|
4439 |
+
$group_query = array(
|
4440 |
+
'count_total' => '', // Prevents total count
|
4441 |
+
'populate_extras' => false,
|
4442 |
+
'type' => 'alphabetical',
|
4443 |
+
|
4444 |
+
'group_id' => absint( $this->args['group_id'] ),
|
4445 |
+
'group_role' => array( 'admin', 'member', 'mod' ),
|
4446 |
+
'page' => 1,
|
4447 |
+
);
|
4448 |
+
$group_users = new BP_Group_Member_Query( $group_query );
|
4449 |
+
|
4450 |
+
if ( $group_users->results ) {
|
4451 |
+
$user_query['exclude'] = wp_list_pluck( $group_users->results, 'ID' );
|
4452 |
+
} else {
|
4453 |
+
$user_query['include'] = array( 0 );
|
4454 |
+
}
|
4455 |
+
}
|
4456 |
+
|
4457 |
+
$user_query = apply_filters( 'bp_groups_member_suggestions_query_args', $user_query, $this );
|
4458 |
+
if ( is_wp_error( $user_query ) ) {
|
4459 |
+
return $user_query;
|
4460 |
+
}
|
4461 |
+
|
4462 |
+
|
4463 |
+
if ( isset( $user_query['group_id'] ) ) {
|
4464 |
+
$user_query = new BP_Group_Member_Query( $user_query );
|
4465 |
+
} else {
|
4466 |
+
$user_query = new BP_User_Query( $user_query );
|
4467 |
+
}
|
4468 |
+
|
4469 |
+
$results = array();
|
4470 |
+
foreach ( $user_query->results as $user ) {
|
4471 |
+
$result = new stdClass();
|
4472 |
+
$result->ID = $user->user_nicename;
|
4473 |
+
$result->image = bp_core_fetch_avatar( array( 'html' => false, 'item_id' => $user->ID ) );
|
4474 |
+
$result->name = bp_core_get_user_displayname( $user->ID );
|
4475 |
+
|
4476 |
+
$results[] = $result;
|
4477 |
+
}
|
4478 |
+
|
4479 |
+
return apply_filters( 'bp_groups_member_suggestions_get_suggestions', $results, $this );
|
4480 |
+
}
|
4481 |
+
}
|
@@ -33,12 +33,12 @@ add_filter( 'bp_get_group_description_excerpt', 'wpautop' );
|
|
33 |
add_filter( 'bp_get_group_description', 'make_clickable', 9 );
|
34 |
add_filter( 'bp_get_group_description_excerpt', 'make_clickable', 9 );
|
35 |
|
36 |
-
add_filter( 'bp_get_group_name', 'wp_filter_kses',
|
37 |
-
add_filter( 'bp_get_group_permalink', 'wp_filter_kses',
|
38 |
add_filter( 'bp_get_group_description', 'bp_groups_filter_kses', 1 );
|
39 |
-
add_filter( 'bp_get_group_description_excerpt', 'wp_filter_kses',
|
40 |
-
add_filter( 'groups_group_name_before_save', 'wp_filter_kses',
|
41 |
-
add_filter( 'groups_group_description_before_save', 'wp_filter_kses',
|
42 |
|
43 |
add_filter( 'bp_get_group_description', 'stripslashes' );
|
44 |
add_filter( 'bp_get_group_description_excerpt', 'stripslashes' );
|
@@ -65,23 +65,49 @@ add_filter( 'bp_get_total_group_count', 'bp_core_number_format' );
|
|
65 |
add_filter( 'bp_get_group_total_for_member', 'bp_core_number_format' );
|
66 |
add_filter( 'bp_get_group_total_members', 'bp_core_number_format' );
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
}
|
86 |
|
87 |
/** Group forums **************************************************************/
|
33 |
add_filter( 'bp_get_group_description', 'make_clickable', 9 );
|
34 |
add_filter( 'bp_get_group_description_excerpt', 'make_clickable', 9 );
|
35 |
|
36 |
+
add_filter( 'bp_get_group_name', 'wp_filter_kses', 1 );
|
37 |
+
add_filter( 'bp_get_group_permalink', 'wp_filter_kses', 1 );
|
38 |
add_filter( 'bp_get_group_description', 'bp_groups_filter_kses', 1 );
|
39 |
+
add_filter( 'bp_get_group_description_excerpt', 'wp_filter_kses', 1 );
|
40 |
+
add_filter( 'groups_group_name_before_save', 'wp_filter_kses', 1 );
|
41 |
+
add_filter( 'groups_group_description_before_save', 'wp_filter_kses', 1 );
|
42 |
|
43 |
add_filter( 'bp_get_group_description', 'stripslashes' );
|
44 |
add_filter( 'bp_get_group_description_excerpt', 'stripslashes' );
|
65 |
add_filter( 'bp_get_group_total_for_member', 'bp_core_number_format' );
|
66 |
add_filter( 'bp_get_group_total_members', 'bp_core_number_format' );
|
67 |
|
68 |
+
/**
|
69 |
+
* Filter output of Group Description through WordPress's KSES API.
|
70 |
+
*
|
71 |
+
* @since BuddyPress (1.1.0)
|
72 |
+
*
|
73 |
+
* @param string $content
|
74 |
+
* @return string
|
75 |
+
*/
|
76 |
+
function bp_groups_filter_kses( $content = '' ) {
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Note that we don't immediately bail if $content is empty. This is because
|
80 |
+
* WordPress's KSES API calls several other filters that might be relevant
|
81 |
+
* to someone's workflow (like `pre_kses`)
|
82 |
+
*/
|
83 |
+
|
84 |
+
// Get allowed tags using core WordPress API allowing third party plugins
|
85 |
+
// to target the specific `buddypress-groups` context.
|
86 |
+
$allowed_tags = wp_kses_allowed_html( 'buddypress-groups' );
|
87 |
+
|
88 |
+
// Add our own tags allowed in group descriptions
|
89 |
+
$allowed_tags['a']['class'] = array();
|
90 |
+
$allowed_tags['img'] = array();
|
91 |
+
$allowed_tags['img']['src'] = array();
|
92 |
+
$allowed_tags['img']['alt'] = array();
|
93 |
+
$allowed_tags['img']['class'] = array();
|
94 |
+
$allowed_tags['img']['width'] = array();
|
95 |
+
$allowed_tags['img']['height'] = array();
|
96 |
+
$allowed_tags['img']['class'] = array();
|
97 |
+
$allowed_tags['img']['id'] = array();
|
98 |
+
$allowed_tags['code'] = array();
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Filter HTML elements allowed for a given context.
|
102 |
+
*
|
103 |
+
* @since BuddyPress (1.1.0)
|
104 |
+
*
|
105 |
+
* @param string $allowed_tags Allowed tags, attributes, and/or entities.
|
106 |
+
*/
|
107 |
+
$tags = apply_filters( 'bp_groups_filter_kses', $allowed_tags );
|
108 |
+
|
109 |
+
// Return KSES'ed content, allowing the above tags
|
110 |
+
return wp_kses( $content, $tags );
|
111 |
}
|
112 |
|
113 |
/** Group forums **************************************************************/
|
@@ -24,23 +24,28 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|
24 |
*
|
25 |
* @param int $group_id The group ID that the new forum should be attached to
|
26 |
* @param string $group_name The group name
|
27 |
-
* @param string $
|
28 |
*
|
29 |
* @since BuddyPress (1.0)
|
30 |
*/
|
31 |
function groups_new_group_forum( $group_id = 0, $group_name = '', $group_desc = '' ) {
|
32 |
-
global $bp;
|
33 |
|
34 |
-
if ( empty( $group_id ) )
|
35 |
$group_id = bp_get_current_group_id();
|
|
|
36 |
|
37 |
-
if ( empty( $group_name ) )
|
38 |
$group_name = bp_get_current_group_name();
|
|
|
39 |
|
40 |
-
if ( empty( $group_desc ) )
|
41 |
-
$group_desc =
|
|
|
42 |
|
43 |
-
$forum_id = bp_forums_new_forum( array(
|
|
|
|
|
|
|
44 |
|
45 |
groups_update_groupmeta( $group_id, 'forum_id', $forum_id );
|
46 |
|
@@ -68,17 +73,16 @@ function groups_update_group_forum( $group_id ) {
|
|
68 |
* 3. The built-in bbPress forums are not correctly installed (usually means they've been
|
69 |
* uninstalled)
|
70 |
*/
|
71 |
-
if ( empty( $group->enable_forum ) || !bp_is_active( 'forums' ) || ( function_exists( 'bp_forums_is_installed_correctly' ) && !bp_forums_is_installed_correctly() ) )
|
72 |
return false;
|
|
|
73 |
|
74 |
-
|
75 |
-
'forum_id'
|
76 |
-
'forum_name'
|
77 |
-
'forum_desc'
|
78 |
-
'forum_slug'
|
79 |
-
);
|
80 |
-
|
81 |
-
bp_forums_update_forum( apply_filters( 'groups_update_group_forum', $args ) );
|
82 |
}
|
83 |
add_action( 'groups_details_updated', 'groups_update_group_forum' );
|
84 |
|
@@ -95,38 +99,43 @@ add_action( 'groups_details_updated', 'groups_update_group_forum' );
|
|
95 |
* @since BuddyPress (1.0)
|
96 |
*/
|
97 |
function groups_new_group_forum_post( $post_text, $topic_id, $page = false ) {
|
98 |
-
if ( empty( $post_text ) )
|
99 |
return false;
|
|
|
100 |
|
101 |
-
$post_text = apply_filters( 'group_forum_post_text_before_save',
|
102 |
-
$topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
|
111 |
-
|
112 |
-
|
|
|
|
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
'content' => apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_id, $post_text, &$topic ) ),
|
118 |
-
'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', "{$primary_link}#post-{$post_id}" ),
|
119 |
-
'type' => 'new_forum_post',
|
120 |
-
'item_id' => bp_get_current_group_id(),
|
121 |
-
'secondary_item_id' => $post_id
|
122 |
-
) );
|
123 |
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
|
126 |
-
|
127 |
-
}
|
128 |
|
129 |
-
return
|
130 |
}
|
131 |
|
132 |
/**
|
@@ -146,33 +155,38 @@ function groups_new_group_forum_topic( $topic_title, $topic_text, $topic_tags, $
|
|
146 |
if ( empty( $topic_title ) || empty( $topic_text ) )
|
147 |
return false;
|
148 |
|
149 |
-
$topic_title = apply_filters( 'group_forum_topic_title_before_save',
|
150 |
-
$topic_text = apply_filters( 'group_forum_topic_text_before_save',
|
151 |
-
$topic_tags = apply_filters( 'group_forum_topic_tags_before_save',
|
152 |
-
$forum_id = apply_filters( 'group_forum_topic_forum_id_before_save', $forum_id
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
'content' => apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &$topic ) ),
|
164 |
-
'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/' ),
|
165 |
-
'type' => 'new_forum_topic',
|
166 |
-
'item_id' => bp_get_current_group_id(),
|
167 |
-
'secondary_item_id' => $topic->topic_id
|
168 |
-
) );
|
169 |
|
170 |
-
|
|
|
|
|
171 |
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
|
175 |
-
return
|
176 |
}
|
177 |
|
178 |
/**
|
@@ -189,45 +203,50 @@ function groups_new_group_forum_topic( $topic_title, $topic_text, $topic_tags, $
|
|
189 |
* @since BuddyPress (1.1)
|
190 |
*/
|
191 |
function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text, $topic_tags = false ) {
|
192 |
-
|
193 |
|
194 |
$topic_title = apply_filters( 'group_forum_topic_title_before_save', $topic_title );
|
195 |
$topic_text = apply_filters( 'group_forum_topic_text_before_save', $topic_text );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
'component' => $bp->groups->id,
|
205 |
-
'type' => 'new_forum_topic'
|
206 |
-
) );
|
207 |
-
}
|
208 |
-
|
209 |
-
$activity_action = sprintf( __( '%1$s edited the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
|
210 |
-
$activity_content = bp_create_excerpt( $topic_text );
|
211 |
-
|
212 |
-
// Record this in activity streams
|
213 |
-
groups_record_activity( array(
|
214 |
-
'id' => $id,
|
215 |
-
'action' => apply_filters_ref_array( 'groups_activity_new_forum_topic_action', array( $activity_action, $topic_text, &$topic ) ),
|
216 |
-
'content' => apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &$topic ) ),
|
217 |
-
'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/' ),
|
218 |
-
'type' => 'new_forum_topic',
|
219 |
-
'item_id' => (int) bp_get_current_group_id(),
|
220 |
-
'user_id' => (int) $topic->topic_poster,
|
221 |
-
'secondary_item_id' => $topic->topic_id,
|
222 |
-
'recorded_time ' => $topic->topic_time
|
223 |
) );
|
224 |
-
|
225 |
-
do_action_ref_array( 'groups_update_group_forum_topic', array( &$topic ) );
|
226 |
-
|
227 |
-
return $topic;
|
228 |
}
|
229 |
|
230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
}
|
232 |
|
233 |
/**
|
@@ -244,52 +263,59 @@ function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text,
|
|
244 |
* @since BuddyPress (1.1)
|
245 |
*/
|
246 |
function groups_update_group_forum_post( $post_id, $post_text, $topic_id, $page = false ) {
|
247 |
-
|
248 |
|
249 |
$post_text = apply_filters( 'group_forum_post_text_before_save', $post_text );
|
250 |
$topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
|
251 |
$post = bp_forums_get_post( $post_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
$activity_content = bp_create_excerpt( $post_text );
|
258 |
-
$primary_link = bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/';
|
259 |
-
|
260 |
-
if ( $page )
|
261 |
-
$primary_link .= "?topic_page=" . $page;
|
262 |
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
'user_id' => $post->poster_id,
|
267 |
-
'component' => $bp->groups->id,
|
268 |
-
'type' => 'new_forum_post',
|
269 |
-
'item_id' => bp_get_current_group_id(),
|
270 |
-
'secondary_item_id' => $post_id
|
271 |
-
) );
|
272 |
-
}
|
273 |
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
'
|
278 |
-
'
|
279 |
-
'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id ),
|
280 |
'type' => 'new_forum_post',
|
281 |
-
'item_id' =>
|
282 |
-
'
|
283 |
-
|
284 |
-
'recorded_time' => $post->post_time
|
285 |
-
) );
|
286 |
-
|
287 |
-
do_action_ref_array( 'groups_update_group_forum_post', array( $post, &$topic ) );
|
288 |
-
|
289 |
-
return $post_id;
|
290 |
}
|
291 |
|
292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
}
|
294 |
|
295 |
/**
|
@@ -308,16 +334,18 @@ function groups_update_group_forum_post( $post_id, $post_text, $topic_id, $page
|
|
308 |
* @since BuddyPress (1.1)
|
309 |
*/
|
310 |
function groups_delete_group_forum_topic( $topic_id ) {
|
311 |
-
|
312 |
|
313 |
// Before deleting the thread, get the post ids so that their activity items can be deleted
|
314 |
-
$posts
|
|
|
315 |
|
316 |
-
if (
|
317 |
do_action( 'groups_before_delete_group_forum_topic', $topic_id );
|
318 |
|
319 |
// Delete the corresponding activity stream items
|
320 |
if ( bp_is_active( 'activity' ) ) {
|
|
|
321 |
// The activity item for the initial topic
|
322 |
bp_activity_delete( array(
|
323 |
'item_id' => bp_get_current_group_id(),
|
@@ -338,11 +366,9 @@ function groups_delete_group_forum_topic( $topic_id ) {
|
|
338 |
}
|
339 |
|
340 |
do_action( 'groups_delete_group_forum_topic', $topic_id );
|
341 |
-
|
342 |
-
return true;
|
343 |
}
|
344 |
|
345 |
-
return
|
346 |
}
|
347 |
|
348 |
/**
|
@@ -353,33 +379,34 @@ function groups_delete_group_forum_topic( $topic_id ) {
|
|
353 |
* @package BuddyPress
|
354 |
*
|
355 |
* @param int $post_id The id of the post you want to delete
|
356 |
-
* @param int $topic_id Optional. The topic to which the post belongs. This
|
357 |
-
*
|
|
|
358 |
* @return bool True on success.
|
359 |
*
|
360 |
* @since BuddyPress (1.1)
|
361 |
*/
|
362 |
function groups_delete_group_forum_post( $post_id, $topic_id = false ) {
|
363 |
-
global $bp;
|
364 |
|
365 |
-
|
|
|
|
|
366 |
do_action( 'groups_before_delete_group_forum_post', $post_id, $topic_id );
|
367 |
|
368 |
// Delete the corresponding activity stream item
|
369 |
-
if ( bp_is_active( 'activity' ) )
|
370 |
bp_activity_delete( array(
|
371 |
'item_id' => bp_get_current_group_id(),
|
372 |
'secondary_item_id' => $post_id,
|
373 |
-
'component' =>
|
374 |
'type' => 'new_forum_post'
|
375 |
) );
|
|
|
376 |
|
377 |
do_action( 'groups_delete_group_forum_post', $post_id, $topic_id );
|
378 |
-
|
379 |
-
return true;
|
380 |
}
|
381 |
|
382 |
-
return
|
383 |
}
|
384 |
|
385 |
/**
|
24 |
*
|
25 |
* @param int $group_id The group ID that the new forum should be attached to
|
26 |
* @param string $group_name The group name
|
27 |
+
* @param string $group_desc The group description
|
28 |
*
|
29 |
* @since BuddyPress (1.0)
|
30 |
*/
|
31 |
function groups_new_group_forum( $group_id = 0, $group_name = '', $group_desc = '' ) {
|
|
|
32 |
|
33 |
+
if ( empty( $group_id ) ) {
|
34 |
$group_id = bp_get_current_group_id();
|
35 |
+
}
|
36 |
|
37 |
+
if ( empty( $group_name ) ) {
|
38 |
$group_name = bp_get_current_group_name();
|
39 |
+
}
|
40 |
|
41 |
+
if ( empty( $group_desc ) ) {
|
42 |
+
$group_desc = bp_get_current_group_description();
|
43 |
+
}
|
44 |
|
45 |
+
$forum_id = bp_forums_new_forum( array(
|
46 |
+
'forum_name' => $group_name,
|
47 |
+
'forum_desc' => $group_desc
|
48 |
+
) );
|
49 |
|
50 |
groups_update_groupmeta( $group_id, 'forum_id', $forum_id );
|
51 |
|
73 |
* 3. The built-in bbPress forums are not correctly installed (usually means they've been
|
74 |
* uninstalled)
|
75 |
*/
|
76 |
+
if ( empty( $group->enable_forum ) || !bp_is_active( 'forums' ) || ( function_exists( 'bp_forums_is_installed_correctly' ) && !bp_forums_is_installed_correctly() ) ) {
|
77 |
return false;
|
78 |
+
}
|
79 |
|
80 |
+
bp_forums_update_forum( apply_filters( 'groups_update_group_forum', array(
|
81 |
+
'forum_id' => groups_get_groupmeta( $group_id, 'forum_id' ),
|
82 |
+
'forum_name' => $group->name,
|
83 |
+
'forum_desc' => $group->description,
|
84 |
+
'forum_slug' => $group->slug
|
85 |
+
) ) );
|
|
|
|
|
86 |
}
|
87 |
add_action( 'groups_details_updated', 'groups_update_group_forum' );
|
88 |
|
99 |
* @since BuddyPress (1.0)
|
100 |
*/
|
101 |
function groups_new_group_forum_post( $post_text, $topic_id, $page = false ) {
|
102 |
+
if ( empty( $post_text ) ) {
|
103 |
return false;
|
104 |
+
}
|
105 |
|
106 |
+
$post_text = apply_filters( 'group_forum_post_text_before_save', $post_text );
|
107 |
+
$topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
|
108 |
+
$post_id = bp_forums_insert_post( array(
|
109 |
+
'post_text' => $post_text,
|
110 |
+
'topic_id' => $topic_id
|
111 |
+
) );
|
112 |
|
113 |
+
if ( empty( $post_id ) ) {
|
114 |
+
return false;
|
115 |
+
}
|
116 |
|
117 |
+
$topic = bp_forums_get_topic_details( $topic_id );
|
118 |
+
$activity_action = sprintf( __( '%1$s replied to the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( bp_loggedin_user_id() ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
|
119 |
+
$activity_content = bp_create_excerpt( $post_text );
|
120 |
+
$primary_link = bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/';
|
121 |
|
122 |
+
if ( !empty( $page ) ) {
|
123 |
+
$primary_link .= "?topic_page=" . $page;
|
124 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
|
126 |
+
// Record this in activity streams
|
127 |
+
groups_record_activity( array(
|
128 |
+
'action' => apply_filters_ref_array( 'groups_activity_new_forum_post_action', array( $activity_action, $post_id, $post_text, &$topic ) ),
|
129 |
+
'content' => apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_id, $post_text, &$topic ) ),
|
130 |
+
'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', "{$primary_link}#post-{$post_id}" ),
|
131 |
+
'type' => 'new_forum_post',
|
132 |
+
'item_id' => bp_get_current_group_id(),
|
133 |
+
'secondary_item_id' => $post_id
|
134 |
+
) );
|
135 |
|
136 |
+
do_action( 'groups_new_forum_topic_post', bp_get_current_group_id(), $post_id );
|
|
|
137 |
|
138 |
+
return $post_id;
|
139 |
}
|
140 |
|
141 |
/**
|
155 |
if ( empty( $topic_title ) || empty( $topic_text ) )
|
156 |
return false;
|
157 |
|
158 |
+
$topic_title = apply_filters( 'group_forum_topic_title_before_save', $topic_title );
|
159 |
+
$topic_text = apply_filters( 'group_forum_topic_text_before_save', $topic_text );
|
160 |
+
$topic_tags = apply_filters( 'group_forum_topic_tags_before_save', $topic_tags );
|
161 |
+
$forum_id = apply_filters( 'group_forum_topic_forum_id_before_save', $forum_id );
|
162 |
+
$topic_id = bp_forums_new_topic( array(
|
163 |
+
'topic_title' => $topic_title,
|
164 |
+
'topic_text' => $topic_text,
|
165 |
+
'topic_tags' => $topic_tags,
|
166 |
+
'forum_id' => $forum_id
|
167 |
+
) );
|
168 |
+
|
169 |
+
if ( empty( $topic_id ) ) {
|
170 |
+
return false;
|
171 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
+
$topic = bp_forums_get_topic_details( $topic_id );
|
174 |
+
$activity_action = sprintf( __( '%1$s started the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( bp_loggedin_user_id() ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
|
175 |
+
$activity_content = bp_create_excerpt( $topic_text );
|
176 |
|
177 |
+
// Record this in activity streams
|
178 |
+
groups_record_activity( array(
|
179 |
+
'action' => apply_filters_ref_array( 'groups_activity_new_forum_topic_action', array( $activity_action, $topic_text, &$topic ) ),
|
180 |
+
'content' => apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &$topic ) ),
|
181 |
+
'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/' ),
|
182 |
+
'type' => 'new_forum_topic',
|
183 |
+
'item_id' => bp_get_current_group_id(),
|
184 |
+
'secondary_item_id' => $topic->topic_id
|
185 |
+
) );
|
186 |
+
|
187 |
+
do_action_ref_array( 'groups_new_forum_topic', array( bp_get_current_group_id(), &$topic ) );
|
188 |
|
189 |
+
return $topic;
|
190 |
}
|
191 |
|
192 |
/**
|
203 |
* @since BuddyPress (1.1)
|
204 |
*/
|
205 |
function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text, $topic_tags = false ) {
|
206 |
+
$bp = buddypress();
|
207 |
|
208 |
$topic_title = apply_filters( 'group_forum_topic_title_before_save', $topic_title );
|
209 |
$topic_text = apply_filters( 'group_forum_topic_text_before_save', $topic_text );
|
210 |
+
$topic = bp_forums_update_topic( array(
|
211 |
+
'topic_title' => $topic_title,
|
212 |
+
'topic_text' => $topic_text,
|
213 |
+
'topic_id' => $topic_id,
|
214 |
+
'topic_tags' => $topic_tags
|
215 |
+
) );
|
216 |
+
|
217 |
+
if ( empty( $topic ) ) {
|
218 |
+
return false;
|
219 |
+
}
|
220 |
|
221 |
+
// Get the corresponding activity item
|
222 |
+
if ( bp_is_active( 'activity' ) ) {
|
223 |
+
$id = bp_activity_get_activity_id( array(
|
224 |
+
'item_id' => bp_get_current_group_id(),
|
225 |
+
'secondary_item_id' => $topic_id,
|
226 |
+
'component' => $bp->groups->id,
|
227 |
+
'type' => 'new_forum_topic'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
) );
|
|
|
|
|
|
|
|
|
229 |
}
|
230 |
|
231 |
+
$activity_action = sprintf( __( '%1$s edited the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
|
232 |
+
$activity_content = bp_create_excerpt( $topic_text );
|
233 |
+
|
234 |
+
// Record this in activity streams
|
235 |
+
groups_record_activity( array(
|
236 |
+
'id' => $id,
|
237 |
+
'action' => apply_filters_ref_array( 'groups_activity_new_forum_topic_action', array( $activity_action, $topic_text, &$topic ) ),
|
238 |
+
'content' => apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &$topic ) ),
|
239 |
+
'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/' ),
|
240 |
+
'type' => 'new_forum_topic',
|
241 |
+
'item_id' => (int) bp_get_current_group_id(),
|
242 |
+
'user_id' => (int) $topic->topic_poster,
|
243 |
+
'secondary_item_id' => $topic->topic_id,
|
244 |
+
'recorded_time ' => $topic->topic_time
|
245 |
+
) );
|
246 |
+
|
247 |
+
do_action_ref_array( 'groups_update_group_forum_topic', array( &$topic ) );
|
248 |
+
|
249 |
+
return $topic;
|
250 |
}
|
251 |
|
252 |
/**
|
263 |
* @since BuddyPress (1.1)
|
264 |
*/
|
265 |
function groups_update_group_forum_post( $post_id, $post_text, $topic_id, $page = false ) {
|
266 |
+
$bp = buddypress();
|
267 |
|
268 |
$post_text = apply_filters( 'group_forum_post_text_before_save', $post_text );
|
269 |
$topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
|
270 |
$post = bp_forums_get_post( $post_id );
|
271 |
+
$post_id = bp_forums_insert_post( array(
|
272 |
+
'post_id' => $post_id,
|
273 |
+
'post_text' => $post_text,
|
274 |
+
'post_time' => $post->post_time,
|
275 |
+
'topic_id' => $topic_id,
|
276 |
+
'poster_id' => $post->poster_id
|
277 |
+
) );
|
278 |
+
|
279 |
+
if ( empty( $post_id ) ) {
|
280 |
+
return false;
|
281 |
+
}
|
282 |
|
283 |
+
$topic = bp_forums_get_topic_details( $topic_id );
|
284 |
+
$activity_action = sprintf( __( '%1$s replied to the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
|
285 |
+
$activity_content = bp_create_excerpt( $post_text );
|
286 |
+
$primary_link = bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/';
|
|
|
|
|
|
|
|
|
|
|
287 |
|
288 |
+
if ( !empty( $page ) ) {
|
289 |
+
$primary_link .= "?topic_page=" . $page;
|
290 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
|
292 |
+
// Get the corresponding activity item
|
293 |
+
if ( bp_is_active( 'activity' ) ) {
|
294 |
+
$id = bp_activity_get_activity_id( array(
|
295 |
+
'user_id' => $post->poster_id,
|
296 |
+
'component' => $bp->groups->id,
|
|
|
297 |
'type' => 'new_forum_post',
|
298 |
+
'item_id' => bp_get_current_group_id(),
|
299 |
+
'secondary_item_id' => $post_id
|
300 |
+
) );
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
}
|
302 |
|
303 |
+
// Update the entry in activity streams
|
304 |
+
groups_record_activity( array(
|
305 |
+
'id' => $id,
|
306 |
+
'action' => apply_filters_ref_array( 'groups_activity_new_forum_post_action', array( $activity_action, $post_text, &$topic, &$topic ) ),
|
307 |
+
'content' => apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_text, &$topic, &$topic ) ),
|
308 |
+
'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id ),
|
309 |
+
'type' => 'new_forum_post',
|
310 |
+
'item_id' => (int) bp_get_current_group_id(),
|
311 |
+
'user_id' => (int) $post->poster_id,
|
312 |
+
'secondary_item_id' => $post_id,
|
313 |
+
'recorded_time' => $post->post_time
|
314 |
+
) );
|
315 |
+
|
316 |
+
do_action_ref_array( 'groups_update_group_forum_post', array( $post, &$topic ) );
|
317 |
+
|
318 |
+
return $post_id;
|
319 |
}
|
320 |
|
321 |
/**
|
334 |
* @since BuddyPress (1.1)
|
335 |
*/
|
336 |
function groups_delete_group_forum_topic( $topic_id ) {
|
337 |
+
$bp = buddypress();
|
338 |
|
339 |
// Before deleting the thread, get the post ids so that their activity items can be deleted
|
340 |
+
$posts = bp_forums_get_topic_posts( array( 'topic_id' => $topic_id, 'per_page' => -1 ) );
|
341 |
+
$action = bp_forums_delete_topic( array( 'topic_id' => $topic_id ) );
|
342 |
|
343 |
+
if ( !empty( $action ) ) {
|
344 |
do_action( 'groups_before_delete_group_forum_topic', $topic_id );
|
345 |
|
346 |
// Delete the corresponding activity stream items
|
347 |
if ( bp_is_active( 'activity' ) ) {
|
348 |
+
|
349 |
// The activity item for the initial topic
|
350 |
bp_activity_delete( array(
|
351 |
'item_id' => bp_get_current_group_id(),
|
366 |
}
|
367 |
|
368 |
do_action( 'groups_delete_group_forum_topic', $topic_id );
|
|
|
|
|
369 |
}
|
370 |
|
371 |
+
return (bool) $action;
|
372 |
}
|
373 |
|
374 |
/**
|
379 |
* @package BuddyPress
|
380 |
*
|
381 |
* @param int $post_id The id of the post you want to delete
|
382 |
+
* @param int $topic_id Optional. The topic to which the post belongs. This
|
383 |
+
* value isn't used in the function but is passed along to
|
384 |
+
* do_action() hooks.
|
385 |
* @return bool True on success.
|
386 |
*
|
387 |
* @since BuddyPress (1.1)
|
388 |
*/
|
389 |
function groups_delete_group_forum_post( $post_id, $topic_id = false ) {
|
|
|
390 |
|
391 |
+
$action = bp_forums_delete_post( array( 'post_id' => $post_id ) );
|
392 |
+
|
393 |
+
if ( !empty( $action ) ) {
|
394 |
do_action( 'groups_before_delete_group_forum_post', $post_id, $topic_id );
|
395 |
|
396 |
// Delete the corresponding activity stream item
|
397 |
+
if ( bp_is_active( 'activity' ) ) {
|
398 |
bp_activity_delete( array(
|
399 |
'item_id' => bp_get_current_group_id(),
|
400 |
'secondary_item_id' => $post_id,
|
401 |
+
'component' => buddypress()->groups->id,
|
402 |
'type' => 'new_forum_post'
|
403 |
) );
|
404 |
+
}
|
405 |
|
406 |
do_action( 'groups_delete_group_forum_post', $post_id, $topic_id );
|
|
|
|
|
407 |
}
|
408 |
|
409 |
+
return (bool) $action;
|
410 |
}
|
411 |
|
412 |
/**
|
@@ -305,7 +305,7 @@ function groups_leave_group( $group_id, $user_id = 0 ) {
|
|
305 |
// Don't let single admins leave the group.
|
306 |
if ( count( groups_get_group_admins( $group_id ) ) < 2 ) {
|
307 |
if ( groups_is_user_admin( $user_id, $group_id ) ) {
|
308 |
-
bp_core_add_message( __( 'As the only
|
309 |
return false;
|
310 |
}
|
311 |
}
|
305 |
// Don't let single admins leave the group.
|
306 |
if ( count( groups_get_group_admins( $group_id ) ) < 2 ) {
|
307 |
if ( groups_is_user_admin( $user_id, $group_id ) ) {
|
308 |
+
bp_core_add_message( __( 'As the only admin, you cannot leave the group.', 'buddypress' ), 'error' );
|
309 |
return false;
|
310 |
}
|
311 |
}
|
@@ -80,7 +80,7 @@ class BP_Groups_Component extends BP_Component {
|
|
80 |
public function __construct() {
|
81 |
parent::start(
|
82 |
'groups',
|
83 |
-
|
84 |
buddypress()->plugin_dir,
|
85 |
array(
|
86 |
'adminbar_myaccount_order' => 70
|
@@ -102,7 +102,6 @@ class BP_Groups_Component extends BP_Component {
|
|
102 |
'widgets',
|
103 |
'activity',
|
104 |
'template',
|
105 |
-
'buddybar',
|
106 |
'adminbar',
|
107 |
'functions',
|
108 |
'notifications'
|
@@ -129,7 +128,7 @@ class BP_Groups_Component extends BP_Component {
|
|
129 |
if ( !defined( 'BP_GROUPS_SLUG' ) )
|
130 |
define( 'BP_GROUPS_SLUG', $this->id );
|
131 |
|
132 |
-
// Global tables for
|
133 |
$global_tables = array(
|
134 |
'table_name' => $bp->table_prefix . 'bp_groups',
|
135 |
'table_name_members' => $bp->table_prefix . 'bp_groups_members',
|
@@ -149,7 +148,7 @@ class BP_Groups_Component extends BP_Component {
|
|
149 |
'has_directory' => true,
|
150 |
'directory_title' => _x( 'Groups', 'component directory title', 'buddypress' ),
|
151 |
'notification_callback' => 'groups_format_notifications',
|
152 |
-
'search_string' =>
|
153 |
'global_tables' => $global_tables,
|
154 |
'meta_tables' => $meta_tables,
|
155 |
);
|
@@ -241,91 +240,22 @@ class BP_Groups_Component extends BP_Component {
|
|
241 |
return;
|
242 |
}
|
243 |
|
244 |
-
if ( bp_is_groups_component() && !empty( $this->current_group ) ) {
|
245 |
-
|
246 |
-
$this->default_extension = apply_filters( 'bp_groups_default_extension', defined( 'BP_GROUPS_DEFAULT_EXTENSION' ) ? BP_GROUPS_DEFAULT_EXTENSION : 'home' );
|
247 |
-
|
248 |
-
if ( !bp_current_action() ) {
|
249 |
-
$bp->current_action = $this->default_extension;
|
250 |
-
}
|
251 |
-
|
252 |
-
// Prepare for a redirect to the canonical URL
|
253 |
-
$bp->canonical_stack['base_url'] = bp_get_group_permalink( $this->current_group );
|
254 |
-
|
255 |
-
if ( bp_current_action() ) {
|
256 |
-
$bp->canonical_stack['action'] = bp_current_action();
|
257 |
-
}
|
258 |
-
|
259 |
-
if ( !empty( $bp->action_variables ) ) {
|
260 |
-
$bp->canonical_stack['action_variables'] = bp_action_variables();
|
261 |
-
}
|
262 |
-
|
263 |
-
// When viewing the default extension, the canonical URL should not have
|
264 |
-
// that extension's slug, unless more has been tacked onto the URL via
|
265 |
-
// action variables
|
266 |
-
if ( bp_is_current_action( $this->default_extension ) && empty( $bp->action_variables ) ) {
|
267 |
-
unset( $bp->canonical_stack['action'] );
|
268 |
-
}
|
269 |
-
|
270 |
-
}
|
271 |
-
|
272 |
-
// Group access control
|
273 |
-
if ( bp_is_groups_component() && !empty( $this->current_group ) ) {
|
274 |
-
if ( !$this->current_group->user_has_access ) {
|
275 |
-
|
276 |
-
// Hidden groups should return a 404 for non-members.
|
277 |
-
// Unset the current group so that you're not redirected
|
278 |
-
// to the default group tab
|
279 |
-
if ( 'hidden' == $this->current_group->status ) {
|
280 |
-
$this->current_group = 0;
|
281 |
-
$bp->is_single_item = false;
|
282 |
-
bp_do_404();
|
283 |
-
return;
|
284 |
-
|
285 |
-
// Skip the no_access check on home and membership request pages
|
286 |
-
} elseif ( !bp_is_current_action( 'home' ) && !bp_is_current_action( 'request-membership' ) ) {
|
287 |
-
|
288 |
-
// Off-limits to this user. Throw an error and redirect to the group's home page
|
289 |
-
if ( is_user_logged_in() ) {
|
290 |
-
bp_core_no_access( array(
|
291 |
-
'message' => __( 'You do not have access to this group.', 'buddypress' ),
|
292 |
-
'root' => bp_get_group_permalink( $bp->groups->current_group ) . 'home/',
|
293 |
-
'redirect' => false
|
294 |
-
) );
|
295 |
-
|
296 |
-
// User does not have access, and does not get a message
|
297 |
-
} else {
|
298 |
-
bp_core_no_access();
|
299 |
-
}
|
300 |
-
}
|
301 |
-
}
|
302 |
-
|
303 |
-
// Protect the admin tab from non-admins
|
304 |
-
if ( bp_is_current_action( 'admin' ) && !bp_is_item_admin() ) {
|
305 |
-
bp_core_no_access( array(
|
306 |
-
'message' => __( 'You are not an admin of this group.', 'buddypress' ),
|
307 |
-
'root' => bp_get_group_permalink( $bp->groups->current_group ),
|
308 |
-
'redirect' => false
|
309 |
-
) );
|
310 |
-
}
|
311 |
-
}
|
312 |
-
|
313 |
// Preconfigured group creation steps
|
314 |
$this->group_creation_steps = apply_filters( 'groups_create_group_steps', array(
|
315 |
'group-details' => array(
|
316 |
-
'name' =>
|
317 |
'position' => 0
|
318 |
),
|
319 |
'group-settings' => array(
|
320 |
-
'name' =>
|
321 |
'position' => 10
|
322 |
)
|
323 |
) );
|
324 |
|
325 |
// If avatar uploads are not disabled, add avatar option
|
326 |
-
if ( ! (int)
|
327 |
$this->group_creation_steps['group-avatar'] = array(
|
328 |
-
'name' =>
|
329 |
'position' => 20
|
330 |
);
|
331 |
}
|
@@ -333,7 +263,7 @@ class BP_Groups_Component extends BP_Component {
|
|
333 |
// If friends component is active, add invitations
|
334 |
if ( bp_is_active( 'friends' ) ) {
|
335 |
$this->group_creation_steps['group-invites'] = array(
|
336 |
-
'name' =>
|
337 |
'position' => 30
|
338 |
);
|
339 |
}
|
@@ -350,7 +280,47 @@ class BP_Groups_Component extends BP_Component {
|
|
350 |
}
|
351 |
|
352 |
/**
|
353 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
*
|
355 |
* @global BuddyPress $bp The one true BuddyPress instance
|
356 |
*/
|
@@ -360,9 +330,9 @@ class BP_Groups_Component extends BP_Component {
|
|
360 |
if ( bp_is_user() ) {
|
361 |
$count = bp_get_total_group_count_for_user();
|
362 |
$class = ( 0 === $count ) ? 'no-count' : 'count';
|
363 |
-
$nav_name = sprintf(
|
364 |
} else {
|
365 |
-
$nav_name =
|
366 |
}
|
367 |
|
368 |
// Add 'Groups' to the main navigation
|
@@ -431,7 +401,7 @@ class BP_Groups_Component extends BP_Component {
|
|
431 |
|
432 |
// Add the "Home" subnav item, as this will always be present
|
433 |
$sub_nav[] = array(
|
434 |
-
'name' => _x( 'Home', 'Group
|
435 |
'slug' => 'home',
|
436 |
'parent_url' => $group_link,
|
437 |
'parent_slug' => $this->current_group->slug,
|
@@ -451,7 +421,7 @@ class BP_Groups_Component extends BP_Component {
|
|
451 |
) {
|
452 |
|
453 |
$sub_nav[] = array(
|
454 |
-
'name' =>
|
455 |
'slug' => 'request-membership',
|
456 |
'parent_url' => $group_link,
|
457 |
'parent_slug' => $this->current_group->slug,
|
@@ -463,7 +433,7 @@ class BP_Groups_Component extends BP_Component {
|
|
463 |
// Forums are enabled and turned on
|
464 |
if ( $this->current_group->enable_forum && bp_is_active( 'forums' ) ) {
|
465 |
$sub_nav[] = array(
|
466 |
-
'name' =>
|
467 |
'slug' => 'forum',
|
468 |
'parent_url' => $group_link,
|
469 |
'parent_slug' => $this->current_group->slug,
|
@@ -475,40 +445,43 @@ class BP_Groups_Component extends BP_Component {
|
|
475 |
}
|
476 |
|
477 |
$sub_nav[] = array(
|
478 |
-
'name' => sprintf(
|
479 |
'slug' => 'members',
|
480 |
'parent_url' => $group_link,
|
481 |
'parent_slug' => $this->current_group->slug,
|
482 |
'screen_function' => 'groups_screen_group_members',
|
483 |
'position' => 60,
|
484 |
'user_has_access' => $this->current_group->user_has_access,
|
485 |
-
'item_css_id' => 'members'
|
|
|
486 |
);
|
487 |
|
488 |
if ( bp_is_active( 'friends' ) && bp_groups_user_can_send_invites() ) {
|
489 |
$sub_nav[] = array(
|
490 |
-
'name' =>
|
491 |
'slug' => 'send-invites',
|
492 |
'parent_url' => $group_link,
|
493 |
'parent_slug' => $this->current_group->slug,
|
494 |
'screen_function' => 'groups_screen_group_invite',
|
495 |
'item_css_id' => 'invite',
|
496 |
'position' => 70,
|
497 |
-
'user_has_access' => $this->current_group->user_has_access
|
|
|
498 |
);
|
499 |
}
|
500 |
|
501 |
// If the user is a group admin, then show the group admin nav item
|
502 |
if ( bp_is_item_admin() ) {
|
503 |
$sub_nav[] = array(
|
504 |
-
'name' =>
|
505 |
'slug' => 'admin',
|
506 |
'parent_url' => $group_link,
|
507 |
'parent_slug' => $this->current_group->slug,
|
508 |
'screen_function' => 'groups_screen_group_admin',
|
509 |
'position' => 1000,
|
510 |
'user_has_access' => true,
|
511 |
-
'item_css_id' => 'admin'
|
|
|
512 |
);
|
513 |
}
|
514 |
|
@@ -537,12 +510,12 @@ class BP_Groups_Component extends BP_Component {
|
|
537 |
|
538 |
// Pending group invites
|
539 |
$count = groups_get_invite_count_for_user();
|
540 |
-
$title =
|
541 |
-
$pending =
|
542 |
|
543 |
if ( !empty( $count['total'] ) ) {
|
544 |
-
$title = sprintf(
|
545 |
-
$pending = sprintf(
|
546 |
}
|
547 |
|
548 |
// Add the "My Account" sub menus
|
@@ -557,7 +530,7 @@ class BP_Groups_Component extends BP_Component {
|
|
557 |
$wp_admin_nav[] = array(
|
558 |
'parent' => 'my-account-' . $this->id,
|
559 |
'id' => 'my-account-' . $this->id . '-memberships',
|
560 |
-
'title' =>
|
561 |
'href' => trailingslashit( $groups_link )
|
562 |
);
|
563 |
|
@@ -574,7 +547,7 @@ class BP_Groups_Component extends BP_Component {
|
|
574 |
$wp_admin_nav[] = array(
|
575 |
'parent' => 'my-account-' . $this->id,
|
576 |
'id' => 'my-account-' . $this->id . '-create',
|
577 |
-
'title' =>
|
578 |
'href' => trailingslashit( bp_get_groups_directory_permalink() . 'create' )
|
579 |
);
|
580 |
}
|
@@ -592,7 +565,7 @@ class BP_Groups_Component extends BP_Component {
|
|
592 |
if ( bp_is_groups_component() ) {
|
593 |
|
594 |
if ( bp_is_my_profile() && !bp_is_single_item() ) {
|
595 |
-
$bp->bp_options_title =
|
596 |
|
597 |
} else if ( !bp_is_my_profile() && !bp_is_single_item() ) {
|
598 |
$bp->bp_options_avatar = bp_core_fetch_avatar( array(
|
@@ -611,11 +584,11 @@ class BP_Groups_Component extends BP_Component {
|
|
611 |
'object' => 'group',
|
612 |
'type' => 'thumb',
|
613 |
'avatar_dir' => 'group-avatars',
|
614 |
-
'alt' => __( 'Group
|
615 |
) );
|
616 |
|
617 |
if ( empty( $bp->bp_options_avatar ) ) {
|
618 |
-
$bp->bp_options_avatar = '<img src="' . esc_url( bp_core_avatar_default_thumb() ) . '" alt="' . esc_attr__( 'No Group
|
619 |
}
|
620 |
}
|
621 |
}
|
80 |
public function __construct() {
|
81 |
parent::start(
|
82 |
'groups',
|
83 |
+
_x( 'User Groups', 'Group screen page <title>', 'buddypress' ),
|
84 |
buddypress()->plugin_dir,
|
85 |
array(
|
86 |
'adminbar_myaccount_order' => 70
|
102 |
'widgets',
|
103 |
'activity',
|
104 |
'template',
|
|
|
105 |
'adminbar',
|
106 |
'functions',
|
107 |
'notifications'
|
128 |
if ( !defined( 'BP_GROUPS_SLUG' ) )
|
129 |
define( 'BP_GROUPS_SLUG', $this->id );
|
130 |
|
131 |
+
// Global tables for groups component
|
132 |
$global_tables = array(
|
133 |
'table_name' => $bp->table_prefix . 'bp_groups',
|
134 |
'table_name_members' => $bp->table_prefix . 'bp_groups_members',
|
148 |
'has_directory' => true,
|
149 |
'directory_title' => _x( 'Groups', 'component directory title', 'buddypress' ),
|
150 |
'notification_callback' => 'groups_format_notifications',
|
151 |
+
'search_string' => _x( 'Search Groups...', 'Component directory search', 'buddypress' ),
|
152 |
'global_tables' => $global_tables,
|
153 |
'meta_tables' => $meta_tables,
|
154 |
);
|
240 |
return;
|
241 |
}
|
242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
// Preconfigured group creation steps
|
244 |
$this->group_creation_steps = apply_filters( 'groups_create_group_steps', array(
|
245 |
'group-details' => array(
|
246 |
+
'name' => _x( 'Details', 'Group screen nav', 'buddypress' ),
|
247 |
'position' => 0
|
248 |
),
|
249 |
'group-settings' => array(
|
250 |
+
'name' => _x( 'Settings', 'Group screen nav', 'buddypress' ),
|
251 |
'position' => 10
|
252 |
)
|
253 |
) );
|
254 |
|
255 |
// If avatar uploads are not disabled, add avatar option
|
256 |
+
if ( ! (int) $bp->site_options['bp-disable-avatar-uploads'] && $bp->avatar->show_avatars ) {
|
257 |
$this->group_creation_steps['group-avatar'] = array(
|
258 |
+
'name' => _x( 'Photo', 'Group screen nav', 'buddypress' ),
|
259 |
'position' => 20
|
260 |
);
|
261 |
}
|
263 |
// If friends component is active, add invitations
|
264 |
if ( bp_is_active( 'friends' ) ) {
|
265 |
$this->group_creation_steps['group-invites'] = array(
|
266 |
+
'name' => _x( 'Invites', 'Group screen nav', 'buddypress' ),
|
267 |
'position' => 30
|
268 |
);
|
269 |
}
|
280 |
}
|
281 |
|
282 |
/**
|
283 |
+
* Set up canonical stack for this component.
|
284 |
+
*
|
285 |
+
* @since BuddyPress (2.1.0)
|
286 |
+
*/
|
287 |
+
public function setup_canonical_stack() {
|
288 |
+
if ( ! bp_is_groups_component() ) {
|
289 |
+
return;
|
290 |
+
}
|
291 |
+
|
292 |
+
if ( empty( $this->current_group ) ) {
|
293 |
+
return;
|
294 |
+
}
|
295 |
+
|
296 |
+
|
297 |
+
$this->default_extension = apply_filters( 'bp_groups_default_extension', defined( 'BP_GROUPS_DEFAULT_EXTENSION' ) ? BP_GROUPS_DEFAULT_EXTENSION : 'home' );
|
298 |
+
|
299 |
+
if ( !bp_current_action() ) {
|
300 |
+
buddypress()->current_action = $this->default_extension;
|
301 |
+
}
|
302 |
+
|
303 |
+
// Prepare for a redirect to the canonical URL
|
304 |
+
buddypress()->canonical_stack['base_url'] = bp_get_group_permalink( $this->current_group );
|
305 |
+
|
306 |
+
if ( bp_current_action() ) {
|
307 |
+
buddypress()->canonical_stack['action'] = bp_current_action();
|
308 |
+
}
|
309 |
+
|
310 |
+
if ( !empty( buddypress()->action_variables ) ) {
|
311 |
+
buddypress()->canonical_stack['action_variables'] = bp_action_variables();
|
312 |
+
}
|
313 |
+
|
314 |
+
// When viewing the default extension, the canonical URL should not have
|
315 |
+
// that extension's slug, unless more has been tacked onto the URL via
|
316 |
+
// action variables
|
317 |
+
if ( bp_is_current_action( $this->default_extension ) && empty( buddypress()->action_variables ) ) {
|
318 |
+
unset( buddypress()->canonical_stack['action'] );
|
319 |
+
}
|
320 |
+
}
|
321 |
+
|
322 |
+
/**
|
323 |
+
* Set up navigation.
|
324 |
*
|
325 |
* @global BuddyPress $bp The one true BuddyPress instance
|
326 |
*/
|
330 |
if ( bp_is_user() ) {
|
331 |
$count = bp_get_total_group_count_for_user();
|
332 |
$class = ( 0 === $count ) ? 'no-count' : 'count';
|
333 |
+
$nav_name = sprintf( _x( 'Groups <span class="%s">%s</span>', 'Group screen nav with counter', 'buddypress' ), esc_attr( $class ), number_format_i18n( $count ) );
|
334 |
} else {
|
335 |
+
$nav_name = _x( 'Groups', 'Group screen nav without counter', 'buddypress' );
|
336 |
}
|
337 |
|
338 |
// Add 'Groups' to the main navigation
|
401 |
|
402 |
// Add the "Home" subnav item, as this will always be present
|
403 |
$sub_nav[] = array(
|
404 |
+
'name' => _x( 'Home', 'Group screen navigation title', 'buddypress' ),
|
405 |
'slug' => 'home',
|
406 |
'parent_url' => $group_link,
|
407 |
'parent_slug' => $this->current_group->slug,
|
421 |
) {
|
422 |
|
423 |
$sub_nav[] = array(
|
424 |
+
'name' => _x( 'Request Membership','Group screen nav', 'buddypress' ),
|
425 |
'slug' => 'request-membership',
|
426 |
'parent_url' => $group_link,
|
427 |
'parent_slug' => $this->current_group->slug,
|
433 |
// Forums are enabled and turned on
|
434 |
if ( $this->current_group->enable_forum && bp_is_active( 'forums' ) ) {
|
435 |
$sub_nav[] = array(
|
436 |
+
'name' => _x( 'Forum', 'My Group screen nav', 'buddypress' ),
|
437 |
'slug' => 'forum',
|
438 |
'parent_url' => $group_link,
|
439 |
'parent_slug' => $this->current_group->slug,
|
445 |
}
|
446 |
|
447 |
$sub_nav[] = array(
|
448 |
+
'name' => sprintf( _x( 'Members <span>%s</span>', 'My Group screen nav', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
|
449 |
'slug' => 'members',
|
450 |
'parent_url' => $group_link,
|
451 |
'parent_slug' => $this->current_group->slug,
|
452 |
'screen_function' => 'groups_screen_group_members',
|
453 |
'position' => 60,
|
454 |
'user_has_access' => $this->current_group->user_has_access,
|
455 |
+
'item_css_id' => 'members',
|
456 |
+
'no_access_url' => $group_link,
|
457 |
);
|
458 |
|
459 |
if ( bp_is_active( 'friends' ) && bp_groups_user_can_send_invites() ) {
|
460 |
$sub_nav[] = array(
|
461 |
+
'name' => _x( 'Send Invites', 'My Group screen nav', 'buddypress' ),
|
462 |
'slug' => 'send-invites',
|
463 |
'parent_url' => $group_link,
|
464 |
'parent_slug' => $this->current_group->slug,
|
465 |
'screen_function' => 'groups_screen_group_invite',
|
466 |
'item_css_id' => 'invite',
|
467 |
'position' => 70,
|
468 |
+
'user_has_access' => $this->current_group->user_has_access,
|
469 |
+
'no_access_url' => $group_link,
|
470 |
);
|
471 |
}
|
472 |
|
473 |
// If the user is a group admin, then show the group admin nav item
|
474 |
if ( bp_is_item_admin() ) {
|
475 |
$sub_nav[] = array(
|
476 |
+
'name' => _x( 'Admin', 'My Group screen nav', 'buddypress' ),
|
477 |
'slug' => 'admin',
|
478 |
'parent_url' => $group_link,
|
479 |
'parent_slug' => $this->current_group->slug,
|
480 |
'screen_function' => 'groups_screen_group_admin',
|
481 |
'position' => 1000,
|
482 |
'user_has_access' => true,
|
483 |
+
'item_css_id' => 'admin',
|
484 |
+
'no_access_url' => $group_link,
|
485 |
);
|
486 |
}
|
487 |
|
510 |
|
511 |
// Pending group invites
|
512 |
$count = groups_get_invite_count_for_user();
|
513 |
+
$title = _x( 'Groups', 'My Account Groups', 'buddypress' );
|
514 |
+
$pending = _x( 'No Pending Invites', 'My Account Groups sub nav', 'buddypress' );
|
515 |
|
516 |
if ( !empty( $count['total'] ) ) {
|
517 |
+
$title = sprintf( _x( 'Groups <span class="count">%s</span>', 'My Account Groups nav', 'buddypress' ), $count );
|
518 |
+
$pending = sprintf( _x( 'Pending Invites <span class="count">%s</span>', 'My Account Groups sub nav', 'buddypress' ), $count );
|
519 |
}
|
520 |
|
521 |
// Add the "My Account" sub menus
|
530 |
$wp_admin_nav[] = array(
|
531 |
'parent' => 'my-account-' . $this->id,
|
532 |
'id' => 'my-account-' . $this->id . '-memberships',
|
533 |
+
'title' => _x( 'Memberships', 'My Account Groups sub nav', 'buddypress' ),
|
534 |
'href' => trailingslashit( $groups_link )
|
535 |
);
|
536 |
|
547 |
$wp_admin_nav[] = array(
|
548 |
'parent' => 'my-account-' . $this->id,
|
549 |
'id' => 'my-account-' . $this->id . '-create',
|
550 |
+
'title' => _x( 'Create a Group', 'My Account Groups sub nav', 'buddypress' ),
|
551 |
'href' => trailingslashit( bp_get_groups_directory_permalink() . 'create' )
|
552 |
);
|
553 |
}
|
565 |
if ( bp_is_groups_component() ) {
|
566 |
|
567 |
if ( bp_is_my_profile() && !bp_is_single_item() ) {
|
568 |
+
$bp->bp_options_title = _x( 'Memberships', 'My Groups page <title>', 'buddypress' );
|
569 |
|
570 |
} else if ( !bp_is_my_profile() && !bp_is_single_item() ) {
|
571 |
$bp->bp_options_avatar = bp_core_fetch_avatar( array(
|
584 |
'object' => 'group',
|
585 |
'type' => 'thumb',
|
586 |
'avatar_dir' => 'group-avatars',
|
587 |
+
'alt' => __( 'Group Profile Photo', 'buddypress' )
|
588 |
) );
|
589 |
|
590 |
if ( empty( $bp->bp_options_avatar ) ) {
|
591 |
+
$bp->bp_options_avatar = '<img src="' . esc_url( bp_core_avatar_default_thumb() ) . '" alt="' . esc_attr__( 'No Group Profile Photo', 'buddypress' ) . '" class="avatar" />';
|
592 |
}
|
593 |
}
|
594 |
}
|
@@ -15,14 +15,25 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|
15 |
|
16 |
/** Emails ********************************************************************/
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
21 |
$subject = bp_get_email_subject( array( 'text' => __( 'Group Details Updated', 'buddypress' ) ) );
|
22 |
$user_ids = BP_Groups_Member::get_group_member_ids( $group->id );
|
23 |
|
24 |
foreach ( (array) $user_ids as $user_id ) {
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
|
27 |
$ud = bp_core_get_core_userdata( $user_id );
|
28 |
|
@@ -56,8 +67,20 @@ To view the group: %2$s
|
|
56 |
do_action( 'bp_groups_sent_updated_email', $user_ids, $subject, '', $group_id );
|
57 |
}
|
58 |
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
|
|
61 |
if ( bp_is_active( 'notifications' ) ) {
|
62 |
bp_notifications_add_notification( array(
|
63 |
'user_id' => $admin_id,
|
@@ -68,8 +91,10 @@ function groups_notification_new_membership_request( $requesting_user_id, $admin
|
|
68 |
) );
|
69 |
}
|
70 |
|
71 |
-
|
|
|
72 |
return false;
|
|
|
73 |
|
74 |
// Username of the user requesting a membership: %1$s in mail
|
75 |
$requesting_user_name = bp_core_get_user_displayname( $requesting_user_id );
|
@@ -108,7 +133,7 @@ To view %4$s\'s profile: %5$s
|
|
108 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
109 |
}
|
110 |
|
111 |
-
|
112 |
$to = apply_filters( 'groups_notification_new_membership_request_to', $to );
|
113 |
$subject = apply_filters_ref_array( 'groups_notification_new_membership_request_subject', array( $subject, &$group ) );
|
114 |
$message = apply_filters_ref_array( 'groups_notification_new_membership_request_message', array( $message, &$group, $requesting_user_name, $profile_link, $group_requests, $settings_link ) );
|
@@ -118,12 +143,25 @@ To view %4$s\'s profile: %5$s
|
|
118 |
do_action( 'bp_groups_sent_membership_request_email', $admin_id, $subject, $message, $requesting_user_id, $group_id, $membership_id );
|
119 |
}
|
120 |
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
-
//
|
124 |
if ( bp_is_active( 'notifications' ) ) {
|
125 |
|
126 |
-
|
|
|
|
|
|
|
127 |
|
128 |
bp_notifications_add_notification( array(
|
129 |
'user_id' => $requesting_user_id,
|
@@ -133,21 +171,20 @@ function groups_notification_membership_request_completed( $requesting_user_id,
|
|
133 |
) );
|
134 |
}
|
135 |
|
136 |
-
|
|
|
137 |
return false;
|
|
|
138 |
|
139 |
-
$group
|
140 |
-
|
141 |
-
$
|
142 |
-
|
143 |
-
$group_link = bp_get_group_permalink( $group );
|
144 |
$settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
|
145 |
$settings_link = bp_core_get_user_domain( $requesting_user_id ) . $settings_slug . '/notifications/';
|
|
|
146 |
|
147 |
// Set up and send the message
|
148 |
-
$
|
149 |
-
|
150 |
-
if ( $accepted ) {
|
151 |
$subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), $group->name ) ) );
|
152 |
$message = sprintf( __(
|
153 |
'Your membership request for the group "%1$s" has been accepted.
|
@@ -173,7 +210,7 @@ To submit another request please log in and visit: %2$s
|
|
173 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
174 |
}
|
175 |
|
176 |
-
|
177 |
$to = apply_filters( 'groups_notification_membership_request_completed_to', $to );
|
178 |
$subject = apply_filters_ref_array( 'groups_notification_membership_request_completed_subject', array( $subject, &$group ) );
|
179 |
$message = apply_filters_ref_array( 'groups_notification_membership_request_completed_message', array( $message, &$group, $group_link, $settings_link ) );
|
@@ -185,30 +222,40 @@ To submit another request please log in and visit: %2$s
|
|
185 |
add_action( 'groups_membership_accepted', 'groups_notification_membership_request_completed', 10, 3 );
|
186 |
add_action( 'groups_membership_rejected', 'groups_notification_membership_request_completed', 10, 3 );
|
187 |
|
188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
|
|
|
190 |
if ( groups_is_user_admin( $user_id, $group_id ) ) {
|
191 |
$promoted_to = __( 'an administrator', 'buddypress' );
|
192 |
-
$type
|
193 |
} else {
|
194 |
$promoted_to = __( 'a moderator', 'buddypress' );
|
195 |
-
$type
|
196 |
}
|
197 |
|
198 |
-
//
|
199 |
if ( bp_is_active( 'notifications' ) ) {
|
200 |
bp_notifications_add_notification( array(
|
201 |
'user_id' => $user_id,
|
202 |
'item_id' => $group_id,
|
203 |
'component_name' => buddypress()->groups->id,
|
204 |
-
'component_action' => $type
|
205 |
-
'date_notified' => bp_core_current_time(),
|
206 |
-
'is_new' => 1,
|
207 |
) );
|
208 |
}
|
209 |
|
210 |
-
|
|
|
211 |
return false;
|
|
|
212 |
|
213 |
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
214 |
$ud = bp_core_get_core_userdata($user_id);
|
@@ -232,7 +279,7 @@ To view the group please visit: %3$s
|
|
232 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
233 |
}
|
234 |
|
235 |
-
|
236 |
$to = apply_filters( 'groups_notification_promoted_member_to', $to );
|
237 |
$subject = apply_filters_ref_array( 'groups_notification_promoted_member_subject', array( $subject, &$group ) );
|
238 |
$message = apply_filters_ref_array( 'groups_notification_promoted_member_message', array( $message, &$group, $promoted_to, $group_link, $settings_link ) );
|
@@ -243,42 +290,57 @@ To view the group please visit: %3$s
|
|
243 |
}
|
244 |
add_action( 'groups_promoted_member', 'groups_notification_promoted_member', 10, 2 );
|
245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) {
|
247 |
|
248 |
-
//
|
|
|
|
|
|
|
|
|
|
|
249 |
$inviter_ud = bp_core_get_core_userdata( $inviter_user_id );
|
250 |
$inviter_name = bp_core_get_userlink( $inviter_user_id, true, false, true );
|
251 |
$inviter_link = bp_core_get_user_domain( $inviter_user_id );
|
|
|
252 |
|
253 |
-
|
254 |
-
|
255 |
-
if ( !$member->invite_sent ) {
|
256 |
-
$invited_user_id = $member->user_id;
|
257 |
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
if ( 'no' == bp_get_user_meta( $invited_user_id, 'notification_groups_invite', true ) )
|
269 |
-
return false;
|
270 |
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
$invites_link = trailingslashit( $invited_link . bp_get_groups_slug() . '/invites' );
|
276 |
|
277 |
-
|
278 |
-
|
279 |
-
|
|
|
|
|
280 |
|
281 |
-
|
|
|
|
|
|
|
282 |
'One of your friends %1$s has invited you to the group: "%2$s".
|
283 |
|
284 |
To view your group invites visit: %3$s
|
@@ -290,28 +352,28 @@ To view %5$s\'s profile visit: %6$s
|
|
290 |
---------------------
|
291 |
', 'buddypress' ), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_link );
|
292 |
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
|
303 |
-
|
304 |
|
305 |
-
|
306 |
-
}
|
307 |
}
|
308 |
|
309 |
/** Notifications *************************************************************/
|
310 |
|
311 |
/**
|
312 |
-
* Format
|
|
|
|
|
313 |
*
|
314 |
-
* @since BuddyPress (1.0)
|
315 |
* @param string $action The kind of notification being rendered
|
316 |
* @param int $item_id The primary item id
|
317 |
* @param int $secondary_item_id The secondary item id
|
@@ -629,9 +691,8 @@ add_action( 'groups_screen_group_invites', 'bp_groups_screen_invites_mark_notifi
|
|
629 |
* administration area.
|
630 |
*
|
631 |
* @since BuddyPress (1.9.0)
|
632 |
-
* @param int $group_id
|
633 |
*/
|
634 |
-
function bp_groups_screen_group_admin_requests_mark_notifications(
|
635 |
if ( bp_is_active( 'notifications' ) ) {
|
636 |
bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->groups->id, 'new_membership_request' );
|
637 |
}
|
15 |
|
16 |
/** Emails ********************************************************************/
|
17 |
|
18 |
+
/**
|
19 |
+
* Notify all group members when a group is updated
|
20 |
+
*
|
21 |
+
* @since BuddyPress (1.0.0)
|
22 |
+
*
|
23 |
+
* @param int $group_id
|
24 |
+
*/
|
25 |
+
function groups_notification_group_updated( $group_id = 0 ) {
|
26 |
|
27 |
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
28 |
$subject = bp_get_email_subject( array( 'text' => __( 'Group Details Updated', 'buddypress' ) ) );
|
29 |
$user_ids = BP_Groups_Member::get_group_member_ids( $group->id );
|
30 |
|
31 |
foreach ( (array) $user_ids as $user_id ) {
|
32 |
+
|
33 |
+
// Continue if member opted out of receiving this email
|
34 |
+
if ( 'no' === bp_get_user_meta( $user_id, 'notification_groups_group_updated', true ) ) {
|
35 |
+
continue;
|
36 |
+
}
|
37 |
|
38 |
$ud = bp_core_get_core_userdata( $user_id );
|
39 |
|
67 |
do_action( 'bp_groups_sent_updated_email', $user_ids, $subject, '', $group_id );
|
68 |
}
|
69 |
|
70 |
+
/**
|
71 |
+
* Notify group admin about new membership request
|
72 |
+
*
|
73 |
+
* @since BuddyPress (1.0.0)
|
74 |
+
*
|
75 |
+
* @param int $requesting_user_id
|
76 |
+
* @param int $admin_id
|
77 |
+
* @param int $group_id
|
78 |
+
* @param int $membership_id
|
79 |
+
* @return boolean
|
80 |
+
*/
|
81 |
+
function groups_notification_new_membership_request( $requesting_user_id = 0, $admin_id = 0, $group_id = 0, $membership_id = 0 ) {
|
82 |
|
83 |
+
// Trigger a BuddyPress Notification
|
84 |
if ( bp_is_active( 'notifications' ) ) {
|
85 |
bp_notifications_add_notification( array(
|
86 |
'user_id' => $admin_id,
|
91 |
) );
|
92 |
}
|
93 |
|
94 |
+
// Bail if member opted out of receiving this email
|
95 |
+
if ( 'no' === bp_get_user_meta( $admin_id, 'notification_groups_membership_request', true ) ) {
|
96 |
return false;
|
97 |
+
}
|
98 |
|
99 |
// Username of the user requesting a membership: %1$s in mail
|
100 |
$requesting_user_name = bp_core_get_user_displayname( $requesting_user_id );
|
133 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
134 |
}
|
135 |
|
136 |
+
// Send the message
|
137 |
$to = apply_filters( 'groups_notification_new_membership_request_to', $to );
|
138 |
$subject = apply_filters_ref_array( 'groups_notification_new_membership_request_subject', array( $subject, &$group ) );
|
139 |
$message = apply_filters_ref_array( 'groups_notification_new_membership_request_message', array( $message, &$group, $requesting_user_name, $profile_link, $group_requests, $settings_link ) );
|
143 |
do_action( 'bp_groups_sent_membership_request_email', $admin_id, $subject, $message, $requesting_user_id, $group_id, $membership_id );
|
144 |
}
|
145 |
|
146 |
+
/**
|
147 |
+
* Notify member about their group membership request
|
148 |
+
*
|
149 |
+
* @since BuddyPress (1.0.0)
|
150 |
+
*
|
151 |
+
* @param type $requesting_user_id
|
152 |
+
* @param type $group_id
|
153 |
+
* @param type $accepted
|
154 |
+
* @return boolean
|
155 |
+
*/
|
156 |
+
function groups_notification_membership_request_completed( $requesting_user_id = 0, $group_id = 0, $accepted = true ) {
|
157 |
|
158 |
+
// Trigger a BuddyPress Notification
|
159 |
if ( bp_is_active( 'notifications' ) ) {
|
160 |
|
161 |
+
// What type of acknowledgement
|
162 |
+
$type = ! empty( $accepted )
|
163 |
+
? 'membership_request_accepted'
|
164 |
+
: 'membership_request_rejected';
|
165 |
|
166 |
bp_notifications_add_notification( array(
|
167 |
'user_id' => $requesting_user_id,
|
171 |
) );
|
172 |
}
|
173 |
|
174 |
+
// Bail if member opted out of receiving this email
|
175 |
+
if ( 'no' === bp_get_user_meta( $requesting_user_id, 'notification_membership_request_completed', true ) ) {
|
176 |
return false;
|
177 |
+
}
|
178 |
|
179 |
+
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
180 |
+
$ud = bp_core_get_core_userdata( $requesting_user_id );
|
181 |
+
$group_link = bp_get_group_permalink( $group );
|
|
|
|
|
182 |
$settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
|
183 |
$settings_link = bp_core_get_user_domain( $requesting_user_id ) . $settings_slug . '/notifications/';
|
184 |
+
$to = $ud->user_email;
|
185 |
|
186 |
// Set up and send the message
|
187 |
+
if ( ! empty( $accepted ) ) {
|
|
|
|
|
188 |
$subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), $group->name ) ) );
|
189 |
$message = sprintf( __(
|
190 |
'Your membership request for the group "%1$s" has been accepted.
|
210 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
211 |
}
|
212 |
|
213 |
+
// Send the message
|
214 |
$to = apply_filters( 'groups_notification_membership_request_completed_to', $to );
|
215 |
$subject = apply_filters_ref_array( 'groups_notification_membership_request_completed_subject', array( $subject, &$group ) );
|
216 |
$message = apply_filters_ref_array( 'groups_notification_membership_request_completed_message', array( $message, &$group, $group_link, $settings_link ) );
|
222 |
add_action( 'groups_membership_accepted', 'groups_notification_membership_request_completed', 10, 3 );
|
223 |
add_action( 'groups_membership_rejected', 'groups_notification_membership_request_completed', 10, 3 );
|
224 |
|
225 |
+
/**
|
226 |
+
* Notify group member they have been promoted
|
227 |
+
*
|
228 |
+
* @since BuddyPress (1.0.0)
|
229 |
+
*
|
230 |
+
* @param int $user_id
|
231 |
+
* @param int $group_id
|
232 |
+
* @return boolean
|
233 |
+
*/
|
234 |
+
function groups_notification_promoted_member( $user_id = 0, $group_id = 0 ) {
|
235 |
|
236 |
+
// What type of promotion is this?
|
237 |
if ( groups_is_user_admin( $user_id, $group_id ) ) {
|
238 |
$promoted_to = __( 'an administrator', 'buddypress' );
|
239 |
+
$type = 'member_promoted_to_admin';
|
240 |
} else {
|
241 |
$promoted_to = __( 'a moderator', 'buddypress' );
|
242 |
+
$type = 'member_promoted_to_mod';
|
243 |
}
|
244 |
|
245 |
+
// Trigger a BuddyPress Notification
|
246 |
if ( bp_is_active( 'notifications' ) ) {
|
247 |
bp_notifications_add_notification( array(
|
248 |
'user_id' => $user_id,
|
249 |
'item_id' => $group_id,
|
250 |
'component_name' => buddypress()->groups->id,
|
251 |
+
'component_action' => $type
|
|
|
|
|
252 |
) );
|
253 |
}
|
254 |
|
255 |
+
// Bail if admin opted out of receiving this email
|
256 |
+
if ( 'no' === bp_get_user_meta( $user_id, 'notification_groups_admin_promotion', true ) ) {
|
257 |
return false;
|
258 |
+
}
|
259 |
|
260 |
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
261 |
$ud = bp_core_get_core_userdata($user_id);
|
279 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
280 |
}
|
281 |
|
282 |
+
// Send the message
|
283 |
$to = apply_filters( 'groups_notification_promoted_member_to', $to );
|
284 |
$subject = apply_filters_ref_array( 'groups_notification_promoted_member_subject', array( $subject, &$group ) );
|
285 |
$message = apply_filters_ref_array( 'groups_notification_promoted_member_message', array( $message, &$group, $promoted_to, $group_link, $settings_link ) );
|
290 |
}
|
291 |
add_action( 'groups_promoted_member', 'groups_notification_promoted_member', 10, 2 );
|
292 |
|
293 |
+
/**
|
294 |
+
* Notify a member they have been invitated to a group
|
295 |
+
*
|
296 |
+
* @since BuddyPress (1.0.0)
|
297 |
+
*
|
298 |
+
* @param object $group
|
299 |
+
* @param object $member
|
300 |
+
* @param int $inviter_user_id
|
301 |
+
* @return boolean
|
302 |
+
*/
|
303 |
function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) {
|
304 |
|
305 |
+
// Bail if member has already been invited
|
306 |
+
if ( ! empty( $member->invite_sent ) ) {
|
307 |
+
return;
|
308 |
+
}
|
309 |
+
|
310 |
+
// @todo $inviter_ud may be used for caching, test without it
|
311 |
$inviter_ud = bp_core_get_core_userdata( $inviter_user_id );
|
312 |
$inviter_name = bp_core_get_userlink( $inviter_user_id, true, false, true );
|
313 |
$inviter_link = bp_core_get_user_domain( $inviter_user_id );
|
314 |
+
$group_link = bp_get_group_permalink( $group );
|
315 |
|
316 |
+
// Setup the ID for the invited user
|
317 |
+
$invited_user_id = $member->user_id;
|
|
|
|
|
318 |
|
319 |
+
// Trigger a BuddyPress Notification
|
320 |
+
if ( bp_is_active( 'notifications' ) ) {
|
321 |
+
bp_notifications_add_notification( array(
|
322 |
+
'user_id' => $invited_user_id,
|
323 |
+
'item_id' => $group->id,
|
324 |
+
'component_name' => buddypress()->groups->id,
|
325 |
+
'component_action' => 'group_invite'
|
326 |
+
) );
|
327 |
+
}
|
|
|
|
|
|
|
328 |
|
329 |
+
// Bail if member opted out of receiving this email
|
330 |
+
if ( 'no' === bp_get_user_meta( $invited_user_id, 'notification_groups_invite', true ) ) {
|
331 |
+
return false;
|
332 |
+
}
|
|
|
333 |
|
334 |
+
$invited_ud = bp_core_get_core_userdata( $invited_user_id );
|
335 |
+
$settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
|
336 |
+
$settings_link = bp_core_get_user_domain( $invited_user_id ) . $settings_slug . '/notifications/';
|
337 |
+
$invited_link = bp_core_get_user_domain( $invited_user_id );
|
338 |
+
$invites_link = trailingslashit( $invited_link . bp_get_groups_slug() . '/invites' );
|
339 |
|
340 |
+
// Set up and send the message
|
341 |
+
$to = $invited_ud->user_email;
|
342 |
+
$subject = bp_get_email_subject( array( 'text' => sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), $group->name ) ) );
|
343 |
+
$message = sprintf( __(
|
344 |
'One of your friends %1$s has invited you to the group: "%2$s".
|
345 |
|
346 |
To view your group invites visit: %3$s
|
352 |
---------------------
|
353 |
', 'buddypress' ), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_link );
|
354 |
|
355 |
+
// Only show the disable notifications line if the settings component is enabled
|
356 |
+
if ( bp_is_active( 'settings' ) ) {
|
357 |
+
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
358 |
+
}
|
359 |
|
360 |
+
// Send the message
|
361 |
+
$to = apply_filters( 'groups_notification_group_invites_to', $to );
|
362 |
+
$subject = apply_filters_ref_array( 'groups_notification_group_invites_subject', array( $subject, &$group ) );
|
363 |
+
$message = apply_filters_ref_array( 'groups_notification_group_invites_message', array( $message, &$group, $inviter_name, $inviter_link, $invites_link, $group_link, $settings_link ) );
|
364 |
|
365 |
+
wp_mail( $to, $subject, $message );
|
366 |
|
367 |
+
do_action( 'bp_groups_sent_invited_email', $invited_user_id, $subject, $message, $group );
|
|
|
368 |
}
|
369 |
|
370 |
/** Notifications *************************************************************/
|
371 |
|
372 |
/**
|
373 |
+
* Format notifications for the Groups component.
|
374 |
+
*
|
375 |
+
* @since BuddyPress (1.0.0)
|
376 |
*
|
|
|
377 |
* @param string $action The kind of notification being rendered
|
378 |
* @param int $item_id The primary item id
|
379 |
* @param int $secondary_item_id The secondary item id
|
691 |
* administration area.
|
692 |
*
|
693 |
* @since BuddyPress (1.9.0)
|
|
|
694 |
*/
|
695 |
+
function bp_groups_screen_group_admin_requests_mark_notifications() {
|
696 |
if ( bp_is_active( 'notifications' ) ) {
|
697 |
bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->groups->id, 'new_membership_request' );
|
698 |
}
|
@@ -505,7 +505,7 @@ function groups_screen_group_request_membership() {
|
|
505 |
if ( groups_accept_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) )
|
506 |
bp_core_add_message( __( 'Group invite accepted', 'buddypress' ) );
|
507 |
else
|
508 |
-
bp_core_add_message( __( 'There was an error accepting the group invitation
|
509 |
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
|
510 |
}
|
511 |
|
@@ -517,7 +517,7 @@ function groups_screen_group_request_membership() {
|
|
517 |
return false;
|
518 |
|
519 |
if ( !groups_send_membership_request( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
|
520 |
-
bp_core_add_message( __( 'There was an error sending your group membership request
|
521 |
} else {
|
522 |
bp_core_add_message( __( 'Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress' ) );
|
523 |
}
|
@@ -568,7 +568,7 @@ function groups_screen_group_admin_edit_details() {
|
|
568 |
$group_notify_members = isset( $_POST['group-notify-members'] ) ? (int) $_POST['group-notify-members'] : 0;
|
569 |
|
570 |
if ( !groups_edit_base_group_details( $_POST['group-id'], $_POST['group-name'], $_POST['group-desc'], $group_notify_members ) ) {
|
571 |
-
bp_core_add_message( __( 'There was an error updating group details
|
572 |
} else {
|
573 |
bp_core_add_message( __( 'Group details were successfully updated.', 'buddypress' ) );
|
574 |
}
|
@@ -612,7 +612,7 @@ function groups_screen_group_admin_settings() {
|
|
612 |
return false;
|
613 |
|
614 |
if ( !groups_edit_group_settings( $_POST['group-id'], $enable_forum, $status, $invite_status ) ) {
|
615 |
-
bp_core_add_message( __( 'There was an error updating group settings
|
616 |
} else {
|
617 |
bp_core_add_message( __( 'Group settings were successfully updated.', 'buddypress' ) );
|
618 |
}
|
@@ -634,7 +634,7 @@ function groups_screen_group_admin_avatar() {
|
|
634 |
return false;
|
635 |
|
636 |
// If the logged-in user doesn't have permission or if avatar uploads are disabled, then stop here
|
637 |
-
if ( ! bp_is_item_admin() || (int) bp_get_option( 'bp-disable-avatar-uploads' ) )
|
638 |
return false;
|
639 |
|
640 |
$bp = buddypress();
|
@@ -646,9 +646,9 @@ function groups_screen_group_admin_avatar() {
|
|
646 |
check_admin_referer( 'bp_group_avatar_delete' );
|
647 |
|
648 |
if ( bp_core_delete_existing_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group' ) ) ) {
|
649 |
-
bp_core_add_message( __( '
|
650 |
} else {
|
651 |
-
bp_core_add_message( __( 'There was a problem deleting
|
652 |
}
|
653 |
}
|
654 |
|
@@ -691,9 +691,9 @@ function groups_screen_group_admin_avatar() {
|
|
691 |
);
|
692 |
|
693 |
if ( !bp_core_avatar_handle_crop( $args ) ) {
|
694 |
-
bp_core_add_message( __( 'There was a problem cropping the
|
695 |
} else {
|
696 |
-
bp_core_add_message( __( 'The new group
|
697 |
}
|
698 |
}
|
699 |
|
@@ -754,7 +754,7 @@ function groups_screen_group_admin_manage_members() {
|
|
754 |
|
755 |
// Demote a user.
|
756 |
elseif ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) )
|
757 |
-
bp_core_add_message( __( 'There was an error when demoting that user
|
758 |
else
|
759 |
bp_core_add_message( __( 'User demoted successfully', 'buddypress' ) );
|
760 |
|
@@ -772,7 +772,7 @@ function groups_screen_group_admin_manage_members() {
|
|
772 |
|
773 |
// Ban a user.
|
774 |
if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) )
|
775 |
-
bp_core_add_message( __( 'There was an error when banning that user
|
776 |
else
|
777 |
bp_core_add_message( __( 'User banned successfully', 'buddypress' ) );
|
778 |
|
@@ -808,7 +808,7 @@ function groups_screen_group_admin_manage_members() {
|
|
808 |
|
809 |
// Remove a user.
|
810 |
if ( !groups_remove_member( $user_id, $bp->groups->current_group->id ) )
|
811 |
-
bp_core_add_message( __( 'There was an error removing that user from the group
|
812 |
else
|
813 |
bp_core_add_message( __( 'User removed successfully', 'buddypress' ) );
|
814 |
|
@@ -847,7 +847,7 @@ function groups_screen_group_admin_requests() {
|
|
847 |
|
848 |
// Accept the membership request
|
849 |
if ( !groups_accept_membership_request( $membership_id ) )
|
850 |
-
bp_core_add_message( __( 'There was an error accepting the membership request
|
851 |
else
|
852 |
bp_core_add_message( __( 'Group membership request accepted', 'buddypress' ) );
|
853 |
|
@@ -858,7 +858,7 @@ function groups_screen_group_admin_requests() {
|
|
858 |
|
859 |
// Reject the membership request
|
860 |
if ( !groups_reject_membership_request( $membership_id ) )
|
861 |
-
bp_core_add_message( __( 'There was an error rejecting the membership request
|
862 |
else
|
863 |
bp_core_add_message( __( 'Group membership request rejected', 'buddypress' ) );
|
864 |
}
|
@@ -892,7 +892,7 @@ function groups_screen_group_admin_delete_group() {
|
|
892 |
|
893 |
// Group admin has deleted the group, now do it.
|
894 |
if ( !groups_delete_group( $bp->groups->current_group->id ) ) {
|
895 |
-
bp_core_add_message( __( 'There was an error deleting the group
|
896 |
} else {
|
897 |
bp_core_add_message( __( 'The group was deleted successfully', 'buddypress' ) );
|
898 |
|
@@ -933,7 +933,7 @@ function groups_screen_notification_settings() {
|
|
933 |
<thead>
|
934 |
<tr>
|
935 |
<th class="icon"></th>
|
936 |
-
<th class="title"><?php
|
937 |
<th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
|
938 |
<th class="no"><?php _e( 'No', 'buddypress' )?></th>
|
939 |
</tr>
|
@@ -942,25 +942,25 @@ function groups_screen_notification_settings() {
|
|
942 |
<tbody>
|
943 |
<tr id="groups-notification-settings-invitation">
|
944 |
<td></td>
|
945 |
-
<td><?php
|
946 |
<td class="yes"><input type="radio" name="notifications[notification_groups_invite]" value="yes" <?php checked( $group_invite, 'yes', true ) ?>/></td>
|
947 |
<td class="no"><input type="radio" name="notifications[notification_groups_invite]" value="no" <?php checked( $group_invite, 'no', true ) ?>/></td>
|
948 |
</tr>
|
949 |
<tr id="groups-notification-settings-info-updated">
|
950 |
<td></td>
|
951 |
-
<td><?php
|
952 |
<td class="yes"><input type="radio" name="notifications[notification_groups_group_updated]" value="yes" <?php checked( $group_update, 'yes', true ) ?>/></td>
|
953 |
<td class="no"><input type="radio" name="notifications[notification_groups_group_updated]" value="no" <?php checked( $group_update, 'no', true ) ?>/></td>
|
954 |
</tr>
|
955 |
<tr id="groups-notification-settings-promoted">
|
956 |
<td></td>
|
957 |
-
<td><?php
|
958 |
<td class="yes"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="yes" <?php checked( $group_promo, 'yes', true ) ?>/></td>
|
959 |
<td class="no"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="no" <?php checked( $group_promo, 'no', true ) ?>/></td>
|
960 |
</tr>
|
961 |
<tr id="groups-notification-settings-request">
|
962 |
<td></td>
|
963 |
-
<td><?php
|
964 |
<td class="yes"><input type="radio" name="notifications[notification_groups_membership_request]" value="yes" <?php checked( $group_request, 'yes', true ) ?>/></td>
|
965 |
<td class="no"><input type="radio" name="notifications[notification_groups_membership_request]" value="no" <?php checked( $group_request, 'no', true ) ?>/></td>
|
966 |
</tr>
|
@@ -1071,7 +1071,7 @@ class BP_Groups_Theme_Compat {
|
|
1071 |
'post_author' => 0,
|
1072 |
'post_date' => 0,
|
1073 |
'post_content' => '',
|
1074 |
-
'post_type' => '
|
1075 |
'post_status' => 'publish',
|
1076 |
'is_page' => true,
|
1077 |
'comment_status' => 'closed'
|
@@ -1119,7 +1119,7 @@ class BP_Groups_Theme_Compat {
|
|
1119 |
*/
|
1120 |
public function create_dummy_post() {
|
1121 |
|
1122 |
-
$title =
|
1123 |
|
1124 |
bp_theme_compat_reset_post( array(
|
1125 |
'ID' => 0,
|
@@ -1127,7 +1127,7 @@ class BP_Groups_Theme_Compat {
|
|
1127 |
'post_author' => 0,
|
1128 |
'post_date' => 0,
|
1129 |
'post_content' => '',
|
1130 |
-
'post_type' => '
|
1131 |
'post_status' => 'publish',
|
1132 |
'is_page' => true,
|
1133 |
'comment_status' => 'closed'
|
@@ -1187,7 +1187,7 @@ class BP_Groups_Theme_Compat {
|
|
1187 |
'post_author' => 0,
|
1188 |
'post_date' => 0,
|
1189 |
'post_content' => '',
|
1190 |
-
'post_type' => '
|
1191 |
'post_status' => 'publish',
|
1192 |
'is_page' => true,
|
1193 |
'comment_status' => 'closed'
|
505 |
if ( groups_accept_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) )
|
506 |
bp_core_add_message( __( 'Group invite accepted', 'buddypress' ) );
|
507 |
else
|
508 |
+
bp_core_add_message( __( 'There was an error accepting the group invitation; please try again.', 'buddypress' ), 'error' );
|
509 |
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
|
510 |
}
|
511 |
|
517 |
return false;
|
518 |
|
519 |
if ( !groups_send_membership_request( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
|
520 |
+
bp_core_add_message( __( 'There was an error sending your group membership request; please try again.', 'buddypress' ), 'error' );
|
521 |
} else {
|
522 |
bp_core_add_message( __( 'Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress' ) );
|
523 |
}
|
568 |
$group_notify_members = isset( $_POST['group-notify-members'] ) ? (int) $_POST['group-notify-members'] : 0;
|
569 |
|
570 |
if ( !groups_edit_base_group_details( $_POST['group-id'], $_POST['group-name'], $_POST['group-desc'], $group_notify_members ) ) {
|
571 |
+
bp_core_add_message( __( 'There was an error updating group details; please try again.', 'buddypress' ), 'error' );
|
572 |
} else {
|
573 |
bp_core_add_message( __( 'Group details were successfully updated.', 'buddypress' ) );
|
574 |
}
|
612 |
return false;
|
613 |
|
614 |
if ( !groups_edit_group_settings( $_POST['group-id'], $enable_forum, $status, $invite_status ) ) {
|
615 |
+
bp_core_add_message( __( 'There was an error updating group settings; please try again.', 'buddypress' ), 'error' );
|
616 |
} else {
|
617 |
bp_core_add_message( __( 'Group settings were successfully updated.', 'buddypress' ) );
|
618 |
}
|
634 |
return false;
|
635 |
|
636 |
// If the logged-in user doesn't have permission or if avatar uploads are disabled, then stop here
|
637 |
+
if ( ! bp_is_item_admin() || (int) bp_get_option( 'bp-disable-avatar-uploads' ) || ! buddypress()->avatar->show_avatars )
|
638 |
return false;
|
639 |
|
640 |
$bp = buddypress();
|
646 |
check_admin_referer( 'bp_group_avatar_delete' );
|
647 |
|
648 |
if ( bp_core_delete_existing_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group' ) ) ) {
|
649 |
+
bp_core_add_message( __( 'The group profile photo was deleted successfully!', 'buddypress' ) );
|
650 |
} else {
|
651 |
+
bp_core_add_message( __( 'There was a problem deleting the group profile photo; please try again.', 'buddypress' ), 'error' );
|
652 |
}
|
653 |
}
|
654 |
|
691 |
);
|
692 |
|
693 |
if ( !bp_core_avatar_handle_crop( $args ) ) {
|
694 |
+
bp_core_add_message( __( 'There was a problem cropping the group profile photo.', 'buddypress' ), 'error' );
|
695 |
} else {
|
696 |
+
bp_core_add_message( __( 'The new group profile photo was uploaded successfully.', 'buddypress' ) );
|
697 |
}
|
698 |
}
|
699 |
|
754 |
|
755 |
// Demote a user.
|
756 |
elseif ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) )
|
757 |
+
bp_core_add_message( __( 'There was an error when demoting that user; please try again', 'buddypress' ), 'error' );
|
758 |
else
|
759 |
bp_core_add_message( __( 'User demoted successfully', 'buddypress' ) );
|
760 |
|
772 |
|
773 |
// Ban a user.
|
774 |
if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) )
|
775 |
+
bp_core_add_message( __( 'There was an error when banning that user; please try again', 'buddypress' ), 'error' );
|
776 |
else
|
777 |
bp_core_add_message( __( 'User banned successfully', 'buddypress' ) );
|
778 |
|
808 |
|
809 |
// Remove a user.
|
810 |
if ( !groups_remove_member( $user_id, $bp->groups->current_group->id ) )
|
811 |
+
bp_core_add_message( __( 'There was an error removing that user from the group; please try again', 'buddypress' ), 'error' );
|
812 |
else
|
813 |
bp_core_add_message( __( 'User removed successfully', 'buddypress' ) );
|
814 |
|
847 |
|
848 |
// Accept the membership request
|
849 |
if ( !groups_accept_membership_request( $membership_id ) )
|
850 |
+
bp_core_add_message( __( 'There was an error accepting the membership request; please try again.', 'buddypress' ), 'error' );
|
851 |
else
|
852 |
bp_core_add_message( __( 'Group membership request accepted', 'buddypress' ) );
|
853 |
|
858 |
|
859 |
// Reject the membership request
|
860 |
if ( !groups_reject_membership_request( $membership_id ) )
|
861 |
+
bp_core_add_message( __( 'There was an error rejecting the membership request; please try again.', 'buddypress' ), 'error' );
|
862 |
else
|
863 |
bp_core_add_message( __( 'Group membership request rejected', 'buddypress' ) );
|
864 |
}
|
892 |
|
893 |
// Group admin has deleted the group, now do it.
|
894 |
if ( !groups_delete_group( $bp->groups->current_group->id ) ) {
|
895 |
+
bp_core_add_message( __( 'There was an error deleting the group; please try again.', 'buddypress' ), 'error' );
|
896 |
} else {
|
897 |
bp_core_add_message( __( 'The group was deleted successfully', 'buddypress' ) );
|
898 |
|
933 |
<thead>
|
934 |
<tr>
|
935 |
<th class="icon"></th>
|
936 |
+
<th class="title"><?php _ex( 'Groups', 'Group settings on notification settings page', 'buddypress' ) ?></th>
|
937 |
<th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
|
938 |
<th class="no"><?php _e( 'No', 'buddypress' )?></th>
|
939 |
</tr>
|
942 |
<tbody>
|
943 |
<tr id="groups-notification-settings-invitation">
|
944 |
<td></td>
|
945 |
+
<td><?php _ex( 'A member invites you to join a group', 'group settings on notification settings page','buddypress' ) ?></td>
|
946 |
<td class="yes"><input type="radio" name="notifications[notification_groups_invite]" value="yes" <?php checked( $group_invite, 'yes', true ) ?>/></td>
|
947 |
<td class="no"><input type="radio" name="notifications[notification_groups_invite]" value="no" <?php checked( $group_invite, 'no', true ) ?>/></td>
|
948 |
</tr>
|
949 |
<tr id="groups-notification-settings-info-updated">
|
950 |
<td></td>
|
951 |
+
<td><?php _ex( 'Group information is updated', 'group settings on notification settings page', 'buddypress' ) ?></td>
|
952 |
<td class="yes"><input type="radio" name="notifications[notification_groups_group_updated]" value="yes" <?php checked( $group_update, 'yes', true ) ?>/></td>
|
953 |
<td class="no"><input type="radio" name="notifications[notification_groups_group_updated]" value="no" <?php checked( $group_update, 'no', true ) ?>/></td>
|
954 |
</tr>
|
955 |
<tr id="groups-notification-settings-promoted">
|
956 |
<td></td>
|
957 |
+
<td><?php _ex( 'You are promoted to a group administrator or moderator', 'group settings on notification settings page', 'buddypress' ) ?></td>
|
958 |
<td class="yes"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="yes" <?php checked( $group_promo, 'yes', true ) ?>/></td>
|
959 |
<td class="no"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="no" <?php checked( $group_promo, 'no', true ) ?>/></td>
|
960 |
</tr>
|
961 |
<tr id="groups-notification-settings-request">
|
962 |
<td></td>
|
963 |
+
<td><?php _ex( 'A member requests to join a private group for which you are an admin', 'group settings on notification settings page', 'buddypress' ) ?></td>
|
964 |
<td class="yes"><input type="radio" name="notifications[notification_groups_membership_request]" value="yes" <?php checked( $group_request, 'yes', true ) ?>/></td>
|
965 |
<td class="no"><input type="radio" name="notifications[notification_groups_membership_request]" value="no" <?php checked( $group_request, 'no', true ) ?>/></td>
|
966 |
</tr>
|
1071 |
'post_author' => 0,
|
1072 |
'post_date' => 0,
|
1073 |
'post_content' => '',
|
1074 |
+
'post_type' => 'page',
|
1075 |
'post_status' => 'publish',
|
1076 |
'is_page' => true,
|
1077 |
'comment_status' => 'closed'
|
1119 |
*/
|
1120 |
public function create_dummy_post() {
|
1121 |
|
1122 |
+
$title = _x( 'Groups', 'Group creation page', 'buddypress' );
|
1123 |
|
1124 |
bp_theme_compat_reset_post( array(
|
1125 |
'ID' => 0,
|
1127 |
'post_author' => 0,
|
1128 |
'post_date' => 0,
|
1129 |
'post_content' => '',
|
1130 |
+
'post_type' => 'page',
|
1131 |
'post_status' => 'publish',
|
1132 |
'is_page' => true,
|
1133 |
'comment_status' => 'closed'
|
1187 |
'post_author' => 0,
|
1188 |
'post_date' => 0,
|
1189 |
'post_content' => '',
|
1190 |
+
'post_type' => 'page',
|
1191 |
'post_status' => 'publish',
|
1192 |
'is_page' => true,
|
1193 |
'comment_status' => 'closed'
|
@@ -234,8 +234,25 @@ class BP_Groups_Template {
|
|
234 |
|
235 |
// Build pagination links
|
236 |
if ( (int) $this->total_group_count && (int) $this->pag_num ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
$this->pag_links = paginate_links( array(
|
238 |
-
'base' => add_query_arg(
|
239 |
'format' => '',
|
240 |
'total' => ceil( (int) $this->total_group_count / (int) $this->pag_num ),
|
241 |
'current' => $this->pag_page,
|
@@ -292,79 +309,103 @@ class BP_Groups_Template {
|
|
292 |
/**
|
293 |
* Start the Groups Template Loop
|
294 |
*
|
295 |
-
*
|
296 |
*
|
297 |
-
*
|
298 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
*
|
300 |
-
* @param array $args
|
301 |
* @return bool True if there are groups to display that match the params
|
302 |
*/
|
303 |
function bp_has_groups( $args = '' ) {
|
304 |
-
global $groups_template
|
305 |
|
306 |
/***
|
307 |
-
*
|
308 |
-
* if arguments are directly passed into the loop. Custom plugins should always
|
309 |
-
* pass their parameters directly to the loop.
|
310 |
*/
|
311 |
-
$slug
|
312 |
-
$type
|
313 |
-
$
|
314 |
-
$order = '';
|
315 |
-
|
316 |
-
// User filtering
|
317 |
-
if ( bp_displayed_user_id() )
|
318 |
-
$user_id = bp_displayed_user_id();
|
319 |
|
320 |
-
//
|
321 |
-
// @todo What is $order? At some point it was removed incompletely?
|
322 |
if ( bp_is_current_action( 'my-groups' ) ) {
|
323 |
-
if ( 'most-popular'
|
324 |
$type = 'popular';
|
325 |
-
} elseif ( 'alphabetically'
|
326 |
$type = 'alphabetical';
|
327 |
}
|
|
|
|
|
328 |
} elseif ( bp_is_current_action( 'invites' ) ) {
|
329 |
$type = 'invites';
|
330 |
-
|
|
|
|
|
331 |
$type = 'single-group';
|
332 |
-
$slug =
|
333 |
}
|
334 |
|
335 |
-
// Default search string
|
336 |
if ( ! empty( $_REQUEST['group-filter-box'] ) ) {
|
337 |
$search_terms = $_REQUEST['group-filter-box'];
|
338 |
-
} elseif (
|
339 |
$search_terms = $_REQUEST['s'];
|
340 |
-
} else {
|
341 |
-
$search_terms = false;
|
342 |
}
|
343 |
|
344 |
-
|
345 |
-
|
|
|
346 |
'order' => 'DESC',
|
347 |
'orderby' => 'last_activity',
|
348 |
'page' => 1,
|
349 |
'per_page' => 20,
|
350 |
'max' => false,
|
351 |
'show_hidden' => false,
|
352 |
-
|
353 |
-
'
|
354 |
-
|
355 |
-
'
|
356 |
-
'
|
357 |
-
'
|
358 |
-
'
|
359 |
-
'
|
360 |
-
'exclude' => false, // Pass comma separated list or array of group ID's to exclude these groups
|
361 |
-
|
362 |
-
'populate_extras' => true, // Get extra meta - is_member, is_banned
|
363 |
'update_meta_cache' => true,
|
364 |
-
);
|
365 |
-
|
366 |
-
$r = bp_parse_args( $args, $defaults, 'has_groups' );
|
367 |
|
|
|
368 |
$groups_template = new BP_Groups_Template( array(
|
369 |
'type' => $r['type'],
|
370 |
'order' => $r['order'],
|
@@ -384,6 +425,7 @@ function bp_has_groups( $args = '' ) {
|
|
384 |
'update_meta_cache' => (bool) $r['update_meta_cache'],
|
385 |
) );
|
386 |
|
|
|
387 |
return apply_filters( 'bp_has_groups', $groups_template->has_groups(), $groups_template, $r );
|
388 |
}
|
389 |
|
@@ -524,43 +566,112 @@ function bp_group_status( $group = false ) {
|
|
524 |
return apply_filters( 'bp_get_group_status', $group->status );
|
525 |
}
|
526 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
527 |
function bp_group_avatar( $args = '' ) {
|
528 |
echo bp_get_group_avatar( $args );
|
529 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
530 |
function bp_get_group_avatar( $args = '' ) {
|
531 |
-
global $
|
532 |
|
533 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
534 |
'type' => 'full',
|
535 |
'width' => false,
|
536 |
'height' => false,
|
537 |
'class' => 'avatar',
|
538 |
'id' => false,
|
539 |
'alt' => sprintf( __( 'Group logo of %s', 'buddypress' ), $groups_template->group->name )
|
540 |
-
);
|
541 |
|
542 |
-
|
543 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
544 |
|
545 |
-
|
546 |
-
if (
|
547 |
$avatar = '<img src="' . esc_url( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . esc_attr( $groups_template->group->name ) . '" />';
|
|
|
548 |
|
549 |
-
return apply_filters( 'bp_get_group_avatar', $avatar );
|
550 |
}
|
551 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
552 |
function bp_group_avatar_thumb( $group = false ) {
|
553 |
echo bp_get_group_avatar_thumb( $group );
|
554 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
function bp_get_group_avatar_thumb( $group = false ) {
|
556 |
-
return bp_get_group_avatar(
|
|
|
|
|
|
|
557 |
}
|
558 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
559 |
function bp_group_avatar_mini( $group = false ) {
|
560 |
echo bp_get_group_avatar_mini( $group );
|
561 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
562 |
function bp_get_group_avatar_mini( $group = false ) {
|
563 |
-
return bp_get_group_avatar(
|
|
|
|
|
|
|
|
|
|
|
564 |
}
|
565 |
|
566 |
function bp_group_last_active( $group = false ) {
|
@@ -774,7 +885,7 @@ function bp_group_creator_avatar( $group = false, $args = array() ) {
|
|
774 |
'height' => false,
|
775 |
'class' => 'avatar',
|
776 |
'id' => false,
|
777 |
-
'alt' => sprintf( __( 'Group creator
|
778 |
);
|
779 |
|
780 |
$r = wp_parse_args( $args, $defaults );
|
@@ -994,7 +1105,7 @@ function bp_groups_pagination_count() {
|
|
994 |
$to_num = bp_core_number_format( ( $start_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $start_num + ( $groups_template->pag_num - 1 ) );
|
995 |
$total = bp_core_number_format( $groups_template->total_group_count );
|
996 |
|
997 |
-
return apply_filters( 'bp_get_groups_pagination_count', sprintf( _n( 'Viewing
|
998 |
}
|
999 |
|
1000 |
function bp_groups_auto_join() {
|
@@ -1514,10 +1625,11 @@ function bp_group_member_remove_link( $user_id = 0 ) {
|
|
1514 |
}
|
1515 |
|
1516 |
function bp_group_admin_tabs( $group = false ) {
|
1517 |
-
global $
|
1518 |
|
1519 |
-
if ( empty( $group ) )
|
1520 |
-
$group = ( $groups_template->group ) ? $groups_template->group :
|
|
|
1521 |
|
1522 |
$current_tab = bp_get_group_current_admin_tab();
|
1523 |
|
@@ -1532,9 +1644,9 @@ function bp_group_admin_tabs( $group = false ) {
|
|
1532 |
|
1533 |
<li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/group-settings' ) ?>"><?php _e( 'Settings', 'buddypress' ); ?></a></li>
|
1534 |
|
1535 |
-
<?php if ( !(int)bp_get_option( 'bp-disable-avatar-uploads' ) ) : ?>
|
1536 |
|
1537 |
-
<li<?php if ( 'group-avatar' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/group-avatar' ) ?>"><?php _e( '
|
1538 |
|
1539 |
<?php endif; ?>
|
1540 |
|
@@ -1625,36 +1737,74 @@ function bp_group_is_member( $group = false ) {
|
|
1625 |
}
|
1626 |
|
1627 |
/**
|
1628 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1629 |
*
|
1630 |
-
*
|
1631 |
-
* check $groups_template->group->is_banned instead of making another SQL query.
|
1632 |
-
* However, if used in a single group's pages, we must use groups_is_user_banned().
|
1633 |
*
|
1634 |
* @global BP_Groups_Template $groups_template Group template loop object
|
1635 |
-
* @param
|
1636 |
-
* @param int $user_id
|
1637 |
-
* @return bool
|
1638 |
-
* @since BuddyPress (1.5)
|
1639 |
*/
|
1640 |
function bp_group_is_user_banned( $group = false, $user_id = 0 ) {
|
1641 |
global $groups_template;
|
1642 |
|
1643 |
// Site admins always have access
|
1644 |
-
if ( bp_current_user_can( 'bp_moderate' ) )
|
1645 |
return false;
|
|
|
1646 |
|
1647 |
-
|
1648 |
-
|
|
|
|
|
1649 |
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
|
|
1653 |
|
1654 |
-
|
1655 |
-
|
|
|
1656 |
|
1657 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1658 |
}
|
1659 |
|
1660 |
function bp_group_accept_invite_link() {
|
@@ -1955,10 +2105,13 @@ function bp_group_status_message( $group = null ) {
|
|
1955 |
|
1956 |
if ( 'private' == $group->status ) {
|
1957 |
if ( ! bp_group_has_requested_membership() ) {
|
1958 |
-
if ( is_user_logged_in() )
|
|
|
|
|
1959 |
$message = __( 'This is a private group and you must request group membership in order to join.', 'buddypress' );
|
1960 |
-
else
|
1961 |
$message = __( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' );
|
|
|
1962 |
|
1963 |
} else {
|
1964 |
$message = __( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' );
|
@@ -2190,7 +2343,9 @@ class BP_Groups_Group_Members_Template {
|
|
2190 |
* @type string $type Optional. Sort order of results. 'last_joined',
|
2191 |
* 'first_joined', or any of the $type params available in
|
2192 |
* {@link BP_User_Query}. Default: 'last_joined'.
|
2193 |
-
* @type string $search_terms Optional. Search terms to match.
|
|
|
|
|
2194 |
* }
|
2195 |
*/
|
2196 |
function bp_group_has_members( $args = '' ) {
|
@@ -2211,12 +2366,13 @@ function bp_group_has_members( $args = '' ) {
|
|
2211 |
'exclude_admins_mods' => $exclude_admins_mods,
|
2212 |
'exclude_banned' => 1,
|
2213 |
'group_role' => false,
|
2214 |
-
'search_terms' =>
|
2215 |
'type' => 'last_joined',
|
2216 |
) );
|
2217 |
|
2218 |
-
if (
|
2219 |
$r['search_terms'] = $_REQUEST['s'];
|
|
|
2220 |
|
2221 |
$members_template = new BP_Groups_Group_Members_Template( $r );
|
2222 |
return apply_filters( 'bp_group_has_members', $members_template->has_members(), $members_template );
|
@@ -2234,31 +2390,97 @@ function bp_group_the_member() {
|
|
2234 |
return $members_template->the_member();
|
2235 |
}
|
2236 |
|
2237 |
-
|
2238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2239 |
}
|
2240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2241 |
global $members_template;
|
2242 |
|
2243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2244 |
}
|
2245 |
|
2246 |
-
|
2247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2248 |
}
|
2249 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2250 |
global $members_template;
|
2251 |
|
2252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2253 |
}
|
2254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2255 |
function bp_group_member_avatar_mini( $width = 30, $height = 30 ) {
|
2256 |
echo bp_get_group_member_avatar_mini( $width, $height );
|
2257 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2258 |
function bp_get_group_member_avatar_mini( $width = 30, $height = 30 ) {
|
2259 |
global $members_template;
|
2260 |
|
2261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2262 |
}
|
2263 |
|
2264 |
function bp_group_member_name() {
|
@@ -2381,7 +2603,7 @@ function bp_group_member_pagination_count() {
|
|
2381 |
$to_num = bp_core_number_format( ( $start_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $start_num + ( $members_template->pag_num - 1 ) );
|
2382 |
$total = bp_core_number_format( $members_template->total_member_count );
|
2383 |
|
2384 |
-
return apply_filters( 'bp_get_group_member_pagination_count', sprintf( _n( 'Viewing
|
2385 |
}
|
2386 |
|
2387 |
function bp_group_member_admin_pagination() {
|
@@ -2437,6 +2659,11 @@ function bp_groups_members_filter() {
|
|
2437 |
<select id="group_members-order-by">
|
2438 |
<option value="last_joined"><?php _e( 'Newest', 'buddypress' ); ?></option>
|
2439 |
<option value="first_joined"><?php _e( 'Oldest', 'buddypress' ); ?></option>
|
|
|
|
|
|
|
|
|
|
|
2440 |
<option value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ); ?></option>
|
2441 |
|
2442 |
<?php do_action( 'bp_groups_members_order_options' ); ?>
|
@@ -2849,14 +3076,16 @@ function bp_groups_filter_title() {
|
|
2849 |
do_action( 'bp_groups_filter_title' );
|
2850 |
}
|
2851 |
|
2852 |
-
|
2853 |
-
|
2854 |
-
|
2855 |
-
|
2856 |
-
|
2857 |
-
|
2858 |
-
|
2859 |
-
|
|
|
|
|
2860 |
}
|
2861 |
|
2862 |
/**
|
@@ -3254,7 +3483,7 @@ function bp_group_requests_pagination_count() {
|
|
3254 |
$to_num = bp_core_number_format( ( $start_num + ( $requests_template->pag_num - 1 ) > $requests_template->total_request_count ) ? $requests_template->total_request_count : $start_num + ( $requests_template->pag_num - 1 ) );
|
3255 |
$total = bp_core_number_format( $requests_template->total_request_count );
|
3256 |
|
3257 |
-
return apply_filters( 'bp_get_group_requests_pagination_count', sprintf( _n( 'Viewing
|
3258 |
}
|
3259 |
|
3260 |
/************************************************************************************
|
@@ -3380,9 +3609,9 @@ class BP_Groups_Invite_Template {
|
|
3380 |
$this->invite->user->profile_data = BP_XProfile_ProfileData::get_all_for_user( $user_id );
|
3381 |
}
|
3382 |
|
3383 |
-
$this->invite->user->avatar = bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'full', 'alt' => sprintf( __( '
|
3384 |
-
$this->invite->user->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf( __( '
|
3385 |
-
$this->invite->user->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf( __( '
|
3386 |
$this->invite->user->email = $this->invite->user->user_email;
|
3387 |
$this->invite->user->user_url = bp_core_get_user_domain( $user_id, $this->invite->user->user_nicename, $this->invite->user->user_login );
|
3388 |
$this->invite->user->user_link = "<a href='{$this->invite->user->user_url}' title='{$this->invite->user->fullname}'>{$this->invite->user->fullname}</a>";
|
@@ -3421,9 +3650,9 @@ function bp_group_has_invites( $args = '' ) {
|
|
3421 |
) );
|
3422 |
|
3423 |
if ( empty( $r['group_id'] ) ) {
|
3424 |
-
if (
|
3425 |
$r['group_id'] = bp_get_current_group_id();
|
3426 |
-
}
|
3427 |
$r['group_id'] = buddypress()->groups->new_group_id;
|
3428 |
}
|
3429 |
}
|
@@ -3549,7 +3778,7 @@ function bp_group_invite_pagination_count() {
|
|
3549 |
$to_num = bp_core_number_format( ( $start_num + ( $invites_template->pag_num - 1 ) > $invites_template->total_invite_count ) ? $invites_template->total_invite_count : $start_num + ( $invites_template->pag_num - 1 ) );
|
3550 |
$total = bp_core_number_format( $invites_template->total_invite_count );
|
3551 |
|
3552 |
-
return apply_filters( 'bp_get_groups_pagination_count', sprintf( _n( 'Viewing
|
3553 |
}
|
3554 |
|
3555 |
/***
|
@@ -3575,9 +3804,7 @@ function bp_group_activity_feed_link() {
|
|
3575 |
echo bp_get_group_activity_feed_link();
|
3576 |
}
|
3577 |
function bp_get_group_activity_feed_link() {
|
3578 |
-
|
3579 |
-
|
3580 |
-
return apply_filters( 'bp_get_group_activity_feed_link', bp_get_group_permalink( $bp->groups->current_group ) . 'feed/' );
|
3581 |
}
|
3582 |
|
3583 |
/**
|
@@ -3599,8 +3826,7 @@ function bp_current_group_id() {
|
|
3599 |
* @return int $current_group_id The id of the current group, if there is one
|
3600 |
*/
|
3601 |
function bp_get_current_group_id() {
|
3602 |
-
$current_group
|
3603 |
-
|
3604 |
$current_group_id = isset( $current_group->id ) ? (int) $current_group->id : 0;
|
3605 |
|
3606 |
return apply_filters( 'bp_get_current_group_id', $current_group_id, $current_group );
|
@@ -3625,8 +3851,7 @@ function bp_current_group_slug() {
|
|
3625 |
* @return string $current_group_slug The slug of the current group, if there is one
|
3626 |
*/
|
3627 |
function bp_get_current_group_slug() {
|
3628 |
-
$current_group
|
3629 |
-
|
3630 |
$current_group_slug = isset( $current_group->slug ) ? $current_group->slug : '';
|
3631 |
|
3632 |
return apply_filters( 'bp_get_current_group_slug', $current_group_slug, $current_group );
|
@@ -3650,44 +3875,96 @@ function bp_current_group_name() {
|
|
3650 |
* @return string The name of the current group, if there is one
|
3651 |
*/
|
3652 |
function bp_get_current_group_name() {
|
3653 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3654 |
|
3655 |
-
|
3656 |
-
return apply_filters( 'bp_get_current_group_name', $name );
|
3657 |
}
|
3658 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3659 |
function bp_groups_action_link( $action = '', $query_args = '', $nonce = false ) {
|
3660 |
echo bp_get_groups_action_link( $action, $query_args, $nonce );
|
3661 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3662 |
function bp_get_groups_action_link( $action = '', $query_args = '', $nonce = false ) {
|
3663 |
-
|
|
|
|
|
3664 |
|
3665 |
// Must be a group
|
3666 |
-
if ( empty( $
|
3667 |
-
return;
|
3668 |
|
3669 |
-
|
3670 |
-
|
3671 |
-
|
3672 |
-
|
3673 |
-
|
|
|
3674 |
|
3675 |
-
|
3676 |
-
|
3677 |
|
3678 |
-
|
3679 |
-
|
3680 |
-
|
|
|
3681 |
|
3682 |
-
|
3683 |
-
|
3684 |
-
|
3685 |
-
|
3686 |
-
|
|
|
|
|
3687 |
|
3688 |
-
// Return the url
|
3689 |
-
|
3690 |
-
return $url;
|
3691 |
}
|
3692 |
|
3693 |
/** Stats **********************************************************************/
|
234 |
|
235 |
// Build pagination links
|
236 |
if ( (int) $this->total_group_count && (int) $this->pag_num ) {
|
237 |
+
$pag_args = array(
|
238 |
+
$page_arg => '%#%',
|
239 |
+
'num' => $this->pag_num,
|
240 |
+
'sortby' => $this->sort_by,
|
241 |
+
'order' => $this->order,
|
242 |
+
);
|
243 |
+
|
244 |
+
if ( defined( 'DOING_AJAX' ) && true === (bool) DOING_AJAX ) {
|
245 |
+
$base = remove_query_arg( 's', wp_get_referer() );
|
246 |
+
} else {
|
247 |
+
$base = '';
|
248 |
+
}
|
249 |
+
|
250 |
+
if ( ! empty( $search_terms ) ) {
|
251 |
+
$pag_args['s'] = $search_terms;
|
252 |
+
}
|
253 |
+
|
254 |
$this->pag_links = paginate_links( array(
|
255 |
+
'base' => add_query_arg( $pag_args, $base ),
|
256 |
'format' => '',
|
257 |
'total' => ceil( (int) $this->total_group_count / (int) $this->pag_num ),
|
258 |
'current' => $this->pag_page,
|
309 |
/**
|
310 |
* Start the Groups Template Loop
|
311 |
*
|
312 |
+
* @since BuddyPress (1.0.0)
|
313 |
*
|
314 |
+
* @param array $args {
|
315 |
+
* Array of parameters. All items are optional.
|
316 |
+
* @type string $type Optional. Shorthand for certain orderby/
|
317 |
+
* order combinations. 'newest', 'active', 'popular',
|
318 |
+
* 'alphabetical', 'random'. When present, will override
|
319 |
+
* orderby and order params. Default: null.
|
320 |
+
* @type string $orderby Optional. Property to sort by.
|
321 |
+
* 'date_created', 'last_activity', 'total_member_count',
|
322 |
+
* 'name', 'random'. Default: 'date_created'.
|
323 |
+
* @type string $order Optional. Sort order. 'ASC' or 'DESC'.
|
324 |
+
* Default: 'DESC'.
|
325 |
+
* @type int $per_page Optional. Number of items to return per page
|
326 |
+
* of results. Default: null (no limit).
|
327 |
+
* @type int $page Optional. Page offset of results to return.
|
328 |
+
* Default: null (no limit).
|
329 |
+
* @type int $user_id Optional. If provided, results will be limited
|
330 |
+
* to groups of which the specified user is a member. Default:
|
331 |
+
* null.
|
332 |
+
* @type string $search_terms Optional. If provided, only groups
|
333 |
+
* whose names or descriptions match the search terms will be
|
334 |
+
* returned. Default: false.
|
335 |
+
* @type array $meta_query Optional. An array of meta_query
|
336 |
+
* conditions. See {@link WP_Meta_Query::queries} for
|
337 |
+
* description.
|
338 |
+
* @type array|string Optional. Array or comma-separated list of
|
339 |
+
* group IDs. Results will be limited to groups within the
|
340 |
+
* list. Default: false.
|
341 |
+
* @type bool $populate_extras Whether to fetch additional
|
342 |
+
* information (such as member count) about groups. Default:
|
343 |
+
* true.
|
344 |
+
* @type array|string Optional. Array or comma-separated list of
|
345 |
+
* group IDs. Results will exclude the listed groups.
|
346 |
+
* Default: false.
|
347 |
+
* @type bool $show_hidden Whether to include hidden groups in
|
348 |
+
* results. Default: false.
|
349 |
+
* }
|
350 |
*
|
|
|
351 |
* @return bool True if there are groups to display that match the params
|
352 |
*/
|
353 |
function bp_has_groups( $args = '' ) {
|
354 |
+
global $groups_template;
|
355 |
|
356 |
/***
|
357 |
+
* Defaults based on the current page & overridden by parsed $args
|
|
|
|
|
358 |
*/
|
359 |
+
$slug = false;
|
360 |
+
$type = '';
|
361 |
+
$search_terms = false;
|
|
|
|
|
|
|
|
|
|
|
362 |
|
363 |
+
// When looking your own groups, check for two action variables
|
|
|
364 |
if ( bp_is_current_action( 'my-groups' ) ) {
|
365 |
+
if ( bp_is_action_variable( 'most-popular', 0 ) ) {
|
366 |
$type = 'popular';
|
367 |
+
} elseif ( bp_is_action_variable( 'alphabetically', 0 ) ) {
|
368 |
$type = 'alphabetical';
|
369 |
}
|
370 |
+
|
371 |
+
// When looking at invites, set type to invites
|
372 |
} elseif ( bp_is_current_action( 'invites' ) ) {
|
373 |
$type = 'invites';
|
374 |
+
|
375 |
+
// When looking at a single group, set the type and slug
|
376 |
+
} elseif ( bp_get_current_group_slug() ) {
|
377 |
$type = 'single-group';
|
378 |
+
$slug = bp_get_current_group_slug();
|
379 |
}
|
380 |
|
381 |
+
// Default search string (too soon to escape here)
|
382 |
if ( ! empty( $_REQUEST['group-filter-box'] ) ) {
|
383 |
$search_terms = $_REQUEST['group-filter-box'];
|
384 |
+
} elseif ( !empty( $_REQUEST['s'] ) ) {
|
385 |
$search_terms = $_REQUEST['s'];
|
|
|
|
|
386 |
}
|
387 |
|
388 |
+
// Parse defaults and requested arguments
|
389 |
+
$r = bp_parse_args( $args, array(
|
390 |
+
'type' => $type,
|
391 |
'order' => 'DESC',
|
392 |
'orderby' => 'last_activity',
|
393 |
'page' => 1,
|
394 |
'per_page' => 20,
|
395 |
'max' => false,
|
396 |
'show_hidden' => false,
|
397 |
+
'page_arg' => 'grpage',
|
398 |
+
'user_id' => bp_displayed_user_id(),
|
399 |
+
'slug' => $slug,
|
400 |
+
'search_terms' => $search_terms,
|
401 |
+
'meta_query' => false,
|
402 |
+
'include' => false,
|
403 |
+
'exclude' => false,
|
404 |
+
'populate_extras' => true,
|
|
|
|
|
|
|
405 |
'update_meta_cache' => true,
|
406 |
+
), 'has_groups' );
|
|
|
|
|
407 |
|
408 |
+
// Setup the Groups template global
|
409 |
$groups_template = new BP_Groups_Template( array(
|
410 |
'type' => $r['type'],
|
411 |
'order' => $r['order'],
|
425 |
'update_meta_cache' => (bool) $r['update_meta_cache'],
|
426 |
) );
|
427 |
|
428 |
+
// Filter and return whether or not the groups loop has groups in it
|
429 |
return apply_filters( 'bp_has_groups', $groups_template->has_groups(), $groups_template, $r );
|
430 |
}
|
431 |
|
566 |
return apply_filters( 'bp_get_group_status', $group->status );
|
567 |
}
|
568 |
|
569 |
+
/**
|
570 |
+
* Output the group avatar while in the groups loop.
|
571 |
+
*
|
572 |
+
* @since BuddyPress (1.0.0)
|
573 |
+
*
|
574 |
+
* @param array $args {@see bp_core_fetch_avatar()}
|
575 |
+
*/
|
576 |
function bp_group_avatar( $args = '' ) {
|
577 |
echo bp_get_group_avatar( $args );
|
578 |
}
|
579 |
+
/**
|
580 |
+
* Return the group avatar while in the groups loop.
|
581 |
+
*
|
582 |
+
* @since BuddyPress (1.0.0)
|
583 |
+
*
|
584 |
+
* @param array $args {@see bp_core_fetch_avatar()}
|
585 |
+
*/
|
586 |
function bp_get_group_avatar( $args = '' ) {
|
587 |
+
global $groups_template;
|
588 |
|
589 |
+
// Bail if avatars are turned off
|
590 |
+
// @todo Should we maybe still filter this?
|
591 |
+
if ( ! buddypress()->avatar->show_avatars ) {
|
592 |
+
return false;
|
593 |
+
}
|
594 |
+
|
595 |
+
// Parse the arguments
|
596 |
+
$r = bp_parse_args( $args, array(
|
597 |
'type' => 'full',
|
598 |
'width' => false,
|
599 |
'height' => false,
|
600 |
'class' => 'avatar',
|
601 |
'id' => false,
|
602 |
'alt' => sprintf( __( 'Group logo of %s', 'buddypress' ), $groups_template->group->name )
|
603 |
+
) );
|
604 |
|
605 |
+
// Fetch the avatar from the folder
|
606 |
+
$avatar = bp_core_fetch_avatar( array(
|
607 |
+
'item_id' => $groups_template->group->id,
|
608 |
+
'title' => $groups_template->group->name,
|
609 |
+
'avatar_dir' => 'group-avatars',
|
610 |
+
'object' => 'group',
|
611 |
+
'type' => $r['type'],
|
612 |
+
'alt' => $r['alt'],
|
613 |
+
'css_id' => $r['id'],
|
614 |
+
'class' => $r['class'],
|
615 |
+
'width' => $r['width'],
|
616 |
+
'height' => $r['height']
|
617 |
+
) );
|
618 |
|
619 |
+
// If No avatar found, provide some backwards compatibility
|
620 |
+
if ( empty( $avatar ) ) {
|
621 |
$avatar = '<img src="' . esc_url( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . esc_attr( $groups_template->group->name ) . '" />';
|
622 |
+
}
|
623 |
|
624 |
+
return apply_filters( 'bp_get_group_avatar', $avatar, $r );
|
625 |
}
|
626 |
|
627 |
+
/**
|
628 |
+
* Output the group avatar thumbnail while in the groups loop.
|
629 |
+
*
|
630 |
+
* @since BuddyPress (1.0.0)
|
631 |
+
*
|
632 |
+
* @param object $group Single group object
|
633 |
+
*/
|
634 |
function bp_group_avatar_thumb( $group = false ) {
|
635 |
echo bp_get_group_avatar_thumb( $group );
|
636 |
}
|
637 |
+
/**
|
638 |
+
* Return the group avatar thumbnail while in the groups loop.
|
639 |
+
*
|
640 |
+
* @since BuddyPress (1.0.0)
|
641 |
+
*
|
642 |
+
* @param object $group Single group object
|
643 |
+
*/
|
644 |
function bp_get_group_avatar_thumb( $group = false ) {
|
645 |
+
return bp_get_group_avatar( array(
|
646 |
+
'type' => 'thumb',
|
647 |
+
'id' => ! empty( $group->id ) ? $group->id : false
|
648 |
+
) );
|
649 |
}
|
650 |
|
651 |
+
/**
|
652 |
+
* Output the miniature group avatar thumbnail while in the groups loop.
|
653 |
+
*
|
654 |
+
* @since BuddyPress (1.0.0)
|
655 |
+
*
|
656 |
+
* @param object $group Single group object
|
657 |
+
*/
|
658 |
function bp_group_avatar_mini( $group = false ) {
|
659 |
echo bp_get_group_avatar_mini( $group );
|
660 |
}
|
661 |
+
/**
|
662 |
+
* Return the miniature group avatar thumbnail while in the groups loop.
|
663 |
+
*
|
664 |
+
* @since BuddyPress (1.0.0)
|
665 |
+
*
|
666 |
+
* @param object $group Single group object
|
667 |
+
*/
|
668 |
function bp_get_group_avatar_mini( $group = false ) {
|
669 |
+
return bp_get_group_avatar( array(
|
670 |
+
'type' => 'thumb',
|
671 |
+
'width' => 30,
|
672 |
+
'height' => 30,
|
673 |
+
'id' => ! empty( $group->id ) ? $group->id : false
|
674 |
+
) );
|
675 |
}
|
676 |
|
677 |
function bp_group_last_active( $group = false ) {
|
885 |
'height' => false,
|
886 |
'class' => 'avatar',
|
887 |
'id' => false,
|
888 |
+
'alt' => sprintf( __( 'Group creator profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $group->creator_id ) )
|
889 |
);
|
890 |
|
891 |
$r = wp_parse_args( $args, $defaults );
|
1105 |
$to_num = bp_core_number_format( ( $start_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $start_num + ( $groups_template->pag_num - 1 ) );
|
1106 |
$total = bp_core_number_format( $groups_template->total_group_count );
|
1107 |
|
1108 |
+
return apply_filters( 'bp_get_groups_pagination_count', sprintf( _n( 'Viewing 1', 'Viewing %1$s - %2$s of %3$s groups', $total, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
|
1109 |
}
|
1110 |
|
1111 |
function bp_groups_auto_join() {
|
1625 |
}
|
1626 |
|
1627 |
function bp_group_admin_tabs( $group = false ) {
|
1628 |
+
global $groups_template;
|
1629 |
|
1630 |
+
if ( empty( $group ) ) {
|
1631 |
+
$group = ( $groups_template->group ) ? $groups_template->group : groups_get_current_group();
|
1632 |
+
}
|
1633 |
|
1634 |
$current_tab = bp_get_group_current_admin_tab();
|
1635 |
|
1644 |
|
1645 |
<li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/group-settings' ) ?>"><?php _e( 'Settings', 'buddypress' ); ?></a></li>
|
1646 |
|
1647 |
+
<?php if ( !(int)bp_get_option( 'bp-disable-avatar-uploads' ) && buddypress()->avatar->show_avatars ) : ?>
|
1648 |
|
1649 |
+
<li<?php if ( 'group-avatar' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/group-avatar' ) ?>"><?php _e( 'Photo', 'buddypress' ); ?></a></li>
|
1650 |
|
1651 |
<?php endif; ?>
|
1652 |
|
1737 |
}
|
1738 |
|
1739 |
/**
|
1740 |
+
* Check whether the current user has an outstanding invite to the current group in the loop.
|
1741 |
+
*
|
1742 |
+
* @param object $group Optional. Group data object. Defaults to the current
|
1743 |
+
* group in the groups loop.
|
1744 |
+
* @return bool True if the user has an outstanding invite, otherwise false.
|
1745 |
+
*/
|
1746 |
+
function bp_group_is_invited( $group = false ) {
|
1747 |
+
global $groups_template;
|
1748 |
+
|
1749 |
+
if ( empty( $group ) ) {
|
1750 |
+
$group =& $groups_template->group;
|
1751 |
+
}
|
1752 |
+
|
1753 |
+
return apply_filters( 'bp_group_is_invited', ! empty( $group->is_invited ) );
|
1754 |
+
}
|
1755 |
+
|
1756 |
+
/**
|
1757 |
+
* Check if a user is banned from a group.
|
1758 |
+
*
|
1759 |
+
* If this function is invoked inside the groups template loop, then we check
|
1760 |
+
* $groups_template->group->is_banned instead of using {@link groups_is_user_banned()}
|
1761 |
+
* and making another SQL query.
|
1762 |
+
*
|
1763 |
+
* In BuddyPress 2.1, to standardize this function, we are defaulting the
|
1764 |
+
* return value to a boolean. In previous versions, using this function would
|
1765 |
+
* return either a string of the integer (0 or 1) or null if a result couldn't
|
1766 |
+
* be found from the database. If the logged-in user had the 'bp_moderate'
|
1767 |
+
* capability, the return value would be boolean false.
|
1768 |
*
|
1769 |
+
* @since BuddyPress (1.5.0)
|
|
|
|
|
1770 |
*
|
1771 |
* @global BP_Groups_Template $groups_template Group template loop object
|
1772 |
+
* @param BP_Groups_Group $group Group to check if user is banned
|
1773 |
+
* @param int $user_id The user ID to check
|
1774 |
+
* @return bool True if user is banned. False if user isn't banned.
|
|
|
1775 |
*/
|
1776 |
function bp_group_is_user_banned( $group = false, $user_id = 0 ) {
|
1777 |
global $groups_template;
|
1778 |
|
1779 |
// Site admins always have access
|
1780 |
+
if ( bp_current_user_can( 'bp_moderate' ) ) {
|
1781 |
return false;
|
1782 |
+
}
|
1783 |
|
1784 |
+
// check groups loop first
|
1785 |
+
// @see BP_Groups_Group::get_group_extras()
|
1786 |
+
if ( ! empty( $groups_template->in_the_loop ) && isset( $groups_template->group->is_banned ) ) {
|
1787 |
+
$retval = $groups_template->group->is_banned;
|
1788 |
|
1789 |
+
// not in loop
|
1790 |
+
} else {
|
1791 |
+
// Default to not banned
|
1792 |
+
$retval = false;
|
1793 |
|
1794 |
+
if ( empty( $group ) ) {
|
1795 |
+
$group = $groups_template->group;
|
1796 |
+
}
|
1797 |
|
1798 |
+
if ( empty( $user_id ) ) {
|
1799 |
+
$user_id = bp_loggedin_user_id();
|
1800 |
+
}
|
1801 |
+
|
1802 |
+
if ( ! empty( $user_id ) && ! empty( $group->id ) ) {
|
1803 |
+
$retval = groups_is_user_banned( $user_id, $group->id );
|
1804 |
+
}
|
1805 |
+
}
|
1806 |
+
|
1807 |
+
return (bool) apply_filters( 'bp_group_is_user_banned', $retval );
|
1808 |
}
|
1809 |
|
1810 |
function bp_group_accept_invite_link() {
|
2105 |
|
2106 |
if ( 'private' == $group->status ) {
|
2107 |
if ( ! bp_group_has_requested_membership() ) {
|
2108 |
+
if ( is_user_logged_in() && bp_group_is_invited() ) {
|
2109 |
+
$message = __( 'You must accept your pending invitation before you can access this private group.', 'buddypress' );
|
2110 |
+
} else if ( is_user_logged_in() ) {
|
2111 |
$message = __( 'This is a private group and you must request group membership in order to join.', 'buddypress' );
|
2112 |
+
} else {
|
2113 |
$message = __( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' );
|
2114 |
+
}
|
2115 |
|
2116 |
} else {
|
2117 |
$message = __( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' );
|
2343 |
* @type string $type Optional. Sort order of results. 'last_joined',
|
2344 |
* 'first_joined', or any of the $type params available in
|
2345 |
* {@link BP_User_Query}. Default: 'last_joined'.
|
2346 |
+
* @type string $search_terms Optional. Search terms to match. Pass an
|
2347 |
+
* empty string to force-disable search, even in the presence of
|
2348 |
+
* $_REQUEST['s']. Default: null.
|
2349 |
* }
|
2350 |
*/
|
2351 |
function bp_group_has_members( $args = '' ) {
|
2366 |
'exclude_admins_mods' => $exclude_admins_mods,
|
2367 |
'exclude_banned' => 1,
|
2368 |
'group_role' => false,
|
2369 |
+
'search_terms' => null,
|
2370 |
'type' => 'last_joined',
|
2371 |
) );
|
2372 |
|
2373 |
+
if ( is_null( $r['search_terms'] ) && ! empty( $_REQUEST['s'] ) ) {
|
2374 |
$r['search_terms'] = $_REQUEST['s'];
|
2375 |
+
}
|
2376 |
|
2377 |
$members_template = new BP_Groups_Group_Members_Template( $r );
|
2378 |
return apply_filters( 'bp_group_has_members', $members_template->has_members(), $members_template );
|
2390 |
return $members_template->the_member();
|
2391 |
}
|
2392 |
|
2393 |
+
/**
|
2394 |
+
* Output the group member avatar while in the groups members loop.
|
2395 |
+
*
|
2396 |
+
* @since BuddyPress (1.0.0)
|
2397 |
+
*
|
2398 |
+
* @param array $args {@see bp_core_fetch_avatar()}
|
2399 |
+
*/
|
2400 |
+
function bp_group_member_avatar( $args = '' ) {
|
2401 |
+
echo bp_get_group_member_avatar( $args );
|
2402 |
}
|
2403 |
+
/**
|
2404 |
+
* Return the group member avatar while in the groups members loop.
|
2405 |
+
*
|
2406 |
+
* @since BuddyPress (1.0.0)
|
2407 |
+
*
|
2408 |
+
* @param array $args {@see bp_core_fetch_avatar()}
|
2409 |
+
*/
|
2410 |
+
function bp_get_group_member_avatar( $args = '' ) {
|
2411 |
global $members_template;
|
2412 |
|
2413 |
+
$r = bp_parse_args( $args, array(
|
2414 |
+
'item_id' => $members_template->member->user_id,
|
2415 |
+
'type' => 'full',
|
2416 |
+
'email' => $members_template->member->user_email,
|
2417 |
+
'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), $members_template->member->display_name )
|
2418 |
+
) );
|
2419 |
+
|
2420 |
+
return apply_filters( 'bp_get_group_member_avatar', bp_core_fetch_avatar( $r ), $r );
|
2421 |
}
|
2422 |
|
2423 |
+
/**
|
2424 |
+
* Output the group member avatar while in the groups members loop.
|
2425 |
+
*
|
2426 |
+
* @since BuddyPress (1.0.0)
|
2427 |
+
*
|
2428 |
+
* @param array $args {@see bp_core_fetch_avatar()}
|
2429 |
+
*/
|
2430 |
+
|
2431 |
+
function bp_group_member_avatar_thumb( $args = '' ) {
|
2432 |
+
echo bp_get_group_member_avatar_thumb( $args );
|
2433 |
}
|
2434 |
+
/**
|
2435 |
+
* Return the group member avatar while in the groups members loop.
|
2436 |
+
*
|
2437 |
+
* @since BuddyPress (1.0.0)
|
2438 |
+
*
|
2439 |
+
* @param array $args {@see bp_core_fetch_avatar()}
|
2440 |
+
*/
|
2441 |
+
function bp_get_group_member_avatar_thumb( $args = '' ) {
|
2442 |
global $members_template;
|
2443 |
|
2444 |
+
$r = bp_parse_args( $args, array(
|
2445 |
+
'item_id' => $members_template->member->user_id,
|
2446 |
+
'type' => 'thumb',
|
2447 |
+
'email' => $members_template->member->user_email,
|
2448 |
+
'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), $members_template->member->display_name )
|
2449 |
+
) );
|
2450 |
+
|
2451 |
+
return apply_filters( 'bp_get_group_member_avatar_thumb', bp_core_fetch_avatar( $r ), $r );
|
2452 |
}
|
2453 |
|
2454 |
+
/**
|
2455 |
+
* Output the group member avatar while in the groups members loop.
|
2456 |
+
*
|
2457 |
+
* @since BuddyPress (1.0.0)
|
2458 |
+
*
|
2459 |
+
* @param array $args {@see bp_core_fetch_avatar()}
|
2460 |
+
*/
|
2461 |
function bp_group_member_avatar_mini( $width = 30, $height = 30 ) {
|
2462 |
echo bp_get_group_member_avatar_mini( $width, $height );
|
2463 |
}
|
2464 |
+
/**
|
2465 |
+
* Output the group member avatar while in the groups members loop.
|
2466 |
+
*
|
2467 |
+
* @since BuddyPress (1.0.0)
|
2468 |
+
*
|
2469 |
+
* @param array $args {@see bp_core_fetch_avatar()}
|
2470 |
+
*/
|
2471 |
function bp_get_group_member_avatar_mini( $width = 30, $height = 30 ) {
|
2472 |
global $members_template;
|
2473 |
|
2474 |
+
$r = bp_parse_args( array(), array(
|
2475 |
+
'item_id' => $members_template->member->user_id,
|
2476 |
+
'type' => 'thumb',
|
2477 |
+
'email' => $members_template->member->user_email,
|
2478 |
+
'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), $members_template->member->display_name ),
|
2479 |
+
'width' => absint( $width ),
|
2480 |
+
'height' => absint( $height )
|
2481 |
+
) );
|
2482 |
+
|
2483 |
+
return apply_filters( 'bp_get_group_member_avatar_mini', bp_core_fetch_avatar( $r ), $r );
|
2484 |
}
|
2485 |
|
2486 |
function bp_group_member_name() {
|
2603 |
$to_num = bp_core_number_format( ( $start_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $start_num + ( $members_template->pag_num - 1 ) );
|
2604 |
$total = bp_core_number_format( $members_template->total_member_count );
|
2605 |
|
2606 |
+
return apply_filters( 'bp_get_group_member_pagination_count', sprintf( _n( 'Viewing 1 member', 'Viewing %1$s - %2$s of %3$s members', $total, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
|
2607 |
}
|
2608 |
|
2609 |
function bp_group_member_admin_pagination() {
|
2659 |
<select id="group_members-order-by">
|
2660 |
<option value="last_joined"><?php _e( 'Newest', 'buddypress' ); ?></option>
|
2661 |
<option value="first_joined"><?php _e( 'Oldest', 'buddypress' ); ?></option>
|
2662 |
+
|
2663 |
+
<?php if ( bp_is_active( 'activity' ) ) : ?>
|
2664 |
+
<option value="group_activity"><?php _e( 'Group Activity', 'buddypress' ); ?></option>
|
2665 |
+
<?php endif; ?>
|
2666 |
+
|
2667 |
<option value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ); ?></option>
|
2668 |
|
2669 |
<?php do_action( 'bp_groups_members_order_options' ); ?>
|
3076 |
do_action( 'bp_groups_filter_title' );
|
3077 |
}
|
3078 |
|
3079 |
+
/**
|
3080 |
+
* Is the current page a specific group admin screen?
|
3081 |
+
*
|
3082 |
+
* @since BuddyPress (1.1)
|
3083 |
+
*
|
3084 |
+
* @param string $slug
|
3085 |
+
* @return bool
|
3086 |
+
*/
|
3087 |
+
function bp_is_group_admin_screen( $slug = '' ) {
|
3088 |
+
return (bool) ( bp_is_group_admin_page() && bp_is_action_variable( $slug ) );
|
3089 |
}
|
3090 |
|
3091 |
/**
|
3483 |
$to_num = bp_core_number_format( ( $start_num + ( $requests_template->pag_num - 1 ) > $requests_template->total_request_count ) ? $requests_template->total_request_count : $start_num + ( $requests_template->pag_num - 1 ) );
|
3484 |
$total = bp_core_number_format( $requests_template->total_request_count );
|
3485 |
|
3486 |
+
return apply_filters( 'bp_get_group_requests_pagination_count', sprintf( _n( 'Viewing 1 request', 'Viewing %1$s - %2$s of %3$s requests', $total, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
|
3487 |
}
|
3488 |
|
3489 |
/************************************************************************************
|
3609 |
$this->invite->user->profile_data = BP_XProfile_ProfileData::get_all_for_user( $user_id );
|
3610 |
}
|
3611 |
|
3612 |
+
$this->invite->user->avatar = bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'full', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->invite->user->fullname ) ) );
|
3613 |
+
$this->invite->user->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->invite->user->fullname ) ) );
|
3614 |
+
$this->invite->user->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->invite->user->fullname ), 'width' => 30, 'height' => 30 ) );
|
3615 |
$this->invite->user->email = $this->invite->user->user_email;
|
3616 |
$this->invite->user->user_url = bp_core_get_user_domain( $user_id, $this->invite->user->user_nicename, $this->invite->user->user_login );
|
3617 |
$this->invite->user->user_link = "<a href='{$this->invite->user->user_url}' title='{$this->invite->user->fullname}'>{$this->invite->user->fullname}</a>";
|
3650 |
) );
|
3651 |
|
3652 |
if ( empty( $r['group_id'] ) ) {
|
3653 |
+
if ( groups_get_current_group() ) {
|
3654 |
$r['group_id'] = bp_get_current_group_id();
|
3655 |
+
} elseif ( ! empty( buddypress()->groups->new_group_id ) ) {
|
3656 |
$r['group_id'] = buddypress()->groups->new_group_id;
|
3657 |
}
|
3658 |
}
|
3778 |
$to_num = bp_core_number_format( ( $start_num + ( $invites_template->pag_num - 1 ) > $invites_template->total_invite_count ) ? $invites_template->total_invite_count : $start_num + ( $invites_template->pag_num - 1 ) );
|
3779 |
$total = bp_core_number_format( $invites_template->total_invite_count );
|
3780 |
|
3781 |
+
return apply_filters( 'bp_get_groups_pagination_count', sprintf( _n( 'Viewing 1 invitation', 'Viewing %1$s - %2$s of %3$s invitations', $total, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
|
3782 |
}
|
3783 |
|
3784 |
/***
|
3804 |
echo bp_get_group_activity_feed_link();
|
3805 |
}
|
3806 |
function bp_get_group_activity_feed_link() {
|
3807 |
+
return apply_filters( 'bp_get_group_activity_feed_link', bp_get_group_permalink( groups_get_current_group() ) . 'feed/' );
|
|
|
|
|
3808 |
}
|
3809 |
|
3810 |
/**
|
3826 |
* @return int $current_group_id The id of the current group, if there is one
|
3827 |
*/
|
3828 |
function bp_get_current_group_id() {
|
3829 |
+
$current_group = groups_get_current_group();
|
|
|
3830 |
$current_group_id = isset( $current_group->id ) ? (int) $current_group->id : 0;
|
3831 |
|
3832 |
return apply_filters( 'bp_get_current_group_id', $current_group_id, $current_group );
|
3851 |
* @return string $current_group_slug The slug of the current group, if there is one
|
3852 |
*/
|
3853 |
function bp_get_current_group_slug() {
|
3854 |
+
$current_group = groups_get_current_group();
|
|
|
3855 |
$current_group_slug = isset( $current_group->slug ) ? $current_group->slug : '';
|
3856 |
|
3857 |
return apply_filters( 'bp_get_current_group_slug', $current_group_slug, $current_group );
|
3875 |
* @return string The name of the current group, if there is one
|
3876 |
*/
|
3877 |
function bp_get_current_group_name() {
|
3878 |
+
$current_group = groups_get_current_group();
|
3879 |
+
$current_group_name = isset( $current_group->name ) ? $current_group->name : '';
|
3880 |
+
$name = apply_filters( 'bp_get_group_name', $current_group_name );
|
3881 |
+
|
3882 |
+
return apply_filters( 'bp_get_current_group_name', $name, $current_group );
|
3883 |
+
}
|
3884 |
+
|
3885 |
+
/**
|
3886 |
+
* Echoes the output of bp_get_current_group_description()
|
3887 |
+
*
|
3888 |
+
* @package BuddyPress
|
3889 |
+
* @since BuddyPress (2.1.0)
|
3890 |
+
*/
|
3891 |
+
function bp_current_group_description() {
|
3892 |
+
echo bp_get_current_group_description();
|
3893 |
+
}
|
3894 |
+
/**
|
3895 |
+
* Returns the description of the current group
|
3896 |
+
*
|
3897 |
+
* @package BuddyPress
|
3898 |
+
* @since BuddyPress (2.1.0)
|
3899 |
+
* @uses apply_filters() Filter bp_get_current_group_description to modify
|
3900 |
+
* this output
|
3901 |
+
*
|
3902 |
+
* @return string The description of the current group, if there is one
|
3903 |
+
*/
|
3904 |
+
function bp_get_current_group_description() {
|
3905 |
+
$current_group = groups_get_current_group();
|
3906 |
+
$current_group_desc = isset( $current_group->description ) ? $current_group->description : '';
|
3907 |
+
$desc = apply_filters( 'bp_get_group_description', $current_group_desc );
|
3908 |
|
3909 |
+
return apply_filters( 'bp_get_current_group_description', $desc );
|
|
|
3910 |
}
|
3911 |
|
3912 |
+
/**
|
3913 |
+
* Output a URL for a group component action
|
3914 |
+
*
|
3915 |
+
* @since BuddyPress (1.2)
|
3916 |
+
*
|
3917 |
+
* @param string $action
|
3918 |
+
* @param string $query_args
|
3919 |
+
* @param bool $nonce
|
3920 |
+
* @return string
|
3921 |
+
*/
|
3922 |
function bp_groups_action_link( $action = '', $query_args = '', $nonce = false ) {
|
3923 |
echo bp_get_groups_action_link( $action, $query_args, $nonce );
|
3924 |
}
|
3925 |
+
/**
|
3926 |
+
* Get a URL for a group component action
|
3927 |
+
*
|
3928 |
+
* @since BuddyPress (1.2)
|
3929 |
+
*
|
3930 |
+
* @param string $action
|
3931 |
+
* @param string $query_args
|
3932 |
+
* @param bool $nonce
|
3933 |
+
* @return string
|
3934 |
+
*/
|
3935 |
function bp_get_groups_action_link( $action = '', $query_args = '', $nonce = false ) {
|
3936 |
+
|
3937 |
+
$current_group = groups_get_current_group();
|
3938 |
+
$url = '';
|
3939 |
|
3940 |
// Must be a group
|
3941 |
+
if ( ! empty( $current_group->id ) ) {
|
|
|
3942 |
|
3943 |
+
// Append $action to $url if provided
|
3944 |
+
if ( !empty( $action ) ) {
|
3945 |
+
$url = bp_get_group_permalink( $current_group ) . $action;
|
3946 |
+
} else {
|
3947 |
+
$url = bp_get_group_permalink( $current_group );
|
3948 |
+
}
|
3949 |
|
3950 |
+
// Add a slash at the end of our user url
|
3951 |
+
$url = trailingslashit( $url );
|
3952 |
|
3953 |
+
// Add possible query args
|
3954 |
+
if ( !empty( $query_args ) && is_array( $query_args ) ) {
|
3955 |
+
$url = add_query_arg( $query_args, $url );
|
3956 |
+
}
|
3957 |
|
3958 |
+
// To nonce, or not to nonce...
|
3959 |
+
if ( true === $nonce ) {
|
3960 |
+
$url = wp_nonce_url( $url );
|
3961 |
+
} elseif ( is_string( $nonce ) ) {
|
3962 |
+
$url = wp_nonce_url( $url, $nonce );
|
3963 |
+
}
|
3964 |
+
}
|
3965 |
|
3966 |
+
// Return the url
|
3967 |
+
return apply_filters( 'bp_get_groups_action_link', $url, $action, $query_args, $nonce );
|
|
|
3968 |
}
|
3969 |
|
3970 |
/** Stats **********************************************************************/
|
@@ -58,9 +58,18 @@ class BP_Groups_Widget extends WP_Widget {
|
|
58 |
|
59 |
$title = !empty( $instance['link_title'] ) ? '<a href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() ) . '">' . $title . '</a>' : $title;
|
60 |
|
61 |
-
echo $before_title . $title . $after_title;
|
62 |
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
<div class="item-options" id="groups-list-options">
|
65 |
<a href="<?php bp_groups_directory_permalink(); ?>" id="newest-groups"<?php if ( $instance['group_default'] == 'newest' ) : ?> class="selected"<?php endif; ?>><?php _e("Newest", 'buddypress') ?></a> |
|
66 |
<a href="<?php bp_groups_directory_permalink(); ?>" id="recently-active-groups"<?php if ( $instance['group_default'] == 'active' ) : ?> class="selected"<?php endif; ?>><?php _e("Active", 'buddypress') ?></a> |
|
58 |
|
59 |
$title = !empty( $instance['link_title'] ) ? '<a href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() ) . '">' . $title . '</a>' : $title;
|
60 |
|
61 |
+
echo $before_title . $title . $after_title;
|
62 |
|
63 |
+
$group_args = array(
|
64 |
+
'user_id' => $user_id,
|
65 |
+
'type' => $instance['group_default'],
|
66 |
+
'per_page' => $instance['max_groups'],
|
67 |
+
'max' => $instance['max_groups'],
|
68 |
+
);
|
69 |
+
|
70 |
+
?>
|
71 |
+
|
72 |
+
<?php if ( bp_has_groups( $group_args ) ) : ?>
|
73 |
<div class="item-options" id="groups-list-options">
|
74 |
<a href="<?php bp_groups_directory_permalink(); ?>" id="newest-groups"<?php if ( $instance['group_default'] == 'newest' ) : ?> class="selected"<?php endif; ?>><?php _e("Newest", 'buddypress') ?></a> |
|
75 |
<a href="<?php bp_groups_directory_permalink(); ?>" id="recently-active-groups"<?php if ( $instance['group_default'] == 'active' ) : ?> class="selected"<?php endif; ?>><?php _e("Active", 'buddypress') ?></a> |
|
@@ -1,17 +1,17 @@
|
|
1 |
jQuery(document).ready( function() {
|
2 |
-
jQuery(
|
3 |
function() {
|
4 |
var link = this;
|
5 |
jQuery(link).addClass('loading');
|
6 |
|
7 |
-
jQuery(
|
8 |
jQuery(this).addClass('selected');
|
9 |
|
10 |
jQuery.post( ajaxurl, {
|
11 |
action: 'widget_groups_list',
|
12 |
'cookie': encodeURIComponent(document.cookie),
|
13 |
-
'_wpnonce': jQuery(
|
14 |
-
'max_groups': jQuery(
|
15 |
'filter': jQuery(this).attr('id')
|
16 |
},
|
17 |
function(response)
|
@@ -29,20 +29,20 @@ function groups_wiget_response(response) {
|
|
29 |
response = response.substr(0, response.length-1);
|
30 |
response = response.split('[[SPLIT]]');
|
31 |
|
32 |
-
if ( response[0]
|
33 |
-
jQuery(
|
34 |
function() {
|
35 |
-
jQuery(
|
36 |
-
jQuery(
|
37 |
}
|
38 |
);
|
39 |
|
40 |
} else {
|
41 |
-
jQuery(
|
42 |
function() {
|
43 |
var message = '<p>' + response[1] + '</p>';
|
44 |
-
jQuery(
|
45 |
-
jQuery(
|
46 |
}
|
47 |
);
|
48 |
}
|
1 |
jQuery(document).ready( function() {
|
2 |
+
jQuery('.widget div#groups-list-options a').on('click',
|
3 |
function() {
|
4 |
var link = this;
|
5 |
jQuery(link).addClass('loading');
|
6 |
|
7 |
+
jQuery('.widget div#groups-list-options a').removeClass('selected');
|
8 |
jQuery(this).addClass('selected');
|
9 |
|
10 |
jQuery.post( ajaxurl, {
|
11 |
action: 'widget_groups_list',
|
12 |
'cookie': encodeURIComponent(document.cookie),
|
13 |
+
'_wpnonce': jQuery('input#_wpnonce-groups').val(),
|
14 |
+
'max_groups': jQuery('input#groups_widget_max').val(),
|
15 |
'filter': jQuery(this).attr('id')
|
16 |
},
|
17 |
function(response)
|
29 |
response = response.substr(0, response.length-1);
|
30 |
response = response.split('[[SPLIT]]');
|
31 |
|
32 |
+
if ( response[0] !== '-1' ) {
|
33 |
+
jQuery('.widget ul#groups-list').fadeOut(200,
|
34 |
function() {
|
35 |
+
jQuery('.widget ul#groups-list').html(response[1]);
|
36 |
+
jQuery('.widget ul#groups-list').fadeIn(200);
|
37 |
}
|
38 |
);
|
39 |
|
40 |
} else {
|
41 |
+
jQuery('.widget ul#groups-list').fadeOut(200,
|
42 |
function() {
|
43 |
var message = '<p>' + response[1] + '</p>';
|
44 |
+
jQuery('.widget ul#groups-list').html(message);
|
45 |
+
jQuery('.widget ul#groups-list').fadeIn(200);
|
46 |
}
|
47 |
);
|
48 |
}
|
@@ -1 +1,2 @@
|
|
1 |
-
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
function groups_wiget_response(a){a=a.substr(0,a.length-1),a=a.split("[[SPLIT]]"),"-1"!==a[0]?jQuery(".widget ul#groups-list").fadeOut(200,function(){jQuery(".widget ul#groups-list").html(a[1]),jQuery(".widget ul#groups-list").fadeIn(200)}):jQuery(".widget ul#groups-list").fadeOut(200,function(){var b="<p>"+a[1]+"</p>";jQuery(".widget ul#groups-list").html(b),jQuery(".widget ul#groups-list").fadeIn(200)})}jQuery(document).ready(function(){jQuery(".widget div#groups-list-options a").on("click",function(){var a=this;return jQuery(a).addClass("loading"),jQuery(".widget div#groups-list-options a").removeClass("selected"),jQuery(this).addClass("selected"),jQuery.post(ajaxurl,{action:"widget_groups_list",cookie:encodeURIComponent(document.cookie),_wpnonce:jQuery("input#_wpnonce-groups").val(),max_groups:jQuery("input#groups_widget_max").val(),filter:jQuery(this).attr("id")},function(b){jQuery(a).removeClass("loading"),groups_wiget_response(b)}),!1})});
|
@@ -4,8 +4,6 @@
|
|
4 |
*
|
5 |
* BuddyPress is social networking software with a twist from the creators of WordPress.
|
6 |
*
|
7 |
-
* $Id$
|
8 |
-
*
|
9 |
* @package BuddyPress
|
10 |
* @subpackage Main
|
11 |
*/
|
@@ -16,7 +14,7 @@
|
|
16 |
* Description: Social networking in a box. Build a social network for your company, school, sports team or niche community all based on the power and flexibility of WordPress.
|
17 |
* Author: The BuddyPress Community
|
18 |
* Author URI: http://buddypress.org/community/members/
|
19 |
-
* Version: 2.
|
20 |
* Text Domain: buddypress
|
21 |
* Domain Path: /bp-languages/
|
22 |
* License: GPLv2 or later (license.txt)
|
@@ -37,7 +35,7 @@ if ( !class_exists( 'BuddyPress' ) ) :
|
|
37 |
*/
|
38 |
class BuddyPress {
|
39 |
|
40 |
-
/** Magic
|
41 |
|
42 |
/**
|
43 |
* BuddyPress uses many variables, most of which can be filtered to
|
@@ -52,7 +50,7 @@ class BuddyPress {
|
|
52 |
*/
|
53 |
private $data;
|
54 |
|
55 |
-
/** Not Magic
|
56 |
|
57 |
/**
|
58 |
* @var array Primary BuddyPress navigation.
|
@@ -97,14 +95,14 @@ class BuddyPress {
|
|
97 |
*/
|
98 |
public $active_components = array();
|
99 |
|
100 |
-
/** Option Overload
|
101 |
|
102 |
/**
|
103 |
* @var array Optional Overloads default options retrieved from get_option().
|
104 |
*/
|
105 |
public $options = array();
|
106 |
|
107 |
-
/** Singleton
|
108 |
|
109 |
/**
|
110 |
* Main BuddyPress Instance.
|
@@ -147,7 +145,7 @@ class BuddyPress {
|
|
147 |
return $instance;
|
148 |
}
|
149 |
|
150 |
-
/** Magic Methods
|
151 |
|
152 |
/**
|
153 |
* A dummy constructor to prevent BuddyPress from being loaded more than once.
|
@@ -207,7 +205,7 @@ class BuddyPress {
|
|
207 |
*/
|
208 |
public function __call( $name = '', $args = array() ) { unset( $name, $args ); return null; }
|
209 |
|
210 |
-
/** Private Methods
|
211 |
|
212 |
/**
|
213 |
* Bootstrap constants.
|
@@ -229,17 +227,16 @@ class BuddyPress {
|
|
229 |
|
230 |
// Path and URL
|
231 |
if ( ! defined( 'BP_PLUGIN_DIR' ) ) {
|
232 |
-
define( 'BP_PLUGIN_DIR',
|
233 |
}
|
234 |
|
235 |
if ( ! defined( 'BP_PLUGIN_URL' ) ) {
|
236 |
-
|
237 |
-
|
238 |
-
// If we're using https, update the protocol. Workaround for WP13941, WP15928, WP19037.
|
239 |
-
if ( is_ssl() )
|
240 |
-
$plugin_url = str_replace( 'http://', 'https://', $plugin_url );
|
241 |
|
242 |
-
|
|
|
|
|
243 |
}
|
244 |
|
245 |
// Define on which blog ID BuddyPress should run
|
@@ -262,7 +259,7 @@ class BuddyPress {
|
|
262 |
$plugins = get_site_option( 'active_sitewide_plugins');
|
263 |
|
264 |
// basename
|
265 |
-
$basename =
|
266 |
|
267 |
// plugin is network-activated; use main site ID instead
|
268 |
if ( isset( $plugins[ $basename ] ) ) {
|
@@ -301,23 +298,23 @@ class BuddyPress {
|
|
301 |
*/
|
302 |
private function setup_globals() {
|
303 |
|
304 |
-
/** Versions
|
305 |
|
306 |
-
$this->version = '2.
|
307 |
$this->db_version = 8311;
|
308 |
|
309 |
-
/** Loading
|
310 |
|
311 |
$this->load_deprecated = ! apply_filters( 'bp_ignore_deprecated', BP_IGNORE_DEPRECATED );
|
312 |
|
313 |
-
/** Toolbar
|
314 |
|
315 |
/**
|
316 |
* @var string The primary toolbar ID
|
317 |
*/
|
318 |
$this->my_account_menu_id = '';
|
319 |
|
320 |
-
/** URIs
|
321 |
|
322 |
/**
|
323 |
* @var int The current offset of the URI.
|
@@ -330,7 +327,7 @@ class BuddyPress {
|
|
330 |
*/
|
331 |
$this->no_status_set = false;
|
332 |
|
333 |
-
/** Components
|
334 |
|
335 |
/**
|
336 |
* @var string Name of the current BuddyPress component (primary)
|
@@ -352,18 +349,18 @@ class BuddyPress {
|
|
352 |
*/
|
353 |
$this->is_single_item = false;
|
354 |
|
355 |
-
/** Root
|
356 |
|
357 |
// BuddyPress Root blog ID
|
358 |
$this->root_blog_id = (int) apply_filters( 'bp_get_root_blog_id', BP_ROOT_BLOG );
|
359 |
|
360 |
-
/** Paths
|
361 |
|
362 |
// BuddyPress root directory
|
363 |
-
$this->file =
|
364 |
-
$this->basename =
|
365 |
-
$this->plugin_dir = BP_PLUGIN_DIR;
|
366 |
-
$this->plugin_url = BP_PLUGIN_URL;
|
367 |
|
368 |
// Languages
|
369 |
$this->lang_dir = $this->plugin_dir . 'bp-languages';
|
@@ -376,12 +373,12 @@ class BuddyPress {
|
|
376 |
$this->old_themes_dir = $this->plugin_dir . 'bp-themes';
|
377 |
$this->old_themes_url = $this->plugin_url . 'bp-themes';
|
378 |
|
379 |
-
/** Theme Compat
|
380 |
|
381 |
$this->theme_compat = new stdClass(); // Base theme compatibility class
|
382 |
$this->filters = new stdClass(); // Used when adding/removing filters
|
383 |
|
384 |
-
/** Users
|
385 |
|
386 |
$this->current_user = new stdClass();
|
387 |
$this->displayed_user = new stdClass();
|
@@ -415,12 +412,12 @@ class BuddyPress {
|
|
415 |
private function includes() {
|
416 |
|
417 |
// Load the WP abstraction file so BuddyPress can run on all WordPress setups.
|
418 |
-
require( $this->plugin_dir . '
|
419 |
|
420 |
// Setup the versions (after we include multisite abstraction above)
|
421 |
$this->versions();
|
422 |
|
423 |
-
/** Update/Install
|
424 |
|
425 |
// Theme compatability
|
426 |
require( $this->plugin_dir . 'bp-core/bp-core-template-loader.php' );
|
@@ -453,7 +450,9 @@ class BuddyPress {
|
|
453 |
require( $this->plugin_dir . 'bp-core/deprecated/1.5.php' );
|
454 |
require( $this->plugin_dir . 'bp-core/deprecated/1.6.php' );
|
455 |
require( $this->plugin_dir . 'bp-core/deprecated/1.7.php' );
|
|
|
456 |
require( $this->plugin_dir . 'bp-core/deprecated/2.0.php' );
|
|
|
457 |
}
|
458 |
}
|
459 |
|
@@ -528,7 +527,7 @@ class BuddyPress {
|
|
528 |
}
|
529 |
}
|
530 |
|
531 |
-
/** Public Methods
|
532 |
|
533 |
/**
|
534 |
* Set up BuddyPress's legacy theme directory.
|
4 |
*
|
5 |
* BuddyPress is social networking software with a twist from the creators of WordPress.
|
6 |
*
|
|
|
|
|
7 |
* @package BuddyPress
|
8 |
* @subpackage Main
|
9 |
*/
|
14 |
* Description: Social networking in a box. Build a social network for your company, school, sports team or niche community all based on the power and flexibility of WordPress.
|
15 |
* Author: The BuddyPress Community
|
16 |
* Author URI: http://buddypress.org/community/members/
|
17 |
+
* Version: 2.1-beta1
|
18 |
* Text Domain: buddypress
|
19 |
* Domain Path: /bp-languages/
|
20 |
* License: GPLv2 or later (license.txt)
|
35 |
*/
|
36 |
class BuddyPress {
|
37 |
|
38 |
+
/** Magic *****************************************************************/
|
39 |
|
40 |
/**
|
41 |
* BuddyPress uses many variables, most of which can be filtered to
|
50 |
*/
|
51 |
private $data;
|
52 |
|
53 |
+
/** Not Magic *************************************************************/
|
54 |
|
55 |
/**
|
56 |
* @var array Primary BuddyPress navigation.
|
95 |
*/
|
96 |
public $active_components = array();
|
97 |
|
98 |
+
/** Option Overload *******************************************************/
|
99 |
|
100 |
/**
|
101 |
* @var array Optional Overloads default options retrieved from get_option().
|
102 |
*/
|
103 |
public $options = array();
|
104 |
|
105 |
+
/** Singleton *************************************************************/
|
106 |
|
107 |
/**
|
108 |
* Main BuddyPress Instance.
|
145 |
return $instance;
|
146 |
}
|
147 |
|
148 |
+
/** Magic Methods *********************************************************/
|
149 |
|
150 |
/**
|
151 |
* A dummy constructor to prevent BuddyPress from being loaded more than once.
|
205 |
*/
|
206 |
public function __call( $name = '', $args = array() ) { unset( $name, $args ); return null; }
|
207 |
|
208 |
+
/** Private Methods *******************************************************/
|
209 |
|
210 |
/**
|
211 |
* Bootstrap constants.
|
227 |
|
228 |
// Path and URL
|
229 |
if ( ! defined( 'BP_PLUGIN_DIR' ) ) {
|
230 |
+
define( 'BP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
231 |
}
|
232 |
|
233 |
if ( ! defined( 'BP_PLUGIN_URL' ) ) {
|
234 |
+
define( 'BP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
235 |
+
}
|
|
|
|
|
|
|
236 |
|
237 |
+
// Only applicable to those running trunk
|
238 |
+
if ( ! defined( 'BP_SOURCE_SUBDIRECTORY' ) ) {
|
239 |
+
define( 'BP_SOURCE_SUBDIRECTORY', '' );
|
240 |
}
|
241 |
|
242 |
// Define on which blog ID BuddyPress should run
|
259 |
$plugins = get_site_option( 'active_sitewide_plugins');
|
260 |
|
261 |
// basename
|
262 |
+
$basename = basename( constant( 'BP_PLUGIN_DIR' ) ) . '/bp-loader.php';
|
263 |
|
264 |
// plugin is network-activated; use main site ID instead
|
265 |
if ( isset( $plugins[ $basename ] ) ) {
|
298 |
*/
|
299 |
private function setup_globals() {
|
300 |
|
301 |
+
/** Versions **********************************************************/
|
302 |
|
303 |
+
$this->version = '2.1-beta1';
|
304 |
$this->db_version = 8311;
|
305 |
|
306 |
+
/** Loading ***********************************************************/
|
307 |
|
308 |
$this->load_deprecated = ! apply_filters( 'bp_ignore_deprecated', BP_IGNORE_DEPRECATED );
|
309 |
|
310 |
+
/** Toolbar ***********************************************************/
|
311 |
|
312 |
/**
|
313 |
* @var string The primary toolbar ID
|
314 |
*/
|
315 |
$this->my_account_menu_id = '';
|
316 |
|
317 |
+
/** URIs **************************************************************/
|
318 |
|
319 |
/**
|
320 |
* @var int The current offset of the URI.
|
327 |
*/
|
328 |
$this->no_status_set = false;
|
329 |
|
330 |
+
/** Components ********************************************************/
|
331 |
|
332 |
/**
|
333 |
* @var string Name of the current BuddyPress component (primary)
|
349 |
*/
|
350 |
$this->is_single_item = false;
|
351 |
|
352 |
+
/** Root **************************************************************/
|
353 |
|
354 |
// BuddyPress Root blog ID
|
355 |
$this->root_blog_id = (int) apply_filters( 'bp_get_root_blog_id', BP_ROOT_BLOG );
|
356 |
|
357 |
+
/** Paths**************************************************************/
|
358 |
|
359 |
// BuddyPress root directory
|
360 |
+
$this->file = constant( 'BP_PLUGIN_DIR' ) . 'bp-loader.php';
|
361 |
+
$this->basename = basename( constant( 'BP_PLUGIN_DIR' ) ) . '/bp-loader.php';
|
362 |
+
$this->plugin_dir = trailingslashit( constant( 'BP_PLUGIN_DIR' ) . constant( 'BP_SOURCE_SUBDIRECTORY' ) );
|
363 |
+
$this->plugin_url = trailingslashit( constant( 'BP_PLUGIN_URL' ) . constant( 'BP_SOURCE_SUBDIRECTORY' ) );
|
364 |
|
365 |
// Languages
|
366 |
$this->lang_dir = $this->plugin_dir . 'bp-languages';
|
373 |
$this->old_themes_dir = $this->plugin_dir . 'bp-themes';
|
374 |
$this->old_themes_url = $this->plugin_url . 'bp-themes';
|
375 |
|
376 |
+
/** Theme Compat ******************************************************/
|
377 |
|
378 |
$this->theme_compat = new stdClass(); // Base theme compatibility class
|
379 |
$this->filters = new stdClass(); // Used when adding/removing filters
|
380 |
|
381 |
+
/** Users *************************************************************/
|
382 |
|
383 |
$this->current_user = new stdClass();
|
384 |
$this->displayed_user = new stdClass();
|
412 |
private function includes() {
|
413 |
|
414 |
// Load the WP abstraction file so BuddyPress can run on all WordPress setups.
|
415 |
+
require( $this->plugin_dir . 'bp-core/bp-core-wpabstraction.php' );
|
416 |
|
417 |
// Setup the versions (after we include multisite abstraction above)
|
418 |
$this->versions();
|
419 |
|
420 |
+
/** Update/Install ****************************************************/
|
421 |
|
422 |
// Theme compatability
|
423 |
require( $this->plugin_dir . 'bp-core/bp-core-template-loader.php' );
|
450 |
require( $this->plugin_dir . 'bp-core/deprecated/1.5.php' );
|
451 |
require( $this->plugin_dir . 'bp-core/deprecated/1.6.php' );
|
452 |
require( $this->plugin_dir . 'bp-core/deprecated/1.7.php' );
|
453 |
+
require( $this->plugin_dir . 'bp-core/deprecated/1.9.php' );
|
454 |
require( $this->plugin_dir . 'bp-core/deprecated/2.0.php' );
|
455 |
+
require( $this->plugin_dir . 'bp-core/deprecated/2.1.php' );
|
456 |
}
|
457 |
}
|
458 |
|
527 |
}
|
528 |
}
|
529 |
|
530 |
+
/** Public Methods ********************************************************/
|
531 |
|
532 |
/**
|
533 |
* Set up BuddyPress's legacy theme directory.
|
@@ -54,11 +54,9 @@ class BP_Members_List_Table extends WP_Users_List_Table {
|
|
54 |
public function prepare_items() {
|
55 |
global $usersearch;
|
56 |
|
57 |
-
$usersearch
|
58 |
-
|
59 |
$signups_per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) );
|
60 |
-
|
61 |
-
$paged = $this->get_pagenum();
|
62 |
|
63 |
$args = array(
|
64 |
'offset' => ( $paged - 1 ) * $signups_per_page,
|
@@ -99,7 +97,7 @@ class BP_Members_List_Table extends WP_Users_List_Table {
|
|
99 |
|
100 |
// Remove the 'current' class from the 'All' link
|
101 |
$views['all'] = str_replace( 'class="current"', '', $views['all'] );
|
102 |
-
$views['registered'] = '<a href="'
|
103 |
|
104 |
return $views;
|
105 |
}
|
@@ -124,12 +122,12 @@ class BP_Members_List_Table extends WP_Users_List_Table {
|
|
124 |
public function get_columns() {
|
125 |
return apply_filters( 'bp_members_signup_columns', array(
|
126 |
'cb' => '<input type="checkbox" />',
|
127 |
-
'username' => __( 'Username',
|
128 |
-
'name' => __( 'Name',
|
129 |
-
'email' => __( 'Email',
|
130 |
-
'registered' => __( 'Registered',
|
131 |
-
'date_sent' => __( 'Last Sent',
|
132 |
-
'count_sent' => __( '
|
133 |
) );
|
134 |
}
|
135 |
|
@@ -141,7 +139,7 @@ class BP_Members_List_Table extends WP_Users_List_Table {
|
|
141 |
public function get_bulk_actions() {
|
142 |
$actions = array(
|
143 |
'activate' => _x( 'Activate', 'Pending signup action', 'buddypress' ),
|
144 |
-
'resend' => _x( 'Email',
|
145 |
);
|
146 |
|
147 |
if ( current_user_can( 'delete_users' ) ) {
|
@@ -167,14 +165,14 @@ class BP_Members_List_Table extends WP_Users_List_Table {
|
|
167 |
|
168 |
// Specific case when BuddyPress is not network activated
|
169 |
if ( is_multisite() && current_user_can( 'manage_network_users') ) {
|
170 |
-
$link = '<a href="'
|
171 |
} elseif ( current_user_can( 'manage_options' ) ) {
|
172 |
-
$link = '<a href="'
|
173 |
}
|
174 |
-
|
175 |
printf( __( 'Registration is disabled. %s', 'buddypress' ), $link );
|
176 |
}
|
177 |
-
|
178 |
}
|
179 |
|
180 |
/**
|
@@ -222,8 +220,8 @@ class BP_Members_List_Table extends WP_Users_List_Table {
|
|
222 |
* @since BuddyPress (2.0.0)
|
223 |
*/
|
224 |
public function column_cb( $signup_object = null ) {
|
225 |
-
|
226 |
-
<label class="screen-reader-text" for="signup_<?php echo intval( $signup_object->id ); ?>"><?php
|
227 |
<input type="checkbox" id="signup_<?php echo intval( $signup_object->id ) ?>" name="allsignups[]" value="<?php echo esc_attr( $signup_object->id ) ?>" />
|
228 |
<?php
|
229 |
}
|
@@ -268,19 +266,19 @@ class BP_Members_List_Table extends WP_Users_List_Table {
|
|
268 |
bp_get_admin_url( 'users.php' )
|
269 |
);
|
270 |
|
271 |
-
echo $avatar . '<strong><a href="
|
272 |
|
273 |
$actions = array();
|
274 |
|
275 |
-
$actions['activate'] = '<a href="'
|
276 |
-
|
277 |
-
$actions['resend'] = '<a href="' . esc_url( $email_link ) . '">' . __( 'Email', 'buddypress' ) . '</a>';
|
278 |
|
279 |
if ( current_user_can( 'delete_users' ) ) {
|
280 |
-
$actions['delete'] = '<a href="
|
281 |
}
|
282 |
|
283 |
$actions = apply_filters( 'bp_members_ms_signup_row_actions', $actions, $signup_object );
|
|
|
284 |
echo $this->row_actions( $actions );
|
285 |
}
|
286 |
|
@@ -303,7 +301,7 @@ class BP_Members_List_Table extends WP_Users_List_Table {
|
|
303 |
* @param object $signup_object The signup data object.
|
304 |
*/
|
305 |
public function column_email( $signup_object = null ) {
|
306 |
-
|
307 |
}
|
308 |
|
309 |
/**
|
@@ -336,6 +334,18 @@ class BP_Members_List_Table extends WP_Users_List_Table {
|
|
336 |
public function column_count_sent( $signup_object = null ) {
|
337 |
echo absint( $signup_object->count_sent );
|
338 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
}
|
340 |
|
341 |
endif;
|
@@ -381,13 +391,11 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
|
|
381 |
* @since BuddyPress (2.0.0)
|
382 |
*/
|
383 |
public function prepare_items() {
|
384 |
-
global $usersearch, $
|
385 |
-
|
386 |
-
$usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
|
387 |
|
|
|
388 |
$signups_per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) );
|
389 |
-
|
390 |
-
$paged = $this->get_pagenum();
|
391 |
|
392 |
$args = array(
|
393 |
'offset' => ( $paged - 1 ) * $signups_per_page,
|
@@ -397,17 +405,18 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
|
|
397 |
'order' => 'DESC'
|
398 |
);
|
399 |
|
400 |
-
if ( isset( $_REQUEST['orderby'] ) )
|
401 |
$args['orderby'] = $_REQUEST['orderby'];
|
|
|
402 |
|
403 |
-
if ( isset( $_REQUEST['order'] ) )
|
404 |
$args['order'] = $_REQUEST['order'];
|
|
|
405 |
|
406 |
-
$mode
|
407 |
-
|
408 |
$signups = BP_Signup::get( $args );
|
409 |
|
410 |
-
$this->items
|
411 |
$this->signup_counts = $signups['total'];
|
412 |
|
413 |
$this->set_pagination_args( array(
|
@@ -423,13 +432,12 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
|
|
423 |
*
|
424 |
* @uses WP_MS_Users_List_Table::get_views() to get the users views
|
425 |
*/
|
426 |
-
function get_views() {
|
427 |
$views = parent::get_views();
|
428 |
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
$views['registered'] = '<a href="' . add_query_arg( 'page', 'bp-signups', bp_get_admin_url( 'users.php' ) ) . '" class="current">' . sprintf( _x( 'Pending <span class="count">(%s)</span>', 'signup users', 'buddypress' ), number_format_i18n( $this->signup_counts ) ) . '</a>';
|
433 |
|
434 |
return $views;
|
435 |
}
|
@@ -442,12 +450,12 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
|
|
442 |
public function get_columns() {
|
443 |
return apply_filters( 'bp_members_ms_signup_columns', array(
|
444 |
'cb' => '<input type="checkbox" />',
|
445 |
-
'username' => __( 'Username',
|
446 |
-
'name' => __( 'Name',
|
447 |
-
'email' => __( 'Email',
|
448 |
-
'registered' => __( 'Registered',
|
449 |
-
'date_sent' => __( 'Last Sent',
|
450 |
-
'count_sent' => __( '
|
451 |
) );
|
452 |
}
|
453 |
|
@@ -459,7 +467,7 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
|
|
459 |
public function get_bulk_actions() {
|
460 |
$actions = array(
|
461 |
'activate' => _x( 'Activate', 'Pending signup action', 'buddypress' ),
|
462 |
-
'resend' => _x( 'Email',
|
463 |
);
|
464 |
|
465 |
if ( current_user_can( 'delete_users' ) ) {
|
@@ -483,7 +491,7 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
|
|
483 |
$link = false;
|
484 |
|
485 |
if ( current_user_can( 'manage_network_users' ) ) {
|
486 |
-
$link = '<a href="'
|
487 |
}
|
488 |
|
489 |
printf( __( 'Registration is disabled. %s', 'buddypress' ), $link );
|
@@ -535,8 +543,8 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
|
|
535 |
* @since BuddyPress (2.0.0)
|
536 |
*/
|
537 |
public function column_cb( $signup_object = null ) {
|
538 |
-
|
539 |
-
<label class="screen-reader-text" for="signup_<?php echo intval( $signup_object->id ); ?>"><?php
|
540 |
<input type="checkbox" id="signup_<?php echo intval( $signup_object->id ) ?>" name="allsignups[]" value="<?php echo esc_attr( $signup_object->id ) ?>" />
|
541 |
<?php
|
542 |
}
|
@@ -581,17 +589,19 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
|
|
581 |
bp_get_admin_url( 'users.php' )
|
582 |
);
|
583 |
|
584 |
-
echo $avatar . '<strong><a href="
|
585 |
|
586 |
-
$actions
|
587 |
|
588 |
-
$actions['
|
|
|
589 |
|
590 |
if ( current_user_can( 'delete_users' ) ) {
|
591 |
-
$actions['delete'] = '<a href="
|
592 |
}
|
593 |
|
594 |
$actions = apply_filters( 'bp_members_ms_signup_row_actions', $actions, $signup_object );
|
|
|
595 |
echo $this->row_actions( $actions );
|
596 |
}
|
597 |
|
@@ -614,7 +624,7 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
|
|
614 |
* @param object $signup_object The signup data object.
|
615 |
*/
|
616 |
public function column_email( $signup_object = null ) {
|
617 |
-
|
618 |
}
|
619 |
|
620 |
/**
|
@@ -627,7 +637,7 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
|
|
627 |
public function column_registered( $signup_object = null ) {
|
628 |
global $mode;
|
629 |
|
630 |
-
if ( 'list'
|
631 |
$date = 'Y/m/d';
|
632 |
} else {
|
633 |
$date = 'Y/m/d \<\b\r \/\> g:i:s a';
|
@@ -644,7 +654,7 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
|
|
644 |
public function column_date_sent( $signup_object = null ) {
|
645 |
global $mode;
|
646 |
|
647 |
-
if ( 'list'
|
648 |
$date = 'Y/m/d';
|
649 |
} else {
|
650 |
$date = 'Y/m/d \<\b\r \/\> g:i:s a';
|
@@ -661,6 +671,18 @@ class BP_Members_MS_List_Table extends WP_MS_Users_List_Table {
|
|
661 |
public function column_count_sent( $signup_object = null ) {
|
662 |
echo absint( $signup_object->count_sent );
|
663 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
664 |
}
|
665 |
|
666 |
endif;
|
54 |
public function prepare_items() {
|
55 |
global $usersearch;
|
56 |
|
57 |
+
$usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
|
|
|
58 |
$signups_per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) );
|
59 |
+
$paged = $this->get_pagenum();
|
|
|
60 |
|
61 |
$args = array(
|
62 |
'offset' => ( $paged - 1 ) * $signups_per_page,
|
97 |
|
98 |
// Remove the 'current' class from the 'All' link
|
99 |
$views['all'] = str_replace( 'class="current"', '', $views['all'] );
|
100 |
+
$views['registered'] = sprintf( '<a href="%1$s" class="current">%2$s</a>', add_query_arg( 'page', 'bp-signups', bp_get_admin_url( 'users.php' ) ), sprintf( _x( 'Pending %s', 'signup users', 'buddypress' ), '<span class="count">(' . number_format_i18n( $this->signup_counts ) . ')</span>' ) );
|
101 |
|
102 |
return $views;
|
103 |
}
|
122 |
public function get_columns() {
|
123 |
return apply_filters( 'bp_members_signup_columns', array(
|
124 |
'cb' => '<input type="checkbox" />',
|
125 |
+
'username' => __( 'Username', 'buddypress' ),
|
126 |
+
'name' => __( 'Name', 'buddypress' ),
|
127 |
+
'email' => __( 'Email', 'buddypress' ),
|
128 |
+
'registered' => __( 'Registered', 'buddypress' ),
|
129 |
+
'date_sent' => __( 'Last Sent', 'buddypress' ),
|
130 |
+
'count_sent' => __( 'Emails Sent', 'buddypress' )
|
131 |
) );
|
132 |
}
|
133 |
|
139 |
public function get_bulk_actions() {
|
140 |
$actions = array(
|
141 |
'activate' => _x( 'Activate', 'Pending signup action', 'buddypress' ),
|
142 |
+
'resend' => _x( 'Email', 'Pending signup action', 'buddypress' ),
|
143 |
);
|
144 |
|
145 |
if ( current_user_can( 'delete_users' ) ) {
|
165 |
|
166 |
// Specific case when BuddyPress is not network activated
|
167 |
if ( is_multisite() && current_user_can( 'manage_network_users') ) {
|
168 |
+
$link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( network_admin_url( 'settings.php' ) ), esc_html__( 'Edit settings', 'buddypress' ) );
|
169 |
} elseif ( current_user_can( 'manage_options' ) ) {
|
170 |
+
$link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( bp_get_admin_url( 'options-general.php' ) ), esc_html__( 'Edit settings', 'buddypress' ) );
|
171 |
}
|
172 |
+
|
173 |
printf( __( 'Registration is disabled. %s', 'buddypress' ), $link );
|
174 |
}
|
175 |
+
|
176 |
}
|
177 |
|
178 |
/**
|
220 |
* @since BuddyPress (2.0.0)
|
221 |
*/
|
222 |
public function column_cb( $signup_object = null ) {
|
223 |
+
?>
|
224 |
+
<label class="screen-reader-text" for="signup_<?php echo intval( $signup_object->id ); ?>"><?php printf( esc_html__( 'Select %s', 'buddypress' ), $signup_object->user_login ); ?></label>
|
225 |
<input type="checkbox" id="signup_<?php echo intval( $signup_object->id ) ?>" name="allsignups[]" value="<?php echo esc_attr( $signup_object->id ) ?>" />
|
226 |
<?php
|
227 |
}
|
266 |
bp_get_admin_url( 'users.php' )
|
267 |
);
|
268 |
|
269 |
+
echo $avatar . sprintf( '<strong><a href="%1$s" class="edit" title="%2$s">%3$s</a></strong><br/>', esc_url( $activate_link ), esc_attr__( 'Activate', 'buddypress' ), $signup_object->user_login );
|
270 |
|
271 |
$actions = array();
|
272 |
|
273 |
+
$actions['activate'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $activate_link ), __( 'Activate', 'buddypress' ) );
|
274 |
+
$actions['resend'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $email_link ), __( 'Email', 'buddypress' ) );
|
|
|
275 |
|
276 |
if ( current_user_can( 'delete_users' ) ) {
|
277 |
+
$actions['delete'] = sprintf( '<a href="%1$s" class="delete">%2$s</a>', esc_url( $delete_link ), __( 'Delete', 'buddypress' ) );
|
278 |
}
|
279 |
|
280 |
$actions = apply_filters( 'bp_members_ms_signup_row_actions', $actions, $signup_object );
|
281 |
+
|
282 |
echo $this->row_actions( $actions );
|
283 |
}
|
284 |
|
301 |
* @param object $signup_object The signup data object.
|
302 |
*/
|
303 |
public function column_email( $signup_object = null ) {
|
304 |
+
printf( '<a href="mailto:%1$s">%2$s</a>', esc_attr( $signup_object->user_email ), esc_html( $signup_object->user_email ) );
|
305 |
}
|
306 |
|
307 |
/**
|
334 |
public function column_count_sent( $signup_object = null ) {
|
335 |
echo absint( $signup_object->count_sent );
|
336 |
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Allow plugins to add their costum column.
|
340 |
+
*
|
341 |
+
* @since BuddyPress 2.1.0
|
342 |
+
*
|
343 |
+
* @param object $signup_object The signup data object.
|
344 |
+
* @param string the column name.
|
345 |
+
*/
|
346 |
+
function column_default( $signup_object = null, $column_name = '' ) {
|
347 |
+
return apply_filters( 'bp_members_signup_custom_column', '', $column_name, $signup_object );
|
348 |
+
}
|
349 |
}
|
350 |
|
351 |
endif;
|
391 |
* @since BuddyPress (2.0.0)
|
392 |
*/
|
393 |
public function prepare_items() {
|
394 |
+
global $usersearch, $mode;
|
|
|
|
|
395 |
|
396 |
+
$usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
|
397 |
$signups_per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) );
|
398 |
+
$paged = $this->get_pagenum();
|
|
|
399 |
|
400 |
$args = array(
|
401 |
'offset' => ( $paged - 1 ) * $signups_per_page,
|
405 |
'order' => 'DESC'
|
406 |
);
|
407 |
|
408 |
+
if ( isset( $_REQUEST['orderby'] ) ) {
|
409 |
$args['orderby'] = $_REQUEST['orderby'];
|
410 |
+
}
|
411 |
|
412 |
+
if ( isset( $_REQUEST['order'] ) ) {
|
413 |
$args['order'] = $_REQUEST['order'];
|
414 |
+
}
|
415 |
|
416 |
+
$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
|
|
|
417 |
$signups = BP_Signup::get( $args );
|
418 |
|
419 |
+
$this->items = $signups['signups'];
|
420 |
$this->signup_counts = $signups['total'];
|
421 |
|
422 |
$this->set_pagination_args( array(
|
432 |
*
|
433 |
* @uses WP_MS_Users_List_Table::get_views() to get the users views
|
434 |
*/
|
435 |
+
public function get_views() {
|
436 |
$views = parent::get_views();
|
437 |
|
438 |
+
// Remove the 'current' class from the 'All' link
|
439 |
+
$views['all'] = str_replace( 'class="current"', '', $views['all'] );
|
440 |
+
$views['registered'] = sprintf( '<a href="%1$s" class="current">%2$s</a>', add_query_arg( 'page', 'bp-signups', bp_get_admin_url( 'users.php' ) ), sprintf( _x( 'Pending %s', 'signup users', 'buddypress' ), '<span class="count">(' . number_format_i18n( $this->signup_counts ) . ')</span>' ) );
|
|
|
441 |
|
442 |
return $views;
|
443 |
}
|
450 |
public function get_columns() {
|
451 |
return apply_filters( 'bp_members_ms_signup_columns', array(
|
452 |
'cb' => '<input type="checkbox" />',
|
453 |
+
'username' => __( 'Username', 'buddypress' ),
|
454 |
+
'name' => __( 'Name', 'buddypress' ),
|
455 |
+
'email' => __( 'Email', 'buddypress' ),
|
456 |
+
'registered' => __( 'Registered', 'buddypress' ),
|
457 |
+
'date_sent' => __( 'Last Sent', 'buddypress' ),
|
458 |
+
'count_sent' => __( 'Emails Sent', 'buddypress' )
|
459 |
) );
|
460 |
}
|
461 |
|
467 |
public function get_bulk_actions() {
|
468 |
$actions = array(
|
469 |
'activate' => _x( 'Activate', 'Pending signup action', 'buddypress' ),
|
470 |
+
'resend' => _x( 'Email', 'Pending signup action', 'buddypress' ),
|
471 |
);
|
472 |
|
473 |
if ( current_user_can( 'delete_users' ) ) {
|
491 |
$link = false;
|
492 |
|
493 |
if ( current_user_can( 'manage_network_users' ) ) {
|
494 |
+
$link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( network_admin_url( 'settings.php' ) ), esc_html__( 'Edit settings', 'buddypress' ) );
|
495 |
}
|
496 |
|
497 |
printf( __( 'Registration is disabled. %s', 'buddypress' ), $link );
|
543 |
* @since BuddyPress (2.0.0)
|
544 |
*/
|
545 |
public function column_cb( $signup_object = null ) {
|
546 |
+
?>
|
547 |
+
<label class="screen-reader-text" for="signup_<?php echo intval( $signup_object->id ); ?>"><?php printf( esc_html__( 'Select %s', 'buddypress' ), $signup_object->user_login ); ?></label>
|
548 |
<input type="checkbox" id="signup_<?php echo intval( $signup_object->id ) ?>" name="allsignups[]" value="<?php echo esc_attr( $signup_object->id ) ?>" />
|
549 |
<?php
|
550 |
}
|
589 |
bp_get_admin_url( 'users.php' )
|
590 |
);
|
591 |
|
592 |
+
echo $avatar . sprintf( '<strong><a href="%1$s" class="edit" title="%2$s">%3$s</a></strong><br/>', esc_url( $activate_link ), esc_attr__( 'Activate', 'buddypress' ), $signup_object->user_login );
|
593 |
|
594 |
+
$actions = array();
|
595 |
|
596 |
+
$actions['activate'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $activate_link ), __( 'Activate', 'buddypress' ) );
|
597 |
+
$actions['resend'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $email_link ), __( 'Email', 'buddypress' ) );
|
598 |
|
599 |
if ( current_user_can( 'delete_users' ) ) {
|
600 |
+
$actions['delete'] = sprintf( '<a href="%1$s" class="delete">%2$s</a>', esc_url( $delete_link ), __( 'Delete', 'buddypress' ) );
|
601 |
}
|
602 |
|
603 |
$actions = apply_filters( 'bp_members_ms_signup_row_actions', $actions, $signup_object );
|
604 |
+
|
605 |
echo $this->row_actions( $actions );
|
606 |
}
|
607 |
|
624 |
* @param object $signup_object The signup data object.
|
625 |
*/
|
626 |
public function column_email( $signup_object = null ) {
|
627 |
+
printf( '<a href="mailto:%1$s">%2$s</a>', esc_attr( $signup_object->user_email ), esc_html( $signup_object->user_email ) );
|
628 |
}
|
629 |
|
630 |
/**
|
637 |
public function column_registered( $signup_object = null ) {
|
638 |
global $mode;
|
639 |
|
640 |
+
if ( 'list' === $mode ) {
|
641 |
$date = 'Y/m/d';
|
642 |
} else {
|
643 |
$date = 'Y/m/d \<\b\r \/\> g:i:s a';
|
654 |
public function column_date_sent( $signup_object = null ) {
|
655 |
global $mode;
|
656 |
|
657 |
+
if ( 'list' === $mode ) {
|
658 |
$date = 'Y/m/d';
|
659 |
} else {
|
660 |
$date = 'Y/m/d \<\b\r \/\> g:i:s a';
|
671 |
public function column_count_sent( $signup_object = null ) {
|
672 |
echo absint( $signup_object->count_sent );
|
673 |
}
|
674 |
+
|
675 |
+
/**
|
676 |
+
* Allow plugins to add their costum column.
|
677 |
+
*
|
678 |
+
* @since BuddyPress 2.1.0
|
679 |
+
*
|
680 |
+
* @param object $signup_object The signup data object.
|
681 |
+
* @param string the column name.
|
682 |
+
*/
|
683 |
+
function column_default( $signup_object = null, $column_name = '' ) {
|
684 |
+
return apply_filters( 'bp_members_ms_signup_custom_column', '', $column_name, $signup_object );
|
685 |
+
}
|
686 |
}
|
687 |
|
688 |
endif;
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**** BP Members Profile Administration Screens ****/
|
2 |
+
|
3 |
+
div#profile-page.wrap form#your-profile {
|
4 |
+
position:relative;
|
5 |
+
}
|
6 |
+
|
7 |
+
div#profile-page.wrap form#your-profile h3:first-of-type {
|
8 |
+
margin-top:5em;
|
9 |
+
}
|
10 |
+
|
11 |
+
div#profile-page.wrap form#your-profile #profile-nav {
|
12 |
+
position: absolute;
|
13 |
+
top: -3.65em;
|
14 |
+
width: 97%;
|
15 |
+
}
|
16 |
+
|
17 |
+
div#community-profile-page #profile-nav {
|
18 |
+
margin-bottom: 1em;
|
19 |
+
}
|
20 |
+
|
21 |
+
#bp_members_admin_user_stats ul {
|
22 |
+
margin-bottom: 0;
|
23 |
+
}
|
24 |
+
div#community-profile-page li.bp-members-profile-stats:before,
|
25 |
+
div#community-profile-page li.bp-friends-profile-stats:before,
|
26 |
+
div#community-profile-page li.bp-groups-profile-stats:before,
|
27 |
+
div#community-profile-page li.bp-blogs-profile-stats:before,
|
28 |
+
div#community-profile-page a.bp-xprofile-avatar-user-admin:before {
|
29 |
+
font: normal 20px/1 'dashicons';
|
30 |
+
speak: none;
|
31 |
+
display: inline-block;
|
32 |
+
padding: 0 0 0 2px;
|
33 |
+
top: 0;
|
34 |
+
right: -1px;
|
35 |
+
position: relative;
|
36 |
+
vertical-align: top;
|
37 |
+
-webkit-font-smoothing: antialiased;
|
38 |
+
-moz-osx-font-smoothing: grayscale;
|
39 |
+
text-decoration: none !important;
|
40 |
+
color: #888;
|
41 |
+
}
|
42 |
+
|
43 |
+
div#community-profile-page li.bp-members-profile-stats:before {
|
44 |
+
content: "\f130";
|
45 |
+
}
|
46 |
+
|
47 |
+
div#community-profile-page li.bp-friends-profile-stats:before {
|
48 |
+
content: "\f454";
|
49 |
+
}
|
50 |
+
|
51 |
+
div#community-profile-page li.bp-groups-profile-stats:before {
|
52 |
+
content: "\f456";
|
53 |
+
}
|
54 |
+
|
55 |
+
div#community-profile-page li.bp-blogs-profile-stats:before {
|
56 |
+
content: "\f120";
|
57 |
+
}
|
58 |
+
|
59 |
+
div#community-profile-page a.bp-xprofile-avatar-user-admin:before {
|
60 |
+
content:"\f182";
|
61 |
+
}
|
62 |
+
|
63 |
+
div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar {
|
64 |
+
width:150px;
|
65 |
+
margin:0 auto;
|
66 |
+
}
|
67 |
+
|
68 |
+
div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar img {
|
69 |
+
max-width: 100%;
|
70 |
+
height: auto;
|
71 |
+
}
|
72 |
+
|
73 |
+
div#community-profile-page div#bp_xprofile_user_admin_avatar a {
|
74 |
+
display:block;
|
75 |
+
margin:1em 0;
|
76 |
+
text-decoration:none;
|
77 |
+
color:#888;
|
78 |
+
}
|
79 |
+
|
80 |
+
div#community-profile-page p.not-activated {
|
81 |
+
margin:1em 1em 0;
|
82 |
+
color:red;
|
83 |
+
}
|
84 |
+
|
85 |
+
#community-profile-page #submitdiv #publishing-action {
|
86 |
+
float: none;
|
87 |
+
width: 100%;
|
88 |
+
}
|
89 |
+
|
90 |
+
.bp-view-profile {
|
91 |
+
float: right;
|
92 |
+
}
|
93 |
+
|
94 |
+
.alt {
|
95 |
+
background: none;
|
96 |
+
}
|
97 |
+
.bp-profile-field {
|
98 |
+
border-bottom: dotted 1px #ccc;
|
99 |
+
font-size: 14px;
|
100 |
+
margin: 15px 0;
|
101 |
+
padding: 10px;
|
102 |
+
}
|
103 |
+
.bp-profile-field:last-child {
|
104 |
+
border-bottom: 0;
|
105 |
+
}
|
106 |
+
.bp-profile-field p {
|
107 |
+
font-size: 14px;
|
108 |
+
}
|
109 |
+
.bp-profile-field .datebox > label,
|
110 |
+
.bp-profile-field .radio > label,
|
111 |
+
.bp-profile-field > label { /* label takes on left side 200px */
|
112 |
+
display: inline-block;
|
113 |
+
font-weight: 600;
|
114 |
+
text-align: right;
|
115 |
+
vertical-align: middle;
|
116 |
+
width: 200px;
|
117 |
+
}
|
118 |
+
|
119 |
+
.field_type_textarea > label,
|
120 |
+
.field_type_multiselectbox > label,
|
121 |
+
.field_type_radio .radio > label,
|
122 |
+
.field_type_checkbox .checkbox > label { /* these fields are usually pretty tall, so align the label for better consistency */
|
123 |
+
vertical-align: top;
|
124 |
+
}
|
125 |
+
.bp-profile-field .description { /* description also sits in the right side column */
|
126 |
+
margin: 10px 200px 10px 0;
|
127 |
+
text-align: right;
|
128 |
+
}
|
129 |
+
.clear-value { /* 'clear value' option also sits in the right side column */
|
130 |
+
display: block;
|
131 |
+
font-size: 12px;
|
132 |
+
margin-right: 200px;
|
133 |
+
}
|
134 |
+
.field_type_checkbox .checkbox > label + label { /* force checkboxes to new lines, in the right side column */
|
135 |
+
display: block;
|
136 |
+
margin-right: 200px;
|
137 |
+
width: auto;
|
138 |
+
}
|
139 |
+
.field_type_radio .radio div:not(.field-visibility-settings) label { /* force radio buttons to new lines */
|
140 |
+
display: block;
|
141 |
+
}
|
142 |
+
.field_type_radio .radio div:not(.field-visibility-settings) { /* make the radio buttons sit in the right side column */
|
143 |
+
display: inline-block;
|
144 |
+
}
|
145 |
+
.field-visibility-settings-notoggle,
|
146 |
+
.field-visibility-settings-toggle { /* visibility settings go in the left column */
|
147 |
+
margin: 10px 200px 10px 0;
|
148 |
+
text-align: right;
|
149 |
+
}
|
150 |
+
.field-visibility-settings { /* visibility settings go in the left column */
|
151 |
+
display: none;
|
152 |
+
margin-right: 200px;
|
153 |
+
}
|
154 |
+
.field-visibility-settings .button { /* visibility setting close button */
|
155 |
+
margin-bottom: 15px;
|
156 |
+
}
|
157 |
+
#normal-sortables .field-visibility-settings legend { /* id required for css selector weight */
|
158 |
+
font-size: 16px;
|
159 |
+
margin-bottom: 10px;
|
160 |
+
}
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
div#profile-page.wrap form#your-profile{position:relative}div#profile-page.wrap form#your-profile h3:first-of-type{margin-top:5em}div#profile-page.wrap form#your-profile #profile-nav{position:absolute;top:-3.65em;width:97%}div#community-profile-page #profile-nav{margin-bottom:1em}#bp_members_admin_user_stats ul{margin-bottom:0}div#community-profile-page a.bp-xprofile-avatar-user-admin:before,div#community-profile-page li.bp-blogs-profile-stats:before,div#community-profile-page li.bp-friends-profile-stats:before,div#community-profile-page li.bp-groups-profile-stats:before,div#community-profile-page li.bp-members-profile-stats:before{font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0 0 0 2px;top:0;right:-1px;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#888}div#community-profile-page li.bp-members-profile-stats:before{content:"\f130"}div#community-profile-page li.bp-friends-profile-stats:before{content:"\f454"}div#community-profile-page li.bp-groups-profile-stats:before{content:"\f456"}div#community-profile-page li.bp-blogs-profile-stats:before{content:"\f120"}div#community-profile-page a.bp-xprofile-avatar-user-admin:before{content:"\f182"}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar{width:150px;margin:0 auto}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar img{max-width:100%;height:auto}div#community-profile-page div#bp_xprofile_user_admin_avatar a{display:block;margin:1em 0;text-decoration:none;color:#888}div#community-profile-page p.not-activated{margin:1em 1em 0;color:red}#community-profile-page #submitdiv #publishing-action{float:none;width:100%}.bp-view-profile{float:right}.alt{background:0 0}.bp-profile-field{border-bottom:dotted 1px #ccc;font-size:14px;margin:15px 0;padding:10px}.bp-profile-field:last-child{border-bottom:0}.bp-profile-field p{font-size:14px}.bp-profile-field .datebox>label,.bp-profile-field .radio>label,.bp-profile-field>label{display:inline-block;font-weight:600;text-align:right;vertical-align:middle;width:200px}.field_type_checkbox .checkbox>label,.field_type_multiselectbox>label,.field_type_radio .radio>label,.field_type_textarea>label{vertical-align:top}.bp-profile-field .description{margin:10px 200px 10px 0;text-align:right}.clear-value{display:block;font-size:12px;margin-right:200px}.field_type_checkbox .checkbox>label+label{display:block;margin-right:200px;width:auto}.field_type_radio .radio div:not(.field-visibility-settings) label{display:block}.field_type_radio .radio div:not(.field-visibility-settings){display:inline-block}.field-visibility-settings-notoggle,.field-visibility-settings-toggle{margin:10px 200px 10px 0;text-align:right}.field-visibility-settings{display:none;margin-right:200px}.field-visibility-settings .button{margin-bottom:15px}#normal-sortables .field-visibility-settings legend{font-size:16px;margin-bottom:10px}
|
@@ -5,58 +5,39 @@ div#profile-page.wrap form#your-profile {
|
|
5 |
}
|
6 |
|
7 |
div#profile-page.wrap form#your-profile h3:first-of-type {
|
8 |
-
margin-top:
|
9 |
}
|
10 |
|
11 |
-
div#profile-page.wrap form#your-profile
|
12 |
-
position:absolute;
|
13 |
-
top
|
14 |
-
|
15 |
-
width:100%;
|
16 |
}
|
17 |
|
18 |
-
div#community-profile-page
|
19 |
-
|
20 |
-
width:100%;
|
21 |
-
margin-top:1em;
|
22 |
-
margin-bottom:1em;
|
23 |
-
padding:1em 0;
|
24 |
-
padding-bottom: 0;
|
25 |
-
height:2.4em;
|
26 |
}
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
margin-left:0.4em;
|
31 |
-
float:left;
|
32 |
-
font-weight: bold;
|
33 |
-
font-size: 15px;
|
34 |
-
line-height: 24px;
|
35 |
}
|
36 |
-
|
37 |
-
form#your-profile ul#profile-nav li a,
|
38 |
-
div#community-profile-page ul#profile-nav li a {
|
39 |
-
text-decoration: none;
|
40 |
-
color:#888;
|
41 |
-
}
|
42 |
-
|
43 |
-
form#your-profile ul#profile-nav li a:hover,
|
44 |
-
form#your-profile ul#profile-nav li.nav-tab-active a,
|
45 |
-
div#community-profile-page ul#profile-nav li a:hover,
|
46 |
-
div#community-profile-page ul#profile-nav li.nav-tab-active a {
|
47 |
-
text-decoration: none;
|
48 |
-
color:#000;
|
49 |
-
}
|
50 |
-
|
51 |
div#community-profile-page li.bp-members-profile-stats:before,
|
52 |
div#community-profile-page li.bp-friends-profile-stats:before,
|
53 |
div#community-profile-page li.bp-groups-profile-stats:before,
|
54 |
div#community-profile-page li.bp-blogs-profile-stats:before,
|
55 |
div#community-profile-page a.bp-xprofile-avatar-user-admin:before {
|
56 |
-
font
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
}
|
61 |
|
62 |
div#community-profile-page li.bp-members-profile-stats:before {
|
5 |
}
|
6 |
|
7 |
div#profile-page.wrap form#your-profile h3:first-of-type {
|
8 |
+
margin-top:5em;
|
9 |
}
|
10 |
|
11 |
+
div#profile-page.wrap form#your-profile #profile-nav {
|
12 |
+
position: absolute;
|
13 |
+
top: -3.65em;
|
14 |
+
width: 97%;
|
|
|
15 |
}
|
16 |
|
17 |
+
div#community-profile-page #profile-nav {
|
18 |
+
margin-bottom: 1em;
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
|
21 |
+
#bp_members_admin_user_stats ul {
|
22 |
+
margin-bottom: 0;
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
div#community-profile-page li.bp-members-profile-stats:before,
|
25 |
div#community-profile-page li.bp-friends-profile-stats:before,
|
26 |
div#community-profile-page li.bp-groups-profile-stats:before,
|
27 |
div#community-profile-page li.bp-blogs-profile-stats:before,
|
28 |
div#community-profile-page a.bp-xprofile-avatar-user-admin:before {
|
29 |
+
font: normal 20px/1 'dashicons';
|
30 |
+
speak: none;
|
31 |
+
display: inline-block;
|
32 |
+
padding: 0 2px 0 0;
|
33 |
+
top: 0;
|
34 |
+
left: -1px;
|
35 |
+
position: relative;
|
36 |
+
vertical-align: top;
|
37 |
+
-webkit-font-smoothing: antialiased;
|
38 |
+
-moz-osx-font-smoothing: grayscale;
|
39 |
+
text-decoration: none !important;
|
40 |
+
color: #888;
|
41 |
}
|
42 |
|
43 |
div#community-profile-page li.bp-members-profile-stats:before {
|
@@ -1 +1,2 @@
|
|
1 |
-
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:26 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
div#profile-page.wrap form#your-profile{position:relative}div#profile-page.wrap form#your-profile h3:first-of-type{margin-top:5em}div#profile-page.wrap form#your-profile #profile-nav{position:absolute;top:-3.65em;width:97%}div#community-profile-page #profile-nav{margin-bottom:1em}#bp_members_admin_user_stats ul{margin-bottom:0}div#community-profile-page a.bp-xprofile-avatar-user-admin:before,div#community-profile-page li.bp-blogs-profile-stats:before,div#community-profile-page li.bp-friends-profile-stats:before,div#community-profile-page li.bp-groups-profile-stats:before,div#community-profile-page li.bp-members-profile-stats:before{font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0 2px 0 0;top:0;left:-1px;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#888}div#community-profile-page li.bp-members-profile-stats:before{content:"\f130"}div#community-profile-page li.bp-friends-profile-stats:before{content:"\f454"}div#community-profile-page li.bp-groups-profile-stats:before{content:"\f456"}div#community-profile-page li.bp-blogs-profile-stats:before{content:"\f120"}div#community-profile-page a.bp-xprofile-avatar-user-admin:before{content:"\f182"}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar{width:150px;margin:0 auto}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar img{max-width:100%;height:auto}div#community-profile-page div#bp_xprofile_user_admin_avatar a{display:block;margin:1em 0;text-decoration:none;color:#888}div#community-profile-page p.not-activated{margin:1em 1em 0;color:red}#community-profile-page #submitdiv #publishing-action{float:none;width:100%}.bp-view-profile{float:left}.alt{background:0 0}.bp-profile-field{border-bottom:dotted 1px #ccc;font-size:14px;margin:15px 0;padding:10px}.bp-profile-field:last-child{border-bottom:0}.bp-profile-field p{font-size:14px}.bp-profile-field .datebox>label,.bp-profile-field .radio>label,.bp-profile-field>label{display:inline-block;font-weight:600;text-align:left;vertical-align:middle;width:200px}.field_type_checkbox .checkbox>label,.field_type_multiselectbox>label,.field_type_radio .radio>label,.field_type_textarea>label{vertical-align:top}.bp-profile-field .description{margin:10px 0 10px 200px;text-align:left}.clear-value{display:block;font-size:12px;margin-left:200px}.field_type_checkbox .checkbox>label+label{display:block;margin-left:200px;width:auto}.field_type_radio .radio div:not(.field-visibility-settings) label{display:block}.field_type_radio .radio div:not(.field-visibility-settings){display:inline-block}.field-visibility-settings-notoggle,.field-visibility-settings-toggle{margin:10px 0 10px 200px;text-align:left}.field-visibility-settings{display:none;margin-left:200px}.field-visibility-settings .button{margin-bottom:15px}#normal-sortables .field-visibility-settings legend{font-size:16px;margin-bottom:10px}
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
( function( $ ) {
|
2 |
// Profile Visibility Settings
|
3 |
|
@@ -50,4 +52,4 @@ function clear( container ) {
|
|
50 |
options[i].selected = false;
|
51 |
}
|
52 |
}
|
53 |
-
}
|
1 |
+
/* exported clear */
|
2 |
+
|
3 |
( function( $ ) {
|
4 |
// Profile Visibility Settings
|
5 |
|
52 |
options[i].selected = false;
|
53 |
}
|
54 |
}
|
55 |
+
}
|
@@ -1 +1,2 @@
|
|
1 |
-
|
|
1 |
+
/*! buddypress - v2.1.0 - 2014-08-22 10:29:24 PM UTC - https://wordpress.org/plugins/buddypress/ */
|
2 |
+
function clear(a){if(a=document.getElementById(a)){var b=a.getElementsByTagName("INPUT"),c=a.getElementsByTagName("OPTION"),d=0;if(b)for(d=0;d<b.length;d++)b[d].checked="";if(c)for(d=0;d<c.length;d++)c[d].selected=!1}}!function(a){a(".visibility-toggle-link").on("click",function(b){b.preventDefault(),a(this).parent().hide().siblings(".field-visibility-settings").show()}),a(".field-visibility-settings-close").on("click",function(b){b.preventDefault();var c=a(this).parent(),d=c.find("input:checked").parent().text();c.hide().siblings(".field-visibility-settings-toggle").children(".current-visibility-level").text(d).end().show()})}(jQuery);
|
@@ -15,13 +15,16 @@
|
|
15 |
if ( !defined( 'ABSPATH' ) ) exit;
|
16 |
|
17 |
/**
|
|
|
|
|
18 |
* When a site admin selects "Mark as Spammer/Not Spammer" from the admin menu
|
19 |
* this action will fire and mark or unmark the user and their blogs as spam.
|
20 |
* Must be a site admin for this function to run.
|
21 |
*
|
22 |
-
*
|
23 |
-
*
|
24 |
-
* @
|
|
|
25 |
*/
|
26 |
function bp_core_action_set_spammer_status( $user_id = 0 ) {
|
27 |
|
@@ -65,9 +68,9 @@ function bp_core_action_set_spammer_status( $user_id = 0 ) {
|
|
65 |
//add_action( 'bp_actions', 'bp_core_action_set_spammer_status' );
|
66 |
|
67 |
/**
|
68 |
-
*
|
69 |
*
|
70 |
-
*
|
71 |
*/
|
72 |
function bp_core_action_delete_user() {
|
73 |
|
@@ -101,10 +104,8 @@ function bp_core_action_delete_user() {
|
|
101 |
//add_action( 'bp_actions', 'bp_core_action_delete_user' );
|
102 |
|
103 |
/**
|
104 |
-
*
|
105 |
*
|
106 |
-
* @package BuddyPress Core
|
107 |
-
* @param string $username Username to check.
|
108 |
* @since BuddyPress (1.0)
|
109 |
*/
|
110 |
function bp_core_get_random_member() {
|
15 |
if ( !defined( 'ABSPATH' ) ) exit;
|
16 |
|
17 |
/**
|
18 |
+
* Catch a "Mark as Spammer/Not Spammer" click from the toolbar.
|
19 |
+
*
|
20 |
* When a site admin selects "Mark as Spammer/Not Spammer" from the admin menu
|
21 |
* this action will fire and mark or unmark the user and their blogs as spam.
|
22 |
* Must be a site admin for this function to run.
|
23 |
*
|
24 |
+
* Note: no longer used in the current state. See the Settings component.
|
25 |
+
*
|
26 |
+
* @param int $user_id Optional. User ID to mark as spam. Defaults to displayed
|
27 |
+
* user.
|
28 |
*/
|
29 |
function bp_core_action_set_spammer_status( $user_id = 0 ) {
|
30 |
|
68 |
//add_action( 'bp_actions', 'bp_core_action_set_spammer_status' );
|
69 |
|
70 |
/**
|
71 |
+
* Process user deletion requests.
|
72 |
*
|
73 |
+
* Note: No longer called here. See the Settings component.
|
74 |
*/
|
75 |
function bp_core_action_delete_user() {
|
76 |
|
104 |
//add_action( 'bp_actions', 'bp_core_action_delete_user' );
|
105 |
|
106 |
/**
|
107 |
+
* Redirect to a random member page when visiting a ?random-member URL.
|
108 |
*
|
|
|
|
|
109 |
* @since BuddyPress (1.0)
|
110 |
*/
|
111 |
function bp_core_get_random_member() {
|
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
// Exit if accessed directly
|
3 |
if ( !defined( 'ABSPATH' ) ) exit;
|
4 |
|
@@ -61,15 +62,16 @@ class BP_Members_Admin {
|
|
61 |
* @access public
|
62 |
* @since BuddyPress (2.0.0)
|
63 |
*
|
64 |
-
* @uses buddypress() to get BuddyPress main instance
|
65 |
*/
|
66 |
public static function register_members_admin() {
|
67 |
-
if( ! is_admin() )
|
68 |
return;
|
|
|
69 |
|
70 |
$bp = buddypress();
|
71 |
|
72 |
-
if( empty( $bp->members->admin ) ) {
|
73 |
$bp->members->admin = new self;
|
74 |
}
|
75 |
|
@@ -108,17 +110,28 @@ class BP_Members_Admin {
|
|
108 |
// The Edit Profile Screen id
|
109 |
$this->user_page = '';
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
// The screen ids to load specific css for
|
112 |
$this->screen_id = array();
|
113 |
|
114 |
// The stats metabox default position
|
115 |
$this->stats_metabox = new StdClass();
|
116 |
|
117 |
-
//
|
118 |
-
$this->
|
119 |
-
|
120 |
-
|
121 |
-
$this->edit_profile_url = add_query_arg( 'page', 'bp-profile-edit', bp_get_admin_url( 'users.php' ) );
|
122 |
|
123 |
// Data specific to signups
|
124 |
$this->users_page = '';
|
@@ -143,99 +156,367 @@ class BP_Members_Admin {
|
|
143 |
*/
|
144 |
private function setup_actions() {
|
145 |
|
146 |
-
/** Extended Profile
|
|
|
|
|
|
|
147 |
|
148 |
// Add some page specific output to the <head>
|
149 |
-
add_action( 'bp_admin_head', array( $this, 'admin_head'
|
150 |
|
151 |
// Add menu item to all users menu
|
152 |
-
add_action(
|
153 |
-
|
154 |
-
|
155 |
-
add_action( 'bp_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
156 |
|
157 |
// Create the Profile Navigation (Profile/Extended Profile)
|
158 |
-
add_action( 'edit_user_profile', array( $this, 'profile_nav'
|
|
|
|
|
|
|
|
|
159 |
|
160 |
// Add a row action to users listing
|
161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
|
163 |
-
/** Signups
|
164 |
|
165 |
if ( is_admin() ) {
|
|
|
|
|
166 |
if ( ! is_multisite() ) {
|
167 |
-
add_action( 'pre_user_query', array( $this, 'remove_signups_from_user_query'),
|
168 |
}
|
169 |
|
170 |
// Reorganise the views navigation in users.php and signups page
|
171 |
if ( current_user_can( $this->capability ) ) {
|
172 |
-
add_filter( "views_{$this->users_screen}", array( $this, 'signup_filter_view'
|
173 |
add_filter( 'set-screen-option', array( $this, 'signup_screen_options' ), 10, 3 );
|
174 |
}
|
175 |
}
|
176 |
}
|
177 |
|
178 |
/**
|
179 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
*
|
181 |
* @access public
|
182 |
* @since BuddyPress (2.0.0)
|
183 |
*
|
184 |
-
* @uses
|
185 |
*/
|
186 |
public function admin_menus() {
|
187 |
|
|
|
|
|
|
|
188 |
// Manage user's profile
|
189 |
-
$hooks['user'] = $this->user_page =
|
|
|
190 |
__( 'Edit Profile', 'buddypress' ),
|
191 |
__( 'Edit Profile', 'buddypress' ),
|
192 |
-
'
|
193 |
'bp-profile-edit',
|
194 |
-
array(
|
195 |
);
|
196 |
|
197 |
-
//
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
$this->
|
202 |
-
|
203 |
-
|
204 |
-
|
|
|
|
|
|
|
|
|
205 |
|
206 |
-
$edit_page
|
207 |
-
$
|
|
|
208 |
|
209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
$edit_page .= '-network';
|
211 |
-
$
|
212 |
$this->user_page .= '-network';
|
|
|
213 |
$this->signups_page .= '-network';
|
214 |
}
|
215 |
|
216 |
-
|
|
|
|
|
|
|
|
|
|
|
217 |
|
|
|
218 |
foreach ( $hooks as $key => $hook ) {
|
219 |
-
add_action( "load
|
220 |
}
|
221 |
|
222 |
-
|
223 |
-
|
|
|
|
|
224 |
}
|
225 |
|
226 |
/**
|
227 |
* Highlight the Users menu if on Edit Profile.
|
228 |
*
|
|
|
|
|
229 |
* @access public
|
230 |
-
* @since BuddyPress (2.
|
231 |
*/
|
232 |
-
public function
|
233 |
-
global $
|
234 |
|
235 |
-
//
|
236 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
$submenu_file = 'users.php';
|
238 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
}
|
240 |
|
241 |
/**
|
@@ -249,11 +530,11 @@ class BP_Members_Admin {
|
|
249 |
* @since BuddyPress (2.0.0)
|
250 |
*/
|
251 |
public function admin_head() {
|
252 |
-
|
253 |
-
remove_submenu_page( '
|
254 |
}
|
255 |
|
256 |
-
/** Community Profile
|
257 |
|
258 |
/**
|
259 |
* Add some specific styling to the Edit User and Edit User's Profile page.
|
@@ -267,11 +548,16 @@ class BP_Members_Admin {
|
|
267 |
}
|
268 |
|
269 |
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
270 |
-
|
271 |
$css = $this->css_url . "admin{$min}.css";
|
272 |
$css = apply_filters( 'bp_members_admin_css', $css );
|
|
|
273 |
wp_enqueue_style( 'bp-members-css', $css, array(), bp_get_version() );
|
274 |
|
|
|
|
|
|
|
|
|
|
|
275 |
// Only load javascript for BuddyPress profile
|
276 |
if ( get_current_screen()->id == $this->user_page ) {
|
277 |
$js = $this->js_url . "admin{$min}.js";
|
@@ -291,22 +577,24 @@ class BP_Members_Admin {
|
|
291 |
*/
|
292 |
public function profile_nav( $user = null, $active = 'WordPress' ) {
|
293 |
|
|
|
294 |
if ( empty( $user->ID ) ) {
|
295 |
return;
|
296 |
}
|
297 |
|
298 |
-
//
|
299 |
-
|
300 |
-
|
301 |
-
|
|
|
302 |
}
|
303 |
|
304 |
-
|
305 |
-
|
306 |
if ( ! empty( $_REQUEST['wp_http_referer'] ) ) {
|
307 |
$query_args['wp_http_referer'] = urlencode( stripslashes_deep( $_REQUEST['wp_http_referer'] ) );
|
308 |
}
|
309 |
|
|
|
310 |
$community_url = add_query_arg( $query_args, $this->edit_profile_url );
|
311 |
$wordpress_url = add_query_arg( $query_args, $this->edit_url );
|
312 |
|
@@ -317,21 +605,21 @@ class BP_Members_Admin {
|
|
317 |
$wp_active = false;
|
318 |
} ?>
|
319 |
|
320 |
-
<
|
321 |
<?php
|
322 |
/**
|
323 |
* In configs where BuddyPress is not network activated, as regular
|
324 |
* admins do not have the capacity to edit other users, we must add
|
325 |
* this check.
|
326 |
*/
|
327 |
-
?>
|
328 |
-
<?php if ( current_user_can( 'edit_user' ) ) :?>
|
329 |
-
<li class="nav-tab<?php echo esc_attr( $wp_active ); ?>"><a href="<?php echo esc_url( $wordpress_url );?>"><?php _e( 'Profile', 'buddypress' ); ?></a></li>
|
330 |
-
<?php endif ;?>
|
331 |
-
<li class="nav-tab<?php echo esc_attr( $bp_active ); ?>"><a href="<?php echo esc_url( $community_url );?>"><?php _e( 'Extended Profile', 'buddypress' ); ?></a></li>
|
332 |
|
333 |
-
|
334 |
-
|
|
|
|
|
|
|
|
|
335 |
|
336 |
<?php
|
337 |
}
|
@@ -348,23 +636,22 @@ class BP_Members_Admin {
|
|
348 |
*/
|
349 |
public function user_admin_load() {
|
350 |
|
351 |
-
|
352 |
-
|
353 |
-
}
|
354 |
|
355 |
-
//
|
356 |
-
if (
|
357 |
-
|
358 |
}
|
359 |
|
360 |
// Build redirection URL
|
361 |
$redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham', 'delete_avatar' ), $_SERVER['REQUEST_URI'] );
|
362 |
-
$doaction
|
363 |
|
364 |
if ( ! empty( $_REQUEST['user_status'] ) ) {
|
365 |
-
$spam = ( 'spam'
|
366 |
|
367 |
-
if ( $spam
|
368 |
$doaction = $_REQUEST['user_status'];
|
369 |
}
|
370 |
}
|
@@ -396,10 +683,17 @@ class BP_Members_Admin {
|
|
396 |
);
|
397 |
|
398 |
// Register metaboxes for the edit screen.
|
399 |
-
add_meta_box(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
400 |
|
401 |
// In case xprofile is not active
|
402 |
-
$this->stats_metabox->context
|
403 |
$this->stats_metabox->priority = 'core';
|
404 |
|
405 |
/**
|
@@ -409,23 +703,37 @@ class BP_Members_Admin {
|
|
409 |
do_action_ref_array( 'bp_members_admin_xprofile_metabox', array( $user_id, get_current_screen()->id, $this->stats_metabox ) );
|
410 |
|
411 |
// If xProfile is inactive, difficult to know what's profile we're on
|
412 |
-
$
|
413 |
-
|
414 |
-
|
|
|
415 |
}
|
416 |
|
417 |
// User Stat metabox
|
418 |
-
add_meta_box(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
|
420 |
-
|
421 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
|
423 |
// Enqueue javascripts
|
424 |
-
wp_enqueue_script( 'postbox'
|
425 |
wp_enqueue_script( 'dashboard' );
|
426 |
|
427 |
// Spam or Ham user
|
428 |
-
}
|
429 |
|
430 |
check_admin_referer( 'edit-bp-profile_' . $user_id );
|
431 |
|
@@ -455,121 +763,72 @@ class BP_Members_Admin {
|
|
455 |
*/
|
456 |
public function user_admin() {
|
457 |
|
458 |
-
if ( !
|
459 |
die( '-1' );
|
460 |
}
|
461 |
|
462 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
463 |
|
464 |
// Construct URL for form
|
465 |
-
$
|
466 |
-
$
|
467 |
-
$wp_http_referer =
|
|
|
|
|
|
|
468 |
|
469 |
// Prepare notice for admin
|
470 |
-
$notice =
|
471 |
|
472 |
-
if ( ! empty( $
|
473 |
-
switch ( $_REQUEST['updated'] ) {
|
474 |
-
case 'avatar':
|
475 |
-
$notice = array(
|
476 |
-
'class' => 'updated',
|
477 |
-
'message' => __( 'Avatar was deleted successfully!', 'buddypress' )
|
478 |
-
);
|
479 |
-
break;
|
480 |
-
case 'ham' :
|
481 |
-
$notice = array(
|
482 |
-
'class' => 'updated',
|
483 |
-
'message' => __( 'User removed as spammer.', 'buddypress' )
|
484 |
-
);
|
485 |
-
break;
|
486 |
-
case 'spam' :
|
487 |
-
$notice = array(
|
488 |
-
'class' => 'updated',
|
489 |
-
'message' => __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' )
|
490 |
-
);
|
491 |
-
break;
|
492 |
-
case 1 :
|
493 |
-
$notice = array(
|
494 |
-
'class' => 'updated',
|
495 |
-
'message' => __( 'Profile updated.', 'buddypress' )
|
496 |
-
);
|
497 |
-
break;
|
498 |
-
}
|
499 |
-
}
|
500 |
|
501 |
-
|
502 |
-
switch ( $_REQUEST['error'] ) {
|
503 |
-
case 'avatar':
|
504 |
-
$notice = array(
|
505 |
-
'class' => 'error',
|
506 |
-
'message' => __( 'There was a problem deleting that avatar, please try again.', 'buddypress' )
|
507 |
-
);
|
508 |
-
break;
|
509 |
-
case 'ham' :
|
510 |
-
$notice = array(
|
511 |
-
'class' => 'error',
|
512 |
-
'message' => __( 'User could not be removed as spammer.', 'buddypress' )
|
513 |
-
);
|
514 |
-
break;
|
515 |
-
case 'spam' :
|
516 |
-
$notice = array(
|
517 |
-
'class' => 'error',
|
518 |
-
'message' => __( 'User could not be marked as spammer.', 'buddypress' )
|
519 |
-
);
|
520 |
-
break;
|
521 |
-
case 1 :
|
522 |
-
$notice = array(
|
523 |
-
'class' => 'error',
|
524 |
-
'message' => __( 'An error occured while trying to update the profile.', 'buddypress' )
|
525 |
-
);
|
526 |
-
break;
|
527 |
-
case 2:
|
528 |
-
$notice = array(
|
529 |
-
'class' => 'error',
|
530 |
-
'message' => __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' )
|
531 |
-
);
|
532 |
-
break;
|
533 |
-
case 3:
|
534 |
-
$notice = array(
|
535 |
-
'class' => 'error',
|
536 |
-
'message' => __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' )
|
537 |
-
);
|
538 |
-
break;
|
539 |
-
}
|
540 |
-
}
|
541 |
|
542 |
-
if ( ! empty( $notice ) ) :
|
543 |
-
if ( 'updated' === $notice['class'] ) : ?>
|
544 |
-
<div id="message" class="<?php echo esc_attr( $notice['class'] ); ?>">
|
545 |
-
<?php else: ?>
|
546 |
-
<div class="<?php echo esc_attr( $notice['class'] ); ?>">
|
547 |
-
<?php endif; ?>
|
548 |
<p><?php echo esc_html( $notice['message'] ); ?></p>
|
|
|
549 |
<?php if ( !empty( $wp_http_referer ) && ( 'updated' === $notice['class'] ) ) : ?>
|
|
|
550 |
<p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php esc_html_e( '← Back to Users', 'buddypress' ); ?></a></p>
|
|
|
551 |
<?php endif; ?>
|
|
|
552 |
</div>
|
|
|
553 |
<?php endif; ?>
|
554 |
|
555 |
-
<div class="wrap"
|
556 |
<?php screen_icon( 'users' ); ?>
|
557 |
-
<h2
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
566 |
</h2>
|
567 |
|
568 |
<?php if ( ! empty( $user ) ) :
|
569 |
|
570 |
$this->profile_nav( $user, 'BuddyPress' ); ?>
|
571 |
|
572 |
-
<form action="<?php echo
|
573 |
<div id="poststuff">
|
574 |
|
575 |
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
|
@@ -595,7 +854,9 @@ class BP_Members_Admin {
|
|
595 |
</form>
|
596 |
|
597 |
<?php else : ?>
|
|
|
598 |
<p><?php printf( __( 'No user found with this ID. <a href="%s">Go back and try again</a>.', 'buddypress' ), esc_url( bp_get_admin_url( 'users.php' ) ) ); ?></p>
|
|
|
599 |
<?php endif; ?>
|
600 |
|
601 |
</div><!-- .wrap -->
|
@@ -621,31 +882,43 @@ class BP_Members_Admin {
|
|
621 |
return;
|
622 |
}
|
623 |
|
624 |
-
if
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
|
|
|
|
|
|
629 |
|
630 |
<div class="submitbox" id="submitcomment">
|
631 |
<div id="minor-publishing">
|
632 |
<div id="misc-publishing-actions">
|
633 |
<?php
|
|
|
|
|
|
|
|
|
634 |
/**
|
635 |
-
* In configs where BuddyPress is not network activated,
|
636 |
-
* cannot mark a user as a spammer on front
|
637 |
-
* it in backend.
|
|
|
|
|
|
|
638 |
*/
|
639 |
-
?>
|
640 |
-
|
641 |
<div class="misc-pub-section" id="comment-status-radio">
|
642 |
-
<label class="approved"><input type="radio" name="user_status" value="ham" <?php checked(
|
643 |
-
<label class="spam"><input type="radio" name="user_status" value="spam" <?php checked(
|
644 |
</div>
|
|
|
645 |
<?php endif ;?>
|
646 |
|
647 |
<div class="misc-pub-section curtime misc-pub-section-last">
|
648 |
<?php
|
|
|
649 |
// translators: Publish box date format, see http://php.net/date
|
650 |
$datef = __( 'M j, Y @ G:i', 'buddypress' );
|
651 |
$date = date_i18n( $datef, strtotime( $user->user_registered ) );
|
@@ -680,9 +953,9 @@ class BP_Members_Admin {
|
|
680 |
* @param WP_User $user The WP_User object to be edited.
|
681 |
*/
|
682 |
public function user_admin_spammer_metabox( $user = null ) {
|
683 |
-
|
684 |
<p><?php printf( __( '%s has been marked as a spammer. All BuddyPress data associated with the user has been removed', 'buddypress' ), esc_html( bp_core_get_user_displayname( $user->ID ) ) ) ;?></p>
|
685 |
-
|
686 |
}
|
687 |
|
688 |
/**
|
@@ -695,6 +968,7 @@ class BP_Members_Admin {
|
|
695 |
*/
|
696 |
public function user_admin_stats_metabox( $user = null ) {
|
697 |
|
|
|
698 |
if ( empty( $user->ID ) ) {
|
699 |
return;
|
700 |
}
|
@@ -712,7 +986,7 @@ class BP_Members_Admin {
|
|
712 |
$date = date_i18n( $datef, strtotime( $last_active ) ); ?>
|
713 |
|
714 |
<ul>
|
715 |
-
<li class="bp-members-profile-stats"><?php printf( __( 'Last active:
|
716 |
|
717 |
<?php
|
718 |
// Loading other stats only if user has activated their account
|
@@ -736,44 +1010,90 @@ class BP_Members_Admin {
|
|
736 |
* @return array Merged actions.
|
737 |
*/
|
738 |
public function row_actions( $actions = '', $user = null ) {
|
739 |
-
|
740 |
-
|
741 |
-
|
|
|
742 |
}
|
743 |
|
744 |
-
//
|
745 |
-
|
746 |
-
|
|
|
|
|
|
|
747 |
}
|
748 |
|
749 |
-
|
750 |
-
|
751 |
-
'wp_http_referer' => urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
|
752 |
-
), $this->edit_profile_url );
|
753 |
|
754 |
-
|
|
|
755 |
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
*/
|
760 |
-
if ( ! empty( $actions['edit'] ) ) {
|
761 |
-
$edit_action = $actions['edit'];
|
762 |
-
unset( $actions['edit'] );
|
763 |
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
771 |
}
|
772 |
|
773 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
774 |
}
|
775 |
|
776 |
-
/**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
777 |
|
778 |
/**
|
779 |
* Display the admin preferences about signups pagination.
|
@@ -815,21 +1135,26 @@ class BP_Members_Admin {
|
|
815 |
global $wpdb;
|
816 |
|
817 |
// Bail if this is an ajax request
|
818 |
-
if ( defined( 'DOING_AJAX' ) )
|
819 |
return;
|
|
|
820 |
|
|
|
821 |
if ( bp_is_update() ) {
|
822 |
return;
|
823 |
}
|
824 |
|
825 |
-
if
|
|
|
826 |
return;
|
827 |
}
|
828 |
|
829 |
-
if
|
|
|
830 |
return;
|
831 |
}
|
832 |
|
|
|
833 |
if ( ! empty( $query->query_vars['role'] ) ) {
|
834 |
return;
|
835 |
}
|
@@ -846,18 +1171,20 @@ class BP_Members_Admin {
|
|
846 |
* @return array The views with the signup view added.
|
847 |
*/
|
848 |
public function signup_filter_view( $views = array() ) {
|
849 |
-
$class = '';
|
850 |
|
851 |
-
|
852 |
-
|
853 |
-
// Remove the 'current' class from All if we're on the signups
|
854 |
-
// view
|
855 |
if ( $this->signups_page == get_current_screen()->id ) {
|
856 |
$views['all'] = str_replace( 'class="current"', '', $views['all'] );
|
857 |
-
$class
|
|
|
|
|
858 |
}
|
859 |
|
860 |
-
$
|
|
|
|
|
|
|
|
|
861 |
|
862 |
return $views;
|
863 |
}
|
@@ -900,7 +1227,7 @@ class BP_Members_Admin {
|
|
900 |
|
901 |
// Build redirection URL
|
902 |
$redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'activated', 'notactivated', 'deleted', 'notdeleted', 'resent', 'notresent', 'do_delete', 'do_resend', 'do_activate', '_wpnonce', 'signup_ids' ), $_SERVER['REQUEST_URI'] );
|
903 |
-
$doaction
|
904 |
|
905 |
// Call an action for plugins to hook in early
|
906 |
do_action( 'bp_signups_admin_load', $doaction, $_REQUEST );
|
@@ -909,7 +1236,7 @@ class BP_Members_Admin {
|
|
909 |
$allowed_actions = apply_filters( 'bp_signups_admin_allowed_actions', array( 'do_delete', 'do_activate', 'do_resend' ) );
|
910 |
|
911 |
// Prepare the display of the Community Profile screen
|
912 |
-
if ( ! in_array( $doaction, $allowed_actions ) || -1 == $doaction ) {
|
913 |
|
914 |
if ( bp_core_do_network_admin() ) {
|
915 |
$bp_members_signup_list_table = self::get_list_table_class( 'BP_Members_MS_List_Table', 'ms-users' );
|
@@ -953,6 +1280,7 @@ class BP_Members_Admin {
|
|
953 |
|
954 |
// Handle resent activation links
|
955 |
if ( 'do_resend' == $doaction ) {
|
|
|
956 |
// nonce check
|
957 |
check_admin_referer( 'signups_resend' );
|
958 |
|
@@ -979,6 +1307,7 @@ class BP_Members_Admin {
|
|
979 |
|
980 |
// Handle activated accounts
|
981 |
} else if ( 'do_activate' == $doaction ) {
|
|
|
982 |
// nonce check
|
983 |
check_admin_referer( 'signups_activate' );
|
984 |
|
@@ -1005,6 +1334,7 @@ class BP_Members_Admin {
|
|
1005 |
|
1006 |
// Handle sign-ups delete
|
1007 |
} else if ( 'do_delete' == $doaction ) {
|
|
|
1008 |
// nonce check
|
1009 |
check_admin_referer( 'signups_delete' );
|
1010 |
|
@@ -1046,40 +1376,39 @@ class BP_Members_Admin {
|
|
1046 |
* @since BuddyPress (2.0.0)
|
1047 |
*/
|
1048 |
public function signups_display_errors() {
|
|
|
|
|
|
|
|
|
1049 |
// Bail if no activation errors
|
1050 |
-
if (
|
1051 |
return;
|
1052 |
}
|
1053 |
|
1054 |
-
|
1055 |
-
|
|
|
1056 |
<li><?php echo esc_html( $error[0] );?>: <?php echo esc_html( $error[1] );?></li>
|
1057 |
-
|
1058 |
-
|
1059 |
|
1060 |
// Delete the redirect transient
|
1061 |
delete_transient( '_bp_admin_signups_errors' );
|
1062 |
}
|
1063 |
|
1064 |
/**
|
1065 |
-
*
|
1066 |
*
|
1067 |
-
*
|
1068 |
-
* - the list of signups
|
1069 |
-
* - or the delete confirmation screen
|
1070 |
-
* - or the activate confirmation screen
|
1071 |
-
* - or the "resend" email confirmation screen
|
1072 |
-
*
|
1073 |
-
* Also prepare the admin notices.
|
1074 |
*
|
1075 |
-
* @
|
1076 |
*/
|
1077 |
-
|
1078 |
-
$doaction = bp_admin_list_table_current_bulk_action();
|
1079 |
|
1080 |
-
//
|
1081 |
$notice = array();
|
1082 |
|
|
|
1083 |
if ( ! empty( $_REQUEST['updated'] ) ) {
|
1084 |
switch ( $_REQUEST['updated'] ) {
|
1085 |
case 'resent':
|
@@ -1186,7 +1515,7 @@ class BP_Members_Admin {
|
|
1186 |
}
|
1187 |
}
|
1188 |
|
1189 |
-
//
|
1190 |
if ( ! empty( $_REQUEST['error'] ) ) {
|
1191 |
switch ( $_REQUEST['error'] ) {
|
1192 |
case 'do_resend':
|
@@ -1212,18 +1541,50 @@ class BP_Members_Admin {
|
|
1212 |
}
|
1213 |
}
|
1214 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1215 |
// Display notices
|
1216 |
if ( ! empty( $notice ) ) :
|
1217 |
if ( 'updated' === $notice['class'] ) : ?>
|
|
|
1218 |
<div id="message" class="<?php echo esc_attr( $notice['class'] ); ?>">
|
|
|
1219 |
<?php else: ?>
|
|
|
1220 |
<div class="<?php echo esc_attr( $notice['class'] ); ?>">
|
|
|
1221 |
<?php endif; ?>
|
|
|
1222 |
<p><?php echo $notice['message']; ?></p>
|
|
|
1223 |
<?php if ( ! empty( $_REQUEST['notactivated'] ) || ! empty( $_REQUEST['notdeleted'] ) || ! empty( $_REQUEST['notsent'] ) ) :?>
|
|
|
1224 |
<ul><?php $this->signups_display_errors();?></ul>
|
|
|
1225 |
<?php endif ;?>
|
|
|
1226 |
</div>
|
|
|
1227 |
<?php endif;
|
1228 |
|
1229 |
// Show the proper screen
|
@@ -1291,14 +1652,17 @@ class BP_Members_Admin {
|
|
1291 |
|
1292 |
<div class="wrap">
|
1293 |
<?php screen_icon( 'users' ); ?>
|
1294 |
-
<h2
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
<a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user', 'buddypress' ); ?></a>
|
1299 |
-
|
|
|
|
|
1300 |
<a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user', 'buddypress' ); ?></a>
|
1301 |
-
|
|
|
1302 |
|
1303 |
if ( $usersearch ) {
|
1304 |
printf( '<span class="subtitle">' . __( 'Search results for “%s”', 'buddypress' ) . '</span>', esc_html( $usersearch ) );
|
@@ -1312,7 +1676,7 @@ class BP_Members_Admin {
|
|
1312 |
|
1313 |
<form id="bp-signups-search-form" action="<?php echo esc_url( $search_form_url ) ;?>">
|
1314 |
<input type="hidden" name="page" value="<?php echo esc_attr( $plugin_page ); ?>" />
|
1315 |
-
<?php $bp_members_signup_list_table->search_box( __( 'Search Pending
|
1316 |
</form>
|
1317 |
|
1318 |
<form id="bp-signups-form" action="<?php echo esc_url( $form_url );?>" method="post">
|
@@ -1400,29 +1764,35 @@ class BP_Members_Admin {
|
|
1400 |
|
1401 |
<ol class="bp-signups-list">
|
1402 |
<?php foreach ( $signups as $signup ) :
|
1403 |
-
|
1404 |
-
|
1405 |
|
1406 |
<li>
|
1407 |
<?php echo esc_html( $signup->user_name ) ?> - <?php echo sanitize_email( $signup->user_email );?>
|
1408 |
|
1409 |
<?php if ( 'resend' == $action ) : ?>
|
|
|
1410 |
<p class="description">
|
1411 |
<?php printf( esc_html__( 'Last notified: %s', 'buddypress'), $last_notified ) ;?>
|
1412 |
|
1413 |
<?php if ( ! empty( $signup->recently_sent ) ) : ?>
|
|
|
1414 |
<span class="attention wp-ui-text-notification"> <?php esc_html_e( '(less than 24 hours ago)', 'buddypress' ); ?></span>
|
|
|
1415 |
<?php endif; ?>
|
1416 |
</p>
|
1417 |
|
1418 |
<?php endif; ?>
|
|
|
1419 |
</li>
|
1420 |
|
1421 |
<?php endforeach; ?>
|
1422 |
</ol>
|
1423 |
|
1424 |
-
<?php if ( '
|
|
|
1425 |
<p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ) ?></strong></p>
|
|
|
1426 |
<?php endif ; ?>
|
1427 |
|
1428 |
<a class="button-primary" href="<?php echo esc_url( $action_url ); ?>"><?php esc_html_e( 'Confirm', 'buddypress' ); ?></a>
|
1 |
<?php
|
2 |
+
|
3 |
// Exit if accessed directly
|
4 |
if ( !defined( 'ABSPATH' ) ) exit;
|
5 |
|
62 |
* @access public
|
63 |
* @since BuddyPress (2.0.0)
|
64 |
*
|
65 |
+
* @uses buddypress() to get BuddyPress main instance.
|
66 |
*/
|
67 |
public static function register_members_admin() {
|
68 |
+
if ( ! is_admin() ) {
|
69 |
return;
|
70 |
+
}
|
71 |
|
72 |
$bp = buddypress();
|
73 |
|
74 |
+
if ( empty( $bp->members->admin ) ) {
|
75 |
$bp->members->admin = new self;
|
76 |
}
|
77 |
|
110 |
// The Edit Profile Screen id
|
111 |
$this->user_page = '';
|
112 |
|
113 |
+
// The Show Profile Screen id
|
114 |
+
$this->user_profile = is_network_admin() ? 'users' : 'profile';
|
115 |
+
|
116 |
+
// The current user id
|
117 |
+
$this->current_user_id = get_current_user_id();
|
118 |
+
|
119 |
+
// The user id being edited
|
120 |
+
$this->user_id = 0;
|
121 |
+
|
122 |
+
// Is a member editing their own profile
|
123 |
+
$this->is_self_profile = false;
|
124 |
+
|
125 |
// The screen ids to load specific css for
|
126 |
$this->screen_id = array();
|
127 |
|
128 |
// The stats metabox default position
|
129 |
$this->stats_metabox = new StdClass();
|
130 |
|
131 |
+
// BuddyPress edit user's profile args
|
132 |
+
$this->edit_profile_args = array( 'page' => 'bp-profile-edit' );
|
133 |
+
$this->edit_profile_url = '';
|
134 |
+
$this->edit_url = '';
|
|
|
135 |
|
136 |
// Data specific to signups
|
137 |
$this->users_page = '';
|
156 |
*/
|
157 |
private function setup_actions() {
|
158 |
|
159 |
+
/** Extended Profile **************************************************/
|
160 |
+
|
161 |
+
// Enqueue all admin JS and CSS
|
162 |
+
add_action( 'bp_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
163 |
|
164 |
// Add some page specific output to the <head>
|
165 |
+
add_action( 'bp_admin_head', array( $this, 'admin_head' ), 999 );
|
166 |
|
167 |
// Add menu item to all users menu
|
168 |
+
add_action( 'admin_menu', array( $this, 'admin_menus' ), 5 );
|
169 |
+
add_action( 'network_admin_menu', array( $this, 'admin_menus' ), 5 );
|
170 |
+
add_action( 'user_admin_menu', array( $this, 'user_profile_menu' ), 5 );
|
|
|
171 |
|
172 |
// Create the Profile Navigation (Profile/Extended Profile)
|
173 |
+
add_action( 'edit_user_profile', array( $this, 'profile_nav' ), 99, 1 );
|
174 |
+
add_action( 'show_user_profile', array( $this, 'profile_nav' ), 99, 1 );
|
175 |
+
|
176 |
+
// Editing users of a specific site
|
177 |
+
add_action( "admin_head-site-users.php", array( $this, 'profile_admin_head' ) );
|
178 |
|
179 |
// Add a row action to users listing
|
180 |
+
if ( bp_core_do_network_admin() ) {
|
181 |
+
add_filter( 'ms_user_row_actions', array( $this, 'row_actions' ), 10, 2 );
|
182 |
+
add_action( 'admin_init', array( $this, 'add_edit_profile_url_filter' ) );
|
183 |
+
add_action( 'wp_after_admin_bar_render', array( $this, 'remove_edit_profile_url_filter' ) );
|
184 |
+
}
|
185 |
+
|
186 |
+
// Add user row actions for single site
|
187 |
+
add_filter( 'user_row_actions', array( $this, 'row_actions' ), 10, 2 );
|
188 |
|
189 |
+
/** Signups ***********************************************************/
|
190 |
|
191 |
if ( is_admin() ) {
|
192 |
+
|
193 |
+
// Filter non multisite user query to remove sign-up users
|
194 |
if ( ! is_multisite() ) {
|
195 |
+
add_action( 'pre_user_query', array( $this, 'remove_signups_from_user_query' ), 10, 1 );
|
196 |
}
|
197 |
|
198 |
// Reorganise the views navigation in users.php and signups page
|
199 |
if ( current_user_can( $this->capability ) ) {
|
200 |
+
add_filter( "views_{$this->users_screen}", array( $this, 'signup_filter_view' ), 10, 1 );
|
201 |
add_filter( 'set-screen-option', array( $this, 'signup_screen_options' ), 10, 3 );
|
202 |
}
|
203 |
}
|
204 |
}
|
205 |
|
206 |
/**
|
207 |
+
* Get the user ID
|
208 |
+
*
|
209 |
+
* Look for $_GET['user_id']. If anything else, force the user ID to the
|
210 |
+
* current user's ID so they aren't left without a user to edit.
|
211 |
+
*
|
212 |
+
* @since BuddyPress (2.1.0)
|
213 |
+
*
|
214 |
+
* @return int
|
215 |
+
*/
|
216 |
+
private function get_user_id() {
|
217 |
+
|
218 |
+
// No user ID to start
|
219 |
+
$user_id = 0;
|
220 |
+
|
221 |
+
// We'll need a user ID when not on the user admin
|
222 |
+
if ( ! empty( $_GET['user_id'] ) ) {
|
223 |
+
$user_id = $_GET['user_id'];
|
224 |
+
|
225 |
+
// Assume the current user ID
|
226 |
+
} else {
|
227 |
+
$user_id = get_current_user_id();
|
228 |
+
}
|
229 |
+
|
230 |
+
return intval( $user_id );
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Can the current user edit the one displayed
|
235 |
+
*
|
236 |
+
* self profile editing / or bp_moderate check.
|
237 |
+
* This might be replaced by more granular capabilities
|
238 |
+
* in the future.
|
239 |
+
*
|
240 |
+
* @access public
|
241 |
+
* @since BuddyPress (2.1.0)
|
242 |
+
*/
|
243 |
+
private function member_can_edit( $user_id = 0 ) {
|
244 |
+
$retval = false;
|
245 |
+
|
246 |
+
// Bail if no user ID was passed
|
247 |
+
if ( empty( $user_id ) ) {
|
248 |
+
return $retval;
|
249 |
+
}
|
250 |
+
|
251 |
+
// Member can edit if they are viewing their own profile
|
252 |
+
if ( $this->current_user_id === $user_id ) {
|
253 |
+
$retval = true;
|
254 |
+
|
255 |
+
// Trust the 'bp_moderate' capability
|
256 |
+
} else {
|
257 |
+
$retval = bp_current_user_can( 'bp_moderate' );
|
258 |
+
}
|
259 |
+
|
260 |
+
return $retval;
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Get admin notice when saving a user or member profile
|
265 |
+
*
|
266 |
+
* @since BuddyPress (2.1.0)
|
267 |
+
*
|
268 |
+
* @return array
|
269 |
+
*/
|
270 |
+
private function get_user_notice() {
|
271 |
+
|
272 |
+
// Setup empty notice for return value
|
273 |
+
$notice = array();
|
274 |
+
|
275 |
+
// Updates
|
276 |
+
if ( ! empty( $_REQUEST['updated'] ) ) {
|
277 |
+
switch ( $_REQUEST['updated'] ) {
|
278 |
+
case 'avatar':
|
279 |
+
$notice = array(
|
280 |
+
'class' => 'updated',
|
281 |
+
'message' => __( 'Profile photo was deleted.', 'buddypress' )
|
282 |
+
);
|
283 |
+
break;
|
284 |
+
case 'ham' :
|
285 |
+
$notice = array(
|
286 |
+
'class' => 'updated',
|
287 |
+
'message' => __( 'User removed as spammer.', 'buddypress' )
|
288 |
+
);
|
289 |
+
break;
|
290 |
+
case 'spam' :
|
291 |
+
$notice = array(
|
292 |
+
'class' => 'updated',
|
293 |
+
'message' => __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' )
|
294 |
+
);
|
295 |
+
break;
|
296 |
+
case 1 :
|
297 |
+
$notice = array(
|
298 |
+
'class' => 'updated',
|
299 |
+
'message' => __( 'Profile updated.', 'buddypress' )
|
300 |
+
);
|
301 |
+
break;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
// Errors
|
306 |
+
if ( ! empty( $_REQUEST['error'] ) ) {
|
307 |
+
switch ( $_REQUEST['error'] ) {
|
308 |
+
case 'avatar':
|
309 |
+
$notice = array(
|
310 |
+
'class' => 'error',
|
311 |
+
'message' => __( 'There was a problem deleting that avatar, please try again.', 'buddypress' )
|
312 |
+
);
|
313 |
+
break;
|
314 |
+
case 'ham' :
|
315 |
+
$notice = array(
|
316 |
+
'class' => 'error',
|
317 |
+
'message' => __( 'User could not be removed as spammer.', 'buddypress' )
|
318 |
+
);
|
319 |
+
break;
|
320 |
+
case 'spam' :
|
321 |
+
$notice = array(
|
322 |
+
'class' => 'error',
|
323 |
+
'message' => __( 'User could not be marked as spammer.', 'buddypress' )
|
324 |
+
);
|
325 |
+
break;
|
326 |
+
case 1 :
|
327 |
+
$notice = array(
|
328 |
+
'class' => 'error',
|
329 |
+
'message' => __( 'An error occured while trying to update the profile.', 'buddypress' )
|
330 |
+
);
|
331 |
+
break;
|
332 |
+
case 2:
|
333 |
+
$notice = array(
|
334 |
+
'class' => 'error',
|
335 |
+
'message' => __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' )
|
336 |
+
);
|
337 |
+
break;
|
338 |
+
case 3:
|
339 |
+
$notice = array(
|
340 |
+
'class' => 'error',
|
341 |
+
'message' => __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' )
|
342 |
+
);
|
343 |
+
break;
|
344 |
+
}
|
345 |
+
}
|
346 |
+
|
347 |
+
return $notice;
|
348 |
+
}
|
349 |
+
|
350 |
+
/**
|
351 |
+
* Create the /user/ admin Profile submenus for all members.
|
352 |
+
*
|
353 |
+
* @access public
|
354 |
+
* @since BuddyPress (2.1.0)
|
355 |
+
*
|
356 |
+
* @uses add_submenu_page() To add the Edit Profile page in Profile section.
|
357 |
+
*/
|
358 |
+
public function user_profile_menu() {
|
359 |
+
|
360 |
+
// Setup the hooks array
|
361 |
+
$hooks = array();
|
362 |
+
|
363 |
+
// Add the faux "Edit Profile" submenu page
|
364 |
+
$hooks['user'] = $this->user_page = add_submenu_page(
|
365 |
+
'profile.php',
|
366 |
+
__( 'Edit Profile', 'buddypress' ),
|
367 |
+
__( 'Edit Profile', 'buddypress' ),
|
368 |
+
'exist',
|
369 |
+
'bp-profile-edit',
|
370 |
+
array( $this, 'user_admin' )
|
371 |
+
);
|
372 |
+
|
373 |
+
// Setup the screen ID's
|
374 |
+
$this->screen_id = array(
|
375 |
+
$this->user_page . '-user',
|
376 |
+
$this->user_profile . '-user'
|
377 |
+
);
|
378 |
+
|
379 |
+
// Loop through new hooks and add method actions
|
380 |
+
foreach ( $hooks as $key => $hook ) {
|
381 |
+
add_action( "load-{$hook}", array( $this, $key . '_admin_load' ) );
|
382 |
+
}
|
383 |
+
|
384 |
+
// Add the profile_admin_head method to proper admin_head actions
|
385 |
+
add_action( "admin_head-{$this->user_page}", array( $this, 'profile_admin_head' ) );
|
386 |
+
add_action( "admin_head-profile.php", array( $this, 'profile_admin_head' ) );
|
387 |
+
}
|
388 |
+
|
389 |
+
/**
|
390 |
+
* Create the All Users / Profile > Edit Profile and All Users Signups submenus.
|
391 |
*
|
392 |
* @access public
|
393 |
* @since BuddyPress (2.0.0)
|
394 |
*
|
395 |
+
* @uses add_submenu_page() To add the Edit Profile page in Users/Profile section.
|
396 |
*/
|
397 |
public function admin_menus() {
|
398 |
|
399 |
+
// Setup the hooks array
|
400 |
+
$hooks = array();
|
401 |
+
|
402 |
// Manage user's profile
|
403 |
+
$hooks['user'] = $this->user_page = add_submenu_page(
|
404 |
+
$this->user_profile . '.php',
|
405 |
__( 'Edit Profile', 'buddypress' ),
|
406 |
__( 'Edit Profile', 'buddypress' ),
|
407 |
+
'read',
|
408 |
'bp-profile-edit',
|
409 |
+
array( $this, 'user_admin' )
|
410 |
);
|
411 |
|
412 |
+
// Only show sign-ups where they belong
|
413 |
+
if ( ! is_multisite() || is_network_admin() ) {
|
414 |
+
|
415 |
+
// Manage signups
|
416 |
+
$hooks['signups'] = $this->signups_page = add_users_page(
|
417 |
+
__( 'Manage Signups', 'buddypress' ),
|
418 |
+
__( 'Manage Signups', 'buddypress' ),
|
419 |
+
$this->capability,
|
420 |
+
'bp-signups',
|
421 |
+
array( $this, 'signups_admin' )
|
422 |
+
);
|
423 |
+
}
|
424 |
|
425 |
+
$edit_page = 'user-edit';
|
426 |
+
$profile_page = 'profile';
|
427 |
+
$this->users_page = 'users';
|
428 |
|
429 |
+
// Self profile check is needed for this pages
|
430 |
+
$page_head = array(
|
431 |
+
$edit_page . '.php',
|
432 |
+
$profile_page . '.php',
|
433 |
+
$this->user_page,
|
434 |
+
$this->users_page . '.php',
|
435 |
+
);
|
436 |
+
|
437 |
+
// Append '-network' to each array item if in network admin
|
438 |
+
if ( is_network_admin() ) {
|
439 |
$edit_page .= '-network';
|
440 |
+
$profile_page .= '-network';
|
441 |
$this->user_page .= '-network';
|
442 |
+
$this->users_page .= '-network';
|
443 |
$this->signups_page .= '-network';
|
444 |
}
|
445 |
|
446 |
+
// Setup the screen ID's
|
447 |
+
$this->screen_id = array(
|
448 |
+
$edit_page,
|
449 |
+
$this->user_page,
|
450 |
+
$profile_page
|
451 |
+
);
|
452 |
|
453 |
+
// Loop through new hooks and add method actions
|
454 |
foreach ( $hooks as $key => $hook ) {
|
455 |
+
add_action( "load-{$hook}", array( $this, $key . '_admin_load' ) );
|
456 |
}
|
457 |
|
458 |
+
// Add the profile_admin_head method to proper admin_head actions
|
459 |
+
foreach ( $page_head as $head ) {
|
460 |
+
add_action( "admin_head-{$head}", array( $this, 'profile_admin_head' ) );
|
461 |
+
}
|
462 |
}
|
463 |
|
464 |
/**
|
465 |
* Highlight the Users menu if on Edit Profile.
|
466 |
*
|
467 |
+
* + Check if on the user's admin profile
|
468 |
+
*
|
469 |
* @access public
|
470 |
+
* @since BuddyPress (2.1.0)
|
471 |
*/
|
472 |
+
public function profile_admin_head() {
|
473 |
+
global $submenu_file, $parent_file;
|
474 |
|
475 |
+
// Is the user editing their own profile?
|
476 |
+
if ( is_user_admin() || ( defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) ) {
|
477 |
+
$this->is_self_profile = true;
|
478 |
+
|
479 |
+
// Is the user attempting to edit their own profile
|
480 |
+
} else {
|
481 |
+
$this->is_self_profile = (bool) ( $this->get_user_id() === $this->current_user_id );
|
482 |
+
}
|
483 |
+
|
484 |
+
// Force the parent file to users.php to open the correct top level menu
|
485 |
+
// but only if not editing a site via the network site editing page.
|
486 |
+
if ( 'sites.php' !== $parent_file ) {
|
487 |
+
$parent_file = 'users.php';
|
488 |
$submenu_file = 'users.php';
|
489 |
}
|
490 |
+
|
491 |
+
// Editing your own profile, so recheck some vars
|
492 |
+
if ( true === $this->is_self_profile ) {
|
493 |
+
|
494 |
+
// Use profile.php as the edit page
|
495 |
+
$edit_page = 'profile.php';
|
496 |
+
|
497 |
+
// Set profile.php as the parent & sub files to correct the menu nav
|
498 |
+
if ( is_blog_admin() || is_user_admin() ) {
|
499 |
+
$parent_file = 'profile.php';
|
500 |
+
$submenu_file = 'profile.php';
|
501 |
+
}
|
502 |
+
|
503 |
+
// Not editing yourself, so use user-edit.php
|
504 |
+
} else {
|
505 |
+
$edit_page = 'user-edit.php';
|
506 |
+
}
|
507 |
+
|
508 |
+
if ( is_user_admin() ) {
|
509 |
+
$this->edit_profile_url = add_query_arg( $this->edit_profile_args, user_admin_url( 'profile.php' ) );
|
510 |
+
$this->edit_url = user_admin_url( 'profile.php' );
|
511 |
+
|
512 |
+
} elseif ( is_blog_admin() ) {
|
513 |
+
$this->edit_profile_url = add_query_arg( $this->edit_profile_args, admin_url( 'users.php' ) );
|
514 |
+
$this->edit_url = admin_url( $edit_page );
|
515 |
+
|
516 |
+
} elseif ( is_network_admin() ) {
|
517 |
+
$this->edit_profile_url = add_query_arg( $this->edit_profile_args, network_admin_url( 'users.php' ) );
|
518 |
+
$this->edit_url = network_admin_url( $edit_page );
|
519 |
+
}
|
520 |
}
|
521 |
|
522 |
/**
|
530 |
* @since BuddyPress (2.0.0)
|
531 |
*/
|
532 |
public function admin_head() {
|
533 |
+
remove_submenu_page( 'users.php', 'bp-profile-edit' );
|
534 |
+
remove_submenu_page( 'profile.php', 'bp-profile-edit' );
|
535 |
}
|
536 |
|
537 |
+
/** Community Profile *****************************************************/
|
538 |
|
539 |
/**
|
540 |
* Add some specific styling to the Edit User and Edit User's Profile page.
|
548 |
}
|
549 |
|
550 |
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
|
|
551 |
$css = $this->css_url . "admin{$min}.css";
|
552 |
$css = apply_filters( 'bp_members_admin_css', $css );
|
553 |
+
|
554 |
wp_enqueue_style( 'bp-members-css', $css, array(), bp_get_version() );
|
555 |
|
556 |
+
wp_style_add_data( 'bp-members-css', 'rtl', true );
|
557 |
+
if ( $min ) {
|
558 |
+
wp_style_add_data( 'bp-members-css', 'suffix', $min );
|
559 |
+
}
|
560 |
+
|
561 |
// Only load javascript for BuddyPress profile
|
562 |
if ( get_current_screen()->id == $this->user_page ) {
|
563 |
$js = $this->js_url . "admin{$min}.js";
|
577 |
*/
|
578 |
public function profile_nav( $user = null, $active = 'WordPress' ) {
|
579 |
|
580 |
+
// Bail if no user ID exists here
|
581 |
if ( empty( $user->ID ) ) {
|
582 |
return;
|
583 |
}
|
584 |
|
585 |
+
// Add the user ID to query agruments when not editing yourself
|
586 |
+
if ( false === $this->is_self_profile ) {
|
587 |
+
$query_args = array( 'user_id' => $user->ID );
|
588 |
+
} else {
|
589 |
+
$query_args = array();
|
590 |
}
|
591 |
|
592 |
+
// Conditionally add a referer if it exists in the existing request
|
|
|
593 |
if ( ! empty( $_REQUEST['wp_http_referer'] ) ) {
|
594 |
$query_args['wp_http_referer'] = urlencode( stripslashes_deep( $_REQUEST['wp_http_referer'] ) );
|
595 |
}
|
596 |
|
597 |
+
// Setup the two distinct "edit" URL's
|
598 |
$community_url = add_query_arg( $query_args, $this->edit_profile_url );
|
599 |
$wordpress_url = add_query_arg( $query_args, $this->edit_url );
|
600 |
|
605 |
$wp_active = false;
|
606 |
} ?>
|
607 |
|
608 |
+
<h2 id="profile-nav" class="nav-tab-wrapper">
|
609 |
<?php
|
610 |
/**
|
611 |
* In configs where BuddyPress is not network activated, as regular
|
612 |
* admins do not have the capacity to edit other users, we must add
|
613 |
* this check.
|
614 |
*/
|
615 |
+
if ( current_user_can( 'edit_user', $user->ID ) ) : ?>
|
|
|
|
|
|
|
|
|
616 |
|
617 |
+
<a class="nav-tab<?php echo esc_attr( $wp_active ); ?>" href="<?php echo esc_url( $wordpress_url );?>"><?php _e( 'Profile', 'buddypress' ); ?></a>
|
618 |
+
|
619 |
+
<?php endif; ?>
|
620 |
+
|
621 |
+
<a class="nav-tab<?php echo esc_attr( $bp_active ); ?>" href="<?php echo esc_url( $community_url );?>"><?php _e( 'Extended Profile', 'buddypress' ); ?></a>
|
622 |
+
</h2>
|
623 |
|
624 |
<?php
|
625 |
}
|
636 |
*/
|
637 |
public function user_admin_load() {
|
638 |
|
639 |
+
// Get the user ID
|
640 |
+
$user_id = $this->get_user_id();
|
|
|
641 |
|
642 |
+
// can current user edit this profile ?
|
643 |
+
if ( ! $this->member_can_edit( $user_id ) ) {
|
644 |
+
wp_die( __( 'You cannot edit the requested user.', 'buddypress' ) );
|
645 |
}
|
646 |
|
647 |
// Build redirection URL
|
648 |
$redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham', 'delete_avatar' ), $_SERVER['REQUEST_URI'] );
|
649 |
+
$doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : false;
|
650 |
|
651 |
if ( ! empty( $_REQUEST['user_status'] ) ) {
|
652 |
+
$spam = (bool) ( 'spam' === $_REQUEST['user_status'] );
|
653 |
|
654 |
+
if ( $spam !== bp_is_user_spammer( $user_id ) ) {
|
655 |
$doaction = $_REQUEST['user_status'];
|
656 |
}
|
657 |
}
|
683 |
);
|
684 |
|
685 |
// Register metaboxes for the edit screen.
|
686 |
+
add_meta_box(
|
687 |
+
'submitdiv',
|
688 |
+
_x( 'Status', 'members user-admin edit screen', 'buddypress' ),
|
689 |
+
array( $this, 'user_admin_status_metabox' ),
|
690 |
+
get_current_screen()->id,
|
691 |
+
'side',
|
692 |
+
'core'
|
693 |
+
);
|
694 |
|
695 |
// In case xprofile is not active
|
696 |
+
$this->stats_metabox->context = 'normal';
|
697 |
$this->stats_metabox->priority = 'core';
|
698 |
|
699 |
/**
|
703 |
do_action_ref_array( 'bp_members_admin_xprofile_metabox', array( $user_id, get_current_screen()->id, $this->stats_metabox ) );
|
704 |
|
705 |
// If xProfile is inactive, difficult to know what's profile we're on
|
706 |
+
if ( 'normal' === $this->stats_metabox->context ) {
|
707 |
+
$display_name = bp_core_get_user_displayname( $user_id );
|
708 |
+
} else {
|
709 |
+
$display_name = __( 'Member', 'buddypress' );
|
710 |
}
|
711 |
|
712 |
// User Stat metabox
|
713 |
+
add_meta_box(
|
714 |
+
'bp_members_admin_user_stats',
|
715 |
+
sprintf( _x( "%s's Stats", 'members user-admin edit screen', 'buddypress' ), $display_name ),
|
716 |
+
array( $this, 'user_admin_stats_metabox' ),
|
717 |
+
get_current_screen()->id,
|
718 |
+
sanitize_key( $this->stats_metabox->context ),
|
719 |
+
sanitize_key( $this->stats_metabox->priority )
|
720 |
+
);
|
721 |
|
722 |
+
/**
|
723 |
+
* Custom metabox ?
|
724 |
+
* Plugins can restrict metabox to "bp_moderate" admins checking
|
725 |
+
* the first argument ($this->is_self_profile) is false in their hook
|
726 |
+
* They can also restruct their metabox to self profile editing
|
727 |
+
* by cheking it set to true.
|
728 |
+
*/
|
729 |
+
do_action( 'bp_members_admin_user_metaboxes', $this->is_self_profile, $user_id );
|
730 |
|
731 |
// Enqueue javascripts
|
732 |
+
wp_enqueue_script( 'postbox' );
|
733 |
wp_enqueue_script( 'dashboard' );
|
734 |
|
735 |
// Spam or Ham user
|
736 |
+
} elseif ( in_array( $doaction, array( 'spam', 'ham' ) ) && empty( $this->is_self_profile ) ) {
|
737 |
|
738 |
check_admin_referer( 'edit-bp-profile_' . $user_id );
|
739 |
|
763 |
*/
|
764 |
public function user_admin() {
|
765 |
|
766 |
+
if ( ! bp_current_user_can( 'bp_moderate' ) && empty( $this->is_self_profile ) ) {
|
767 |
die( '-1' );
|
768 |
}
|
769 |
|
770 |
+
// Get the user ID
|
771 |
+
$user_id = $this->get_user_id();
|
772 |
+
$user = get_user_to_edit( $user_id );
|
773 |
+
|
774 |
+
// Construct title
|
775 |
+
if ( true === $this->is_self_profile ) {
|
776 |
+
$title = __( 'Profile', 'buddypress' );
|
777 |
+
} else {
|
778 |
+
$title = __( 'Edit User', 'buddypress' );
|
779 |
+
}
|
780 |
|
781 |
// Construct URL for form
|
782 |
+
$request_url = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham' ), $_SERVER['REQUEST_URI'] );
|
783 |
+
$form_action_url = add_query_arg( 'action', 'update', $request_url );
|
784 |
+
$wp_http_referer = false;
|
785 |
+
if ( ! empty( $_REQUEST['wp_http_referer'] ) ) {
|
786 |
+
$wp_http_referer = remove_query_arg( array( 'action', 'updated' ), $_REQUEST['wp_http_referer'] );
|
787 |
+
}
|
788 |
|
789 |
// Prepare notice for admin
|
790 |
+
$notice = $this->get_user_notice();
|
791 |
|
792 |
+
if ( ! empty( $notice ) ) : ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
793 |
|
794 |
+
<div <?php if ( 'updated' === $notice['class'] ) : ?>id="message" <?php endif; ?>class="<?php echo esc_attr( $notice['class'] ); ?>">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
795 |
|
|
|
|
|
|
|
|
|
|
|
|
|
796 |
<p><?php echo esc_html( $notice['message'] ); ?></p>
|
797 |
+
|
798 |
<?php if ( !empty( $wp_http_referer ) && ( 'updated' === $notice['class'] ) ) : ?>
|
799 |
+
|
800 |
<p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php esc_html_e( '← Back to Users', 'buddypress' ); ?></a></p>
|
801 |
+
|
802 |
<?php endif; ?>
|
803 |
+
|
804 |
</div>
|
805 |
+
|
806 |
<?php endif; ?>
|
807 |
|
808 |
+
<div class="wrap" id="community-profile-page">
|
809 |
<?php screen_icon( 'users' ); ?>
|
810 |
+
<h2><?php echo esc_html( $title ); ?>
|
811 |
+
|
812 |
+
<?php if ( empty( $this->is_self_profile ) ) : ?>
|
813 |
+
|
814 |
+
<?php if ( current_user_can( 'create_users' ) ) : ?>
|
815 |
+
|
816 |
+
<a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user', 'buddypress' ); ?></a>
|
817 |
+
|
818 |
+
<?php elseif ( is_multisite() && current_user_can( 'promote_users' ) ) : ?>
|
819 |
+
|
820 |
+
<a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user', 'buddypress' ); ?></a>
|
821 |
+
|
822 |
+
<?php endif; ?>
|
823 |
+
|
824 |
+
<?php endif; ?>
|
825 |
</h2>
|
826 |
|
827 |
<?php if ( ! empty( $user ) ) :
|
828 |
|
829 |
$this->profile_nav( $user, 'BuddyPress' ); ?>
|
830 |
|
831 |
+
<form action="<?php echo esc_url( $form_action_url ); ?>" id="your-profile" method="post">
|
832 |
<div id="poststuff">
|
833 |
|
834 |
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
|
854 |
</form>
|
855 |
|
856 |
<?php else : ?>
|
857 |
+
|
858 |
<p><?php printf( __( 'No user found with this ID. <a href="%s">Go back and try again</a>.', 'buddypress' ), esc_url( bp_get_admin_url( 'users.php' ) ) ); ?></p>
|
859 |
+
|
860 |
<?php endif; ?>
|
861 |
|
862 |
</div><!-- .wrap -->
|
882 |
return;
|
883 |
}
|
884 |
|
885 |
+
// Bail if user has not been activated yet (how didy ou get here?)
|
886 |
+
if ( isset( $user->user_status ) && ( 2 == $user->user_status ) ) : ?>
|
887 |
+
|
888 |
+
<p class="not-activated"><?php esc_html_e( 'User account has not yet been activated', 'buddypress' ); ?></p><br/>
|
889 |
+
|
890 |
+
<?php return;
|
891 |
+
|
892 |
+
endif; ?>
|
893 |
|
894 |
<div class="submitbox" id="submitcomment">
|
895 |
<div id="minor-publishing">
|
896 |
<div id="misc-publishing-actions">
|
897 |
<?php
|
898 |
+
|
899 |
+
// Get the spam status once here to compare against below
|
900 |
+
$is_spammer = bp_is_user_spammer( $user->ID );
|
901 |
+
|
902 |
/**
|
903 |
+
* In configs where BuddyPress is not network activated,
|
904 |
+
* regular admins cannot mark a user as a spammer on front
|
905 |
+
* end. This prevent them to do it in backend.
|
906 |
+
*
|
907 |
+
* Also prevent admins from marking themselves or other
|
908 |
+
* admins as spammers.
|
909 |
*/
|
910 |
+
if ( ( empty( $this->is_self_profile ) && ( ! in_array( $user->user_login, get_super_admins() ) ) && empty( $this->subsite_activated ) ) || ( ! empty( $this->subsite_activated ) && current_user_can( 'manage_network_users' ) ) ) : ?>
|
911 |
+
|
912 |
<div class="misc-pub-section" id="comment-status-radio">
|
913 |
+
<label class="approved"><input type="radio" name="user_status" value="ham" <?php checked( $is_spammer, false ); ?>><?php esc_html_e( 'Active', 'buddypress' ); ?></label><br />
|
914 |
+
<label class="spam"><input type="radio" name="user_status" value="spam" <?php checked( $is_spammer, true ); ?>><?php esc_html_e( 'Spammer', 'buddypress' ); ?></label>
|
915 |
</div>
|
916 |
+
|
917 |
<?php endif ;?>
|
918 |
|
919 |
<div class="misc-pub-section curtime misc-pub-section-last">
|
920 |
<?php
|
921 |
+
|
922 |
// translators: Publish box date format, see http://php.net/date
|
923 |
$datef = __( 'M j, Y @ G:i', 'buddypress' );
|
924 |
$date = date_i18n( $datef, strtotime( $user->user_registered ) );
|
953 |
* @param WP_User $user The WP_User object to be edited.
|
954 |
*/
|
955 |
public function user_admin_spammer_metabox( $user = null ) {
|
956 |
+
?>
|
957 |
<p><?php printf( __( '%s has been marked as a spammer. All BuddyPress data associated with the user has been removed', 'buddypress' ), esc_html( bp_core_get_user_displayname( $user->ID ) ) ) ;?></p>
|
958 |
+
<?php
|
959 |
}
|
960 |
|
961 |
/**
|
968 |
*/
|
969 |
public function user_admin_stats_metabox( $user = null ) {
|
970 |
|
971 |
+
// Bail if no user ID
|
972 |
if ( empty( $user->ID ) ) {
|
973 |
return;
|
974 |
}
|
986 |
$date = date_i18n( $datef, strtotime( $last_active ) ); ?>
|
987 |
|
988 |
<ul>
|
989 |
+
<li class="bp-members-profile-stats"><?php printf( __( 'Last active: %1$s', 'buddypress' ), '<strong>' . $date . '</strong>' ); ?></li>
|
990 |
|
991 |
<?php
|
992 |
// Loading other stats only if user has activated their account
|
1010 |
* @return array Merged actions.
|
1011 |
*/
|
1012 |
public function row_actions( $actions = '', $user = null ) {
|
1013 |
+
|
1014 |
+
// Bail if no user ID
|
1015 |
+
if ( empty( $user->ID ) ) {
|
1016 |
+
return;
|
1017 |
}
|
1018 |
|
1019 |
+
// Setup args array
|
1020 |
+
$args = array();
|
1021 |
+
|
1022 |
+
// Add the user ID if it's not for the current user
|
1023 |
+
if ( $user->ID !== $this->current_user_id ) {
|
1024 |
+
$args['user_id'] = $user->ID;
|
1025 |
}
|
1026 |
|
1027 |
+
// Add the referer
|
1028 |
+
$args['wp_http_referer'] = urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) );
|
|
|
|
|
1029 |
|
1030 |
+
// Add the "Extended" link if the current user can edit this user
|
1031 |
+
if ( current_user_can( 'edit_user', $user->ID ) || bp_current_user_can( 'bp_moderate' ) ) {
|
1032 |
|
1033 |
+
// Add query args and setup the Extended link
|
1034 |
+
$edit_profile = add_query_arg( $args, $this->edit_profile_url );
|
1035 |
+
$edit_profile_link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $edit_profile ), esc_html__( 'Extended', 'buddypress' ) );
|
|
|
|
|
|
|
|
|
1036 |
|
1037 |
+
/**
|
1038 |
+
* Check the edit action is available
|
1039 |
+
* and preserve the order edit | profile | remove/delete
|
1040 |
+
*/
|
1041 |
+
if ( ! empty( $actions['edit'] ) ) {
|
1042 |
+
$edit_action = $actions['edit'];
|
1043 |
+
unset( $actions['edit'] );
|
1044 |
+
|
1045 |
+
$new_edit_actions = array(
|
1046 |
+
'edit' => $edit_action,
|
1047 |
+
'edit-profile' => $edit_profile_link,
|
1048 |
+
);
|
1049 |
+
|
1050 |
+
// If not available simply add the edit profile action
|
1051 |
+
} else {
|
1052 |
+
$new_edit_actions = array( 'edit-profile' => $edit_profile_link );
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
$actions = array_merge( $new_edit_actions, $actions );
|
1056 |
}
|
1057 |
|
1058 |
+
return $actions;
|
1059 |
+
}
|
1060 |
+
|
1061 |
+
/**
|
1062 |
+
* Add a filter to edit profile url in WP Admin Bar
|
1063 |
+
*
|
1064 |
+
* @access public
|
1065 |
+
* @since BuddyPress (2.1.0)
|
1066 |
+
*/
|
1067 |
+
public function add_edit_profile_url_filter() {
|
1068 |
+
add_filter( 'bp_members_edit_profile_url', array( $this, 'filter_adminbar_profile_link' ), 10, 3 );
|
1069 |
}
|
1070 |
|
1071 |
+
/**
|
1072 |
+
* Filter the profile url
|
1073 |
+
*
|
1074 |
+
* @access public
|
1075 |
+
* @since BuddyPress (2.1.0)
|
1076 |
+
*
|
1077 |
+
* @uses user_admin_url()
|
1078 |
+
*/
|
1079 |
+
public function filter_adminbar_profile_link( $profile_link = '', $url = '', $user_id = 0 ) {
|
1080 |
+
if ( ! is_super_admin( $user_id ) && is_admin() ) {
|
1081 |
+
$profile_link = user_admin_url( 'profile.php' );
|
1082 |
+
}
|
1083 |
+
return $profile_link;
|
1084 |
+
}
|
1085 |
+
|
1086 |
+
/**
|
1087 |
+
* Remove the filter to edit profile url in WP Admin Bar
|
1088 |
+
*
|
1089 |
+
* @access public
|
1090 |
+
* @since BuddyPress (2.1.0)
|
1091 |
+
*/
|
1092 |
+
public function remove_edit_profile_url_filter() {
|
1093 |
+
remove_filter( 'bp_members_edit_profile_url', array( $this, 'filter_adminbar_profile_link' ), 10, 3 );
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
/** Signups Management ****************************************************/
|
1097 |
|
1098 |
/**
|
1099 |
* Display the admin preferences about signups pagination.
|
1135 |
global $wpdb;
|
1136 |
|
1137 |
// Bail if this is an ajax request
|
1138 |
+
if ( defined( 'DOING_AJAX' ) ) {
|
1139 |
return;
|
1140 |
+
}
|
1141 |
|
1142 |
+
// Bail if updating BuddyPress
|
1143 |
if ( bp_is_update() ) {
|
1144 |
return;
|
1145 |
}
|
1146 |
|
1147 |
+
// Bail if there is no current admin screen
|
1148 |
+
if ( ! function_exists( 'get_current_screen' ) || ! get_current_screen() ) {
|
1149 |
return;
|
1150 |
}
|
1151 |
|
1152 |
+
// Bail if not on a users page
|
1153 |
+
if ( $this->users_page !== get_current_screen()->id ) {
|
1154 |
return;
|
1155 |
}
|
1156 |
|
1157 |
+
// Bail if already querying by an existing role
|
1158 |
if ( ! empty( $query->query_vars['role'] ) ) {
|
1159 |
return;
|
1160 |
}
|
1171 |
* @return array The views with the signup view added.
|
1172 |
*/
|
1173 |
public function signup_filter_view( $views = array() ) {
|
|
|
1174 |
|
1175 |
+
// Remove the 'current' class from All if we're on the signups view
|
|
|
|
|
|
|
1176 |
if ( $this->signups_page == get_current_screen()->id ) {
|
1177 |
$views['all'] = str_replace( 'class="current"', '', $views['all'] );
|
1178 |
+
$class = 'current';
|
1179 |
+
} else {
|
1180 |
+
$class = '';
|
1181 |
}
|
1182 |
|
1183 |
+
$signups = BP_Signup::count_signups();
|
1184 |
+
$url = add_query_arg( 'page', 'bp-signups', bp_get_admin_url( 'users.php' ) );
|
1185 |
+
$text = sprintf( _x( 'Pending %s', 'signup users', 'buddypress' ), '<span class="count">(' . number_format_i18n( $signups ) . ')</span>' );
|
1186 |
+
|
1187 |
+
$views['registered'] = sprintf( '<a href="%1$s" class="%2$s">%3$s</a>', $url, $class, $text );
|
1188 |
|
1189 |
return $views;
|
1190 |
}
|
1227 |
|
1228 |
// Build redirection URL
|
1229 |
$redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'activated', 'notactivated', 'deleted', 'notdeleted', 'resent', 'notresent', 'do_delete', 'do_resend', 'do_activate', '_wpnonce', 'signup_ids' ), $_SERVER['REQUEST_URI'] );
|
1230 |
+
$doaction = bp_admin_list_table_current_bulk_action();
|
1231 |
|
1232 |
// Call an action for plugins to hook in early
|
1233 |
do_action( 'bp_signups_admin_load', $doaction, $_REQUEST );
|
1236 |
$allowed_actions = apply_filters( 'bp_signups_admin_allowed_actions', array( 'do_delete', 'do_activate', 'do_resend' ) );
|
1237 |
|
1238 |
// Prepare the display of the Community Profile screen
|
1239 |
+
if ( ! in_array( $doaction, $allowed_actions ) || ( -1 == $doaction ) ) {
|
1240 |
|
1241 |
if ( bp_core_do_network_admin() ) {
|
1242 |
$bp_members_signup_list_table = self::get_list_table_class( 'BP_Members_MS_List_Table', 'ms-users' );
|
1280 |
|
1281 |
// Handle resent activation links
|
1282 |
if ( 'do_resend' == $doaction ) {
|
1283 |
+
|
1284 |
// nonce check
|
1285 |
check_admin_referer( 'signups_resend' );
|
1286 |
|
1307 |
|
1308 |
// Handle activated accounts
|
1309 |
} else if ( 'do_activate' == $doaction ) {
|
1310 |
+
|
1311 |
// nonce check
|
1312 |
check_admin_referer( 'signups_activate' );
|
1313 |
|
1334 |
|
1335 |
// Handle sign-ups delete
|
1336 |
} else if ( 'do_delete' == $doaction ) {
|
1337 |
+
|
1338 |
// nonce check
|
1339 |
check_admin_referer( 'signups_delete' );
|
1340 |
|
1376 |
* @since BuddyPress (2.0.0)
|
1377 |
*/
|
1378 |
public function signups_display_errors() {
|
1379 |
+
|
1380 |
+
// Look for sign-up errors
|
1381 |
+
$errors = get_transient( '_bp_admin_signups_errors' );
|
1382 |
+
|
1383 |
// Bail if no activation errors
|
1384 |
+
if ( empty( $errors ) ) {
|
1385 |
return;
|
1386 |
}
|
1387 |
|
1388 |
+
// Loop through errors and display them
|
1389 |
+
foreach ( $errors as $error ) : ?>
|
1390 |
+
|
1391 |
<li><?php echo esc_html( $error[0] );?>: <?php echo esc_html( $error[1] );?></li>
|
1392 |
+
|
1393 |
+
<?php endforeach;
|
1394 |
|
1395 |
// Delete the redirect transient
|
1396 |
delete_transient( '_bp_admin_signups_errors' );
|
1397 |
}
|
1398 |
|
1399 |
/**
|
1400 |
+
* Get admin notice when viewing the sign-up page
|
1401 |
*
|
1402 |
+
* @since BuddyPress (2.1.0)
|
|
|
|
|
|
|
|
|
|
|
|
|
1403 |
*
|
1404 |
+
* @return array
|
1405 |
*/
|
1406 |
+
private function get_signup_notice() {
|
|
|
1407 |
|
1408 |
+
// Setup empty notice for return value
|
1409 |
$notice = array();
|
1410 |
|
1411 |
+
// Updates
|
1412 |
if ( ! empty( $_REQUEST['updated'] ) ) {
|
1413 |
switch ( $_REQUEST['updated'] ) {
|
1414 |
case 'resent':
|
1515 |
}
|
1516 |
}
|
1517 |
|
1518 |
+
// Errors
|
1519 |
if ( ! empty( $_REQUEST['error'] ) ) {
|
1520 |
switch ( $_REQUEST['error'] ) {
|
1521 |
case 'do_resend':
|
1541 |
}
|
1542 |
}
|
1543 |
|
1544 |
+
return $notice;
|
1545 |
+
}
|
1546 |
+
|
1547 |
+
/**
|
1548 |
+
* Signups admin page router.
|
1549 |
+
*
|
1550 |
+
* Depending on the context, display
|
1551 |
+
* - the list of signups
|
1552 |
+
* - or the delete confirmation screen
|
1553 |
+
* - or the activate confirmation screen
|
1554 |
+
* - or the "resend" email confirmation screen
|
1555 |
+
*
|
1556 |
+
* Also prepare the admin notices.
|
1557 |
+
*
|
1558 |
+
* @since BuddyPress (2.0.0)
|
1559 |
+
*/
|
1560 |
+
public function signups_admin() {
|
1561 |
+
$doaction = bp_admin_list_table_current_bulk_action();
|
1562 |
+
|
1563 |
+
// Prepare notices for admin
|
1564 |
+
$notice = $this->get_signup_notice();
|
1565 |
+
|
1566 |
// Display notices
|
1567 |
if ( ! empty( $notice ) ) :
|
1568 |
if ( 'updated' === $notice['class'] ) : ?>
|
1569 |
+
|
1570 |
<div id="message" class="<?php echo esc_attr( $notice['class'] ); ?>">
|
1571 |
+
|
1572 |
<?php else: ?>
|
1573 |
+
|
1574 |
<div class="<?php echo esc_attr( $notice['class'] ); ?>">
|
1575 |
+
|
1576 |
<?php endif; ?>
|
1577 |
+
|
1578 |
<p><?php echo $notice['message']; ?></p>
|
1579 |
+
|
1580 |
<?php if ( ! empty( $_REQUEST['notactivated'] ) || ! empty( $_REQUEST['notdeleted'] ) || ! empty( $_REQUEST['notsent'] ) ) :?>
|
1581 |
+
|
1582 |
<ul><?php $this->signups_display_errors();?></ul>
|
1583 |
+
|
1584 |
<?php endif ;?>
|
1585 |
+
|
1586 |
</div>
|
1587 |
+
|
1588 |
<?php endif;
|
1589 |
|
1590 |
// Show the proper screen
|
1652 |
|
1653 |
<div class="wrap">
|
1654 |
<?php screen_icon( 'users' ); ?>
|
1655 |
+
<h2><?php _e( 'Users', 'buddypress' ); ?>
|
1656 |
+
|
1657 |
+
<?php if ( current_user_can( 'create_users' ) ) : ?>
|
1658 |
+
|
1659 |
<a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user', 'buddypress' ); ?></a>
|
1660 |
+
|
1661 |
+
<?php elseif ( is_multisite() && current_user_can( 'promote_users' ) ) : ?>
|
1662 |
+
|
1663 |
<a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user', 'buddypress' ); ?></a>
|
1664 |
+
|
1665 |
+
<?php endif;
|
1666 |
|
1667 |
if ( $usersearch ) {
|
1668 |
printf( '<span class="subtitle">' . __( 'Search results for “%s”', 'buddypress' ) . '</span>', esc_html( $usersearch ) );
|
1676 |
|
1677 |
<form id="bp-signups-search-form" action="<?php echo esc_url( $search_form_url ) ;?>">
|
1678 |
<input type="hidden" name="page" value="<?php echo esc_attr( $plugin_page ); ?>" />
|
1679 |
+
<?php $bp_members_signup_list_table->search_box( __( 'Search Pending Users', 'buddypress' ), 'bp-signups' ); ?>
|
1680 |
</form>
|
1681 |
|
1682 |
<form id="bp-signups-form" action="<?php echo esc_url( $form_url );?>" method="post">
|
1764 |
|
1765 |
<ol class="bp-signups-list">
|
1766 |
<?php foreach ( $signups as $signup ) :
|
1767 |
+
|
1768 |
+
$last_notified = mysql2date( 'Y/m/d g:i:s a', $signup->date_sent ); ?>
|
1769 |
|
1770 |
<li>
|
1771 |
<?php echo esc_html( $signup->user_name ) ?> - <?php echo sanitize_email( $signup->user_email );?>
|
1772 |
|
1773 |
<?php if ( 'resend' == $action ) : ?>
|
1774 |
+
|
1775 |
<p class="description">
|
1776 |
<?php printf( esc_html__( 'Last notified: %s', 'buddypress'), $last_notified ) ;?>
|
1777 |
|
1778 |
<?php if ( ! empty( $signup->recently_sent ) ) : ?>
|
1779 |
+
|
1780 |
<span class="attention wp-ui-text-notification"> <?php esc_html_e( '(less than 24 hours ago)', 'buddypress' ); ?></span>
|
1781 |
+
|
1782 |
<?php endif; ?>
|
1783 |
</p>
|
1784 |
|
1785 |
<?php endif; ?>
|
1786 |
+
|
1787 |
</li>
|
1788 |
|
1789 |
<?php endforeach; ?>
|
1790 |
</ol>
|
1791 |
|
1792 |
+
<?php if ( 'delete' === $action ) : ?>
|
1793 |
+
|
1794 |
<p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ) ?></strong></p>
|
1795 |
+
|
1796 |
<?php endif ; ?>
|
1797 |
|
1798 |
<a class="button-primary" href="<?php echo esc_url( $action_url ); ?>"><?php esc_html_e( 'Confirm', 'buddypress' ); ?></a>
|
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* BuddyPress Members Toolbar
|
5 |
*
|
6 |
-
* Handles the member functions related to the WordPress Toolbar
|
7 |
*
|
8 |
* @package BuddyPress
|
9 |
* @subpackage MembersAdminBar
|
@@ -15,7 +15,8 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|
15 |
/**
|
16 |
* Add the "My Account" menu and all submenus.
|
17 |
*
|
18 |
-
* @since BuddyPress (1.6)
|
|
|
19 |
* @todo Deprecate WP 3.2 Toolbar compatibility when we drop 3.2 support
|
20 |
*/
|
21 |
function bp_members_admin_bar_my_account_menu() {
|
@@ -50,7 +51,7 @@ function bp_members_admin_bar_my_account_menu() {
|
|
50 |
$wp_admin_bar->add_menu( array(
|
51 |
'id' => 'bp-login',
|
52 |
'title' => __( 'Log in', 'buddypress' ),
|
53 |
-
'href' => wp_login_url(
|
54 |
) );
|
55 |
|
56 |
// Sign up
|
@@ -66,10 +67,9 @@ function bp_members_admin_bar_my_account_menu() {
|
|
66 |
add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_my_account_menu', 4 );
|
67 |
|
68 |
/**
|
69 |
-
*
|
70 |
*
|
71 |
-
* @
|
72 |
-
* @since BuddyPress (1.5)
|
73 |
*/
|
74 |
function bp_members_admin_bar_user_admin_menu() {
|
75 |
global $bp, $wp_admin_bar;
|
@@ -106,7 +106,7 @@ function bp_members_admin_bar_user_admin_menu() {
|
|
106 |
$wp_admin_bar->add_menu( array(
|
107 |
'parent' => $bp->user_admin_menu_id,
|
108 |
'id' => $bp->user_admin_menu_id . '-change-avatar',
|
109 |
-
'title' => __( "Edit
|
110 |
'href' => bp_get_members_component_link( 'profile', 'change-avatar' )
|
111 |
) );
|
112 |
}
|
@@ -136,10 +136,9 @@ function bp_members_admin_bar_user_admin_menu() {
|
|
136 |
add_action( 'admin_bar_menu', 'bp_members_admin_bar_user_admin_menu', 99 );
|
137 |
|
138 |
/**
|
139 |
-
* Build the "Notifications" dropdown
|
140 |
*
|
141 |
-
* @
|
142 |
-
* @since BuddyPress (1.5)
|
143 |
*/
|
144 |
function bp_members_admin_bar_notifications_menu() {
|
145 |
|
@@ -153,9 +152,9 @@ function bp_members_admin_bar_notifications_menu() {
|
|
153 |
add_action( 'admin_bar_menu', 'bp_members_admin_bar_notifications_menu', 90 );
|
154 |
|
155 |
/**
|
156 |
-
* Remove rogue WP core
|
157 |
*
|
158 |
-
* @since BuddyPress (1.6)
|
159 |
*/
|
160 |
function bp_members_remove_edit_page_menu() {
|
161 |
if ( bp_is_user() ) {
|
3 |
/**
|
4 |
* BuddyPress Members Toolbar
|
5 |
*
|
6 |
+
* Handles the member functions related to the WordPress Toolbar.
|
7 |
*
|
8 |
* @package BuddyPress
|
9 |
* @subpackage MembersAdminBar
|
15 |
/**
|
16 |
* Add the "My Account" menu and all submenus.
|
17 |
*
|
18 |
+
* @since BuddyPress (1.6.0)
|
19 |
+
*
|
20 |
* @todo Deprecate WP 3.2 Toolbar compatibility when we drop 3.2 support
|
21 |
*/
|
22 |
function bp_members_admin_bar_my_account_menu() {
|
51 |
$wp_admin_bar->add_menu( array(
|
52 |
'id' => 'bp-login',
|
53 |
'title' => __( 'Log in', 'buddypress' ),
|
54 |
+
'href' => wp_login_url( bp_get_requested_url() )
|
55 |
) );
|
56 |
|
57 |
// Sign up
|
67 |
add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_my_account_menu', 4 );
|
68 |
|
69 |
/**
|
70 |
+
* Add the User Admin top-level menu to user pages.
|
71 |
*
|
72 |
+
* @since BuddyPress (1.5.0)
|
|
|
73 |
*/
|
74 |
function bp_members_admin_bar_user_admin_menu() {
|
75 |
global $bp, $wp_admin_bar;
|
106 |
$wp_admin_bar->add_menu( array(
|
107 |
'parent' => $bp->user_admin_menu_id,
|
108 |
'id' => $bp->user_admin_menu_id . '-change-avatar',
|
109 |
+
'title' => __( "Edit Profile Photo", 'buddypress' ),
|
110 |
'href' => bp_get_members_component_link( 'profile', 'change-avatar' )
|
111 |
) );
|
112 |
}
|
136 |
add_action( 'admin_bar_menu', 'bp_members_admin_bar_user_admin_menu', 99 );
|
137 |
|
138 |
/**
|
139 |
+
* Build the "Notifications" dropdown.
|
140 |
*
|
141 |
+
* @since BuddyPress (1.5.0)
|
|
|
142 |
*/
|
143 |
function bp_members_admin_bar_notifications_menu() {
|
144 |
|
152 |
add_action( 'admin_bar_menu', 'bp_members_admin_bar_notifications_menu', 90 );
|
153 |
|
154 |
/**
|
155 |
+
* Remove rogue WP core Edit menu when viewing a single user.
|
156 |
*
|
157 |
+
* @since BuddyPress (1.6.0)
|
158 |
*/
|
159 |
function bp_members_remove_edit_page_menu() {
|
160 |
if ( bp_is_user() ) {
|
@@ -1,116 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* BuddyPress Members BuddyBar
|
5 |
-
*
|
6 |
-
* Handles the member functions related to the BuddyBar
|
7 |
-
*
|
8 |
-
* @package BuddyPress
|
9 |
-
* @subpackage MembersBuddyBar
|
10 |
-
*/
|
11 |
-
|
12 |
-
// Exit if accessed directly
|
13 |
-
if ( !defined( 'ABSPATH' ) ) exit;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Notifications Menu
|
17 |
-
*/
|
18 |
-
function bp_adminbar_notifications_menu() {
|
19 |
-
|
20 |
-
// Bail if notifications is not active
|
21 |
-
if ( ! bp_is_active( 'notifications' ) ) {
|
22 |
-
return false;
|
23 |
-
}
|
24 |
-
|
25 |
-
bp_notifications_buddybar_menu();
|
26 |
-
}
|
27 |
-
add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Blog Authors Menu (visible when not logged in)
|
31 |
-
*/
|
32 |
-
function bp_adminbar_authors_menu() {
|
33 |
-
global $wpdb;
|
34 |
-
|
35 |
-
// Only for multisite
|
36 |
-
if ( !is_multisite() )
|
37 |
-
return false;
|
38 |
-
|
39 |
-
// Hide on root blog
|
40 |
-
if ( $wpdb->blogid == bp_get_root_blog_id() || !bp_is_active( 'blogs' ) )
|
41 |
-
return false;
|
42 |
-
|
43 |
-
$blog_prefix = $wpdb->get_blog_prefix( $wpdb->blogid );
|
44 |
-
$authors = $wpdb->get_results( "SELECT user_id, user_login, user_nicename, display_name, user_email, meta_value as caps FROM $wpdb->users u, $wpdb->usermeta um WHERE u.ID = um.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY um.user_id" );
|
45 |
-
|
46 |
-
if ( !empty( $authors ) ) {
|
47 |
-
// This is a blog, render a menu with links to all authors
|
48 |
-
echo '<li id="bp-adminbar-authors-menu"><a href="/">';
|
49 |
-
_e('Blog Authors', 'buddypress');
|
50 |
-
echo '</a>';
|
51 |
-
|
52 |
-
echo '<ul class="author-list">';
|
53 |
-
foreach( (array) $authors as $author ) {
|
54 |
-
$caps = maybe_unserialize( $author->caps );
|
55 |
-
if ( isset( $caps['subscriber'] ) || isset( $caps['contributor'] ) ) continue;
|
56 |
-
|
57 |
-
echo '<li>';
|
58 |
-
echo '<a href="' . bp_core_get_user_domain( $author->user_id, $author->user_nicename, $author->user_login ) . '">';
|
59 |
-
echo bp_core_fetch_avatar( array(
|
60 |
-
'item_id' => $author->user_id,
|
61 |
-
'email' => $author->user_email,
|
62 |
-
'width' => 15,
|
63 |
-
'height' => 15,
|
64 |
-
'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), $author->display_name )
|
65 |
-
) );
|
66 |
-
echo ' ' . $author->display_name . '</a>';
|
67 |
-
echo '<div class="admin-bar-clear"></div>';
|
68 |
-
echo '</li>';
|
69 |
-
}
|
70 |
-
echo '</ul>';
|
71 |
-
echo '</li>';
|
72 |
-
}
|
73 |
-
}
|
74 |
-
add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Adds an Toolbar menu to any profile page providing site moderator actions
|
78 |
-
* that allow capable users to clean up a users account.
|
79 |
-
*
|
80 |
-
* @package BuddyPress XProfile
|
81 |
-
*/
|
82 |
-
function bp_members_adminbar_admin_menu() {
|
83 |
-
|
84 |
-
// Only show if viewing a user
|
85 |
-
if ( !bp_displayed_user_id() )
|
86 |
-
return false;
|
87 |
-
|
88 |
-
// Don't show this menu to non site admins or if you're viewing your own profile
|
89 |
-
if ( !current_user_can( 'edit_users' ) || bp_is_my_profile() )
|
90 |
-
return false; ?>
|
91 |
-
|
92 |
-
<li id="bp-adminbar-adminoptions-menu">
|
93 |
-
|
94 |
-
<a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
|
95 |
-
|
96 |
-
<ul>
|
97 |
-
<?php if ( bp_is_active( 'xprofile' ) ) : ?>
|
98 |
-
|
99 |
-
<li><a href="<?php bp_members_component_link( 'profile', 'edit' ); ?>"><?php printf( __( "Edit %s's Profile", 'buddypress' ), esc_attr( bp_get_displayed_user_fullname() ) ) ?></a></li>
|
100 |
-
|
101 |
-
<?php endif ?>
|
102 |
-
|
103 |
-
<li><a href="<?php bp_members_component_link( 'profile', 'change-avatar' ); ?>"><?php printf( __( "Edit %s's Avatar", 'buddypress' ), esc_attr( bp_get_displayed_user_fullname() ) ) ?></a></li>
|
104 |
-
|
105 |
-
<li><a href="<?php bp_members_component_link( 'settings', 'capabilities' ); ?>"><?php _e( 'User Capabilities', 'buddypress' ); ?></a></li>
|
106 |
-
|
107 |
-
<li><a href="<?php bp_members_component_link( 'settings', 'delete-account' ); ?>"><?php printf( __( "Delete %s's Account", 'buddypress' ), esc_attr( bp_get_displayed_user_fullname() ) ); ?></a></li>
|
108 |
-
|
109 |
-
<?php do_action( 'bp_members_adminbar_admin_menu' ) ?>
|
110 |
-
|
111 |
-
</ul>
|
112 |
-
</li>
|
113 |
-
|
114 |
-
<?php
|
115 |
-
}
|
116 |
-
add_action( 'bp_adminbar_menus', 'bp_members_adminbar_admin_menu', 20 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -150,9 +150,8 @@ class BP_Signup {
|
|
150 |
|
151 |
// Search terms
|
152 |
if ( ! empty( $r['usersearch'] ) ) {
|
153 |
-
$
|
154 |
-
$
|
155 |
-
$sql['where'][] = "( user_login LIKE '%" . $search_terms_clean . "%' OR user_email LIKE '%" . $search_terms_clean . "%' OR meta LIKE '%" . $search_terms_clean . "%' )";
|
156 |
}
|
157 |
|
158 |
// Activation key
|
@@ -208,7 +207,7 @@ class BP_Signup {
|
|
208 |
$diff = $now - $sent_at;
|
209 |
|
210 |
/**
|
211 |
-
* add a boolean in case the last time an activation link
|
212 |
* has been sent happened less than a day ago
|
213 |
*/
|
214 |
if ( $diff < 1 * DAY_IN_SECONDS ) {
|
@@ -472,8 +471,8 @@ class BP_Signup {
|
|
472 |
*
|
473 |
* @since BuddyPress (2.0.0)
|
474 |
*
|
475 |
-
* @param array $signup_ids
|
476 |
-
* @return array
|
477 |
*/
|
478 |
public static function resend( $signup_ids = array() ) {
|
479 |
if ( empty( $signup_ids ) || ! is_array( $signup_ids ) ) {
|
@@ -539,8 +538,8 @@ class BP_Signup {
|
|
539 |
*
|
540 |
* @since BuddyPress (2.0.0)
|
541 |
*
|
542 |
-
* @param array $signup_ids Single
|
543 |
-
* @return array
|
544 |
*/
|
545 |
public static function activate( $signup_ids = array() ) {
|
546 |
if ( empty( $signup_ids ) || ! is_array( $signup_ids ) ) {
|
@@ -599,8 +598,8 @@ class BP_Signup {
|
|
599 |
*
|
600 |
* @since BuddyPress (2.0.0)
|
601 |
*
|
602 |
-
* @param array $signup_ids
|
603 |
-
* @return array
|
604 |
*/
|
605 |
public static function delete( $signup_ids = array() ) {
|
606 |
global $wpdb;
|
150 |
|
151 |
// Search terms
|
152 |
if ( ! empty( $r['usersearch'] ) ) {
|
153 |
+
$search_terms_like = '%' . bp_esc_like( $r['usersearch'] ) . '%';
|
154 |
+
$sql['where'][] = $wpdb->prepare( "( user_login LIKE %s OR user_email LIKE %s OR meta LIKE %s )", $search_terms_like, $search_terms_like, $search_terms_like );
|
|
|
155 |
}
|
156 |
|
157 |
// Activation key
|
207 |
$diff = $now - $sent_at;
|
208 |
|
209 |
/**
|
210 |
+
* add a boolean in case the last time an activation link
|
211 |
* has been sent happened less than a day ago
|
212 |
*/
|
213 |
if ( $diff < 1 * DAY_IN_SECONDS ) {
|
471 |
*
|
472 |
* @since BuddyPress (2.0.0)
|
473 |
*
|
474 |
+
* @param array $signup_ids Single ID or list of IDs to resend.
|
475 |
+
* @return array
|
476 |
*/
|
477 |
public static function resend( $signup_ids = array() ) {
|
478 |
if ( empty( $signup_ids ) || ! is_array( $signup_ids ) ) {
|
538 |
*
|
539 |
* @since BuddyPress (2.0.0)
|
540 |
*
|
541 |
+
* @param array $signup_ids Single ID or list of IDs to activate.
|
542 |
+
* @return array
|
543 |
*/
|
544 |
public static function activate( $signup_ids = array() ) {
|
545 |
if ( empty( $signup_ids ) || ! is_array( $signup_ids ) ) {
|
598 |
*
|
599 |
* @since BuddyPress (2.0.0)
|
600 |
*
|
601 |
+
* @param array $signup_ids Single ID or list of IDs to delete.
|
602 |
+
* @return array
|
603 |
*/
|
604 |
public static function delete( $signup_ids = array() ) {
|
605 |
global $wpdb;
|
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* BuddyPress Members Filters
|
5 |
*
|
6 |
-
*
|
7 |
*
|
8 |
* @package BuddyPress
|
9 |
* @subpackage MembersFilters
|
@@ -13,19 +13,20 @@
|
|
13 |
if ( !defined( 'ABSPATH' ) ) exit;
|
14 |
|
15 |
/**
|
16 |
-
* Escape commonly used fullname output functions
|
17 |
*/
|
18 |
add_filter( 'bp_displayed_user_fullname', 'esc_html' );
|
19 |
add_filter( 'bp_get_loggedin_user_fullname', 'esc_html' );
|
20 |
|
21 |
/**
|
22 |
-
* Load additional sign-up sanitization filters on bp_loaded.
|
23 |
-
* to prevent XSS in the BuddyPress sign-up process. You can unhook these to
|
24 |
-
* allow for customization of your registration fields, however it is highly
|
25 |
-
* recommended that you leave these in place for the safety of your network.
|
26 |
*
|
27 |
-
*
|
28 |
-
*
|
|
|
|
|
|
|
|
|
29 |
*/
|
30 |
function bp_members_signup_sanitization() {
|
31 |
|
@@ -53,12 +54,49 @@ function bp_members_signup_sanitization() {
|
|
53 |
add_action( 'bp_loaded', 'bp_members_signup_sanitization' );
|
54 |
|
55 |
/**
|
56 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
*
|
58 |
-
* @since BuddyPress 1.6
|
59 |
*
|
60 |
-
* @param string $url
|
61 |
-
* @param int $user_id
|
62 |
* @param string $scheme
|
63 |
* @return string
|
64 |
*/
|
3 |
/**
|
4 |
* BuddyPress Members Filters
|
5 |
*
|
6 |
+
* Filters specific to the Members component.
|
7 |
*
|
8 |
* @package BuddyPress
|
9 |
* @subpackage MembersFilters
|
13 |
if ( !defined( 'ABSPATH' ) ) exit;
|
14 |
|
15 |
/**
|
16 |
+
* Escape commonly used fullname output functions.
|
17 |
*/
|
18 |
add_filter( 'bp_displayed_user_fullname', 'esc_html' );
|
19 |
add_filter( 'bp_get_loggedin_user_fullname', 'esc_html' );
|
20 |
|
21 |
/**
|
22 |
+
* Load additional sign-up sanitization filters on bp_loaded.
|
|
|
|
|
|
|
23 |
*
|
24 |
+
* These are used to prevent XSS in the BuddyPress sign-up process. You can
|
25 |
+
* unhook these to allow for customization of your registration fields;
|
26 |
+
* however, it is highly recommended that you leave these in place for the
|
27 |
+
* safety of your network.
|
28 |
+
*
|
29 |
+
* @since BuddyPress (1.5.0)
|
30 |
*/
|
31 |
function bp_members_signup_sanitization() {
|
32 |
|
54 |
add_action( 'bp_loaded', 'bp_members_signup_sanitization' );
|
55 |
|
56 |
/**
|
57 |
+
* Make sure the username is not the blog slug in case of root profile & subdirectory blog
|
58 |
+
*
|
59 |
+
* If BP_ENABLE_ROOT_PROFILES is defined & multisite config is set to subdirectories,
|
60 |
+
* then there is a chance site.url/username == site.url/blogslug. If so, user's profile
|
61 |
+
* is not reachable, instead the blog is displayed. This filter makes sure the signup username
|
62 |
+
* is not the same than the blog slug for this particular config.
|
63 |
+
*
|
64 |
+
* @since BuddyPress (2.1.0)
|
65 |
+
* @param array $illegal_names
|
66 |
+
* @return array $illegal_names
|
67 |
+
*/
|
68 |
+
function bp_members_signup_with_subdirectory_blog( $illegal_names = array() ) {
|
69 |
+
if ( ! bp_core_enable_root_profiles() ) {
|
70 |
+
return $illegal_names;
|
71 |
+
}
|
72 |
+
|
73 |
+
if ( is_network_admin() && isset( $_POST['blog'] ) ) {
|
74 |
+
$blog = $_POST['blog'];
|
75 |
+
$domain = '';
|
76 |
+
|
77 |
+
if ( preg_match( '|^([a-zA-Z0-9-])$|', $blog['domain'] ) ) {
|
78 |
+
$domain = strtolower( $blog['domain'] );
|
79 |
+
}
|
80 |
+
|
81 |
+
if ( username_exists( $domain ) ) {
|
82 |
+
$illegal_names[] = $domain;
|
83 |
+
}
|
84 |
+
|
85 |
+
} else {
|
86 |
+
$illegal_names[] = buddypress()->signup->username;
|
87 |
+
}
|
88 |
+
|
89 |
+
return $illegal_names;
|
90 |
+
}
|
91 |
+
add_filter( 'subdirectory_reserved_names', 'bp_members_signup_with_subdirectory_blog', 10, 1 );
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Filter the user profile URL to point to BuddyPress profile edit.
|
95 |
*
|
96 |
+
* @since BuddyPress (1.6.0)
|
97 |
*
|
98 |
+
* @param string $url WP profile edit URL.
|
99 |
+
* @param int $user_id ID of the user.
|
100 |
* @param string $scheme
|
101 |
* @return string
|
102 |
*/
|
@@ -13,12 +13,11 @@
|
|
13 |
if ( !defined( 'ABSPATH' ) ) exit;
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
-
* @since BuddyPress (1.5)
|
19 |
*
|
20 |
-
* @
|
21 |
-
* @return bool True if set, False if empty
|
22 |
*/
|
23 |
function bp_members_has_directory() {
|
24 |
global $bp;
|
@@ -27,17 +26,18 @@ function bp_members_has_directory() {
|
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
-
* Define the
|
31 |
-
* These can be overridden manually by defining these slugs in wp-config.php.
|
32 |
*
|
33 |
-
*
|
34 |
-
*
|
|
|
|
|
35 |
*
|
36 |
-
*
|
37 |
-
*
|
38 |
*/
|
39 |
function bp_core_define_slugs() {
|
40 |
-
|
41 |
|
42 |
// No custom members slug
|
43 |
if ( !defined( 'BP_MEMBERS_SLUG' ) ) {
|
@@ -69,18 +69,35 @@ function bp_core_define_slugs() {
|
|
69 |
add_action( 'bp_setup_globals', 'bp_core_define_slugs', 11 );
|
70 |
|
71 |
/**
|
72 |
-
*
|
73 |
*
|
74 |
* Since BuddyPress 1.7, bp_core_get_users() uses BP_User_Query. If you
|
75 |
* need backward compatibility with BP_Core_User::get_users(), filter the
|
76 |
* bp_use_legacy_user_query value, returning true.
|
77 |
*
|
78 |
-
* @
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
*/
|
80 |
function bp_core_get_users( $args = '' ) {
|
81 |
|
82 |
// Parse the user query arguments
|
83 |
-
$
|
84 |
'type' => 'active', // active, newest, alphabetical, random or popular
|
85 |
'user_id' => false, // Pass a user_id to limit to only friend connections for this user
|
86 |
'exclude' => false, // Users to exclude from results
|
@@ -92,18 +109,28 @@ function bp_core_get_users( $args = '' ) {
|
|
92 |
'page' => 1, // The page to return if limiting per page
|
93 |
'populate_extras' => true, // Fetch the last active, where the user is a friend, total friend count, latest update
|
94 |
'count_total' => 'count_query' // What kind of total user count to do, if any. 'count_query', 'sql_calc_found_rows', or false
|
95 |
-
) );
|
96 |
|
97 |
// For legacy users. Use of BP_Core_User::get_users() is deprecated.
|
98 |
-
if ( apply_filters( 'bp_use_legacy_user_query', false, __FUNCTION__, $
|
99 |
-
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
// Default behavior as of BuddyPress 1.7
|
103 |
} else {
|
104 |
|
105 |
// Get users like we were asked to do...
|
106 |
-
$users = new BP_User_Query( $
|
107 |
|
108 |
// ...but reformat the results to match bp_core_get_users() behavior.
|
109 |
$retval = array(
|
@@ -112,17 +139,17 @@ function bp_core_get_users( $args = '' ) {
|
|
112 |
);
|
113 |
}
|
114 |
|
115 |
-
return apply_filters( 'bp_core_get_users', $retval, $
|
116 |
}
|
117 |
|
118 |
/**
|
119 |
-
*
|
120 |
*
|
121 |
-
* @package BuddyPress Core
|
122 |
-
* @global $current_user WordPress global variable containing current logged in user information
|
123 |
* @param int $user_id The ID of the user.
|
|
|
|
|
124 |
*/
|
125 |
-
function bp_core_get_user_domain( $user_id, $user_nicename = false, $user_login = false ) {
|
126 |
|
127 |
if ( empty( $user_id ) ) {
|
128 |
return;
|
@@ -147,13 +174,13 @@ function bp_core_get_user_domain( $user_id, $user_nicename = false, $user_login
|
|
147 |
/**
|
148 |
* Fetch everything in the wp_users table for a user, without any usermeta.
|
149 |
*
|
150 |
-
* @package BuddyPress Core
|
151 |
* @param int $user_id The ID of the user.
|
152 |
-
* @
|
153 |
*/
|
154 |
-
function bp_core_get_core_userdata( $user_id ) {
|
155 |
-
if ( empty( $user_id ) )
|
156 |
return false;
|
|
|
157 |
|
158 |
if ( !$userdata = wp_cache_get( 'bp_core_userdata_' . $user_id, 'bp' ) ) {
|
159 |
$userdata = BP_Core_User::get_core_userdata( $user_id );
|
@@ -163,57 +190,64 @@ function bp_core_get_core_userdata( $user_id ) {
|
|
163 |
}
|
164 |
|
165 |
/**
|
166 |
-
*
|
167 |
-
*
|
|
|
168 |
*
|
169 |
-
* @
|
170 |
-
*
|
171 |
-
* @
|
|
|
172 |
*/
|
173 |
function bp_core_get_displayed_userid( $user_login ) {
|
174 |
return apply_filters( 'bp_core_get_displayed_userid', bp_core_get_userid( $user_login ) );
|
175 |
}
|
176 |
|
177 |
/**
|
178 |
-
*
|
|
|
|
|
179 |
*
|
180 |
-
* @
|
181 |
-
* @
|
182 |
-
* @global $wpdb WordPress DB access object.
|
183 |
-
* @return int|bool The ID of the matched user, or false.
|
184 |
*/
|
185 |
-
function bp_core_get_userid( $username ) {
|
186 |
-
|
187 |
-
|
188 |
-
if ( empty( $username ) )
|
189 |
return false;
|
|
|
190 |
|
191 |
-
|
|
|
|
|
192 |
}
|
193 |
|
194 |
/**
|
195 |
-
*
|
|
|
|
|
196 |
*
|
197 |
-
* @
|
198 |
-
* @
|
199 |
-
* @global $wpdb WordPress DB access object.
|
200 |
-
* @return int|bool The ID of the matched user, or false.
|
201 |
*/
|
202 |
-
function bp_core_get_userid_from_nicename( $user_nicename ) {
|
203 |
-
|
204 |
-
|
205 |
-
if ( empty( $user_nicename ) )
|
206 |
return false;
|
|
|
|
|
|
|
207 |
|
208 |
-
return apply_filters( 'bp_core_get_userid_from_nicename',
|
209 |
}
|
210 |
|
211 |
/**
|
212 |
-
*
|
213 |
*
|
214 |
-
*
|
215 |
-
*
|
216 |
-
*
|
|
|
|
|
|
|
217 |
* @return string|bool The username of the matched user, or false.
|
218 |
*/
|
219 |
function bp_core_get_username( $user_id = 0, $user_nicename = false, $user_login = false ) {
|
@@ -280,20 +314,20 @@ function bp_core_get_username( $user_id = 0, $user_nicename = false, $user_login
|
|
280 |
}
|
281 |
|
282 |
/**
|
283 |
-
*
|
284 |
-
* used for linking to user profiles and anywhere else a sanitized and unique
|
285 |
-
* slug to a user is needed.
|
286 |
*
|
287 |
-
*
|
|
|
288 |
*
|
289 |
-
* @
|
290 |
-
*
|
291 |
-
* @
|
292 |
-
*
|
|
|
293 |
* @return string|bool The username of the matched user, or false.
|
294 |
*/
|
295 |
function bp_members_get_user_nicename( $user_id ) {
|
296 |
-
|
297 |
|
298 |
if ( !$user_nicename = wp_cache_get( 'bp_members_user_nicename_' . $user_id, 'bp' ) ) {
|
299 |
$update_cache = true;
|
@@ -329,30 +363,33 @@ function bp_members_get_user_nicename( $user_id ) {
|
|
329 |
}
|
330 |
|
331 |
// Add this to cache
|
332 |
-
if ( true == $update_cache && !empty( $user_nicename ) )
|
333 |
wp_cache_set( 'bp_members_user_nicename_' . $user_id, $user_nicename, 'bp' );
|
|
|
334 |
|
335 |
return apply_filters( 'bp_members_get_user_nicename', $user_nicename );
|
336 |
}
|
337 |
|
338 |
/**
|
339 |
-
*
|
340 |
*
|
341 |
-
* @package BuddyPress Core
|
342 |
* @param int $uid User ID to check.
|
343 |
-
* @
|
344 |
-
*
|
345 |
*/
|
346 |
function bp_core_get_user_email( $uid ) {
|
347 |
|
348 |
if ( !$email = wp_cache_get( 'bp_user_email_' . $uid, 'bp' ) ) {
|
|
|
349 |
// User exists
|
350 |
-
|
|
|
351 |
$email = $ud->user_email;
|
352 |
|
353 |
// User was deleted
|
354 |
-
else
|
355 |
$email = '';
|
|
|
356 |
|
357 |
wp_cache_set( 'bp_user_email_' . $uid, $email, 'bp' );
|
358 |
}
|
@@ -361,30 +398,38 @@ function bp_core_get_user_email( $uid ) {
|
|
361 |
}
|
362 |
|
363 |
/**
|
364 |
-
*
|
|
|
365 |
* eg: <a href="http://andy.domain.com/">Andy Peatling</a>
|
|
|
366 |
* Optional parameters will return just the name or just the URL.
|
367 |
*
|
368 |
* @param int $user_id User ID to check.
|
369 |
-
* @param bool $no_anchor Disable URL and HTML and just return full name.
|
370 |
-
*
|
371 |
-
* @
|
372 |
-
*
|
|
|
|
|
373 |
*/
|
374 |
function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false ) {
|
375 |
$display_name = bp_core_get_user_displayname( $user_id );
|
376 |
|
377 |
-
if ( empty( $display_name ) )
|
378 |
return false;
|
|
|
379 |
|
380 |
-
if ( $no_anchor )
|
381 |
return $display_name;
|
|
|
382 |
|
383 |
-
if ( !$url = bp_core_get_user_domain( $user_id ) )
|
384 |
return false;
|
|
|
385 |
|
386 |
-
if ( $just_link )
|
387 |
return $url;
|
|
|
388 |
|
389 |
return apply_filters( 'bp_core_get_userlink', '<a href="' . $url . '" title="' . $display_name . '">' . $display_name . '</a>', $user_id );
|
390 |
}
|
@@ -480,7 +525,6 @@ function bp_core_get_user_displaynames( $user_ids ) {
|
|
480 |
* user not found.
|
481 |
*/
|
482 |
function bp_core_get_user_displayname( $user_id_or_username ) {
|
483 |
-
global $bp;
|
484 |
|
485 |
$fullname = '';
|
486 |
|
@@ -514,12 +558,9 @@ add_filter( 'bp_core_get_user_displayname', 'stripslashes' );
|
|
514 |
add_filter( 'bp_core_get_user_displayname', 'esc_html' );
|
515 |
|
516 |
/**
|
517 |
-
*
|
518 |
*
|
519 |
-
* @package BuddyPress Core
|
520 |
* @param string $email The email address for the user.
|
521 |
-
* @uses bp_core_get_userlink() BuddyPress function to get a userlink by user ID.
|
522 |
-
* @uses get_user_by() WordPress function to get userdata via an email address
|
523 |
* @return string The link to the users home base. False on no match.
|
524 |
*/
|
525 |
function bp_core_get_userlink_by_email( $email ) {
|
@@ -528,24 +569,29 @@ function bp_core_get_userlink_by_email( $email ) {
|
|
528 |
}
|
529 |
|
530 |
/**
|
531 |
-
*
|
532 |
*
|
533 |
-
* @param string $username If BP_ENABLE_USERNAME_COMPATIBILITY_MODE is set,
|
534 |
-
*
|
|
|
535 |
*/
|
536 |
function bp_core_get_userlink_by_username( $username ) {
|
537 |
-
if ( bp_is_username_compatibility_mode() )
|
538 |
$user_id = bp_core_get_userid( $username );
|
539 |
-
else
|
540 |
$user_id = bp_core_get_userid_from_nicename( $username );
|
|
|
541 |
|
542 |
return apply_filters( 'bp_core_get_userlink_by_username', bp_core_get_userlink( $user_id, false, false, true ) );
|
543 |
}
|
544 |
|
545 |
/**
|
546 |
-
*
|
|
|
|
|
|
|
|
|
547 |
*
|
548 |
-
* @package BuddyPress Core
|
549 |
* @return int The total number of members.
|
550 |
*/
|
551 |
function bp_core_get_total_member_count() {
|
@@ -561,7 +607,7 @@ function bp_core_get_total_member_count() {
|
|
561 |
}
|
562 |
|
563 |
/**
|
564 |
-
*
|
565 |
*
|
566 |
* @return int The number of active members
|
567 |
*/
|
@@ -611,12 +657,14 @@ function bp_core_process_spammer_status( $user_id, $status, $do_wp_cleanup = tru
|
|
611 |
global $wpdb;
|
612 |
|
613 |
// Bail if no user ID
|
614 |
-
if ( empty( $user_id ) )
|
615 |
return;
|
|
|
616 |
|
617 |
// Bail if user ID is super admin
|
618 |
-
if ( is_super_admin( $user_id ) )
|
619 |
return;
|
|
|
620 |
|
621 |
// Get the functions file
|
622 |
if ( is_multisite() ) {
|
@@ -641,7 +689,7 @@ function bp_core_process_spammer_status( $user_id, $status, $do_wp_cleanup = tru
|
|
641 |
// Get the blogs for the user
|
642 |
$blogs = get_blogs_of_user( $user_id, true );
|
643 |
|
644 |
-
foreach ( (array) $blogs as $
|
645 |
|
646 |
// Do not mark the main or current root blog as spam
|
647 |
if ( 1 == $details->userblog_id || bp_get_root_blog_id() == $details->userblog_id ) {
|
@@ -687,11 +735,11 @@ function bp_core_process_spammer_status( $user_id, $status, $do_wp_cleanup = tru
|
|
687 |
}
|
688 |
|
689 |
/**
|
690 |
-
* Hook to WP's make_spam_user and run our custom BP spam functions
|
691 |
*
|
692 |
-
* @since BuddyPress (1.6)
|
693 |
*
|
694 |
-
* @param int $user_id The user
|
695 |
*/
|
696 |
function bp_core_mark_user_spam_admin( $user_id ) {
|
697 |
bp_core_process_spammer_status( $user_id, 'spam', false );
|
@@ -699,11 +747,11 @@ function bp_core_mark_user_spam_admin( $user_id ) {
|
|
699 |
add_action( 'make_spam_user', 'bp_core_mark_user_spam_admin' );
|
700 |
|
701 |
/**
|
702 |
-
* Hook to WP's make_ham_user and run our custom BP spam functions
|
703 |
*
|
704 |
-
* @since BuddyPress (1.6)
|
705 |
*
|
706 |
-
* @param int $user_id The user
|
707 |
*/
|
708 |
function bp_core_mark_user_ham_admin( $user_id ) {
|
709 |
bp_core_process_spammer_status( $user_id, 'ham', false );
|
@@ -711,17 +759,17 @@ function bp_core_mark_user_ham_admin( $user_id ) {
|
|
711 |
add_action( 'make_ham_user', 'bp_core_mark_user_ham_admin' );
|
712 |
|
713 |
/**
|
714 |
-
*
|
715 |
*
|
716 |
-
* @
|
717 |
-
* @
|
718 |
-
* @return bool True if spammer, False if not.
|
719 |
*/
|
720 |
function bp_is_user_spammer( $user_id = 0 ) {
|
721 |
|
722 |
// No user to check
|
723 |
-
if ( empty( $user_id ) )
|
724 |
return false;
|
|
|
725 |
|
726 |
$bp = buddypress();
|
727 |
|
@@ -755,28 +803,30 @@ function bp_is_user_spammer( $user_id = 0 ) {
|
|
755 |
} else {
|
756 |
|
757 |
// Check if spam
|
758 |
-
if ( !empty( $user->spam ) )
|
759 |
$is_spammer = true;
|
|
|
760 |
|
761 |
-
if ( 1 == $user->user_status )
|
762 |
$is_spammer = true;
|
|
|
763 |
}
|
764 |
|
765 |
return apply_filters( 'bp_is_user_spammer', (bool) $is_spammer );
|
766 |
}
|
767 |
|
768 |
/**
|
769 |
-
*
|
770 |
*
|
771 |
-
* @
|
772 |
-
* @
|
773 |
-
* @return bool True if deleted, False if not.
|
774 |
*/
|
775 |
function bp_is_user_deleted( $user_id = 0 ) {
|
776 |
|
777 |
// No user to check
|
778 |
-
if ( empty( $user_id ) )
|
779 |
return false;
|
|
|
780 |
|
781 |
$bp = buddypress();
|
782 |
|
@@ -810,73 +860,83 @@ function bp_is_user_deleted( $user_id = 0 ) {
|
|
810 |
} else {
|
811 |
|
812 |
// Check if deleted
|
813 |
-
if ( !empty( $user->deleted ) )
|
814 |
$is_deleted = true;
|
|
|
815 |
|
816 |
-
if ( 2 == $user->user_status )
|
817 |
$is_deleted = true;
|
818 |
-
|
819 |
}
|
820 |
|
821 |
return apply_filters( 'bp_is_user_deleted', (bool) $is_deleted );
|
822 |
}
|
823 |
|
824 |
/**
|
825 |
-
*
|
826 |
*
|
827 |
-
* @since BuddyPress (1.6)
|
828 |
*
|
829 |
* @uses is_user_logged_in() To check if user is logged in
|
830 |
* @uses bp_loggedin_user_id() To get current user ID
|
831 |
* @uses bp_is_user_spammer() To check if user is spammer
|
832 |
* @uses bp_is_user_deleted() To check if user is deleted
|
833 |
*
|
834 |
-
* @param int $user_id The user ID to check
|
835 |
-
* @return bool True if
|
836 |
*/
|
837 |
function bp_is_user_active( $user_id = 0 ) {
|
838 |
|
839 |
// Default to current user
|
840 |
-
if ( empty( $user_id ) && is_user_logged_in() )
|
841 |
$user_id = bp_loggedin_user_id();
|
|
|
842 |
|
843 |
// No user to check
|
844 |
-
if ( empty( $user_id ) )
|
845 |
return false;
|
|
|
846 |
|
847 |
// Check spam
|
848 |
-
if ( bp_is_user_spammer( $user_id ) )
|
849 |
return false;
|
|
|
850 |
|
851 |
// Check deleted
|
852 |
-
if ( bp_is_user_deleted( $user_id ) )
|
853 |
return false;
|
|
|
854 |
|
855 |
// Assume true if not spam or deleted
|
856 |
return true;
|
857 |
}
|
858 |
|
859 |
/**
|
860 |
-
*
|
861 |
*
|
862 |
-
* @since BuddyPress (1.6)
|
|
|
|
|
|
|
863 |
*
|
864 |
* @uses is_user_logged_in() To check if user is logged in
|
865 |
* @uses bp_get_displayed_user_id() To get current user ID
|
866 |
* @uses bp_is_user_active() To check if user is active
|
867 |
*
|
868 |
-
* @param int $user_id The user ID to check
|
869 |
-
* @return bool True if inactive, false
|
870 |
*/
|
871 |
function bp_is_user_inactive( $user_id = 0 ) {
|
872 |
|
873 |
// Default to current user
|
874 |
-
if ( empty( $user_id ) && is_user_logged_in() )
|
875 |
$user_id = bp_loggedin_user_id();
|
|
|
876 |
|
877 |
// No user to check
|
878 |
-
if ( empty( $user_id ) )
|
879 |
return false;
|
|
|
880 |
|
881 |
// Return the inverse of active
|
882 |
return !bp_is_user_active( $user_id );
|
@@ -892,6 +952,7 @@ function bp_is_user_inactive( $user_id = 0 ) {
|
|
892 |
* @return bool True on success, false on failure.
|
893 |
*/
|
894 |
function bp_update_user_last_activity( $user_id = 0, $time = '' ) {
|
|
|
895 |
// Fall back on current user
|
896 |
if ( empty( $user_id ) ) {
|
897 |
$user_id = bp_loggedin_user_id();
|
@@ -936,13 +997,13 @@ function bp_update_user_last_activity( $user_id = 0, $time = '' ) {
|
|
936 |
* @param string $meta_key Meta key being fetched.
|
937 |
*/
|
938 |
function _bp_get_user_meta_last_activity_warning( $retval, $object_id, $meta_key ) {
|
939 |
-
static $warned;
|
940 |
|
941 |
if ( 'last_activity' === $meta_key ) {
|
942 |
// Don't send the warning more than once per pageload
|
943 |
-
if (
|
944 |
_doing_it_wrong( 'get_user_meta( $user_id, \'last_activity\' )', __( 'User last_activity data is no longer stored in usermeta. Use bp_get_user_last_activity() instead.', 'buddypress' ), '2.0.0' );
|
945 |
-
$warned =
|
946 |
}
|
947 |
|
948 |
return bp_get_user_last_activity( $object_id );
|
@@ -1008,18 +1069,16 @@ function bp_last_activity_migrate() {
|
|
1008 |
|
1009 |
$bp = buddypress();
|
1010 |
|
1011 |
-
//
|
|
|
|
|
|
|
|
|
1012 |
$sql = "INSERT INTO {$bp->members->table_name_last_activity} (`user_id`, `component`, `type`, `action`, `content`, `primary_link`, `item_id`, `date_recorded` ) (
|
1013 |
SELECT user_id, '{$bp->members->id}' as component, 'last_activity' as type, '' as action, '' as content, '' as primary_link, 0 as item_id, meta_value AS date_recorded
|
1014 |
FROM {$wpdb->usermeta}
|
1015 |
WHERE
|
1016 |
meta_key = 'last_activity'
|
1017 |
-
AND
|
1018 |
-
user_id NOT IN (
|
1019 |
-
SELECT user_id
|
1020 |
-
FROM {$bp->members->table_name_last_activity}
|
1021 |
-
WHERE component = '{$bp->members->id}' AND type = 'last_activity'
|
1022 |
-
)
|
1023 |
);";
|
1024 |
|
1025 |
return $wpdb->query( $sql );
|
@@ -1028,35 +1087,43 @@ function bp_last_activity_migrate() {
|
|
1028 |
/**
|
1029 |
* Fetch every post that is authored by the given user for the current blog.
|
1030 |
*
|
1031 |
-
*
|
1032 |
-
*
|
1033 |
-
* @
|
|
|
|
|
|
|
1034 |
*/
|
1035 |
function bp_core_get_all_posts_for_user( $user_id = 0 ) {
|
1036 |
global $wpdb;
|
1037 |
|
1038 |
-
if ( empty( $user_id ) )
|
1039 |
$user_id = bp_displayed_user_id();
|
|
|
1040 |
|
1041 |
return apply_filters( 'bp_core_get_all_posts_for_user', $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_status = 'publish' AND post_type = 'post'", $user_id ) ) );
|
1042 |
}
|
1043 |
|
1044 |
/**
|
1045 |
-
*
|
|
|
|
|
1046 |
*
|
1047 |
-
* @
|
1048 |
-
*
|
1049 |
-
* @
|
1050 |
*/
|
1051 |
function bp_core_delete_account( $user_id = 0 ) {
|
1052 |
|
1053 |
// Use logged in user ID if none is passed
|
1054 |
-
if ( empty( $user_id ) )
|
1055 |
$user_id = bp_loggedin_user_id();
|
|
|
1056 |
|
1057 |
// Site admins cannot be deleted
|
1058 |
-
if ( is_super_admin( $user_id ) )
|
1059 |
return false;
|
|
|
1060 |
|
1061 |
// Extra checks if user is not deleting themselves
|
1062 |
if ( bp_loggedin_user_id() !== absint( $user_id ) ) {
|
@@ -1110,9 +1177,12 @@ add_action( 'wpmu_delete_user', 'bp_core_delete_avatar_on_user_delete' );
|
|
1110 |
add_action( 'delete_user', 'bp_core_delete_avatar_on_user_delete' );
|
1111 |
|
1112 |
/**
|
1113 |
-
*
|
1114 |
*
|
1115 |
-
*
|
|
|
|
|
|
|
1116 |
*/
|
1117 |
function bp_core_ucfirst( $str ) {
|
1118 |
if ( function_exists( 'mb_strtoupper' ) && function_exists( 'mb_substr' ) ) {
|
@@ -1124,23 +1194,30 @@ function bp_core_ucfirst( $str ) {
|
|
1124 |
}
|
1125 |
|
1126 |
/**
|
1127 |
-
*
|
1128 |
-
* redirect them to the home page and stop them from logging in.
|
1129 |
*
|
1130 |
-
*
|
1131 |
-
*
|
1132 |
*
|
1133 |
* @since BuddyPress (1.1.2)
|
|
|
|
|
|
|
|
|
|
|
1134 |
*/
|
1135 |
function bp_core_boot_spammer( $user ) {
|
|
|
1136 |
// check to see if the $user has already failed logging in, if so return $user as-is
|
1137 |
-
if ( is_wp_error( $user ) || empty( $user ) )
|
1138 |
return $user;
|
|
|
1139 |
|
1140 |
// the user exists; now do a check to see if the user is a spammer
|
1141 |
// if the user is a spammer, stop them in their tracks!
|
1142 |
-
if ( is_a( $user, 'WP_User' ) && ( ( is_multisite() && (int) $user->spam ) || 1 == $user->user_status ) )
|
1143 |
return new WP_Error( 'invalid_username', __( '<strong>ERROR</strong>: Your account has been marked as a spammer.', 'buddypress' ) );
|
|
|
1144 |
|
1145 |
// user is good to go!
|
1146 |
return $user;
|
@@ -1148,11 +1225,9 @@ function bp_core_boot_spammer( $user ) {
|
|
1148 |
add_filter( 'authenticate', 'bp_core_boot_spammer', 30 );
|
1149 |
|
1150 |
/**
|
1151 |
-
*
|
1152 |
*
|
1153 |
-
* @
|
1154 |
-
* @param int $user_id The user id for the user to delete usermeta for
|
1155 |
-
* @uses bp_delete_user_meta() deletes a row from the wp_usermeta table based on meta_key
|
1156 |
*/
|
1157 |
function bp_core_remove_data( $user_id ) {
|
1158 |
|
@@ -1166,16 +1241,23 @@ add_action( 'wpmu_delete_user', 'bp_core_remove_data' );
|
|
1166 |
add_action( 'delete_user', 'bp_core_remove_data' );
|
1167 |
add_action( 'bp_make_spam_user', 'bp_core_remove_data' );
|
1168 |
|
|
|
|
|
|
|
|
|
|
|
1169 |
function bp_core_can_edit_settings() {
|
1170 |
-
if ( bp_is_my_profile() )
|
1171 |
return true;
|
|
|
1172 |
|
1173 |
if ( is_super_admin( bp_displayed_user_id() ) && ! is_super_admin() ) {
|
1174 |
return false;
|
1175 |
}
|
1176 |
|
1177 |
-
if ( bp_current_user_can( 'bp_moderate' ) || current_user_can( 'edit_users' ) )
|
1178 |
return true;
|
|
|
1179 |
|
1180 |
return false;
|
1181 |
}
|
@@ -1183,7 +1265,7 @@ function bp_core_can_edit_settings() {
|
|
1183 |
/** Sign-up *******************************************************************/
|
1184 |
|
1185 |
/**
|
1186 |
-
* Flush illegal names by getting and setting 'illegal_names' site option
|
1187 |
*/
|
1188 |
function bp_core_flush_illegal_names() {
|
1189 |
$illegal_names = get_site_option( 'illegal_names' );
|
@@ -1191,12 +1273,12 @@ function bp_core_flush_illegal_names() {
|
|
1191 |
}
|
1192 |
|
1193 |
/**
|
1194 |
-
*
|
1195 |
-
* specific BuddyPress and Multi-site slugs
|
1196 |
*
|
1197 |
-
* @param array|string $value Illegal names
|
1198 |
-
*
|
1199 |
-
* @
|
|
|
1200 |
*/
|
1201 |
function bp_core_get_illegal_names( $value = '', $oldvalue = '' ) {
|
1202 |
|
@@ -1262,7 +1344,7 @@ function bp_core_get_illegal_names( $value = '', $oldvalue = '' ) {
|
|
1262 |
add_filter( 'pre_update_site_option_illegal_names', 'bp_core_get_illegal_names', 10, 2 );
|
1263 |
|
1264 |
/**
|
1265 |
-
* Check that an email address is valid for use
|
1266 |
*
|
1267 |
* Performs the following checks:
|
1268 |
* - Is the email address well-formed?
|
@@ -1274,7 +1356,7 @@ add_filter( 'pre_update_site_option_illegal_names', 'bp_core_get_illegal_names',
|
|
1274 |
*
|
1275 |
* @param string $user_email The email being checked
|
1276 |
* @return bool|array True if the address passes all checks; otherwise an array
|
1277 |
-
*
|
1278 |
*/
|
1279 |
function bp_core_validate_email_address( $user_email ) {
|
1280 |
$errors = array();
|
@@ -1282,13 +1364,15 @@ function bp_core_validate_email_address( $user_email ) {
|
|
1282 |
$user_email = sanitize_email( $user_email );
|
1283 |
|
1284 |
// Is the email well-formed?
|
1285 |
-
if ( ! is_email( $user_email ) )
|
1286 |
$errors['invalid'] = 1;
|
|
|
1287 |
|
1288 |
// Is the email on the Banned Email Domains list?
|
1289 |
// Note: This check only works on Multisite
|
1290 |
-
if ( function_exists( 'is_email_address_unsafe' ) && is_email_address_unsafe( $user_email ) )
|
1291 |
$errors['domain_banned'] = 1;
|
|
|
1292 |
|
1293 |
// Is the email on the Limited Email Domains list?
|
1294 |
// Note: This check only works on Multisite
|
@@ -1301,8 +1385,9 @@ function bp_core_validate_email_address( $user_email ) {
|
|
1301 |
}
|
1302 |
|
1303 |
// Is the email alreday in use?
|
1304 |
-
if ( email_exists( $user_email ) )
|
1305 |
$errors['in_use'] = 1;
|
|
|
1306 |
|
1307 |
$retval = ! empty( $errors ) ? $errors : true;
|
1308 |
|
@@ -1310,39 +1395,44 @@ function bp_core_validate_email_address( $user_email ) {
|
|
1310 |
}
|
1311 |
|
1312 |
/**
|
1313 |
-
* Add the appropriate errors to a WP_Error object, given results of a validation test
|
1314 |
*
|
1315 |
* Functions like bp_core_validate_email_address() return a structured array
|
1316 |
* of error codes. bp_core_add_validation_error_messages() takes this array and
|
1317 |
* parses, adding the appropriate error messages to the WP_Error object.
|
1318 |
*
|
1319 |
-
* @since BuddyPress (1.7)
|
|
|
1320 |
* @see bp_core_validate_email_address()
|
1321 |
*
|
1322 |
-
* @param WP_Error $errors WP_Error object
|
1323 |
* @param array $validation_results The return value of a validation function
|
1324 |
-
*
|
1325 |
*/
|
1326 |
function bp_core_add_validation_error_messages( WP_Error $errors, $validation_results ) {
|
1327 |
-
if ( ! empty( $validation_results['invalid'] ) )
|
1328 |
$errors->add( 'user_email', __( 'Please check your email address.', 'buddypress' ) );
|
|
|
1329 |
|
1330 |
-
if ( ! empty( $validation_results['domain_banned'] ) )
|
1331 |
$errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) );
|
|
|
1332 |
|
1333 |
-
if ( ! empty( $validation_results['domain_not_allowed'] ) )
|
1334 |
$errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) );
|
|
|
1335 |
|
1336 |
-
if ( ! empty( $validation_results['in_use'] ) )
|
1337 |
$errors->add( 'user_email', __( 'Sorry, that email address is already used!', 'buddypress' ) );
|
|
|
1338 |
}
|
1339 |
|
1340 |
/**
|
1341 |
* Validate a user name and email address when creating a new user.
|
1342 |
*
|
1343 |
-
* @param string $user_name Username to validate
|
1344 |
-
* @param string $user_email Email address to validate
|
1345 |
-
* @return array Results of user validation including errors, if any
|
1346 |
*/
|
1347 |
function bp_core_validate_user_signup( $user_name, $user_email ) {
|
1348 |
|
@@ -1427,15 +1517,37 @@ function bp_core_validate_user_signup( $user_name, $user_email ) {
|
|
1427 |
return apply_filters( 'bp_core_validate_user_signup', $result );
|
1428 |
}
|
1429 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1430 |
function bp_core_validate_blog_signup( $blog_url, $blog_title ) {
|
1431 |
-
if ( !is_multisite() || !function_exists( 'wpmu_validate_blog_signup' ) )
|
1432 |
return false;
|
|
|
1433 |
|
1434 |
return apply_filters( 'bp_core_validate_blog_signup', wpmu_validate_blog_signup( $blog_url, $blog_title ) );
|
1435 |
}
|
1436 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1437 |
function bp_core_signup_user( $user_login, $user_password, $user_email, $usermeta ) {
|
1438 |
-
|
1439 |
|
1440 |
// We need to cast $user_id to pass to the filters
|
1441 |
$user_id = false;
|
@@ -1495,13 +1607,30 @@ function bp_core_signup_user( $user_login, $user_password, $user_email, $usermet
|
|
1495 |
return $user_id;
|
1496 |
}
|
1497 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1498 |
function bp_core_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) {
|
1499 |
-
if ( !is_multisite() || !function_exists( 'wpmu_signup_blog' ) )
|
1500 |
return false;
|
|
|
1501 |
|
1502 |
return apply_filters( 'bp_core_signup_blog', wpmu_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) );
|
1503 |
}
|
1504 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1505 |
function bp_core_activate_signup( $key ) {
|
1506 |
global $wpdb;
|
1507 |
|
@@ -1607,8 +1736,9 @@ function bp_core_activate_signup( $key ) {
|
|
1607 |
foreach( (array) $profile_field_ids as $field_id ) {
|
1608 |
$current_field = isset( $user['meta']["field_{$field_id}"] ) ? $user['meta']["field_{$field_id}"] : false;
|
1609 |
|
1610 |
-
if ( !empty( $current_field ) )
|
1611 |
xprofile_set_field_data( $field_id, $user_id, $current_field );
|
|
|
1612 |
|
1613 |
// Save the visibility level
|
1614 |
$visibility_level = ! empty( $user['meta']['field_' . $field_id . '_visibility'] ) ? $user['meta']['field_' . $field_id . '_visibility'] : 'public';
|
@@ -1714,19 +1844,25 @@ function bp_members_migrate_signups() {
|
|
1714 |
}
|
1715 |
}
|
1716 |
|
|
|
|
|
|
|
|
|
|
|
1717 |
function bp_core_new_user_activity( $user ) {
|
1718 |
-
if ( empty( $user ) || !bp_is_active( 'activity' ) )
|
1719 |
return false;
|
|
|
1720 |
|
1721 |
-
if ( is_array( $user ) )
|
1722 |
$user_id = $user['user_id'];
|
1723 |
-
else
|
1724 |
$user_id = $user;
|
|
|
1725 |
|
1726 |
-
if ( empty( $user_id ) )
|
1727 |
return false;
|
1728 |
-
|
1729 |
-
$userlink = bp_core_get_userlink( $user_id );
|
1730 |
|
1731 |
bp_activity_add( array(
|
1732 |
'user_id' => $user_id,
|
@@ -1736,11 +1872,20 @@ function bp_core_new_user_activity( $user ) {
|
|
1736 |
}
|
1737 |
add_action( 'bp_core_activated_user', 'bp_core_new_user_activity' );
|
1738 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1739 |
function bp_core_map_user_registration( $user_id ) {
|
1740 |
|
1741 |
// Only map data when the site admin is adding users, not on registration.
|
1742 |
-
if ( !is_admin() )
|
1743 |
return false;
|
|
|
1744 |
|
1745 |
// Add the user's fullname to Xprofile
|
1746 |
if ( bp_is_active( 'xprofile' ) ) {
|
@@ -1748,33 +1893,55 @@ function bp_core_map_user_registration( $user_id ) {
|
|
1748 |
$lastname = ' ' . bp_get_user_meta( $user_id, 'last_name', true );
|
1749 |
$name = $firstname . $lastname;
|
1750 |
|
1751 |
-
if ( empty( $name ) || ' ' == $name )
|
1752 |
$name = bp_get_user_meta( $user_id, 'nickname', true );
|
|
|
1753 |
|
1754 |
xprofile_set_field_data( 1, $user_id, $name );
|
1755 |
}
|
1756 |
}
|
1757 |
add_action( 'user_register', 'bp_core_map_user_registration' );
|
1758 |
|
|
|
|
|
|
|
|
|
|
|
1759 |
function bp_core_signup_avatar_upload_dir() {
|
1760 |
-
|
1761 |
|
1762 |
-
if (
|
1763 |
return false;
|
|
|
1764 |
|
1765 |
$path = bp_core_avatar_upload_path() . '/avatars/signups/' . $bp->signup->avatar_dir;
|
1766 |
$newbdir = $path;
|
1767 |
|
1768 |
-
if ( !file_exists( $path ) )
|
1769 |
@wp_mkdir_p( $path );
|
|
|
1770 |
|
1771 |
$newurl = bp_core_avatar_url() . '/avatars/signups/' . $bp->signup->avatar_dir;
|
1772 |
$newburl = $newurl;
|
1773 |
$newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir;
|
1774 |
|
1775 |
-
return apply_filters( 'bp_core_signup_avatar_upload_dir', array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1776 |
}
|
1777 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1778 |
function bp_core_signup_send_validation_email( $user_id, $user_email, $key ) {
|
1779 |
$activate_url = bp_get_activation_page() ."?key=$key";
|
1780 |
$activate_url = esc_url( $activate_url );
|
@@ -1881,25 +2048,27 @@ function bp_members_login_resend_activation_email() {
|
|
1881 |
if ( ! empty( $resend['errors'] ) ) {
|
1882 |
$error = __( '<strong>ERROR</strong>: Your account has already been activated.', 'buddypress' );
|
1883 |
} else {
|
1884 |
-
$error = __( 'Activation email resent!
|
1885 |
}
|
1886 |
}
|
1887 |
add_action( 'login_form_bp-resend-activation', 'bp_members_login_resend_activation_email' );
|
1888 |
|
1889 |
/**
|
1890 |
-
*
|
1891 |
*/
|
1892 |
function bp_core_wpsignup_redirect() {
|
1893 |
|
1894 |
// Bail in admin or if custom signup page is broken
|
1895 |
-
if ( is_admin() || ! bp_has_custom_signup_page() )
|
1896 |
return;
|
|
|
1897 |
|
1898 |
$action = !empty( $_GET['action'] ) ? $_GET['action'] : '';
|
1899 |
|
1900 |
// Not at the WP core signup page and action is not register
|
1901 |
-
if ( ! empty( $_SERVER['SCRIPT_NAME'] ) && false === strpos( $_SERVER['SCRIPT_NAME'], 'wp-signup.php' ) && ( 'register' != $action ) )
|
1902 |
return;
|
|
|
1903 |
|
1904 |
bp_core_redirect( bp_get_signup_page() );
|
1905 |
}
|
@@ -1924,7 +2093,7 @@ add_action( 'bp_init', 'bp_core_wpsignup_redirect' );
|
|
1924 |
*
|
1925 |
* This is important as the $bp->loggedin_user object is setup at priority 4.
|
1926 |
*
|
1927 |
-
* @since BuddyPress (
|
1928 |
*/
|
1929 |
function bp_stop_live_spammer() {
|
1930 |
// if we're on the login page, stop now to prevent redirect loop
|
@@ -1968,7 +2137,7 @@ add_action( 'bp_init', 'bp_stop_live_spammer', 5 );
|
|
1968 |
/**
|
1969 |
* Show a custom error message when a logged-in user is marked as a spammer.
|
1970 |
*
|
1971 |
-
* @since BuddyPress (
|
1972 |
*/
|
1973 |
function bp_live_spammer_login_error() {
|
1974 |
global $error;
|
13 |
if ( !defined( 'ABSPATH' ) ) exit;
|
14 |
|
15 |
/**
|
16 |
+
* Check for the existence of a Members directory page.
|
17 |
*
|
18 |
+
* @since BuddyPress (1.5.0)
|
19 |
*
|
20 |
+
* @return bool True if found, otherwise false.
|
|
|
21 |
*/
|
22 |
function bp_members_has_directory() {
|
23 |
global $bp;
|
26 |
}
|
27 |
|
28 |
/**
|
29 |
+
* Define the slug constants for the Members component.
|
|
|
30 |
*
|
31 |
+
* Handles the three slug constants used in the Members component -
|
32 |
+
* BP_MEMBERS_SLUG, BP_REGISTER_SLUG, and BP_ACTIVATION_SLUG. If these
|
33 |
+
* constants are not overridden in wp-config.php or bp-custom.php, they are
|
34 |
+
* defined here to match the slug of the corresponding WP pages.
|
35 |
*
|
36 |
+
* In general, fallback values are only used during initial BP page creation,
|
37 |
+
* when no slugs have been explicitly defined.
|
38 |
*/
|
39 |
function bp_core_define_slugs() {
|
40 |
+
$bp = buddypress();
|
41 |
|
42 |
// No custom members slug
|
43 |
if ( !defined( 'BP_MEMBERS_SLUG' ) ) {
|
69 |
add_action( 'bp_setup_globals', 'bp_core_define_slugs', 11 );
|
70 |
|
71 |
/**
|
72 |
+
* Fetch an array of users based on the parameters passed.
|
73 |
*
|
74 |
* Since BuddyPress 1.7, bp_core_get_users() uses BP_User_Query. If you
|
75 |
* need backward compatibility with BP_Core_User::get_users(), filter the
|
76 |
* bp_use_legacy_user_query value, returning true.
|
77 |
*
|
78 |
+
* @param array $args {
|
79 |
+
* Array of arguments. All are optional. See {@link BP_User_Query} for
|
80 |
+
* a more complete description of arguments.
|
81 |
+
* @type string $type Sort order. Default: 'active'.
|
82 |
+
* @type int $user_id Limit results to friends of a user. Default: false.
|
83 |
+
* @type mixed $exclude IDs to exclude from results. Default: false.
|
84 |
+
* @type string $search_terms Limit to users matching search terms. Default: false.
|
85 |
+
* @type string $meta_key Limit to users with a meta_key. Default: false.
|
86 |
+
* @type string $meta_value Limit to users with a meta_value (with
|
87 |
+
* meta_key). Default: false.
|
88 |
+
* @type mixed $include Limit results by user IDs. Default: false.
|
89 |
+
* @type int $per_page Results per page. Default: 20.
|
90 |
+
* @type int $page Page of results. Default: 1.
|
91 |
+
* @type bool $populate_extras Fetch optional extras. Default: true.
|
92 |
+
* @type string|bool $count_total How to do total user count.
|
93 |
+
* Default: 'count_query'.
|
94 |
+
* }
|
95 |
+
* @return array
|
96 |
*/
|
97 |
function bp_core_get_users( $args = '' ) {
|
98 |
|
99 |
// Parse the user query arguments
|
100 |
+
$r = bp_parse_args( $args, array(
|
101 |
'type' => 'active', // active, newest, alphabetical, random or popular
|
102 |
'user_id' => false, // Pass a user_id to limit to only friend connections for this user
|
103 |
'exclude' => false, // Users to exclude from results
|
109 |
'page' => 1, // The page to return if limiting per page
|
110 |
'populate_extras' => true, // Fetch the last active, where the user is a friend, total friend count, latest update
|
111 |
'count_total' => 'count_query' // What kind of total user count to do, if any. 'count_query', 'sql_calc_found_rows', or false
|
112 |
+
), 'core_get_users' );
|
113 |
|
114 |
// For legacy users. Use of BP_Core_User::get_users() is deprecated.
|
115 |
+
if ( apply_filters( 'bp_use_legacy_user_query', false, __FUNCTION__, $r ) ) {
|
116 |
+
$retval = BP_Core_User::get_users(
|
117 |
+
$r['type'],
|
118 |
+
$r['per_page'],
|
119 |
+
$r['page'],
|
120 |
+
$r['user_id'],
|
121 |
+
$r['include'],
|
122 |
+
$r['search_terms'],
|
123 |
+
$r['populate_extras'],
|
124 |
+
$r['exclude'],
|
125 |
+
$r['meta_key'],
|
126 |
+
$r['meta_value']
|
127 |
+
);
|
128 |
|
129 |
// Default behavior as of BuddyPress 1.7
|
130 |
} else {
|
131 |
|
132 |
// Get users like we were asked to do...
|
133 |
+
$users = new BP_User_Query( $r );
|
134 |
|
135 |
// ...but reformat the results to match bp_core_get_users() behavior.
|
136 |
$retval = array(
|
139 |
);
|
140 |
}
|
141 |
|
142 |
+
return apply_filters( 'bp_core_get_users', $retval, $r );
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
+
* Return the domain for the passed user: e.g. http://domain.com/members/andy/.
|
147 |
*
|
|
|
|
|
148 |
* @param int $user_id The ID of the user.
|
149 |
+
* @param string $user_nicename Optional. user_nicename of the user.
|
150 |
+
* @param string $user_login Optional. user_login of the user.
|
151 |
*/
|
152 |
+
function bp_core_get_user_domain( $user_id = 0, $user_nicename = false, $user_login = false ) {
|
153 |
|
154 |
if ( empty( $user_id ) ) {
|
155 |
return;
|
174 |
/**
|
175 |
* Fetch everything in the wp_users table for a user, without any usermeta.
|
176 |
*
|
|
|
177 |
* @param int $user_id The ID of the user.
|
178 |
+
* @return array
|
179 |
*/
|
180 |
+
function bp_core_get_core_userdata( $user_id = 0 ) {
|
181 |
+
if ( empty( $user_id ) ) {
|
182 |
return false;
|
183 |
+
}
|
184 |
|
185 |
if ( !$userdata = wp_cache_get( 'bp_core_userdata_' . $user_id, 'bp' ) ) {
|
186 |
$userdata = BP_Core_User::get_core_userdata( $user_id );
|
190 |
}
|
191 |
|
192 |
/**
|
193 |
+
* Return the ID of a user, based on user_login.
|
194 |
+
*
|
195 |
+
* No longer used.
|
196 |
*
|
197 |
+
* @todo Deprecate.
|
198 |
+
*
|
199 |
+
* @param string $user_login user_login of the user being queried.
|
200 |
+
* @return int
|
201 |
*/
|
202 |
function bp_core_get_displayed_userid( $user_login ) {
|
203 |
return apply_filters( 'bp_core_get_displayed_userid', bp_core_get_userid( $user_login ) );
|
204 |
}
|
205 |
|
206 |
/**
|
207 |
+
* Return the user ID based on a user's user_login.
|
208 |
+
*
|
209 |
+
* @since BuddyPress (1.0.0)
|
210 |
*
|
211 |
+
* @param string $username user_login to check.
|
212 |
+
* @return int|null The ID of the matched user on success, null on failure.
|
|
|
|
|
213 |
*/
|
214 |
+
function bp_core_get_userid( $username = '' ) {
|
215 |
+
if ( empty( $username ) ) {
|
|
|
|
|
216 |
return false;
|
217 |
+
}
|
218 |
|
219 |
+
$user = get_user_by( 'login', $username );
|
220 |
+
|
221 |
+
return apply_filters( 'bp_core_get_userid', ! empty( $user->ID ) ? $user->ID : NULL, $username );
|
222 |
}
|
223 |
|
224 |
/**
|
225 |
+
* Return the user ID based on a user's user_nicename.
|
226 |
+
*
|
227 |
+
* @since BuddyPress (1.2.3)
|
228 |
*
|
229 |
+
* @param string $user_nicename user_nicename to check.
|
230 |
+
* @return int|null The ID of the matched user on success, null on failure.
|
|
|
|
|
231 |
*/
|
232 |
+
function bp_core_get_userid_from_nicename( $user_nicename = '' ) {
|
233 |
+
if ( empty( $user_nicename ) ) {
|
|
|
|
|
234 |
return false;
|
235 |
+
}
|
236 |
+
|
237 |
+
$user = get_user_by( 'slug', $user_nicename );
|
238 |
|
239 |
+
return apply_filters( 'bp_core_get_userid_from_nicename', ! empty( $user->ID ) ? $user->ID : NULL, $user_nicename );
|
240 |
}
|
241 |
|
242 |
/**
|
243 |
+
* Return the username for a user based on their user id.
|
244 |
*
|
245 |
+
* This function is sensitive to the BP_ENABLE_USERNAME_COMPATIBILITY_MODE,
|
246 |
+
* so it will return the user_login or user_nicename as appropriate.
|
247 |
+
*
|
248 |
+
* @param int $user_id User ID to check.
|
249 |
+
* @param string $user_nicename Optional. user_nicename of user being checked.
|
250 |
+
* @param string $user_login Optional. user_login of user being checked.
|
251 |
* @return string|bool The username of the matched user, or false.
|
252 |
*/
|
253 |
function bp_core_get_username( $user_id = 0, $user_nicename = false, $user_login = false ) {
|
314 |
}
|
315 |
|
316 |
/**
|
317 |
+
* Return the user_nicename for a user based on their user_id.
|
|
|
|
|
318 |
*
|
319 |
+
* This should be used for linking to user profiles and anywhere else a
|
320 |
+
* sanitized and unique slug to a user is needed.
|
321 |
*
|
322 |
+
* @since BuddyPress (1.5.0)
|
323 |
+
*
|
324 |
+
* @todo Refactor to use a WP core function, if possible.
|
325 |
+
*
|
326 |
+
* @param int $user_id User ID to check.
|
327 |
* @return string|bool The username of the matched user, or false.
|
328 |
*/
|
329 |
function bp_members_get_user_nicename( $user_id ) {
|
330 |
+
$bp = buddypress();
|
331 |
|
332 |
if ( !$user_nicename = wp_cache_get( 'bp_members_user_nicename_' . $user_id, 'bp' ) ) {
|
333 |
$update_cache = true;
|
363 |
}
|
364 |
|
365 |
// Add this to cache
|
366 |
+
if ( true == $update_cache && !empty( $user_nicename ) ) {
|
367 |
wp_cache_set( 'bp_members_user_nicename_' . $user_id, $user_nicename, 'bp' );
|
368 |
+
}
|
369 |
|
370 |
return apply_filters( 'bp_members_get_user_nicename', $user_nicename );
|
371 |
}
|
372 |
|
373 |
/**
|
374 |
+
* Return the email address for the user based on user ID.
|
375 |
*
|
|
|
376 |
* @param int $uid User ID to check.
|
377 |
+
* @return string The email for the matched user. Empty string if no user
|
378 |
+
* matched the $uid.
|
379 |
*/
|
380 |
function bp_core_get_user_email( $uid ) {
|
381 |
|
382 |
if ( !$email = wp_cache_get( 'bp_user_email_' . $uid, 'bp' ) ) {
|
383 |
+
|
384 |
// User exists
|
385 |
+
$ud = bp_core_get_core_userdata( $uid );
|
386 |
+
if ( ! empty( $ud ) ) {
|
387 |
$email = $ud->user_email;
|
388 |
|
389 |
// User was deleted
|
390 |
+
} else {
|
391 |
$email = '';
|
392 |
+
}
|
393 |
|
394 |
wp_cache_set( 'bp_user_email_' . $uid, $email, 'bp' );
|
395 |
}
|
398 |
}
|
399 |
|
400 |
/**
|
401 |
+
* Return a HTML formatted link for a user with the user's full name as the link text.
|
402 |
+
*
|
403 |
* eg: <a href="http://andy.domain.com/">Andy Peatling</a>
|
404 |
+
*
|
405 |
* Optional parameters will return just the name or just the URL.
|
406 |
*
|
407 |
* @param int $user_id User ID to check.
|
408 |
+
* @param bool $no_anchor Disable URL and HTML and just return full name.
|
409 |
+
* Default: false.
|
410 |
+
* @param bool $just_link Disable full name and HTML and just return the URL
|
411 |
+
* text. Default false.
|
412 |
+
* @return string|bool The link text based on passed parameters, or false on
|
413 |
+
* no match.
|
414 |
*/
|
415 |
function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false ) {
|
416 |
$display_name = bp_core_get_user_displayname( $user_id );
|
417 |
|
418 |
+
if ( empty( $display_name ) ) {
|
419 |
return false;
|
420 |
+
}
|
421 |
|
422 |
+
if ( ! empty( $no_anchor ) ) {
|
423 |
return $display_name;
|
424 |
+
}
|
425 |
|
426 |
+
if ( !$url = bp_core_get_user_domain( $user_id ) ) {
|
427 |
return false;
|
428 |
+
}
|
429 |
|
430 |
+
if ( ! empty( $just_link ) ) {
|
431 |
return $url;
|
432 |
+
}
|
433 |
|
434 |
return apply_filters( 'bp_core_get_userlink', '<a href="' . $url . '" title="' . $display_name . '">' . $display_name . '</a>', $user_id );
|
435 |
}
|
525 |
* user not found.
|
526 |
*/
|
527 |
function bp_core_get_user_displayname( $user_id_or_username ) {
|
|
|
528 |
|
529 |
$fullname = '';
|
530 |
|
558 |
add_filter( 'bp_core_get_user_displayname', 'esc_html' );
|
559 |
|
560 |
/**
|
561 |
+
* Return the user link for the user based on user email address.
|
562 |
*
|
|
|
563 |
* @param string $email The email address for the user.
|
|
|
|
|
564 |
* @return string The link to the users home base. False on no match.
|
565 |
*/
|
566 |
function bp_core_get_userlink_by_email( $email ) {
|
569 |
}
|
570 |
|
571 |
/**
|
572 |
+
* Return the user link for the user based on the supplied identifier.
|
573 |
*
|
574 |
+
* @param string $username If BP_ENABLE_USERNAME_COMPATIBILITY_MODE is set,
|
575 |
+
* this should be user_login, otherwise it should be user_nicename.
|
576 |
+
* @return string|bool The link to the user's domain, false on no match.
|
577 |
*/
|
578 |
function bp_core_get_userlink_by_username( $username ) {
|
579 |
+
if ( bp_is_username_compatibility_mode() ) {
|
580 |
$user_id = bp_core_get_userid( $username );
|
581 |
+
} else {
|
582 |
$user_id = bp_core_get_userid_from_nicename( $username );
|
583 |
+
}
|
584 |
|
585 |
return apply_filters( 'bp_core_get_userlink_by_username', bp_core_get_userlink( $user_id, false, false, true ) );
|
586 |
}
|
587 |
|
588 |
/**
|
589 |
+
* Return the total number of members for the installation.
|
590 |
+
*
|
591 |
+
* Note that this is a raw count of non-spam, activated users. It does not
|
592 |
+
* account for users who have logged activity (last_active). See
|
593 |
+
* {@link bp_core_get_active_member_count()}.
|
594 |
*
|
|
|
595 |
* @return int The total number of members.
|
596 |
*/
|
597 |
function bp_core_get_total_member_count() {
|
607 |
}
|
608 |
|
609 |
/**
|
610 |
+
* Return the total number of members, limited to those members with last_activity
|
611 |
*
|
612 |
* @return int The number of active members
|
613 |
*/
|
657 |
global $wpdb;
|
658 |
|
659 |
// Bail if no user ID
|
660 |
+
if ( empty( $user_id ) ) {
|
661 |
return;
|
662 |
+
}
|
663 |
|
664 |
// Bail if user ID is super admin
|
665 |
+
if ( is_super_admin( $user_id ) ) {
|
666 |
return;
|
667 |
+
}
|
668 |
|
669 |
// Get the functions file
|
670 |
if ( is_multisite() ) {
|
689 |
// Get the blogs for the user
|
690 |
$blogs = get_blogs_of_user( $user_id, true );
|
691 |
|
692 |
+
foreach ( (array) array_values( $blogs ) as $details ) {
|
693 |
|
694 |
// Do not mark the main or current root blog as spam
|
695 |
if ( 1 == $details->userblog_id || bp_get_root_blog_id() == $details->userblog_id ) {
|
735 |
}
|
736 |
|
737 |
/**
|
738 |
+
* Hook to WP's make_spam_user and run our custom BP spam functions.
|
739 |
*
|
740 |
+
* @since BuddyPress (1.6.0)
|
741 |
*
|
742 |
+
* @param int $user_id The user ID passed from the make_spam_user hook.
|
743 |
*/
|
744 |
function bp_core_mark_user_spam_admin( $user_id ) {
|
745 |
bp_core_process_spammer_status( $user_id, 'spam', false );
|
747 |
add_action( 'make_spam_user', 'bp_core_mark_user_spam_admin' );
|
748 |
|
749 |
/**
|
750 |
+
* Hook to WP's make_ham_user and run our custom BP spam functions.
|
751 |
*
|
752 |
+
* @since BuddyPress (1.6.0)
|
753 |
*
|
754 |
+
* @param int $user_id The user ID passed from the make_ham_user hook.
|
755 |
*/
|
756 |
function bp_core_mark_user_ham_admin( $user_id ) {
|
757 |
bp_core_process_spammer_status( $user_id, 'ham', false );
|
759 |
add_action( 'make_ham_user', 'bp_core_mark_user_ham_admin' );
|
760 |
|
761 |
/**
|
762 |
+
* Check whether a user has been marked as a spammer.
|
763 |
*
|
764 |
+
* @param int $user_id The ID for the user.
|
765 |
+
* @return bool True if spammer, otherwise false.
|
|
|
766 |
*/
|
767 |
function bp_is_user_spammer( $user_id = 0 ) {
|
768 |
|
769 |
// No user to check
|
770 |
+
if ( empty( $user_id ) ) {
|
771 |
return false;
|
772 |
+
}
|
773 |
|
774 |
$bp = buddypress();
|
775 |
|
803 |
} else {
|
804 |
|
805 |
// Check if spam
|
806 |
+
if ( !empty( $user->spam ) ) {
|
807 |
$is_spammer = true;
|
808 |
+
}
|
809 |
|
810 |
+
if ( 1 == $user->user_status ) {
|
811 |
$is_spammer = true;
|
812 |
+
}
|
813 |
}
|
814 |
|
815 |
return apply_filters( 'bp_is_user_spammer', (bool) $is_spammer );
|
816 |
}
|
817 |
|
818 |
/**
|
819 |
+
* Check whether a user has been marked as deleted.
|
820 |
*
|
821 |
+
* @param int $user_id The ID for the user.
|
822 |
+
* @return bool True if deleted, otherwise false.
|
|
|
823 |
*/
|
824 |
function bp_is_user_deleted( $user_id = 0 ) {
|
825 |
|
826 |
// No user to check
|
827 |
+
if ( empty( $user_id ) ) {
|
828 |
return false;
|
829 |
+
}
|
830 |
|
831 |
$bp = buddypress();
|
832 |
|
860 |
} else {
|
861 |
|
862 |
// Check if deleted
|
863 |
+
if ( !empty( $user->deleted ) ) {
|
864 |
$is_deleted = true;
|
865 |
+
}
|
866 |
|
867 |
+
if ( 2 == $user->user_status ) {
|
868 |
$is_deleted = true;
|
869 |
+
}
|
870 |
}
|
871 |
|
872 |
return apply_filters( 'bp_is_user_deleted', (bool) $is_deleted );
|
873 |
}
|
874 |
|
875 |
/**
|
876 |
+
* Check whether a user is "active", ie neither deleted nor spammer.
|
877 |
*
|
878 |
+
* @since BuddyPress (1.6.0)
|
879 |
*
|
880 |
* @uses is_user_logged_in() To check if user is logged in
|
881 |
* @uses bp_loggedin_user_id() To get current user ID
|
882 |
* @uses bp_is_user_spammer() To check if user is spammer
|
883 |
* @uses bp_is_user_deleted() To check if user is deleted
|
884 |
*
|
885 |
+
* @param int $user_id The user ID to check.
|
886 |
+
* @return bool True if active, otherwise false.
|
887 |
*/
|
888 |
function bp_is_user_active( $user_id = 0 ) {
|
889 |
|
890 |
// Default to current user
|
891 |
+
if ( empty( $user_id ) && is_user_logged_in() ) {
|
892 |
$user_id = bp_loggedin_user_id();
|
893 |
+
}
|
894 |
|
895 |
// No user to check
|
896 |
+
if ( empty( $user_id ) ) {
|
897 |
return false;
|
898 |
+
}
|
899 |
|
900 |
// Check spam
|
901 |
+
if ( bp_is_user_spammer( $user_id ) ) {
|
902 |
return false;
|
903 |
+
}
|
904 |
|
905 |
// Check deleted
|
906 |
+
if ( bp_is_user_deleted( $user_id ) ) {
|
907 |
return false;
|
908 |
+
}
|
909 |
|
910 |
// Assume true if not spam or deleted
|
911 |
return true;
|
912 |
}
|
913 |
|
914 |
/**
|
915 |
+
* Check whether user is not active.
|
916 |
*
|
917 |
+
* @since BuddyPress (1.6.0)
|
918 |
+
*
|
919 |
+
* @todo No need for the user fallback checks, since they're done in
|
920 |
+
* bp_is_user_active().
|
921 |
*
|
922 |
* @uses is_user_logged_in() To check if user is logged in
|
923 |
* @uses bp_get_displayed_user_id() To get current user ID
|
924 |
* @uses bp_is_user_active() To check if user is active
|
925 |
*
|
926 |
+
* @param int $user_id The user ID to check.
|
927 |
+
* @return bool True if inactive, otherwise false.
|
928 |
*/
|
929 |
function bp_is_user_inactive( $user_id = 0 ) {
|
930 |
|
931 |
// Default to current user
|
932 |
+
if ( empty( $user_id ) && is_user_logged_in() ) {
|
933 |
$user_id = bp_loggedin_user_id();
|
934 |
+
}
|
935 |
|
936 |
// No user to check
|
937 |
+
if ( empty( $user_id ) ) {
|
938 |
return false;
|
939 |
+
}
|
940 |
|
941 |
// Return the inverse of active
|
942 |
return !bp_is_user_active( $user_id );
|
952 |
* @return bool True on success, false on failure.
|
953 |
*/
|
954 |
function bp_update_user_last_activity( $user_id = 0, $time = '' ) {
|
955 |
+
|
956 |
// Fall back on current user
|
957 |
if ( empty( $user_id ) ) {
|
958 |
$user_id = bp_loggedin_user_id();
|
997 |
* @param string $meta_key Meta key being fetched.
|
998 |
*/
|
999 |
function _bp_get_user_meta_last_activity_warning( $retval, $object_id, $meta_key ) {
|
1000 |
+
static $warned = false;
|
1001 |
|
1002 |
if ( 'last_activity' === $meta_key ) {
|
1003 |
// Don't send the warning more than once per pageload
|
1004 |
+
if ( false === $warned ) {
|
1005 |
_doing_it_wrong( 'get_user_meta( $user_id, \'last_activity\' )', __( 'User last_activity data is no longer stored in usermeta. Use bp_get_user_last_activity() instead.', 'buddypress' ), '2.0.0' );
|
1006 |
+
$warned = true;
|
1007 |
}
|
1008 |
|
1009 |
return bp_get_user_last_activity( $object_id );
|
1069 |
|
1070 |
$bp = buddypress();
|
1071 |
|
1072 |
+
// Wipe out existing last_activity data in the activity table -
|
1073 |
+
// this helps to prevent duplicates when pulling from the usermeta
|
1074 |
+
// table
|
1075 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->members->table_name_last_activity} WHERE component = %s AND type = 'last_activity'", $bp->members->id ) );
|
1076 |
+
|
1077 |
$sql = "INSERT INTO {$bp->members->table_name_last_activity} (`user_id`, `component`, `type`, `action`, `content`, `primary_link`, `item_id`, `date_recorded` ) (
|
1078 |
SELECT user_id, '{$bp->members->id}' as component, 'last_activity' as type, '' as action, '' as content, '' as primary_link, 0 as item_id, meta_value AS date_recorded
|
1079 |
FROM {$wpdb->usermeta}
|
1080 |
WHERE
|
1081 |
meta_key = 'last_activity'
|
|
|
|
|
|
|
|
|
|
|
|
|
1082 |
);";
|
1083 |
|
1084 |
return $wpdb->query( $sql );
|
1087 |
/**
|
1088 |
* Fetch every post that is authored by the given user for the current blog.
|
1089 |
*
|
1090 |
+
* No longer used in BuddyPress.
|
1091 |
+
*
|
1092 |
+
* @todo Deprecate.
|
1093 |
+
*
|
1094 |
+
* @param int $user_id ID of the user being queried.
|
1095 |
+
* @return array Post IDs.
|
1096 |
*/
|
1097 |
function bp_core_get_all_posts_for_user( $user_id = 0 ) {
|
1098 |
global $wpdb;
|
1099 |
|
1100 |
+
if ( empty( $user_id ) ) {
|
1101 |
$user_id = bp_displayed_user_id();
|
1102 |
+
}
|
1103 |
|
1104 |
return apply_filters( 'bp_core_get_all_posts_for_user', $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_status = 'publish' AND post_type = 'post'", $user_id ) ) );
|
1105 |
}
|
1106 |
|
1107 |
/**
|
1108 |
+
* Process account deletion requests.
|
1109 |
+
*
|
1110 |
+
* Primarily used for self-deletions, as requested through Settings.
|
1111 |
*
|
1112 |
+
* @param int $user_id Optional. ID of the user to be deleted. Default: the
|
1113 |
+
* logged-in user.
|
1114 |
+
* @return bool True on success, false on failure.
|
1115 |
*/
|
1116 |
function bp_core_delete_account( $user_id = 0 ) {
|
1117 |
|
1118 |
// Use logged in user ID if none is passed
|
1119 |
+
if ( empty( $user_id ) ) {
|
1120 |
$user_id = bp_loggedin_user_id();
|
1121 |
+
}
|
1122 |
|
1123 |
// Site admins cannot be deleted
|
1124 |
+
if ( is_super_admin( $user_id ) ) {
|
1125 |
return false;
|
1126 |
+
}
|
1127 |
|
1128 |
// Extra checks if user is not deleting themselves
|
1129 |
if ( bp_loggedin_user_id() !== absint( $user_id ) ) {
|
1177 |
add_action( 'delete_user', 'bp_core_delete_avatar_on_user_delete' );
|
1178 |
|
1179 |
/**
|
1180 |
+
* Multibyte-safe ucfirst() support.
|
1181 |
*
|
1182 |
+
* Uses multibyte functions when available on the PHP build.
|
1183 |
+
*
|
1184 |
+
* @param string $str String to be upper-cased.
|
1185 |
+
* @return string
|
1186 |
*/
|
1187 |
function bp_core_ucfirst( $str ) {
|
1188 |
if ( function_exists( 'mb_strtoupper' ) && function_exists( 'mb_substr' ) ) {
|
1194 |
}
|
1195 |
|
1196 |
/**
|
1197 |
+
* Prevent spammers from logging in.
|
|
|
1198 |
*
|
1199 |
+
* When a user logs in, check if they have been marked as a spammer. If yes
|
1200 |
+
* then simply redirect them to the home page and stop them from logging in.
|
1201 |
*
|
1202 |
* @since BuddyPress (1.1.2)
|
1203 |
+
*
|
1204 |
+
* @param WP_User|WP_Error $user Either the WP_User object or the WP_Error
|
1205 |
+
* object, as passed to the 'authenticate' filter.
|
1206 |
+
* @return WP_User|WP_Error If the user is not a spammer, return the WP_User
|
1207 |
+
* object. Otherwise a new WP_Error object.
|
1208 |
*/
|
1209 |
function bp_core_boot_spammer( $user ) {
|
1210 |
+
|
1211 |
// check to see if the $user has already failed logging in, if so return $user as-is
|
1212 |
+
if ( is_wp_error( $user ) || empty( $user ) ) {
|
1213 |
return $user;
|
1214 |
+
}
|
1215 |
|
1216 |
// the user exists; now do a check to see if the user is a spammer
|
1217 |
// if the user is a spammer, stop them in their tracks!
|
1218 |
+
if ( is_a( $user, 'WP_User' ) && ( ( is_multisite() && (int) $user->spam ) || 1 == $user->user_status ) ) {
|
1219 |
return new WP_Error( 'invalid_username', __( '<strong>ERROR</strong>: Your account has been marked as a spammer.', 'buddypress' ) );
|
1220 |
+
}
|
1221 |
|
1222 |
// user is good to go!
|
1223 |
return $user;
|
1225 |
add_filter( 'authenticate', 'bp_core_boot_spammer', 30 );
|
1226 |
|
1227 |
/**
|
1228 |
+
* Delete last_activity data for the user when the user is deleted.
|
1229 |
*
|
1230 |
+
* @param int $user_id The user ID for the user to delete usermeta for.
|
|
|
|
|
1231 |
*/
|
1232 |
function bp_core_remove_data( $user_id ) {
|
1233 |
|
1241 |
add_action( 'delete_user', 'bp_core_remove_data' );
|
1242 |
add_action( 'bp_make_spam_user', 'bp_core_remove_data' );
|
1243 |
|
1244 |
+
/**
|
1245 |
+
* Check whether the logged-in user can edit settings for the displayed user.
|
1246 |
+
*
|
1247 |
+
* @return bool True if editing is allowed, otherwise false.
|
1248 |
+
*/
|
1249 |
function bp_core_can_edit_settings() {
|
1250 |
+
if ( bp_is_my_profile() ) {
|
1251 |
return true;
|
1252 |
+
}
|
1253 |
|
1254 |
if ( is_super_admin( bp_displayed_user_id() ) && ! is_super_admin() ) {
|
1255 |
return false;
|
1256 |
}
|
1257 |
|
1258 |
+
if ( bp_current_user_can( 'bp_moderate' ) || current_user_can( 'edit_users' ) ) {
|
1259 |
return true;
|
1260 |
+
}
|
1261 |
|
1262 |
return false;
|
1263 |
}
|
1265 |
/** Sign-up *******************************************************************/
|
1266 |
|
1267 |
/**
|
1268 |
+
* Flush illegal names by getting and setting 'illegal_names' site option.
|
1269 |
*/
|
1270 |
function bp_core_flush_illegal_names() {
|
1271 |
$illegal_names = get_site_option( 'illegal_names' );
|
1273 |
}
|
1274 |
|
1275 |
/**
|
1276 |
+
* Add BuddyPress-specific items to the illegal_names array.
|
|
|
1277 |
*
|
1278 |
+
* @param array|string $value Illegal names as being saved defined in
|
1279 |
+
* Multisite settings.
|
1280 |
+
* @param array|string $oldvalue The old value of the option.
|
1281 |
+
* @return array Merged and unique array of illegal names.
|
1282 |
*/
|
1283 |
function bp_core_get_illegal_names( $value = '', $oldvalue = '' ) {
|
1284 |
|
1344 |
add_filter( 'pre_update_site_option_illegal_names', 'bp_core_get_illegal_names', 10, 2 );
|
1345 |
|
1346 |
/**
|
1347 |
+
* Check that an email address is valid for use.
|
1348 |
*
|
1349 |
* Performs the following checks:
|
1350 |
* - Is the email address well-formed?
|
1356 |
*
|
1357 |
* @param string $user_email The email being checked
|
1358 |
* @return bool|array True if the address passes all checks; otherwise an array
|
1359 |
+
* of error codes.
|
1360 |
*/
|
1361 |
function bp_core_validate_email_address( $user_email ) {
|
1362 |
$errors = array();
|
1364 |
$user_email = sanitize_email( $user_email );
|
1365 |
|
1366 |
// Is the email well-formed?
|
1367 |
+
if ( ! is_email( $user_email ) ) {
|
1368 |
$errors['invalid'] = 1;
|
1369 |
+
}
|
1370 |
|
1371 |
// Is the email on the Banned Email Domains list?
|
1372 |
// Note: This check only works on Multisite
|
1373 |
+
if ( function_exists( 'is_email_address_unsafe' ) && is_email_address_unsafe( $user_email ) ) {
|
1374 |
$errors['domain_banned'] = 1;
|
1375 |
+
}
|
1376 |
|
1377 |
// Is the email on the Limited Email Domains list?
|
1378 |
// Note: This check only works on Multisite
|
1385 |
}
|
1386 |
|
1387 |
// Is the email alreday in use?
|
1388 |
+
if ( email_exists( $user_email ) ) {
|
1389 |
$errors['in_use'] = 1;
|
1390 |
+
}
|
1391 |
|
1392 |
$retval = ! empty( $errors ) ? $errors : true;
|
1393 |
|
1395 |
}
|
1396 |
|
1397 |
/**
|
1398 |
+
* Add the appropriate errors to a WP_Error object, given results of a validation test.
|
1399 |
*
|
1400 |
* Functions like bp_core_validate_email_address() return a structured array
|
1401 |
* of error codes. bp_core_add_validation_error_messages() takes this array and
|
1402 |
* parses, adding the appropriate error messages to the WP_Error object.
|
1403 |
*
|
1404 |
+
* @since BuddyPress (1.7.0)
|
1405 |
+
*
|
1406 |
* @see bp_core_validate_email_address()
|
1407 |
*
|
1408 |
+
* @param WP_Error $errors WP_Error object.
|
1409 |
* @param array $validation_results The return value of a validation function
|
1410 |
+
* like bp_core_validate_email_address().
|
1411 |
*/
|
1412 |
function bp_core_add_validation_error_messages( WP_Error $errors, $validation_results ) {
|
1413 |
+
if ( ! empty( $validation_results['invalid'] ) ) {
|
1414 |
$errors->add( 'user_email', __( 'Please check your email address.', 'buddypress' ) );
|
1415 |
+
}
|
1416 |
|
1417 |
+
if ( ! empty( $validation_results['domain_banned'] ) ) {
|
1418 |
$errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) );
|
1419 |
+
}
|
1420 |
|
1421 |
+
if ( ! empty( $validation_results['domain_not_allowed'] ) ) {
|
1422 |
$errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) );
|
1423 |
+
}
|
1424 |
|
1425 |
+
if ( ! empty( $validation_results['in_use'] ) ) {
|
1426 |
$errors->add( 'user_email', __( 'Sorry, that email address is already used!', 'buddypress' ) );
|
1427 |
+
}
|
1428 |
}
|
1429 |
|
1430 |
/**
|
1431 |
* Validate a user name and email address when creating a new user.
|
1432 |
*
|
1433 |
+
* @param string $user_name Username to validate.
|
1434 |
+
* @param string $user_email Email address to validate.
|
1435 |
+
* @return array Results of user validation including errors, if any.
|
1436 |
*/
|
1437 |
function bp_core_validate_user_signup( $user_name, $user_email ) {
|
1438 |
|
1517 |
return apply_filters( 'bp_core_validate_user_signup', $result );
|
1518 |
}
|
1519 |
|
1520 |
+
/**
|
1521 |
+
* Validate blog URL and title provided at signup.
|
1522 |
+
*
|
1523 |
+
* @todo Why do we have this wrapper?
|
1524 |
+
*
|
1525 |
+
* @param string $blog_url Blog URL requested during registration.
|
1526 |
+
* @param string $blog_title Blog title requested during registration.
|
1527 |
+
* @return array
|
1528 |
+
*/
|
1529 |
function bp_core_validate_blog_signup( $blog_url, $blog_title ) {
|
1530 |
+
if ( ! is_multisite() || ! function_exists( 'wpmu_validate_blog_signup' ) ) {
|
1531 |
return false;
|
1532 |
+
}
|
1533 |
|
1534 |
return apply_filters( 'bp_core_validate_blog_signup', wpmu_validate_blog_signup( $blog_url, $blog_title ) );
|
1535 |
}
|
1536 |
|
1537 |
+
/**
|
1538 |
+
* Process data submitted at user registration and convert to a signup object.
|
1539 |
+
*
|
1540 |
+
* @todo There appears to be a bug in the return value on success.
|
1541 |
+
*
|
1542 |
+
* @param string $user_login Login name requested by the user.
|
1543 |
+
* @param string $user_password Password requested by the user.
|
1544 |
+
* @param string $user_email Email address entered by the user.
|
1545 |
+
* @param array $usermeta Miscellaneous metadata about the user (blog-specific
|
1546 |
+
* signup data, xprofile data, etc).
|
1547 |
+
* @return bool|WP_Error True on success, WP_Error on failure.
|
1548 |
+
*/
|
1549 |
function bp_core_signup_user( $user_login, $user_password, $user_email, $usermeta ) {
|
1550 |
+
$bp = buddypress();
|
1551 |
|
1552 |
// We need to cast $user_id to pass to the filters
|
1553 |
$user_id = false;
|
1607 |
return $user_id;
|
1608 |
}
|
1609 |
|
1610 |
+
/**
|
1611 |
+
* Create a blog and user based on data supplied at user registration.
|
1612 |
+
*
|
1613 |
+
* @param string $blog_domain Domain requested by user.
|
1614 |
+
* @param string $blog_path Path requested by user.
|
1615 |
+
* @param string $blog_title Title as entered by user.
|
1616 |
+
* @param string $user_name user_login of requesting user.
|
1617 |
+
* @param string $user_email Email address of requesting user.
|
1618 |
+
* @param string $usermeta Miscellaneous metadata for the user.
|
1619 |
+
*/
|
1620 |
function bp_core_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) {
|
1621 |
+
if ( ! is_multisite() || ! function_exists( 'wpmu_signup_blog' ) ) {
|
1622 |
return false;
|
1623 |
+
}
|
1624 |
|
1625 |
return apply_filters( 'bp_core_signup_blog', wpmu_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) );
|
1626 |
}
|
1627 |
|
1628 |
+
/**
|
1629 |
+
* Activate a signup, as identified by an activation key.
|
1630 |
+
*
|
1631 |
+
* @param string $key Activation key.
|
1632 |
+
* @return int|bool User ID on success, false on failure.
|
1633 |
+
*/
|
1634 |
function bp_core_activate_signup( $key ) {
|
1635 |
global $wpdb;
|
1636 |
|
1736 |
foreach( (array) $profile_field_ids as $field_id ) {
|
1737 |
$current_field = isset( $user['meta']["field_{$field_id}"] ) ? $user['meta']["field_{$field_id}"] : false;
|
1738 |
|
1739 |
+
if ( !empty( $current_field ) ) {
|
1740 |
xprofile_set_field_data( $field_id, $user_id, $current_field );
|
1741 |
+
}
|
1742 |
|
1743 |
// Save the visibility level
|
1744 |
$visibility_level = ! empty( $user['meta']['field_' . $field_id . '_visibility'] ) ? $user['meta']['field_' . $field_id . '_visibility'] : 'public';
|
1844 |
}
|
1845 |
}
|
1846 |
|
1847 |
+
/**
|
1848 |
+
* Create a "became a registered user" activity item when a user activates his account.
|
1849 |
+
*
|
1850 |
+
* @param array $user Array of userdata passed to bp_core_activated_user hook.
|
1851 |
+
*/
|
1852 |
function bp_core_new_user_activity( $user ) {
|
1853 |
+
if ( empty( $user ) || ! bp_is_active( 'activity' ) || ! bp_is_active( 'xprofile' ) ) {
|
1854 |
return false;
|
1855 |
+
}
|
1856 |
|
1857 |
+
if ( is_array( $user ) ) {
|
1858 |
$user_id = $user['user_id'];
|
1859 |
+
} else {
|
1860 |
$user_id = $user;
|
1861 |
+
}
|
1862 |
|
1863 |
+
if ( empty( $user_id ) ) {
|
1864 |
return false;
|
1865 |
+
}
|
|
|
1866 |
|
1867 |
bp_activity_add( array(
|
1868 |
'user_id' => $user_id,
|
1872 |
}
|
1873 |
add_action( 'bp_core_activated_user', 'bp_core_new_user_activity' );
|
1874 |
|
1875 |
+
/**
|
1876 |
+
* Map a user's WP display name to the XProfile fullname field, if necessary.
|
1877 |
+
*
|
1878 |
+
* This only happens when a user is registered in wp-admin by an administrator;
|
1879 |
+
* during normal registration, XProfile data is provided directly by the user.
|
1880 |
+
*
|
1881 |
+
* @param int $user_id ID of the user.
|
1882 |
+
*/
|
1883 |
function bp_core_map_user_registration( $user_id ) {
|
1884 |
|
1885 |
// Only map data when the site admin is adding users, not on registration.
|
1886 |
+
if ( ! is_admin() ) {
|
1887 |
return false;
|
1888 |
+
}
|
1889 |
|
1890 |
// Add the user's fullname to Xprofile
|
1891 |
if ( bp_is_active( 'xprofile' ) ) {
|
1893 |
$lastname = ' ' . bp_get_user_meta( $user_id, 'last_name', true );
|
1894 |
$name = $firstname . $lastname;
|
1895 |
|
1896 |
+
if ( empty( $name ) || ' ' == $name ) {
|
1897 |
$name = bp_get_user_meta( $user_id, 'nickname', true );
|
1898 |
+
}
|
1899 |
|
1900 |
xprofile_set_field_data( 1, $user_id, $name );
|
1901 |
}
|
1902 |
}
|
1903 |
add_action( 'user_register', 'bp_core_map_user_registration' );
|
1904 |
|
1905 |
+
/**
|
1906 |
+
* Get the avatar storage directory for use during registration.
|
1907 |
+
*
|
1908 |
+
* @return string|bool Directory path on success, false on failure.
|
1909 |
+
*/
|
1910 |
function bp_core_signup_avatar_upload_dir() {
|
1911 |
+
$bp = buddypress();
|
1912 |
|
1913 |
+
if ( empty( $bp->signup->avatar_dir ) ) {
|
1914 |
return false;
|
1915 |
+
}
|
1916 |
|
1917 |
$path = bp_core_avatar_upload_path() . '/avatars/signups/' . $bp->signup->avatar_dir;
|
1918 |
$newbdir = $path;
|
1919 |
|
1920 |
+
if ( ! file_exists( $path ) ) {
|
1921 |
@wp_mkdir_p( $path );
|
1922 |
+
}
|
1923 |
|
1924 |
$newurl = bp_core_avatar_url() . '/avatars/signups/' . $bp->signup->avatar_dir;
|
1925 |
$newburl = $newurl;
|
1926 |
$newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir;
|
1927 |
|
1928 |
+
return apply_filters( 'bp_core_signup_avatar_upload_dir', array(
|
1929 |
+
'path' => $path,
|
1930 |
+
'url' => $newurl,
|
1931 |
+
'subdir' => $newsubdir,
|
1932 |
+
'basedir' => $newbdir,
|
1933 |
+
'baseurl' => $newburl,
|
1934 |
+
'error' => false
|
1935 |
+
) );
|
1936 |
}
|
1937 |
|
1938 |
+
/**
|
1939 |
+
* Send activation email to a newly registered user.
|
1940 |
+
*
|
1941 |
+
* @param int $user_id ID of the new user.
|
1942 |
+
* @param string $user_email Email address of the new user.
|
1943 |
+
* @param string $key Activation key.
|
1944 |
+
*/
|
1945 |
function bp_core_signup_send_validation_email( $user_id, $user_email, $key ) {
|
1946 |
$activate_url = bp_get_activation_page() ."?key=$key";
|
1947 |
$activate_url = esc_url( $activate_url );
|
2048 |
if ( ! empty( $resend['errors'] ) ) {
|
2049 |
$error = __( '<strong>ERROR</strong>: Your account has already been activated.', 'buddypress' );
|
2050 |
} else {
|
2051 |
+
$error = __( 'Activation email resent! Please check your inbox or spam folder.', 'buddypress' );
|
2052 |
}
|
2053 |
}
|
2054 |
add_action( 'login_form_bp-resend-activation', 'bp_members_login_resend_activation_email' );
|
2055 |
|
2056 |
/**
|
2057 |
+
* Redirect away from wp-signup.php if BP registration templates are present.
|
2058 |
*/
|
2059 |
function bp_core_wpsignup_redirect() {
|
2060 |
|
2061 |
// Bail in admin or if custom signup page is broken
|
2062 |
+
if ( is_admin() || ! bp_has_custom_signup_page() ) {
|
2063 |
return;
|
2064 |
+
}
|
2065 |
|
2066 |
$action = !empty( $_GET['action'] ) ? $_GET['action'] : '';
|
2067 |
|
2068 |
// Not at the WP core signup page and action is not register
|
2069 |
+
if ( ! empty( $_SERVER['SCRIPT_NAME'] ) && false === strpos( $_SERVER['SCRIPT_NAME'], 'wp-signup.php' ) && ( 'register' != $action ) ) {
|
2070 |
return;
|
2071 |
+
}
|
2072 |
|
2073 |
bp_core_redirect( bp_get_signup_page() );
|
2074 |
}
|
2093 |
*
|
2094 |
* This is important as the $bp->loggedin_user object is setup at priority 4.
|
2095 |
*
|
2096 |
+
* @since BuddyPress (1.8.0)
|
2097 |
*/
|
2098 |
function bp_stop_live_spammer() {
|
2099 |
// if we're on the login page, stop now to prevent redirect loop
|
2137 |
/**
|
2138 |
* Show a custom error message when a logged-in user is marked as a spammer.
|
2139 |
*
|
2140 |
+
* @since BuddyPress (1.8.0)
|
2141 |
*/
|
2142 |
function bp_live_spammer_login_error() {
|
2143 |
global $error;
|
@@ -1,9 +1,8 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* BuddyPress Member Loader
|
4 |
*
|
5 |
-
* A members component to help contain all of the user specific slugs
|
6 |
-
*
|
7 |
* @package BuddyPress
|
8 |
* @subpackage Members
|
9 |
*/
|
@@ -14,9 +13,9 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|
14 |
class BP_Members_Component extends BP_Component {
|
15 |
|
16 |
/**
|
17 |
-
* Start the members component creation process
|
18 |
*
|
19 |
-
* @since BuddyPress (1.5)
|
20 |
*/
|
21 |
public function __construct() {
|
22 |
parent::start(
|
@@ -30,23 +29,26 @@ class BP_Members_Component extends BP_Component {
|
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
-
* Include files
|
34 |
*
|
35 |
-
* @
|
|
|
|
|
36 |
*/
|
37 |
public function includes( $includes = array() ) {
|
|
|
|
|
38 |
$includes = array(
|
39 |
'actions',
|
40 |
'classes',
|
41 |
'filters',
|
42 |
'screens',
|
43 |
'template',
|
44 |
-
'buddybar',
|
45 |
'adminbar',
|
46 |
-
'functions'
|
47 |
-
'notifications',
|
48 |
);
|
49 |
|
|
|
50 |
if ( is_admin() ) {
|
51 |
$includes[] = 'admin';
|
52 |
}
|
@@ -55,38 +57,49 @@ class BP_Members_Component extends BP_Component {
|
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
-
*
|
59 |
*
|
60 |
* The BP_MEMBERS_SLUG constant is deprecated, and only used here for
|
61 |
* backwards compatibility.
|
62 |
*
|
63 |
-
* @since BuddyPress (1.5)
|
|
|
|
|
|
|
|
|
64 |
*/
|
65 |
public function setup_globals( $args = array() ) {
|
66 |
$bp = buddypress();
|
67 |
|
68 |
-
|
69 |
-
|
|
|
|
|
70 |
define( 'BP_MEMBERS_SLUG', $this->id );
|
|
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
'
|
75 |
-
'
|
|
|
76 |
'directory_title' => _x( 'Members', 'component directory title', 'buddypress' ),
|
77 |
-
'
|
|
|
78 |
'table_name_last_activity' => bp_core_get_table_prefix() . 'bp_activity',
|
79 |
'table_name_signups' => bp_core_get_table_prefix() . 'signups',
|
80 |
-
)
|
81 |
-
'search_string' => __( 'Search Members...', 'buddypress' ),
|
82 |
);
|
83 |
|
84 |
-
parent::setup_globals( $
|
85 |
|
86 |
/** Logged in user ****************************************************/
|
87 |
|
|
|
|
|
|
|
88 |
// Fetch the full name for the logged in user
|
89 |
-
$bp->loggedin_user->fullname =
|
90 |
|
91 |
// Hits the DB on single WP installs so get this separately
|
92 |
$bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin( bp_loggedin_user_id() );
|
@@ -94,21 +107,19 @@ class BP_Members_Component extends BP_Component {
|
|
94 |
// The domain for the user currently logged in. eg: http://domain.com/members/andy
|
95 |
$bp->loggedin_user->domain = bp_core_get_user_domain( bp_loggedin_user_id() );
|
96 |
|
97 |
-
// The core userdata of the user who is currently logged in.
|
98 |
-
$bp->loggedin_user->userdata = bp_core_get_core_userdata( bp_loggedin_user_id() );
|
99 |
-
|
100 |
/** Displayed user ****************************************************/
|
101 |
|
102 |
-
// The domain for the user currently being displayed
|
103 |
-
$bp->displayed_user->domain = bp_core_get_user_domain( bp_displayed_user_id() );
|
104 |
-
|
105 |
// The core userdata of the user who is currently being displayed
|
106 |
$bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() );
|
107 |
|
108 |
// Fetch the full name displayed user
|
109 |
-
$bp->displayed_user->fullname =
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
-
/** Signup ***************************************************/
|
112 |
$bp->signup = new stdClass;
|
113 |
|
114 |
/** Profiles Fallback *************************************************/
|
@@ -118,20 +129,30 @@ class BP_Members_Component extends BP_Component {
|
|
118 |
$bp->profile->slug = 'profile';
|
119 |
$bp->profile->id = 'profile';
|
120 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
/** Default Profile Component *****************************************/
|
123 |
|
124 |
-
if (
|
|
|
|
|
125 |
if ( bp_is_active( 'activity' ) && isset( $bp->pages->activity ) ) {
|
126 |
$bp->default_component = bp_get_activity_slug();
|
127 |
} else {
|
128 |
$bp->default_component = ( 'xprofile' === $bp->profile->id ) ? 'profile' : $bp->profile->id;
|
129 |
}
|
130 |
-
|
131 |
-
} else {
|
132 |
-
$bp->default_component = BP_DEFAULT_COMPONENT;
|
133 |
}
|
134 |
|
|
|
|
|
135 |
if ( bp_displayed_user_id() ) {
|
136 |
$bp->canonical_stack['base_url'] = bp_displayed_user_domain();
|
137 |
|
@@ -147,10 +168,12 @@ class BP_Members_Component extends BP_Component {
|
|
147 |
$bp->canonical_stack['action_variables'] = bp_action_variables();
|
148 |
}
|
149 |
|
150 |
-
|
|
|
151 |
$bp->current_component = $bp->default_component;
|
152 |
-
|
153 |
-
|
|
|
154 |
unset( $bp->canonical_stack['component'] );
|
155 |
}
|
156 |
|
@@ -167,69 +190,82 @@ class BP_Members_Component extends BP_Component {
|
|
167 |
}
|
168 |
|
169 |
/**
|
170 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
*/
|
172 |
public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
$bp = buddypress();
|
174 |
|
175 |
-
//
|
176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
|
183 |
-
|
184 |
-
'name' => __( 'Profile', 'buddypress' ),
|
185 |
-
'slug' => $bp->profile->slug,
|
186 |
-
'position' => 20,
|
187 |
-
'screen_function' => 'bp_members_screen_display_profile',
|
188 |
-
'default_subnav_slug' => 'public',
|
189 |
-
'item_css_id' => $bp->profile->id
|
190 |
-
);
|
191 |
-
|
192 |
-
// User links
|
193 |
-
$user_domain = bp_displayed_user_domain() ? bp_displayed_user_domain() : bp_loggedin_user_domain();
|
194 |
-
$profile_link = trailingslashit( $user_domain . $bp->profile->slug );
|
195 |
-
|
196 |
-
// Add the subnav items to the profile
|
197 |
-
$sub_nav[] = array(
|
198 |
-
'name' => __( 'View', 'buddypress' ),
|
199 |
-
'slug' => 'public',
|
200 |
-
'parent_url' => $profile_link,
|
201 |
-
'parent_slug' => $bp->profile->slug,
|
202 |
-
'screen_function' => 'bp_members_screen_display_profile',
|
203 |
-
'position' => 10
|
204 |
-
);
|
205 |
-
|
206 |
-
parent::setup_nav( $main_nav, $sub_nav );
|
207 |
-
}
|
208 |
}
|
209 |
|
210 |
/**
|
211 |
-
*
|
212 |
-
*
|
213 |
-
* @global BuddyPress $bp The one true BuddyPress instance
|
214 |
*/
|
215 |
public function setup_title() {
|
216 |
$bp = buddypress();
|
217 |
|
218 |
if ( bp_is_my_profile() ) {
|
219 |
$bp->bp_options_title = __( 'You', 'buddypress' );
|
220 |
-
} elseif( bp_is_user() ) {
|
|
|
221 |
$bp->bp_options_avatar = bp_core_fetch_avatar( array(
|
222 |
'item_id' => bp_displayed_user_id(),
|
223 |
'type' => 'thumb',
|
224 |
-
'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ),
|
225 |
) );
|
226 |
-
$bp->bp_options_title = bp_get_displayed_user_fullname();
|
227 |
}
|
228 |
|
229 |
parent::setup_title();
|
230 |
}
|
231 |
}
|
232 |
|
|
|
|
|
|
|
233 |
function bp_setup_members() {
|
234 |
buddypress()->members = new BP_Members_Component();
|
235 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* BuddyPress Member Loader
|
5 |
*
|
|
|
|
|
6 |
* @package BuddyPress
|
7 |
* @subpackage Members
|
8 |
*/
|
13 |
class BP_Members_Component extends BP_Component {
|
14 |
|
15 |
/**
|
16 |
+
* Start the members component creation process.
|
17 |
*
|
18 |
+
* @since BuddyPress (1.5.0)
|
19 |
*/
|
20 |
public function __construct() {
|
21 |
parent::start(
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
+
* Include bp-members files.
|
33 |
*
|
34 |
+
* @see BP_Component::includes() for description of parameters.
|
35 |
+
*
|
36 |
+
* @param array $includes See {@link BP_Component::includes()}.
|
37 |
*/
|
38 |
public function includes( $includes = array() ) {
|
39 |
+
|
40 |
+
// Always include these files
|
41 |
$includes = array(
|
42 |
'actions',
|
43 |
'classes',
|
44 |
'filters',
|
45 |
'screens',
|
46 |
'template',
|
|
|
47 |
'adminbar',
|
48 |
+
'functions'
|
|
|
49 |
);
|
50 |
|
51 |
+
// Include these only if in admin
|
52 |
if ( is_admin() ) {
|
53 |
$includes[] = 'admin';
|
54 |
}
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
+
* Set up bp-members global settings.
|
61 |
*
|
62 |
* The BP_MEMBERS_SLUG constant is deprecated, and only used here for
|
63 |
* backwards compatibility.
|
64 |
*
|
65 |
+
* @since BuddyPress (1.5.0)
|
66 |
+
*
|
67 |
+
* @see BP_Component::setup_globals() for description of parameters.
|
68 |
+
*
|
69 |
+
* @param array $args See {@link BP_Component::setup_globals()}.
|
70 |
*/
|
71 |
public function setup_globals( $args = array() ) {
|
72 |
$bp = buddypress();
|
73 |
|
74 |
+
/** Component Globals *************************************************/
|
75 |
+
|
76 |
+
// Define a slug, as a fallback for backpat
|
77 |
+
if ( !defined( 'BP_MEMBERS_SLUG' ) ) {
|
78 |
define( 'BP_MEMBERS_SLUG', $this->id );
|
79 |
+
}
|
80 |
|
81 |
+
// Override any passed args
|
82 |
+
$args = array(
|
83 |
+
'slug' => BP_MEMBERS_SLUG,
|
84 |
+
'root_slug' => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : BP_MEMBERS_SLUG,
|
85 |
+
'has_directory' => true,
|
86 |
'directory_title' => _x( 'Members', 'component directory title', 'buddypress' ),
|
87 |
+
'search_string' => __( 'Search Members...', 'buddypress' ),
|
88 |
+
'global_tables' => array(
|
89 |
'table_name_last_activity' => bp_core_get_table_prefix() . 'bp_activity',
|
90 |
'table_name_signups' => bp_core_get_table_prefix() . 'signups',
|
91 |
+
)
|
|
|
92 |
);
|
93 |
|
94 |
+
parent::setup_globals( $args );
|
95 |
|
96 |
/** Logged in user ****************************************************/
|
97 |
|
98 |
+
// The core userdata of the user who is currently logged in.
|
99 |
+
$bp->loggedin_user->userdata = bp_core_get_core_userdata( bp_loggedin_user_id() );
|
100 |
+
|
101 |
// Fetch the full name for the logged in user
|
102 |
+
$bp->loggedin_user->fullname = isset( $bp->loggedin_user->userdata->display_name ) ? $bp->loggedin_user->userdata->display_name : '';
|
103 |
|
104 |
// Hits the DB on single WP installs so get this separately
|
105 |
$bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin( bp_loggedin_user_id() );
|
107 |
// The domain for the user currently logged in. eg: http://domain.com/members/andy
|
108 |
$bp->loggedin_user->domain = bp_core_get_user_domain( bp_loggedin_user_id() );
|
109 |
|
|
|
|
|
|
|
110 |
/** Displayed user ****************************************************/
|
111 |
|
|
|
|
|
|
|
112 |
// The core userdata of the user who is currently being displayed
|
113 |
$bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() );
|
114 |
|
115 |
// Fetch the full name displayed user
|
116 |
+
$bp->displayed_user->fullname = isset( $bp->displayed_user->userdata->display_name ) ? $bp->displayed_user->userdata->display_name : '';
|
117 |
+
|
118 |
+
// The domain for the user currently being displayed
|
119 |
+
$bp->displayed_user->domain = bp_core_get_user_domain( bp_displayed_user_id() );
|
120 |
+
|
121 |
+
/** Signup ************************************************************/
|
122 |
|
|
|
123 |
$bp->signup = new stdClass;
|
124 |
|
125 |
/** Profiles Fallback *************************************************/
|
129 |
$bp->profile->slug = 'profile';
|
130 |
$bp->profile->id = 'profile';
|
131 |
}
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Set up canonical stack for this component.
|
136 |
+
*
|
137 |
+
* @since BuddyPress (2.1.0)
|
138 |
+
*/
|
139 |
+
public function setup_canonical_stack() {
|
140 |
+
$bp = buddypress();
|
141 |
|
142 |
/** Default Profile Component *****************************************/
|
143 |
|
144 |
+
if ( defined( 'BP_DEFAULT_COMPONENT' ) && BP_DEFAULT_COMPONENT ) {
|
145 |
+
$bp->default_component = BP_DEFAULT_COMPONENT;
|
146 |
+
} else {
|
147 |
if ( bp_is_active( 'activity' ) && isset( $bp->pages->activity ) ) {
|
148 |
$bp->default_component = bp_get_activity_slug();
|
149 |
} else {
|
150 |
$bp->default_component = ( 'xprofile' === $bp->profile->id ) ? 'profile' : $bp->profile->id;
|
151 |
}
|
|
|
|
|
|
|
152 |
}
|
153 |
|
154 |
+
/** Canonical Component Stack *****************************************/
|
155 |
+
|
156 |
if ( bp_displayed_user_id() ) {
|
157 |
$bp->canonical_stack['base_url'] = bp_displayed_user_domain();
|
158 |
|
168 |
$bp->canonical_stack['action_variables'] = bp_action_variables();
|
169 |
}
|
170 |
|
171 |
+
// Looking at the single member root/home, so assume the default
|
172 |
+
if ( ! bp_current_component() ) {
|
173 |
$bp->current_component = $bp->default_component;
|
174 |
+
|
175 |
+
// The canonical URL will not contain the default component
|
176 |
+
} elseif ( bp_is_current_component( $bp->default_component ) && ! bp_current_action() ) {
|
177 |
unset( $bp->canonical_stack['component'] );
|
178 |
}
|
179 |
|
190 |
}
|
191 |
|
192 |
/**
|
193 |
+
* Set up fall-back component navigation if XProfile is inactive.
|
194 |
+
*
|
195 |
+
* @since BuddyPress (1.5.0)
|
196 |
+
*
|
197 |
+
* @see BP_Component::setup_nav() for a description of arguments.
|
198 |
+
*
|
199 |
+
* @param array $main_nav Optional. See BP_Component::setup_nav() for
|
200 |
+
* description.
|
201 |
+
* @param array $sub_nav Optional. See BP_Component::setup_nav() for
|
202 |
+
* description.
|
203 |
*/
|
204 |
public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
|
205 |
+
|
206 |
+
// Bail if XProfile component is active
|
207 |
+
if ( bp_is_active( 'xprofile' ) ) {
|
208 |
+
return;
|
209 |
+
}
|
210 |
+
|
211 |
+
// Don't set up navigation if there's no member
|
212 |
+
if ( ! is_user_logged_in() && ! bp_is_user() ) {
|
213 |
+
return;
|
214 |
+
}
|
215 |
+
|
216 |
$bp = buddypress();
|
217 |
|
218 |
+
// Setup the main navigation
|
219 |
+
$main_nav = array(
|
220 |
+
'name' => _x( 'Profile', 'Member profile main navigation', 'buddypress' ),
|
221 |
+
'slug' => $bp->profile->slug,
|
222 |
+
'position' => 20,
|
223 |
+
'screen_function' => 'bp_members_screen_display_profile',
|
224 |
+
'default_subnav_slug' => 'public',
|
225 |
+
'item_css_id' => $bp->profile->id
|
226 |
+
);
|
227 |
|
228 |
+
// User links
|
229 |
+
$user_domain = bp_displayed_user_domain() ? bp_displayed_user_domain() : bp_loggedin_user_domain();
|
230 |
+
$profile_link = trailingslashit( $user_domain . $bp->profile->slug );
|
231 |
+
|
232 |
+
// Setup the subnav items for the member profile
|
233 |
+
$sub_nav[] = array(
|
234 |
+
'name' => _x( 'View', 'Member profile view', 'buddypress' ),
|
235 |
+
'slug' => 'public',
|
236 |
+
'parent_url' => $profile_link,
|
237 |
+
'parent_slug' => $bp->profile->slug,
|
238 |
+
'screen_function' => 'bp_members_screen_display_profile',
|
239 |
+
'position' => 10
|
240 |
+
);
|
241 |
|
242 |
+
parent::setup_nav( $main_nav, $sub_nav );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
}
|
244 |
|
245 |
/**
|
246 |
+
* Set up the title for pages and <title>.
|
|
|
|
|
247 |
*/
|
248 |
public function setup_title() {
|
249 |
$bp = buddypress();
|
250 |
|
251 |
if ( bp_is_my_profile() ) {
|
252 |
$bp->bp_options_title = __( 'You', 'buddypress' );
|
253 |
+
} elseif ( bp_is_user() ) {
|
254 |
+
$bp->bp_options_title = bp_get_displayed_user_fullname();
|
255 |
$bp->bp_options_avatar = bp_core_fetch_avatar( array(
|
256 |
'item_id' => bp_displayed_user_id(),
|
257 |
'type' => 'thumb',
|
258 |
+
'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), $bp->bp_options_title )
|
259 |
) );
|
|
|
260 |
}
|
261 |
|
262 |
parent::setup_title();
|
263 |
}
|
264 |
}
|
265 |
|
266 |
+
/**
|
267 |
+
* Set up the bp-members component.
|
268 |
+
*/
|
269 |
function bp_setup_members() {
|
270 |
buddypress()->members = new BP_Members_Component();
|
271 |
}
|
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* BuddyPress Member Screens
|
5 |
*
|
6 |
-
* Handlers for member screens that aren't handled elsewhere
|
7 |
*
|
8 |
* @package BuddyPress
|
9 |
* @subpackage MembersScreens
|
@@ -13,10 +13,7 @@
|
|
13 |
if ( !defined( 'ABSPATH' ) ) exit;
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
-
*
|
18 |
-
* @package BuddyPress Members
|
19 |
-
* @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
|
20 |
*/
|
21 |
function bp_members_screen_display_profile() {
|
22 |
do_action( 'bp_members_screen_display_profile' );
|
@@ -24,15 +21,7 @@ function bp_members_screen_display_profile() {
|
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
-
*
|
28 |
-
*
|
29 |
-
* @global object $bp
|
30 |
-
*
|
31 |
-
* @uses bp_is_user()
|
32 |
-
* @uses bp_is_current_component()
|
33 |
-
* @uses do_action()
|
34 |
-
* @uses bp_core_load_template()
|
35 |
-
* @uses apply_filters()
|
36 |
*/
|
37 |
function bp_members_screen_index() {
|
38 |
if ( bp_is_members_directory() ) {
|
@@ -45,11 +34,13 @@ function bp_members_screen_index() {
|
|
45 |
}
|
46 |
add_action( 'bp_screens', 'bp_members_screen_index' );
|
47 |
|
48 |
-
|
|
|
|
|
49 |
function bp_core_screen_signup() {
|
50 |
global $bp;
|
51 |
|
52 |
-
if ( !bp_is_current_component( 'register' ) )
|
53 |
return;
|
54 |
|
55 |
// Not a directory
|
@@ -220,6 +211,9 @@ function bp_core_screen_signup() {
|
|
220 |
}
|
221 |
add_action( 'bp_screens', 'bp_core_screen_signup' );
|
222 |
|
|
|
|
|
|
|
223 |
function bp_core_screen_activation() {
|
224 |
global $bp;
|
225 |
|
@@ -267,31 +261,31 @@ function bp_core_screen_activation() {
|
|
267 |
}
|
268 |
add_action( 'bp_screens', 'bp_core_screen_activation' );
|
269 |
|
270 |
-
/** Theme
|
271 |
|
272 |
/**
|
273 |
* The main theme compat class for BuddyPress Members.
|
274 |
*
|
275 |
-
* This class sets up the necessary theme
|
276 |
* member template parts to the_title and the_content areas of a theme.
|
277 |
*
|
278 |
-
* @since BuddyPress (1.7)
|
279 |
*/
|
280 |
class BP_Members_Theme_Compat {
|
281 |
|
282 |
/**
|
283 |
-
*
|
284 |
*
|
285 |
-
* @since BuddyPress (1.7)
|
286 |
*/
|
287 |
public function __construct() {
|
288 |
add_action( 'bp_setup_theme_compat', array( $this, 'is_members' ) );
|
289 |
}
|
290 |
|
291 |
/**
|
292 |
-
* Are we looking at something that needs members theme
|
293 |
*
|
294 |
-
* @since BuddyPress (1.7)
|
295 |
*/
|
296 |
public function is_members() {
|
297 |
|
@@ -330,11 +324,12 @@ class BP_Members_Theme_Compat {
|
|
330 |
/**
|
331 |
* Add template hierarchy to theme compat for the members directory page.
|
332 |
*
|
333 |
-
* This is to mirror how WordPress has
|
|
|
334 |
*
|
335 |
-
* @since BuddyPress (1.8)
|
336 |
*
|
337 |
-
* @param string $templates The templates from bp_get_theme_compat_templates()
|
338 |
* @return array $templates Array of custom templates to look for.
|
339 |
*/
|
340 |
public function directory_template_hierarchy( $templates = array() ) {
|
@@ -352,9 +347,9 @@ class BP_Members_Theme_Compat {
|
|
352 |
}
|
353 |
|
354 |
/**
|
355 |
-
* Update the global $post with directory data
|
356 |
*
|
357 |
-
* @since BuddyPress (1.7)
|
358 |
*/
|
359 |
public function directory_dummy_post() {
|
360 |
bp_theme_compat_reset_post( array(
|
@@ -363,7 +358,7 @@ class BP_Members_Theme_Compat {
|
|
363 |
'post_author' => 0,
|
364 |
'post_date' => 0,
|
365 |
'post_content' => '',
|
366 |
-
'post_type' => '
|
367 |
'post_status' => 'publish',
|
368 |
'is_page' => true,
|
369 |
'comment_status' => 'closed'
|
@@ -371,9 +366,9 @@ class BP_Members_Theme_Compat {
|
|
371 |
}
|
372 |
|
373 |
/**
|
374 |
-
* Filter the_content with the members index template part
|
375 |
*
|
376 |
-
* @since BuddyPress (1.7)
|
377 |
*/
|
378 |
public function directory_content() {
|
379 |
return bp_buffer_template_part( 'members/index', null, false );
|
@@ -384,11 +379,13 @@ class BP_Members_Theme_Compat {
|
|
384 |
/**
|
385 |
* Add custom template hierarchy to theme compat for member pages.
|
386 |
*
|
387 |
-
* This is to mirror how WordPress has
|
|
|
388 |
*
|
389 |
-
* @since BuddyPress (1.8)
|
390 |
*
|
391 |
-
* @param string $templates The templates from
|
|
|
392 |
* @return array $templates Array of custom templates to look for.
|
393 |
*/
|
394 |
public function single_template_hierarchy( $templates ) {
|
@@ -412,9 +409,9 @@ class BP_Members_Theme_Compat {
|
|
412 |
}
|
413 |
|
414 |
/**
|
415 |
-
* Update the global $post with the displayed user's data
|
416 |
*
|
417 |
-
* @since BuddyPress (1.7)
|
418 |
*/
|
419 |
public function single_dummy_post() {
|
420 |
bp_theme_compat_reset_post( array(
|
@@ -423,7 +420,7 @@ class BP_Members_Theme_Compat {
|
|
423 |
'post_author' => 0,
|
424 |
'post_date' => 0,
|
425 |
'post_content' => '',
|
426 |
-
'post_type' => '
|
427 |
'post_status' => 'publish',
|
428 |
'is_page' => true,
|
429 |
'comment_status' => 'closed'
|
@@ -431,9 +428,9 @@ class BP_Members_Theme_Compat {
|
|
431 |
}
|
432 |
|
433 |
/**
|
434 |
-
* Filter the_content with the members' single home template part
|
435 |
*
|
436 |
-
* @since BuddyPress (1.7)
|
437 |
*/
|
438 |
public function single_dummy_content() {
|
439 |
return bp_buffer_template_part( 'members/single/home', null, false );
|
@@ -447,14 +444,14 @@ new BP_Members_Theme_Compat();
|
|
447 |
* This class sets up the necessary theme compatability actions to safely output
|
448 |
* registration template parts to the_title and the_content areas of a theme.
|
449 |
*
|
450 |
-
* @since BuddyPress (1.7)
|
451 |
*/
|
452 |
class BP_Registration_Theme_Compat {
|
453 |
|
454 |
/**
|
455 |
* Setup the groups component theme compatibility
|
456 |
*
|
457 |
-
* @since BuddyPress (1.7)
|
458 |
*/
|
459 |
public function __construct() {
|
460 |
add_action( 'bp_setup_theme_compat', array( $this, 'is_registration' ) );
|
@@ -463,7 +460,7 @@ class BP_Registration_Theme_Compat {
|
|
463 |
/**
|
464 |
* Are we looking at either the registration or activation pages?
|
465 |
*
|
466 |
-
* @since BuddyPress (1.7)
|
467 |
*/
|
468 |
public function is_registration() {
|
469 |
|
@@ -484,13 +481,14 @@ class BP_Registration_Theme_Compat {
|
|
484 |
/** Template ***********************************************************/
|
485 |
|
486 |
/**
|
487 |
-
* Add template hierarchy to theme compat for registration
|
488 |
*
|
489 |
-
* This is to mirror how WordPress has
|
|
|
490 |
*
|
491 |
-
* @since BuddyPress (1.8)
|
492 |
*
|
493 |
-
* @param string $templates The templates from bp_get_theme_compat_templates()
|
494 |
* @return array $templates Array of custom templates to look for.
|
495 |
*/
|
496 |
public function template_hierarchy( $templates ) {
|
@@ -509,9 +507,9 @@ class BP_Registration_Theme_Compat {
|
|
509 |
}
|
510 |
|
511 |
/**
|
512 |
-
* Update the global $post with dummy data
|
513 |
*
|
514 |
-
* @since BuddyPress (1.7)
|
515 |
*/
|
516 |
public function dummy_post() {
|
517 |
// Registration page
|
@@ -531,15 +529,13 @@ class BP_Registration_Theme_Compat {
|
|
531 |
}
|
532 |
}
|
533 |
|
534 |
-
$post_type = bp_is_register_page() ? 'bp_register' : 'bp_activate';
|
535 |
-
|
536 |
bp_theme_compat_reset_post( array(
|
537 |
'ID' => 0,
|
538 |
'post_title' => $title,
|
539 |
'post_author' => 0,
|
540 |
'post_date' => 0,
|
541 |
'post_content' => '',
|
542 |
-
'post_type' =>
|
543 |
'post_status' => 'publish',
|
544 |
'is_page' => true,
|
545 |
'comment_status' => 'closed'
|
@@ -549,7 +545,7 @@ class BP_Registration_Theme_Compat {
|
|
549 |
/**
|
550 |
* Filter the_content with either the register or activate templates.
|
551 |
*
|
552 |
-
* @since BuddyPress (1.7)
|
553 |
*/
|
554 |
public function dummy_content() {
|
555 |
if ( bp_is_register_page() ) {
|
3 |
/**
|
4 |
* BuddyPress Member Screens
|
5 |
*
|
6 |
+
* Handlers for member screens that aren't handled elsewhere.
|
7 |
*
|
8 |
* @package BuddyPress
|
9 |
* @subpackage MembersScreens
|
13 |
if ( !defined( 'ABSPATH' ) ) exit;
|
14 |
|
15 |
/**
|
16 |
+
* Handle the display of the profile page by loading the correct template file.
|
|
|
|
|
|
|
17 |
*/
|
18 |
function bp_members_screen_display_profile() {
|
19 |
do_action( 'bp_members_screen_display_profile' );
|
21 |
}
|
22 |
|
23 |
/**
|
24 |
+
* Handle the display of the members directory index.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
*/
|
26 |
function bp_members_screen_index() {
|
27 |
if ( bp_is_members_directory() ) {
|
34 |
}
|
35 |
add_action( 'bp_screens', 'bp_members_screen_index' );
|
36 |
|
37 |
+
/**
|
38 |
+
* Handle the loading of the signup screen.
|
39 |
+
*/
|
40 |
function bp_core_screen_signup() {
|
41 |
global $bp;
|
42 |
|
43 |
+
if ( ! bp_is_current_component( 'register' ) || bp_current_action() )
|
44 |
return;
|
45 |
|
46 |
// Not a directory
|
211 |
}
|
212 |
add_action( 'bp_screens', 'bp_core_screen_signup' );
|
213 |
|
214 |
+
/**
|
215 |
+
* Handle the loading of the Activate screen.
|
216 |
+
*/
|
217 |
function bp_core_screen_activation() {
|
218 |
global $bp;
|
219 |
|
261 |
}
|
262 |
add_action( 'bp_screens', 'bp_core_screen_activation' );
|
263 |
|
264 |
+
/** Theme Compatibility *******************************************************/
|
265 |
|
266 |
/**
|
267 |
* The main theme compat class for BuddyPress Members.
|
268 |
*
|
269 |
+
* This class sets up the necessary theme compatibility actions to safely output
|
270 |
* member template parts to the_title and the_content areas of a theme.
|
271 |
*
|
272 |
+
* @since BuddyPress (1.7.0)
|
273 |
*/
|
274 |
class BP_Members_Theme_Compat {
|
275 |
|
276 |
/**
|
277 |
+
* Set up the members component theme compatibility.
|
278 |
*
|
279 |
+
* @since BuddyPress (1.7.0)
|
280 |
*/
|
281 |
public function __construct() {
|
282 |
add_action( 'bp_setup_theme_compat', array( $this, 'is_members' ) );
|
283 |
}
|
284 |
|
285 |
/**
|
286 |
+
* Are we looking at something that needs members theme compatibility?
|
287 |
*
|
288 |
+
* @since BuddyPress (1.7.0)
|
289 |
*/
|
290 |
public function is_members() {
|
291 |
|
324 |
/**
|
325 |
* Add template hierarchy to theme compat for the members directory page.
|
326 |
*
|
327 |
+
* This is to mirror how WordPress has
|
328 |
+
* {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
|
329 |
*
|
330 |
+
* @since BuddyPress (1.8.0)
|
331 |
*
|
332 |
+
* @param string $templates The templates from bp_get_theme_compat_templates().
|
333 |
* @return array $templates Array of custom templates to look for.
|
334 |
*/
|
335 |
public function directory_template_hierarchy( $templates = array() ) {
|
347 |
}
|
348 |
|
349 |
/**
|
350 |
+
* Update the global $post with directory data.
|
351 |
*
|
352 |
+
* @since BuddyPress (1.7.0)
|
353 |
*/
|
354 |
public function directory_dummy_post() {
|
355 |
bp_theme_compat_reset_post( array(
|
358 |
'post_author' => 0,
|
359 |
'post_date' => 0,
|
360 |
'post_content' => '',
|
361 |
+
'post_type' => 'page',
|
362 |
'post_status' => 'publish',
|
363 |
'is_page' => true,
|
364 |
'comment_status' => 'closed'
|
366 |
}
|
367 |
|
368 |
/**
|
369 |
+
* Filter the_content with the members index template part.
|
370 |
*
|
371 |
+
* @since BuddyPress (1.7.0)
|
372 |
*/
|
373 |
public function directory_content() {
|
374 |
return bp_buffer_template_part( 'members/index', null, false );
|
379 |
/**
|
380 |
* Add custom template hierarchy to theme compat for member pages.
|
381 |
*
|
382 |
+
* This is to mirror how WordPress has
|
383 |
+
* {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
|
384 |
*
|
385 |
+
* @since BuddyPress (1.8.0)
|
386 |
*
|
387 |
+
* @param string $templates The templates from
|
388 |
+
* bp_get_theme_compat_templates().
|
389 |
* @return array $templates Array of custom templates to look for.
|
390 |
*/
|
391 |
public function single_template_hierarchy( $templates ) {
|
409 |
}
|
410 |
|
411 |
/**
|
412 |
+
* Update the global $post with the displayed user's data.
|
413 |
*
|
414 |
+
* @since BuddyPress (1.7.0)
|
415 |
*/
|
416 |
public function single_dummy_post() {
|
417 |
bp_theme_compat_reset_post( array(
|
420 |
'post_author' => 0,
|
421 |
'post_date' => 0,
|
422 |
'post_content' => '',
|
423 |
+
'post_type' => 'page',
|
424 |
'post_status' => 'publish',
|
425 |
'is_page' => true,
|
426 |
'comment_status' => 'closed'
|
428 |
}
|
429 |
|
430 |
/**
|
431 |
+
* Filter the_content with the members' single home template part.
|
432 |
*
|
433 |
+
* @since BuddyPress (1.7.0)
|
434 |
*/
|
435 |
public function single_dummy_content() {
|
436 |
return bp_buffer_template_part( 'members/single/home', null, false );
|
444 |
* This class sets up the necessary theme compatability actions to safely output
|
445 |
* registration template parts to the_title and the_content areas of a theme.
|
446 |
*
|
447 |
+
* @since BuddyPress (1.7.0)
|
448 |
*/
|
449 |
class BP_Registration_Theme_Compat {
|
450 |
|
451 |
/**
|
452 |
* Setup the groups component theme compatibility
|
453 |
*
|
454 |
+
* @since BuddyPress (1.7.0)
|
455 |
*/
|
456 |
public function __construct() {
|
457 |
add_action( 'bp_setup_theme_compat', array( $this, 'is_registration' ) );
|
460 |
/**
|
461 |
* Are we looking at either the registration or activation pages?
|
462 |
*
|
463 |
+
* @since BuddyPress (1.7.0)
|
464 |
*/
|
465 |
public function is_registration() {
|
466 |
|
481 |
/** Template ***********************************************************/
|
482 |
|
483 |
/**
|
484 |
+
* Add template hierarchy to theme compat for registration/activation pages.
|
485 |
*
|
486 |
+
* This is to mirror how WordPress has
|
487 |
+
* {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
|
488 |
*
|
489 |
+
* @since BuddyPress (1.8.0)
|
490 |
*
|
491 |
+
* @param string $templates The templates from bp_get_theme_compat_templates().
|
492 |
* @return array $templates Array of custom templates to look for.
|
493 |
*/
|
494 |
public function template_hierarchy( $templates ) {
|
507 |
}
|
508 |
|
509 |
/**
|
510 |
+
* Update the global $post with dummy data.
|
511 |
*
|
512 |
+
* @since BuddyPress (1.7.0)
|
513 |
*/
|
514 |
public function dummy_post() {
|
515 |
// Registration page
|
529 |
}
|
530 |
}
|
531 |
|
|
|
|
|
532 |
bp_theme_compat_reset_post( array(
|
533 |
'ID' => 0,
|
534 |
'post_title' => $title,
|
535 |
'post_author' => 0,
|
536 |
'post_date' => 0,
|
537 |
'post_content' => '',
|
538 |
+
'post_type' => 'page',
|
539 |
'post_status' => 'publish',
|
540 |
'is_page' => true,
|
541 |
'comment_status' => 'closed'
|
545 |
/**
|
546 |
* Filter the_content with either the register or activate templates.
|
547 |
*
|
548 |
+
* @since BuddyPress (1.7.0)
|
549 |
*/
|
550 |
public function dummy_content() {
|
551 |
if ( bp_is_register_page() ) {
|
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* BuddyPress Member Template Tags
|
5 |
*
|
6 |
-
* Functions that are safe to use inside your template files and themes
|
7 |
*
|
8 |
* @package BuddyPress
|
9 |
* @subpackage Members
|
@@ -13,11 +13,9 @@
|
|
13 |
if ( !defined( 'ABSPATH' ) ) exit;
|
14 |
|
15 |
/**
|
16 |
-
* Output the members component slug
|
17 |
*
|
18 |
-
* @
|
19 |
-
* @subpackage Members Template
|
20 |
-
* @since BuddyPress (1.5)
|
21 |
*
|
22 |
* @uses bp_get_members_slug()
|
23 |
*/
|
@@ -25,22 +23,20 @@ function bp_members_slug() {
|
|
25 |
echo bp_get_members_slug();
|
26 |
}
|
27 |
/**
|
28 |
-
* Return the members component slug
|
|
|
|
|
29 |
*
|
30 |
-
* @
|
31 |
-
* @subpackage Members Template
|
32 |
-
* @since BuddyPress (1.5)
|
33 |
*/
|
34 |
function bp_get_members_slug() {
|
35 |
return apply_filters( 'bp_get_members_slug', buddypress()->members->slug );
|
36 |
}
|
37 |
|
38 |
/**
|
39 |
-
* Output the members component root slug
|
40 |
*
|
41 |
-
* @
|
42 |
-
* @subpackage Members Template
|
43 |
-
* @since BuddyPress (1.5)
|
44 |
*
|
45 |
* @uses bp_get_members_root_slug()
|
46 |
*/
|
@@ -48,37 +44,31 @@ function bp_members_root_slug() {
|
|
48 |
echo bp_get_members_root_slug();
|
49 |
}
|
50 |
/**
|
51 |
-
* Return the members component root slug
|
|
|
|
|
52 |
*
|
53 |
-
* @
|
54 |
-
* @subpackage Members Template
|
55 |
-
* @since BuddyPress (1.5)
|
56 |
*/
|
57 |
function bp_get_members_root_slug() {
|
58 |
return apply_filters( 'bp_get_members_root_slug', buddypress()->members->root_slug );
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
-
* Output member directory permalink
|
|
|
|
|
63 |
*
|
64 |
-
* @package BuddyPress
|
65 |
-
* @subpackage Members Template
|
66 |
-
* @since BuddyPress (1.5)
|
67 |
* @uses bp_get_members_directory_permalink()
|
68 |
*/
|
69 |
function bp_members_directory_permalink() {
|
70 |
echo bp_get_members_directory_permalink();
|
71 |
}
|
72 |
/**
|
73 |
-
* Return member directory permalink
|
|
|
|
|
74 |
*
|
75 |
-
* @package BuddyPress
|
76 |
-
* @subpackage Members Template
|
77 |
-
* @since BuddyPress (1.5)
|
78 |
-
* @uses apply_filters()
|
79 |
-
* @uses traisingslashit()
|
80 |
-
* @uses bp_get_root_domain()
|
81 |
-
* @uses bp_get_members_root_slug()
|
82 |
* @return string
|
83 |
*/
|
84 |
function bp_get_members_directory_permalink() {
|
@@ -86,11 +76,9 @@ function bp_members_directory_permalink() {
|
|
86 |
}
|
87 |
|
88 |
/**
|
89 |
-
* Output the sign-up slug
|
90 |
*
|
91 |
-
* @
|
92 |
-
* @subpackage Members Template
|
93 |
-
* @since BuddyPress (1.5)
|
94 |
*
|
95 |
* @uses bp_get_signup_slug()
|
96 |
*/
|
@@ -98,11 +86,11 @@ function bp_signup_slug() {
|
|
98 |
echo bp_get_signup_slug();
|
99 |
}
|
100 |
/**
|
101 |
-
* Return the sign-up slug
|
|
|
|
|
102 |
*
|
103 |
-
* @
|
104 |
-
* @subpackage Members Template
|
105 |
-
* @since BuddyPress (1.5)
|
106 |
*/
|
107 |
function bp_get_signup_slug() {
|
108 |
$bp = buddypress();
|
@@ -119,11 +107,9 @@ function bp_signup_slug() {
|
|
119 |
}
|
120 |
|
121 |
/**
|
122 |
-
* Output the activation slug
|
123 |
*
|
124 |
-
* @
|
125 |
-
* @subpackage Members Template
|
126 |
-
* @since BuddyPress (1.5)
|
127 |
*
|
128 |
* @uses bp_get_activate_slug()
|
129 |
*/
|
@@ -131,11 +117,11 @@ function bp_activate_slug() {
|
|
131 |
echo bp_get_activate_slug();
|
132 |
}
|
133 |
/**
|
134 |
-
* Return the activation slug
|
|
|
|
|
135 |
*
|
136 |
-
* @
|
137 |
-
* @subpackage Members Template
|
138 |
-
* @since BuddyPress (1.5)
|
139 |
*/
|
140 |
function bp_get_activate_slug() {
|
141 |
$bp = buddypress();
|
@@ -151,24 +137,104 @@ function bp_activate_slug() {
|
|
151 |
return apply_filters( 'bp_get_activate_slug', $slug );
|
152 |
}
|
153 |
|
154 |
-
|
155 |
-
*
|
156 |
-
*
|
|
|
157 |
*/
|
158 |
-
|
159 |
class BP_Core_Members_Template {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
var $current_member = -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
var $member_count;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
var $members;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
var $member;
|
164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
var $in_the_loop;
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
var $pag_page;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
var $pag_num;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
var $pag_links;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
var $total_member_count;
|
171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
function __construct( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value, $page_arg = 'upage' ) {
|
173 |
|
174 |
$this->pag_page = !empty( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : (int) $page_number;
|
@@ -198,8 +264,22 @@ class BP_Core_Members_Template {
|
|
198 |
}
|
199 |
|
200 |
if ( (int) $this->total_member_count && (int) $this->pag_num ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
$this->pag_links = paginate_links( array(
|
202 |
-
'base' => add_query_arg( $
|
203 |
'format' => '',
|
204 |
'total' => ceil( (int) $this->total_member_count / (int) $this->pag_num ),
|
205 |
'current' => (int) $this->pag_page,
|
@@ -210,6 +290,13 @@ class BP_Core_Members_Template {
|
|
210 |
}
|
211 |
}
|
212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
function has_members() {
|
214 |
if ( $this->member_count )
|
215 |
return true;
|
@@ -217,6 +304,11 @@ class BP_Core_Members_Template {
|
|
217 |
return false;
|
218 |
}
|
219 |
|
|
|
|
|
|
|
|
|
|
|
220 |
function next_member() {
|
221 |
$this->current_member++;
|
222 |
$this->member = $this->members[$this->current_member];
|
@@ -224,6 +316,9 @@ class BP_Core_Members_Template {
|
|
224 |
return $this->member;
|
225 |
}
|
226 |
|
|
|
|
|
|
|
227 |
function rewind_members() {
|
228 |
$this->current_member = -1;
|
229 |
if ( $this->member_count > 0 ) {
|
@@ -231,6 +326,17 @@ class BP_Core_Members_Template {
|
|
231 |
}
|
232 |
}
|
233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
function members() {
|
235 |
if ( $this->current_member + 1 < $this->member_count ) {
|
236 |
return true;
|
@@ -244,6 +350,15 @@ class BP_Core_Members_Template {
|
|
244 |
return false;
|
245 |
}
|
246 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
function the_member() {
|
248 |
|
249 |
$this->in_the_loop = true;
|
@@ -255,12 +370,62 @@ class BP_Core_Members_Template {
|
|
255 |
}
|
256 |
}
|
257 |
|
|
|
|
|
|
|
258 |
function bp_rewind_members() {
|
259 |
global $members_template;
|
260 |
|
261 |
return $members_template->rewind_members();
|
262 |
}
|
263 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
function bp_has_members( $args = '' ) {
|
265 |
global $members_template;
|
266 |
|
@@ -319,19 +484,37 @@ function bp_has_members( $args = '' ) {
|
|
319 |
return apply_filters( 'bp_has_members', $members_template->has_members(), $members_template );
|
320 |
}
|
321 |
|
|
|
|
|
|
|
|
|
|
|
322 |
function bp_the_member() {
|
323 |
global $members_template;
|
324 |
return $members_template->the_member();
|
325 |
}
|
326 |
|
|
|
|
|
|
|
|
|
|
|
327 |
function bp_members() {
|
328 |
global $members_template;
|
329 |
return $members_template->members();
|
330 |
}
|
331 |
|
|
|
|
|
|
|
332 |
function bp_members_pagination_count() {
|
333 |
echo bp_get_members_pagination_count();
|
334 |
}
|
|
|
|
|
|
|
|
|
|
|
335 |
function bp_get_members_pagination_count() {
|
336 |
global $members_template;
|
337 |
|
@@ -344,20 +527,28 @@ function bp_members_pagination_count() {
|
|
344 |
$total = bp_core_number_format( $members_template->total_member_count );
|
345 |
|
346 |
if ( 'active' == $members_template->type )
|
347 |
-
$pag = sprintf( _n( 'Viewing
|
348 |
else if ( 'popular' == $members_template->type )
|
349 |
-
$pag = sprintf( _n( 'Viewing
|
350 |
else if ( 'online' == $members_template->type )
|
351 |
-
$pag = sprintf( _n( 'Viewing
|
352 |
else
|
353 |
-
$pag = sprintf( _n( 'Viewing
|
354 |
|
355 |
return apply_filters( 'bp_members_pagination_count', $pag );
|
356 |
}
|
357 |
|
|
|
|
|
|
|
358 |
function bp_members_pagination_links() {
|
359 |
echo bp_get_members_pagination_links();
|
360 |
}
|
|
|
|
|
|
|
|
|
|
|
361 |
function bp_get_members_pagination_links() {
|
362 |
global $members_template;
|
363 |
|
@@ -365,9 +556,7 @@ function bp_members_pagination_links() {
|
|
365 |
}
|
366 |
|
367 |
/**
|
368 |
-
*
|
369 |
-
*
|
370 |
-
* Echo id from bp_get_member_user_id()
|
371 |
*
|
372 |
* @uses bp_get_member_user_id()
|
373 |
*/
|
@@ -375,12 +564,9 @@ function bp_member_user_id() {
|
|
375 |
echo bp_get_member_user_id();
|
376 |
}
|
377 |
/**
|
378 |
-
*
|
379 |
-
*
|
380 |
-
* Get the id of the user in a members loop
|
381 |
*
|
382 |
-
* @
|
383 |
-
* @return string Members id
|
384 |
*/
|
385 |
function bp_get_member_user_id() {
|
386 |
global $members_template;
|
@@ -389,19 +575,19 @@ function bp_member_user_id() {
|
|
389 |
}
|
390 |
|
391 |
/**
|
392 |
-
* Output the row class of
|
393 |
*
|
394 |
-
* @since BuddyPress (1.7)
|
395 |
*/
|
396 |
function bp_member_class() {
|
397 |
echo bp_get_member_class();
|
398 |
}
|
399 |
/**
|
400 |
-
* Return the row class of
|
|
|
|
|
401 |
*
|
402 |
-
* @
|
403 |
-
* @return string Row class of the member
|
404 |
-
* @since BuddyPress (1.7)
|
405 |
*/
|
406 |
function bp_get_member_class() {
|
407 |
global $members_template;
|
@@ -430,22 +616,15 @@ function bp_member_class() {
|
|
430 |
}
|
431 |
|
432 |
/**
|
433 |
-
*
|
434 |
-
*
|
435 |
-
* Echo nicename from bp_get_member_user_nicename()
|
436 |
-
*
|
437 |
-
* @uses bp_get_member_user_nicename()
|
438 |
*/
|
439 |
function bp_member_user_nicename() {
|
440 |
echo bp_get_member_user_nicename();
|
441 |
}
|
442 |
/**
|
443 |
-
*
|
444 |
-
*
|
445 |
-
* Get the nicename of the user in a members loop
|
446 |
*
|
447 |
-
* @
|
448 |
-
* @return string Members nicename
|
449 |
*/
|
450 |
function bp_get_member_user_nicename() {
|
451 |
global $members_template;
|
@@ -453,22 +632,15 @@ function bp_member_user_nicename() {
|
|
453 |
}
|
454 |
|
455 |
/**
|
456 |
-
*
|
457 |
-
*
|
458 |
-
* Echo login from bp_get_member_user_login()
|
459 |
-
*
|
460 |
-
* @uses bp_get_member_user_login()
|
461 |
*/
|
462 |
function bp_member_user_login() {
|
463 |
echo bp_get_member_user_login();
|
464 |
}
|
465 |
/**
|
466 |
-
*
|
467 |
*
|
468 |
-
*
|
469 |
-
*
|
470 |
-
* @global object $members_template
|
471 |
-
* @return string Members login
|
472 |
*/
|
473 |
function bp_get_member_user_login() {
|
474 |
global $members_template;
|
@@ -476,36 +648,61 @@ function bp_member_user_login() {
|
|
476 |
}
|
477 |
|
478 |
/**
|
479 |
-
*
|
480 |
-
*
|
481 |
-
* Echo email address from bp_get_member_user_email()
|
482 |
-
*
|
483 |
-
* @uses bp_get_member_user_email()
|
484 |
*/
|
485 |
function bp_member_user_email() {
|
486 |
echo bp_get_member_user_email();
|
487 |
}
|
488 |
/**
|
489 |
-
*
|
490 |
*
|
491 |
-
*
|
492 |
-
*
|
493 |
-
* @global object $members_template
|
494 |
-
* @return string Members email address
|
495 |
*/
|
496 |
function bp_get_member_user_email() {
|
497 |
global $members_template;
|
498 |
return apply_filters( 'bp_get_member_user_email', $members_template->member->user_email );
|
499 |
}
|
500 |
|
|
|
|
|
|
|
|
|
|
|
501 |
function bp_member_is_loggedin_user() {
|
502 |
global $members_template;
|
503 |
return apply_filters( 'bp_member_is_loggedin_user', bp_loggedin_user_id() == $members_template->member->id ? true : false );
|
504 |
}
|
505 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
506 |
function bp_member_avatar( $args = '' ) {
|
507 |
echo apply_filters( 'bp_member_avatar', bp_get_member_avatar( $args ) );
|
508 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
509 |
function bp_get_member_avatar( $args = '' ) {
|
510 |
global $members_template;
|
511 |
|
@@ -526,36 +723,48 @@ function bp_member_avatar( $args = '' ) {
|
|
526 |
return apply_filters( 'bp_get_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->id, 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $members_template->member->user_email ) ) );
|
527 |
}
|
528 |
|
|
|
|
|
|
|
529 |
function bp_member_permalink() {
|
530 |
echo bp_get_member_permalink();
|
531 |
}
|
|
|
|
|
|
|
|
|
|
|
532 |
function bp_get_member_permalink() {
|
533 |
global $members_template;
|
534 |
|
535 |
return apply_filters( 'bp_get_member_permalink', bp_core_get_user_domain( $members_template->member->id, $members_template->member->user_nicename, $members_template->member->user_login ) );
|
536 |
}
|
|
|
|
|
|
|
|
|
537 |
function bp_member_link() { echo bp_get_member_permalink(); }
|
|
|
|
|
|
|
|
|
538 |
function bp_get_member_link() { return bp_get_member_permalink(); }
|
539 |
|
540 |
/**
|
541 |
-
*
|
542 |
-
*
|
543 |
-
* @package BuddyPress
|
544 |
*/
|
545 |
function bp_member_name() {
|
546 |
echo apply_filters( 'bp_member_name', bp_get_member_name() );
|
547 |
}
|
548 |
/**
|
549 |
-
*
|
550 |
-
*
|
551 |
-
* Full name is, by default, pulled from xprofile's Full Name field. When this field is
|
552 |
-
* empty, we try to get an alternative name from the WP users table, in the following order
|
553 |
-
* of preference: display_name, user_nicename, user_login.
|
554 |
*
|
555 |
-
*
|
|
|
|
|
|
|
556 |
*
|
557 |
-
* @
|
558 |
-
* @return string The user's fullname for display
|
559 |
*/
|
560 |
function bp_get_member_name() {
|
561 |
global $members_template;
|
@@ -599,34 +808,59 @@ function bp_member_last_active( $args = array() ) {
|
|
599 |
*
|
600 |
* @param array $args {
|
601 |
* Array of optional arguments.
|
602 |
-
* @type
|
603 |
-
* ago". If false, formatted "5 minutes ago".
|
|
|
604 |
* }
|
605 |
* @return string
|
606 |
*/
|
607 |
function bp_get_member_last_active( $args = array() ) {
|
608 |
global $members_template;
|
609 |
|
610 |
-
|
611 |
-
|
|
|
612 |
) );
|
613 |
|
|
|
|
|
|
|
|
|
|
|
|
|
614 |
if ( isset( $members_template->member->last_activity ) ) {
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
|
|
|
|
620 |
} else {
|
621 |
$last_activity = __( 'Never active', 'buddypress' );
|
622 |
}
|
623 |
|
624 |
-
|
|
|
625 |
}
|
626 |
|
|
|
|
|
|
|
627 |
function bp_member_latest_update( $args = '' ) {
|
628 |
echo bp_get_member_latest_update( $args );
|
629 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
630 |
function bp_get_member_latest_update( $args = '' ) {
|
631 |
global $members_template;
|
632 |
|
@@ -641,7 +875,9 @@ function bp_member_latest_update( $args = '' ) {
|
|
641 |
if ( !bp_is_active( 'activity' ) || empty( $members_template->member->latest_update ) || !$update = maybe_unserialize( $members_template->member->latest_update ) )
|
642 |
return false;
|
643 |
|
644 |
-
$update_content = apply_filters( 'bp_get_activity_latest_update_excerpt',
|
|
|
|
|
645 |
|
646 |
// If $view_link is true and the text returned by bp_create_excerpt() is different from the original text (ie it's
|
647 |
// been truncated), add the "View" l
|
3 |
/**
|
4 |
* BuddyPress Member Template Tags
|
5 |
*
|
6 |
+
* Functions that are safe to use inside your template files and themes.
|
7 |
*
|
8 |
* @package BuddyPress
|
9 |
* @subpackage Members
|
13 |
if ( !defined( 'ABSPATH' ) ) exit;
|
14 |
|
15 |
/**
|
16 |
+
* Output the members component slug.
|
17 |
*
|
18 |
+
* @since BuddyPress (1.5.0)
|
|
|
|
|
19 |
*
|
20 |
* @uses bp_get_members_slug()
|
21 |
*/
|
23 |
echo bp_get_members_slug();
|
24 |
}
|
25 |
/**
|
26 |
+
* Return the members component slug.
|
27 |
+
*
|
28 |
+
* @since BuddyPress (1.5.0)
|
29 |
*
|
30 |
+
* @return string
|
|
|
|
|
31 |
*/
|
32 |
function bp_get_members_slug() {
|
33 |
return apply_filters( 'bp_get_members_slug', buddypress()->members->slug );
|
34 |
}
|
35 |
|
36 |
/**
|
37 |
+
* Output the members component root slug.
|
38 |
*
|
39 |
+
* @since BuddyPress (1.5.0)
|
|
|
|
|
40 |
*
|
41 |
* @uses bp_get_members_root_slug()
|
42 |
*/
|
44 |
echo bp_get_members_root_slug();
|
45 |
}
|
46 |
/**
|
47 |
+
* Return the members component root slug.
|
48 |
+
*
|
49 |
+
* @since BuddyPress (1.5.0)
|
50 |
*
|
51 |
+
* @return string
|
|
|
|
|
52 |
*/
|
53 |
function bp_get_members_root_slug() {
|
54 |
return apply_filters( 'bp_get_members_root_slug', buddypress()->members->root_slug );
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
+
* Output member directory permalink.
|
59 |
+
*
|
60 |
+
* @since BuddyPress (1.5.0)
|
61 |
*
|
|
|
|
|
|
|
62 |
* @uses bp_get_members_directory_permalink()
|
63 |
*/
|
64 |
function bp_members_directory_permalink() {
|
65 |
echo bp_get_members_directory_permalink();
|
66 |
}
|
67 |
/**
|
68 |
+
* Return member directory permalink.
|
69 |
+
*
|
70 |
+
* @since BuddyPress (1.5.0)
|
71 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
* @return string
|
73 |
*/
|
74 |
function bp_get_members_directory_permalink() {
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
+
* Output the sign-up slug.
|
80 |
*
|
81 |
+
* @since BuddyPress (1.5.0)
|
|
|
|
|
82 |
*
|
83 |
* @uses bp_get_signup_slug()
|
84 |
*/
|
86 |
echo bp_get_signup_slug();
|
87 |
}
|
88 |
/**
|
89 |
+
* Return the sign-up slug.
|
90 |
+
*
|
91 |
+
* @since BuddyPress (1.5.0)
|
92 |
*
|
93 |
+
* @return string
|
|
|
|
|
94 |
*/
|
95 |
function bp_get_signup_slug() {
|
96 |
$bp = buddypress();
|
107 |
}
|
108 |
|
109 |
/**
|
110 |
+
* Output the activation slug.
|
111 |
*
|
112 |
+
* @since BuddyPress (1.5.0)
|
|
|
|
|
113 |
*
|
114 |
* @uses bp_get_activate_slug()
|
115 |
*/
|
117 |
echo bp_get_activate_slug();
|
118 |
}
|
119 |
/**
|
120 |
+
* Return the activation slug.
|
121 |
+
*
|
122 |
+
* @since BuddyPress (1.5.0)
|
123 |
*
|
124 |
+
* @return string
|
|
|
|
|
125 |
*/
|
126 |
function bp_get_activate_slug() {
|
127 |
$bp = buddypress();
|
137 |
return apply_filters( 'bp_get_activate_slug', $slug );
|
138 |
}
|
139 |
|
140 |
+
/**
|
141 |
+
* The main member template loop class.
|
142 |
+
*
|
143 |
+
* Responsible for loading a group of members into a loop for display.
|
144 |
*/
|
|
|
145 |
class BP_Core_Members_Template {
|
146 |
+
|
147 |
+
/**
|
148 |
+
* The loop iterator.
|
149 |
+
*
|
150 |
+
* @access public
|
151 |
+
* @var int
|
152 |
+
*/
|
153 |
var $current_member = -1;
|
154 |
+
|
155 |
+
/**
|
156 |
+
* The number of members returned by the paged query.
|
157 |
+
*
|
158 |
+
* @access public
|
159 |
+
* @var int
|
160 |
+
*/
|
161 |
var $member_count;
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Array of members located by the query.
|
165 |
+
*
|
166 |
+
* @access public
|
167 |
+
* @var array
|
168 |
+
*/
|
169 |
var $members;
|
170 |
+
|
171 |
+
/**
|
172 |
+
* The member object currently being iterated on.
|
173 |
+
*
|
174 |
+
* @access public
|
175 |
+
* @var object
|
176 |
+
*/
|
177 |
var $member;
|
178 |
|
179 |
+
/**
|
180 |
+
* A flag for whether the loop is currently being iterated.
|
181 |
+
*
|
182 |
+
* @access public
|
183 |
+
* @var bool
|
184 |
+
*/
|
185 |
var $in_the_loop;
|
186 |
|
187 |
+
/**
|
188 |
+
* The page number being requested.
|
189 |
+
*
|
190 |
+
* @access public
|
191 |
+
* @var public
|
192 |
+
*/
|
193 |
var $pag_page;
|
194 |
+
|
195 |
+
/**
|
196 |
+
* The number of items being requested per page.
|
197 |
+
*
|
198 |
+
* @access public
|
199 |
+
* @var public
|
200 |
+
*/
|
201 |
var $pag_num;
|
202 |
+
|
203 |
+
/**
|
204 |
+
* An HTML string containing pagination links.
|
205 |
+
*
|
206 |
+
* @access public
|
207 |
+
* @var string
|
208 |
+
*/
|
209 |
var $pag_links;
|
210 |
+
|
211 |
+
/**
|
212 |
+
* The total number of members matching the query parameters.
|
213 |
+
*
|
214 |
+
* @access public
|
215 |
+
* @var int
|
216 |
+
*/
|
217 |
var $total_member_count;
|
218 |
|
219 |
+
/**
|
220 |
+
* Constructor method.
|
221 |
+
*
|
222 |
+
* @see BP_User_Query for an in-depth description of parameters.
|
223 |
+
*
|
224 |
+
* @param string $type Sort order.
|
225 |
+
* @param int $page_number Page of results.
|
226 |
+
* @param int $per_page Number of results per page.
|
227 |
+
* @param int $max Max number of results to return.
|
228 |
+
* @param int $user_id Limit to friends of a user.
|
229 |
+
* @param string $search_terms Limit to users matching search terms.
|
230 |
+
* @param array $include Limit results by these user IDs.
|
231 |
+
* @param bool $populate_extras Fetch optional extras.
|
232 |
+
* @param array $exclude Exclude these IDs from results.
|
233 |
+
* @param array $meta_key Limit to users with a meta_key.
|
234 |
+
* @param array $meta_value Limit to users with a meta_value (with meta_key).
|
235 |
+
* @param array $page_arg Optional. The string used as a query
|
236 |
+
* parameter in pagination links. Default: 'upage'.
|
237 |
+
*/
|
238 |
function __construct( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value, $page_arg = 'upage' ) {
|
239 |
|
240 |
$this->pag_page = !empty( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : (int) $page_number;
|
264 |
}
|
265 |
|
266 |
if ( (int) $this->total_member_count && (int) $this->pag_num ) {
|
267 |
+
$pag_args = array(
|
268 |
+
$page_arg => '%#%',
|
269 |
+
);
|
270 |
+
|
271 |
+
if ( defined( 'DOING_AJAX' ) && true === (bool) DOING_AJAX ) {
|
272 |
+
$base = remove_query_arg( 's', wp_get_referer() );
|
273 |
+
} else {
|
274 |
+
$base = '';
|
275 |
+
}
|
276 |
+
|
277 |
+
if ( ! empty( $search_terms ) ) {
|
278 |
+
$pag_args['s'] = $search_terms;
|
279 |
+
}
|
280 |
+
|
281 |
$this->pag_links = paginate_links( array(
|
282 |
+
'base' => add_query_arg( $pag_args, $base ),
|
283 |
'format' => '',
|
284 |
'total' => ceil( (int) $this->total_member_count / (int) $this->pag_num ),
|
285 |
'current' => (int) $this->pag_page,
|
290 |
}
|
291 |
}
|
292 |
|
293 |
+
/**
|
294 |
+
* Whether there are members available in the loop.
|
295 |
+
*
|
296 |
+
* @see bp_has_members()
|
297 |
+
*
|
298 |
+
* @return bool True if there are items in the loop, otherwise false.
|
299 |
+
*/
|
300 |
function has_members() {
|
301 |
if ( $this->member_count )
|
302 |
return true;
|
304 |
return false;
|
305 |
}
|
306 |
|
307 |
+
/**
|
308 |
+
* Set up the next member and iterate index.
|
309 |
+
*
|
310 |
+
* @return object The next member to iterate over.
|
311 |
+
*/
|
312 |
function next_member() {
|
313 |
$this->current_member++;
|
314 |
$this->member = $this->members[$this->current_member];
|
316 |
return $this->member;
|
317 |
}
|
318 |
|
319 |
+
/**
|
320 |
+
* Rewind the members and reset member index.
|
321 |
+
*/
|
322 |
function rewind_members() {
|
323 |
$this->current_member = -1;
|
324 |
if ( $this->member_count > 0 ) {
|
326 |
}
|
327 |
}
|
328 |
|
329 |
+
/**
|
330 |
+
* Whether there are members left in the loop to iterate over.
|
331 |
+
*
|
332 |
+
* This method is used by {@link bp_members()} as part of the while loop
|
333 |
+
* that controls iteration inside the members loop, eg:
|
334 |
+
* while ( bp_members() ) { ...
|
335 |
+
*
|
336 |
+
* @see bp_members()
|
337 |
+
*
|
338 |
+
* @return bool True if there are more members to show, otherwise false.
|
339 |
+
*/
|
340 |
function members() {
|
341 |
if ( $this->current_member + 1 < $this->member_count ) {
|
342 |
return true;
|
350 |
return false;
|
351 |
}
|
352 |
|
353 |
+
/**
|
354 |
+
* Set up the current member inside the loop.
|
355 |
+
*
|
356 |
+
* Used by {@link bp_the_member()} to set up the current member data
|
357 |
+
* while looping, so that template tags used during that iteration make
|
358 |
+
* reference to the current member.
|
359 |
+
*
|
360 |
+
* @see bp_the_member()
|
361 |
+
*/
|
362 |
function the_member() {
|
363 |
|
364 |
$this->in_the_loop = true;
|
370 |
}
|
371 |
}
|
372 |
|
373 |
+
/**
|
374 |
+
* Rewind the members and reset member index.
|
375 |
+
*/
|
376 |
function bp_rewind_members() {
|
377 |
global $members_template;
|
378 |
|
379 |
return $members_template->rewind_members();
|
380 |
}
|
381 |
|
382 |
+
/**
|
383 |
+
* Initialize the members loop.
|
384 |
+
*
|
385 |
+
* Based on the $args passed, bp_has_members() populates the $members_template
|
386 |
+
* global, enabling the use of BuddyPress templates and template functions to
|
387 |
+
* display a list of members.
|
388 |
+
*
|
389 |
+
* @global object $members_template {@link BP_Members_Template}
|
390 |
+
*
|
391 |
+
* @param array $args {
|
392 |
+
* Arguments for limiting the contents of the members loop. Most arguments
|
393 |
+
* are in the same format as {@link BP_User_Query}. However, because
|
394 |
+
* the format of the arguments accepted here differs in a number of ways,
|
395 |
+
* and because bp_has_members() determines some default arguments in a
|
396 |
+
* dynamic fashion, we list all accepted arguments here as well.
|
397 |
+
*
|
398 |
+
* Arguments can be passed as an associative array, or as a URL query
|
399 |
+
* string (eg, 'user_id=4&per_page=3').
|
400 |
+
*
|
401 |
+
* @type int $type Sort order. 'active', 'random', 'newest', 'popular',
|
402 |
+
* 'online', 'alphabetical'. Default: 'active'.
|
403 |
+
* @type int|bool $page Page of results to display. Default: 1.
|
404 |
+
* @type int|bool $per_page Number of results per page. Default: 20.
|
405 |
+
* @type int|bool $max Maximum number of results to return.
|
406 |
+
* Default: false (unlimited).
|
407 |
+
* @type string $page_arg The string used as a query parameter in
|
408 |
+
* pagination links. Default: 'bpage'.
|
409 |
+
* @type array|int|string|bool $include Limit results by a list of user
|
410 |
+
* IDs. Accepts an array, a single integer, a comma-separated list of
|
411 |
+
* IDs, or false (to disable this limiting). Default: false.
|
412 |
+
* 'active', 'alphabetical', 'newest', or 'random'.
|
413 |
+
* @type array|int|string|bool $exclude Exclude users from results by ID.
|
414 |
+
* Accepts an array, a single integer, a comma-separated list of
|
415 |
+
* IDs, or false (to disable this limiting). Default: false.
|
416 |
+
* @type int $user_id If provided, results are limited to the friends of
|
417 |
+
* the specified user. When on a user's Friends page, defaults to
|
418 |
+
* the ID of the displayed user. Otherwise defaults to 0.
|
419 |
+
* @type string $search_terms Limit results by a search term. Default: null.
|
420 |
+
* @type string $meta_key Limit results by the presence of a usermeta key.
|
421 |
+
* Default: false.
|
422 |
+
* @type mixed $meta_value When used with meta_key, limits results by the
|
423 |
+
* a matching usermeta value. Default: false.
|
424 |
+
* @type bool $populate_extras Whether to fetch optional data, such as
|
425 |
+
* friend counts. Default: true.
|
426 |
+
* }
|
427 |
+
* @return bool Returns true when blogs are found, otherwise false.
|
428 |
+
*/
|
429 |
function bp_has_members( $args = '' ) {
|
430 |
global $members_template;
|
431 |
|
484 |
return apply_filters( 'bp_has_members', $members_template->has_members(), $members_template );
|
485 |
}
|
486 |
|
487 |
+
/**
|
488 |
+
* Set up the current member inside the loop.
|
489 |
+
*
|
490 |
+
* @return object
|
491 |
+
*/
|
492 |
function bp_the_member() {
|
493 |
global $members_template;
|
494 |
return $members_template->the_member();
|
495 |
}
|
496 |
|
497 |
+
/**
|
498 |
+
* Check whether there are more members to iterate over.
|
499 |
+
*
|
500 |
+
* @return bool
|
501 |
+
*/
|
502 |
function bp_members() {
|
503 |
global $members_template;
|
504 |
return $members_template->members();
|
505 |
}
|
506 |
|
507 |
+
/**
|
508 |
+
* Output the members pagination count.
|
509 |
+
*/
|
510 |
function bp_members_pagination_count() {
|
511 |
echo bp_get_members_pagination_count();
|
512 |
}
|
513 |
+
/**
|
514 |
+
* Generate the members pagination count.
|
515 |
+
*
|
516 |
+
* @return string
|
517 |
+
*/
|
518 |
function bp_get_members_pagination_count() {
|
519 |
global $members_template;
|
520 |
|
527 |
$total = bp_core_number_format( $members_template->total_member_count );
|
528 |
|
529 |
if ( 'active' == $members_template->type )
|
530 |
+
$pag = sprintf( _n( 'Viewing 1 active member', 'Viewing %1$s - %2$s of %3$s active members', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
|
531 |
else if ( 'popular' == $members_template->type )
|
532 |
+
$pag = sprintf( _n( 'Viewing 1 member with friends', 'Viewing %1$s - %2$s of %3$s members with friends', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
|
533 |
else if ( 'online' == $members_template->type )
|
534 |
+
$pag = sprintf( _n( 'Viewing 1 online member', 'Viewing %1$s - %2$s of %3$s online members', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
|
535 |
else
|
536 |
+
$pag = sprintf( _n( 'Viewing 1 member', 'Viewing %1$s - %2$s of %3$s members', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
|
537 |
|
538 |
return apply_filters( 'bp_members_pagination_count', $pag );
|
539 |
}
|
540 |
|
541 |
+
/**
|
542 |
+
* Output the members pagination links.
|
543 |
+
*/
|
544 |
function bp_members_pagination_links() {
|
545 |
echo bp_get_members_pagination_links();
|
546 |
}
|
547 |
+
/**
|
548 |
+
* Fetch the members pagination links.
|
549 |
+
*
|
550 |
+
* @return string
|
551 |
+
*/
|
552 |
function bp_get_members_pagination_links() {
|
553 |
global $members_template;
|
554 |
|
556 |
}
|
557 |
|
558 |
/**
|
559 |
+
* Output the ID of the current member in the loop.
|
|
|
|
|
560 |
*
|
561 |
* @uses bp_get_member_user_id()
|
562 |
*/
|
564 |
echo bp_get_member_user_id();
|
565 |
}
|
566 |
/**
|
567 |
+
* Get the ID of the current member in the loop.
|
|
|
|
|
568 |
*
|
569 |
+
* @return string Member ID.
|
|
|
570 |
*/
|
571 |
function bp_get_member_user_id() {
|
572 |
global $members_template;
|
575 |
}
|
576 |
|
577 |
/**
|
578 |
+
* Output the row class of the current member in the loop.
|
579 |
*
|
580 |
+
* @since BuddyPress (1.7.0)
|
581 |
*/
|
582 |
function bp_member_class() {
|
583 |
echo bp_get_member_class();
|
584 |
}
|
585 |
/**
|
586 |
+
* Return the row class of the current member in the loop.
|
587 |
+
*
|
588 |
+
* @since BuddyPress (1.7.0)
|
589 |
*
|
590 |
+
* @return string Row class of the member.
|
|
|
|
|
591 |
*/
|
592 |
function bp_get_member_class() {
|
593 |
global $members_template;
|
616 |
}
|
617 |
|
618 |
/**
|
619 |
+
* Output nicename of current member in the loop.
|
|
|
|
|
|
|
|
|
620 |
*/
|
621 |
function bp_member_user_nicename() {
|
622 |
echo bp_get_member_user_nicename();
|
623 |
}
|
624 |
/**
|
625 |
+
* Get the nicename of the current member in the loop.
|
|
|
|
|
626 |
*
|
627 |
+
* @return string Members nicename.
|
|
|
628 |
*/
|
629 |
function bp_get_member_user_nicename() {
|
630 |
global $members_template;
|
632 |
}
|
633 |
|
634 |
/**
|
635 |
+
* Output login for current member in the loop.
|
|
|
|
|
|
|
|
|
636 |
*/
|
637 |
function bp_member_user_login() {
|
638 |
echo bp_get_member_user_login();
|
639 |
}
|
640 |
/**
|
641 |
+
* Get the login of the current member in the loop.
|
642 |
*
|
643 |
+
* @return string Member's login.
|
|
|
|
|
|
|
644 |
*/
|
645 |
function bp_get_member_user_login() {
|
646 |
global $members_template;
|
648 |
}
|
649 |
|
650 |
/**
|
651 |
+
* Output the email address for the current member in the loop.
|
|
|
|
|
|
|
|
|
652 |
*/
|
653 |
function bp_member_user_email() {
|
654 |
echo bp_get_member_user_email();
|
655 |
}
|
656 |
/**
|
657 |
+
* Get the email address of the current member in the loop.
|
658 |
*
|
659 |
+
* @return string Member's email address.
|
|
|
|
|
|
|
660 |
*/
|
661 |
function bp_get_member_user_email() {
|
662 |
global $members_template;
|
663 |
return apply_filters( 'bp_get_member_user_email', $members_template->member->user_email );
|
664 |
}
|
665 |
|
666 |
+
/**
|
667 |
+
* Check whether the current member in the loop is the logged-in user.
|
668 |
+
*
|
669 |
+
* @return bool
|
670 |
+
*/
|
671 |
function bp_member_is_loggedin_user() {
|
672 |
global $members_template;
|
673 |
return apply_filters( 'bp_member_is_loggedin_user', bp_loggedin_user_id() == $members_template->member->id ? true : false );
|
674 |
}
|
675 |
|
676 |
+
/**
|
677 |
+
* Output a member's avatar.
|
678 |
+
*
|
679 |
+
* @see bp_get_member_avatar() for description of arguments.
|
680 |
+
*
|
681 |
+
* @param array $args See {@link bp_get_member_avatar()}.
|
682 |
+
*/
|
683 |
function bp_member_avatar( $args = '' ) {
|
684 |
echo apply_filters( 'bp_member_avatar', bp_get_member_avatar( $args ) );
|
685 |
}
|
686 |
+
/**
|
687 |
+
* Get a member's avatar.
|
688 |
+
*
|
689 |
+
* @see bp_core_fetch_avatar() For a description of arguments and
|
690 |
+
* return values.
|
691 |
+
*
|
692 |
+
* @param array $args {
|
693 |
+
* Arguments are listed here with an explanation of their defaults.
|
694 |
+
* For more information about the arguments, see
|
695 |
+
* {@link bp_core_fetch_avatar()}.
|
696 |
+
* @type string $alt Default: 'Profile picture of [user name]'.
|
697 |
+
* @type string $class Default: 'avatar'.
|
698 |
+
* @type string $type Default: 'thumb'.
|
699 |
+
* @type int|bool $width Default: false.
|
700 |
+
* @type int|bool $height Default: false.
|
701 |
+
* @type bool $id Currently unused.
|
702 |
+
* @type bool $no_grav Default: false.
|
703 |
+
* }
|
704 |
+
* @return string User avatar string.
|
705 |
+
*/
|
706 |
function bp_get_member_avatar( $args = '' ) {
|
707 |
global $members_template;
|
708 |
|
723 |
return apply_filters( 'bp_get_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->id, 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $members_template->member->user_email ) ) );
|
724 |
}
|
725 |
|
726 |
+
/**
|
727 |
+
* Output the permalink for the current member in the loop.
|
728 |
+
*/
|
729 |
function bp_member_permalink() {
|
730 |
echo bp_get_member_permalink();
|
731 |
}
|
732 |
+
/**
|
733 |
+
* Get the permalink for the current member in the loop.
|
734 |
+
*
|
735 |
+
* @return string
|
736 |
+
*/
|
737 |
function bp_get_member_permalink() {
|
738 |
global $members_template;
|
739 |
|
740 |
return apply_filters( 'bp_get_member_permalink', bp_core_get_user_domain( $members_template->member->id, $members_template->member->user_nicename, $members_template->member->user_login ) );
|
741 |
}
|
742 |
+
|
743 |
+
/**
|
744 |
+
* Alias of {@link bp_member_permalink()}.
|
745 |
+
*/
|
746 |
function bp_member_link() { echo bp_get_member_permalink(); }
|
747 |
+
|
748 |
+
/**
|
749 |
+
* Alias of {@link bp_get_member_permalink()}.
|
750 |
+
*/
|
751 |
function bp_get_member_link() { return bp_get_member_permalink(); }
|
752 |
|
753 |
/**
|
754 |
+
* Output display name of current member in the loop.
|
|
|
|
|
755 |
*/
|
756 |
function bp_member_name() {
|
757 |
echo apply_filters( 'bp_member_name', bp_get_member_name() );
|
758 |
}
|
759 |
/**
|
760 |
+
* Get the display name of the current member in the loop.
|
|
|
|
|
|
|
|
|
761 |
*
|
762 |
+
* Full name is, by default, pulled from xprofile's Full Name field.
|
763 |
+
* When this field is empty, we try to get an alternative name from the
|
764 |
+
* WP users table, in the following order of preference: display_name,
|
765 |
+
* user_nicename, user_login.
|
766 |
*
|
767 |
+
* @return string The user's fullname for display.
|
|
|
768 |
*/
|
769 |
function bp_get_member_name() {
|
770 |
global $members_template;
|
808 |
*
|
809 |
* @param array $args {
|
810 |
* Array of optional arguments.
|
811 |
+
* @type mixed $active_format If true, formatted "active 5 minutes
|
812 |
+
* ago". If false, formatted "5 minutes ago". If string, should
|
813 |
+
* be sprintf'able like 'last seen %s ago'.
|
814 |
* }
|
815 |
* @return string
|
816 |
*/
|
817 |
function bp_get_member_last_active( $args = array() ) {
|
818 |
global $members_template;
|
819 |
|
820 |
+
// Parse the activy format
|
821 |
+
$r = bp_parse_args( $args, array(
|
822 |
+
'active_format' => true
|
823 |
) );
|
824 |
|
825 |
+
// Backwards compatibilty for anyone forcing a 'true' active_format
|
826 |
+
if ( true === $r['active_format'] ) {
|
827 |
+
$r['active_format'] = __( 'active %s', 'buddypress' );
|
828 |
+
}
|
829 |
+
|
830 |
+
// Member has logged in at least one time
|
831 |
if ( isset( $members_template->member->last_activity ) ) {
|
832 |
+
|
833 |
+
// Backwards compatibility for pre 1.5 'ago' strings
|
834 |
+
$last_activity = ! empty( $r['active_format'] )
|
835 |
+
? bp_core_get_last_activity( $members_template->member->last_activity, $r['active_format'] )
|
836 |
+
: bp_core_time_since( $members_template->member->last_activity );
|
837 |
+
|
838 |
+
// Member has never logged in or been active
|
839 |
} else {
|
840 |
$last_activity = __( 'Never active', 'buddypress' );
|
841 |
}
|
842 |
|
843 |
+
// Filter and return
|
844 |
+
return apply_filters( 'bp_member_last_active', $last_activity, $r );
|
845 |
}
|
846 |
|
847 |
+
/**
|
848 |
+
* Output the latest update of the current member in the loop.
|
849 |
+
*/
|
850 |
function bp_member_latest_update( $args = '' ) {
|
851 |
echo bp_get_member_latest_update( $args );
|
852 |
}
|
853 |
+
/**
|
854 |
+
* Get the latest update from the current member in the loop.
|
855 |
+
*
|
856 |
+
* @param array $args {
|
857 |
+
* Array of optional arguments.
|
858 |
+
* @type int $length Truncation length. Default: 225.
|
859 |
+
* @type bool $view_link Whether to provide a 'View' link for
|
860 |
+
* truncated entries. Default: false.
|
861 |
+
* }
|
862 |
+
* @return string
|
863 |
+
*/
|
864 |
function bp_get_member_latest_update( $args = '' ) {
|
865 |
global $members_template;
|
866 |
|
875 |
if ( !bp_is_active( 'activity' ) || empty( $members_template->member->latest_update ) || !$update = maybe_unserialize( $members_template->member->latest_update ) )
|
876 |
return false;
|
877 |
|
878 |
+
$update_content = apply_filters( 'bp_get_activity_latest_update_excerpt', trim( strip_tags( bp_create_excerpt( $update['content'], $length ) ) ) );
|
879 |
+
|
880 |
+
$update_content = sprintf( _x( '- "%s"', 'member latest update in member directory', 'buddypress' ), $update_content );
|
881 |
|
882 |
// If $view_link is true and the text returned by bp_create_excerpt() is different from the original text (ie it's
|
883 |
// been truncated), add the "View" l
|