PluginProbe ʕ •ᴥ•ʔ
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More / 3.0
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More v3.0
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
380 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_elementor_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 if (!KeyController::HasPremiumKey()) {
71 add_submenu_page(self::MENU_SLUG, 'Get Premium', '<span class="' . self::PREMIUM_CLASS . '">' . __('Get Premium', 'superbaddons') . '</span>', Capabilities::CONTRIBUTOR, 'https://superbthemes.com/superb-addons/');
72 }
73 }
74
75 private function GetAdminMenuNotification()
76 {
77 $HasRegisteredKey = KeyController::HasRegisteredKey();
78 if ($HasRegisteredKey) {
79 $KeyStatus = KeyController::GetKeyStatus();
80 if (!$KeyStatus['active'] || $KeyStatus['expired'] || !$KeyStatus['verified']) {
81 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"));
82 }
83 }
84
85 return;
86 }
87
88 public function AdminMenuHighlightScripts()
89 {
90 ?>
91 <style>
92 ul#adminmenu .<?= self::PREMIUM_CLASS ?> {
93 color: #fff;
94 background-color: #4312E2;
95 background-image: linear-gradient(180deg, #9524FF 0%, #4312E2 100%);
96 border-radius: 6px;
97 padding: 5px 15px;
98 font-weight: 500;
99 display: inline-block;
100 }
101
102 tbody#the-list .<?= self::PREMIUM_CLASS ?> {
103 color: #4312E2;
104 font-weight: 900;
105 }
106 </style>
107 <script type="text/javascript">
108 jQuery(document).ready(function($) {
109 $('ul#adminmenu .<?= self::PREMIUM_CLASS ?>').parent("a").attr('target', '_blank');
110 });
111 </script>
112 <?php
113 }
114
115 public function AdminMenuEnqueues($page_hook)
116 {
117 if ($page_hook === 'plugins.php') {
118 wp_enqueue_style(
119 'superb-addons-elements',
120 SUPERBADDONS_ASSETS_PATH . '/css/framework.min.css',
121 array(),
122 SUPERBADDONS_VERSION
123 );
124 wp_enqueue_style(
125 'superb-addons-font-manrope',
126 SUPERBADDONS_ASSETS_PATH . '/fonts/manrope/manrope.css',
127 array(),
128 SUPERBADDONS_VERSION
129 );
130 wp_enqueue_style(
131 'superb-addons-admin-modal',
132 SUPERBADDONS_ASSETS_PATH . '/css/admin-modal.min.css',
133 array(),
134 SUPERBADDONS_VERSION
135 );
136
137 wp_enqueue_script('superb-addons-feedback', SUPERBADDONS_ASSETS_PATH . '/js/admin/deactivate-feedback.js', array('jquery'), SUPERBADDONS_VERSION, true);
138 wp_localize_script('superb-addons-feedback', 'superbaddonssettings_g', array(
139 "plugin" => plugin_basename(SUPERBADDONS_BASE),
140 "rest" => array(
141 "base" => \get_rest_url(),
142 "namespace" => RestController::NAMESPACE,
143 "nonce" => wp_create_nonce("wp_rest"),
144 "routes" => array(
145 "settings" => SettingsController::SETTINGS_ROUTE,
146 )
147 )
148 ));
149 add_action('admin_footer', function () {
150 new FeedbackModal();
151 });
152 return;
153 }
154
155 if (!in_array($page_hook, array_values($this->hooks))) {
156 return;
157 }
158 wp_enqueue_style(
159 'superb-addons-admin-dashboard',
160 SUPERBADDONS_ASSETS_PATH . '/css/admin-dashboard.min.css',
161 array(),
162 SUPERBADDONS_VERSION
163 );
164 wp_enqueue_style(
165 'superb-addons-elements',
166 SUPERBADDONS_ASSETS_PATH . '/css/framework.min.css',
167 array(),
168 SUPERBADDONS_VERSION
169 );
170 wp_enqueue_style(
171 'superb-addons-font-manrope',
172 SUPERBADDONS_ASSETS_PATH . '/fonts/manrope/manrope.css',
173 array(),
174 SUPERBADDONS_VERSION
175 );
176
177 if ($page_hook === $this->hooks[self::SUPPORT]) {
178 wp_enqueue_script('superb-addons-troubleshooting', SUPERBADDONS_ASSETS_PATH . '/js/admin/troubleshooting.js', array('jquery'), SUPERBADDONS_VERSION, true);
179 wp_localize_script('superb-addons-troubleshooting', 'superbaddonstroubleshooting_g', array(
180 "rest" => array(
181 "base" => \get_rest_url(),
182 "namespace" => RestController::NAMESPACE,
183 "nonce" => wp_create_nonce("wp_rest"),
184 "routes" => array(
185 "troubleshooting" => TroubleshootingController::TROUBLESHOOTING_ROUTE,
186 )
187 ),
188 "steps" => array(
189 "wordpressversion" => array(
190 "title" => esc_html__("WordPress Version", "superbaddons"),
191 "text" => esc_html__("Checking Compatibility", "superbaddons"),
192 "errorText" => esc_html__("Incompatible. Please update WordPress.", "superbaddons"),
193 "successText" => esc_html__("Compatible", "superbaddons"),
194 ),
195 "elementorversion" => array(
196 "title" => esc_html__("Elementor Version", "superbaddons"),
197 "text" => esc_html__("Checking Compatibility", "superbaddons"),
198 "errorText" => esc_html__("Incompatible. Please install or update Elementor.", "superbaddons"),
199 "successText" => esc_html__("Compatible", "superbaddons"),
200 ),
201 "connection" => array(
202 "title" => esc_html__("Connection Status", "superbaddons"),
203 "text" => esc_html__("Checking Connection", "superbaddons"),
204 "errorText" => esc_html__("No Connection", "superbaddons"),
205 "successText" => esc_html__("Connected", "superbaddons"),
206 ),
207 "domainshift" => array(
208 "title" => esc_html__("Connection Update", "superbaddons"),
209 "text" => esc_html__("Trying New Connection", "superbaddons"),
210 "errorText" => esc_html__("Connection Blocked", "superbaddons"),
211 "successText" => esc_html__("Connected", "superbaddons"),
212 ),
213 "service" => array(
214 "title" => esc_html__("Service Status", "superbaddons"),
215 "text" => esc_html__("Checking Service", "superbaddons"),
216 "errorText" => esc_html__("Service Unavailable", "superbaddons"),
217 "successText" => esc_html__("Service Online", "superbaddons"),
218 ),
219 "keycheck" => array(
220 "title" => esc_html__("License Key Status", "superbaddons"),
221 "text" => esc_html__("Checking License Key", "superbaddons"),
222 "errorText" => esc_html__("Invalid License Key", "superbaddons"),
223 "successText" => esc_html__("Valid License Key", "superbaddons"),
224 ),
225 "keyverify" => array(
226 "title" => esc_html__("License Key Verification", "superbaddons"),
227 "text" => esc_html__("Re-verifying License Key", "superbaddons"),
228 "errorText" => esc_html__("License could not be verified", "superbaddons"),
229 "successText" => esc_html__("License Key Verified", "superbaddons"),
230 ),
231 "cacheclear" => array(
232 "title" => esc_html__("Cache Status", "superbaddons"),
233 "text" => esc_html__("Clearing Cache", "superbaddons"),
234 "errorText" => esc_html__("Cache could not be cleared", "superbaddons"),
235 "successText" => esc_html__("Cache Cleared", "superbaddons"),
236 )
237 )
238 ));
239 add_action("admin_footer", array($this, 'TroubleshootingTemplates'));
240 } elseif ($page_hook === $this->hooks[self::SETTINGS]) {
241 wp_enqueue_style(
242 'superb-addons-admin-modal',
243 SUPERBADDONS_ASSETS_PATH . '/css/admin-modal.min.css',
244 array(),
245 SUPERBADDONS_VERSION
246 );
247
248 wp_enqueue_script('superb-addons-settings', SUPERBADDONS_ASSETS_PATH . '/js/admin/settings.js', array('jquery'), SUPERBADDONS_VERSION, true);
249 wp_localize_script('superb-addons-settings', 'superbaddonssettings_g', array(
250 "save_message" => esc_html__("Settings saved successfully.", "superbaddons"),
251 "modal" => array(
252 "cache" => array(
253 "title" => esc_html__("Clear Cache", "superbaddons"),
254 "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"),
255 "success" => esc_html__("Cache cleared successfully.", "superbaddons")
256 ),
257 "view_logs" => array(
258 "title" => esc_html__("Error Log", "superbaddons"),
259 "no_logs" => esc_html__("No errors have been logged.", "superbaddons"),
260 "icon_unshared" => esc_url(SUPERBADDONS_ASSETS_PATH . "/img/cloud-slash.svg"),
261 "unshared_title" => esc_html__("Error Log Not Shared", "superbaddons"),
262 "icon_shared" => esc_url(SUPERBADDONS_ASSETS_PATH . "/img/cloud-check.svg"),
263 "shared_title" => esc_html__("Error Log Shared", "superbaddons"),
264 ),
265 "clear_logs" => array(
266 "title" => esc_html__("Clear Logs", "superbaddons"),
267 "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"),
268 "success" => esc_html__("Error logs cleared successfully.", "superbaddons")
269 ),
270 "remove_key" => array(
271 "title" => esc_html__("Remove License Key", "superbaddons"),
272 "content" => esc_html__("Are you sure you want to remove your license key from this website?", "superbaddons"),
273 )
274 ),
275 "rest" => array(
276 "base" => \get_rest_url(),
277 "namespace" => RestController::NAMESPACE,
278 "nonce" => wp_create_nonce("wp_rest"),
279 "routes" => array(
280 "settings" => SettingsController::SETTINGS_ROUTE,
281 )
282 )
283 ));
284 wp_enqueue_style(
285 'superbaddons-js-snackbar',
286 SUPERBADDONS_ASSETS_PATH . '/lib/js-snackbar.min.css',
287 array(),
288 SUPERBADDONS_VERSION
289 );
290 } elseif ($page_hook === $this->hooks[self::ELEMENTOR_DASHBOARD] || $page_hook === $this->hooks[self::GUTENBERG_DASHBOARD]) {
291 $library_loader_file = $page_hook === $this->hooks[self::ELEMENTOR_DASHBOARD] ? 'elementor' : 'gutenberg';
292 $menu_items = $page_hook === $this->hooks[self::ELEMENTOR_DASHBOARD] ? ElementorController::GetElementorLibraryMenuItems() : GutenbergController::GetGutenbergLibraryMenuItems();
293
294
295 wp_enqueue_script('superb-addons-select2', SUPERBADDONS_ASSETS_PATH . '/lib/select2.min.js', array('jquery'), SUPERBADDONS_VERSION, true);
296 wp_enqueue_script('superb-addons-library-dashboard', SUPERBADDONS_ASSETS_PATH . '/js/admin/' . $library_loader_file . '.js', array('jquery'), SUPERBADDONS_VERSION, true);
297 wp_localize_script('superb-addons-library-dashboard', 'superblayoutlibrary_g', array(
298 "style_placeholder" => esc_html__('All themes', 'superbaddons'),
299 "category_placeholder" => esc_html__('All categories', 'superbaddons'),
300 "snacks" => array(
301 "list_error" => esc_html__('Something went wrong while attempting to list elements. Please try again or contact support if the problem persists.', 'superbaddons')
302 ),
303 "menu_items" => $menu_items,
304 "rest" => array(
305 "base" => \get_rest_url(),
306 "namespace" => RestController::NAMESPACE,
307 "nonce" => wp_create_nonce("wp_rest"),
308 "routes" => array(
309 "settings" => SettingsController::SETTINGS_ROUTE,
310 )
311 )
312 ));
313
314 wp_enqueue_style(
315 'superb-elementor-editor-layout-library',
316 SUPERBADDONS_ASSETS_PATH . '/css/layout-library-editor.min.css',
317 array(),
318 SUPERBADDONS_VERSION
319 );
320 wp_enqueue_style(
321 'superbaddons-select2',
322 SUPERBADDONS_ASSETS_PATH . '/lib/select2.min.css',
323 array(),
324 SUPERBADDONS_VERSION
325 );
326 wp_enqueue_style(
327 'superbaddons-js-snackbar',
328 SUPERBADDONS_ASSETS_PATH . '/lib/js-snackbar.min.css',
329 array(),
330 SUPERBADDONS_VERSION
331 );
332 }
333 }
334
335 public function TroubleshootingTemplates()
336 {
337 ob_start();
338 include(SUPERBADDONS_PLUGIN_DIR . 'src/admin/templates/troubleshooting-step.php');
339 $template = ob_get_clean();
340 echo '<script type="text/template" id="tmpl-superb-addons-troubleshooting-step">' . $template . '</script>';
341 }
342
343 public function SuperbDashboard()
344 {
345 $this->DashboardPageSetup(DashboardPage::class);
346 }
347
348 public function ElementorDashboard()
349 {
350 $this->DashboardPageSetup(ElementorDashboardPage::class);
351 }
352
353 public function GutenbergDashboard()
354 {
355 $this->DashboardPageSetup(GutenbergDashboardPage::class);
356 }
357
358 public function Support()
359 {
360 $this->DashboardPageSetup(SupportPage::class);
361 }
362
363 public function Settings()
364 {
365 $this->DashboardPageSetup(SettingsPage::class);
366 }
367
368 private function DashboardPageSetup($page_class)
369 {
370 ?>
371 <div class="superbaddons-wrap">
372 <?php new Navigation(); ?>
373 <div class="superbaddons-wrap-inner">
374 <?php new $page_class(); ?>
375 </div>
376 </div>
377 <?php
378 }
379 }
380