| @@ -1,92 +1,95 @@ | ||
| 1 | -<?php if (!defined('ABSPATH')) exit; // Exit if accessed directly ?> | |
| 1 | +<?php if (!defined('ABSPATH')) { exit;} // Exit if accessed directly ?> | |
| 2 | 2 | <?php |
| 3 | 3 | /** |
| 4 | - * @var $primaryItems array | |
| 5 | - * @var $settingsItems array | |
| 6 | - * @var $spaceGroups array | |
| 7 | - * @var $topInlineLinks array | |
| 8 | - * @var $bottomLinkGroups array | |
| 9 | - * @var $is_admin bool | |
| 10 | - * @var $has_color_scheme bool | |
| 11 | - * @var $context string | |
| 4 | + * @var array $primaryItems | |
| 5 | + * @var array $settingsItems | |
| 6 | + * @var array $spaceGroups | |
| 7 | + * @var array $topInlineLinks | |
| 8 | + * @var array $bottomLinkGroups | |
| 9 | + * @var bool $is_admin | |
| 10 | + * @var bool $has_color_scheme | |
| 11 | + * @var string $context | |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | use FluentCommunity\App\Services\Helper; |
| 15 | +use FluentCommunity\Framework\Support\Arr; | |
| 15 | 16 | |
| 16 | -$fluentCommunityShowFeedLink = \FluentCommunity\App\Functions\Utility::isCustomizationEnabled('feed_link_on_sidebar'); | |
| 17 | -$fluentCommunityCollapsedGroups = Helper::getCollapsedSidebarGroups(array_merge((array) $spaceGroups, (array) $bottomLinkGroups)); | |
| 17 | +$fluentCommunityPrimaryItems = $primaryItems ?? []; | |
| 18 | +$fluentCommunitySettingsItems = $settingsItems ?? []; | |
| 19 | +$fluentCommunitySpaceGroups = $spaceGroups ?? []; | |
| 20 | +$fluentCommunityTopInlineLinks = $topInlineLinks ?? []; | |
| 21 | +$fluentCommunityBottomLinkGroups = $bottomLinkGroups ?? []; | |
| 22 | +$fluentCommunityIsAdmin = $is_admin ?? false; | |
| 23 | +$fluentCommunityContext = $context ?? ''; | |
| 24 | +$fluentCommunityFeedItem = $fluentCommunityPrimaryItems['all_feeds'] ?? []; | |
| 25 | +$fluentCommunityShowFeedLink = $fluentCommunityFeedItem && \FluentCommunity\App\Functions\Utility::isCustomizationEnabled('feed_link_on_sidebar'); | |
| 26 | +$fluentCommunityCollapsedGroups = Helper::getCollapsedSidebarGroups(array_merge($fluentCommunitySpaceGroups, $fluentCommunityBottomLinkGroups)); | |
| 18 | 27 | |
| 19 | 28 | ?> |
| 20 | 29 | |
| 30 | +<?php if ($fluentCommunityContext != 'ajax'): ?> | |
| 31 | + <?php do_action('fluent_community/before_sidebar_wrap', $fluentCommunityContext); ?> | |
| 32 | +<?php endif; ?> | |
| 33 | + | |
| 21 | 34 | <div id="fcom_sidebar_wrap" class="fcom_sidebar_wrap"> |
| 22 | 35 | <?php if (apply_filters('fluent_community/will_render_default_sidebar_items', true)) : ?> |
| 23 | 36 | <nav aria-label="<?php echo esc_attr__('Main Sidebar Home menu', 'fluent-community'); ?>"> |
| 24 | 37 | <ul class="fcom_sm_only fcom_general_menu fcom_home_link"> |
| 25 | - <?php Helper::renderMenuItems($primaryItems, 'fcom_menu_link', '<span class="fcom_no_avatar"></span>', true); ?> | |
| 38 | + <?php Helper::renderMenuItems($fluentCommunityPrimaryItems, 'fcom_menu_link', '<span class="fcom_no_avatar"></span>', true); ?> | |
| 26 | 39 | </ul> |
| 27 | 40 | </nav> |
| 28 | - <?php if($fluentCommunityShowFeedLink || $topInlineLinks): ?> | |
| 41 | + <?php if($fluentCommunityShowFeedLink || $fluentCommunityTopInlineLinks): ?> | |
| 29 | 42 | <nav aria-label="<?php echo esc_attr__('Main Sidebar Mobile Menu', 'fluent-community'); ?>"> |
| 30 | 43 | <ul class="fcom_general_menu"> |
| 31 | 44 | <?php if ($fluentCommunityShowFeedLink): ?> |
| 32 | 45 | <li class="fcom_menu_item_all_feeds fcom_desktop_only"> |
| 33 | - <a class="fcom_menu_link fcom_dashboard route_url" | |
| 34 | - href="<?php echo esc_url(Helper::baseUrl('/')); ?>"> | |
| 46 | + <a class="fcom_menu_link <?php echo esc_attr(Arr::get($fluentCommunityFeedItem, 'link_classes', 'fcom_dashboard route_url')); ?>" | |
| 47 | + data-fcom-hint="<?php echo esc_attr(Arr::get($fluentCommunityFeedItem, 'title', __('Feed', 'fluent-community'))); ?>" | |
| 48 | + href="<?php echo esc_url(Arr::get($fluentCommunityFeedItem, 'permalink', Helper::baseUrl('/'))); ?>"> | |
| 35 | 49 | <div class="community_avatar"> |
| 36 | 50 | <span class="fcom_shape"> |
| 37 | 51 | <i class="el-icon"> |
| 38 | - <?php if (!empty($primaryItems['all_feeds'])): ?> | |
| 39 | - <?php Helper::printLinkIcon($primaryItems['all_feeds']); // prints directly with internal escaping ?> | |
| 40 | - <?php else: ?> | |
| 41 | - <svg width="20" height="18" viewBox="0 0 20 18" fill="none"> | |
| 42 | - <path fill-rule="evenodd" d="M10 13.166H10.0075H10Z" fill="currentColor"/> | |
| 43 | - <path d="M10 13.166H10.0075" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | |
| 44 | - <path d="M16.6666 6.08301V10.2497C16.6666 13.3924 16.6666 14.9637 15.6903 15.94C14.714 16.9163 13.1426 16.9163 9.99992 16.9163C6.85722 16.9163 5.28587 16.9163 4.30956 15.94C3.33325 14.9637 3.33325 13.3924 3.33325 10.2497V6.08301" stroke="currentColor" stroke-width="1.5"/> | |
| 45 | - <path d="M18.3333 7.74967L14.714 4.27925C12.4918 2.14842 11.3807 1.08301 9.99996 1.08301C8.61925 1.08301 7.50814 2.14842 5.28592 4.27924L1.66663 7.74967" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/> | |
| 46 | - </svg> | |
| 47 | - <?php endif; ?> | |
| 52 | + <?php Helper::printLinkIcon($fluentCommunityFeedItem); // prints directly with internal escaping ?> | |
| 48 | 53 | </i> |
| 49 | 54 | </span> |
| 50 | 55 | </div> |
| 51 | - <span class="community_name"> | |
| 52 | - <?php if (!empty($primaryItems['all_feeds']['title'])): ?> | |
| 53 | - <?php echo esc_html($primaryItems['all_feeds']['title']); ?> | |
| 54 | - <?php else: ?> | |
| 55 | - <?php esc_html_e('Feed', 'fluent-community'); ?> | |
| 56 | - <?php endif; ?> | |
| 56 | + <span class="community_name" title="<?php echo esc_attr(Arr::get($fluentCommunityFeedItem, 'title', __('Feed', 'fluent-community'))); ?>"> | |
| 57 | + <?php echo esc_html(Arr::get($fluentCommunityFeedItem, 'title', __('Feed', 'fluent-community'))); ?> | |
| 57 | 58 | </span> |
| 58 | 59 | </a> |
| 59 | 60 | </li> |
| 60 | 61 | <?php endif; ?> |
| 61 | - <?php Helper::renderMenuItems($topInlineLinks, 'fcom_menu_link fcom_custom_link', '<span class="fcom_no_avatar"></span>', true); ?> | |
| 62 | + <?php Helper::renderMenuItems($fluentCommunityTopInlineLinks, 'fcom_menu_link fcom_custom_link', '<span class="fcom_no_avatar"></span>', true); ?> | |
| 62 | 63 | </ul> |
| 63 | 64 | </nav> |
| 64 | 65 | <?php endif; ?> |
| 65 | 66 | |
| 66 | 67 | <div class="fcom_sidebar_contents"> |
| 67 | - <?php foreach ($spaceGroups as $fluentCommunitySpaceGroup): ?> | |
| 68 | + <?php foreach ($fluentCommunitySpaceGroups as $fluentCommunitySpaceGroup): ?> | |
| 68 | 69 | <?php if($fluentCommunitySpaceGroup['children']): ?> |
| 69 | - <?php | |
| 70 | - $fluentCommunityGroupCollapsedClass = in_array(sanitize_key((string) $fluentCommunitySpaceGroup['id']), $fluentCommunityCollapsedGroups, true) | |
| 70 | + <?php | |
| 71 | + $fluentCommunityGroupCollapsedClass = in_array(sanitize_key((string) $fluentCommunitySpaceGroup['id']), $fluentCommunityCollapsedGroups, true) | |
| 71 | 72 | ? ' fcom_group_collapsed' |
| 72 | 73 | : ''; |
| 73 | - ?> | |
| 74 | + ?> | |
| 74 | 75 | <div class="<?php echo esc_attr('fcom_communities_menu' . $fluentCommunityGroupCollapsedClass); ?>"> |
| 75 | 76 | <div class="fcom_space_group_header fcom_group_title"> |
| 76 | - <h4 data-group_id="<?php echo (int)$fluentCommunitySpaceGroup['id']; ?>" data-fcom-tip="<?php echo esc_attr($fluentCommunitySpaceGroup['title']); ?>" class="space_section_title" tabindex="0" role="button" aria-label="<?php echo esc_attr($fluentCommunitySpaceGroup['title']); ?>" aria-expanded="<?php echo $fluentCommunityGroupCollapsedClass ? 'false' : 'true'; ?>"> | |
| 77 | - <span><?php echo esc_html($fluentCommunitySpaceGroup['title']); ?></span> | |
| 77 | + <?php // No title/aria-label on the header itself: the inner span text is the accessible name, so either attribute would make screen readers repeat it. ?> | |
| 78 | + <h4 data-group_id="<?php echo (int)$fluentCommunitySpaceGroup['id']; ?>" data-fcom-hint="<?php echo esc_attr($fluentCommunitySpaceGroup['title']); ?>" class="space_section_title" tabindex="0" role="button" aria-expanded="<?php echo $fluentCommunityGroupCollapsedClass ? 'false' : 'true'; ?>"> | |
| 79 | + <span title="<?php echo esc_attr($fluentCommunitySpaceGroup['title']); ?>"><?php echo esc_html($fluentCommunitySpaceGroup['title']); ?></span> | |
| 78 | 80 | <i class="el-icon fcom_space_down"> |
| 79 | 81 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"></path></svg> |
| 80 | 82 | </i> |
| 81 | 83 | </h4> |
| 82 | - <?php if ($is_admin): ?> | |
| 84 | + <?php if ($fluentCommunityIsAdmin): ?> | |
| 83 | 85 | <div class="fcom_space_create"> |
| 84 | 86 | <a class="fcom_space_create_link" data-parent_id="<?php echo (int)$fluentCommunitySpaceGroup['id']; ?>" href="<?php echo esc_url(Helper::baseUrl('discover/spaces/?create_space=yes&parent_id=' . $fluentCommunitySpaceGroup['id'])); ?>">+</a> |
| 85 | 87 | </div> |
| 86 | 88 | <?php endif; ?> |
| 87 | 89 | </div> |
| 88 | - <nav aria-label="Group Menu for <?php echo esc_html($fluentCommunitySpaceGroup['title']); ?>"> | |
| 90 | + <?php /* translators: %s is replaced by the title of the space group */ ?> | |
| 91 | + <nav aria-label="<?php echo esc_attr(sprintf(__('Group menu for %s', 'fluent-community'), $fluentCommunitySpaceGroup['title'])); ?>"> | |
| 89 | 92 | <ul> |
| 90 | 93 | <?php foreach ($fluentCommunitySpaceGroup['children'] as $fluentCommunityLink): ?> |
| 91 | 94 | <li class="space_menu_item"> |
| 92 | 95 | <?php Helper::renderLink($fluentCommunityLink, 'fcom_menu_link'); ?> |
| @@ -97,10 +100,10 @@ | ||
| 97 | 100 | </div> |
| 98 | 101 | <?php endif; ?> |
| 99 | 102 | <?php endforeach; ?> |
| 100 | 103 | |
| 101 | - <?php if ($bottomLinkGroups): ?> | |
| 102 | - <?php foreach ($bottomLinkGroups as $fluentCommunityBottomLink): ?> | |
| 104 | + <?php if ($fluentCommunityBottomLinkGroups): ?> | |
| 105 | + <?php foreach ($fluentCommunityBottomLinkGroups as $fluentCommunityBottomLink): ?> | |
| 103 | 106 | <?php |
| 104 | 107 | $fluentCommunityBottomItems = isset($fluentCommunityBottomLink['items']) ? $fluentCommunityBottomLink['items'] : []; |
| 105 | 108 | |
| 106 | 109 | $fluentCommunityBottomCollapsedClass = in_array(sanitize_key((string) $fluentCommunityBottomLink['slug']), $fluentCommunityCollapsedGroups, true) |
| @@ -108,16 +111,16 @@ | ||
| 108 | 111 | : ''; |
| 109 | 112 | ?> |
| 110 | 113 | <div class="<?php echo esc_attr('fcom_communities_menu' . $fluentCommunityBottomCollapsedClass); ?>"> |
| 111 | 114 | <div class="fcom_space_group_header fcom_group_title"> |
| 112 | - <h4 role="button" tabindex="0" aria-expanded="<?php echo $fluentCommunityBottomCollapsedClass ? 'false' : 'true'; ?>" aria-label="<?php echo esc_attr($fluentCommunityBottomLink['title']); ?>" data-group_id="<?php echo esc_attr($fluentCommunityBottomLink['slug']); ?>" data-fcom-tip="<?php echo esc_attr($fluentCommunityBottomLink['title']); ?>" | |
| 115 | + <h4 role="button" tabindex="0" aria-expanded="<?php echo $fluentCommunityBottomCollapsedClass ? 'false' : 'true'; ?>" data-group_id="<?php echo esc_attr($fluentCommunityBottomLink['slug']); ?>" data-fcom-hint="<?php echo esc_attr($fluentCommunityBottomLink['title']); ?>" | |
| 113 | 116 | class="space_section_title"> |
| 114 | - <span><?php echo esc_html($fluentCommunityBottomLink['title']); ?></span> | |
| 117 | + <span title="<?php echo esc_attr($fluentCommunityBottomLink['title']); ?>"><?php echo esc_html($fluentCommunityBottomLink['title']); ?></span> | |
| 115 | 118 | <i class="el-icon fcom_space_down"> |
| 116 | 119 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"></path></svg> |
| 117 | 120 | </i> |
| 118 | 121 | </h4> |
| 119 | - <?php if ($is_admin): ?> | |
| 122 | + <?php if ($fluentCommunityIsAdmin): ?> | |
| 120 | 123 | <div class="fcom_space_create"> |
| 121 | 124 | <a href="<?php echo esc_url(Helper::baseUrl('admin/settings/menu-settings')); ?>"> |
| 122 | 125 | + |
| 123 | 126 | </a> |
| @@ -123,9 +126,10 @@ | ||
| 123 | 126 | </a> |
| 124 | 127 | </div> |
| 125 | 128 | <?php endif; ?> |
| 126 | 129 | </div> |
| 127 | - <nav aria-label="Group Menu for <?php echo esc_html($fluentCommunityBottomLink['title']); ?>"> | |
| 130 | + <?php /* translators: %s is replaced by the title of the sidebar link group */ ?> | |
| 131 | + <nav aria-label="<?php echo esc_attr(sprintf(__('Group menu for %s', 'fluent-community'), $fluentCommunityBottomLink['title'])); ?>"> | |
| 128 | 132 | <ul> |
| 129 | 133 | <?php foreach ($fluentCommunityBottomLink['items'] as $fluentCommunityButtomLink): ?> |
| 130 | 134 | <li class="space_menu_item"> |
| 131 | 135 | <?php Helper::renderLink($fluentCommunityButtomLink, 'fcom_menu_link space_menu_item route_url fcom_custom_link', '🔗'); ?> |
| @@ -137,13 +141,13 @@ | ||
| 137 | 141 | <?php endforeach; ?> |
| 138 | 142 | <?php endif; ?> |
| 139 | 143 | |
| 140 | 144 | |
| 141 | - <?php if ($settingsItems): ?> | |
| 145 | + <?php if ($fluentCommunitySettingsItems): ?> | |
| 142 | 146 | <div style="margin-top: 20px;"> |
| 143 | 147 | <h4 class="space_section_title"><?php esc_html_e('# Manage', 'fluent-community'); ?></h4> |
| 144 | 148 | <ul style="margin-top: 20px;"> |
| 145 | - <?php Helper::renderSettingsMenuItems($settingsItems); ?> | |
| 149 | + <?php Helper::renderSettingsMenuItems($fluentCommunitySettingsItems); ?> | |
| 146 | 150 | </ul> |
| 147 | 151 | </div> |
| 148 | 152 | <?php endif; ?> |
| 149 | 153 | </div> |
| @@ -150,9 +154,9 @@ | ||
| 150 | 154 | <?php endif; ?> |
| 151 | 155 | </div> |
| 152 | 156 | |
| 153 | 157 | |
| 154 | -<?php if ($context != 'ajax'): ?> | |
| 155 | - <?php do_action('fluent_community/after_sidebar_wrap', $context); ?> | |
| 158 | +<?php if ($fluentCommunityContext != 'ajax'): ?> | |
| 159 | + <?php do_action('fluent_community/after_sidebar_wrap', $fluentCommunityContext); ?> | |
| 156 | 160 | <div id="fcom_menu_sidebar"></div> |
| 157 | - <?php do_action('fluent_community/after_portal_sidebar', $context); ?> | |
| 161 | + <?php do_action('fluent_community/after_portal_sidebar', $fluentCommunityContext); ?> | |
| 158 | 162 | <?php endif; ?> |