PluginProbe ʕ •ᴥ•ʔ
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More / 3.0.7
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More v3.0.7
4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 trunk 1.0.0 2.0.0 2.0.1 2.0.2 2.0.3 3.0 3.0.1 3.0.2 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.2.0 3.2.1 3.2.2 3.2.4 3.2.5 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.4.5 3.4.6 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.7.0 3.7.1
superb-blocks / src / admin / controllers / class-dashboard-controller.php
superb-blocks / src / admin / controllers Last commit date
class-dashboard-controller.php 2 years ago class-settings-controller.php 2 years ago class-troubleshooting-controller.php 2 years ago
class-dashboard-controller.php
375 lines
1 <?php
2
3 namespace SuperbAddons\Admin\Controllers;
4
5 defined('ABSPATH') || exit();
6
7 use SuperbAddons\Admin\Pages\DashboardPage;
8 use SuperbAddons\Admin\Pages\ElementorDashboardPage;
9 use SuperbAddons\Admin\Pages\GutenbergDashboardPage;
10 use SuperbAddons\Admin\Pages\SettingsPage;
11 use SuperbAddons\Admin\Pages\SupportPage;
12 use SuperbAddons\Components\Admin\FeedbackModal;
13 use SuperbAddons\Config\Capabilities;
14 use SuperbAddons\Data\Controllers\RestController;
15
16 use SuperbAddons\Components\Admin\Navigation;
17 use SuperbAddons\Data\Controllers\KeyController;
18 use SuperbAddons\Elementor\Controllers\ElementorController;
19 use SuperbAddons\Gutenberg\Controllers\GutenbergController;
20
21 class DashboardController
22 {
23 const MENU_SLUG = 'superbaddons';
24 const DASHBOARD = 'dashboard';
25 const ELEMENTOR_DASHBOARD = 'superbaddons-element-dashboard';
26 const GUTENBERG_DASHBOARD = 'superbaddons-gutenberg-dashboard';
27 const SETTINGS = 'superbaddons-settings';
28 const SUPPORT = 'superbaddons-support';
29
30 const PREMIUM_CLASS = 'superbaddons-get-premium';
31
32 private $hooks;
33
34 public function __construct()
35 {
36 new SettingsController();
37 new TroubleshootingController();
38 $this->hooks = array();
39 add_action("admin_menu", array($this, 'SuperbAddonsAdminMenu'));
40 add_filter('plugin_action_links_' . SUPERBADDONS_BASE, array($this, 'PluginActions'));
41 add_action('admin_enqueue_scripts', array($this, 'AdminMenuEnqueues'), 1000);
42 if (!KeyController::HasPremiumKey()) {
43 add_action("admin_head", array($this, 'AdminMenuHighlightScripts'));
44 }
45 }
46
47
48 public function PluginActions($actions)
49 {
50 $added_actions = array(
51 "<a href='" . esc_url(admin_url("admin.php?page=" . self::MENU_SLUG)) . "'>" . esc_html__('Dashboard', 'superbaddons') . "</a>",
52 "<a href='" . esc_url(admin_url("admin.php?page=" . self::SETTINGS)) . "'>" . esc_html__('Settings', 'superbaddons') . "</a>",
53 "<a href='" . esc_url(admin_url("admin.php?page=" . self::SUPPORT)) . "'>" . esc_html__('Support', 'superbaddons') . "</a>"
54 );
55 $actions = array_merge($added_actions, $actions);
56 if (!KeyController::HasPremiumKey()) {
57 $actions[] = "<a href='" . esc_url("https://superbthemes.com/superb-addons/") . "' class='" . self::PREMIUM_CLASS . "' target='_blank'>" . esc_html__('Get Premium', 'superbaddons') . "</a>";
58 }
59 return $actions;
60 }
61
62 public function SuperbAddonsAdminMenu()
63 {
64 add_menu_page(esc_html__('Superb Addons', 'superbaddons'), esc_html__('Superb Addons', 'superbaddons') . $this->GetAdminMenuNotification(), Capabilities::CONTRIBUTOR, self::MENU_SLUG, array($this, 'SuperbDashboard'), SUPERBADDONS_ASSETS_PATH . '/img/icon-superb-dashboard-menu.png', '58.6');
65 $this->hooks[self::DASHBOARD] = add_submenu_page(self::MENU_SLUG, esc_html__('Superb Addons - Dashboard', 'superbaddons'), esc_html__('Dashboard', 'superbaddons'), Capabilities::CONTRIBUTOR, self::MENU_SLUG);
66 $this->hooks[self::ELEMENTOR_DASHBOARD] = add_submenu_page(self::MENU_SLUG, esc_html__('Superb Addons - Elementor', 'superbaddons'), esc_html__('Elementor Addons', 'superbaddons'), Capabilities::CONTRIBUTOR, self::ELEMENTOR_DASHBOARD, array($this, 'ElementorDashboard'));
67 $this->hooks[self::GUTENBERG_DASHBOARD] = add_submenu_page(self::MENU_SLUG, esc_html__('Superb Addons - Gutenberg', 'superbaddons'), esc_html__('Gutenberg Addons', 'superbaddons'), Capabilities::CONTRIBUTOR, self::GUTENBERG_DASHBOARD, array($this, 'GutenbergDashboard'));
68 $this->hooks[self::SETTINGS] = add_submenu_page(self::MENU_SLUG, esc_html__('Superb Addons - Settings', 'superbaddons'), esc_html__('Settings', 'superbaddons') . $this->GetAdminMenuNotification(), Capabilities::ADMIN, self::SETTINGS, array($this, 'Settings'));
69 $this->hooks[self::SUPPORT] = add_submenu_page(self::MENU_SLUG, esc_html__('Superb Addons - Get Help', 'superbaddons'), esc_html__('Get Help', 'superbaddons'), Capabilities::CONTRIBUTOR, self::SUPPORT, array($this, 'Support'));
70 }
71
72 private function GetAdminMenuNotification()
73 {
74 $HasRegisteredKey = KeyController::HasRegisteredKey();
75 if ($HasRegisteredKey) {
76 $KeyStatus = KeyController::GetKeyStatus();
77 if (!$KeyStatus['active'] || $KeyStatus['expired'] || !$KeyStatus['verified']) {
78 return sprintf('<span class="update-plugins count-1"><span class="plugin-count" aria-hidden="true">1</span><span class="screen-reader-text">%s</span></span>', esc_html__("Issue Detected", "superbaddons"));
79 }
80 }
81
82 return;
83 }
84
85 public function AdminMenuHighlightScripts()
86 {
87 ?>
88 <style>
89 tbody#the-list .<?= self::PREMIUM_CLASS ?> {
90 color: #4312E2;
91 font-weight: 900;
92 }
93 </style>
94 <?php
95 }
96
97 public function AdminMenuEnqueues($page_hook)
98 {
99 if ($page_hook === 'plugins.php') {
100 wp_enqueue_style(
101 'superb-addons-elements',
102 SUPERBADDONS_ASSETS_PATH . '/css/framework.min.css',
103 array(),
104 SUPERBADDONS_VERSION
105 );
106 wp_enqueue_style(
107 'superb-addons-font-manrope',
108 SUPERBADDONS_ASSETS_PATH . '/fonts/manrope/manrope.css',
109 array(),
110 SUPERBADDONS_VERSION
111 );
112 wp_enqueue_style(
113 'superb-addons-admin-modal',
114 SUPERBADDONS_ASSETS_PATH . '/css/admin-modal.min.css',
115 array(),
116 SUPERBADDONS_VERSION
117 );
118
119 wp_enqueue_script('superb-addons-feedback', SUPERBADDONS_ASSETS_PATH . '/js/admin/deactivate-feedback.js', array('jquery'), SUPERBADDONS_VERSION, true);
120 wp_localize_script('superb-addons-feedback', 'superbaddonssettings_g', array(
121 "plugin" => plugin_basename(SUPERBADDONS_BASE),
122 "rest" => array(
123 "base" => \get_rest_url(),
124 "namespace" => RestController::NAMESPACE,
125 "nonce" => wp_create_nonce("wp_rest"),
126 "routes" => array(
127 "settings" => SettingsController::SETTINGS_ROUTE,
128 )
129 )
130 ));
131 add_action('admin_footer', function () {
132 new FeedbackModal();
133 });
134 return;
135 }
136
137 if (!in_array($page_hook, array_values($this->hooks))) {
138 return;
139 }
140 wp_enqueue_style(
141 'superb-addons-admin-dashboard',
142 SUPERBADDONS_ASSETS_PATH . '/css/admin-dashboard.min.css',
143 array(),
144 SUPERBADDONS_VERSION
145 );
146 wp_enqueue_style(
147 'superb-addons-elements',
148 SUPERBADDONS_ASSETS_PATH . '/css/framework.min.css',
149 array(),
150 SUPERBADDONS_VERSION
151 );
152 wp_enqueue_style(
153 'superb-addons-font-manrope',
154 SUPERBADDONS_ASSETS_PATH . '/fonts/manrope/manrope.css',
155 array(),
156 SUPERBADDONS_VERSION
157 );
158
159 if ($page_hook === $this->hooks[self::SUPPORT]) {
160 wp_enqueue_script('superb-addons-troubleshooting', SUPERBADDONS_ASSETS_PATH . '/js/admin/troubleshooting.js', array('jquery', 'wp-i18n'), SUPERBADDONS_VERSION, true);
161 wp_localize_script('superb-addons-troubleshooting', 'superbaddonstroubleshooting_g', array(
162 "rest" => array(
163 "base" => \get_rest_url(),
164 "namespace" => RestController::NAMESPACE,
165 "nonce" => wp_create_nonce("wp_rest"),
166 "routes" => array(
167 "troubleshooting" => TroubleshootingController::TROUBLESHOOTING_ROUTE,
168 "tutorial" => TroubleshootingController::TUTORIAL_ROUTE,
169 )
170 ),
171 "steps" => array(
172 "wordpressversion" => array(
173 "title" => esc_html__("WordPress Version", "superbaddons"),
174 "text" => esc_html__("Checking Compatibility", "superbaddons"),
175 "errorText" => esc_html__("Incompatible. Please update WordPress.", "superbaddons"),
176 "successText" => esc_html__("Compatible", "superbaddons"),
177 ),
178 "elementorversion" => array(
179 "title" => esc_html__("Elementor Version", "superbaddons"),
180 "text" => esc_html__("Checking Compatibility", "superbaddons"),
181 "errorText" => esc_html__("Incompatible. Please install or update Elementor.", "superbaddons"),
182 "successText" => esc_html__("Compatible", "superbaddons"),
183 ),
184 "connection" => array(
185 "title" => esc_html__("Connection Status", "superbaddons"),
186 "text" => esc_html__("Checking Connection", "superbaddons"),
187 "errorText" => esc_html__("No Connection", "superbaddons"),
188 "successText" => esc_html__("Connected", "superbaddons"),
189 ),
190 "domainshift" => array(
191 "title" => esc_html__("Connection Update", "superbaddons"),
192 "text" => esc_html__("Trying New Connection", "superbaddons"),
193 "errorText" => esc_html__("Connection Blocked", "superbaddons"),
194 "successText" => esc_html__("Connected", "superbaddons"),
195 ),
196 "service" => array(
197 "title" => esc_html__("Service Status", "superbaddons"),
198 "text" => esc_html__("Checking Service", "superbaddons"),
199 "errorText" => esc_html__("Service Unavailable", "superbaddons"),
200 "successText" => esc_html__("Service Online", "superbaddons"),
201 ),
202 "keycheck" => array(
203 "title" => esc_html__("License Key Status", "superbaddons"),
204 "text" => esc_html__("Checking License Key", "superbaddons"),
205 "errorText" => esc_html__("Invalid License Key", "superbaddons"),
206 "successText" => esc_html__("Valid License Key", "superbaddons"),
207 ),
208 "keyverify" => array(
209 "title" => esc_html__("License Key Verification", "superbaddons"),
210 "text" => esc_html__("Re-verifying License Key", "superbaddons"),
211 "errorText" => esc_html__("License could not be verified", "superbaddons"),
212 "successText" => esc_html__("License Key Verified", "superbaddons"),
213 ),
214 "cacheclear" => array(
215 "title" => esc_html__("Cache Status", "superbaddons"),
216 "text" => esc_html__("Clearing Cache", "superbaddons"),
217 "errorText" => esc_html__("Cache could not be cleared", "superbaddons"),
218 "successText" => esc_html__("Cache Cleared", "superbaddons"),
219 )
220 )
221 ));
222 add_action("admin_footer", array($this, 'TroubleshootingTemplates'));
223 wp_enqueue_style(
224 'superb-addons-admin-modal',
225 SUPERBADDONS_ASSETS_PATH . '/css/admin-modal.min.css',
226 array(),
227 SUPERBADDONS_VERSION
228 );
229 wp_enqueue_style(
230 'superbaddons-js-snackbar',
231 SUPERBADDONS_ASSETS_PATH . '/lib/js-snackbar.min.css',
232 array(),
233 SUPERBADDONS_VERSION
234 );
235 } elseif ($page_hook === $this->hooks[self::SETTINGS]) {
236 wp_enqueue_style(
237 'superb-addons-admin-modal',
238 SUPERBADDONS_ASSETS_PATH . '/css/admin-modal.min.css',
239 array(),
240 SUPERBADDONS_VERSION
241 );
242
243 wp_enqueue_script('superb-addons-settings', SUPERBADDONS_ASSETS_PATH . '/js/admin/settings.js', array('jquery'), SUPERBADDONS_VERSION, true);
244 wp_localize_script('superb-addons-settings', 'superbaddonssettings_g', array(
245 "save_message" => esc_html__("Settings saved successfully.", "superbaddons"),
246 "modal" => array(
247 "cache" => array(
248 "title" => esc_html__("Clear Cache", "superbaddons"),
249 "content" => esc_html__("All element- data and images will need to be loaded again if the cache is removed. This should only be done if you are experiencing issues or planning to delete the plugin. Are you sure you want to clear the cache?", "superbaddons"),
250 "success" => esc_html__("Cache cleared successfully.", "superbaddons")
251 ),
252 "view_logs" => array(
253 "title" => esc_html__("Error Log", "superbaddons"),
254 "no_logs" => esc_html__("No errors have been logged.", "superbaddons"),
255 "icon_unshared" => esc_url(SUPERBADDONS_ASSETS_PATH . "/img/cloud-slash.svg"),
256 "unshared_title" => esc_html__("Error Log Not Shared", "superbaddons"),
257 "icon_shared" => esc_url(SUPERBADDONS_ASSETS_PATH . "/img/cloud-check.svg"),
258 "shared_title" => esc_html__("Error Log Shared", "superbaddons"),
259 ),
260 "clear_logs" => array(
261 "title" => esc_html__("Clear Logs", "superbaddons"),
262 "content" => esc_html__("Error Logs are used for debugging purposes and help improve the plugin when shared with our support team and developers. Are you sure you want to clear the error logs?", "superbaddons"),
263 "success" => esc_html__("Error logs cleared successfully.", "superbaddons")
264 ),
265 "remove_key" => array(
266 "title" => esc_html__("Remove License Key", "superbaddons"),
267 "content" => esc_html__("Are you sure you want to remove your license key from this website?", "superbaddons"),
268 )
269 ),
270 "rest" => array(
271 "base" => \get_rest_url(),
272 "namespace" => RestController::NAMESPACE,
273 "nonce" => wp_create_nonce("wp_rest"),
274 "routes" => array(
275 "settings" => SettingsController::SETTINGS_ROUTE,
276 )
277 )
278 ));
279 wp_enqueue_style(
280 'superbaddons-js-snackbar',
281 SUPERBADDONS_ASSETS_PATH . '/lib/js-snackbar.min.css',
282 array(),
283 SUPERBADDONS_VERSION
284 );
285 } elseif ($page_hook === $this->hooks[self::ELEMENTOR_DASHBOARD] || $page_hook === $this->hooks[self::GUTENBERG_DASHBOARD]) {
286 $library_loader_file = $page_hook === $this->hooks[self::ELEMENTOR_DASHBOARD] ? 'elementor' : 'gutenberg';
287 $menu_items = $page_hook === $this->hooks[self::ELEMENTOR_DASHBOARD] ? ElementorController::GetElementorLibraryMenuItems() : GutenbergController::GetGutenbergLibraryMenuItems();
288
289
290 wp_enqueue_script('superb-addons-select2', SUPERBADDONS_ASSETS_PATH . '/lib/select2.min.js', array('jquery'), SUPERBADDONS_VERSION, true);
291 wp_enqueue_script('superb-addons-library-dashboard', SUPERBADDONS_ASSETS_PATH . '/js/admin/' . $library_loader_file . '.js', array('jquery'), SUPERBADDONS_VERSION, true);
292 wp_localize_script('superb-addons-library-dashboard', 'superblayoutlibrary_g', array(
293 "style_placeholder" => esc_html__('All themes', 'superbaddons'),
294 "category_placeholder" => esc_html__('All categories', 'superbaddons'),
295 "snacks" => array(
296 "list_error" => esc_html__('Something went wrong while attempting to list elements. Please try again or contact support if the problem persists.', 'superbaddons')
297 ),
298 "menu_items" => $menu_items,
299 "rest" => array(
300 "base" => \get_rest_url(),
301 "namespace" => RestController::NAMESPACE,
302 "nonce" => wp_create_nonce("wp_rest"),
303 "routes" => array(
304 "settings" => SettingsController::SETTINGS_ROUTE,
305 )
306 )
307 ));
308
309 wp_enqueue_style(
310 'superb-elementor-editor-layout-library',
311 SUPERBADDONS_ASSETS_PATH . '/css/layout-library-editor.min.css',
312 array(),
313 SUPERBADDONS_VERSION
314 );
315 wp_enqueue_style(
316 'superbaddons-select2',
317 SUPERBADDONS_ASSETS_PATH . '/lib/select2.min.css',
318 array(),
319 SUPERBADDONS_VERSION
320 );
321 wp_enqueue_style(
322 'superbaddons-js-snackbar',
323 SUPERBADDONS_ASSETS_PATH . '/lib/js-snackbar.min.css',
324 array(),
325 SUPERBADDONS_VERSION
326 );
327 }
328 }
329
330 public function TroubleshootingTemplates()
331 {
332 ob_start();
333 include(SUPERBADDONS_PLUGIN_DIR . 'src/admin/templates/troubleshooting-step.php');
334 $template = ob_get_clean();
335 echo '<script type="text/template" id="tmpl-superb-addons-troubleshooting-step">' . $template . '</script>';
336 }
337
338 public function SuperbDashboard()
339 {
340 $this->DashboardPageSetup(DashboardPage::class);
341 }
342
343 public function ElementorDashboard()
344 {
345 $this->DashboardPageSetup(ElementorDashboardPage::class);
346 }
347
348 public function GutenbergDashboard()
349 {
350 $this->DashboardPageSetup(GutenbergDashboardPage::class);
351 }
352
353 public function Support()
354 {
355 $this->DashboardPageSetup(SupportPage::class);
356 }
357
358 public function Settings()
359 {
360 $this->DashboardPageSetup(SettingsPage::class);
361 }
362
363 private function DashboardPageSetup($page_class)
364 {
365 ?>
366 <div class="superbaddons-wrap">
367 <?php new Navigation(); ?>
368 <div class="superbaddons-wrap-inner">
369 <?php new $page_class(); ?>
370 </div>
371 </div>
372 <?php
373 }
374 }
375