@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | function requireWPPluginFunctions() |
3 | 3 | { |
4 | - if (! function_exists('is_plugin_active')) { |
|
5 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
4 | + if (!function_exists('is_plugin_active')) { |
|
5 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
6 | 6 | } |
7 | 7 | } |
8 | 8 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | function getConfigValue($configKey) |
21 | 21 | { |
22 | 22 | global $wpdb; |
23 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
23 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
24 | 24 | $value = $wpdb->get_var($wpdb->prepare("SELECT value FROM $tableName WHERE config= %s ", $configKey)); |
25 | 25 | |
26 | 26 | return $value; |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | function isPgTableCreated($tableToCheck) |
38 | 38 | { |
39 | 39 | global $wpdb; |
40 | - $tableName = $wpdb->prefix . $tableToCheck; |
|
41 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) { |
|
40 | + $tableName = $wpdb->prefix.$tableToCheck; |
|
41 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")==$tableName) { |
|
42 | 42 | return true; |
43 | 43 | } |
44 | 44 | |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | function createPgCartTable() |
52 | 52 | { |
53 | 53 | global $wpdb; |
54 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
54 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
55 | 55 | $charset_collate = $wpdb->get_charset_collate(); |
56 | 56 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
57 | 57 | UNIQUE KEY id (id)) $charset_collate"; |
58 | 58 | |
59 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
59 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
60 | 60 | dbDelta($sql); |
61 | 61 | } |
62 | 62 | |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | { |
65 | 65 | global $wpdb; |
66 | 66 | $charset_collate = $wpdb->get_charset_collate(); |
67 | - $LogsTableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
67 | + $LogsTableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
68 | 68 | $sqlQuery = "CREATE TABLE $LogsTableName ( |
69 | 69 | id int NOT NULL AUTO_INCREMENT, |
70 | 70 | log text NOT NULL, |
71 | 71 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, |
72 | 72 | UNIQUE KEY id (id)) |
73 | 73 | $charset_collate"; |
74 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
74 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
75 | 75 | dbDelta($sqlQuery); |
76 | 76 | } |
77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | function insertLogEntry($exception = null, $message = null) |
83 | 83 | { |
84 | 84 | global $wpdb; |
85 | - if (! isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
85 | + if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
86 | 86 | createLogsTable(); |
87 | 87 | } |
88 | 88 | $logEntry = new Pagantis\ModuleUtils\Model\Log\LogEntry(); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } else { |
92 | 92 | $logEntry = $logEntry->info($message); |
93 | 93 | } |
94 | - $tableName = $wpdb->prefix . PG_LOGS_TABLE_NAME; |
|
94 | + $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
|
95 | 95 | $wpdb->insert($tableName, array('log' => $logEntry->toJson())); |
96 | 96 | } |
97 | 97 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | $pgDecimalSeparator = getPgSimulatorDecimalSeparatorConfig(); |
104 | 104 | $wc_decimal_sep = get_option('woocommerce_price_decimal_sep'); |
105 | - if (stripslashes($wc_decimal_sep) == stripslashes($pgDecimalSeparator)) { |
|
105 | + if (stripslashes($wc_decimal_sep)==stripslashes($pgDecimalSeparator)) { |
|
106 | 106 | return true; |
107 | 107 | } else { |
108 | 108 | return false; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | { |
118 | 118 | $pgThousandSeparator = getPgSimulatorThousandsSeparator(); |
119 | 119 | $wc_price_thousand = get_option('woocommerce_price_thousand_sep'); |
120 | - if (stripslashes($wc_price_thousand) == stripslashes($pgThousandSeparator)) { |
|
120 | + if (stripslashes($wc_price_thousand)==stripslashes($pgThousandSeparator)) { |
|
121 | 121 | return true; |
122 | 122 | } else { |
123 | 123 | return false; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | function getPgSimulatorThousandsSeparator() |
131 | 131 | { |
132 | 132 | global $wpdb; |
133 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
133 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
134 | 134 | $query = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
135 | 135 | $result = $wpdb->get_row($query, ARRAY_A); |
136 | 136 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | function getPgSimulatorDecimalSeparatorConfig() |
144 | 144 | { |
145 | 145 | global $wpdb; |
146 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
146 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
147 | 147 | $query = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'"; |
148 | 148 | $result = $wpdb->get_row($query, ARRAY_A); |
149 | 149 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | if (areThousandsSeparatorEqual()) { |
157 | 157 | return; |
158 | 158 | } |
159 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
159 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
160 | 160 | $thousandSeparator = get_option('woocommerce_price_thousand_sep'); |
161 | 161 | $wpdb->update( |
162 | 162 | $tableName, |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | if (areDecimalSeparatorEqual()) { |
174 | 174 | return; |
175 | 175 | } |
176 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
176 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
177 | 177 | $decimalSeparator = get_option('woocommerce_price_decimal_sep'); |
178 | 178 | $wpdb->update( |
179 | 179 | $tableName, |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | function isSimulatorTypeValid($simulatorType, $validSimulatorTypes) |
195 | 195 | { |
196 | - if (! in_array($simulatorType, $validSimulatorTypes)) { |
|
196 | + if (!in_array($simulatorType, $validSimulatorTypes)) { |
|
197 | 197 | return false; |
198 | 198 | } |
199 | 199 | |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | function areMerchantKeysSet() |
221 | 221 | { |
222 | 222 | $settings = get_option('woocommerce_pagantis_settings'); |
223 | - $publicKey = ! empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : ''; |
|
224 | - $privateKey = ! empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : ''; |
|
223 | + $publicKey = !empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : ''; |
|
224 | + $privateKey = !empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : ''; |
|
225 | 225 | if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { |
226 | 226 | return false; |
227 | 227 | } |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | function areMerchantKeysSet4x() |
233 | 233 | { |
234 | 234 | $settings = get_option('woocommerce_pagantis_settings'); |
235 | - $publicKey = ! empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : ''; |
|
236 | - $privateKey = ! empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : ''; |
|
235 | + $publicKey = !empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : ''; |
|
236 | + $privateKey = !empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : ''; |
|
237 | 237 | if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { |
238 | 238 | return false; |
239 | 239 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | function isSimulatorEnabled() |
245 | 245 | { |
246 | 246 | $settings = get_option('woocommerce_pagantis_settings'); |
247 | - if ((! empty($settings['simulator']) && 'yes' === $settings['simulator']) ? true : false) { |
|
247 | + if ((!empty($settings['simulator']) && 'yes'===$settings['simulator']) ? true : false) { |
|
248 | 248 | return true; |
249 | 249 | } |
250 | 250 | |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | { |
256 | 256 | $settings = get_option('woocommerce_pagantis_settings'); |
257 | 257 | |
258 | - return (! empty($settings['enabled']) && 'yes' === $settings['enabled']); |
|
258 | + return (!empty($settings['enabled']) && 'yes'===$settings['enabled']); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | function isPluginEnabled4x() |
262 | 262 | { |
263 | 263 | $settings = get_option('woocommerce_pagantis_settings'); |
264 | - return (! empty($settings['enabled_4x']) && 'yes' === $settings['enabled_4x']); |
|
264 | + return (!empty($settings['enabled_4x']) && 'yes'===$settings['enabled_4x']); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | { |
270 | 270 | $locale = strtolower(strstr(get_locale(), '_', true)); |
271 | 271 | $allowedCountries = maybe_unserialize(getConfigValue('PAGANTIS_ALLOWED_COUNTRIES')); |
272 | - if (! in_array(strtolower($locale), $allowedCountries)) { |
|
272 | + if (!in_array(strtolower($locale), $allowedCountries)) { |
|
273 | 273 | return false; |
274 | 274 | } |
275 | 275 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | global $product; |
287 | 287 | if (method_exists($product, 'get_price')) { |
288 | 288 | $productPrice = $product->get_price(); |
289 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0')); |
|
289 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0')); |
|
290 | 290 | if ($validAmount) { |
291 | 291 | return true; |
292 | 292 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | global $product; |
306 | 306 | if (method_exists($product, 'get_price')) { |
307 | 307 | $productPrice = $product->get_price(); |
308 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0')); |
|
308 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0')); |
|
309 | 309 | if ($validAmount) { |
310 | 310 | return true; |
311 | 311 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | function getExtraConfig() |
325 | 325 | { |
326 | 326 | global $wpdb; |
327 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME; |
|
327 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
|
328 | 328 | $response = array(); |
329 | 329 | $dbResult = $wpdb->get_results("select config, value from $tableName", ARRAY_A); |
330 | 330 | foreach ($dbResult as $value) { |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | function getModuleVersion() |
338 | 338 | { |
339 | 339 | |
340 | - $mainFile = plugin_dir_path(PG_WC_MAIN_FILE). '/WC_Pagantis.php'; |
|
340 | + $mainFile = plugin_dir_path(PG_WC_MAIN_FILE).'/WC_Pagantis.php'; |
|
341 | 341 | $version = get_file_data($mainFile, array('Version' => 'Version'), false); |
342 | 342 | return $version['Version']; |
343 | 343 | } |
@@ -349,9 +349,9 @@ discard block |
||
349 | 349 | */ |
350 | 350 | function getNationalId($order) |
351 | 351 | { |
352 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
352 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
353 | 353 | $data = $mdObject->get_data(); |
354 | - if ($data['key'] == 'vat_number') { |
|
354 | + if ($data['key']=='vat_number') { |
|
355 | 355 | return $data['value']; |
356 | 356 | } |
357 | 357 | } |
@@ -366,9 +366,9 @@ discard block |
||
366 | 366 | */ |
367 | 367 | function getTaxId($order) |
368 | 368 | { |
369 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
369 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
370 | 370 | $data = $mdObject->get_data(); |
371 | - if ($data['key'] == 'billing_cfpiva') { |
|
371 | + if ($data['key']=='billing_cfpiva') { |
|
372 | 372 | return $data['value']; |
373 | 373 | } |
374 | 374 | } |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | $metaProduct = get_post_meta($product_id); |
386 | 386 | |
387 | 387 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) |
388 | - && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
388 | + && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | $promotedAmount = 0; |
397 | 397 | foreach (WC()->cart->get_cart() as $key => $item) { |
398 | 398 | $promotedProduct = isProductPromoted($item['product_id']); |
399 | - if ($promotedProduct == 'true') { |
|
399 | + if ($promotedProduct=='true') { |
|
400 | 400 | $promotedAmount += $item['line_total'] + $item['line_tax']; |
401 | 401 | } |
402 | 402 | } |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | { |
415 | 415 | global $wpdb; |
416 | 416 | checkCartProcessTable(); |
417 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
417 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
418 | 418 | $wpdb->insert($tableName, array('id' => $orderId, 'order_id' => $pagantisOrderId, 'token' => $token), array('%d', '%s', '%s')); |
419 | 419 | } |
420 | 420 | |
@@ -424,14 +424,14 @@ discard block |
||
424 | 424 | function checkCartProcessTable() |
425 | 425 | { |
426 | 426 | global $wpdb; |
427 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE; |
|
427 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE; |
|
428 | 428 | |
429 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
429 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
430 | 430 | $charset_collate = $wpdb->get_charset_collate(); |
431 | 431 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), token varchar(32) |
432 | 432 | UNIQUE KEY id (id)) $charset_collate"; |
433 | 433 | |
434 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
434 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
435 | 435 | dbDelta($sql); |
436 | 436 | } |
437 | 437 | } |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
475 | 475 | )); |
476 | 476 | foreach ($customer_orders as $customer_order) { |
477 | - if (trim($sign_up) == '' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) { |
|
477 | + if (trim($sign_up)=='' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) { |
|
478 | 478 | $sign_up = substr($customer_order->post_date, 0, 10); |
479 | 479 | } |
480 | 480 | } |
@@ -485,5 +485,5 @@ discard block |
||
485 | 485 | |
486 | 486 | function isPagePaymentPage() |
487 | 487 | { |
488 | - return (is_checkout() && ! is_order_received_page()) || is_checkout_pay_page(); |
|
488 | + return (is_checkout() && !is_order_received_page()) || is_checkout_pay_page(); |
|
489 | 489 | } |