@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | register_activation_hook(__FILE__, array($this, 'pagantisActivation')); |
| 90 | 90 | add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl')); |
| 91 | 91 | add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave')); |
| 92 | - add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate')); |
|
| 93 | - add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave')); |
|
| 92 | + add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate')); |
|
| 93 | + add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave')); |
|
| 94 | 94 | // i18n |
| 95 | - load_plugin_textdomain('pagantis', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); |
|
| 95 | + load_plugin_textdomain('pagantis', false, dirname(plugin_basename(__FILE__)).'/languages'); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | { |
| 119 | 119 | $post_id = $product->get_id(); |
| 120 | 120 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted']; |
| 121 | - if ($pagantis_promoted_value == 'on') { |
|
| 121 | + if ($pagantis_promoted_value=='on') { |
|
| 122 | 122 | $pagantis_promoted_value = 'yes'; |
| 123 | 123 | } else { |
| 124 | 124 | $pagantis_promoted_value = 'no'; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | public function pagantisPromotedVarSave($post_id) |
| 153 | 153 | { |
| 154 | 154 | $pagantis_promoted_value = $_POST['pagantis_promoted']; |
| 155 | - if ($pagantis_promoted_value == null) { |
|
| 155 | + if ($pagantis_promoted_value==null) { |
|
| 156 | 156 | $pagantis_promoted_value = 'no'; |
| 157 | 157 | } |
| 158 | 158 | update_post_meta($post_id, 'custom_product_pagantis_promoted', esc_attr($pagantis_promoted_value)); |
@@ -165,8 +165,8 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | public function loadPagantisTranslation($mofile, $domain) |
| 167 | 167 | { |
| 168 | - if ('pagantis' === $domain) { |
|
| 169 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 168 | + if ('pagantis'===$domain) { |
|
| 169 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 170 | 170 | } |
| 171 | 171 | return $mofile; |
| 172 | 172 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | global $wpdb; |
| 180 | 180 | |
| 181 | 181 | $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
| 182 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
| 182 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
| 183 | 183 | $charset_collate = $wpdb->get_charset_collate(); |
| 184 | 184 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
| 185 | 185 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 191 | 191 | |
| 192 | 192 | //Check if table exists |
| 193 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
| 193 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
| 194 | 194 | if ($tableExists) { |
| 195 | 195 | $charset_collate = $wpdb->get_charset_collate(); |
| 196 | 196 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | //Updated value field to adapt to new length < v8.0.1 |
| 206 | 206 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'"; |
| 207 | 207 | $results = $wpdb->get_results($query, ARRAY_A); |
| 208 | - if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') { |
|
| 208 | + if ($results['0']['COLUMN_TYPE']=='varchar(100)') { |
|
| 209 | 209 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)"; |
| 210 | 210 | $wpdb->query($sql); |
| 211 | 211 | } |
@@ -215,9 +215,9 @@ discard block |
||
| 215 | 215 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'"; |
| 216 | 216 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A); |
| 217 | 217 | foreach ($dbCurrentConfig as $item) { |
| 218 | - if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
| 218 | + if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { |
|
| 219 | 219 | $css_price_selector = $this->preparePriceSelector($item['value']); |
| 220 | - if ($item['value'] != $css_price_selector) { |
|
| 220 | + if ($item['value']!=$css_price_selector) { |
|
| 221 | 221 | $wpdb->update( |
| 222 | 222 | $tableName, |
| 223 | 223 | array('value' => stripslashes($css_price_selector)), |
@@ -226,9 +226,9 @@ discard block |
||
| 226 | 226 | array('%s') |
| 227 | 227 | ); |
| 228 | 228 | } |
| 229 | - } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
| 229 | + } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { |
|
| 230 | 230 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']); |
| 231 | - if ($item['value'] != $css_quantity_selector) { |
|
| 231 | + if ($item['value']!=$css_quantity_selector) { |
|
| 232 | 232 | $wpdb->update( |
| 233 | 233 | $tableName, |
| 234 | 234 | array('value' => stripslashes($css_quantity_selector)), |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 246 | 246 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'"; |
| 247 | 247 | $results = $wpdb->get_results($query, ARRAY_A); |
| 248 | - if (count($results) == 0) { |
|
| 248 | + if (count($results)==0) { |
|
| 249 | 249 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value' => '.'), array('%s', '%s')); |
| 250 | 250 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value' => ','), array('%s', '%s')); |
| 251 | 251 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 255 | 255 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'"; |
| 256 | 256 | $results = $wpdb->get_results($query, ARRAY_A); |
| 257 | - if (count($results) == 0) { |
|
| 257 | + if (count($results)==0) { |
|
| 258 | 258 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value' => '0'), array('%s', '%s')); |
| 259 | 259 | } |
| 260 | 260 | |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 263 | 263 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'"; |
| 264 | 264 | $results = $wpdb->get_results($query, ARRAY_A); |
| 265 | - if (count($results) == 0) { |
|
| 265 | + if (count($results)==0) { |
|
| 266 | 266 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value' => 'default'), array('%s', '%s')); |
| 267 | 267 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value' => 'default'), array('%s', '%s')); |
| 268 | 268 | } |
@@ -271,17 +271,17 @@ discard block |
||
| 271 | 271 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 272 | 272 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'"; |
| 273 | 273 | $results = $wpdb->get_results($query, ARRAY_A); |
| 274 | - if (count($results) == 0) { |
|
| 274 | + if (count($results)==0) { |
|
| 275 | 275 | $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value' => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s')); |
| 276 | 276 | $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s')); |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | //Adapting to variable selector < v8.3.6 |
| 280 | - $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
| 280 | + $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price"; |
|
| 281 | 281 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 282 | 282 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'"; |
| 283 | 283 | $results = $wpdb->get_results($query, ARRAY_A); |
| 284 | - if (count($results) == 0) { |
|
| 284 | + if (count($results)==0) { |
|
| 285 | 285 | $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s')); |
| 286 | 286 | } |
| 287 | 287 | |
@@ -329,9 +329,9 @@ discard block |
||
| 329 | 329 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
| 330 | 330 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
| 331 | 331 | $totalPrice = $product->get_price(); |
| 332 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
| 333 | - if ($cfg['enabled'] !== 'yes' || $cfg['pagantis_public_key'] == '' || $cfg['pagantis_private_key'] == '' || |
|
| 334 | - $cfg['simulator'] !== 'yes' || !$allowedCountry || !$validAmount) { |
|
| 332 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
| 333 | + if ($cfg['enabled']!=='yes' || $cfg['pagantis_public_key']=='' || $cfg['pagantis_private_key']=='' || |
|
| 334 | + $cfg['simulator']!=='yes' || !$allowedCountry || !$validAmount) { |
|
| 335 | 335 | return; |
| 336 | 336 | } |
| 337 | 337 | |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | */ |
| 371 | 371 | public function addPagantisGateway($methods) |
| 372 | 372 | { |
| 373 | - if (! class_exists('WC_Payment_Gateway')) { |
|
| 373 | + if (!class_exists('WC_Payment_Gateway')) { |
|
| 374 | 374 | return $methods; |
| 375 | 375 | } |
| 376 | 376 | |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | */ |
| 426 | 426 | public function pagantisRowMeta($links, $file) |
| 427 | 427 | { |
| 428 | - if ($file == plugin_basename(__FILE__)) { |
|
| 428 | + if ($file==plugin_basename(__FILE__)) { |
|
| 429 | 429 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
| 430 | 430 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
| 431 | 431 | __('API documentation', 'pagantis').'</a>'; |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
| 454 | 454 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
| 455 | 455 | $results = $wpdb->get_results($query); |
| 456 | - if (isset($results) && $privateKey == $secretKey) { |
|
| 456 | + if (isset($results) && $privateKey==$secretKey) { |
|
| 457 | 457 | foreach ($results as $key => $result) { |
| 458 | 458 | $response[$key]['timestamp'] = $result->createdAt; |
| 459 | 459 | $response[$key]['log'] = json_decode($result->log); |
@@ -480,12 +480,12 @@ discard block |
||
| 480 | 480 | |
| 481 | 481 | $filters = ($data->get_params()); |
| 482 | 482 | $secretKey = $filters['secret']; |
| 483 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 483 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 484 | 484 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
| 485 | - if ($privateKey != $secretKey) { |
|
| 485 | + if ($privateKey!=$secretKey) { |
|
| 486 | 486 | $response['status'] = 401; |
| 487 | 487 | $response['result'] = 'Unauthorized'; |
| 488 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 488 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
| 489 | 489 | if (count($_POST)) { |
| 490 | 490 | foreach ($_POST as $config => $value) { |
| 491 | 491 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; |
| 546 | 546 | $results = $wpdb->get_results($query); |
| 547 | 547 | |
| 548 | - if (isset($results) && $privateKey == $secretKey) { |
|
| 548 | + if (isset($results) && $privateKey==$secretKey) { |
|
| 549 | 549 | foreach ($results as $result) { |
| 550 | 550 | $key = $result->ID; |
| 551 | 551 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | */ |
| 630 | 630 | private function prepareQuantitySelector($css_quantity_selector) |
| 631 | 631 | { |
| 632 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
| 632 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
| 633 | 633 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
| 634 | 634 | } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
| 635 | 635 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | */ |
| 646 | 646 | private function preparePriceSelector($css_price_selector) |
| 647 | 647 | { |
| 648 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
| 648 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
| 649 | 649 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
| 650 | 650 | } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
| 651 | 651 | $css_price_selector = serialize(array($css_price_selector)); |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | { |
| 664 | 664 | $metaProduct = get_post_meta($product_id); |
| 665 | 665 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
| 666 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
| 666 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
| 667 | 667 | } |
| 668 | 668 | } |
| 669 | 669 | |