roles ) && is_array( $current_user->roles) ) { foreach( $current_user->roles as $role) { $user_roles[] = $role; } } $data = [ 'site_url' => site_url(), 'admin_url' => admin_url(), 'nonce' => wp_create_nonce( 'wp_rest' ), 'date_format' => get_option( 'date_format' ), 'date_format_string' => date_i18n( get_option( 'date_format' ) ), 'time_format' => get_option( 'time_format' ), 'time_format_string' => date_i18n( get_option( 'time_format' ) ), 'start_of_week' => get_option( 'start_of_week', 0 ), 'current_user_id' => get_current_user_id(), 'currency_list' => booktics_get_currencies(), 'bookticsPro' => class_exists('BookticsPro'), 'user_role' => (array) $user_roles, 'doc_links' => self::get_doc_links(), 'aisentic' => self::get_aisentic_state(), ]; return apply_filters( 'booktics_admin_localize', $data ); } /** * Build a slug => doc_link map from the module registry. * * Single source of truth for documentation URLs: both the addon card * (PHP `doc_link`) and the React configure modals read from this list, * so a doc URL is only ever defined once in booktics_modules_list(). * * @return array */ private static function get_doc_links() { $doc_links = []; foreach ( booktics_modules_list() as $module ) { if ( ! empty( $module['slug'] ) && ! empty( $module['doc_link'] ) ) { $doc_links[ $module['slug'] ] = $module['doc_link']; } } return $doc_links; } /** * Aisentic connection state for the admin UI. * * The identity comes from booktics_aisentic_identity() so the email rendered on * the consent copy is the same one the register action would send. * * @return array */ private static function get_aisentic_state() { $identity = booktics_aisentic_identity(); $integration = get_option( 'aisentic_integration_settings', [] ); return [ 'name' => $identity['name'], 'email' => $identity['email'], 'site_url' => $identity['site_url'], 'active' => class_exists( 'Aisentic\Init' ), 'registered' => booktics_aisentic_is_registered(), 'supports_registration' => class_exists( 'Aisentic\Api\Services\Registration_Service' ), 'connected' => isset( $integration['booktics']['status'] ) && 'connected' === $integration['booktics']['status'], ]; } /** * Get frontend localize data * * @return array Collection localize data */ public static function get_frontend() { $data = [ 'site_url' => site_url(), 'nonce' => wp_create_nonce( 'wp_rest' ), 'date_format' => get_option( 'date_format' ), 'time_format' => get_option( 'time_format' ), 'current_user_id' => get_current_user_id(), 'start_of_week' => get_option( 'start_of_week', 0 ), 'locale_name' => strtolower( str_replace( '_', '-', get_locale() ) ), 'currency_list' => booktics_get_currencies(), ]; return apply_filters( 'booktics_frontend_localize', $data ); } }