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 | boonebgorges |
Plugin | ![]() |
Version | 2.1-RC1 |
Comparing to | |
See all releases |
Code changes from version 2.0.3 to 2.1-RC1
- 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 -20
- bp-activity/bp-activity-cssjs.php +48 -0
- bp-activity/bp-activity-filters.php +9 -2
- bp-activity/bp-activity-functions.php +382 -279
- bp-activity/bp-activity-loader.php +16 -15
- bp-activity/bp-activity-screens.php +2 -2
- bp-activity/bp-activity-template.php +504 -147
- bp-activity/css/mentions-rtl.css +80 -0
- bp-activity/css/mentions-rtl.min.css +2 -0
- bp-activity/css/mentions.css +80 -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 +151 -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/mentions.gif +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 +221 -147
- bp-core/bp-core-adminbar.php +32 -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 +58 -7
- bp-core/bp-core-functions.php +213 -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 +522 -478
- bp-core/bp-core-theme-compatibility.php +3 -0
- 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 +636 -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-languages/buddypress.pot +0 -7212
- 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 +628 -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 +755 -181
- bp-messages/bp-messages-actions.php +36 -10
- bp-messages/bp-messages-cache.php +5 -6
- bp-messages/bp-messages-classes.php +110 -10
- bp-messages/bp-messages-cssjs.php +19 -13
- bp-messages/bp-messages-filters.php +0 -1
- bp-messages/bp-messages-functions.php +172 -51
- bp-messages/bp-messages-loader.php +28 -8
- bp-messages/bp-messages-notifications.php +43 -25
- bp-messages/bp-messages-screens.php +42 -12
- bp-messages/bp-messages-template.php +914 -179
- bp-messages/bp-messages-widgets.php +1 -1
- bp-messages/css/autocomplete/jquery.autocompletefb.min.css +0 -1
- bp-messages/js/autocomplete/jquery.autocomplete.min.js +0 -13
- bp-messages/js/autocomplete/jquery.autocompletefb.min.js +0 -16
- bp-messages/js/autocomplete/jquery.bgiframe.min.js +0 -6
- bp-messages/js/autocomplete/jquery.dimensions.min.js +0 -13
- bp-notifications/bp-notifications-buddybar.php +0 -57
- bp-notifications/bp-notifications-classes.php +4 -2
- bp-notifications/bp-notifications-functions.php +39 -34
- bp-notifications/bp-notifications-loader.php +10 -11
- bp-notifications/bp-notifications-template.php +178 -80
- bp-settings/bp-settings-actions.php +112 -5
- bp-settings/bp-settings-loader.php +1 -1
- bp-settings/bp-settings-template.php +26 -0
- bp-templates/bp-legacy/buddypress-functions.php +49 -69
- bp-templates/bp-legacy/buddypress/activity/activity-loop.php +1 -9
- bp-templates/bp-legacy/buddypress/activity/entry.php +3 -3
- bp-templates/bp-legacy/buddypress/activity/index.php +2 -30
- bp-templates/bp-legacy/buddypress/activity/post-form.php +4 -4
- bp-templates/bp-legacy/buddypress/groups/create.php +28 -25
- bp-templates/bp-legacy/buddypress/groups/single/activity.php +3 -9
- bp-templates/bp-legacy/buddypress/groups/single/admin.php +6 -6
- bp-templates/bp-legacy/buddypress/groups/single/home.php +23 -32
- bp-templates/bp-legacy/buddypress/members/register.php +7 -6
- bp-templates/bp-legacy/buddypress/members/single/activity.php +3 -34
- bp-templates/bp-legacy/buddypress/members/single/groups/invites.php +1 -1
- bp-templates/bp-legacy/buddypress/members/single/messages/single.php +1 -1
- bp-templates/bp-legacy/buddypress/members/single/profile/change-avatar.php +8 -8
- bp-templates/bp-legacy/buddypress/members/single/profile/edit.php +6 -4
- bp-templates/bp-legacy/buddypress/members/single/settings/general.php +3 -2
- bp-templates/bp-legacy/buddypress/members/single/settings/profile.php +1 -1
- bp-templates/bp-legacy/css/buddypress-rtl.css +141 -29
- bp-templates/bp-legacy/css/buddypress-rtl.min.css +2 -0
- bp-templates/bp-legacy/css/buddypress.css +36 -4
- bp-templates/bp-legacy/css/buddypress.min.css +2 -0
- bp-templates/bp-legacy/js/buddypress.js +500 -410
- bp-templates/bp-legacy/js/buddypress.min.js +2 -0
- bp-templates/bp-legacy/js/password-verify.js +43 -0
- bp-templates/bp-legacy/js/password-verify.min.js +2 -0
- bp-themes/bp-default/.jshintrc +25 -0
- bp-themes/bp-default/_inc/ajax.php +1 -1
- bp-themes/bp-default/_inc/global.js +16 -21
- bp-themes/bp-default/_inc/images/45pc_black.png +0 -0
- bp-themes/bp-default/_inc/images/60pc_black.png +0 -0
- bp-themes/bp-default/_inc/images/activity_arrow.gif +0 -0
- bp-themes/bp-default/_inc/images/admin-menu-arrow.gif +0 -0
- bp-themes/bp-default/_inc/images/ajax-loader.gif +0 -0
- bp-themes/bp-default/_inc/images/background.gif +0 -0
- bp-themes/bp-default/_inc/images/closed.png +0 -0
- bp-themes/bp-default/_inc/images/default_header.jpg +0 -0
- bp-themes/bp-default/_inc/images/item_back.gif +0 -0
- bp-themes/bp-default/_inc/images/replyto_arrow.gif +0 -0
- bp-themes/bp-default/_inc/images/rss.png +0 -0
- bp-themes/bp-default/_inc/images/sidebar_back.gif +0 -0
- bp-themes/bp-default/_inc/images/white-grad.png +0 -0
- bp-themes/bp-default/activity/index.php +1 -1
- bp-themes/bp-default/functions.php +20 -1
- bp-themes/bp-default/groups/single/activity.php +1 -1
- bp-themes/bp-default/members/single/activity.php +1 -1
- bp-themes/bp-default/rtl.css +1 -1
- bp-themes/bp-default/screenshot.png +0 -0
- bp-themes/bp-default/style.css +1 -1
- bp-themes/index.php +0 -5
- bp-xprofile/admin/css/admin-rtl.css +251 -0
- bp-xprofile/admin/css/admin-rtl.min.css +2 -0
- bp-xprofile/admin/css/admin.css +72 -69
- bp-xprofile/admin/css/admin.min.css +2 -1
- bp-xprofile/admin/js/admin.js +85 -77
- bp-xprofile/admin/js/admin.min.js +2 -1
- bp-xprofile/bp-xprofile-actions.php +14 -3
- bp-xprofile/bp-xprofile-activity.php +91 -79
- bp-xprofile/bp-xprofile-admin.php +183 -136
- bp-xprofile/bp-xprofile-buddybar.php +0 -4
- bp-xprofile/bp-xprofile-classes.php +608 -248
- bp-xprofile/bp-xprofile-cssjs.php +23 -0
- bp-xprofile/bp-xprofile-filters.php +102 -41
- bp-xprofile/bp-xprofile-functions.php +305 -114
- bp-xprofile/bp-xprofile-loader.php +60 -34
- bp-xprofile/bp-xprofile-screens.php +12 -9
- bp-xprofile/bp-xprofile-template.php +86 -18
- buddypress.pot +3018 -2845
- readme.txt +14 -17
@@ -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-09-16 3:09:10 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-09-16 3:09:10 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-09-16 3:09:09 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 |
/**
|
@@ -547,7 +600,6 @@ class BP_Activity_Activity {
|
|
547 |
* @return array
|
548 |
*/
|
549 |
protected static function append_user_fullnames( $activities ) {
|
550 |
-
global $wpdb;
|
551 |
|
552 |
if ( bp_is_active( 'xprofile' ) && ! empty( $activities ) ) {
|
553 |
$activity_user_ids = wp_list_pluck( $activities, 'user_id' );
|
@@ -656,6 +708,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 |
/**
|
600 |
* @return array
|
601 |
*/
|
602 |
protected static function append_user_fullnames( $activities ) {
|
|
|
603 |
|
604 |
if ( bp_is_active( 'xprofile' ) && ! empty( $activities ) ) {
|
605 |
$activity_user_ids = wp_list_pluck( $activities, 'user_id' );
|
708 |
return $sql_array;
|
709 |
}
|
710 |
|
711 |
+
/**
|
712 |
+
* Get the SQL for the 'date_query' param in BP_Activity_Activity::get().
|
713 |
+
*
|
714 |
+
* We use BP_Date_Query, which extends WP_Date_Query, to do the heavy lifting
|
715 |
+
* of parsing the date_query array and creating the necessary SQL clauses.
|
716 |
+
* However, since BP_Activity_Activity::get() builds its SQL differently than
|
717 |
+
* WP_Query, we have to alter the return value (stripping the leading AND
|
718 |
+
* keyword from the query).
|
719 |
+
*
|
720 |
+
* @since BuddyPress (2.1.0)
|
721 |
+
*
|
722 |
+
* @param array $date_query An array of date_query parameters. See the
|
723 |
+
* documentation for the first parameter of WP_Date_Query.
|
724 |
+
* @return string
|
725 |
+
*/
|
726 |
+
public static function get_date_query_sql( $date_query = array() ) {
|
727 |
+
$sql = '';
|
728 |
+
|
729 |
+
// Date query
|
730 |
+
if ( ! empty( $date_query ) && is_array( $date_query ) && class_exists( 'BP_Date_Query' ) ) {
|
731 |
+
$date_query = new BP_Date_Query( $date_query, 'date_recorded' );
|
732 |
+
$sql = preg_replace( '/^\sAND/', '', $date_query->get_sql() );
|
733 |
+
}
|
734 |
+
|
735 |
+
return $sql;
|
736 |
+
}
|
737 |
+
|
738 |
/**
|
739 |
* In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
|
740 |
*
|
@@ -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
|
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,60 @@ 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 +1241,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 +1261,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
|
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
|
1220 |
|
1221 |
return $activity_id;
|
1222 |
}
|
@@ -1224,7 +1304,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 +1319,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 +1338,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 +1370,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 +1378,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 +1386,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 +1397,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 +1407,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 +1434,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 +1456,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 +1468,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 +1505,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 +1518,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 +1548,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 +1560,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 +1573,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 +1583,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 +1614,20 @@ 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 +1640,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 +1678,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 +1690,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 +1714,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 +1735,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 +1756,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 +1793,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 +1804,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 +1842,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 +1890,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 +1914,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 +1933,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 +1943,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 +1958,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 +1973,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 +1993,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 |