Passed
Pull Request — master (#169)
by
unknown
02:05
created
classes/class-verify-nonces.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
 /**
12 12
  * Abort if this file is called directly
13 13
  */
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
18
-if ( ! class_exists( 'Algolia_Verify_Nonces' ) ) {
18
+if ( ! class_exists('Algolia_Verify_Nonces')) {
19 19
 	/**
20 20
 	 * Verify submitted nonces
21 21
 	 */
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
 			/**
30 30
 			 * Filter incoming nonces and values
31 31
 			 */
32
-			$settings_nonce = filter_input( INPUT_POST, 'algolia_woo_indexer_admin_api_nonce_name', FILTER_DEFAULT );
32
+			$settings_nonce = filter_input(INPUT_POST, 'algolia_woo_indexer_admin_api_nonce_name', FILTER_DEFAULT);
33 33
 			
34 34
 			/**
35 35
 			 * Return boolean depending on if the nonce has been set
36 36
 			 */
37
-			return isset( $settings_nonce );
37
+			return isset($settings_nonce);
38 38
 
39 39
 		}
40 40
 
@@ -47,22 +47,22 @@  discard block
 block discarded – undo
47 47
 			/**
48 48
 			 * Filter incoming nonces and values
49 49
 			 */
50
-			$send_products_nonce      = filter_input( INPUT_POST, 'send_products_to_algolia_nonce_name', FILTER_DEFAULT );
51
-			$send_products_to_algolia = filter_input( INPUT_POST, 'send_products_to_algolia', FILTER_DEFAULT );
50
+			$send_products_nonce      = filter_input(INPUT_POST, 'send_products_to_algolia_nonce_name', FILTER_DEFAULT);
51
+			$send_products_to_algolia = filter_input(INPUT_POST, 'send_products_to_algolia', FILTER_DEFAULT);
52 52
 
53 53
 			/**
54 54
 			 * Display error and die if nonce is not verified and does not pass security check
55 55
 			 * Also check if the hidden value field send_products_to_algolia is set
56 56
 			 */
57 57
 
58
-			if ( ! wp_verify_nonce( $send_products_nonce, 'send_products_to_algolia_nonce_action' ) && isset( $send_products_to_algolia ) ) {
59
-				wp_die( esc_html__( 'Action is not allowed.', 'algolia-woo-indexer' ), esc_html__( 'Error!', 'algolia-woo-indexer' ) );
58
+			if ( ! wp_verify_nonce($send_products_nonce, 'send_products_to_algolia_nonce_action') && isset($send_products_to_algolia)) {
59
+				wp_die(esc_html__('Action is not allowed.', 'algolia-woo-indexer'), esc_html__('Error!', 'algolia-woo-indexer'));
60 60
 			}
61 61
 
62 62
 			/**
63 63
 			 * If we have verified the send_products_nonce and the send_products hidden field is set, return true
64 64
 			 */
65
-			if ( wp_verify_nonce( $send_products_nonce, 'send_products_to_algolia_nonce_action' ) && isset( $send_products_to_algolia ) ) {
65
+			if (wp_verify_nonce($send_products_nonce, 'send_products_to_algolia_nonce_action') && isset($send_products_to_algolia)) {
66 66
 				return true;
67 67
 			}
68 68
 		}
Please login to merge, or discard this patch.
classes/class-algolia-woo-indexer.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -16,18 +16,18 @@  discard block
 block discarded – undo
16 16
 /**
17 17
  * Abort if this file is called directly
18 18
  */
19
-if (!defined('ABSPATH')) {
19
+if ( ! defined('ABSPATH')) {
20 20
     exit;
21 21
 }
22 22
 
23 23
 /**
24 24
  * Include plugin file if function is_plugin_active does not exist
25 25
  */
26
-if (!function_exists('is_plugin_active')) {
26
+if ( ! function_exists('is_plugin_active')) {
27 27
     require_once(ABSPATH . '/wp-admin/includes/plugin.php');
28 28
 }
29 29
 
30
-if (!class_exists('Algolia_Woo_Indexer')) {
30
+if ( ! class_exists('Algolia_Woo_Indexer')) {
31 31
     /**
32 32
      * Algolia WooIndexer main class
33 33
      */
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
              * But I have still done it to be 100% safe
229 229
              */
230 230
             $auto_send = get_option(ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS);
231
-            $auto_send = (!empty($auto_send)) ? 1 : 0; ?>
231
+            $auto_send = ( ! empty($auto_send)) ? 1 : 0; ?>
232 232
             <input id="algolia_woo_indexer_automatically_send_new_products" name="algolia_woo_indexer_automatically_send_new_products[checked]" type="checkbox" <?php checked(1, $auto_send); ?> />
233 233
         <?php
234 234
         }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
         public static function algolia_woo_indexer_field_output($args)
242 242
         {
243 243
             $value = get_option(ALGOWOO_DB_OPTION . BASIC_FIELD_PREFIX . $args["name"]);
244
-            $isChecked = (!empty($value)) ? 1 : 0;
244
+            $isChecked = ( ! empty($value)) ? 1 : 0;
245 245
         ?>
246 246
             <input id="<?php echo $args["label_for"] ?>" name="<?php echo $args["label_for"] ?>[checked]" type="checkbox" <?php checked(1, $isChecked); ?> />
247 247
         <?php
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
         public static function algolia_woo_indexer_attributes_enabled_output()
256 256
         {
257 257
             $value = get_option(ALGOWOO_DB_OPTION . ATTRIBUTES_ENABLED);
258
-            $isChecked = (!empty($value)) ? 1 : 0;
258
+            $isChecked = ( ! empty($value)) ? 1 : 0;
259 259
         ?>
260 260
             <input id="algolia_woo_indexer_attributes_enabled" name="algolia_woo_indexer_attributes_enabled[checked]" type="checkbox" <?php checked(1, $isChecked); ?> />
261 261
             <?php
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
         {
331 331
             $attribute_taxonomies = wc_get_attribute_taxonomies();
332 332
 
333
-            if (!$attribute_taxonomies) {
333
+            if ( ! $attribute_taxonomies) {
334 334
                 echo esc_html__('You don\'t have any attributes defined yet. Go to WooCommerce and add some to use this feature.', 'algolia-woo-indexer');
335 335
                 return;
336 336
             }
@@ -415,10 +415,10 @@  discard block
 block discarded – undo
415 415
              */
416 416
             Algolia_Check_Requirements::check_unmet_requirements();
417 417
 
418
-            if (!Algolia_Check_Requirements::algolia_wp_version_check() || !Algolia_Check_Requirements::algolia_php_version_check()) {
418
+            if ( ! Algolia_Check_Requirements::algolia_wp_version_check() || ! Algolia_Check_Requirements::algolia_php_version_check()) {
419 419
                 add_action(
420 420
                     'admin_notices',
421
-                    function () {
421
+                    function() {
422 422
                         echo '<div class="error notice">
423 423
                                   <p>' . esc_html__('Please check the server requirements for Algolia Woo Indexer. <br/> It requires minimum PHP version 7.2 and WordPress version 5.0', 'algolia-woo-indexer') . '</p>
424 424
                                 </div>';
@@ -452,10 +452,10 @@  discard block
 block discarded – undo
452 452
 
453 453
                 self::$plugin_url = admin_url('options-general.php?page=algolia-woo-indexer-settings');
454 454
 
455
-                if (!is_plugin_active('woocommerce/woocommerce.php')) {
455
+                if ( ! is_plugin_active('woocommerce/woocommerce.php')) {
456 456
                     add_action(
457 457
                         'admin_notices',
458
-                        function () {
458
+                        function() {
459 459
                             echo '<div class="error notice">
460 460
 								  <p>' . esc_html__('WooCommerce plugin must be enabled for Algolia Woo Indexer to work.', 'algolia-woo-indexer') . '</p>
461 461
 								</div>';
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
             /**
549 549
              * Sanitizing by setting the value to either 1 or 0
550 550
              */
551
-            $sanitized['product'] = (!empty($auto_send)) ? 1 : 0;
552
-            $sanitized['attributes_enabled'] = (!empty($attributes_enabled)) ? 1 : 0;
551
+            $sanitized['product'] = ( ! empty($auto_send)) ? 1 : 0;
552
+            $sanitized['attributes_enabled'] = ( ! empty($attributes_enabled)) ? 1 : 0;
553 553
 
554 554
             /**
555 555
              * Filter the data fields checkboxes and verify that the input is an array and assign it to an associative array
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
             $sanitized['fields'] = array();
560 560
             foreach (BASIC_FIELDS as $field) {
561 561
                 $raw_field = filter_input(INPUT_POST, 'algolia_woo_indexer_field_' . $field, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
562
-                $filtered_field = (!empty($raw_field)) ? 1 : 0;
562
+                $filtered_field = ( ! empty($raw_field)) ? 1 : 0;
563 563
                 $sanitized['fields'][$field] = $filtered_field;
564 564
             }
565 565
 
@@ -569,21 +569,21 @@  discard block
 block discarded – undo
569 569
              *
570 570
              * @see https://developer.wordpress.org/reference/functions/update_option/
571 571
              */
572
-            if (isset($sanitized['app_id']) && (!empty($sanitized['app_id']))) {
572
+            if (isset($sanitized['app_id']) && ( ! empty($sanitized['app_id']))) {
573 573
                 update_option(
574 574
                     ALGOWOO_DB_OPTION . ALGOLIA_APP_ID,
575 575
                     $sanitized['app_id']
576 576
                 );
577 577
             }
578 578
 
579
-            if (isset($sanitized['api_key']) && (!empty($sanitized['api_key']))) {
579
+            if (isset($sanitized['api_key']) && ( ! empty($sanitized['api_key']))) {
580 580
                 update_option(
581 581
                     ALGOWOO_DB_OPTION . ALGOLIA_API_KEY,
582 582
                     $sanitized['api_key']
583 583
                 );
584 584
             }
585 585
 
586
-            if (isset($sanitized['index_name']) && (!empty($sanitized['index_name']))) {
586
+            if (isset($sanitized['index_name']) && ( ! empty($sanitized['index_name']))) {
587 587
                 update_option(
588 588
                     ALGOWOO_DB_OPTION . INDEX_NAME,
589 589
                     $sanitized['index_name']
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
             }
599 599
 
600 600
             foreach (array_keys(ATTRIBUTES_SETTINGS) as $key) {
601
-                $value = $sanitized['attributes_'.$key];
601
+                $value = $sanitized['attributes_' . $key];
602 602
                 if (isset($value)) {
603 603
                     $extension = constant('ATTRIBUTES_' . strtoupper($key));
604 604
                     update_option(
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
                 }
609 609
             }
610 610
 
611
-            if (isset($sanitized['fields']) && (!empty($sanitized['fields']))) {
611
+            if (isset($sanitized['fields']) && ( ! empty($sanitized['fields']))) {
612 612
                 foreach ($sanitized['fields'] as $key => $value) {
613 613
                     update_option(
614 614
                         ALGOWOO_DB_OPTION . BASIC_FIELD_PREFIX . $key,
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
             /**
673 673
              * Verify that the user can access the settings page
674 674
              */
675
-            if (!current_user_can('manage_options')) {
675
+            if ( ! current_user_can('manage_options')) {
676 676
                 wp_die(esc_html__('Action not allowed.', 'algolia_woo_indexer_settings'));
677 677
             } ?>
678 678
             <div class="wrap">
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
          */
700 700
         public static function get_instance()
701 701
         {
702
-            if (!self::$instance) {
702
+            if ( ! self::$instance) {
703 703
                 self::$instance = new Algolia_Woo_Indexer();
704 704
             }
705 705
             return self::$instance;
Please login to merge, or discard this patch.
classes/class-send-products.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * Abort if this file is called directly
16 16
  */
17
-if (!defined('ABSPATH')) {
17
+if ( ! defined('ABSPATH')) {
18 18
     exit;
19 19
 }
20 20
 
21 21
 /**
22 22
  * Include plugin file if function is_plugin_active does not exist
23 23
  */
24
-if (!function_exists('is_plugin_active')) {
24
+if ( ! function_exists('is_plugin_active')) {
25 25
     require_once(ABSPATH . '/wp-admin/includes/plugin.php');
26 26
 }
27 27
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 define('ATTRIBUTES_INTERP', '_attributes_interp');
84 84
 
85 85
 
86
-if (!class_exists('Algolia_Send_Products')) {
86
+if ( ! class_exists('Algolia_Send_Products')) {
87 87
     /**
88 88
      * Algolia WooIndexer main class
89 89
      */
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             } catch (\Algolia\AlgoliaSearch\Exceptions\UnreachableException $error) {
111 111
                 add_action(
112 112
                     'admin_notices',
113
-                    function () {
113
+                    function() {
114 114
                         echo '<div class="error notice">
115 115
                             <p>' . esc_html__('An error has been encountered. Please check your application ID and API key. ', 'algolia-woo-indexer') . '</p>
116 116
 						</div>';
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
             /**
147 147
              *  only if enabled or validation skipped and not empty
148 148
              */
149
-            if ((!self::is_basic_field_enabled($field) && !$skip_basic_field_validation) || empty($value)) {
149
+            if (( ! self::is_basic_field_enabled($field) && ! $skip_basic_field_validation) || empty($value)) {
150 150
                 return $record;
151 151
             }
152 152
 
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
             $sale_price = 0;
166 166
             $regular_price = 0;
167 167
             if ($product->is_type('simple')) {
168
-                $sale_price     =  $product->get_sale_price();
169
-                $regular_price  =  $product->get_regular_price();
168
+                $sale_price     = $product->get_sale_price();
169
+                $regular_price  = $product->get_regular_price();
170 170
             } elseif ($product->is_type('variable')) {
171
-                $sale_price     =  $product->get_variation_sale_price('min', true);
172
-                $regular_price  =  $product->get_variation_regular_price('max', true);
171
+                $sale_price     = $product->get_variation_sale_price('min', true);
172
+                $regular_price  = $product->get_variation_regular_price('max', true);
173 173
             }
174 174
             return array(
175 175
                 'sale_price' => $sale_price,
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
             $setting_ids_interp = get_option(ALGOWOO_DB_OPTION . ATTRIBUTES_INTERP);
263 263
             $setting_ids_interp = explode(",", $setting_ids_interp);
264 264
 
265
-            if (!$rawAttributes) {
265
+            if ( ! $rawAttributes) {
266 266
                 return false;
267 267
             }
268 268
 
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
                  */
280 280
                 if (
281 281
                     $attribute->get_variation() ||
282
-                    !in_array($id, $setting_ids) ||
283
-                    ($setting_visibility ===  "visible" && $visibility === false) ||
284
-                    ($setting_visibility ===  "hidden" && $visibility === true) ||
285
-                    ($setting_variation ===  "used" && $variation === false) ||
286
-                    ($setting_variation ===  "notused" && $variation === true)
282
+                    ! in_array($id, $setting_ids) ||
283
+                    ($setting_visibility === "visible" && $visibility === false) ||
284
+                    ($setting_visibility === "hidden" && $visibility === true) ||
285
+                    ($setting_variation === "used" && $variation === false) ||
286
+                    ($setting_variation === "notused" && $variation === true)
287 287
                 ) {
288 288
                     continue;
289 289
                 }
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             $algolia_api_key        = is_string($algolia_api_key) ? $algolia_api_key : CHANGE_ME;
351 351
 
352 352
             $algolia_index_name     = get_option(ALGOWOO_DB_OPTION . INDEX_NAME);
353
-            $algolia_index_name        = is_string($algolia_index_name) ? $algolia_index_name : CHANGE_ME;
353
+            $algolia_index_name = is_string($algolia_index_name) ? $algolia_index_name : CHANGE_ME;
354 354
 
355 355
             /**
356 356
              * Display admin notice and return if not all values have been set
Please login to merge, or discard this patch.