Skip to content

Commit 97e565f

Browse files
committed
Add attribute to post group tags widget to get only personal tags
1 parent 0462845 commit 97e565f

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

plugins/bcc-login/includes/class-bcc-login-visibility.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,23 +1048,40 @@ function post_group_tags_widget($atts) {
10481048
$post_id = get_the_ID();
10491049
if (!$post_id) return false;
10501050

1051-
$attributes = shortcode_atts(array('limit' => 1000, 'with_link' => false), $atts);
1051+
$attributes = shortcode_atts(
1052+
array(
1053+
'limit' => 100,
1054+
'with_link' => true,
1055+
'personal' => false
1056+
),
1057+
$atts
1058+
);
1059+
1060+
// Convert to actual booleans
1061+
$personal = filter_var($attributes['personal'], FILTER_VALIDATE_BOOLEAN);
1062+
$with_link = filter_var($attributes['with_link'], FILTER_VALIDATE_BOOLEAN);
10521063

10531064
$post_groups = get_post_meta($post_id, 'bcc_groups', false);
10541065
$filtering_groups = $this->_settings->filtering_groups;
1055-
$shown_groups = array_slice(array_intersect($post_groups, $filtering_groups), 0, $attributes['limit']);
1066+
$shown_groups = array_intersect($post_groups, $filtering_groups);
1067+
1068+
if ($personal) {
1069+
$user_groups = $this->get_current_user_groups();
1070+
$shown_groups = array_intersect($shown_groups, $user_groups);
1071+
}
1072+
1073+
$shown_groups = array_slice($shown_groups, 0, $attributes['limit']);
10561074

10571075
$html = '';
10581076

10591077
foreach ($shown_groups as $group) {
1060-
$link = $attributes['with_link'] == true ? '?target-groups[]='. $group : 'javascript:void(0)';
1078+
$link = $with_link ? '?target-groups[]='. $group : 'javascript:void(0)';
10611079
$html .= '<a class="bcc-badge bcc-badge-sm bcc-badge-custom" href="'. $link . '"><i class="material-symbols-rounded">info</i><span>' . $this->get_group_name($group) . '</span></a>';
10621080
}
10631081

10641082
return $html;
10651083
}
10661084

1067-
10681085
function tags_for_queried_target_groups() {
10691086
$html = '';
10701087

0 commit comments

Comments
 (0)