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