PluginProbe
seQura / 4.3.0
seQura v4.3.0
4.3.4 4.3.3 4.3.2 4.3.1 trunk 2.0.0 2.0.10 2.0.11 2.0.12 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0.0 3.0.2 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 4.0.0 All 30 releases
← All changes | src/Controllers/Hooks/Asset/class-assets-controller.php +143 -118 3.0.54.3.0 View file →
@@ -8,14 +8,14 @@
8 8
9 9 namespace SeQura\WC\Controllers\Hooks\Asset;
10 10
11 11 use SeQura\WC\Controllers\Controller;
12 -use SeQura\WC\Core\Extension\Infrastructure\Configuration\Configuration;
13 -use SeQura\WC\Services\Assets\Interface_Assets;
14 12 use SeQura\WC\Services\I18n\Interface_I18n;
15 -use SeQura\WC\Services\Interface_Logger_Service;
13 +use SeQura\WC\Services\Log\Interface_Logger_Service;
16 14 use SeQura\WC\Services\Payment\Interface_Payment_Method_Service;
17 -use SeQura\WC\Services\Regex\Interface_Regex;
15 +use SeQura\Core\Infrastructure\Utility\RegexProvider;
16 +use SeQura\WC\Services\Service\Interface_Settings_Service;
17 +use SeQura\WC\Services\Widgets\Interface_Widgets_Service;
18 18
19 19 /**
20 20 * Define the assets related functionality
21 21 */
@@ -23,8 +23,9 @@
23 23
24 24 private const HANDLE_SETTINGS_PAGE = 'sequra-settings';
25 25 private const HANDLE_CHECKOUT = 'sequra-checkout';
26 26 private const HANDLE_WIDGET = 'sequra-widget';
27 + private const HANDLE_CONFIG_PARAMS = 'sequra-config-params';
27 28 private const HANDLE_CORE = 'sequra-core';
28 29 private const INTEGRATION_CORE_VERSION = '1.0.0';
29 30 private const STRATEGY_DEFER = 'defer';
30 31
@@ -65,20 +66,13 @@
65 66
66 67 /**
67 68 * Settings service
68 69 *
69 - * @var Configuration
70 + * @var Interface_Settings_Service
70 71 */
71 - private $configuration;
72 + private $settings_service;
72 73
73 74 /**
74 - * Assets service
75 - *
76 - * @var Interface_Assets
77 - */
78 - private $assets;
79 -
80 - /**
81 75 * Payment method service
82 76 *
83 77 * @var Interface_Payment_Method_Service
84 78 */
@@ -86,13 +80,20 @@
86 80
87 81 /**
88 82 * Regex service
89 83 *
90 - * @var Interface_Regex
84 + * @var RegexProvider
91 85 */
92 86 private $regex;
93 87
94 88 /**
89 + * Widgets service
90 + *
91 + * @var Interface_Widgets_Service
92 + */
93 + private $widgets_service;
94 +
95 + /**
95 96 * Constructor
96 97 */
97 98 public function __construct(
98 99 string $assets_dir_url,
@@ -101,12 +102,12 @@
101 102 string $wp_version,
102 103 Interface_I18n $i18n,
103 104 Interface_Logger_Service $logger,
104 105 string $templates_path,
105 - Configuration $configuration,
106 - Interface_Assets $assets,
106 + Interface_Settings_Service $settings_service,
107 107 Interface_Payment_Method_Service $payment_method_service,
108 - Interface_Regex $regex
108 + RegexProvider $regex,
109 + Interface_Widgets_Service $widgets_service
109 110 ) {
110 111 parent::__construct( $logger, $templates_path );
111 112 $this->assets_dir_url = $assets_dir_url;
112 113 $this->assets_dir_path = $assets_dir_path;
@@ -112,13 +113,13 @@
112 113 $this->assets_dir_path = $assets_dir_path;
113 114 $this->assets_version = $assets_version;
114 115 $this->i18n = $i18n;
115 116 $this->logger = $logger;
116 - $this->configuration = $configuration;
117 - $this->assets = $assets;
117 + $this->settings_service = $settings_service;
118 118 $this->payment_method_service = $payment_method_service;
119 119 $this->regex = $regex;
120 120 $this->wp_version = $wp_version;
121 + $this->widgets_service = $widgets_service;
121 122 }
122 123
123 124 /**
124 125 * Enqueue styles and scripts in WP-Admin
@@ -125,19 +126,19 @@
125 126 *
126 127 * @return void
127 128 */
128 129 public function enqueue_admin() {
129 - $this->logger->log_info( 'Hook executed', __FUNCTION__, __CLASS__ );
130 - if ( ! $this->configuration->is_settings_page() ) {
130 + $this->logger->log_debug( 'Hook executed', __FUNCTION__, __CLASS__ );
131 + if ( ! $this->settings_service->is_settings_page() ) {
131 132 return;
132 133 }
133 134 // Styles.
134 - wp_enqueue_style( self::HANDLE_CORE, "{$this->assets_dir_url}/css/sequra-core.css", array(), self::INTEGRATION_CORE_VERSION );
135 + \wp_enqueue_style( self::HANDLE_CORE, "{$this->assets_dir_url}/integration-core-ui/css/sequra-core.css", array(), self::INTEGRATION_CORE_VERSION );
135 136
136 137 // Scripts.
137 - wp_register_script( self::HANDLE_SETTINGS_PAGE, "{$this->assets_dir_url}/js/dist/page/settings.min.js", array(), $this->assets_version, true );
138 - wp_localize_script( self::HANDLE_SETTINGS_PAGE, 'SequraFE', $this->get_sequra_fe_l10n() );
139 - wp_enqueue_script( self::HANDLE_SETTINGS_PAGE );
138 + \wp_register_script( self::HANDLE_SETTINGS_PAGE, "{$this->assets_dir_url}/js/dist/page/settings.min.js", array(), $this->assets_version, true );
139 + \wp_localize_script( self::HANDLE_SETTINGS_PAGE, 'SequraFE', $this->get_sequra_fe_l10n() );
140 + \wp_enqueue_script( self::HANDLE_SETTINGS_PAGE );
140 141 }
141 142
142 143 /**
143 144 * Get the SequraFE object
@@ -145,88 +146,83 @@
145 146 * @return mixed[]
146 147 */
147 148 private function get_sequra_fe_l10n(): array {
148 149 $connection_config = array(
149 - 'getConnectionDataUrl' => get_rest_url( null, 'sequra/v1/onboarding/data/{storeId}' ),
150 + 'getConnectionDataUrl' => \get_rest_url( null, 'sequra/v1/onboarding/data/{storeId}' ),
151 + 'getDeploymentsUrl' => \get_rest_url( null, 'sequra/v1/onboarding/deployments/{storeId}' ),
152 + 'getNotConnectedDeploymentsUrl' => \get_rest_url( null, 'sequra/v1/onboarding/deployments/not-connected/{storeId}' ),
150 153 );
151 154 $payment_page_config = array_merge(
152 155 $connection_config,
153 156 array(
154 - 'getPaymentMethodsUrl' => get_rest_url( null, 'sequra/v1/payment/methods/{storeId}/{merchantId}' ),
155 - 'getAllPaymentMethodsUrl' => get_rest_url( null, 'sequra/v1/payment/methods/{storeId}' ),
156 - 'getSellingCountriesUrl' => get_rest_url( null, 'sequra/v1/onboarding/countries/selling/{storeId}' ),
157 - 'getCountrySettingsUrl' => get_rest_url( null, 'sequra/v1/onboarding/countries/{storeId}' ),
158 - 'validateConnectionDataUrl' => get_rest_url( null, 'sequra/v1/onboarding/data/validate/{storeId}' ),
157 + 'getPaymentMethodsUrl' => \get_rest_url( null, 'sequra/v1/payment/methods/{storeId}/{merchantId}' ),
158 + 'getAllAvailablePaymentMethodsUrl' => \get_rest_url( null, 'sequra/v1/payment/methods/{storeId}' ),
159 + 'getSellingCountriesUrl' => \get_rest_url( null, 'sequra/v1/onboarding/countries/selling/{storeId}' ),
160 + 'getCountrySettingsUrl' => \get_rest_url( null, 'sequra/v1/onboarding/countries/{storeId}' ),
161 + 'validateConnectionDataUrl' => \get_rest_url( null, 'sequra/v1/onboarding/data/validate/{storeId}' ),
159 162 )
160 163 );
161 164 $onboarding_page_config = array_merge(
162 165 $payment_page_config,
163 166 array(
164 - 'saveConnectionDataUrl' => get_rest_url( null, 'sequra/v1/onboarding/data/{storeId}' ),
165 - 'saveCountrySettingsUrl' => get_rest_url( null, 'sequra/v1/onboarding/countries/{storeId}' ),
166 - 'getWidgetSettingsUrl' => get_rest_url( null, 'sequra/v1/onboarding/widgets/{storeId}' ),
167 - 'saveWidgetSettingsUrl' => get_rest_url( null, 'sequra/v1/onboarding/widgets/{storeId}' ),
167 + 'saveCountrySettingsUrl' => \get_rest_url( null, 'sequra/v1/onboarding/countries/{storeId}' ),
168 + 'getWidgetSettingsUrl' => \get_rest_url( null, 'sequra/v1/onboarding/widgets/{storeId}' ),
169 + 'saveWidgetSettingsUrl' => \get_rest_url( null, 'sequra/v1/onboarding/widgets/{storeId}' ),
170 + 'disconnectUrl' => \get_rest_url( null, 'sequra/v1/onboarding/data/disconnect/{storeId}' ),
171 + 'connectUrl' => \get_rest_url( null, 'sequra/v1/onboarding/data/connect/{storeId}' ),
168 172 )
169 173 );
170 174 $page_config = array(
171 - 'onboarding' => $onboarding_page_config,
172 - 'settings' => array_merge(
175 + 'onboarding' => $onboarding_page_config,
176 + 'settings' => array_merge(
173 177 $onboarding_page_config,
174 178 array(
175 - 'getShopPaymentMethodsUrl' => '', // Not used in this implementation.
176 - 'getShopCategoriesUrl' => get_rest_url( null, 'sequra/v1/settings/shop-categories/{storeId}' ),
177 - 'getGeneralSettingsUrl' => get_rest_url( null, 'sequra/v1/settings/general/{storeId}' ),
178 - 'saveGeneralSettingsUrl' => get_rest_url( null, 'sequra/v1/settings/general/{storeId}' ),
179 - 'getShopOrderStatusesUrl' => get_rest_url( null, 'sequra/v1/settings/order-status/list/{storeId}' ),
180 - 'getOrderStatusMappingSettingsUrl' => get_rest_url( null, 'sequra/v1/settings/order-status/{storeId}' ),
181 - 'saveOrderStatusMappingSettingsUrl' => get_rest_url( null, 'sequra/v1/settings/order-status/{storeId}' ),
182 - 'disconnectUrl' => get_rest_url( null, 'sequra/v1/onboarding/data/disconnect/{storeId}' ),
179 + 'getShopCategoriesUrl' => \get_rest_url( null, 'sequra/v1/settings/shop-categories/{storeId}' ),
180 + 'getGeneralSettingsUrl' => \get_rest_url( null, 'sequra/v1/settings/general/{storeId}' ),
181 + 'saveGeneralSettingsUrl' => \get_rest_url( null, 'sequra/v1/settings/general/{storeId}' ),
182 + 'getShopOrderStatusesUrl' => \get_rest_url( null, 'sequra/v1/settings/order-status/list/{storeId}' ),
183 + 'getOrderStatusMappingSettingsUrl' => \get_rest_url( null, 'sequra/v1/settings/order-status/{storeId}' ),
184 + 'saveOrderStatusMappingSettingsUrl' => \get_rest_url( null, 'sequra/v1/settings/order-status/{storeId}' ),
183 185 )
184 186 ),
185 - 'payment' => $payment_page_config,
186 - 'transactions' => array_merge(
187 + 'payment' => $payment_page_config,
188 + 'advanced' => array_merge(
187 189 $connection_config,
188 190 array(
189 - 'getTransactionLogsUrl' => get_rest_url( null, 'sequra/v1/log/{storeId}' ),
191 + 'getLogsUrl' => \get_rest_url( null, 'sequra/v1/log/{storeId}' ),
192 + 'removeLogsUrl' => \get_rest_url( null, 'sequra/v1/log/{storeId}' ),
193 + 'getLogsSettingsUrl' => \get_rest_url( null, 'sequra/v1/log/settings/{storeId}' ),
194 + 'saveLogsSettingsUrl' => \get_rest_url( null, 'sequra/v1/log/settings/{storeId}' ),
190 195 )
191 196 ),
192 - 'advanced' => array_merge(
193 - $connection_config,
194 - array(
195 - 'getLogsUrl' => get_rest_url( null, 'sequra/v1/log/{storeId}' ),
196 - 'removeLogsUrl' => get_rest_url( null, 'sequra/v1/log/{storeId}' ),
197 - 'getLogsSettingsUrl' => get_rest_url( null, 'sequra/v1/log/settings/{storeId}' ),
198 - 'saveLogsSettingsUrl' => get_rest_url( null, 'sequra/v1/log/settings/{storeId}' ),
199 - )
200 - ),
201 197 );
202 198
203 199 $state_controller = array(
204 - 'storesUrl' => get_rest_url( null, 'sequra/v1/settings/stores/{storeId}' ),
205 - 'currentStoreUrl' => get_rest_url( null, 'sequra/v1/settings/current-store' ),
206 - 'stateUrl' => get_rest_url( null, 'sequra/v1/settings/state/{storeId}' ),
207 - 'versionUrl' => get_rest_url( null, 'sequra/v1/settings/version/{storeId}' ),
208 - 'shopNameUrl' => get_rest_url( null, 'sequra/v1/settings/shop-name/{storeId}' ),
200 + 'storesUrl' => \get_rest_url( null, 'sequra/v1/settings/stores/{storeId}' ),
201 + 'currentStoreUrl' => \get_rest_url( null, 'sequra/v1/settings/current-store' ),
202 + 'stateUrl' => \get_rest_url( null, 'sequra/v1/settings/state/{storeId}' ),
203 + 'versionUrl' => \get_rest_url( null, 'sequra/v1/settings/version/{storeId}' ),
204 + 'shopNameUrl' => \get_rest_url( null, 'sequra/v1/settings/shop-name/{storeId}' ),
209 205 'pageConfiguration' => $page_config,
210 206 );
211 207
212 - $pages_payment = array( 'methods' );
213 - $sequra_fe = array(
208 + $sequra_fe = array(
209 + 'flags' => array(
210 + 'isShowCheckoutAsHostedPageFieldVisible' => false, // Not used in this implementation.
211 + 'configurableSelectorsForMiniWidgets' => true,
212 + 'isServiceSellingAllowed' => true,
213 + 'isAltPriceSelectorVisible' => true,
214 + ),
214 215 'translations' => array(
215 216 'default' => $this->load_translation(),
216 217 'current' => $this->load_translation( $this->i18n->get_lang() ),
217 218 ),
218 219 'pages' => array(
219 - 'onboarding' => array( 'connect', 'countries', 'widgets' ),
220 + 'onboarding' => array( 'deployments', 'connect', 'countries', 'widgets' ),
220 221 'settings' => array( 'general', 'connection', 'order_status', 'widget' ),
221 - 'payment' => $pages_payment,
222 + 'payment' => array( 'methods' ),
222 223 'advanced' => array( 'debug' ),
223 224 ),
224 - 'integration' => array(
225 - 'authToken' => '', // Not used in this implementation.
226 - 'isMultistore' => count( $this->configuration->get_stores() ) > 1,
227 - 'hasVersion' => version_compare( $this->configuration->get_marketplace_version(), $this->configuration->get_module_version(), '>' ),
228 - ),
229 225 'generalSettings' => array(
230 226 'useHostedPage' => false,
231 227 'useReplacementPaymentMethod' => false,
232 228 'useAllowedIPAddresses' => true,
@@ -233,18 +229,10 @@
233 229 'useOrderReporting' => false,
234 230 ),
235 231 'isPromotional' => false,
236 232 '_state_controller' => $state_controller,
237 - 'customHeader' => array( 'X-WP-Nonce' => wp_create_nonce( 'wp_rest' ) ),
238 -
239 - 'regex' => array(
240 - 'ip' => $this->regex->ip( false ),
241 - 'dateOrDuration' => $this->regex->date_or_duration( false ),
242 - ),
243 - 'miniWidgetLabels' => array(
244 - 'messages' => $this->configuration->get_mini_widget_default_messages(),
245 - 'messagesBelowLimit' => $this->configuration->get_mini_widget_default_messages_below_limit(),
246 - ),
233 + 'customHeader' => array( 'X-WP-Nonce' => \wp_create_nonce( 'wp_rest' ) ),
234 + 'regex' => $this->regex->toArray(),
247 235 );
248 236
249 237 return $sequra_fe;
250 238 }
@@ -254,24 +242,33 @@
254 242 *
255 243 * @return array<string, mixed>
256 244 */
257 245 private function get_sequra_widget_facade_l10n(): array {
258 - $merchant = $this->configuration->get_merchant_ref( $this->i18n->get_current_country() );
259 - $methods = $this->payment_method_service->get_all_widget_compatible_payment_methods( $this->configuration->get_store_id(), $merchant );
260 246 return array(
261 - 'scriptUri' => $this->assets->get_cdn_resource_uri( $this->configuration->get_env(), 'sequra-checkout.min.js' ),
262 - 'thousandSeparator' => wc_get_price_thousand_separator(),
263 - 'decimalSeparator' => wc_get_price_decimal_separator(),
264 - 'locale' => $this->i18n->get_locale(),
265 - 'merchant' => $merchant,
266 - 'assetKey' => $this->configuration->get_assets_key(),
267 - 'products' => array_column( $methods, 'product' ),
268 - 'widgets' => array(),
269 - 'miniWidgets' => array(),
247 + 'widgets' => array(),
248 + 'miniWidgets' => array(),
270 249 );
271 250 }
272 251
273 252 /**
253 + * Get the SequraConfigParams object
254 + *
255 + * @return array<string, mixed>
256 + */
257 + private function get_sequra_config_params_l10n(): array {
258 + $data = $this->widgets_service->get_widget_config_params() ?? array();
259 + return array(
260 + 'scriptUri' => $data['scriptUri'] ?? '',
261 + 'thousandSeparator' => $data['thousandSeparator'] ?? '',
262 + 'decimalSeparator' => $data['decimalSeparator'] ?? '',
263 + 'locale' => $data['locale'] ?? '',
264 + 'merchant' => $data['merchant'] ?? '',
265 + 'assetKey' => $data['assetKey'] ?? '',
266 + 'products' => $data['products'] ?? array(),
267 + );
268 + }
269 +
270 + /**
274 271 * Get the script arguments to enqueue based on the WP version
275 272 *
276 273 * @return array|bool
277 274 */
@@ -288,13 +285,13 @@
288 285 /**
289 286 * Enqueue styles and scripts in Front-End for the checkout page
290 287 */
291 288 private function enqueue_front_checkout(): void {
292 - wp_enqueue_style( self::HANDLE_CHECKOUT, "{$this->assets_dir_url}/css/checkout.css", array(), $this->assets_version );
293 - wp_register_script(
289 + \wp_enqueue_style( self::HANDLE_CHECKOUT, "{$this->assets_dir_url}/css/checkout.css", array(), $this->assets_version );
290 + \wp_register_script(
294 291 self::HANDLE_CHECKOUT,
295 292 "{$this->assets_dir_url}/js/dist/page/checkout.min.js",
296 - array(),
293 + array( self::HANDLE_CONFIG_PARAMS ),
297 294 $this->assets_version,
298 295 $this->get_script_args( self::STRATEGY_DEFER, true )
299 296 );
300 297
@@ -301,9 +298,8 @@
301 298 /**
302 299 * Check if the checkout is a Gutenberg block based version
303 300 *
304 301 * @since 3.0.0
305 - * TODO: Document the hook
306 302 */
307 303 $is_block = apply_filters(
308 304 'sequra_is_block_checkout',
309 305 ! $this->payment_method_service->is_order_pay_page() // TODO: Remove this condition once the block checkout is implemented in the order pay page.
@@ -311,16 +307,36 @@
311 307 && method_exists( 'Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils', 'is_checkout_block_default' )
312 308 && \Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils::is_checkout_block_default()
313 309 );
314 310
315 - wp_localize_script(
311 + /**
312 + * Set the flag to delay the updated checkout event listener
313 + *
314 + * @since 3.2.0
315 + * @param bool $is_updated_checkout_listener_delayed
316 + * @return bool
317 + */
318 + $is_updated_checkout_listener_delayed = (bool) apply_filters( 'sequra_is_updated_checkout_listener_delayed', false );
319 +
320 + /**
321 + * Set the delay for the updated checkout event listener in milliseconds
322 + *
323 + * @since 3.2.0
324 + * @param int $updated_checkout_listener_delay
325 + * @return int
326 + */
327 + $updated_checkout_listener_delay = (int) apply_filters( 'sequra_updated_checkout_listener_delay', 0 );
328 +
329 + \wp_localize_script(
316 330 self::HANDLE_CHECKOUT,
317 331 'SeQuraCheckout',
318 332 array(
319 - 'isBlockCheckout' => $is_block,
333 + 'isBlockCheckout' => $is_block,
334 + 'isUpdatedCheckoutListenerDelayed' => $is_updated_checkout_listener_delayed,
335 + 'updatedCheckoutListenerDelay' => $updated_checkout_listener_delay,
320 336 )
321 337 );
322 - wp_enqueue_script( self::HANDLE_CHECKOUT );
338 + \wp_enqueue_script( self::HANDLE_CHECKOUT );
323 339 }
324 340
325 341 /**
326 342 * Enqueue styles and scripts in Front-End for the widgets
@@ -325,19 +341,18 @@
325 341 /**
326 342 * Enqueue styles and scripts in Front-End for the widgets
327 343 */
328 344 private function enqueue_front_widgets(): void {
329 -
330 - wp_enqueue_style( self::HANDLE_WIDGET, "{$this->assets_dir_url}/css/widget.css", array(), $this->assets_version );
331 - wp_register_script(
345 + \wp_enqueue_style( self::HANDLE_WIDGET, "{$this->assets_dir_url}/css/widget.css", array(), $this->assets_version );
346 + \wp_register_script(
332 347 self::HANDLE_WIDGET,
333 348 "{$this->assets_dir_url}/js/dist/page/widget-facade.min.js",
334 - array(),
349 + array( self::HANDLE_CONFIG_PARAMS ),
335 350 $this->assets_version,
336 351 $this->get_script_args( self::STRATEGY_DEFER, false )
337 352 );
338 - wp_localize_script( self::HANDLE_WIDGET, 'SequraWidgetFacade', $this->get_sequra_widget_facade_l10n() );
339 - wp_enqueue_script( self::HANDLE_WIDGET );
353 + \wp_localize_script( self::HANDLE_WIDGET, 'SequraWidgetFacade', $this->get_sequra_widget_facade_l10n() );
354 + \wp_enqueue_script( self::HANDLE_WIDGET );
340 355 }
341 356
342 357 /**
343 358 * Check if the current post has the widget shortcode in its content
@@ -342,13 +357,13 @@
342 357 /**
343 358 * Check if the current post has the widget shortcode in its content
344 359 */
345 360 private function has_widget_shortcode(): bool {
346 - if ( is_checkout() || is_cart() || ! is_singular() ) {
361 + if ( \is_checkout() || \is_cart() || ! \is_singular() ) {
347 362 return false;
348 363 }
349 364 global $post;
350 - return has_shortcode( $post->post_content, 'sequra_widget' );
365 + return \has_shortcode( $post->post_content, 'sequra_widget' );
351 366 }
352 367
353 368 /**
354 369 * Check if the current post has the cart widget shortcode in its content
@@ -353,13 +368,13 @@
353 368 /**
354 369 * Check if the current post has the cart widget shortcode in its content
355 370 */
356 371 private function has_cart_widget_shortcode(): bool {
357 - if ( is_checkout() || is_product() || ! is_page() ) {
372 + if ( \is_checkout() || \is_product() || ! \is_page() ) {
358 373 return false;
359 374 }
360 375 global $post;
361 - return has_shortcode( $post->post_content, 'sequra_cart_widget' );
376 + return \has_shortcode( $post->post_content, 'sequra_cart_widget' );
362 377 }
363 378
364 379 /**
365 380 * Check if the current post has the cart widget shortcode in its content
@@ -364,13 +379,13 @@
364 379 /**
365 380 * Check if the current post has the cart widget shortcode in its content
366 381 */
367 382 private function has_product_listing_widget_shortcode(): bool {
368 - if ( is_checkout() || is_product() || is_cart() || ! is_page() ) {
383 + if ( \is_checkout() || \is_product() || \is_cart() || ! \is_page() ) {
369 384 return false;
370 385 }
371 386 global $post;
372 - return has_shortcode( $post->post_content, 'sequra_product_listing_widget' );
387 + return \has_shortcode( $post->post_content, 'sequra_product_listing_widget' );
373 388 }
374 389
375 390 /**
376 391 * Enqueue styles and scripts in Front-End
@@ -377,20 +392,30 @@
377 392 *
378 393 * @return void
379 394 */
380 395 public function enqueue_front() {
381 - $this->logger->log_info( 'Hook executed', __FUNCTION__, __CLASS__ );
396 + $this->logger->log_debug( 'Hook executed', __FUNCTION__, __CLASS__ );
397 +
398 + \wp_register_script(
399 + self::HANDLE_CONFIG_PARAMS,
400 + "{$this->assets_dir_url}/js/dist/page/sequra-config-params.min.js",
401 + array(),
402 + $this->assets_version,
403 + $this->get_script_args( self::STRATEGY_DEFER, false )
404 + );
405 + \wp_localize_script( self::HANDLE_CONFIG_PARAMS, 'SequraConfigParams', $this->get_sequra_config_params_l10n() );
406 +
382 407 if ( $this->payment_method_service->is_checkout() ) {
383 408 $this->enqueue_front_checkout();
384 409 }
385 410
386 - if ( is_product()
411 + if ( \is_product()
387 412 || $this->has_widget_shortcode()
388 - || is_cart()
413 + || \is_cart()
389 414 || $this->has_cart_widget_shortcode()
390 - || is_product_category()
391 - || is_product_tag()
392 - || is_shop()
415 + || \is_product_category()
416 + || \is_product_tag()
417 + || \is_shop()
393 418 || $this->has_product_listing_widget_shortcode() ) {
394 419 $this->enqueue_front_widgets();
395 420 }
396 421 }
@@ -401,9 +426,9 @@
401 426 * @param string $lang Language code.
402 427 * @return mixed[]
403 428 */
404 429 private function load_translation( $lang = 'en' ): array {
405 - $path = "{$this->assets_dir_path}/lang/{$lang}.json";
430 + $path = "{$this->assets_dir_path}/integration-core-ui/lang/{$lang}.json";
406 431 $translations = array();
407 432
408 433 global $wp_filesystem;
409 434 require_once ABSPATH . '/wp-admin/includes/file.php';