PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.11
Booking for Appointments and Events Calendar – Amelia v1.2.11
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Infrastructure / WP / config / Menu.php
ameliabooking / src / Infrastructure / WP / config Last commit date
Database.php 1 year ago Menu.php 2 years ago Roles.php 2 years ago
Menu.php
160 lines
1 <?php
2
3 namespace AmeliaBooking\Infrastructure\WP\config;
4
5 use AmeliaBooking\Domain\Services\Settings\SettingsService;
6 use AmeliaBooking\Infrastructure\Licence\Licence;
7 use AmeliaBooking\Infrastructure\WP\Translations\BackendStrings;
8
9 /**
10 * Class Menu
11 */
12 class Menu
13 {
14 /** @var SettingsService $settingsService */
15 private $settingsService;
16
17 /**
18 * Menu constructor.
19 *
20 * @param SettingsService $settingsService
21 */
22 public function __construct(SettingsService $settingsService)
23 {
24 $this->settingsService = $settingsService;
25 }
26
27 /**
28 * @return array
29 */
30 public function __invoke()
31 {
32 $defaultPageOnBackend = $this->settingsService->getSetting(
33 'general',
34 'defaultPageOnBackend'
35 );
36
37 $defaultPages = [
38 [
39 'parentSlug' => 'amelia',
40 'pageTitle' => 'Dashboard',
41 'menuTitle' => BackendStrings::getDashboardStrings()['dashboard'],
42 'capability' => 'amelia_read_dashboard',
43 'menuSlug' => 'wpamelia-dashboard',
44 ],
45 [
46 'parentSlug' => 'amelia',
47 'pageTitle' => 'Calendar',
48 'menuTitle' => BackendStrings::getCalendarStrings()['calendar'],
49 'capability' => 'amelia_read_calendar',
50 'menuSlug' => 'wpamelia-calendar',
51 ],
52 [
53 'parentSlug' => 'amelia',
54 'pageTitle' => 'Appointments',
55 'menuTitle' => BackendStrings::getCommonStrings()['appointments'],
56 'capability' => 'amelia_read_appointments',
57 'menuSlug' => 'wpamelia-appointments',
58 ],
59 [
60 'parentSlug' => 'amelia',
61 'pageTitle' => 'Events',
62 'menuTitle' => BackendStrings::getCommonStrings()['events'],
63 'capability' => 'amelia_read_events',
64 'menuSlug' => 'wpamelia-events',
65 ]
66 ];
67
68 $defaultPageKey = array_search($defaultPageOnBackend, array_column($defaultPages, 'pageTitle'), true);
69
70 $defaultPageElement = array_splice($defaultPages, $defaultPageKey, 1);
71
72 $menuItems = [
73 [
74 'parentSlug' => 'amelia',
75 'pageTitle' => 'Services',
76 'menuTitle' => BackendStrings::getCommonStrings()['services'],
77 'capability' => 'amelia_read_services',
78 'menuSlug' => 'wpamelia-services',
79 ],
80 [
81 'parentSlug' => 'amelia',
82 'pageTitle' => 'Locations',
83 'menuTitle' => BackendStrings::getCommonStrings()['locations'],
84 'capability' => 'amelia_read_locations',
85 'menuSlug' => 'wpamelia-locations',
86 ],
87 [
88 'parentSlug' => 'amelia',
89 'pageTitle' => 'Customers',
90 'menuTitle' => BackendStrings::getCustomerStrings()['customers'],
91 'capability' => 'amelia_read_customers',
92 'menuSlug' => 'wpamelia-customers',
93 ],
94 [
95 'parentSlug' => 'amelia',
96 'pageTitle' => 'Finance',
97 'menuTitle' => BackendStrings::getPaymentStrings()['finance'],
98 'capability' => 'amelia_read_finance',
99 'menuSlug' => 'wpamelia-finance',
100 ],
101 [
102 'parentSlug' => 'amelia',
103 'pageTitle' => 'Notifications',
104 'menuTitle' => BackendStrings::getNotificationsStrings()['notifications'],
105 'capability' => 'amelia_read_notifications',
106 'menuSlug' => 'wpamelia-notifications',
107 ],
108 [
109 'parentSlug' => 'amelia',
110 'pageTitle' => 'Customize',
111 'menuTitle' => BackendStrings::getCustomizeStrings()['customize'],
112 'capability' => 'amelia_read_customize',
113 'menuSlug' => 'wpamelia-customize',
114 ],
115 [
116 'parentSlug' => 'amelia',
117 'pageTitle' => 'Customize New',
118 'menuTitle' => BackendStrings::getCustomizeStrings()['customize'] . ' New',
119 'capability' => 'amelia_read_customize',
120 'menuSlug' => 'wpamelia-customize-new',
121 ],
122 [
123 'parentSlug' => 'amelia',
124 'pageTitle' => 'Custom Fields',
125 'menuTitle' => BackendStrings::getCustomizeStrings()['custom_fields'],
126 'capability' => 'amelia_read_customize',
127 'menuSlug' => 'wpamelia-cf',
128 ],
129 [
130 'parentSlug' => 'amelia',
131 'pageTitle' => 'Settings',
132 'menuTitle' => BackendStrings::getSettingsStrings()['settings'],
133 'capability' => 'amelia_read_settings',
134 'menuSlug' => 'wpamelia-settings',
135 ],
136 [
137 'parentSlug' => 'amelia',
138 'pageTitle' => 'What\'s new',
139 'menuTitle' => BackendStrings::getCommonStrings()['whats_new'],
140 'capability' => 'amelia_read_whats_new',
141 'menuSlug' => 'wpamelia-whats-new',
142 ],
143 ];
144
145 if ($liteMenuItem = Licence::getLiteMenuItem()) {
146 $menuItems[] = $liteMenuItem;
147 }
148
149 if ($employeesMenuItem = Licence::getEmployeesMenuItem()) {
150 array_unshift($menuItems, $employeesMenuItem);
151 }
152
153 return array_merge(
154 $defaultPageElement,
155 $defaultPages,
156 $menuItems
157 );
158 }
159 }
160