| @@ -1,7 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Booktics\Assets; |
| 3 | 3 | |
| 4 | +use Booktics\Admin\Theme_Mode; | |
| 5 | + | |
| 4 | 6 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 5 | 7 | |
| 6 | 8 | /** |
| 7 | 9 | * Manage all localize data |
| @@ -31,12 +33,17 @@ | ||
| 31 | 33 | 'time_format' => get_option( 'time_format' ), |
| 32 | 34 | 'time_format_string' => date_i18n( get_option( 'time_format' ) ), |
| 33 | 35 | 'start_of_week' => get_option( 'start_of_week', 0 ), |
| 34 | 36 | 'current_user_id' => get_current_user_id(), |
| 37 | + 'current_user_email' => $current_user->user_email, | |
| 38 | + 'current_user_name' => $current_user->display_name, | |
| 35 | 39 | 'currency_list' => booktics_get_currencies(), |
| 36 | 40 | 'bookticsPro' => class_exists('BookticsPro'), |
| 37 | 41 | 'user_role' => (array) $user_roles, |
| 38 | 42 | 'doc_links' => self::get_doc_links(), |
| 43 | + 'aisentic' => self::get_aisentic_state(), | |
| 44 | + 'theme_mode' => Theme_Mode::get_for_user(), | |
| 45 | + 'dark_mode_enabled' => Theme_Mode::is_enabled(), | |
| 39 | 46 | ]; |
| 40 | 47 | |
| 41 | 48 | return apply_filters( 'booktics_admin_localize', $data ); |
| 42 | 49 | } |
| @@ -59,8 +66,32 @@ | ||
| 59 | 66 | } |
| 60 | 67 | } |
| 61 | 68 | |
| 62 | 69 | return $doc_links; |
| 70 | + } | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * Aisentic connection state for the admin UI. | |
| 74 | + * | |
| 75 | + * The identity comes from booktics_aisentic_identity() so the email rendered on | |
| 76 | + * the consent copy is the same one the register action would send. | |
| 77 | + * | |
| 78 | + * @return array<string, mixed> | |
| 79 | + */ | |
| 80 | + private static function get_aisentic_state() { | |
| 81 | + $identity = booktics_aisentic_identity(); | |
| 82 | + $integration = get_option( 'aisentic_integration_settings', [] ); | |
| 83 | + | |
| 84 | + return [ | |
| 85 | + 'name' => $identity['name'], | |
| 86 | + 'email' => $identity['email'], | |
| 87 | + 'site_url' => $identity['site_url'], | |
| 88 | + 'active' => class_exists( 'Aisentic\Init' ), | |
| 89 | + 'registered' => booktics_aisentic_is_registered(), | |
| 90 | + 'supports_registration' => class_exists( 'Aisentic\Api\Services\Registration_Service' ), | |
| 91 | + 'connected' => isset( $integration['booktics']['status'] ) | |
| 92 | + && 'connected' === $integration['booktics']['status'], | |
| 93 | + ]; | |
| 63 | 94 | } |
| 64 | 95 | |
| 65 | 96 | /** |
| 66 | 97 | * Get frontend localize data |