-
Notifications
You must be signed in to change notification settings - Fork 7
/
bp-gtm-filters.php
87 lines (73 loc) · 3.71 KB
/
bp-gtm-filters.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
<?php
// All filters
function bp_gtm_filter_short_links($content){
global $bp;
$gtm_link = bp_get_group_permalink(). $bp->gtm->slug . '/';
$i = $j = 0;
if (preg_match_all('~([#]+([TP])(\d+))~', $content, $data, PREG_SET_ORDER)) {
$content = strip_tags($content, '<p>'); // prevent duplicate <a> tags in comments
$content = nl2br($content);
//print_var($data);
foreach((array)$data as $match){
if ($match[2] == 'T'){
$name = bp_gtm_get_el_name_by_id($match[3], 'task');
if(!$name) {
$name = __('doesn\'t exist','bp_gtm');
$color = 'color-red';
}
if(!$i)/// prevent duplicate <a> tags in comments
$content = str_replace($match[1], '<a class="'.$color.'" href="'.$gtm_link.'tasks/view/'.$match[3].'" title="'.__('Task:','bp_gtm').' '.$name.'">'.$match[1].'</a>', $content);
$i++;
}elseif($match[2] == 'P'){
$name = bp_gtm_get_el_name_by_id($match[3], 'project');
if(!$name) {
$name = __('doesn\'t exist','bp_gtm');
$color = 'color-red';
}
if(!$j)/// prevent duplicate <a> tags in comments
$content = str_replace($match[1], '<a class="'.$color.'" href="'.$gtm_link.'projects/view/'.$match[3].'" title="'.__('Project:','bp_gtm').' '.$name.'">'.$match[1].'</a>', $content);
$j++;
}
}
}
return $content;
}
//add_filter('bp_gtm_project_desc_content', 'wp_filter_kses', 1);
add_filter('bp_gtm_project_desc_content', 'wptexturize');
add_filter('bp_gtm_project_desc_content', 'convert_chars');
add_filter('bp_gtm_project_desc_content', 'wpautop');
add_filter('bp_gtm_project_desc_content', 'stripslashes_deep');
add_filter('bp_gtm_project_desc_content', 'bp_gtm_filter_short_links');
//add_filter('bp_gtm_task_desc_content', 'wp_filter_kses', 1);
add_filter('bp_gtm_task_desc_content', 'wptexturize');
add_filter('bp_gtm_task_desc_content', 'convert_chars');
add_filter('bp_gtm_task_desc_content', 'wpautop');
add_filter('bp_gtm_task_desc_content', 'stripslashes_deep');
add_filter('bp_gtm_task_desc_content', 'bp_gtm_filter_short_links');
add_filter('bp_gtm_discuss_text_content', 'wp_filter_kses', 1);
add_filter('bp_gtm_discuss_text_content', 'wptexturize');
add_filter('bp_gtm_discuss_text_content', 'convert_chars');
add_filter('bp_gtm_discuss_text_content', 'wpautop');
add_filter('bp_gtm_discuss_text_content', 'stripslashes_deep');
add_filter('bp_gtm_discuss_text_content', 'bp_gtm_filter_short_links');
add_filter('bp_gtm_term_name_content', 'wp_filter_kses', 1);
add_filter('bp_gtm_term_name_content', 'convert_chars');
add_filter('bp_gtm_term_name_content', 'stripslashes_deep');
add_filter('bp_gtm_project_name_content', 'wp_filter_kses', 1);
add_filter('bp_gtm_project_name_content', 'convert_chars');
add_filter('bp_gtm_project_name_content', 'stripslashes_deep');
add_filter('bp_gtm_task_name_content', 'wp_filter_kses', 1);
add_filter('bp_gtm_task_name_content', 'convert_chars');
add_filter('bp_gtm_task_name_content', 'stripslashes_deep');
add_filter('bp_gtm_role_name', 'wp_filter_kses', 1);
add_filter('bp_gtm_role_name', 'convert_chars');
add_filter('bp_gtm_role_name', 'stripslashes_deep');
add_filter('bp_gtm_labes', 'wp_filter_kses', 1);
add_filter('bp_gtm_labes', 'convert_chars');
// Allow shortcodes - for code excerpts in future
add_filter('bp_gtm_project_desc_content', 'do_shortcode');
add_filter('bp_gtm_task_desc_content', 'do_shortcode');
// Mention @slaFFik is back
add_filter('bp_gtm_discuss_text_content', 'bp_activity_at_name_filter');
add_filter('bp_gtm_task_desc_content', 'bp_activity_at_name_filter');
add_filter('bp_gtm_project_desc_content', 'bp_activity_at_name_filter');