| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCommunity\App\Hooks\Handlers; |
| 4 |
|
| 5 |
use FluentCommunity\App\Functions\Utility; |
| 6 |
use FluentCommunity\App\Services\Helper; |
| 7 |
use FluentCommunity\App\Vite; |
| 8 |
use FluentCommunity\Framework\Support\Arr; |
| 9 |
|
| 10 |
class PortalSettingsHandler |
| 11 |
{ |
| 12 |
public function register() |
| 13 |
{ |
| 14 |
add_filter('fluent_community/portal_data_vars', function ($vars) { |
| 15 |
if (Arr::get($vars, 'route_group') != 'admin') { |
| 16 |
return $vars; |
| 17 |
} |
| 18 |
|
| 19 |
$isRtl = Helper::isRtl(); |
| 20 |
unset($vars['js_files']['fcom_app_admin']); |
| 21 |
$vars['js_files']['fcom_app'] = [ |
| 22 |
'url' => Vite::getStaticSrcUrl('admin_app.js'), |
| 23 |
'deps' => [] |
| 24 |
]; |
| 25 |
|
| 26 |
if (!Utility::isDev()) { |
| 27 |
$vars['css_files']['fcom_admin_vendor'] = [ |
| 28 |
'url' => Vite::getStaticSrcUrl('admin_app.css', $isRtl) // vite automatically build src/admin_app.css for all components also styles inside components |
| 29 |
]; |
| 30 |
} |
| 31 |
|
| 32 |
add_filter('fluent_community/header_vars', function ($vars) { |
| 33 |
$vars['menuItems'] = []; |
| 34 |
return $vars; |
| 35 |
}); |
| 36 |
|
| 37 |
add_filter('fluent_community/will_render_default_sidebar_items', '__return_false'); |
| 38 |
|
| 39 |
add_action('fluent_community/after_header_menu', function () { |
| 40 |
echo '<h4 style="margin: 0; font-size: 20px;">' . __('Portal Settings', 'fluent-community') . '</h4>'; |
| 41 |
}); |
| 42 |
|
| 43 |
$vars['js_vars']['fluentComAdmin']['portal_slug'] = ltrim(Helper::getPortalSlug(true), '/') . '/admin'; |
| 44 |
|
| 45 |
// check if current route starts with admin |
| 46 |
return $vars; |
| 47 |
}); |
| 48 |
} |
| 49 |
} |
| 50 |
|