guard_admin(); if ( $check ) { return $check; } if ( ! function_exists( 'timetics_get_settings' ) ) { return [ 'error' => 'Timetics settings are unavailable.' ]; } try { $raw = timetics_get_settings(); $raw = is_array( $raw ) ? $raw : []; $secrets = array_fill_keys( self::SECRET_KEYS, false ); $settings = []; foreach ( $raw as $key => $value ) { if ( in_array( $key, self::SECRET_KEYS, true ) || preg_match( self::SECRET_PATTERN, (string) $key ) ) { $secrets[ $key ] = ! empty( $value ); continue; } $settings[ $key ] = $this->preview_setting( $value ); } ksort( $settings ); return [ 'settings' => $settings, 'secrets_configured' => $secrets, 'note' => 'Secret keys (API keys, tokens, webhook URLs) are shown only as configured true/false. ' . 'Payment, integration, currency, timezone, booking-status, and email-notification settings are ' . 'read-only here; change them in Timetics → Settings. Only business name and brand colors are ' . 'editable via timetics-update-settings.', ]; } catch ( \Throwable $e ) { Log::error( 'Timetics_Get_Settings_Tool error', [ 'error' => $e->getMessage() ] ); return [ 'error' => 'Failed to read settings: ' . $e->getMessage() ]; } } /** * Reduce a setting value to a compact, model-friendly preview. * * Long free-text settings (e.g. email templates) are capped without stripping * their markup so the admin still sees roughly what they contain; scalars and * short arrays pass through unchanged. */ private function preview_setting( $value ) { if ( is_string( $value ) && strlen( $value ) > 300 ) { return substr( $value, 0, 300 ) . '…'; } return $value; } }