Passed
Pull Request — master (#27)
by
unknown
04:24
created
WC_Pagantis.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
         register_activation_hook(__FILE__, array($this, 'pagantisActivation'));
80 80
         add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl'));
81 81
         add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave'));
82
-        add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate'));
83
-        add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave'));
82
+        add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate'));
83
+        add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave'));
84 84
     }
85 85
 
86 86
     /**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     {
107 107
         $post_id = $product->get_id();
108 108
         $pagantis_promoted_value = $_REQUEST['pagantis_promoted'];
109
-        if ($pagantis_promoted_value == 'on') {
109
+        if ($pagantis_promoted_value=='on') {
110 110
             $pagantis_promoted_value = 'yes';
111 111
         } else {
112 112
             $pagantis_promoted_value = 'no';
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     public function pagantisPromotedVarSave($post_id)
141 141
     {
142 142
         $pagantis_promoted_value = $_POST['pagantis_promoted'];
143
-        if ($pagantis_promoted_value == null) {
143
+        if ($pagantis_promoted_value==null) {
144 144
             $pagantis_promoted_value = 'no';
145 145
         }
146 146
         update_post_meta($post_id, 'custom_product_pagantis_promoted', esc_attr($pagantis_promoted_value));
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
      */
154 154
     public function loadPagantisTranslation($mofile, $domain)
155 155
     {
156
-        if ('pagantis' === $domain) {
157
-            $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo';
156
+        if ('pagantis'===$domain) {
157
+            $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo';
158 158
         }
159 159
         return $mofile;
160 160
     }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         global $wpdb;
168 168
 
169 169
         $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE;
170
-        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
170
+        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
171 171
             $charset_collate = $wpdb->get_charset_collate();
172 172
             $sql = "CREATE TABLE $tableName ( order_id int NOT NULL,  
173 173
                     createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate";
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         $tableName = $wpdb->prefix.self::CONFIG_TABLE;
179 179
 
180 180
         //Check if table exists
181
-        $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName;
181
+        $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName;
182 182
         if ($tableExists) {
183 183
             $charset_collate = $wpdb->get_charset_collate();
184 184
             $sql = "CREATE TABLE IF NOT EXISTS $tableName (
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
             //Updated value field to adapt to new length < v8.0.1
194 194
             $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'";
195 195
             $results = $wpdb->get_results($query, ARRAY_A);
196
-            if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') {
196
+            if ($results['0']['COLUMN_TYPE']=='varchar(100)') {
197 197
                 $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)";
198 198
                 $wpdb->query($sql);
199 199
             }
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
                                or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'";
204 204
             $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A);
205 205
             foreach ($dbCurrentConfig as $item) {
206
-                if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') {
206
+                if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') {
207 207
                     $css_price_selector = $this->preparePriceSelector($item['value']);
208
-                    if ($item['value'] != $css_price_selector) {
208
+                    if ($item['value']!=$css_price_selector) {
209 209
                         $wpdb->update(
210 210
                             $tableName,
211 211
                             array('value' => stripslashes($css_price_selector)),
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
                             array('%s')
215 215
                         );
216 216
                     }
217
-                } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') {
217
+                } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') {
218 218
                     $css_quantity_selector = $this->prepareQuantitySelector($item['value']);
219
-                    if ($item['value'] != $css_quantity_selector) {
219
+                    if ($item['value']!=$css_quantity_selector) {
220 220
                         $wpdb->update(
221 221
                             $tableName,
222 222
                             array('value' => stripslashes($css_quantity_selector)),
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
         $tableName = $wpdb->prefix.self::CONFIG_TABLE;
234 234
         $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'";
235 235
         $results = $wpdb->get_results($query, ARRAY_A);
236
-        if (count($results) == 0) {
236
+        if (count($results)==0) {
237 237
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value'  => '.'), array('%s', '%s'));
238 238
             $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value'  => ','), array('%s', '%s'));
239 239
         }
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
         $locale = strtolower(strstr(get_locale(), '_', true));
280 280
         $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']);
281 281
         $allowedCountry = (in_array(strtolower($locale), $allowedCountries));
282
-        if ($cfg['enabled'] !== 'yes' || $cfg['pagantis_public_key'] == '' || $cfg['pagantis_private_key'] == '' ||
283
-            $cfg['simulator'] !== 'yes' ||  $product->get_price() < $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] ||
284
-            !$allowedCountry ) {
282
+        if ($cfg['enabled']!=='yes' || $cfg['pagantis_public_key']=='' || $cfg['pagantis_private_key']=='' ||
283
+            $cfg['simulator']!=='yes' || $product->get_price() < $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] ||
284
+            !$allowedCountry) {
285 285
             return;
286 286
         }
287 287
 
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      */
317 317
     public function addPagantisGateway($methods)
318 318
     {
319
-        if (! class_exists('WC_Payment_Gateway')) {
319
+        if (!class_exists('WC_Payment_Gateway')) {
320 320
             return $methods;
321 321
         }
322 322
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
      */
372 372
     public function pagantisRowMeta($links, $file)
373 373
     {
374
-        if ($file == plugin_basename(__FILE__)) {
374
+        if ($file==plugin_basename(__FILE__)) {
375 375
             $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>';
376 376
             $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'.
377 377
                        __('API documentation', 'pagantis').'</a>';
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
         $tableName = $wpdb->prefix.self::LOGS_TABLE;
400 400
         $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc";
401 401
         $results = $wpdb->get_results($query);
402
-        if (isset($results) && $privateKey == $secretKey) {
402
+        if (isset($results) && $privateKey==$secretKey) {
403 403
             foreach ($results as $key => $result) {
404 404
                 $response[$key]['timestamp'] = $result->createdAt;
405 405
                 $response[$key]['log']       = json_decode($result->log);
@@ -426,12 +426,12 @@  discard block
 block discarded – undo
426 426
 
427 427
         $filters   = ($data->get_params());
428 428
         $secretKey = $filters['secret'];
429
-        $cfg  = get_option('woocommerce_pagantis_settings');
429
+        $cfg = get_option('woocommerce_pagantis_settings');
430 430
         $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null;
431
-        if ($privateKey != $secretKey) {
431
+        if ($privateKey!=$secretKey) {
432 432
             $response['status'] = 401;
433 433
             $response['result'] = 'Unauthorized';
434
-        } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
434
+        } elseif ($_SERVER['REQUEST_METHOD']=='POST') {
435 435
             if (count($_POST)) {
436 436
                 foreach ($_POST as $config => $value) {
437 437
                     if (isset($this->defaultConfigs[$config]) && $response['status']==null) {
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
                   and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc";
492 492
         $results = $wpdb->get_results($query);
493 493
 
494
-        if (isset($results) && $privateKey == $secretKey) {
494
+        if (isset($results) && $privateKey==$secretKey) {
495 495
             foreach ($results as $result) {
496 496
                 $key = $result->ID;
497 497
                 $response['message'][$key]['timestamp'] = $result->post_date;
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
      */
576 576
     private function prepareQuantitySelector($css_quantity_selector)
577 577
     {
578
-        if ($css_quantity_selector == 'default' || $css_quantity_selector == '') {
578
+        if ($css_quantity_selector=='default' || $css_quantity_selector=='') {
579 579
             $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'];
580 580
         } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it
581 581
             $css_quantity_selector = serialize(array($css_quantity_selector));
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
      */
592 592
     private function preparePriceSelector($css_price_selector)
593 593
     {
594
-        if ($css_price_selector == 'default' || $css_price_selector == '') {
594
+        if ($css_price_selector=='default' || $css_price_selector=='') {
595 595
             $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'];
596 596
         } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it
597 597
             $css_price_selector = serialize(array($css_price_selector));
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
     {
610 610
         $metaProduct = get_post_meta($product_id);
611 611
         return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) &&
612
-                $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false';
612
+                $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false';
613 613
     }
614 614
 }
615 615
 
Please login to merge, or discard this patch.