| 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' && Helper::isSiteAdmin()) { |
| 15 |
add_action('fluent_community/before_header_right_menu_items', function () { |
| 16 |
?> |
| 17 |
<li class="customizer_menu_item"> |
| 18 |
<a |
| 19 |
href="<?php echo esc_url(Helper::baseUrl('/?customizer_panel=1')); ?>"> |
| 20 |
<?php esc_html_e('Customize Colors', 'fluent-community'); ?> |
| 21 |
</a> |
| 22 |
</li> |
| 23 |
<li class="top_menu_item customizer_menu_button"> |
| 24 |
<button type="button" aria-label="<?php echo esc_attr__('Customize', 'fluent-community'); ?>" class="fcom_menu_button"> |
| 25 |
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_3687_33463)"><path d="M18.3337 9.99984C18.3337 5.39746 14.6027 1.6665 10.0003 1.6665C5.39795 1.6665 1.66699 5.39746 1.66699 9.99984C1.66699 14.6022 5.39795 18.3332 10.0003 18.3332C10.7018 18.3332 11.667 18.4301 11.667 17.4998C11.667 16.9924 11.403 16.6008 11.1408 16.2119C10.7572 15.6428 10.3773 15.0793 10.8337 14.1665C11.3892 13.0554 12.3152 13.0554 13.7349 13.0554C14.4448 13.0554 15.2781 13.0554 16.2504 12.9165C18.0012 12.6664 18.3337 11.5902 18.3337 9.99984Z" stroke="currentColor" stroke-width="1.5"></path><path d="M5.83398 12.502L5.84121 12.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><ellipse cx="7.91699" cy="7.08301" rx="1.25" ry="1.25" stroke="currentColor" stroke-width="1.5"></ellipse><ellipse cx="13.75" cy="7.9165" rx="1.25" ry="1.25" stroke="currentColor" stroke-width="1.5"></ellipse></g><defs><clipPath id="clip0_3687_33463"><rect width="20" height="20" fill="currentColor"></rect></clipPath></defs></svg> |
| 26 |
</button> |
| 27 |
</li> |
| 28 |
<?php |
| 29 |
}); |
| 30 |
} else if (isset($_GET['customizer_panel']) && Helper::isSiteAdmin()) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 31 |
$isRtl = Helper::isRtl(); |
| 32 |
$vars['css_files'] = array_merge($vars['css_files'], [ |
| 33 |
'customizer' => [ |
| 34 |
'url' => Vite::getStaticSrcUrl('customizer.css', $isRtl) |
| 35 |
], |
| 36 |
'customizer_app' => [ |
| 37 |
'url' => Vite::getStaticSrcUrl('customizer_app.css', $isRtl) |
| 38 |
], |
| 39 |
]); |
| 40 |
|
| 41 |
add_action('fluent_community/before_portal_rendered', [$this, 'pushCustomizer'], 10, 1); |
| 42 |
$vars['js_vars']['customizerI18n'] = [ |
| 43 |
'Light Mode' => __('Light Mode', 'fluent-community'), |
| 44 |
'Dark Mode' => __('Dark Mode', 'fluent-community'), |
| 45 |
'color_inst' => __('The following styles will be applied when a member views your community in', 'fluent-community'), |
| 46 |
'Exit' => __('Exit', 'fluent-community'), |
| 47 |
'Save Settings' => __('Save Settings', 'fluent-community'), |
| 48 |
'Color Schema' => __('Color Schema', 'fluent-community'), |
| 49 |
'Select Color Schema' => __('Select Color Schema', 'fluent-community'), |
| 50 |
'Header' => __('Header', 'fluent-community'), |
| 51 |
'Background color of the header area' => __('Background color of the header area', 'fluent-community'), |
| 52 |
'Background' => __('Background', 'fluent-community'), |
| 53 |
'Link or Button colors of the header area' => __('Link or Button colors of the header area', 'fluent-community'), |
| 54 |
'Text/Link' => __('Text/Link', 'fluent-community'), |
| 55 |
'Background color of the active item in the top menu' => __('Background color of the active item in the top menu', 'fluent-community'), |
| 56 |
'Active Item Background' => __('Active Item Background', 'fluent-community'), |
| 57 |
'Text color of the active item in the top menu' => __('Text color of the active item in the top menu', 'fluent-community'), |
| 58 |
'Active Item Color' => __('Active Item Color', 'fluent-community'), |
| 59 |
'Background color of the hovered item in the top menu' => __('Background color of the hovered item in the top menu', 'fluent-community'), |
| 60 |
'Hover Background' => __('Hover Background', 'fluent-community'), |
| 61 |
'Text color of the hovered item in the top menu' => __('Text color of the hovered item in the top menu', 'fluent-community'), |
| 62 |
'Hover Color' => __('Hover Color', 'fluent-community'), |
| 63 |
'The main background color of the sidebar' => __('The main background color of the sidebar', 'fluent-community'), |
| 64 |
'The text/link color of the sidebar' => __('The text/link color of the sidebar', 'fluent-community'), |
| 65 |
'Background color of the active item in the sidebar' => __('Background color of the active item in the sidebar', 'fluent-community'), |
| 66 |
'Text color of the active item in the sidebar' => __('Text color of the active item in the sidebar', 'fluent-community'), |
| 67 |
'Background color of the hovered item in the sidebar' => __('Background color of the hovered item in the sidebar', 'fluent-community'), |
| 68 |
'Text color of the hovered item in the sidebar' => __('Text color of the hovered item in the sidebar', 'fluent-community'), |
| 69 |
'Background color of the main area' => __('Background color of the main area', 'fluent-community'), |
| 70 |
'Body Background' => __('Body Background', 'fluent-community'), |
| 71 |
'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'), |
| 72 |
'Primary Content Background' => __('Primary Content Background', 'fluent-community'), |
| 73 |
'Background color of the secondary content area like each comment' => __('Background color of the secondary content area like each comment', 'fluent-community'), |
| 74 |
'Secondary Content Background' => __('Secondary Content Background', 'fluent-community'), |
| 75 |
'Text color of the main area this includes post, comment, headings' => __('Text color of the main area this includes post, comment, headings', 'fluent-community'), |
| 76 |
'Text Color' => __('Text Color', 'fluent-community'), |
| 77 |
'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'), |
| 78 |
'Off Text Color' => __('Off Text Color', 'fluent-community'), |
| 79 |
'Border color of the main sections' => __('Border color of the main sections', 'fluent-community'), |
| 80 |
'Primary Border Color' => __('Primary Border Color', 'fluent-community'), |
| 81 |
'Border color of the secondary sections' => __('Border color of the secondary sections', 'fluent-community'), |
| 82 |
'Secondary Border Color' => __('Secondary Border Color', 'fluent-community'), |
| 83 |
'Navigations' => __('Navigations', 'fluent-community'), |
| 84 |
'Color of the links in the main content area.' => __('Color of the links in the main content area.', 'fluent-community'), |
| 85 |
'Link Color' => __('Link Color', 'fluent-community'), |
| 86 |
'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'), |
| 87 |
'Primary Button Background' => __('Primary Button Background', 'fluent-community'), |
| 88 |
'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'), |
| 89 |
'Primary Button Text Color' => __('Primary Button Text Color', 'fluent-community'), |
| 90 |
'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'), |
| 91 |
'Secondary Nav Text Color' => __('Secondary Nav Text Color', 'fluent-community'), |
| 92 |
'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'), |
| 93 |
'Secondary Nav Active Background' => __('Secondary Nav Active Background', 'fluent-community'), |
| 94 |
'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'), |
| 95 |
'Secondary Nav Active Color' => __('Secondary Nav Active Color', 'fluent-community'), |
| 96 |
'Sidebar' => __('Sidebar', 'fluent-community'), |
| 97 |
'General' => __('General', 'fluent-community'), |
| 98 |
'Save Settings (Pro Required)' => __('Save Settings (Pro Required)', 'fluent-community'), |
| 99 |
]; |
| 100 |
} |
| 101 |
|
| 102 |
return $vars; |
| 103 |
}); |
| 104 |
} |
| 105 |
|
| 106 |
public function pushCustomizer($data) |
| 107 |
{ |
| 108 |
add_action('fluent_community/portal_footer', function () { |
| 109 |
$jsFiles = [ |
| 110 |
'customizer_app' => [ |
| 111 |
'url' => Vite::getDynamicSrcUrl('customizer/customizer_app.js') |
| 112 |
], |
| 113 |
]; |
| 114 |
|
| 115 |
foreach ($jsFiles as $file) { |
| 116 |
?> |
| 117 |
<script type="module" |
| 118 |
src="<?php echo esc_url($file['url']); ?>?version=<?php echo esc_attr(FLUENT_COMMUNITY_PLUGIN_VERSION); ?>" |
| 119 |
defer="defer"></script> |
| 120 |
<?php |
| 121 |
} |
| 122 |
}, 1); |
| 123 |
|
| 124 |
add_action('fluent_community/before_portal_dom', function () { |
| 125 |
?> |
| 126 |
<div id="fcom_customizer_panel"> |
| 127 |
|
| 128 |
</div> |
| 129 |
<?php |
| 130 |
}); |
| 131 |
} |
| 132 |
|
| 133 |
} |
| 134 |
|