| @@ -425,8 +425,11 @@ | ||
| 425 | 425 | 'current_user_id' => get_current_user_id(), |
| 426 | 426 | 'timeticsPro' => class_exists('TimeticsPro') ? true : false, |
| 427 | 427 | 'demo_url' => $this->demo_url(), |
| 428 | 428 | 'current_user' => timetics_get_current_user(), |
| 429 | + 'aisentic' => $this->get_aisentic_state(), | |
| 430 | + 'theme_mode' => Core\Admin\Theme_Mode::get_for_localize(), | |
| 431 | + 'dark_mode_enabled' => Core\Admin\Theme_Mode::is_enabled(), | |
| 429 | 432 | ); |
| 430 | 433 | |
| 431 | 434 | $localize_obj = apply_filters( 'timetics_admin_localize_data', $localize_obj ); |
| 432 | 435 | |
| @@ -433,8 +436,37 @@ | ||
| 433 | 436 | wp_localize_script( 'timetics-dashboard-scripts', 'timetics', $localize_obj ); |
| 434 | 437 | } |
| 435 | 438 | |
| 436 | 439 | /** |
| 440 | + * Aisentic connect state for the onboarding consent box and dashboard banner. | |
| 441 | + * | |
| 442 | + * Both surfaces show the email before the user opts in, so the value comes | |
| 443 | + * from the same resolver the connect request uses. | |
| 444 | + * | |
| 445 | + * @return array Aisentic identity plus active/registered flags. | |
| 446 | + */ | |
| 447 | + private function get_aisentic_state() { | |
| 448 | + $identity = timetics_aisentic_identity(); | |
| 449 | + | |
| 450 | + return [ | |
| 451 | + 'name' => $identity['name'], | |
| 452 | + 'email' => $identity['email'], | |
| 453 | + 'active' => class_exists( 'Aisentic\Init' ), | |
| 454 | + 'registered' => timetics_aisentic_is_registered(), | |
| 455 | + 'icon' => \Timetics\Core\Addon\Extension_Icon::get( 'aisentic' ), | |
| 456 | + /* | |
| 457 | + * Aisentic builds before the registration handshake have no | |
| 458 | + * listener for our hook. Connecting would fail silently there, so | |
| 459 | + * the UI hides the offer instead of promising something dead. | |
| 460 | + */ | |
| 461 | + 'supports_registration' => class_exists( 'Aisentic\Api\Services\Registration_Service' ), | |
| 462 | + 'terms_url' => 'https://arraytics.com/terms-of-service/', | |
| 463 | + // Only people who could install Aisentic by hand get the setup dialog. | |
| 464 | + 'can_setup' => current_user_can( 'manage_options' ) && current_user_can( 'install_plugins' ), | |
| 465 | + ]; | |
| 466 | + } | |
| 467 | + | |
| 468 | + /** | |
| 437 | 469 | * Register scripts and styles for frontend |
| 438 | 470 | * |
| 439 | 471 | * @return void |
| 440 | 472 | */ |
| @@ -465,10 +497,10 @@ | ||
| 465 | 497 | |
| 466 | 498 | wp_register_script( 'timetics-frontend-scripts', TIMETICS_ASSETS_URL . 'js/frontend.js', [ 'jquery', 'wp-plugins', 'wp-i18n', 'wp-element', 'wp-dom', 'wp-data' ], TIMETICS_VERSION, true ); |
| 467 | 499 | |
| 468 | 500 | $calendar_locale = timetics_get_option('calendar_locale'); |
| 469 | - if (!empty($calendar_locale)) { | |
| 470 | - wp_register_script( 'calendar-locale', "https://npmcdn.com/flatpickr/dist/l10n/{$calendar_locale}.js", [ 'jquery', 'wp-plugins', 'wp-i18n', 'wp-element', 'wp-dom', 'wp-data' ], TIMETICS_VERSION, true ); | |
| 501 | + if (!empty($calendar_locale) && file_exists( TIMETICS_PLUGIN_DIR . "assets/js/local/{$calendar_locale}.js" ) ) { | |
| 502 | + wp_register_script( 'calendar-locale', TIMETICS_ASSETS_URL . "js/local/{$calendar_locale}.js", [ 'jquery', 'wp-plugins', 'wp-i18n', 'wp-element', 'wp-dom', 'wp-data' ], TIMETICS_VERSION, true ); | |
| 471 | 503 | } |
| 472 | 504 | |
| 473 | 505 | // load text domain |
| 474 | 506 | wp_set_script_translations( 'timetics-frontend-scripts', 'timetics', TIMETICS_PLUGIN_DIR . 'languages/' ); |
| @@ -567,9 +599,9 @@ | ||
| 567 | 599 | |
| 568 | 600 | \Wpmet\Libs\Banner::instance('timetics') |
| 569 | 601 | ->is_test(true) |
| 570 | 602 | ->set_filter(ltrim($filter_string, ',')) |
| 571 | - ->set_api_url('https://banner.themefunction.com/public/jhanda') | |
| 603 | + ->set_api_url('https://banner.arraytics.com/public/jhanda') | |
| 572 | 604 | ->set_plugin_screens('timetics') |
| 573 | 605 | ->set_plugin_screens('toplevel_page_timetics') |
| 574 | 606 | ->call(); |
| 575 | 607 | // show get-help and upgrade-to-premium menu. |