PluginProbe ʕ •ᴥ•ʔ
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More / 4.0.7
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More v4.0.7
4.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
wizard 4 days ago class-dashboard-controller.php 4 days ago class-license-resolve-controller.php 4 days ago class-newsletter-signup-controller.php 4 days ago class-notice-controller.php 4 days ago class-plugin-reset-controller.php 4 days ago class-review-controller.php 4 days ago class-rewrite-check-controller.php 4 days ago class-settings-controller.php 4 days ago class-troubleshooting-controller.php 4 days ago
class-dashboard-controller.php
1024 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\FormsPage;
11 use SuperbAddons\Admin\Pages\SettingsPage;
12 use SuperbAddons\Admin\Pages\SupportPage;
13 use SuperbAddons\Admin\Pages\Wizard\PageWizardMainPage;
14 use SuperbAddons\Admin\Utils\AdminLinkSource;
15 use SuperbAddons\Admin\Utils\AdminLinkUtil;
16 use SuperbAddons\Components\Admin\FeedbackModal;
17 use SuperbAddons\Config\Capabilities;
18 use SuperbAddons\Data\Controllers\RestController;
19
20 use SuperbAddons\Components\Admin\Navigation;
21 use SuperbAddons\Data\Controllers\CacheController;
22 use SuperbAddons\Data\Controllers\CSSController;
23 use SuperbAddons\Data\Controllers\KeyController;
24 use SuperbAddons\Data\Controllers\LinkController;
25 use SuperbAddons\Data\Utils\CacheTypes;
26 use SuperbAddons\Data\Utils\GutenbergCache;
27 use SuperbAddons\Data\Utils\AllowedTemplateHTMLUtil;
28 use SuperbAddons\Data\Utils\ScriptTranslations;
29 use SuperbAddons\Data\Utils\Wizard\WizardActionParameter;
30 use SuperbAddons\Elementor\Controllers\ElementorController;
31 use SuperbAddons\Gutenberg\Controllers\GutenbergController;
32 use SuperbAddons\Gutenberg\Controllers\GutenbergEnhancementsController;
33 use SuperbAddons\Library\Controllers\FavoritesController;
34 use SuperbAddons\Library\Controllers\LibraryRequestController;
35 use SuperbAddons\Gutenberg\Form\FormPermissions;
36 use SuperbAddons\Tours\Controllers\TourController;
37
38 class DashboardController
39 {
40 const MENU_SLUG = 'superbaddons';
41 const DASHBOARD = 'dashboard';
42 const ADDITIONAL_CSS = 'superbaddons-additional-css';
43 const SETTINGS = 'superbaddons-settings';
44 const SUPPORT = 'superbaddons-support';
45 const FORMS = 'superbaddons-forms';
46
47 const PAGE_WIZARD = 'superbaddons-page-wizard';
48
49 const THEME_DESIGNER_REDIRECT_SLUG = 'superbaddons-theme-designer';
50 const STYLEBOOK_REDIRECT_SLUG = 'superbaddons-stylebook';
51
52 const PREMIUM_CLASS = 'superbaddons-get-premium';
53
54 const NOTICE_ID_UPSELL = 'addons_delayed';
55 const NOTICE_ID_REVIEW = 'review_request';
56
57 private $hooks;
58
59 public function __construct()
60 {
61 new SettingsController();
62 new TroubleshootingController();
63 NewsletterSignupController::Initialize();
64 $this->hooks = array();
65 add_action("admin_menu", array($this, 'SuperbAddonsAdminMenu'));
66 add_action("admin_menu", array($this, 'AdminMenuAdditions'));
67 add_action('admin_init', array($this, 'MaybeActivationRedirect'));
68 add_action('admin_init', array($this, 'ConditionalThemePageRedirect'));
69 add_filter('plugin_action_links_' . SUPERBADDONS_BASE, array($this, 'PluginActions'));
70 add_action('admin_enqueue_scripts', array($this, 'AdminMenuEnqueues'), 1000);
71 if (!KeyController::HasValidPremiumKey()) {
72 add_action("admin_head", array($this, 'AdminMenuHighlightScripts'));
73 }
74 $this->HandleNotices();
75 }
76
77
78 public function PluginActions($actions)
79 {
80 $added_actions = array(
81 "<a href='" . esc_url(admin_url("admin.php?page=" . self::MENU_SLUG)) . "'>" . esc_html__('Dashboard', "superb-blocks") . "</a>",
82 "<a href='" . esc_url(admin_url("admin.php?page=" . self::SETTINGS)) . "'>" . esc_html__('Settings', "superb-blocks") . "</a>",
83 "<a href='" . esc_url(admin_url("admin.php?page=" . self::SUPPORT)) . "'>" . esc_html__('Get Help', "superb-blocks") . "</a>"
84 );
85 $actions = array_merge($added_actions, $actions);
86 if (!KeyController::HasValidPremiumKey()) {
87 $actions[] = "<a href='" . esc_url(AdminLinkUtil::GetLink(AdminLinkSource::WP_PLUGIN_PAGE)) . "' class='" . self::PREMIUM_CLASS . "' target='_blank'>" . esc_html__('Get Premium', "superb-blocks") . "</a>";
88 }
89 return $actions;
90 }
91
92 public function SuperbAddonsAdminMenu()
93 {
94 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');
95 $this->hooks[self::DASHBOARD] = add_submenu_page(self::MENU_SLUG, __('Superb Addons - Dashboard', "superb-blocks"), __('Dashboard', "superb-blocks"), Capabilities::CONTRIBUTOR, self::MENU_SLUG);
96 $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'));
97 // Forms menu: visible to admins and roles with 'view' form permission
98 $forms_capability = FormPermissions::Can('view') ? 'read' : Capabilities::ADMIN;
99 $this->hooks[self::FORMS] = add_submenu_page(self::MENU_SLUG, __('Superb Addons - Forms', "superb-blocks"), __('Forms', "superb-blocks"), $forms_capability, self::FORMS, array($this, 'Forms'));
100 $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'));
101 $this->hooks[self::SETTINGS] = add_submenu_page(self::MENU_SLUG, __('Superb Addons - Settings', "superb-blocks"), __('Settings', "superb-blocks"), Capabilities::ADMIN, self::SETTINGS, array($this, 'Settings'));
102 $this->hooks[self::SUPPORT] = add_submenu_page(self::MENU_SLUG, __('Superb Addons - Get Help', "superb-blocks"), __('Get Help', "superb-blocks") . $this->GetAdminMenuNotification(), Capabilities::CONTRIBUTOR, self::SUPPORT, array($this, 'Support'));
103 }
104
105 public function AdminMenuAdditions()
106 {
107 // Block theme related admin menu additions
108 if (!function_exists('wp_is_block_theme') || !wp_is_block_theme()) return;
109
110 // Gated by the Admin Shortcuts module toggle (Settings > Modules).
111 if (!self::IsDashboardShortcutsEnabled()) return;
112
113 $front_page_template = get_block_template(get_stylesheet() . "//front-page");
114 if ($front_page_template && isset($front_page_template->id)) {
115 add_pages_page(
116 __('Edit Front Page', "superb-blocks"),
117 __('Edit Front Page', "superb-blocks"),
118 Capabilities::ADMIN,
119 add_query_arg(
120 array(
121 'postType' => 'wp_template',
122 'postId' => urlencode($front_page_template->id),
123 'canvas' => 'edit',
124 ),
125 admin_url('site-editor.php')
126 )
127 );
128 }
129
130 add_pages_page(
131 __('Add Template Page', "superb-blocks"),
132 __('Add Template Page', "superb-blocks"),
133 Capabilities::ADMIN,
134 WizardController::GetWizardURL(WizardActionParameter::ADD_NEW_PAGES)
135 );
136
137 add_theme_page(
138 __('Theme Designer', "superb-blocks"),
139 __('Theme Designer', "superb-blocks"),
140 Capabilities::ADMIN,
141 self::THEME_DESIGNER_REDIRECT_SLUG,
142 array($this, 'ThemeDesignerRedirectFallbackPage')
143 );
144 add_theme_page(
145 __('Style Book', "superb-blocks"),
146 __('Style Book', "superb-blocks"),
147 Capabilities::ADMIN,
148 self::STYLEBOOK_REDIRECT_SLUG,
149 array($this, 'StylesRedirectFallbackPage')
150 );
151 }
152
153 private static function IsDashboardShortcutsEnabled()
154 {
155 $options = GutenbergEnhancementsController::GetGlobalEnhancementsOptions();
156 return !empty($options[GutenbergEnhancementsController::DASHBOARD_SHORTCUTS_KEY]);
157 }
158
159 public function MaybeActivationRedirect()
160 {
161 if (!get_transient('superbaddons_activation_redirect')) {
162 return;
163 }
164
165 delete_transient('superbaddons_activation_redirect');
166
167 // Nonce not required: only checking presence of WP core's activate-multi flag to bail out of our own redirect, no data processed.
168 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
169 if (is_network_admin() || isset($_GET['activate-multi'])) {
170 return;
171 }
172
173 wp_safe_redirect(admin_url('admin.php?page=' . self::MENU_SLUG));
174 exit;
175 }
176
177 public function ConditionalThemePageRedirect()
178 {
179 // Check if we are heading to a theme page. Ensure the user has the required capability.
180 // Nonce not required as this is a simple redirect.
181 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
182 if (!isset($_GET['page'])) {
183 return;
184 }
185
186 // Gated by the Admin Shortcuts module toggle (Settings > Modules).
187 if (!self::IsDashboardShortcutsEnabled()) {
188 return;
189 }
190
191 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
192 $page = sanitize_text_field(wp_unslash($_GET['page']));
193 if (!in_array($page, array(self::THEME_DESIGNER_REDIRECT_SLUG, self::STYLEBOOK_REDIRECT_SLUG)) || !current_user_can(Capabilities::ADMIN)) {
194 return;
195 }
196
197 $target_url = false;
198 switch ($page) {
199 case self::THEME_DESIGNER_REDIRECT_SLUG:
200 $target_url = WizardController::GetWizardURL(WizardActionParameter::INTRO);
201 break;
202 case self::STYLEBOOK_REDIRECT_SLUG:
203 $target_url = $this->GetStylebookURL();
204 break;
205 }
206
207 if ($target_url) {
208 wp_safe_redirect($target_url);
209 exit;
210 }
211
212 // If the target URL is not set, redirect to the default plugin page.
213 wp_safe_redirect(admin_url('admin.php?page=' . self::MENU_SLUG));
214 exit;
215 }
216
217 private function GetStylebookURL()
218 {
219 $stylebook_url = add_query_arg(
220 array(
221 'p' => urlencode('/styles'),
222 'preview' => 'stylebook'
223 ),
224 admin_url('site-editor.php')
225 );
226 return $stylebook_url;
227 }
228
229 public function StylesRedirectFallbackPage()
230 {
231 $target_url = $this->GetStylebookURL();
232 $target_page_label = __('Stylebook', "superb-blocks");
233 $this->GenericRedirectFallbackPage($target_page_label, $target_url);
234 }
235
236 public function ThemeDesignerRedirectFallbackPage()
237 {
238 $target_url = WizardController::GetWizardURL(WizardActionParameter::INTRO);
239 $target_page_label = __('Theme Designer', "superb-blocks");
240 $this->GenericRedirectFallbackPage($target_page_label, $target_url);
241 }
242
243 private function GenericRedirectFallbackPage($target_page_label = false, $target_url = false)
244 {
245 if (!$target_page_label) {
246 $target_page_label = __('Superb Addons', "superb-blocks");
247 }
248 if (!$target_url) {
249 $target_url = admin_url('admin.php?page=' . self::MENU_SLUG); // Fallback URL
250 }
251 // This content will be shown if the ConditionalThemeDesignerRedirect redirect fails or is bypassed.
252 echo '<div class="wrap">';
253 echo '</div>';
254
255 echo '<div class="superbaddons-theme-designer-redirect">';
256 echo '<div class="superbaddons-theme-designer-redirect-card">';
257 echo '<div class="superbaddons-theme-designer-redirect-header">';
258 echo '<img src="' . esc_url(SUPERBADDONS_ASSETS_PATH . '/img/icon-superb-dashboard-menu.png') . '" alt="' . esc_attr__('Superb Addons', 'superb-blocks') . '">';
259 echo '<h1>' . esc_html__('Theme Designer', 'superb-blocks') . '</h1>';
260 echo '</div>';
261
262 echo '<p>' . esc_html__('Oops. Looks like you were not correctly redirected. Please click the link below.', 'superb-blocks') . '</p>';
263 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>';
264
265 echo '<style>';
266 echo '.superbaddons-theme-designer-redirect { display: flex; justify-content: baseline; align-items: center; }';
267 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); }';
268 echo '.superbaddons-theme-designer-redirect-header { display: flex; align-items: center; }';
269 echo '.superbaddons-theme-designer-redirect-header img { width: 20px; height: 20px; margin-right: 10px; }';
270 echo '.superbaddons-theme-designer-redirect-header h1 { font-size: 24px; }';
271 echo '.superbaddons-theme-designer-redirect p { font-size: 16px; }';
272 echo '.superbaddons-theme-designer-redirect a { color: #0073aa; text-decoration: none; }';
273 echo '.superbaddons-theme-designer-redirect a:hover { text-decoration: underline; }';
274 echo '</style>';
275 echo '<div class="superbaddons-theme-designer-redirect-footer">';
276 echo '<p>' . esc_html__('If you continue to experience issues, please contact support.', 'superb-blocks') . '</p>';
277 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>';
278
279 echo '</div>';
280 echo '</div>';
281 }
282
283 private function GetAdminMenuNotification()
284 {
285 $HasRegisteredKey = KeyController::HasRegisteredKey();
286 if ($HasRegisteredKey) {
287 $KeyStatus = KeyController::GetKeyStatus();
288 if (!$KeyStatus['active'] || $KeyStatus['expired'] || !$KeyStatus['verified'] || $KeyStatus['exceeded']) {
289 return sprintf('<span class="update-plugins count-1"><span class="plugin-count" aria-hidden="true">!</span><span class="screen-reader-text">%s</span></span>', esc_html__("Issue Detected", "superb-blocks"));
290 }
291 }
292
293 if (RewriteCheckController::HasDetectedIssue()) {
294 return sprintf('<span class="update-plugins count-1"><span class="plugin-count" aria-hidden="true">!</span><span class="screen-reader-text">%s</span></span>', esc_html__("Issue Detected", "superb-blocks"));
295 }
296
297 return;
298 }
299
300 public function AdminMenuHighlightScripts()
301 {
302 ?>
303 <style>
304 tbody#the-list .<?php echo esc_html(self::PREMIUM_CLASS); ?> {
305 color: #4312E2;
306 font-weight: 900;
307 }
308 </style>
309 <?php
310 }
311
312 public function HandleNotices()
313 {
314 add_action('wp_loaded', function () {
315 $options = array("notices" => array());
316 if (!KeyController::HasValidPremiumKey()) {
317 $options["notices"][] = array(
318 'unique_id' => self::NOTICE_ID_UPSELL,
319 'content' => LinkController::GetNoticeContentFile(),
320 'delay' => '+2 days'
321 );
322 }
323 if (ReviewController::ShouldShowReviewNotice()) {
324 $options["notices"][] = array(
325 'unique_id' => self::NOTICE_ID_REVIEW,
326 'content' => 'review-notice.php'
327 );
328 }
329 if (WizardController::GetWizardRecommenderTransient()) {
330 $options["notices"][] = array(
331 'unique_id' => 'wizard_recommender',
332 'content' => "wizard-recommender-notice.php"
333 );
334 } elseif (WizardController::GetWizardWoocommerceTransient()) {
335 $options["notices"][] = array(
336 'unique_id' => 'wizard_woocommerce',
337 'content' => "wizard-woocommerce-notice.php"
338 );
339 }
340 AdminNoticeController::init($options);
341 });
342 }
343
344 public function AdminMenuEnqueues($page_hook)
345 {
346 if ($page_hook === 'plugins.php') {
347 $this->enqueueCommonStyles();
348 $this->enqueueFeedback();
349 return;
350 }
351
352 if (!in_array($page_hook, array_values($this->hooks))) {
353 return;
354 }
355
356 $this->enqueueCommonStyles();
357 $this->enqueueUpsellModal();
358 wp_enqueue_style(
359 'superb-addons-admin-dashboard',
360 SUPERBADDONS_ASSETS_PATH . '/css/admin-dashboard.min.css',
361 array(),
362 SUPERBADDONS_VERSION
363 );
364
365 switch ($page_hook) {
366 case $this->hooks[self::DASHBOARD]:
367 $this->enqueuePatternLibraryBase();
368 $this->enqueueDashboard();
369 break;
370
371 case $this->hooks[self::SUPPORT]:
372 $this->enqueueSupport();
373 break;
374
375 case $this->hooks[self::SETTINGS]:
376 $this->enqueueSettings();
377 break;
378
379 case $this->hooks[self::ADDITIONAL_CSS]:
380 $this->enqueueAdditionalCSS();
381 break;
382
383 case $this->hooks[self::PAGE_WIZARD]:
384 $this->enqueuePageWizard();
385 break;
386
387 case $this->hooks[self::FORMS]:
388 $this->enqueueForms();
389 break;
390 }
391 }
392
393 private function enqueueCommonStyles()
394 {
395 wp_enqueue_style(
396 'superb-addons-elements',
397 SUPERBADDONS_ASSETS_PATH . '/css/framework.min.css',
398 array(),
399 SUPERBADDONS_VERSION
400 );
401 wp_enqueue_style(
402 'superb-addons-font-manrope',
403 SUPERBADDONS_ASSETS_PATH . '/fonts/manrope/manrope.css',
404 array(),
405 SUPERBADDONS_VERSION
406 );
407 wp_enqueue_style(
408 'superb-addons-admin-modal',
409 SUPERBADDONS_ASSETS_PATH . '/css/admin-modal.min.css',
410 array(),
411 SUPERBADDONS_VERSION
412 );
413 wp_enqueue_style(
414 'superbaddons-toast',
415 SUPERBADDONS_ASSETS_PATH . '/css/toast.min.css',
416 array(),
417 SUPERBADDONS_VERSION
418 );
419 }
420
421 // Vanilla modal bundle.
422 private function enqueueUpsellModal()
423 {
424 wp_enqueue_script(
425 'superb-addons-upsell-modal-admin',
426 SUPERBADDONS_ASSETS_PATH . '/js/admin/upsell-modal.js',
427 array('wp-i18n', 'wp-url', 'wp-escape-html'),
428 SUPERBADDONS_VERSION,
429 true
430 );
431 ScriptTranslations::Set('superb-addons-upsell-modal-admin');
432 // Link variant for admin pages: read at module load by
433 // premium-link-source.js and by the vanilla modal / click delegation.
434 LinkController::Localize('superb-addons-upsell-modal-admin');
435 }
436
437 private function enqueueFeedback()
438 {
439 wp_enqueue_script('superb-addons-feedback', SUPERBADDONS_ASSETS_PATH . '/js/admin/deactivate-feedback.js', array('jquery'), SUPERBADDONS_VERSION, true);
440 wp_localize_script('superb-addons-feedback', 'superbaddonssettings_g', array(
441 "plugin" => plugin_basename(SUPERBADDONS_BASE),
442 "rest" => array(
443 "base" => \get_rest_url(),
444 "namespace" => RestController::NAMESPACE,
445 "nonce" => wp_create_nonce("wp_rest"),
446 "routes" => array(
447 "settings" => SettingsController::SETTINGS_ROUTE,
448 )
449 )
450 ));
451 add_action('admin_footer', function () {
452 new FeedbackModal();
453 });
454 }
455
456 private function enqueuePatternLibraryBase()
457 {
458 GutenbergController::AddonsLibrary();
459 wp_enqueue_script('superb-addons-select2', SUPERBADDONS_ASSETS_PATH . '/lib/select2.min.js', array('jquery'), SUPERBADDONS_VERSION, true);
460 wp_enqueue_style(
461 'superb-dashboard-layout-library',
462 SUPERBADDONS_ASSETS_PATH . '/css/layout-library-editor.min.css',
463 array(),
464 SUPERBADDONS_VERSION
465 );
466 wp_enqueue_style(
467 'superbaddons-select2',
468 SUPERBADDONS_ASSETS_PATH . '/lib/select2.min.css',
469 array(),
470 SUPERBADDONS_VERSION
471 );
472 }
473
474 private function enqueueDashboard()
475 {
476 wp_enqueue_script('superb-addons-library-dashboard', SUPERBADDONS_ASSETS_PATH . '/js/admin/dashboard.js', array('jquery', "wp-i18n"), SUPERBADDONS_VERSION, true);
477 ScriptTranslations::Set('superb-addons-library-dashboard');
478 wp_localize_script('superb-addons-library-dashboard', 'superblayoutlibrary_g', array(
479 "style_placeholder" => esc_html__('All themes', "superb-blocks"),
480 "category_placeholder" => esc_html__('All categories', "superb-blocks"),
481 "snacks" => array(
482 "list_error" => esc_html__('Something went wrong while attempting to list elements. Please try again or contact support if the problem persists.', "superb-blocks")
483 ),
484 "gutenberg_menu_items" => GutenbergController::GetGutenbergLibraryMenuItems(),
485 "elementor_menu_items" => ElementorController::GetElementorLibraryMenuItems(),
486 "chunk_route" => LibraryRequestController::GUTENBERG_V2_LIST_CHUNK_ROUTE,
487 "favorites" => FavoritesController::GetFavorites(get_current_user_id()),
488 "tutorial_urls" => array(
489 "gutenberg" => esc_url_raw(add_query_arg(
490 array(
491 TourController::TOUR_GUTENBERG => TourController::GUTENBERG_TOUR_PATTERNS,
492 TourController::TOUR_NONCE_PARAM => wp_create_nonce(TourController::TOUR_NONCE_ACTION),
493 ),
494 admin_url('post-new.php')
495 )),
496 "elementor" => esc_url_raw(add_query_arg(
497 array(
498 TourController::TOUR_GUTENBERG => TourController::GUTENBERG_TOUR_PATTERNS,
499 TourController::TOUR_NONCE_PARAM => wp_create_nonce(TourController::TOUR_NONCE_ACTION),
500 ),
501 admin_url('post-new.php')
502 )),
503 ),
504 "rest" => array(
505 "base" => \get_rest_url(),
506 "namespace" => RestController::NAMESPACE,
507 "nonce" => wp_create_nonce("wp_rest"),
508 "routes" => array(
509 "settings" => SettingsController::SETTINGS_ROUTE,
510 )
511 )
512 ));
513
514 // Dashboard Welcome Tour
515 wp_enqueue_style(
516 'superbaddons-driver',
517 SUPERBADDONS_ASSETS_PATH . '/lib/driver.css',
518 array(),
519 SUPERBADDONS_VERSION
520 );
521 wp_enqueue_script('superb-addons-tour-dashboard', SUPERBADDONS_ASSETS_PATH . '/js/guided-tours/dashboard-welcome.js', array('wp-i18n', 'jquery', 'superb-addons-library-dashboard'), SUPERBADDONS_VERSION, true);
522 ScriptTranslations::Set('superb-addons-tour-dashboard');
523 wp_localize_script('superb-addons-tour-dashboard', 'superbaddonstour_g', array(
524 "auto_start" => !TourController::IsTourCompleted(TourController::TOUR_DASHBOARD_WELCOME_META),
525 "rest" => array(
526 "base" => \get_rest_url(),
527 "namespace" => RestController::NAMESPACE,
528 "nonce" => wp_create_nonce("wp_rest"),
529 "routes" => array(
530 "tutorial" => TroubleshootingController::TUTORIAL_ROUTE,
531 )
532 )
533 ));
534 }
535
536 private function enqueueSupport()
537 {
538 wp_enqueue_script('superb-addons-troubleshooting', SUPERBADDONS_ASSETS_PATH . '/js/admin/troubleshooting.js', array('jquery', 'wp-i18n'), SUPERBADDONS_VERSION, true);
539 ScriptTranslations::Set('superb-addons-troubleshooting');
540 wp_localize_script('superb-addons-troubleshooting', 'superbaddonstroubleshooting_g', array(
541 "rest" => array(
542 "base" => \get_rest_url(),
543 "namespace" => RestController::NAMESPACE,
544 "nonce" => wp_create_nonce("wp_rest"),
545 "fallback_url" => add_query_arg(
546 'rest_route',
547 '/' . RestController::NAMESPACE . TroubleshootingController::TROUBLESHOOTING_ROUTE,
548 trailingslashit(home_url()) . 'index.php'
549 ),
550 "routes" => array(
551 "troubleshooting" => TroubleshootingController::TROUBLESHOOTING_ROUTE,
552 "tutorial" => TroubleshootingController::TUTORIAL_ROUTE,
553 )
554 ),
555 "steps" => array(
556 "restcheck" => array(
557 "title" => esc_html__("REST API Status", "superb-blocks"),
558 "text" => esc_html__("Checking REST API", "superb-blocks"),
559 "errorText" => esc_html__("REST API Unavailable", "superb-blocks"),
560 "successText" => esc_html__("REST API Available", "superb-blocks"),
561 ),
562 "restfix" => array(
563 "title" => esc_html__("Permalink Configuration", "superb-blocks"),
564 "text" => esc_html__("Refreshing Permalinks", "superb-blocks"),
565 "errorText" => esc_html__("Could not refresh permalinks", "superb-blocks"),
566 "successText" => esc_html__("Permalinks Refreshed", "superb-blocks"),
567 ),
568 "connection" => array(
569 "title" => esc_html__("Connection Status", "superb-blocks"),
570 "text" => esc_html__("Checking Connection", "superb-blocks"),
571 "errorText" => esc_html__("No Connection", "superb-blocks"),
572 "successText" => esc_html__("Connected", "superb-blocks"),
573 ),
574 "domainshift" => array(
575 "title" => esc_html__("Connection Update", "superb-blocks"),
576 "text" => esc_html__("Trying New Connection", "superb-blocks"),
577 "errorText" => esc_html__("Connection Blocked", "superb-blocks"),
578 "successText" => esc_html__("Connected", "superb-blocks"),
579 ),
580 "service" => array(
581 "title" => esc_html__("Service Status", "superb-blocks"),
582 "text" => esc_html__("Checking Service", "superb-blocks"),
583 "errorText" => esc_html__("Service Unavailable", "superb-blocks"),
584 "successText" => esc_html__("Service Online", "superb-blocks"),
585 ),
586 "keycheck" => array(
587 "title" => esc_html__("License Key Status", "superb-blocks"),
588 "text" => esc_html__("Checking License Key", "superb-blocks"),
589 "errorText" => esc_html__("Invalid License Key", "superb-blocks"),
590 "successText" => esc_html__("Valid License Key", "superb-blocks"),
591 ),
592 "keyverify" => array(
593 "title" => esc_html__("License Key Verification", "superb-blocks"),
594 "text" => esc_html__("Re-verifying License Key", "superb-blocks"),
595 "errorText" => esc_html__("License could not be verified", "superb-blocks"),
596 "successText" => esc_html__("License Key Verified", "superb-blocks"),
597 ),
598 "cacheclear" => array(
599 "title" => esc_html__("Cache Status", "superb-blocks"),
600 "text" => esc_html__("Clearing Cache", "superb-blocks"),
601 "errorText" => esc_html__("Cache could not be cleared", "superb-blocks"),
602 "successText" => esc_html__("Cache Cleared", "superb-blocks"),
603 )
604 )
605 ));
606 add_action("admin_footer", array($this, 'TroubleshootingTemplates'));
607 }
608
609 private function enqueueSettings()
610 {
611 wp_enqueue_script('superb-addons-settings', SUPERBADDONS_ASSETS_PATH . '/js/admin/settings.js', array('jquery'), SUPERBADDONS_VERSION, true);
612 wp_localize_script('superb-addons-settings', 'superbaddonssettings_g', array(
613 "save_message" => esc_html__("Settings saved successfully.", "superb-blocks"),
614 "modal" => array(
615 "cache" => array(
616 "title" => esc_html__("Clear Cache", "superb-blocks"),
617 "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 with the design library or theme designer. Are you sure you want to clear the cache?", "superb-blocks"),
618 "success" => esc_html__("Cache cleared successfully.", "superb-blocks")
619 ),
620 "view_logs" => array(
621 "title" => esc_html__("Error Log", "superb-blocks"),
622 "no_logs" => esc_html__("No errors have been logged.", "superb-blocks"),
623 "icon_unshared" => esc_url(SUPERBADDONS_ASSETS_PATH . "/img/cloud-slash.svg"),
624 "unshared_title" => esc_html__("Error Log Not Shared", "superb-blocks"),
625 "icon_shared" => esc_url(SUPERBADDONS_ASSETS_PATH . "/img/cloud-check.svg"),
626 "shared_title" => esc_html__("Error Log Shared", "superb-blocks"),
627 ),
628 "clear_logs" => array(
629 "title" => esc_html__("Clear Logs", "superb-blocks"),
630 "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"),
631 "success" => esc_html__("Error logs cleared successfully.", "superb-blocks")
632 ),
633 "remove_key" => array(
634 "title" => esc_html__("Remove License Key", "superb-blocks"),
635 "content" => esc_html__("Are you sure you want to remove your license key from this website?", "superb-blocks"),
636 ),
637 "clear_restoration_points" => array(
638 "title" => esc_html__("Clear Restoration Points", "superb-blocks"),
639 "content" => esc_html__("Restoration points can not be recovered after being cleared. Are you sure you want to clear all restoration points?", "superb-blocks"),
640 "success" => esc_html__("Restoration points cleared successfully.", "superb-blocks")
641 ),
642 "remove_mailchimp_key" => array(
643 "title" => esc_html__("Remove Mailchimp API Key", "superb-blocks"),
644 "content" => esc_html__("Are you sure you want to remove your Mailchimp API key? Forms using the Mailchimp integration will stop sending subscribers until a new key is added.", "superb-blocks"),
645 ),
646 "remove_brevo_key" => array(
647 "title" => esc_html__("Remove Brevo API Key", "superb-blocks"),
648 "content" => esc_html__("Are you sure you want to remove your Brevo API key? Forms using the Brevo integration will stop sending contacts until a new key is added.", "superb-blocks"),
649 ),
650 "remove_google_sheets_key" => array(
651 "title" => esc_html__("Disconnect Google Sheets", "superb-blocks"),
652 "content" => esc_html__("Are you sure you want to disconnect Google Sheets? Forms using the Google Sheets integration will stop appending rows until a new Service Account key is added.", "superb-blocks"),
653 ),
654 "remove_captcha_key" => array(
655 "title" => esc_html__("Remove CAPTCHA Keys", "superb-blocks"),
656 "content" => esc_html__("Are you sure you want to remove these CAPTCHA keys? Forms using this provider will fall back to basic spam protection.", "superb-blocks"),
657 ),
658 "remove_captcha_key_in_use" => array(
659 "title" => esc_html__("Remove CAPTCHA Keys", "superb-blocks"),
660 /* translators: %d: number of forms using this CAPTCHA provider */
661 "content" => esc_html__("This CAPTCHA provider is currently in use on %d forms. Removing the keys will disable CAPTCHA protection on those forms. Continue?", "superb-blocks"),
662 ),
663 "data_retention_confirm" => array(
664 "title" => esc_html__("Enable Data Retention", "superb-blocks"),
665 /* translators: %d: number of days */
666 "content" => esc_html__("This will permanently delete all submissions older than %d days. This affects all forms and cannot be undone. Continue?", "superb-blocks"),
667 ),
668 "remove_integration_in_use" => array(
669 "title" => esc_html__("Remove API Key", "superb-blocks"),
670 /* translators: %1$s: integration name, %2$d: number of forms */
671 "content" => esc_html__("This integration is currently in use on %d forms. Removing the API key will prevent those forms from syncing. Continue?", "superb-blocks"),
672 ),
673 "remove_all_data" => array(
674 "title" => esc_html__("Remove All Plugin Data", "superb-blocks"),
675 "content" => esc_html__("This permanently deletes every Superb Addons option, setting, integration key, user preference, and scheduled task. Your license key will also be deactivated and removed from this site. This action cannot be undone.", "superb-blocks"),
676 "ack_label" => esc_html__("I understand that this will permanently delete my license key, plugin settings, integration keys, user preferences, and all related data from this site.", "superb-blocks"),
677 "submissions_label" => esc_html__("Also permanently delete all form submissions stored on this site", "superb-blocks"),
678 "success" => esc_html__("All plugin data removed. Reloading...", "superb-blocks"),
679 ),
680 ),
681 "integration_key_saved" => esc_html__("API key saved and validated successfully.", "superb-blocks"),
682 "integration_key_removed" => esc_html__("API key removed successfully.", "superb-blocks"),
683 "integration_key_error" => esc_html__("An error occurred. Please try again.", "superb-blocks"),
684 "connected_label" => esc_html__("Connected", "superb-blocks"),
685 "not_connected_label" => esc_html__("Not Connected", "superb-blocks"),
686 "disconnect_label" => esc_html__("Disconnect", "superb-blocks"),
687 "connect_label" => esc_html__("Connect", "superb-blocks"),
688 "placeholder_mailchimp" => esc_attr__("Enter Mailchimp API key", "superb-blocks"),
689 "placeholder_brevo" => esc_attr__("Enter Brevo API key", "superb-blocks"),
690 "placeholder_google_sheets" => esc_attr__("Paste Service Account JSON key", "superb-blocks"),
691 "gs_share_hint" => esc_html__("Share your spreadsheet with this email address (as an Editor) so it can add rows.", "superb-blocks"),
692 "trash_icon_url" => esc_url(SUPERBADDONS_ASSETS_PATH . '/img/trash-light.svg'),
693 "spinner_url" => esc_url(SUPERBADDONS_ASSETS_PATH . '/img/blocks-spinner.svg'),
694 "captcha_saved" => esc_html__("CAPTCHA keys saved.", "superb-blocks"),
695 "captcha_removed" => esc_html__("CAPTCHA keys removed.", "superb-blocks"),
696 "captcha_error" => esc_html__("An error occurred. Please try again.", "superb-blocks"),
697 "permissions_saved" => esc_html__("Permissions saved.", "superb-blocks"),
698 "notice_default_access" => esc_html__("This role has full access by default. Enable access control above to customize permissions.", "superb-blocks"),
699 "notice_explicit_access" => esc_html__("Configure which form features this role can access.", "superb-blocks"),
700 "default_email_saved" => esc_html__("Email settings saved.", "superb-blocks"),
701 "data_retention_saved" => esc_html__("Data retention settings saved.", "superb-blocks"),
702 /* translators: %d: number of days */
703 "data_retention_warning" => esc_html__("Submissions older than %d days are automatically deleted.", "superb-blocks"),
704 /* translators: %d: number of forms using this integration */
705 "in_use_badge" => esc_html__("In use on %d forms", "superb-blocks"),
706 "search_placeholder" => esc_attr__("Search settings...", "superb-blocks"),
707 "rest" => array(
708 "base" => \get_rest_url(),
709 "namespace" => RestController::NAMESPACE,
710 "nonce" => wp_create_nonce("wp_rest"),
711 "routes" => array(
712 "settings" => SettingsController::SETTINGS_ROUTE,
713 )
714 )
715 ));
716 }
717
718 private function enqueueAdditionalCSS()
719 {
720 wp_enqueue_style(
721 'superbaddons-select2',
722 SUPERBADDONS_ASSETS_PATH . '/lib/select2.min.css',
723 array(),
724 SUPERBADDONS_VERSION
725 );
726
727 do_action('superbaddons/admin/css-blocks/enqueue');
728
729 wp_enqueue_script('superb-addons-select2', SUPERBADDONS_ASSETS_PATH . '/lib/select2.min.js', array('jquery'), SUPERBADDONS_VERSION, true);
730 $code_editor_settings = wp_enqueue_code_editor(array('type' => 'text/css', 'codemirror' => array('lint' => true)));
731 wp_enqueue_script('superb-addons-css-blocks', SUPERBADDONS_ASSETS_PATH . '/js/admin/cssblocks.js', array('jquery', 'wp-i18n'), SUPERBADDONS_VERSION, true);
732 ScriptTranslations::Set('superb-addons-css-blocks');
733 wp_localize_script('superb-addons-css-blocks', 'superbaddonscssblocks_g', array(
734 "codeEditorSettings" => $code_editor_settings,
735 "rest" => array(
736 "base" => \get_rest_url(),
737 "namespace" => RestController::NAMESPACE,
738 "nonce" => wp_create_nonce("wp_rest"),
739 "routes" => array(
740 "css" => CSSController::CSS_ROUTE,
741 ),
742 "error_message" => esc_html__("An error occurred while updating the CSS block. Please try again.", "superb-blocks"),
743 ),
744 ));
745 }
746
747 private function enqueuePageWizard()
748 {
749 wp_enqueue_style(
750 'superb-addons-page-wizard',
751 SUPERBADDONS_ASSETS_PATH . '/css/page-wizard.min.css',
752 array(),
753 SUPERBADDONS_VERSION
754 );
755 wp_enqueue_script('superb-addons-page-wizard', SUPERBADDONS_ASSETS_PATH . '/js/admin/page-wizard.js', array('jquery', 'wp-i18n'), SUPERBADDONS_VERSION, true);
756 ScriptTranslations::Set('superb-addons-page-wizard');
757 wp_localize_script('superb-addons-page-wizard', 'superbaddonswizard_g', array(
758 "favorites" => FavoritesController::GetFavorites(get_current_user_id()),
759 "industries" => self::GetLibraryIndustries(),
760 "rest" => array(
761 "base" => \get_rest_url(),
762 "namespace" => RestController::NAMESPACE,
763 "nonce" => wp_create_nonce("wp_rest"),
764 "routes" => array(
765 "wizard" => WizardController::WIZARD_ROUTE,
766 "favorites" => FavoritesController::FAVORITES_ROUTE,
767 "warm_cache" => LibraryRequestController::GUTENBERG_V2_WARM_CACHE_ROUTE,
768 )
769 )
770 ));
771
772 // Block Theme Explainer Tour
773 wp_enqueue_style(
774 'superbaddons-driver',
775 SUPERBADDONS_ASSETS_PATH . '/lib/driver.css',
776 array(),
777 SUPERBADDONS_VERSION
778 );
779 wp_enqueue_script('superb-addons-tour-block-theme', SUPERBADDONS_ASSETS_PATH . '/js/guided-tours/block-theme-explainer.js', array('wp-i18n', 'jquery', 'superb-addons-page-wizard'), SUPERBADDONS_VERSION, true);
780 ScriptTranslations::Set('superb-addons-tour-block-theme');
781 wp_localize_script('superb-addons-tour-block-theme', 'superbaddonstour_g', array(
782 "auto_start" => !TourController::IsTourCompleted(TourController::TOUR_BLOCK_THEME_META),
783 "rest" => array(
784 "base" => \get_rest_url(),
785 "namespace" => RestController::NAMESPACE,
786 "nonce" => wp_create_nonce("wp_rest"),
787 "routes" => array(
788 "tutorial" => TroubleshootingController::TUTORIAL_ROUTE,
789 )
790 )
791 ));
792 }
793
794 /**
795 * Read the industries list from the unified library cache. Returns [] when the
796 * cache is cold, so the wizard falls back gracefully (the sidebar just omits
797 * the Industries section).
798 */
799 private static function GetLibraryIndustries()
800 {
801 try {
802 $cache = CacheController::GetCache(GutenbergCache::LIBRARY, CacheTypes::GUTENBERG);
803 if ($cache && isset($cache->industries) && is_array($cache->industries)) {
804 return $cache->industries;
805 }
806 } catch (\Exception $e) {
807 // Fall through to empty list.
808 }
809 return array();
810 }
811
812 private function enqueueForms()
813 {
814 wp_enqueue_style(
815 'superb-addons-admin-forms',
816 SUPERBADDONS_ASSETS_PATH . '/css/admin-forms.min.css',
817 array(),
818 SUPERBADDONS_VERSION
819 );
820 wp_enqueue_script('superb-addons-admin-forms', SUPERBADDONS_ASSETS_PATH . '/js/admin/forms.js', array('jquery'), SUPERBADDONS_VERSION, true);
821 wp_localize_script('superb-addons-admin-forms', 'superbaddonsadminforms_g', array(
822 "forms_url" => esc_url(admin_url('admin.php?page=' . self::FORMS)),
823 "permissions" => FormPermissions::GetCurrentUserPermissions(),
824 "rest" => array(
825 "base" => \get_rest_url(),
826 "namespace" => RestController::NAMESPACE,
827 "nonce" => wp_create_nonce("wp_rest"),
828 "routes" => array(
829 "submissions" => \SuperbAddons\Gutenberg\Form\FormController::SUBMISSIONS_ROUTE,
830 "submissions_forms" => \SuperbAddons\Gutenberg\Form\FormController::SUBMISSIONS_FORMS_ROUTE,
831 "submissions_bulk_delete" => \SuperbAddons\Gutenberg\Form\FormController::SUBMISSIONS_BULK_DELETE_ROUTE,
832 "submissions_bulk_status" => \SuperbAddons\Gutenberg\Form\FormController::SUBMISSIONS_BULK_STATUS_ROUTE,
833 "submissions_mark_read" => '/form/submissions/{id}/read',
834 "submissions_mark_unread" => '/form/submissions/{id}/unread',
835 "submissions_delete" => '/form/submissions/{id}',
836 "form_delete" => '/form/{form_id}',
837 "submissions_resend_email" => '/form/submissions/{id}/resend-email',
838 "submissions_star" => '/form/submissions/{id}/star',
839 "submissions_unstar" => '/form/submissions/{id}/unstar',
840 "submissions_bulk_star" => \SuperbAddons\Gutenberg\Form\FormController::SUBMISSIONS_BULK_STAR_ROUTE,
841 "export" => '/form/{form_id}/export',
842 "submissions_not_spam" => '/form/submissions/{id}/not-spam',
843 "spam_count" => '/form/{form_id}/spam-count',
844 "retry_integration" => '/form/submissions/{id}/retry-integration',
845 "submissions_notes" => '/form/submissions/{id}/notes',
846 "submissions_notes_delete" => '/form/submissions/{id}/notes/{index}',
847 "fields_save" => \SuperbAddons\Gutenberg\Form\FormController::FIELDS_SAVE_ROUTE,
848 "fields_get" => '/form/fields/{form_id}',
849 "submissions_count" => \SuperbAddons\Gutenberg\Form\FormController::SUBMISSIONS_COUNT_ROUTE,
850 )
851 ),
852 "icons" => array(
853 "trash" => esc_url(SUPERBADDONS_ASSETS_PATH . '/img/trash-light.svg'),
854 "eye" => esc_url(SUPERBADDONS_ASSETS_PATH . '/img/eye.svg'),
855 "eye_slash" => esc_url(SUPERBADDONS_ASSETS_PATH . '/img/eye-slash.svg'),
856 "copy" => esc_url(SUPERBADDONS_ASSETS_PATH . '/img/copy.svg'),
857 "star_regular" => esc_url(SUPERBADDONS_ASSETS_PATH . '/img/purple-star-regular.svg'),
858 "star_fill" => esc_url(SUPERBADDONS_ASSETS_PATH . '/img/purple-star-fill.svg'),
859 "checkmark" => esc_url(SUPERBADDONS_ASSETS_PATH . '/img/checkmark.svg'),
860 ),
861 "i18n" => array(
862 "delete_confirm_title" => esc_html__("Delete Submission", "superb-blocks"),
863 "delete_confirm" => esc_html__("Are you sure? This action cannot be undone.", "superb-blocks"),
864 "bulk_delete_confirm_title" => esc_html__("Delete Selected Submissions", "superb-blocks"),
865 "bulk_delete_confirm" => esc_html__("Are you sure? This action cannot be undone.", "superb-blocks"),
866 "deleted" => esc_html__("Submission deleted.", "superb-blocks"),
867 "bulk_deleted" => esc_html__("Submissions deleted.", "superb-blocks"),
868 "error" => esc_html__("An error occurred. Please try again.", "superb-blocks"),
869 "no_submissions" => esc_html__("No submissions found.", "superb-blocks"),
870 "no_filter_results" => esc_html__("No submissions match your filters.", "superb-blocks"),
871 "new_status" => esc_html__("New", "superb-blocks"),
872 "read_status" => esc_html__("Read", "superb-blocks"),
873 "mark_read" => esc_html__("Mark as Read", "superb-blocks"),
874 "mark_unread" => esc_html__("Mark as Unread", "superb-blocks"),
875 "bulk_marked_read" => esc_html__("Submissions marked as read.", "superb-blocks"),
876 "bulk_marked_unread" => esc_html__("Submissions marked as unread.", "superb-blocks"),
877 "copied" => esc_html__("Copied!", "superb-blocks"),
878 "filter_all" => esc_html__("All", "superb-blocks"),
879 "filter_unread" => esc_html__("Unread", "superb-blocks"),
880 "filter_read" => esc_html__("Read", "superb-blocks"),
881 "clear_filters" => esc_html__("Clear filters", "superb-blocks"),
882 /* translators: 1: current submission number, 2: total submissions */
883 "submission_counter" => esc_html__('Submission %1$s of %2$s', "superb-blocks"),
884 "prev_submission" => esc_html__("Previous submission", "superb-blocks"),
885 "next_submission" => esc_html__("Next submission", "superb-blocks"),
886 "total_label" => esc_html__("Total", "superb-blocks"),
887 "unread_label" => esc_html__("Unread", "superb-blocks"),
888 "today_label" => esc_html__("Today", "superb-blocks"),
889 "this_week_label" => esc_html__("This Week", "superb-blocks"),
890 "date_all_time" => esc_html__("All Time", "superb-blocks"),
891 "date_this_month" => esc_html__("This Month", "superb-blocks"),
892 "date_last_30" => esc_html__("Last 30 Days", "superb-blocks"),
893 "date_custom_range" => esc_html__("Custom Range", "superb-blocks"),
894 "date_from" => esc_html__("From", "superb-blocks"),
895 "date_to" => esc_html__("To", "superb-blocks"),
896 "date_apply" => esc_html__("Apply", "superb-blocks"),
897 "date_clear" => esc_html__("Clear", "superb-blocks"),
898 "delete_form_confirm_title" => esc_html__("Delete Form", "superb-blocks"),
899 "delete_form_confirm" => esc_html__("This will permanently delete the form and all stored submissions. The form block will stop working if it remains on your site. This action cannot be undone.", "superb-blocks"),
900 /* translators: %s: post type name (e.g. "page", "post", "template") */
901 "delete_form_remove_block" => esc_html__("Also remove the form block from its %s (recommended)", "superb-blocks"),
902 "source_type_labels" => array(
903 "page" => esc_html__("page", "superb-blocks"),
904 "post" => esc_html__("post", "superb-blocks"),
905 "wp_template" => esc_html__("template", "superb-blocks"),
906 "wp_template_part" => esc_html__("template part", "superb-blocks"),
907 "wp_block" => esc_html__("pattern", "superb-blocks"),
908 ),
909 "form_deleted" => esc_html__("Form deleted.", "superb-blocks"),
910 "resend_admin" => esc_html__("Resend Admin Email", "superb-blocks"),
911 "resend_user" => esc_html__("Resend User Email", "superb-blocks"),
912 "resend_user_confirm_title" => esc_html__("Resend User Email", "superb-blocks"),
913 "resend_user_confirm" => esc_html__("This will send the confirmation email to the user again. Are you sure you want to continue?", "superb-blocks"),
914 "resend_admin_success" => esc_html__("Admin email sent.", "superb-blocks"),
915 "resend_user_success" => esc_html__("User email sent.", "superb-blocks"),
916 "resend_error" => esc_html__("Failed to send email. Please try again.", "superb-blocks"),
917 "starred" => esc_html__("Starred", "superb-blocks"),
918 "star" => esc_html__("Star", "superb-blocks"),
919 "unstar" => esc_html__("Unstar", "superb-blocks"),
920 "bulk_starred" => esc_html__("Submissions starred.", "superb-blocks"),
921 "bulk_unstarred" => esc_html__("Submissions unstarred.", "superb-blocks"),
922 "export" => esc_html__("Export", "superb-blocks"),
923 /* translators: %d: number of filtered submissions */
924 "export_filtered" => esc_html__("Filtered results (%d)", "superb-blocks"),
925 "print" => esc_html__("Print", "superb-blocks"),
926 "print_status_new" => esc_html__("Unread", "superb-blocks"),
927 "print_status_read" => esc_html__("Read", "superb-blocks"),
928 "selected_single" => esc_html__("1 selected", "superb-blocks"),
929 /* translators: %d: number of selected submissions */
930 "selected_multiple" => esc_html__("%d selected", "superb-blocks"),
931 "spam_tab" => esc_html__("Spam", "superb-blocks"),
932 "not_spam" => esc_html__("Not Spam", "superb-blocks"),
933 "not_spam_success" => esc_html__("Submission moved to inbox.", "superb-blocks"),
934 "spam_reason_label" => esc_html__("Spam Reason", "superb-blocks"),
935 "spam_reason_honeypot" => esc_html__("Honeypot", "superb-blocks"),
936 "spam_reason_captcha" => esc_html__("CAPTCHA failure", "superb-blocks"),
937 "spam_reason_bot_detection" => esc_html__("Bot detection", "superb-blocks"),
938 /* translators: %d: number of filtered spam submissions */
939 "export_spam_filtered" => esc_html__("Filtered spam (%d)", "superb-blocks"),
940 "retry_mailchimp" => esc_html__("Retry Mailchimp", "superb-blocks"),
941 "retry_brevo" => esc_html__("Retry Brevo", "superb-blocks"),
942 "retry_success" => esc_html__("Integration sent successfully.", "superb-blocks"),
943 "retry_error" => esc_html__("Failed to send to integration.", "superb-blocks"),
944 "email_status_sent" => esc_html__("Sent", "superb-blocks"),
945 "email_status_failed" => esc_html__("Failed", "superb-blocks"),
946 "email_status_not_sent" => esc_html__("Not sent", "superb-blocks"),
947 // Phase 3: Notes
948 "add_note" => esc_html__("Add Note", "superb-blocks"),
949 "note_placeholder" => esc_html__("Add a note...", "superb-blocks"),
950 "note_added" => esc_html__("Note added.", "superb-blocks"),
951 "note_deleted" => esc_html__("Note deleted.", "superb-blocks"),
952 "note_error" => esc_html__("Failed to save note.", "superb-blocks"),
953 "note_delete_error" => esc_html__("Failed to delete note.", "superb-blocks"),
954 "note_delete_confirm_title" => esc_html__("Delete Note", "superb-blocks"),
955 "note_delete_confirm" => esc_html__("Are you sure you want to delete this note?", "superb-blocks"),
956 "notes_label" => esc_html__("Notes", "superb-blocks"),
957 "include_notes" => esc_html__("Include notes", "superb-blocks"),
958 /* translators: %d: number of remaining characters */
959 "chars_remaining" => esc_html__("%d characters remaining", "superb-blocks"),
960 // Phase 3: Visible Fields
961 "fields_btn" => esc_html__("Fields", "superb-blocks"),
962 "fields_saved" => esc_html__("Field preferences saved.", "superb-blocks"),
963 "fields_error" => esc_html__("Failed to save field preferences.", "superb-blocks"),
964 "fields_reset" => esc_html__("Reset", "superb-blocks"),
965 "export_all_fields" => esc_html__("Export all fields", "superb-blocks"),
966 // Phase 3: Real-time
967 "new_submission_received" => esc_html__("New submission received", "superb-blocks"),
968 )
969 ));
970 }
971
972 public function TroubleshootingTemplates()
973 {
974 AllowedTemplateHTMLUtil::enable_safe_styles();
975 ob_start();
976 include(SUPERBADDONS_PLUGIN_DIR . 'src/admin/templates/troubleshooting-step.php');
977 $template = ob_get_clean();
978 echo '<script type="text/template" id="tmpl-superb-addons-troubleshooting-step">' . wp_kses($template, "post") . '</script>';
979 AllowedTemplateHTMLUtil::disable_safe_styles();
980 }
981
982 public function SuperbDashboard()
983 {
984 $this->DashboardPageSetup(DashboardPage::class);
985 }
986
987 public function AdditionalCSS()
988 {
989 $this->DashboardPageSetup(AdditionalCSSPage::class);
990 }
991
992 public function Support()
993 {
994 $this->DashboardPageSetup(SupportPage::class);
995 }
996
997 public function Settings()
998 {
999 $this->DashboardPageSetup(SettingsPage::class);
1000 }
1001
1002 public function PageWizard()
1003 {
1004 $this->DashboardPageSetup(PageWizardMainPage::class, true, __("Theme Designer", "superb-blocks"));
1005 }
1006
1007 public function Forms()
1008 {
1009 $this->DashboardPageSetup(FormsPage::class);
1010 }
1011
1012 private function DashboardPageSetup($page_class, $hide_navigation_items = false, $theme_designer = false)
1013 {
1014 ?>
1015 <div class="superbaddons-wrap">
1016 <?php new Navigation($hide_navigation_items, $theme_designer); ?>
1017 <div class="superbaddons-wrap-inner">
1018 <?php new $page_class(); ?>
1019 </div>
1020 </div>
1021 <?php
1022 }
1023 }
1024