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