| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCommunity\App\Hooks\Handlers; |
| 4 |
|
| 5 |
use FluentCommunity\App\Services\Helper; |
| 6 |
use FluentCommunity\App\Vite; |
| 7 |
use FluentCommunity\Framework\Support\Arr; |
| 8 |
|
| 9 |
class CustomizerHander |
| 10 |
{ |
| 11 |
public function register() |
| 12 |
{ |
| 13 |
add_filter('fluent_community/portal_data_vars', function ($vars) { |
| 14 |
if (Arr::get($vars, 'route_group') == 'admin') { |
| 15 |
add_action('fluent_community/before_header_right_menu_items', function () { |
| 16 |
?> |
| 17 |
<li> |
| 18 |
<a style="border: 1px solid; padding: 3px 15px; color: var(--fcom-menu-text, #545861);background: var(--fcom-active-bg, #f0f3f5);" |
| 19 |
href="<?php echo esc_url(Helper::baseUrl('/?customizer_panel=1')); ?>"><?php _e('Customize Colors', 'fluent-community'); ?></a> |
| 20 |
</li> |
| 21 |
<?php |
| 22 |
}); |
| 23 |
} else if (isset($_GET['customizer_panel']) && Helper::isSiteAdmin()) { |
| 24 |
|
| 25 |
$vars['css_files'] = array_merge($vars['css_files'], [ |
| 26 |
'customizer' => [ |
| 27 |
'url' => Vite::getStaticSrcUrl('customizer.css') |
| 28 |
], |
| 29 |
'customizer_app' => [ |
| 30 |
'url' => Vite::getStaticSrcUrl('customizer_app.css') |
| 31 |
], |
| 32 |
]); |
| 33 |
|
| 34 |
add_action('fluent_community/before_portal_rendered', [$this, 'pushCustomizer'], 10, 1); |
| 35 |
$vars['js_vars']['customizerI18n'] = [ |
| 36 |
'Light Mode' => __('Light Mode', 'fluent-community'), |
| 37 |
'Dark Mode' => __('Dark Mode', 'fluent-community'), |
| 38 |
'color_inst' => __('The following styles will be applied when a member views your community in'), |
| 39 |
'Exit' => __('Exit', 'fluent-community'), |
| 40 |
'Save Settings' => __('Save Settings', 'fluent-community'), |
| 41 |
'Color Schema' => __('Color Schema', 'fluent-community'), |
| 42 |
'Select Color Schema' => __('Select Color Schema', 'fluent-community'), |
| 43 |
'Header' => __('Header', 'fluent-community'), |
| 44 |
'Background color of the header area' => __('Background color of the header area', 'fluent-community'), |
| 45 |
'Background' => __('Background', 'fluent-community'), |
| 46 |
'Link or Button colors of the header area' => __('Link or Button colors of the header area', 'fluent-community'), |
| 47 |
'Text/Link' => __('Text/Link', 'fluent-community'), |
| 48 |
'Background color of the active item in the top menu' => __('Background color of the active item in the top menu', 'fluent-community'), |
| 49 |
'Active Item Background' => __('Active Item Background', 'fluent-community'), |
| 50 |
'Text color of the active item in the top menu' => __('Text color of the active item in the top menu', 'fluent-community'), |
| 51 |
'Active Item Color' => __('Active Item Color', 'fluent-community'), |
| 52 |
'Background color of the hovered item in the top menu' => __('Background color of the hovered item in the top menu', 'fluent-community'), |
| 53 |
'Hover Background' => __('Hover Background', 'fluent-community'), |
| 54 |
'Text color of the hovered item in the top menu' => __('Text color of the hovered item in the top menu', 'fluent-community'), |
| 55 |
'Hover Color' => __('Hover Color', 'fluent-community'), |
| 56 |
'The main background color of the sidebar' => __('The main background color of the sidebar', 'fluent-community'), |
| 57 |
'The text/link color of the sidebar' => __('The text/link color of the sidebar', 'fluent-community'), |
| 58 |
'Background color of the active item in the sidebar' => __('Background color of the active item in the sidebar', 'fluent-community'), |
| 59 |
'Text color of the active item in the sidebar' => __('Text color of the active item in the sidebar', 'fluent-community'), |
| 60 |
'Background color of the hovered item in the sidebar' => __('Background color of the hovered item in the sidebar', 'fluent-community'), |
| 61 |
'Text color of the hovered item in the sidebar' => __('Text color of the hovered item in the sidebar', 'fluent-community'), |
| 62 |
'Background color of the main area' => __('Background color of the main area', 'fluent-community'), |
| 63 |
'Body Background' => __('Body Background', 'fluent-community'), |
| 64 |
'Background color of the primary content area like sub header and post content' => __('Background color of the primary content area like sub header and post content', 'fluent-community'), |
| 65 |
'Primary Content Background' => __('Primary Content Background', 'fluent-community'), |
| 66 |
'Background color of the secondary content area like each comment' => __('Background color of the secondary content area like each comment', 'fluent-community'), |
| 67 |
'Secondary Content Background' => __('Secondary Content Background', 'fluent-community'), |
| 68 |
'Text color of the main area this includes post, comment, headings' => __('Text color of the main area this includes post, comment, headings', 'fluent-community'), |
| 69 |
'Text Color' => __('Text Color', 'fluent-community'), |
| 70 |
'Text color of the secondary area this includes post meta, comment meta' => __('Text color of the secondary area this includes post meta, comment meta', 'fluent-community'), |
| 71 |
'Off Text Color' => __('Off Text Color', 'fluent-community'), |
| 72 |
'Border color of the main sections' => __('Border color of the main sections', 'fluent-community'), |
| 73 |
'Primary Border Color' => __('Primary Border Color', 'fluent-community'), |
| 74 |
'order color of the secondary sections' => __('order color of the secondary sections', 'fluent-community'), |
| 75 |
'Secondary Border Color' => __('Secondary Border Color', 'fluent-community'), |
| 76 |
'Navigations' => __('Navigations', 'fluent-community'), |
| 77 |
'Color of the links in the main content area.' => __('Color of the links in the main content area.', 'fluent-community'), |
| 78 |
'Link Color' => __('Link Color', 'fluent-community'), |
| 79 |
'Background color of the primary buttons. This includes the buttons in the post, comment, and forms.' => __('Background color of the primary buttons. This includes the buttons in the post, comment, and forms.', 'fluent-community'), |
| 80 |
'Primary Button Background' => __('Primary Button Background', 'fluent-community'), |
| 81 |
'Text color of the primary buttons. This includes the buttons in the post, comment, and forms.' => __('Text color of the primary buttons. This includes the buttons in the post, comment, and forms.', 'fluent-community'), |
| 82 |
'Primary Button Text Color' => __('Primary Button Text Color', 'fluent-community'), |
| 83 |
'Background color of the secondary buttons. This includes the buttons in the space, user profile, and other secondary headers.' => __('Background color of the secondary buttons. This includes the buttons in the space, user profile, and other secondary headers.', 'fluent-community'), |
| 84 |
'Secondary Nav Text Color' => __('Secondary Nav Text Color', 'fluent-community'), |
| 85 |
'Background color of the secondary buttons on active state. This includes the buttons in the space, user profile, and other secondary headers.' => __('Background color of the secondary buttons on active state. This includes the buttons in the space, user profile, and other secondary headers.', 'fluent-community'), |
| 86 |
'Secondary Nav Active Background' => __('Secondary Nav Active Background', 'fluent-community'), |
| 87 |
'Text color of the secondary buttons on active state. This includes the buttons in the space, user profile, and other secondary headers.' => __('Text color of the secondary buttons on active state. This includes the buttons in the space, user profile, and other secondary headers.', 'fluent-community'), |
| 88 |
'Secondary Nav Active Color' => __('Secondary Nav Active Color', 'fluent-community') |
| 89 |
]; |
| 90 |
} |
| 91 |
|
| 92 |
return $vars; |
| 93 |
}); |
| 94 |
} |
| 95 |
|
| 96 |
public function pushCustomizer($data) |
| 97 |
{ |
| 98 |
add_action('fluent_community/portal_footer', function () { |
| 99 |
$jsFiles = [ |
| 100 |
'customizer_app' => [ |
| 101 |
'url' => Vite::getDynamicSrcUrl('customizer/customizer_app.js') |
| 102 |
], |
| 103 |
]; |
| 104 |
|
| 105 |
foreach ($jsFiles as $file) { |
| 106 |
?> |
| 107 |
<script type="module" |
| 108 |
src="<?php echo esc_url($file['url']); ?>?version=<?php echo esc_attr(FLUENT_COMMUNITY_PLUGIN_VERSION); ?>" |
| 109 |
defer="defer"></script> |
| 110 |
<?php |
| 111 |
} |
| 112 |
}, 1); |
| 113 |
|
| 114 |
add_action('fluent_community/before_portal_dom', function () { |
| 115 |
?> |
| 116 |
<div id="fcom_customizer_panel"> |
| 117 |
|
| 118 |
</div> |
| 119 |
<?php |
| 120 |
}); |
| 121 |
} |
| 122 |
|
| 123 |
} |
| 124 |
|