PluginProbe ʕ •ᴥ•ʔ
Weight Based Shipping Table Rate for WooCommerce – Flexible Shipping / 6.11.0
Weight Based Shipping Table Rate for WooCommerce – Flexible Shipping v6.11.0
6.12.1 6.12.0 6.11.0 6.10.0 6.9.1 6.9.0 6.8.1 6.8.0 6.7.4 6.7.3 6.7.2 6.7.0 4.21.7 4.22.0 4.22.1 4.23.0 4.23.1 4.23.2 4.23.3 4.24.0 4.24.1 4.24.10 4.24.11 4.24.12 4.24.13 4.24.14 4.24.15 4.24.16 4.24.17 4.24.18 4.24.19 4.24.2 4.24.4 4.24.6 4.24.7 4.24.8 4.24.9 4.25.0 4.25.1 4.25.2 4.25.4 4.25.5 4.25.6 4.25.7 4.25.8 4.3.0 4.3.1 4.4.0 4.4.1 4.5.0 4.5.1 4.6.0 4.6.1 4.7.0 4.7.1 4.7.2 4.8.0 4.8.1 4.8.3 4.8.4 4.8.5 4.9.0 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.0.9 5.1.0 5.1.1 5.1.2 5.1.3 5.2.0 5.3.0 5.3.1 5.3.3 5.3.4 5.3.5 6.0.0 6.1.0 6.1.1 6.1.2 6.2.0 6.2.1 6.2.2 6.2.3 6.2.4 6.3.0 trunk 6.4.0 1.4 6.4.1 1.4.1 6.4.2 1.5 6.4.3 1.6 6.4.5 1.6.1 6.5.0 1.6.2 6.5.1 1.7 6.5.2 1.8 6.5.3 1.9 6.5.4 1.9.1 6.5.5 1.9.10 6.5.6 1.9.11 6.5.7 1.9.12 6.5.8 1.9.2 6.6.0 1.9.3 6.6.1 1.9.4 6.6.2 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0 2.0.1 2.1 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.6 3.0.7 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.10.0 3.11.0 3.11.1 3.11.2 3.11.3 3.11.4 3.12.0 3.13.0 3.14.0 3.14.1 3.14.2 3.14.3 3.14.4 3.15.0 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.2.0 3.3.1 3.3.10 3.3.11 3.3.12 3.3.13 3.3.14 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.8.0 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.15 3.9.16 3.9.17 3.9.18 3.9.19 3.9.2 3.9.20 3.9.21 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.9 4.0.0 4.0.1 4.0.10 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.11.0 4.11.1 4.11.2 4.11.3 4.11.4 4.11.5 4.11.6 4.11.7 4.11.8 4.11.9 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.14.0 4.14.1 4.14.2 4.15.0 4.16.0 4.16.1 4.16.2 4.17.0 4.18.0 4.18.1 4.18.2 4.18.3 4.18.4 4.18.5 4.18.6 4.19.0 4.19.1 4.2.0 4.20.0 4.20.1 4.20.2 4.20.3 4.21.0 4.21.1 4.21.2 4.21.3 4.21.4 4.21.5
flexible-shipping / vendor_prefixed / octolize / wp-octolize-docs-chat / src / Chat / ChatSettings.php
flexible-shipping / vendor_prefixed / octolize / wp-octolize-docs-chat / src / Chat Last commit date
views 2 weeks ago AjaxChatSettings.php 2 weeks ago Assets.php 2 weeks ago ChatContainer.php 2 weeks ago ChatSettings.php 2 weeks ago ChatSettingsProvider.php 2 weeks ago ConsentSettings.php 2 weeks ago DocsChat.php 2 weeks ago HookableChatObjects.php 2 weeks ago
ChatSettings.php
183 lines
1 <?php
2
3 declare (strict_types=1);
4 namespace FSVendor\Octolize\Docs\Chat;
5
6 /**
7 * Configures the chat and its diagnostic metadata.
8 */
9 class ChatSettings
10 {
11 private const WEBHOOK_URL = 'webhook_url';
12 private const STREAMING = 'streaming';
13 private const INITIAL_MESSAGES = 'initial_messages';
14 private const TITLE = 'title';
15 private const SUBTITLE = 'subtitle';
16 private const FOOTER = 'footer';
17 private const INPUT_PLACEHOLDER = 'input_placeholder';
18 private const GET_STARTED = 'get_started';
19 private const METADATA = 'metadata';
20 private const CONSENT = 'consent';
21 private const CONSENT_DISABLED = 'consent_disabled';
22 private string $plugin = 'Octolize';
23 private array $plugin_settings = [];
24 private array $plugin_settings_masked_fields = ['api_key', 'api_secret', 'client_id', 'client_secret', 'user_id', 'password', 'access_key', 'account_numer'];
25 private array $shipping_method_settings = [];
26 private string $current_page = 'Plugin settings';
27 private array $settings = [];
28 private ?ConsentSettings $consent_settings = null;
29 public function set_webhook_url(string $url): void
30 {
31 $this->settings[self::WEBHOOK_URL] = $url;
32 }
33 public function set_streaming(bool $streaming): void
34 {
35 $this->settings[self::STREAMING] = $streaming;
36 }
37 public function set_initial_messages(array $messages): void
38 {
39 $this->settings[self::INITIAL_MESSAGES] = $messages;
40 }
41 public function set_title(string $title): void
42 {
43 $this->settings[self::TITLE] = $title;
44 }
45 public function set_subtitle(string $subtitle): void
46 {
47 $this->settings[self::SUBTITLE] = $subtitle;
48 }
49 public function set_footer(string $footer): void
50 {
51 $this->settings[self::FOOTER] = $footer;
52 }
53 public function set_input_placeholder(string $placeholder): void
54 {
55 $this->settings[self::INPUT_PLACEHOLDER] = $placeholder;
56 }
57 public function set_metadata(array $metadata): void
58 {
59 $this->settings[self::METADATA] = $metadata;
60 }
61 /**
62 * @param string $key
63 * @param $value
64 *
65 * @return void
66 */
67 public function add_metadata(string $key, $value): void
68 {
69 $this->settings[self::METADATA][$key] = $value;
70 }
71 public function set_plugin_settings(array $settings): void
72 {
73 $this->plugin_settings = $settings;
74 }
75 public function set_get_started(string $get_started): void
76 {
77 $this->settings[self::GET_STARTED] = $get_started;
78 }
79 /**
80 * Enable or disable consent popup explicitly.
81 * When true, consent popup is disabled and chat can initialize without asking.
82 */
83 public function set_consent_disabled(bool $disabled): void
84 {
85 $this->settings[self::CONSENT_DISABLED] = $disabled;
86 }
87 public function set_consent(array $consent): void
88 {
89 $this->consent_settings = ConsentSettings::from_array($consent);
90 }
91 public function set_consent_settings(ConsentSettings $consent_settings): void
92 {
93 $this->consent_settings = $consent_settings;
94 }
95 public function set_shipping_method_settings(array $settings): void
96 {
97 $this->shipping_method_settings = $settings;
98 }
99 public function set_plugin(string $plugin): void
100 {
101 $this->plugin = $plugin;
102 }
103 public function set_current_page(string $page): void
104 {
105 $this->current_page = $page;
106 }
107 public function get_settings(): array
108 {
109 return $this->add_metadata_to_settings($this->prepare_settings());
110 }
111 private function prepare_settings(): array
112 {
113 $settings = $this->settings;
114 if (empty($settings[self::WEBHOOK_URL])) {
115 $settings[self::WEBHOOK_URL] = 'https://n8n.octolize.dev/webhook/5f60a382-151a-49bf-8baa-52b070c11179/chat';
116 }
117 if (empty($settings[self::STREAMING])) {
118 $settings[self::STREAMING] = \false;
119 }
120 if (empty($settings[self::INITIAL_MESSAGES])) {
121 $settings[self::INITIAL_MESSAGES] = [__('Hi there! 👋 I’m here to help you set up and use the plugin.', 'flexible-shipping'), __('You can ask me about:
122 - settings and configuration,
123 - common errors and how to fix them,
124 - integrations with other tools.
125
126 Just tell me what you need help with 🙂', 'flexible-shipping')];
127 }
128 if (empty($settings[self::TITLE])) {
129 $settings[self::TITLE] = __('Hi there! 👋', 'flexible-shipping');
130 }
131 if (empty($settings[self::SUBTITLE])) {
132 $settings[self::SUBTITLE] = __('I’m your AI Assistant. I’ll help you quickly configure the plugin and solve any issues.', 'flexible-shipping');
133 }
134 if (empty($settings[self::INPUT_PLACEHOLDER])) {
135 $settings[self::INPUT_PLACEHOLDER] = __('Type your question to get instant answer..', 'flexible-shipping');
136 }
137 if (empty($settings[self::FOOTER])) {
138 $settings[self::FOOTER] = __('AI can make mistakes. Octolize has access to the conversation held in this chat.', 'flexible-shipping');
139 }
140 if (empty($settings[self::GET_STARTED])) {
141 $settings[self::GET_STARTED] = __('New conversation', 'flexible-shipping');
142 }
143 $settings[self::CONSENT] = ($this->consent_settings ?? new ConsentSettings())->to_array();
144 if (!array_key_exists(self::CONSENT_DISABLED, $settings)) {
145 $settings[self::CONSENT_DISABLED] = \false;
146 }
147 return $settings;
148 }
149 private function add_metadata_to_settings(array $settings): array
150 {
151 return array_merge($settings, [self::METADATA => $this->get_metadata()]);
152 }
153 private function get_metadata(): array
154 {
155 $metadata = $this->settings[self::METADATA] ?? [];
156 $metadata['plugin'] = $this->plugin;
157 $metadata['plugin_settings'] = $this->mask_settings($this->plugin_settings);
158 $metadata['shipping_method_settings'] = $this->shipping_method_settings;
159 $metadata['user_id'] = $this->user_id ?? md5(site_url());
160 $metadata['current_page'] = $this->current_page;
161 $metadata['wc_store_address'] = $this->prepare_store_address();
162 $metadata['wc_shipping_options'] = $this->prepare_shipping_options();
163 return $metadata;
164 }
165 private function prepare_store_address(): array
166 {
167 return ['woocommerce_store_address' => get_option('woocommerce_store_address', ''), 'woocommerce_store_address_2' => get_option('woocommerce_store_address_2', ''), 'woocommerce_store_city' => get_option('woocommerce_store_city', ''), 'woocommerce_store_postcode' => get_option('woocommerce_store_postcode', ''), 'woocommerce_default_country' => get_option('woocommerce_default_country', '')];
168 }
169 private function prepare_shipping_options(): array
170 {
171 return ['woocommerce_allowed_countries' => get_option('woocommerce_allowed_countries', ''), 'woocommerce_ship_to_countries' => get_option('woocommerce_ship_to_countries', ''), 'woocommerce_default_customer_address' => get_option('woocommerce_default_customer_address', '')];
172 }
173 private function mask_settings(array $settings): array
174 {
175 foreach ($settings as $key => $value) {
176 if (in_array($key, $this->plugin_settings_masked_fields, \true)) {
177 $settings[$key] = '********';
178 }
179 }
180 return $settings;
181 }
182 }
183