@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | |
22 | -require_once(__DIR__ . '/includes/pg-functions.php'); |
|
22 | +require_once(__DIR__.'/includes/pg-functions.php'); |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Required minimums and constants |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | public function __construct() |
82 | 82 | { |
83 | 83 | require_once(plugin_dir_path(__FILE__).'/vendor/autoload.php'); |
84 | - require_once(PG_ABSPATH . '/includes/pg-functions.php'); |
|
84 | + require_once(PG_ABSPATH.'/includes/pg-functions.php'); |
|
85 | 85 | $this->template_path = plugin_dir_path(__FILE__).'/templates/'; |
86 | 86 | |
87 | 87 | $this->pagantisActivation(); |
@@ -97,15 +97,15 @@ discard block |
||
97 | 97 | add_action('init', array($this, 'checkWcPriceSettings'), 10); |
98 | 98 | add_action('woocommerce_after_template_part', array($this, 'pagantisAddSimulatorHtmlDiv'), 10); |
99 | 99 | add_action('woocommerce_single_product_summary', array($this, 'pagantisInitProductSimulator'), 20); |
100 | - add_action('woocommerce_single_variation', array($this,'pagantisAddProductSnippetForVariations'), 30); |
|
100 | + add_action('woocommerce_single_variation', array($this, 'pagantisAddProductSnippetForVariations'), 30); |
|
101 | 101 | add_action('wp_enqueue_scripts', 'add_pagantis_widget_js'); |
102 | 102 | add_action('rest_api_init', array($this, 'pagantisRegisterEndpoint')); //Endpoint |
103 | 103 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
104 | 104 | register_activation_hook(__FILE__, array($this, 'pagantisActivation')); |
105 | 105 | add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl')); |
106 | 106 | add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave')); |
107 | - add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate')); |
|
108 | - add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave')); |
|
107 | + add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate')); |
|
108 | + add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave')); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | { |
132 | 132 | $post_id = $product->get_id(); |
133 | 133 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted']; |
134 | - if ($pagantis_promoted_value === 'on') { |
|
134 | + if ($pagantis_promoted_value==='on') { |
|
135 | 135 | $pagantis_promoted_value = 'yes'; |
136 | 136 | } else { |
137 | 137 | $pagantis_promoted_value = 'no'; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | public function pagantisPromotedVarSave($post_id) |
166 | 166 | { |
167 | 167 | $pagantis_promoted_value = $_POST['pagantis_promoted']; |
168 | - if ($pagantis_promoted_value !== 'yes') { |
|
168 | + if ($pagantis_promoted_value!=='yes') { |
|
169 | 169 | $pagantis_promoted_value = 'no'; |
170 | 170 | } |
171 | 171 | |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function loadPagantisTranslation($mofile, $domain) |
181 | 181 | { |
182 | - if ('pagantis' === $domain) { |
|
183 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
182 | + if ('pagantis'===$domain) { |
|
183 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
184 | 184 | } |
185 | 185 | return $mofile; |
186 | 186 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | global $wpdb; |
194 | 194 | |
195 | 195 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME; |
196 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
196 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
197 | 197 | $charset_collate = $wpdb->get_charset_collate(); |
198 | 198 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
199 | 199 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
205 | 205 | |
206 | 206 | //Check if table exists |
207 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
207 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
208 | 208 | if ($tableExists) { |
209 | 209 | $charset_collate = $wpdb->get_charset_collate(); |
210 | 210 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | //Updated value field to adapt to new length < v8.0.1 |
220 | 220 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'"; |
221 | 221 | $results = $wpdb->get_results($query, ARRAY_A); |
222 | - if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') { |
|
222 | + if ($results['0']['COLUMN_TYPE']=='varchar(100)') { |
|
223 | 223 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)"; |
224 | 224 | $wpdb->query($sql); |
225 | 225 | } |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
230 | 230 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A); |
231 | 231 | foreach ($dbCurrentConfig as $item) { |
232 | - if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
232 | + if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
233 | 233 | $css_price_selector = $this->preparePriceSelector($item['value']); |
234 | - if ($item['value'] != $css_price_selector) { |
|
234 | + if ($item['value']!=$css_price_selector) { |
|
235 | 235 | $wpdb->update( |
236 | 236 | $tableName, |
237 | 237 | array('value' => stripslashes($css_price_selector)), |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | array('%s') |
241 | 241 | ); |
242 | 242 | } |
243 | - } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
243 | + } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
244 | 244 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']); |
245 | - if ($item['value'] != $css_quantity_selector) { |
|
245 | + if ($item['value']!=$css_quantity_selector) { |
|
246 | 246 | $wpdb->update( |
247 | 247 | $tableName, |
248 | 248 | array('value' => stripslashes($css_quantity_selector)), |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | // Making sure DB tables are created < v8.6.9 |
259 | - if (!isPgTableCreated(PG_LOGS_TABLE_NAME)){ |
|
259 | + if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) { |
|
260 | 260 | createLogsTable(); |
261 | 261 | } |
262 | 262 | checkCartProcessTable(); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
266 | 266 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
267 | 267 | $results = $wpdb->get_results($query, ARRAY_A); |
268 | - if (count($results) == 0) { |
|
268 | + if (count($results)==0) { |
|
269 | 269 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), array('%s', '%s')); |
270 | 270 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value' => ','), array('%s', '%s')); |
271 | 271 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
275 | 275 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'"; |
276 | 276 | $results = $wpdb->get_results($query, ARRAY_A); |
277 | - if (count($results) == 0) { |
|
277 | + if (count($results)==0) { |
|
278 | 278 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value' => '0'), array('%s', '%s')); |
279 | 279 | } |
280 | 280 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
283 | 283 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'"; |
284 | 284 | $results = $wpdb->get_results($query, ARRAY_A); |
285 | - if (count($results) == 0) { |
|
285 | + if (count($results)==0) { |
|
286 | 286 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value' => 'default'), array('%s', '%s')); |
287 | 287 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value' => 'default'), array('%s', '%s')); |
288 | 288 | } |
@@ -292,17 +292,17 @@ discard block |
||
292 | 292 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
293 | 293 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'"; |
294 | 294 | $results = $wpdb->get_results($query, ARRAY_A); |
295 | - if (count($results) == 0) { |
|
295 | + if (count($results)==0) { |
|
296 | 296 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value' => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s')); |
297 | 297 | $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s')); |
298 | 298 | } |
299 | 299 | |
300 | 300 | //Adapting to variable selector < v8.3.6 |
301 | - $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
301 | + $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
302 | 302 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
303 | 303 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'"; |
304 | 304 | $results = $wpdb->get_results($query, ARRAY_A); |
305 | - if (count($results) == 0) { |
|
305 | + if (count($results)==0) { |
|
306 | 306 | $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s')); |
307 | 307 | } |
308 | 308 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
311 | 311 | $query = "select * from $tableName where config='PAGANTIS_TITLE_4x'"; |
312 | 312 | $results = $wpdb->get_results($query, ARRAY_A); |
313 | - if (count($results) == 0) { |
|
313 | + if (count($results)==0) { |
|
314 | 314 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_TITLE_4x', 'value' => 'Until 4 installments, without fees'), array('%s', '%s')); |
315 | 315 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MIN_AMOUNT_4x', 'value' => 1), array('%s', '%s')); |
316 | 316 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT_4x', 'value' => 800), array('%s', '%s')); |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
324 | 324 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X'"; |
325 | 325 | $results = $wpdb->get_results($query, ARRAY_A); |
326 | - if (count($results) == 0) { |
|
326 | + if (count($results)==0) { |
|
327 | 327 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X', 'value' => 'default'), array('%s', '%s')); |
328 | 328 | } |
329 | 329 | |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME; |
340 | 340 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
341 | 341 | $results = $wpdb->get_results($query, ARRAY_A); |
342 | - if (count($results) == 0) { |
|
342 | + if (count($results)==0) { |
|
343 | 343 | $wpdb->update($tableName, array('value' => 'a:4:{i:0;s:52:"div.summary *:not(del)>.woocommerce-Price-amount bdi";i:1;s:48:"div.summary *:not(del)>.woocommerce-Price-amount";i:2;s:54:"div.entry-summary *:not(del)>.woocommerce-Price-amount";i:3;s:36:"*:not(del)>.woocommerce-Price-amount";}'), array('config' => 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'), array('%s'), array('%s')); |
344 | 344 | } |
345 | 345 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $isAtcTplPresent = isTemplatePresent( |
433 | 433 | $template_name, |
434 | 434 | array('single-product/add-to-cart/variation-add-to-cart-button.php', |
435 | - 'single-product/add-to-cart/variation.php','single-product/add-to-cart/simple.php') |
|
435 | + 'single-product/add-to-cart/variation.php', 'single-product/add-to-cart/simple.php') |
|
436 | 436 | ); |
437 | 437 | |
438 | 438 | $html = apply_filters('pagantis_simulator_selector_html', '<div class="mainPagantisSimulator"></div><div class="pagantisSimulator"></div>'); |
@@ -444,10 +444,10 @@ discard block |
||
444 | 444 | } |
445 | 445 | |
446 | 446 | $pagantisSimulator4x = 'enabled'; |
447 | - if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) { |
|
447 | + if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) { |
|
448 | 448 | $pagantisSimulator4x = 'disabled'; |
449 | 449 | } |
450 | - if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { |
|
450 | + if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { |
|
451 | 451 | return; |
452 | 452 | } |
453 | 453 | |
@@ -503,12 +503,12 @@ discard block |
||
503 | 503 | $pagantisSimulator4x = 'disabled'; |
504 | 504 | } |
505 | 505 | |
506 | - if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { |
|
506 | + if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { |
|
507 | 507 | return; |
508 | 508 | } |
509 | 509 | |
510 | 510 | $totalPrice = $product->get_price(); |
511 | - $formattedInstallments = number_format($totalPrice/4, 2); |
|
511 | + $formattedInstallments = number_format($totalPrice / 4, 2); |
|
512 | 512 | $simulatorMessage = sprintf(__('or 4 installments of %s€, without fees, with ', 'pagantis'), $formattedInstallments); |
513 | 513 | $post_id = $product->get_id(); |
514 | 514 | $logo = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg'; |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | */ |
552 | 552 | public function addPagantisGateway($methods) |
553 | 553 | { |
554 | - if (! class_exists('WC_Payment_Gateway')) { |
|
554 | + if (!class_exists('WC_Payment_Gateway')) { |
|
555 | 555 | return $methods; |
556 | 556 | } |
557 | 557 | |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | */ |
617 | 617 | public function pagantisRowMeta($links, $file) |
618 | 618 | { |
619 | - if ($file == plugin_basename(__FILE__)) { |
|
619 | + if ($file==plugin_basename(__FILE__)) { |
|
620 | 620 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
621 | 621 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
622 | 622 | __('API documentation', 'pagantis').'</a>'; |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME; |
646 | 646 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
647 | 647 | $results = $wpdb->get_results($query); |
648 | - if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { |
|
648 | + if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { |
|
649 | 649 | foreach ($results as $key => $result) { |
650 | 650 | $response[$key]['timestamp'] = $result->createdAt; |
651 | 651 | $response[$key]['log'] = json_decode($result->log); |
@@ -672,13 +672,13 @@ discard block |
||
672 | 672 | |
673 | 673 | $filters = ($data->get_params()); |
674 | 674 | $secretKey = $filters['secret']; |
675 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
675 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
676 | 676 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
677 | 677 | $privateKey4x = isset($cfg['pagantis_private_key_4x']) ? $cfg['pagantis_private_key_4x'] : null; |
678 | - if ($privateKey != $secretKey && $privateKey4x != $secretKey) { |
|
678 | + if ($privateKey!=$secretKey && $privateKey4x!=$secretKey) { |
|
679 | 679 | $response['status'] = 401; |
680 | 680 | $response['result'] = 'Unauthorized'; |
681 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
681 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
682 | 682 | if (count($_POST)) { |
683 | 683 | foreach ($_POST as $config => $value) { |
684 | 684 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; |
740 | 740 | $results = $wpdb->get_results($query); |
741 | 741 | |
742 | - if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { |
|
742 | + if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { |
|
743 | 743 | foreach ($results as $result) { |
744 | 744 | $key = $result->ID; |
745 | 745 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -812,7 +812,7 @@ discard block |
||
812 | 812 | */ |
813 | 813 | private function prepareQuantitySelector($css_quantity_selector) |
814 | 814 | { |
815 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
815 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
816 | 816 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
817 | 817 | } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
818 | 818 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | */ |
829 | 829 | private function preparePriceSelector($css_price_selector) |
830 | 830 | { |
831 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
831 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
832 | 832 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
833 | 833 | } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
834 | 834 | $css_price_selector = serialize(array($css_price_selector)); |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | { |
847 | 847 | $metaProduct = get_post_meta($product_id); |
848 | 848 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
849 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
849 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
850 | 850 | } |
851 | 851 | |
852 | 852 | /** |