forked from dimensionmedia/buddystrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions-bp.php
340 lines (238 loc) · 9.66 KB
/
functions-bp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?php
/*
* functions-bp.php
*
* This is most of where the filters and general functions reside for adding Twitter Bootstrap classes, etc.
* More specific modifications are found in other functions files (function-groups.php, etc.)
*
*
*/
add_filter('bp_get_displayed_user_nav_activity', 'bs_bp_get_displayed_user_nav_activity',10,8);
add_filter('bp_get_displayed_user_nav_xprofile', 'bs_bp_get_displayed_user_nav_activity',10,8);
add_filter('bp_get_displayed_user_nav_messages', 'bs_bp_get_displayed_user_nav_activity',10,8);
add_filter('bp_get_displayed_user_nav_friends', 'bs_bp_get_displayed_user_nav_activity',10,8);
add_filter('bp_get_displayed_user_nav_groups', 'bs_bp_get_displayed_user_nav_activity',10,8);
add_filter('bp_get_displayed_user_nav_settings', 'bs_bp_get_displayed_user_nav_activity',10,8);
/**
* Filter to replace member menu tab HTML w/ Twitter Bootstrap HTML
*
* @return text HTML content
**/
function bs_bp_get_displayed_user_nav_activity($val) {
$val = str_replace('current','active',$val);
$val = str_replace('<span>','<span class="badge">',$val);
return $val;
}
add_filter('bp_get_member_avatar', 'bs_bp_get_member_avatar',10,8);
add_filter('bp_get_displayed_user_avatar', 'bs_bp_get_member_avatar',10,8);
/**
* Filter to replace button classes to confirm w/ Twitter Bootstrap
*
* @return text HTML content
**/
function bs_bp_get_member_avatar($val) {
$val = str_replace('class="','class="img-polaroid ',$val);
return $val;
}
add_filter('get_search_form', 'bs_get_search_form', 1);
/**
* Filter to add Twitter Bootstrap to add btn-success to submit button on search form... not a BuddyPress function, but still used potentially
*
* @return text HTML content
**/
function bs_get_search_form($form) {
// print_r ($form); exit;
$form = str_replace('type="submit"','type="submit" class="btn btn-success"',$form);
return $val;
}
add_filter('bp_get_button', 'bs_bp_get_button',10,8);
/**
* Filter to replace button classes to confirm w/ Twitter Bootstrap
*
* @return text HTML content
**/
function bs_bp_get_button($val) {
$val = str_replace('class="edit','class="btn btn-mini btn-danger',$val);
return $val;
}
add_filter('bp_get_group_member_avatar_thumb', 'bs_bp_get_group_member_avatar_thumb',10,8);
/**
* Filter to replace button classes to confirm w/ Twitter Bootstrap
*
* @return text HTML content
**/
function bs_bp_get_group_member_avatar_thumb($val) {
$val = str_replace('class="','class="img-polaroid ',$val);
return $val;
}
add_filter('bp_get_group_avatar', 'bs_bp_get_group_avatar',10,8);
/**
* Filter to add Twitter Bootstrap img-polaroid to get_avatar function... not a BuddyPress function, but still used potentially
*
* @return text HTML content
**/
function bs_bp_get_group_avatar($val) {
$val = str_replace('class="','class="img-polaroid ',$val);
return $val;
}
add_filter('bp_activity_recurse_comments_start_ul', 'bs_bp_activity_recurse_comments_start_ul',10,8);
/**
* Filter to add Twitter Bootstrap img-polaroid to get_avatar function... not a BuddyPress function, but still used potentially
*
* @return text HTML content
**/
function bs_bp_activity_recurse_comments_start_ul($val) {
$val = str_replace('<ul>','<ul class="unstyled">',$val);
return $val;
}
add_filter('bp_get_activity_avatar', 'bs_bp_get_activity_avatar',10,8);
/**
* Filter to add Twitter Bootstrap img-polaroid to get_avatar function... not a BuddyPress function, but still used potentially
*
* @return text HTML content
**/
function bs_bp_get_activity_avatar($val) {
$val = str_replace('class="','class="img-polaroid ',$val);
return $val;
}
add_filter('bp_get_loggedin_user_avatar', 'bs_bp_get_loggedin_user_avatar',10,8);
/**
* Filter to add Twitter Bootstrap img-polaroid to get_avatar function... not a BuddyPress function, but still used potentially
*
* @return text HTML content
**/
function bs_bp_get_loggedin_user_avatar($val) {
$val = str_replace('class="','class="img-polaroid ',$val);
return $val;
}
add_filter('get_avatar', 'bs_get_avatar',10,8);
/**
* Filter to add Twitter Bootstrap img-polaroid to get_avatar function... not a BuddyPress function, but still used potentially
*
* @return text HTML content
**/
function bs_get_avatar($val) {
$val = str_replace('class="','class="img-polaroid ',$val);
return $val;
}
add_filter('bp_get_activity_delete_link', 'bs_bp_get_activity_delete_link',10,3);
/**
* Filter to replace button classes to confirm w/ Twitter Bootstrap
*
* @return text HTML content
**/
function bs_bp_get_activity_delete_link($val) {
$val = str_replace('class="button','class="btn btn-mini btn-danger',$val);
return $val;
}
add_filter('bp_get_add_friend_button', 'bs_bp_get_add_friend_button',10,3);
/**
* Filter to replace friend button classes to confirm w/ Twitter Bootstrap
*
* @return text HTML content
**/
function bs_bp_get_add_friend_button($val) {
// print_r ($val);
if ($val['id'] == "pending" && $val['component'] == "friends") {
$val['link_class'] = str_replace('friendship-button','friendship-button btn btn-danger',$val['link_class']);
$val['link_text'] = '<i class="icon-thumbs-down"></i> ' . $val['link_text'];
} else {
$val['link_class'] = str_replace('friendship-button','friendship-button btn btn-success',$val['link_class']);
$val['link_text'] = '<i class="icon-plus"></i> ' . $val['link_text'];
}
return $val;
}
add_filter('bp_get_send_public_message_button', 'bs_bp_get_send_public_message_button',10,3);
/**
* Filter to replace friend button classes to confirm w/ Twitter Bootstrap
*
* @return text HTML content
**/
function bs_bp_get_send_public_message_button($val) {
$val['link_class'] = str_replace('button','button btn btn-info',$val['link_class']);
$val['link_text'] = '<i class="icon-bullhorn"></i> ' . $val['link_text'];
return $val;
}
add_filter('bp_get_send_message_button', 'bs_bp_get_send_private_message_button',10,3);
/**
* Filter to replace friend button classes to confirm w/ Twitter Bootstrap
*
* @return text HTML content
**/
function bs_bp_get_send_private_message_button($val) {
$val = str_replace('send-message','send-message btn btn-info',$val);
$val = str_replace('Private Message','<i class="icon-envelope"></i> Private Message',$val);
return $val;
}
/**
* Function to replace active css to confirm w/ Twitter Bootstrap
*
* @return text HTML content
**/
function bs_bp_get_displayed_user_nav() {
global $bp;
foreach ( (array) $bp->bp_nav as $user_nav_item ) {
if ( empty( $user_nav_item['show_for_displayed_user'] ) && !bp_is_my_profile() )
continue;
$selected = '';
if ( bp_is_current_component( $user_nav_item['slug'] ) ) {
$selected = ' class="active"';
}
if ( bp_loggedin_user_domain() ) {
$link = str_replace( bp_loggedin_user_domain(), bp_displayed_user_domain(), $user_nav_item['link'] );
} else {
$link = trailingslashit( bp_displayed_user_domain() . $user_nav_item['link'] );
}
$user_nav_item['name'] = str_replace('<span>','<span class="badge badge-inverse attendee-count">',$user_nav_item['name']);
echo apply_filters_ref_array( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], array( '<li id="' . $user_nav_item['css_id'] . '-personal-li" ' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $link . '">' . $user_nav_item['name'] . '</a></li>', &$user_nav_item ) );
}
}
/**
* Function to replace active css to confirm w/ Twitter Bootstrap
*
* @return text HTML content
**/
function bs_bp_get_options_nav() {
global $bp;
// If we are looking at a member profile, then the we can use the current component as an
// index. Otherwise we need to use the component's root_slug
$component_index = !empty( $bp->displayed_user ) ? bp_current_component() : bp_get_root_slug( bp_current_component() );
if ( !bp_is_single_item() ) {
if ( !isset( $bp->bp_options_nav[$component_index] ) || count( $bp->bp_options_nav[$component_index] ) < 1 ) {
return false;
} else {
$the_index = $component_index;
}
} else {
if ( !isset( $bp->bp_options_nav[bp_current_item()] ) || count( $bp->bp_options_nav[bp_current_item()] ) < 1 ) {
return false;
} else {
$the_index = bp_current_item();
}
}
// Loop through each navigation item
foreach ( (array) $bp->bp_options_nav[$the_index] as $subnav_item ) {
//print_r ($subnav_item);
if ( !$subnav_item['user_has_access'] )
continue;
// If the current action or an action variable matches the nav item id, then add a highlight CSS class.
if ( $subnav_item['slug'] == bp_current_action() ) {
$selected = ' class="active"';
} else {
$selected = '';
}
// List type depends on our current component
$list_type = bp_is_group() ? 'groups' : 'personal';
// echo out the final list item
// if this is a profile edit, give the dropdown else don't
if ($component_index == "profile" && $subnav_item['slug'] == "edit") {
echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li class="dropdown" id="' . $subnav_item['css_id'] . '-' . $list_type . '-li" ' . $selected . '><a href="#" class="dropdown-toggle" data-toggle="dropdown">' . $subnav_item['name'] . ' <b class="caret"></b></a>
<ul class="dropdown-menu">'.bs_bp_get_profile_group_tabs().'
</ul></li>', $subnav_item );
} else {
$subnav_item['name'] = str_replace('<span>', '<span class="badge">', $subnav_item['name']);
echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="' . $subnav_item['css_id'] . '-' . $list_type . '-li" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item );
}
}
}
?>