Passed
Pull Request — master (#169)
by
unknown
01:59
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   +23 added lines, -23 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>';
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
             $attributes_visibility           = filter_input(INPUT_POST, 'algolia_woo_indexer_attributes_visibility', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
517 517
             $attributes_variation            = filter_input(INPUT_POST, 'algolia_woo_indexer_attributes_variation', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
518 518
             $attributes_list                 = filter_input(INPUT_POST, 'algolia_woo_indexer_attributes_list', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
519
-            $attributes_interp     = filter_input(INPUT_POST, 'algolia_woo_indexer_attributes_interp', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
519
+            $attributes_interp = filter_input(INPUT_POST, 'algolia_woo_indexer_attributes_interp', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
520 520
 
521 521
             /**
522 522
              * Properly sanitize text fields before updating data
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
             $filtered_app_id         = sanitize_text_field($post_application_id['id']);
527 527
             $filtered_api_key        = sanitize_text_field($post_api_key['key']);
528 528
             $filtered_index_name     = sanitize_text_field($post_index_name['name']);
529
-            $filtered_attributes_visibility     = sanitize_text_field($attributes_visibility['value']);
530
-            $filtered_attributes_variation     = sanitize_text_field($attributes_variation['value']);
529
+            $filtered_attributes_visibility = sanitize_text_field($attributes_visibility['value']);
530
+            $filtered_attributes_variation = sanitize_text_field($attributes_variation['value']);
531 531
 
532 532
             /**
533 533
              * sanitize select list of id's by getting integers and them implode seperated with comma
@@ -547,8 +547,8 @@  discard block
 block discarded – undo
547 547
             /**
548 548
              * Sanitizing by setting the value to either 1 or 0
549 549
              */
550
-            $filtered_product = (!empty($auto_send)) ? 1 : 0;
551
-            $filtered_attributes_enabled = (!empty($attributes_enabled)) ? 1 : 0;
550
+            $filtered_product = ( ! empty($auto_send)) ? 1 : 0;
551
+            $filtered_attributes_enabled = ( ! empty($attributes_enabled)) ? 1 : 0;
552 552
 
553 553
             /**
554 554
              * Filter the data fields checkboxes and verify that the input is an array and assign it to an associative array
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
             $filtered_fields = array();
559 559
             foreach (BASIC_FIELDS as $field) {
560 560
                 $raw_field = filter_input(INPUT_POST, 'algolia_woo_indexer_field_' . $field, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
561
-                $filtered_field = (!empty($raw_field)) ? 1 : 0;
561
+                $filtered_field = ( ! empty($raw_field)) ? 1 : 0;
562 562
                 $filtered_fields[$field] = $filtered_field;
563 563
             }
564 564
 
@@ -568,21 +568,21 @@  discard block
 block discarded – undo
568 568
              *
569 569
              * @see https://developer.wordpress.org/reference/functions/update_option/
570 570
              */
571
-            if (isset($filtered_app_id) && (!empty($filtered_app_id))) {
571
+            if (isset($filtered_app_id) && ( ! empty($filtered_app_id))) {
572 572
                 update_option(
573 573
                     ALGOWOO_DB_OPTION . ALGOLIA_APP_ID,
574 574
                     $filtered_app_id
575 575
                 );
576 576
             }
577 577
 
578
-            if (isset($filtered_api_key) && (!empty($filtered_api_key))) {
578
+            if (isset($filtered_api_key) && ( ! empty($filtered_api_key))) {
579 579
                 update_option(
580 580
                     ALGOWOO_DB_OPTION . ALGOLIA_API_KEY,
581 581
                     $filtered_api_key
582 582
                 );
583 583
             }
584 584
 
585
-            if (isset($filtered_index_name) && (!empty($filtered_index_name))) {
585
+            if (isset($filtered_index_name) && ( ! empty($filtered_index_name))) {
586 586
                 update_option(
587 587
                     ALGOWOO_DB_OPTION . INDEX_NAME,
588 588
                     $filtered_index_name
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
                 }
608 608
             }
609 609
 
610
-            if (isset($filtered_fields) && (!empty($filtered_fields))) {
610
+            if (isset($filtered_fields) && ( ! empty($filtered_fields))) {
611 611
                 foreach ($filtered_fields as $key => $value) {
612 612
                     update_option(
613 613
                         ALGOWOO_DB_OPTION . BASIC_FIELD_PREFIX . $key,
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
             /**
672 672
              * Verify that the user can access the settings page
673 673
              */
674
-            if (!current_user_can('manage_options')) {
674
+            if ( ! current_user_can('manage_options')) {
675 675
                 wp_die(esc_html__('Action not allowed.', 'algolia_woo_indexer_settings'));
676 676
             } ?>
677 677
             <div class="wrap">
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
          */
699 699
         public static function get_instance()
700 700
         {
701
-            if (!self::$instance) {
701
+            if ( ! self::$instance) {
702 702
                 self::$instance = new Algolia_Woo_Indexer();
703 703
             }
704 704
             return self::$instance;
Please login to merge, or discard this patch.
classes/class-send-products.php 1 patch
Spacing   +17 added lines, -17 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
 
@@ -280,8 +280,8 @@  discard block
 block discarded – undo
280 280
                  */
281 281
                 $visibility = $attribute["visible"];
282 282
                 if (
283
-                    ($setting_visibility ===  "visible" && $visibility === false) ||
284
-                    ($setting_visibility ===  "hidden" && $visibility === true)
283
+                    ($setting_visibility === "visible" && $visibility === false) ||
284
+                    ($setting_visibility === "hidden" && $visibility === true)
285 285
                 ) {
286 286
                     continue;
287 287
                 }
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
                  */
292 292
                 $variation = $attribute["variation"];
293 293
                 if (
294
-                    ($setting_variation ===  "used" && $variation === false) ||
295
-                    ($setting_variation ===  "notused" && $variation === true)
294
+                    ($setting_variation === "used" && $variation === false) ||
295
+                    ($setting_variation === "notused" && $variation === true)
296 296
                 ) {
297 297
                     continue;
298 298
                 }
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
                  * ensure that taxonomy is whitelisted
302 302
                  */
303 303
                 $id = $attribute->get_id();
304
-                if (!in_array($id, $setting_ids)) {
304
+                if ( ! in_array($id, $setting_ids)) {
305 305
                     continue;
306 306
                 }
307 307
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
                     /**
329 329
                      * normal mixed content case 
330 330
                      */
331
-                    if (!in_array($id, $setting_ids_interp)) {
331
+                    if ( ! in_array($id, $setting_ids_interp)) {
332 332
                         foreach ($terms as $term) {
333 333
                             $single_term = esc_html($term->name);
334 334
                             array_push($tax_terms, $single_term);
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
             $algolia_api_key        = is_string($algolia_api_key) ? $algolia_api_key : CHANGE_ME;
367 367
 
368 368
             $algolia_index_name     = get_option(ALGOWOO_DB_OPTION . INDEX_NAME);
369
-            $algolia_index_name        = is_string($algolia_index_name) ? $algolia_index_name : CHANGE_ME;
369
+            $algolia_index_name = is_string($algolia_index_name) ? $algolia_index_name : CHANGE_ME;
370 370
 
371 371
             /**
372 372
              * Display admin notice and return if not all values have been set
Please login to merge, or discard this patch.