Passed
Pull Request — master (#136)
by Daniel
06:36 queued 04:43
created
uninstall.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,14 +9,14 @@
 block discarded – undo
9 9
 /*
10 10
 *  If uninstall was not called from WordPress, then exit
11 11
 */
12
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
12
+if ( ! defined('WP_UNINSTALL_PLUGIN')) {
13 13
 	exit;
14 14
 }
15 15
 
16
-define( 'ALGOWOO_DB_OPTION', '_algolia_woo_indexer' );
16
+define('ALGOWOO_DB_OPTION', '_algolia_woo_indexer');
17 17
 
18
-delete_option( ALGOWOO_DB_OPTION . '_application_id' );
19
-delete_option( ALGOWOO_DB_OPTION . '_admin_api_key' );
20
-delete_option( ALGOWOO_DB_OPTION . '_index_name' );
21
-delete_option( ALGOWOO_DB_OPTION . '_index_in_stock' );
22
-delete_option( ALGOWOO_DB_OPTION . '_automatically_send_new_products' );
18
+delete_option(ALGOWOO_DB_OPTION . '_application_id');
19
+delete_option(ALGOWOO_DB_OPTION . '_admin_api_key');
20
+delete_option(ALGOWOO_DB_OPTION . '_index_name');
21
+delete_option(ALGOWOO_DB_OPTION . '_index_in_stock');
22
+delete_option(ALGOWOO_DB_OPTION . '_automatically_send_new_products');
Please login to merge, or discard this patch.
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 if if no nonce has been set for either of the two forms
36 36
 			 */
37
-			if ( ! isset( $settings_nonce ) ) {
37
+			if ( ! isset($settings_nonce)) {
38 38
 				return;
39 39
 			}
40 40
 
@@ -49,22 +49,22 @@  discard block
 block discarded – undo
49 49
 			/**
50 50
 			 * Filter incoming nonces and values
51 51
 			 */
52
-			$send_products_nonce      = filter_input( INPUT_POST, 'send_products_to_algolia_nonce_name', FILTER_DEFAULT );
53
-			$send_products_to_algolia = filter_input( INPUT_POST, 'send_products_to_algolia', FILTER_DEFAULT );
52
+			$send_products_nonce      = filter_input(INPUT_POST, 'send_products_to_algolia_nonce_name', FILTER_DEFAULT);
53
+			$send_products_to_algolia = filter_input(INPUT_POST, 'send_products_to_algolia', FILTER_DEFAULT);
54 54
 
55 55
 			/**
56 56
 			 * Display error and die if nonce is not verified and does not pass security check
57 57
 			 * Also check if the hidden value field send_products_to_algolia is set
58 58
 			 */
59 59
 
60
-			if ( ! wp_verify_nonce( $send_products_nonce, 'send_products_to_algolia_nonce_action' ) && isset( $send_products_to_algolia ) ) {
61
-				wp_die( esc_html__( 'Action is not allowed.', 'algolia-woo-indexer' ), esc_html__( 'Error!', 'algolia-woo-indexer' ) );
60
+			if ( ! wp_verify_nonce($send_products_nonce, 'send_products_to_algolia_nonce_action') && isset($send_products_to_algolia)) {
61
+				wp_die(esc_html__('Action is not allowed.', 'algolia-woo-indexer'), esc_html__('Error!', 'algolia-woo-indexer'));
62 62
 			}
63 63
 
64 64
 			/**
65 65
 			 * If we have verified the send_products_nonce and the send_products hidden field is set, return true
66 66
 			 */
67
-			if ( wp_verify_nonce( $send_products_nonce, 'send_products_to_algolia_nonce_action' ) && isset( $send_products_to_algolia ) ) {
67
+			if (wp_verify_nonce($send_products_nonce, 'send_products_to_algolia_nonce_action') && isset($send_products_to_algolia)) {
68 68
 				return true;
69 69
 			}
70 70
 		}
Please login to merge, or discard this patch.
classes/class-check-requirements.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * Abort if this file is called directly
19 19
  */
20
-if (! defined('ABSPATH')) {
20
+if ( ! defined('ABSPATH')) {
21 21
     exit;
22 22
 }
23 23
 
24
-if (! class_exists('Algolia_Check_Requirements')) {
24
+if ( ! class_exists('Algolia_Check_Requirements')) {
25 25
     /**
26 26
      * Check requirements for Algolia plugin
27 27
      */
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
 		 * 	@param string $algolia_index_name Algolia index name.
50 50
 		 * 
51 51
 		 */
52
-		public static function check_algolia_input_values($algolia_application_id, $algolia_api_key, $algolia_index_name )
52
+		public static function check_algolia_input_values($algolia_application_id, $algolia_api_key, $algolia_index_name)
53 53
 		{	
54 54
 			if (empty($algolia_application_id) || empty($algolia_api_key || empty($algolia_index_name))) {
55 55
                 add_action(
56 56
                     'admin_notices',
57
-                    function () {
57
+                    function() {
58 58
                         echo '<div class="error notice">
59 59
 							  <p>' . esc_html__('All settings need to be set for the plugin to work.', 'algolia-woo-indexer') . '</p>
60 60
 							</div>';
@@ -84,16 +84,16 @@  discard block
 block discarded – undo
84 84
          */
85 85
         public static function check_unmet_requirements()
86 86
         {
87
-            if (! extension_loaded('mbstring')) {
87
+            if ( ! extension_loaded('mbstring')) {
88 88
                 echo '<div class="error notice">
89 89
 					  <p>' . esc_html__('Algolia Woo Indexer requires the "mbstring" PHP extension to be enabled. Please contact your hosting provider.', 'algolia-woo-indexer') . '</p>
90 90
 				  </div>';
91
-            } elseif (! function_exists('mb_ereg_replace')) {
91
+            } elseif ( ! function_exists('mb_ereg_replace')) {
92 92
                 echo '<div class="error notice">
93 93
 					  <p>' . esc_html__('Algolia Woo Indexer needs "mbregex" NOT to be disabled. Please contact your hosting provider.', 'algolia-woo-indexer') . '</p>
94 94
 				  </div>';
95 95
             }
96
-            if (! extension_loaded('curl')) {
96
+            if ( ! extension_loaded('curl')) {
97 97
                 echo '<div class="error notice">
98 98
 					  <p>' . esc_html__('Algolia Woo Indexer requires the "cURL" PHP extension to be enabled. Please contact your hosting provider.', 'algolia-woo-indexer') . '</p>
99 99
 				  </div>';
Please login to merge, or discard this patch.
classes/class-algolia-woo-indexer.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -15,18 +15,18 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * Abort if this file is called directly
17 17
  */
18
-if ( ! defined( 'ABSPATH' ) ) {
18
+if ( ! defined('ABSPATH')) {
19 19
 	exit;
20 20
 }
21 21
 
22 22
 /**
23 23
  * Include plugin file if function is_plugin_active does not exist
24 24
  */
25
-if (! function_exists('is_plugin_active')) {
25
+if ( ! function_exists('is_plugin_active')) {
26 26
     require_once(ABSPATH . '/wp-admin/includes/plugin.php');
27 27
 }
28 28
 
29
-if (! class_exists('Algolia_Woo_Indexer')) {
29
+if ( ! class_exists('Algolia_Woo_Indexer')) {
30 30
     /**
31 31
      * Algolia WooIndexer main class
32 32
      */
@@ -98,34 +98,34 @@  discard block
 block discarded – undo
98 98
                 add_settings_section(
99 99
                     'algolia_woo_indexer_main',
100 100
                     esc_html__('Algolia Woo Plugin Settings', 'algolia-woo-indexer'),
101
-                    array( $algowooindexer, 'algolia_woo_indexer_section_text' ),
101
+                    array($algowooindexer, 'algolia_woo_indexer_section_text'),
102 102
                     'algolia_woo_indexer'
103 103
                 );
104 104
                 add_settings_field(
105 105
                     'algolia_woo_indexer_application_id',
106 106
                     esc_html__('Application ID', 'algolia-woo-indexer'),
107
-                    array( $algowooindexer, 'algolia_woo_indexer_application_id_output' ),
107
+                    array($algowooindexer, 'algolia_woo_indexer_application_id_output'),
108 108
                     'algolia_woo_indexer',
109 109
                     'algolia_woo_indexer_main'
110 110
                 );
111 111
                 add_settings_field(
112 112
                     'algolia_woo_indexer_admin_api_key',
113 113
                     esc_html__('Admin API Key', 'algolia-woo-indexer'),
114
-                    array( $algowooindexer, 'algolia_woo_indexer_admin_api_key_output' ),
114
+                    array($algowooindexer, 'algolia_woo_indexer_admin_api_key_output'),
115 115
                     'algolia_woo_indexer',
116 116
                     'algolia_woo_indexer_main'
117 117
                 );
118 118
                 add_settings_field(
119 119
                     'algolia_woo_indexer_index_name',
120 120
                     esc_html__('Index name (will be created if not existing)', 'algolia-woo-indexer'),
121
-                    array( $algowooindexer, 'algolia_woo_indexer_index_name_output' ),
121
+                    array($algowooindexer, 'algolia_woo_indexer_index_name_output'),
122 122
                     'algolia_woo_indexer',
123 123
                     'algolia_woo_indexer_main'
124 124
                 );
125 125
                 add_settings_field(
126 126
                     'algolia_woo_indexer_automatically_send_new_products',
127 127
                     esc_html__('Automatically index new products', 'algolia-woo-indexer'),
128
-                    array( $algowooindexer, 'algolia_woo_indexer_automatically_send_new_products_output' ),
128
+                    array($algowooindexer, 'algolia_woo_indexer_automatically_send_new_products_output'),
129 129
                     'algolia_woo_indexer',
130 130
                     'algolia_woo_indexer_main'
131 131
                 );
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
              * But I have still done it to be 100% safe
191 191
              */
192 192
             $automatically_send_new_products = get_option(ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS);
193
-            $automatically_send_new_products = (! empty($automatically_send_new_products)) ? 1 : 0; ?>
193
+            $automatically_send_new_products = ( ! empty($automatically_send_new_products)) ? 1 : 0; ?>
194 194
 			<input id="algolia_woo_indexer_automatically_send_new_products" name="algolia_woo_indexer_automatically_send_new_products[checked]"
195 195
 			type="checkbox" <?php checked(1, $automatically_send_new_products); ?> />
196 196
 			<?php
@@ -236,10 +236,10 @@  discard block
 block discarded – undo
236 236
              */
237 237
             Algolia_Check_Requirements::check_unmet_requirements();
238 238
 
239
-            if (! Algolia_Check_Requirements::algolia_wp_version_check() || ! Algolia_Check_Requirements::algolia_php_version_check()) {
239
+            if ( ! Algolia_Check_Requirements::algolia_wp_version_check() || ! Algolia_Check_Requirements::algolia_php_version_check()) {
240 240
                 add_action(
241 241
                     'admin_notices',
242
-                    function () {
242
+                    function() {
243 243
                         echo '<div class="error notice">
244 244
                                   <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>
245 245
                                 </div>';
@@ -252,31 +252,31 @@  discard block
 block discarded – undo
252 252
             /**
253 253
              * Setup translations
254 254
              */
255
-            add_action('plugins_loaded', array( $ob_class, 'load_textdomain' ));
255
+            add_action('plugins_loaded', array($ob_class, 'load_textdomain'));
256 256
 
257 257
             /**
258 258
              * Add actions to setup admin menu
259 259
              */
260 260
             if (is_admin()) {
261
-                add_action('admin_menu', array( $ob_class, 'admin_menu' ));
262
-                add_action('admin_init', array( $ob_class, 'setup_settings_sections' ));
263
-                add_action('admin_init', array( $ob_class, 'update_settings_options' ));
264
-                add_action('admin_init', array( $ob_class, 'maybe_send_products' ));
261
+                add_action('admin_menu', array($ob_class, 'admin_menu'));
262
+                add_action('admin_init', array($ob_class, 'setup_settings_sections'));
263
+                add_action('admin_init', array($ob_class, 'update_settings_options'));
264
+                add_action('admin_init', array($ob_class, 'maybe_send_products'));
265 265
 
266 266
                 /**
267 267
                  * Register hook to automatically send new products if the option is set
268 268
                  */
269 269
 
270 270
                 if ('1' === $automatically_send_new_products) {
271
-                    add_action('save_post', array( $ob_class, 'send_new_product_to_algolia' ), 10, 3);
271
+                    add_action('save_post', array($ob_class, 'send_new_product_to_algolia'), 10, 3);
272 272
                 }
273 273
 
274 274
                 self::$plugin_url = admin_url('options-general.php?page=algolia-woo-indexer-settings');
275 275
 
276
-                if (! is_plugin_active('woocommerce/woocommerce.php')) {
276
+                if ( ! is_plugin_active('woocommerce/woocommerce.php')) {
277 277
                     add_action(
278 278
                         'admin_notices',
279
-                        function () {
279
+                        function() {
280 280
                             echo '<div class="error notice">
281 281
 								  <p>' . esc_html__('WooCommerce plugin must be enabled for Algolia Woo Indexer to work.', 'algolia-woo-indexer') . '</p>
282 282
 								</div>';
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
             /**
342 342
              * Sanitizing by setting the value to either 1 or 0
343 343
              */
344
-            $filtered_automatically_send_new_products = (! empty($automatically_send_new_products)) ? 1 : 0;
344
+            $filtered_automatically_send_new_products = ( ! empty($automatically_send_new_products)) ? 1 : 0;
345 345
 
346 346
             /**
347 347
              * Values have been filtered and sanitized
@@ -349,28 +349,28 @@  discard block
 block discarded – undo
349 349
              *
350 350
              * @see https://developer.wordpress.org/reference/functions/update_option/
351 351
              */
352
-            if (isset($filtered_application_id) && (! empty($filtered_application_id))) {
352
+            if (isset($filtered_application_id) && ( ! empty($filtered_application_id))) {
353 353
                 update_option(
354 354
                     ALGOWOO_DB_OPTION . ALGOLIA_APPLICATION_ID,
355 355
                     $filtered_application_id
356 356
                 );
357 357
             }
358 358
 
359
-            if (isset($filtered_api_key) && (! empty($filtered_api_key))) {
359
+            if (isset($filtered_api_key) && ( ! empty($filtered_api_key))) {
360 360
                 update_option(
361 361
                     ALGOWOO_DB_OPTION . ALGOLIA_API_KEY,
362 362
                     $filtered_api_key
363 363
                 );
364 364
             }
365 365
 
366
-            if (isset($filtered_index_name) && (! empty($filtered_index_name))) {
366
+            if (isset($filtered_index_name) && ( ! empty($filtered_index_name))) {
367 367
                 update_option(
368 368
                     ALGOWOO_DB_OPTION . INDEX_NAME,
369 369
                     $filtered_index_name
370 370
                 );
371 371
             }
372 372
 
373
-            if (isset($filtered_automatically_send_new_products) && (! empty($filtered_automatically_send_new_products))) {
373
+            if (isset($filtered_automatically_send_new_products) && ( ! empty($filtered_automatically_send_new_products))) {
374 374
                 update_option(
375 375
                     ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS,
376 376
                     $filtered_automatically_send_new_products
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
                 esc_html__('Algolia Woo Indexer Settings', 'algolia-woo-indexer'),
419 419
                 'manage_options',
420 420
                 'algolia-woo-indexer-settings',
421
-                array( get_called_class(), 'algolia_woo_indexer_settings' )
421
+                array(get_called_class(), 'algolia_woo_indexer_settings')
422 422
             );
423 423
         }
424 424
 
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
             /**
433 433
             * Verify that the user can access the settings page
434 434
             */
435
-            if (! current_user_can('manage_options')) {
435
+            if ( ! current_user_can('manage_options')) {
436 436
                 wp_die(esc_html__('Action not allowed.', 'algolia_woo_indexer_settings'));
437 437
             } ?>
438 438
 			<div class="wrap">
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
          */
460 460
         public static function get_instance()
461 461
         {
462
-            if (! self::$instance) {
462
+            if ( ! self::$instance) {
463 463
                 self::$instance = new Algolia_Woo_Indexer();
464 464
             }
465 465
             return self::$instance;
Please login to merge, or discard this patch.
algolia-woo-indexer.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,31 +18,31 @@
 block discarded – undo
18 18
 /**
19 19
  * Abort if this file is called directly
20 20
  */
21
-if ( ! defined( 'ABSPATH' ) ) {
21
+if ( ! defined('ABSPATH')) {
22 22
 	exit;
23 23
 }
24 24
 
25 25
 /**
26 26
  * Main class file
27 27
  */
28
-require_once plugin_dir_path( __FILE__ ) . '/classes/class-algolia-woo-indexer.php';
28
+require_once plugin_dir_path(__FILE__) . '/classes/class-algolia-woo-indexer.php';
29 29
 
30 30
 /**
31 31
  * Class for checking plugin requirements
32 32
  */
33
-require_once plugin_dir_path( __FILE__ ) . '/classes/class-check-requirements.php';
33
+require_once plugin_dir_path(__FILE__) . '/classes/class-check-requirements.php';
34 34
 
35 35
 /**
36 36
  * Class for verifying nonces
37 37
  */
38
-require_once plugin_dir_path( __FILE__ ) . '/classes/class-verify-nonces.php';
38
+require_once plugin_dir_path(__FILE__) . '/classes/class-verify-nonces.php';
39 39
 
40 40
 /**
41 41
  * Class for sending products
42 42
  */
43
-require_once plugin_dir_path( __FILE__ ) . '/classes/class-send-products.php';
43
+require_once plugin_dir_path(__FILE__) . '/classes/class-send-products.php';
44 44
 
45 45
 $algowooindexer = \Algowoo\Algolia_Woo_Indexer::get_instance();
46 46
 
47
-register_activation_hook( __FILE__, array( $algowooindexer, 'activate_plugin' ) );
48
-register_deactivation_hook( __FILE__, array( $algowooindexer, 'deactivate_plugin' ) );
47
+register_activation_hook(__FILE__, array($algowooindexer, 'activate_plugin'));
48
+register_deactivation_hook(__FILE__, array($algowooindexer, 'deactivate_plugin'));
Please login to merge, or discard this patch.
classes/class-send-products.php 1 patch
Spacing   +9 added lines, -9 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
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 define('ALGOLIA_APPLICATION_ID', '_application_id');
45 45
 define('ALGOLIA_API_KEY', '_admin_api_key');
46 46
 
47
-if (!class_exists('Algolia_Send_Products')) {
47
+if ( ! class_exists('Algolia_Send_Products')) {
48 48
     /**
49 49
      * Algolia WooIndexer main class
50 50
      */
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
             } catch (\Algolia\AlgoliaSearch\Exceptions\UnreachableException $error) {
71 71
                 add_action(
72 72
                     'admin_notices',
73
-                    function () {
73
+                    function() {
74 74
                         echo '<div class="error notice">
75 75
 							  <p>' . esc_html__('An error has been encountered. Please check your application ID and API key. ', 'algolia-woo-indexer') . '</p>
76 76
 							</div>';
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             $algolia_api_key        = is_string($algolia_api_key) ? $algolia_api_key : CHANGE_ME;
107 107
 
108 108
             $algolia_index_name     = get_option(ALGOWOO_DB_OPTION . INDEX_NAME);
109
-            $algolia_index_name        = is_string($algolia_index_name) ? $algolia_index_name : CHANGE_ME;
109
+            $algolia_index_name = is_string($algolia_index_name) ? $algolia_index_name : CHANGE_ME;
110 110
 
111 111
             /**
112 112
              * Display admin notice and return if not all values have been set
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
                  * Set sale price or regular price based on product type
172 172
                  */
173 173
                 if ($product->is_type('simple')) {
174
-                    $sale_price     =  $product->get_sale_price();
175
-                    $regular_price  =  $product->get_regular_price();
174
+                    $sale_price     = $product->get_sale_price();
175
+                    $regular_price  = $product->get_regular_price();
176 176
                 } elseif ($product->is_type('variable')) {
177
-                    $sale_price     =  $product->get_variation_sale_price('min', true);
178
-                    $regular_price  =  $product->get_variation_regular_price('max', true);
177
+                    $sale_price     = $product->get_variation_sale_price('min', true);
178
+                    $regular_price  = $product->get_variation_regular_price('max', true);
179 179
                 }
180 180
 
181 181
                 /**
Please login to merge, or discard this patch.