PluginProbe ʕ •ᴥ•ʔ
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More / 3.7.0
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More v3.7.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
wizard 5 months ago class-dashboard-controller.php 5 months ago class-newsletter-signup-controller.php 5 months ago class-notice-controller.php 5 months ago class-settings-controller.php 5 months ago class-troubleshooting-controller.php 5 months ago
class-dashboard-controller.php
628 lines
1 <?php
2
3 namespace SuperbAddons\Admin\Controllers;
4
5 defined('ABSPATH') || exit();
6
7 use SuperbAddons\Admin\Controllers\Wizard\WizardController;
8 use SuperbAddons\Admin\Pages\AdditionalCSSPage;
9 use SuperbAddons\Admin\Pages\DashboardPage;
10 use SuperbAddons\Admin\Pages\SettingsPage;
11 use SuperbAddons\Admin\Pages\SupportPage;
12 use SuperbAddons\Admin\Pages\Wizard\PageWizardMainPage;
13 use SuperbAddons\Admin\Utils\AdminLinkSource;
14 use SuperbAddons\Admin\Utils\AdminLinkUtil;
15 use SuperbAddons\Components\Admin\FeedbackModal;
16 use SuperbAddons\Config\Capabilities;
17 use SuperbAddons\Data\Controllers\RestController;
18
19 use SuperbAddons\Components\Admin\Navigation;
20 use SuperbAddons\Data\Controllers\CSSController;
21 use SuperbAddons\Data\Controllers\KeyController;
22 use SuperbAddons\Data\Utils\AllowedTemplateHTMLUtil;
23 use SuperbAddons\Data\Utils\ScriptTranslations;
24 use SuperbAddons\Data\Utils\Wizard\WizardActionParameter;
25 use SuperbAddons\Elementor\Controllers\ElementorController;
26 use SuperbAddons\Gutenberg\Controllers\GutenbergController;
27
28 class DashboardController
29 {
30 const MENU_SLUG = 'superbaddons';
31 const DASHBOARD = 'dashboard';
32 const ADDITIONAL_CSS = 'superbaddons-additional-css';
33 const SETTINGS = 'superbaddons-settings';
34 const SUPPORT = 'superbaddons-support';
35
36 const PAGE_WIZARD = 'superbaddons-page-wizard';
37
38 const THEME_DESIGNER_REDIRECT_SLUG = 'superbaddons-theme-designer';
39 const STYLEBOOK_REDIRECT_SLUG = 'superbaddons-stylebook';
40
41 const PREMIUM_CLASS = 'superbaddons-get-premium';
42
43 private $hooks;
44
45 public function __construct()
46 {
47 new SettingsController();
48 new TroubleshootingController();
49 NewsletterSignupController::Initialize();
50 $this->hooks = array();
51 add_action("admin_menu", array($this, 'SuperbAddonsAdminMenu'));
52 add_action("admin_menu", array($this, 'AdminMenuAdditions'));
53 add_action('admin_init', array($this, 'ConditionalThemePageRedirect'));
54 add_filter('plugin_action_links_' . SUPERBADDONS_BASE, array($this, 'PluginActions'));
55 add_action('admin_enqueue_scripts', array($this, 'AdminMenuEnqueues'), 1000);
56 if (!KeyController::HasValidPremiumKey()) {
57 add_action("admin_head", array($this, 'AdminMenuHighlightScripts'));
58 }
59 $this->HandleNotices();
60 }
61
62
63 public function PluginActions($actions)
64 {
65 $added_actions = array(
66 "<a href='" . esc_url(admin_url("admin.php?page=" . self::MENU_SLUG)) . "'>" . esc_html__('Dashboard', "superb-blocks") . "</a>",
67 "<a href='" . esc_url(admin_url("admin.php?page=" . self::SETTINGS)) . "'>" . esc_html__('Settings', "superb-blocks") . "</a>",
68 "<a href='" . esc_url(admin_url("admin.php?page=" . self::SUPPORT)) . "'>" . esc_html__('Support', "superb-blocks") . "</a>"
69 );
70 $actions = array_merge($added_actions, $actions);
71 if (!KeyController::HasValidPremiumKey()) {
72 $actions[] = "<a href='" . esc_url(AdminLinkUtil::GetLink(AdminLinkSource::WP_PLUGIN_PAGE)) . "' class='" . self::PREMIUM_CLASS . "' target='_blank'>" . esc_html__('Get Premium', "superb-blocks") . "</a>";
73 }
74 return $actions;
75 }
76
77 public function SuperbAddonsAdminMenu()
78 {
79 add_menu_page(__('Superb Addons', "superb-blocks"), __('Superb Addons', "superb-blocks") . $this->GetAdminMenuNotification(), Capabilities::CONTRIBUTOR, self::MENU_SLUG, array($this, 'SuperbDashboard'), SUPERBADDONS_ASSETS_PATH . '/img/icon-superb-dashboard-menu.png', '58.6');
80 $this->hooks[self::DASHBOARD] = add_submenu_page(self::MENU_SLUG, __('Superb Addons - Dashboard', "superb-blocks"), __('Dashboard', "superb-blocks"), Capabilities::CONTRIBUTOR, self::MENU_SLUG);
81 $this->hooks[self::PAGE_WIZARD] = add_submenu_page(self::MENU_SLUG, __('Superb Addons - Theme Designer', "superb-blocks"), __('Theme Designer', "superb-blocks"), Capabilities::ADMIN, self::PAGE_WIZARD, array($this, 'PageWizard'));
82 $this->hooks[self::ADDITIONAL_CSS] = add_submenu_page(self::MENU_SLUG, __('Superb Addons - Custom CSS', "superb-blocks"), __('Custom CSS', "superb-blocks"), Capabilities::ADMIN, self::ADDITIONAL_CSS, array($this, 'AdditionalCSS'));
83 $this->hooks[self::SETTINGS] = add_submenu_page(self::MENU_SLUG, __('Superb Addons - Settings', "superb-blocks"), __('Settings', "superb-blocks") . $this->GetAdminMenuNotification(), Capabilities::ADMIN, self::SETTINGS, array($this, 'Settings'));
84 $this->hooks[self::SUPPORT] = add_submenu_page(self::MENU_SLUG, __('Superb Addons - Get Help', "superb-blocks"), __('Get Help', "superb-blocks"), Capabilities::CONTRIBUTOR, self::SUPPORT, array($this, 'Support'));
85 }
86
87 public function AdminMenuAdditions()
88 {
89 // Block theme related admin menu additions
90 if (!function_exists('wp_is_block_theme') || !wp_is_block_theme()) return;
91
92 $front_page_template = get_block_template(get_stylesheet() . "//front-page");
93 if ($front_page_template && isset($front_page_template->id)) {
94 add_pages_page(
95 __('Edit Front Page', "superb-blocks"),
96 __('Edit Front Page', "superb-blocks"),
97 Capabilities::ADMIN,
98 add_query_arg(
99 array(
100 'postType' => 'wp_template',
101 'postId' => urlencode($front_page_template->id),
102 'canvas' => 'edit',
103 ),
104 admin_url('site-editor.php')
105 )
106 );
107 }
108
109 add_pages_page(
110 __('Add Template Page', "superb-blocks"),
111 __('Add Template Page', "superb-blocks"),
112 Capabilities::ADMIN,
113 WizardController::GetWizardURL(WizardActionParameter::ADD_NEW_PAGES)
114 );
115
116 add_theme_page(
117 __('Theme Designer', "superb-blocks"),
118 __('Theme Designer', "superb-blocks"),
119 Capabilities::ADMIN,
120 self::THEME_DESIGNER_REDIRECT_SLUG,
121 array($this, 'ThemeDesignerRedirectFallbackPage')
122 );
123 add_theme_page(
124 __('Stylebook', "superb-blocks"),
125 __('Stylebook', "superb-blocks"),
126 Capabilities::ADMIN,
127 self::STYLEBOOK_REDIRECT_SLUG,
128 array($this, 'StylesRedirectFallbackPage')
129 );
130 }
131
132 public function ConditionalThemePageRedirect()
133 {
134 // Check if we are heading to a theme page. Ensure the user has the required capability.
135 // Nonce not required as this is a simple redirect.
136 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
137 if (!isset($_GET['page'])) {
138 return;
139 }
140
141 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
142 $page = sanitize_text_field(wp_unslash($_GET['page']));
143 if (!in_array($page, array(self::THEME_DESIGNER_REDIRECT_SLUG, self::STYLEBOOK_REDIRECT_SLUG)) || !current_user_can(Capabilities::ADMIN)) {
144 return;
145 }
146
147 $target_url = false;
148 switch ($page) {
149 case self::THEME_DESIGNER_REDIRECT_SLUG:
150 $target_url = WizardController::GetWizardURL(WizardActionParameter::INTRO);
151 break;
152 case self::STYLEBOOK_REDIRECT_SLUG:
153 $target_url = $this->GetStylebookURL();
154 break;
155 }
156
157 if ($target_url) {
158 wp_safe_redirect($target_url);
159 exit;
160 }
161
162 // If the target URL is not set, redirect to the default plugin page.
163 wp_safe_redirect(admin_url('admin.php?page=' . self::MENU_SLUG));
164 exit;
165 }
166
167 private function GetStylebookURL()
168 {
169 $stylebook_url = add_query_arg(
170 array(
171 'p' => urlencode('/styles'),
172 'preview' => 'stylebook'
173 ),
174 admin_url('site-editor.php')
175 );
176 return $stylebook_url;
177 }
178
179 public function StylesRedirectFallbackPage()
180 {
181 $target_url = $this->GetStylebookURL();
182 $target_page_label = __('Stylebook', "superb-blocks");
183 $this->GenericRedirectFallbackPage($target_page_label, $target_url);
184 }
185
186 public function ThemeDesignerRedirectFallbackPage()
187 {
188 $target_url = WizardController::GetWizardURL(WizardActionParameter::INTRO);
189 $target_page_label = __('Theme Designer', "superb-blocks");
190 $this->GenericRedirectFallbackPage($target_page_label, $target_url);
191 }
192
193 private function GenericRedirectFallbackPage($target_page_label = false, $target_url = false)
194 {
195 if (!$target_page_label) {
196 $target_page_label = __('Superb Addons', "superb-blocks");
197 }
198 if (!$target_url) {
199 $target_url = admin_url('admin.php?page=' . self::MENU_SLUG); // Fallback URL
200 }
201 // This content will be shown if the ConditionalThemeDesignerRedirect redirect fails or is bypassed.
202 echo '<div class="wrap">';
203 echo '</div>';
204
205 echo '<div class="superbaddons-theme-designer-redirect">';
206 echo '<div class="superbaddons-theme-designer-redirect-card">';
207 echo '<div class="superbaddons-theme-designer-redirect-header">';
208 echo '<img src="' . esc_url(SUPERBADDONS_ASSETS_PATH . '/img/icon-superb-dashboard-menu.png') . '" alt="' . esc_attr__('Superb Addons', 'superb-blocks') . '">';
209 echo '<h1>' . esc_html__('Theme Designer', 'superb-blocks') . '</h1>';
210 echo '</div>';
211
212 echo '<p>' . esc_html__('Oops. Looks like you were not correctly redirected. Please click the link below.', 'superb-blocks') . '</p>';
213 echo '<p><a href="' . esc_url($target_url) . '">' . esc_html(sprintf(/* translators: %s: title of a page*/__('Go to %s', 'superb-blocks'), $target_page_label)) . '</a></p>';
214
215 echo '<style>';
216 echo '.superbaddons-theme-designer-redirect { display: flex; justify-content: baseline; align-items: center; }';
217 echo '.superbaddons-theme-designer-redirect-card { display: flex; flex-direction: column; align-items: center; background-color: #fff; padding: 20px; border-radius: 5px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); }';
218 echo '.superbaddons-theme-designer-redirect-header { display: flex; align-items: center; }';
219 echo '.superbaddons-theme-designer-redirect-header img { width: 20px; height: 20px; margin-right: 10px; }';
220 echo '.superbaddons-theme-designer-redirect-header h1 { font-size: 24px; }';
221 echo '.superbaddons-theme-designer-redirect p { font-size: 16px; }';
222 echo '.superbaddons-theme-designer-redirect a { color: #0073aa; text-decoration: none; }';
223 echo '.superbaddons-theme-designer-redirect a:hover { text-decoration: underline; }';
224 echo '</style>';
225 echo '<div class="superbaddons-theme-designer-redirect-footer">';
226 echo '<p>' . esc_html__('If you continue to experience issues, please contact support.', 'superb-blocks') . '</p>';
227 echo '<p><a href="' . esc_url(AdminLinkUtil::GetLink(AdminLinkSource::DEFAULT, array('url' => 'https://superbthemes.com/contact/'))) . '" target="_blank" rel="noopener">' . esc_html__('Contact Support', 'superb-blocks') . '</a></p>';
228
229 echo '</div>';
230 echo '</div>';
231 }
232
233 private function GetAdminMenuNotification()
234 {
235 $HasRegisteredKey = KeyController::HasRegisteredKey();
236 if ($HasRegisteredKey) {
237 $KeyStatus = KeyController::GetKeyStatus();
238 if (!$KeyStatus['active'] || $KeyStatus['expired'] || !$KeyStatus['verified'] || $KeyStatus['exceeded']) {
239 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", "superb-blocks"));
240 }
241 }
242
243 return;
244 }
245
246 public function AdminMenuHighlightScripts()
247 {
248 ?>
249 <style>
250 tbody#the-list .<?php echo esc_html(self::PREMIUM_CLASS); ?> {
251 color: #4312E2;
252 font-weight: 900;
253 }
254 </style>
255 <?php
256 }
257
258 public function HandleNotices()
259 {
260 add_action('wp_loaded', function () {
261 $options = array("notices" => array());
262 if (!KeyController::HasValidPremiumKey()) {
263 $options["notices"][] = array(
264 'unique_id' => 'addons_delayed',
265 'content' => "addons-notice.php",
266 'delay' => '+6 days'
267 );
268 }
269 if (WizardController::GetWizardRecommenderTransient()) {
270 $options["notices"][] = array(
271 'unique_id' => 'wizard_recommender',
272 'content' => "wizard-recommender-notice.php"
273 );
274 } elseif (WizardController::GetWizardWoocommerceTransient()) {
275 $options["notices"][] = array(
276 'unique_id' => 'wizard_woocommerce',
277 'content' => "wizard-woocommerce-notice.php"
278 );
279 }
280 AdminNoticeController::init($options);
281 });
282 }
283
284 public function AdminMenuEnqueues($page_hook)
285 {
286 if ($page_hook === 'plugins.php') {
287 $this->enqueueCommonStyles();
288 $this->enqueueFeedback();
289 return;
290 }
291
292 if (!in_array($page_hook, array_values($this->hooks))) {
293 return;
294 }
295
296 $this->enqueueCommonStyles();
297 wp_enqueue_style(
298 'superb-addons-admin-dashboard',
299 SUPERBADDONS_ASSETS_PATH . '/css/admin-dashboard.min.css',
300 array(),
301 SUPERBADDONS_VERSION
302 );
303
304 switch ($page_hook) {
305 case $this->hooks[self::DASHBOARD]:
306 $this->enqueuePatternLibraryBase();
307 $this->enqueueDashboard();
308 break;
309
310 case $this->hooks[self::SUPPORT]:
311 $this->enqueueSupport();
312 break;
313
314 case $this->hooks[self::SETTINGS]:
315 $this->enqueueSettings();
316 break;
317
318 case $this->hooks[self::ADDITIONAL_CSS]:
319 $this->enqueueAdditionalCSS();
320 break;
321
322 case $this->hooks[self::PAGE_WIZARD]:
323 $this->enqueuePageWizard();
324 break;
325 }
326 }
327
328 private function enqueueCommonStyles()
329 {
330 wp_enqueue_style(
331 'superb-addons-elements',
332 SUPERBADDONS_ASSETS_PATH . '/css/framework.min.css',
333 array(),
334 SUPERBADDONS_VERSION
335 );
336 wp_enqueue_style(
337 'superb-addons-font-manrope',
338 SUPERBADDONS_ASSETS_PATH . '/fonts/manrope/manrope.css',
339 array(),
340 SUPERBADDONS_VERSION
341 );
342 wp_enqueue_style(
343 'superb-addons-admin-modal',
344 SUPERBADDONS_ASSETS_PATH . '/css/admin-modal.min.css',
345 array(),
346 SUPERBADDONS_VERSION
347 );
348 wp_enqueue_style(
349 'superbaddons-js-snackbar',
350 SUPERBADDONS_ASSETS_PATH . '/lib/js-snackbar.min.css',
351 array(),
352 SUPERBADDONS_VERSION
353 );
354 }
355
356 private function enqueueFeedback()
357 {
358 wp_enqueue_script('superb-addons-feedback', SUPERBADDONS_ASSETS_PATH . '/js/admin/deactivate-feedback.js', array('jquery'), SUPERBADDONS_VERSION, true);
359 wp_localize_script('superb-addons-feedback', 'superbaddonssettings_g', array(
360 "plugin" => plugin_basename(SUPERBADDONS_BASE),
361 "rest" => array(
362 "base" => \get_rest_url(),
363 "namespace" => RestController::NAMESPACE,
364 "nonce" => wp_create_nonce("wp_rest"),
365 "routes" => array(
366 "settings" => SettingsController::SETTINGS_ROUTE,
367 )
368 )
369 ));
370 add_action('admin_footer', function () {
371 new FeedbackModal();
372 });
373 }
374
375 private function enqueuePatternLibraryBase()
376 {
377 GutenbergController::AddonsLibrary();
378 wp_enqueue_script('superb-addons-select2', SUPERBADDONS_ASSETS_PATH . '/lib/select2.min.js', array('jquery'), SUPERBADDONS_VERSION, true);
379 wp_enqueue_style(
380 'superb-dashboard-layout-library',
381 SUPERBADDONS_ASSETS_PATH . '/css/layout-library-editor.min.css',
382 array(),
383 SUPERBADDONS_VERSION
384 );
385 wp_enqueue_style(
386 'superbaddons-select2',
387 SUPERBADDONS_ASSETS_PATH . '/lib/select2.min.css',
388 array(),
389 SUPERBADDONS_VERSION
390 );
391 }
392
393 private function enqueueDashboard()
394 {
395 wp_enqueue_script('superb-addons-library-dashboard', SUPERBADDONS_ASSETS_PATH . '/js/admin/dashboard.js', array('jquery', "wp-i18n"), SUPERBADDONS_VERSION, true);
396 ScriptTranslations::Set('superb-addons-library-dashboard');
397 wp_localize_script('superb-addons-library-dashboard', 'superblayoutlibrary_g', array(
398 "style_placeholder" => esc_html__('All themes', "superb-blocks"),
399 "category_placeholder" => esc_html__('All categories', "superb-blocks"),
400 "snacks" => array(
401 "list_error" => esc_html__('Something went wrong while attempting to list elements. Please try again or contact support if the problem persists.', "superb-blocks")
402 ),
403 "gutenberg_menu_items" => GutenbergController::GetGutenbergLibraryMenuItems(),
404 "elementor_menu_items" => ElementorController::GetElementorLibraryMenuItems(),
405 "rest" => array(
406 "base" => \get_rest_url(),
407 "namespace" => RestController::NAMESPACE,
408 "nonce" => wp_create_nonce("wp_rest"),
409 "routes" => array(
410 "settings" => SettingsController::SETTINGS_ROUTE,
411 )
412 )
413 ));
414 }
415
416 private function enqueueSupport()
417 {
418 wp_enqueue_script('superb-addons-troubleshooting', SUPERBADDONS_ASSETS_PATH . '/js/admin/troubleshooting.js', array('jquery', 'wp-i18n'), SUPERBADDONS_VERSION, true);
419 ScriptTranslations::Set('superb-addons-troubleshooting');
420 wp_localize_script('superb-addons-troubleshooting', 'superbaddonstroubleshooting_g', array(
421 "rest" => array(
422 "base" => \get_rest_url(),
423 "namespace" => RestController::NAMESPACE,
424 "nonce" => wp_create_nonce("wp_rest"),
425 "routes" => array(
426 "troubleshooting" => TroubleshootingController::TROUBLESHOOTING_ROUTE,
427 "tutorial" => TroubleshootingController::TUTORIAL_ROUTE,
428 )
429 ),
430 "steps" => array(
431 "wordpressversion" => array(
432 "title" => esc_html__("WordPress Version", "superb-blocks"),
433 "text" => esc_html__("Checking Compatibility", "superb-blocks"),
434 "errorText" => esc_html__("Incompatible. Please update WordPress.", "superb-blocks"),
435 "successText" => esc_html__("Compatible", "superb-blocks"),
436 ),
437 "elementorversion" => array(
438 "active" => is_plugin_active('elementor/elementor.php'),
439 "title" => esc_html__("Elementor Version", "superb-blocks"),
440 "text" => esc_html__("Checking Compatibility", "superb-blocks"),
441 "errorText" => esc_html__("Incompatible. Please update Elementor.", "superb-blocks"),
442 "successText" => esc_html__("Compatible", "superb-blocks"),
443 ),
444 "connection" => array(
445 "title" => esc_html__("Connection Status", "superb-blocks"),
446 "text" => esc_html__("Checking Connection", "superb-blocks"),
447 "errorText" => esc_html__("No Connection", "superb-blocks"),
448 "successText" => esc_html__("Connected", "superb-blocks"),
449 ),
450 "domainshift" => array(
451 "title" => esc_html__("Connection Update", "superb-blocks"),
452 "text" => esc_html__("Trying New Connection", "superb-blocks"),
453 "errorText" => esc_html__("Connection Blocked", "superb-blocks"),
454 "successText" => esc_html__("Connected", "superb-blocks"),
455 ),
456 "service" => array(
457 "title" => esc_html__("Service Status", "superb-blocks"),
458 "text" => esc_html__("Checking Service", "superb-blocks"),
459 "errorText" => esc_html__("Service Unavailable", "superb-blocks"),
460 "successText" => esc_html__("Service Online", "superb-blocks"),
461 ),
462 "keycheck" => array(
463 "title" => esc_html__("License Key Status", "superb-blocks"),
464 "text" => esc_html__("Checking License Key", "superb-blocks"),
465 "errorText" => esc_html__("Invalid License Key", "superb-blocks"),
466 "successText" => esc_html__("Valid License Key", "superb-blocks"),
467 ),
468 "keyverify" => array(
469 "title" => esc_html__("License Key Verification", "superb-blocks"),
470 "text" => esc_html__("Re-verifying License Key", "superb-blocks"),
471 "errorText" => esc_html__("License could not be verified", "superb-blocks"),
472 "successText" => esc_html__("License Key Verified", "superb-blocks"),
473 ),
474 "cacheclear" => array(
475 "title" => esc_html__("Cache Status", "superb-blocks"),
476 "text" => esc_html__("Clearing Cache", "superb-blocks"),
477 "errorText" => esc_html__("Cache could not be cleared", "superb-blocks"),
478 "successText" => esc_html__("Cache Cleared", "superb-blocks"),
479 )
480 )
481 ));
482 add_action("admin_footer", array($this, 'TroubleshootingTemplates'));
483 }
484
485 private function enqueueSettings()
486 {
487 wp_enqueue_script('superb-addons-settings', SUPERBADDONS_ASSETS_PATH . '/js/admin/settings.js', array('jquery'), SUPERBADDONS_VERSION, true);
488 wp_localize_script('superb-addons-settings', 'superbaddonssettings_g', array(
489 "save_message" => esc_html__("Settings saved successfully.", "superb-blocks"),
490 "modal" => array(
491 "cache" => array(
492 "title" => esc_html__("Clear Cache", "superb-blocks"),
493 "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?", "superb-blocks"),
494 "success" => esc_html__("Cache cleared successfully.", "superb-blocks")
495 ),
496 "view_logs" => array(
497 "title" => esc_html__("Error Log", "superb-blocks"),
498 "no_logs" => esc_html__("No errors have been logged.", "superb-blocks"),
499 "icon_unshared" => esc_url(SUPERBADDONS_ASSETS_PATH . "/img/cloud-slash.svg"),
500 "unshared_title" => esc_html__("Error Log Not Shared", "superb-blocks"),
501 "icon_shared" => esc_url(SUPERBADDONS_ASSETS_PATH . "/img/cloud-check.svg"),
502 "shared_title" => esc_html__("Error Log Shared", "superb-blocks"),
503 ),
504 "clear_logs" => array(
505 "title" => esc_html__("Clear Logs", "superb-blocks"),
506 "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?", "superb-blocks"),
507 "success" => esc_html__("Error logs cleared successfully.", "superb-blocks")
508 ),
509 "remove_key" => array(
510 "title" => esc_html__("Remove License Key", "superb-blocks"),
511 "content" => esc_html__("Are you sure you want to remove your license key from this website?", "superb-blocks"),
512 ),
513 "clear_restoration_points" => array(
514 "title" => esc_html__("Clear Restoration Points", "superb-blocks"),
515 "content" => esc_html__("Restoration points can not be recovered after being cleared. Are you sure you want to clear all restoration points?", "superb-blocks"),
516 "success" => esc_html__("Restoration points cleared successfully.", "superb-blocks")
517 )
518 ),
519 "rest" => array(
520 "base" => \get_rest_url(),
521 "namespace" => RestController::NAMESPACE,
522 "nonce" => wp_create_nonce("wp_rest"),
523 "routes" => array(
524 "settings" => SettingsController::SETTINGS_ROUTE,
525 )
526 )
527 ));
528 }
529
530 private function enqueueAdditionalCSS()
531 {
532 wp_enqueue_style(
533 'superbaddons-select2',
534 SUPERBADDONS_ASSETS_PATH . '/lib/select2.min.css',
535 array(),
536 SUPERBADDONS_VERSION
537 );
538
539 do_action('superbaddons/admin/css-blocks/enqueue');
540
541 wp_enqueue_script('superb-addons-select2', SUPERBADDONS_ASSETS_PATH . '/lib/select2.min.js', array('jquery'), SUPERBADDONS_VERSION, true);
542 $code_editor_settings = wp_enqueue_code_editor(array('type' => 'text/css', 'codemirror' => array('lint' => true)));
543 wp_enqueue_script('superb-addons-css-blocks', SUPERBADDONS_ASSETS_PATH . '/js/admin/cssblocks.js', array('jquery', 'wp-i18n'), SUPERBADDONS_VERSION, true);
544 ScriptTranslations::Set('superb-addons-css-blocks');
545 wp_localize_script('superb-addons-css-blocks', 'superbaddonscssblocks_g', array(
546 "codeEditorSettings" => $code_editor_settings,
547 "rest" => array(
548 "base" => \get_rest_url(),
549 "namespace" => RestController::NAMESPACE,
550 "nonce" => wp_create_nonce("wp_rest"),
551 "routes" => array(
552 "css" => CSSController::CSS_ROUTE,
553 ),
554 "error_message" => esc_html__("An error occurred while updating the CSS block. Please try again.", "superb-blocks"),
555 ),
556 ));
557 }
558
559 private function enqueuePageWizard()
560 {
561 wp_enqueue_style(
562 'superb-addons-page-wizard',
563 SUPERBADDONS_ASSETS_PATH . '/css/page-wizard.min.css',
564 array(),
565 SUPERBADDONS_VERSION
566 );
567 wp_enqueue_script('superb-addons-page-wizard', SUPERBADDONS_ASSETS_PATH . '/js/admin/page-wizard.js', array('jquery', 'wp-i18n'), SUPERBADDONS_VERSION, true);
568 ScriptTranslations::Set('superb-addons-page-wizard');
569 wp_localize_script('superb-addons-page-wizard', 'superbaddonswizard_g', array(
570 "rest" => array(
571 "base" => \get_rest_url(),
572 "namespace" => RestController::NAMESPACE,
573 "nonce" => wp_create_nonce("wp_rest"),
574 "routes" => array(
575 "wizard" => WizardController::WIZARD_ROUTE,
576 )
577 )
578 ));
579 }
580
581 public function TroubleshootingTemplates()
582 {
583 AllowedTemplateHTMLUtil::enable_safe_styles();
584 ob_start();
585 include(SUPERBADDONS_PLUGIN_DIR . 'src/admin/templates/troubleshooting-step.php');
586 $template = ob_get_clean();
587 echo '<script type="text/template" id="tmpl-superb-addons-troubleshooting-step">' . wp_kses($template, "post") . '</script>';
588 AllowedTemplateHTMLUtil::disable_safe_styles();
589 }
590
591 public function SuperbDashboard()
592 {
593 $this->DashboardPageSetup(DashboardPage::class);
594 }
595
596 public function AdditionalCSS()
597 {
598 $this->DashboardPageSetup(AdditionalCSSPage::class);
599 }
600
601 public function Support()
602 {
603 $this->DashboardPageSetup(SupportPage::class);
604 }
605
606 public function Settings()
607 {
608 $this->DashboardPageSetup(SettingsPage::class);
609 }
610
611 public function PageWizard()
612 {
613 $this->DashboardPageSetup(PageWizardMainPage::class, true, __("Theme Designer", "superb-blocks"));
614 }
615
616 private function DashboardPageSetup($page_class, $hide_navigation_items = false, $subtitle = false)
617 {
618 ?>
619 <div class="superbaddons-wrap">
620 <?php new Navigation($hide_navigation_items, $subtitle); ?>
621 <div class="superbaddons-wrap-inner">
622 <?php new $page_class(); ?>
623 </div>
624 </div>
625 <?php
626 }
627 }
628