@@ -11,11 +11,11 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -17,18 +17,18 @@ discard block |
||
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 | 24 | /** |
25 | 25 | * Include plugin file if function is_plugin_active does not exist |
26 | 26 | */ |
27 | -if (!function_exists('is_plugin_active')) { |
|
27 | +if ( ! function_exists('is_plugin_active')) { |
|
28 | 28 | require_once(ABSPATH . '/wp-admin/includes/plugin.php'); |
29 | 29 | } |
30 | 30 | |
31 | -if (!class_exists('Algolia_Woo_Indexer')) { |
|
31 | +if ( ! class_exists('Algolia_Woo_Indexer')) { |
|
32 | 32 | /** |
33 | 33 | * Algolia WooIndexer main class |
34 | 34 | */ |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * But I have still done it to be 100% safe |
223 | 223 | */ |
224 | 224 | $auto_send = get_option(ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS); |
225 | - $auto_send = (!empty($auto_send)) ? 1 : 0; ?> |
|
225 | + $auto_send = ( ! empty($auto_send)) ? 1 : 0; ?> |
|
226 | 226 | <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); ?> /> |
227 | 227 | <?php |
228 | 228 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | public static function algolia_woo_indexer_field_output($args) |
236 | 236 | { |
237 | 237 | $value = get_option(ALGOWOO_DB_OPTION . BASIC_FIELD_PREFIX . $args["name"]); |
238 | - $isChecked = (!empty($value)) ? 1 : 0; |
|
238 | + $isChecked = ( ! empty($value)) ? 1 : 0; |
|
239 | 239 | ?> |
240 | 240 | <input id="<?php echo $args["label_for"] ?>" name="<?php echo $args["label_for"] ?>[checked]" type="checkbox" <?php checked(1, $isChecked); ?> /> |
241 | 241 | <?php |
@@ -305,10 +305,10 @@ discard block |
||
305 | 305 | */ |
306 | 306 | Algolia_Check_Requirements::check_unmet_requirements(); |
307 | 307 | |
308 | - if (!Algolia_Check_Requirements::algolia_wp_version_check() || !Algolia_Check_Requirements::algolia_php_version_check()) { |
|
308 | + if ( ! Algolia_Check_Requirements::algolia_wp_version_check() || ! Algolia_Check_Requirements::algolia_php_version_check()) { |
|
309 | 309 | add_action( |
310 | 310 | 'admin_notices', |
311 | - function () { |
|
311 | + function() { |
|
312 | 312 | echo '<div class="error notice"> |
313 | 313 | <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> |
314 | 314 | </div>'; |
@@ -342,10 +342,10 @@ discard block |
||
342 | 342 | |
343 | 343 | self::$plugin_url = admin_url('options-general.php?page=algolia-woo-indexer-settings'); |
344 | 344 | |
345 | - if (!is_plugin_active('woocommerce/woocommerce.php')) { |
|
345 | + if ( ! is_plugin_active('woocommerce/woocommerce.php')) { |
|
346 | 346 | add_action( |
347 | 347 | 'admin_notices', |
348 | - function () { |
|
348 | + function() { |
|
349 | 349 | echo '<div class="error notice"> |
350 | 350 | <p>' . esc_html__('WooCommerce plugin must be enabled for Algolia Woo Indexer to work.', 'algolia-woo-indexer') . '</p> |
351 | 351 | </div>'; |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | /** |
419 | 419 | * Sanitizing by setting the value to either 1 or 0 |
420 | 420 | */ |
421 | - $sanitized['product'] = (!empty($auto_send)) ? 1 : 0; |
|
421 | + $sanitized['product'] = ( ! empty($auto_send)) ? 1 : 0; |
|
422 | 422 | |
423 | 423 | /** |
424 | 424 | * Filter the data fields checkboxes and verify that the input is an array and assign it to an associative array |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | $sanitized['fields'] = array(); |
429 | 429 | foreach (BASIC_FIELDS as $field) { |
430 | 430 | $raw_field = filter_input(INPUT_POST, 'algolia_woo_indexer_field_' . $field, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
431 | - $filtered_field = (!empty($raw_field)) ? 1 : 0; |
|
431 | + $filtered_field = ( ! empty($raw_field)) ? 1 : 0; |
|
432 | 432 | $sanitized['fields'][$field] = $filtered_field; |
433 | 433 | } |
434 | 434 | |
@@ -438,21 +438,21 @@ discard block |
||
438 | 438 | * |
439 | 439 | * @see https://developer.wordpress.org/reference/functions/update_option/ |
440 | 440 | */ |
441 | - if (isset($sanitized['app_id']) && (!empty($sanitized['app_id']))) { |
|
441 | + if (isset($sanitized['app_id']) && ( ! empty($sanitized['app_id']))) { |
|
442 | 442 | update_option( |
443 | 443 | ALGOWOO_DB_OPTION . ALGOLIA_APP_ID, |
444 | 444 | $sanitized['app_id'] |
445 | 445 | ); |
446 | 446 | } |
447 | 447 | |
448 | - if (isset($sanitized['api_key']) && (!empty($sanitized['api_key']))) { |
|
448 | + if (isset($sanitized['api_key']) && ( ! empty($sanitized['api_key']))) { |
|
449 | 449 | update_option( |
450 | 450 | ALGOWOO_DB_OPTION . ALGOLIA_API_KEY, |
451 | 451 | $sanitized['api_key'] |
452 | 452 | ); |
453 | 453 | } |
454 | 454 | |
455 | - if (isset($sanitized['index_name']) && (!empty($sanitized['index_name']))) { |
|
455 | + if (isset($sanitized['index_name']) && ( ! empty($sanitized['index_name']))) { |
|
456 | 456 | update_option( |
457 | 457 | ALGOWOO_DB_OPTION . INDEX_NAME, |
458 | 458 | $sanitized['index_name'] |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | ); |
467 | 467 | } |
468 | 468 | |
469 | - if (isset($sanitized['fields']) && (!empty($sanitized['fields']))) { |
|
469 | + if (isset($sanitized['fields']) && ( ! empty($sanitized['fields']))) { |
|
470 | 470 | foreach ($sanitized['fields'] as $key => $value) { |
471 | 471 | update_option( |
472 | 472 | ALGOWOO_DB_OPTION . BASIC_FIELD_PREFIX . $key, |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | /** |
546 | 546 | * Verify that the user can access the settings page |
547 | 547 | */ |
548 | - if (!current_user_can('manage_options')) { |
|
548 | + if ( ! current_user_can('manage_options')) { |
|
549 | 549 | wp_die(esc_html__('Action not allowed.', 'algolia_woo_indexer_settings')); |
550 | 550 | } ?> |
551 | 551 | <div class="wrap"> |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | */ |
573 | 573 | public static function get_instance() |
574 | 574 | { |
575 | - if (!self::$instance) { |
|
575 | + if ( ! self::$instance) { |
|
576 | 576 | self::$instance = new Algolia_Woo_Indexer(); |
577 | 577 | } |
578 | 578 | return self::$instance; |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * Abort if this file is called directly |
47 | 47 | */ |
48 | -if (!defined('ABSPATH')) { |
|
48 | +if ( ! defined('ABSPATH')) { |
|
49 | 49 | exit; |
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | -if (!class_exists('Algolia_Attributes')) { |
|
53 | +if ( ! class_exists('Algolia_Attributes')) { |
|
54 | 54 | /** |
55 | 55 | * Algolia WooIndexer Attributes |
56 | 56 | */ |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | public static function algolia_woo_indexer_attributes_enabled_output() |
112 | 112 | { |
113 | 113 | $value = get_option(ALGOWOO_DB_OPTION . ATTRIBUTES_ENABLED); |
114 | - $isChecked = (!empty($value)) ? 1 : 0; |
|
114 | + $isChecked = ( ! empty($value)) ? 1 : 0; |
|
115 | 115 | ?> |
116 | 116 | <input id="algolia_woo_indexer_attributes_enabled" name="algolia_woo_indexer_attributes_enabled[checked]" type="checkbox" <?php checked(1, $isChecked); ?> /> |
117 | 117 | <?php |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | |
219 | 219 | |
220 | 220 | $values = wc_get_attribute_taxonomies(); |
221 | - if (!$values) { |
|
221 | + if ( ! $values) { |
|
222 | 222 | echo esc_html__('You don\'t have any attributes defined yet. Go to WooCommerce and add some to use this feature.', 'algolia-woo-indexer'); |
223 | 223 | return; |
224 | 224 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | /** |
318 | 318 | * Sanitizing by setting the value to either 1 or 0 |
319 | 319 | */ |
320 | - $sanitized['attributes_enabled'] = (!empty($attributes_enabled)) ? 1 : 0; |
|
320 | + $sanitized['attributes_enabled'] = ( ! empty($attributes_enabled)) ? 1 : 0; |
|
321 | 321 | |
322 | 322 | |
323 | 323 | /** |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | */ |
405 | 405 | public static function get_instance() |
406 | 406 | { |
407 | - if (!self::$instance) { |
|
407 | + if ( ! self::$instance) { |
|
408 | 408 | self::$instance = new Algolia_Attributes(); |
409 | 409 | } |
410 | 410 | return self::$instance; |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | $setting_ids_interp = get_option(ALGOWOO_DB_OPTION . ATTRIBUTES_INTERP); |
476 | 476 | $setting_ids_interp = explode(",", $setting_ids_interp); |
477 | 477 | |
478 | - if (!$rawAttributes) { |
|
478 | + if ( ! $rawAttributes) { |
|
479 | 479 | return false; |
480 | 480 | } |
481 | 481 | |
@@ -492,11 +492,11 @@ discard block |
||
492 | 492 | */ |
493 | 493 | if ( |
494 | 494 | $attribute->get_variation() || |
495 | - !in_array($id, $setting_ids) || |
|
496 | - ($setting_visibility === "visible" && $visibility === false) || |
|
497 | - ($setting_visibility === "hidden" && $visibility === true) || |
|
498 | - ($setting_variation === "used" && $variation === false) || |
|
499 | - ($setting_variation === "notused" && $variation === true) |
|
495 | + ! in_array($id, $setting_ids) || |
|
496 | + ($setting_visibility === "visible" && $visibility === false) || |
|
497 | + ($setting_visibility === "hidden" && $visibility === true) || |
|
498 | + ($setting_variation === "used" && $variation === false) || |
|
499 | + ($setting_variation === "notused" && $variation === true) |
|
500 | 500 | ) { |
501 | 501 | continue; |
502 | 502 | } |
@@ -15,14 +15,14 @@ discard block |
||
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 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | define('CUSTOM_FIELDS', '_custom_fields'); |
68 | 68 | |
69 | 69 | |
70 | -if (!class_exists('Algolia_Send_Products')) { |
|
70 | +if ( ! class_exists('Algolia_Send_Products')) { |
|
71 | 71 | /** |
72 | 72 | * Algolia WooIndexer main class |
73 | 73 | */ |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } catch (\Algolia\AlgoliaSearch\Exceptions\UnreachableException $error) { |
95 | 95 | add_action( |
96 | 96 | 'admin_notices', |
97 | - function () { |
|
97 | + function() { |
|
98 | 98 | echo '<div class="error notice"> |
99 | 99 | <p>' . esc_html__('An error has been encountered. Please check your application ID and API key. ', 'algolia-woo-indexer') . '</p> |
100 | 100 | </div>'; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | /** |
131 | 131 | * only if enabled or validation skipped and not empty |
132 | 132 | */ |
133 | - if ((!self::is_basic_field_enabled($field) && !$skip_basic_field_validation) || empty($value)) { |
|
133 | + if (( ! self::is_basic_field_enabled($field) && ! $skip_basic_field_validation) || empty($value)) { |
|
134 | 134 | return $record; |
135 | 135 | } |
136 | 136 | |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | $sale_price = 0; |
150 | 150 | $regular_price = 0; |
151 | 151 | if ($product->is_type('simple')) { |
152 | - $sale_price = $product->get_sale_price(); |
|
153 | - $regular_price = $product->get_regular_price(); |
|
152 | + $sale_price = $product->get_sale_price(); |
|
153 | + $regular_price = $product->get_regular_price(); |
|
154 | 154 | } elseif ($product->is_type('variable')) { |
155 | - $sale_price = $product->get_variation_sale_price('min', true); |
|
156 | - $regular_price = $product->get_variation_regular_price('max', true); |
|
155 | + $sale_price = $product->get_variation_sale_price('min', true); |
|
156 | + $regular_price = $product->get_variation_regular_price('max', true); |
|
157 | 157 | } |
158 | 158 | return array( |
159 | 159 | 'sale_price' => $sale_price, |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $custom_field_with_values = array(); |
193 | 193 | foreach ($custom_fields_array as $custom_field) { |
194 | 194 | $value = get_post_meta($product->get_id(), $custom_field); |
195 | - if (!empty($value)) { |
|
195 | + if ( ! empty($value)) { |
|
196 | 196 | $custom_field_with_values[$custom_field] = $value; |
197 | 197 | } |
198 | 198 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $algolia_api_key = is_string($algolia_api_key) ? $algolia_api_key : CHANGE_ME; |
267 | 267 | |
268 | 268 | $algolia_index_name = get_option(ALGOWOO_DB_OPTION . INDEX_NAME); |
269 | - $algolia_index_name = is_string($algolia_index_name) ? $algolia_index_name : CHANGE_ME; |
|
269 | + $algolia_index_name = is_string($algolia_index_name) ? $algolia_index_name : CHANGE_ME; |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Display admin notice and return if not all values have been set |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * get custom fields and merge |
367 | 367 | */ |
368 | 368 | $custom_fields = self::get_custom_fields($product); |
369 | - if (!empty($custom_fields)) { |
|
369 | + if ( ! empty($custom_fields)) { |
|
370 | 370 | $record = array_merge($record, $custom_fields); |
371 | 371 | } |
372 | 372 |
@@ -18,36 +18,36 @@ |
||
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 attributes |
42 | 42 | */ |
43 | -require_once plugin_dir_path( __FILE__ ) . '/classes/class-attributes.php'; |
|
43 | +require_once plugin_dir_path(__FILE__) . '/classes/class-attributes.php'; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Class for sending products |
47 | 47 | */ |
48 | -require_once plugin_dir_path( __FILE__ ) . '/classes/class-send-products.php'; |
|
48 | +require_once plugin_dir_path(__FILE__) . '/classes/class-send-products.php'; |
|
49 | 49 | |
50 | 50 | $algowooindexer = \Algowoo\Algolia_Woo_Indexer::get_instance(); |
51 | 51 | |
52 | -register_activation_hook( __FILE__, array( $algowooindexer, 'activate_plugin' ) ); |
|
53 | -register_deactivation_hook( __FILE__, array( $algowooindexer, 'deactivate_plugin' ) ); |
|
52 | +register_activation_hook(__FILE__, array($algowooindexer, 'activate_plugin')); |
|
53 | +register_deactivation_hook(__FILE__, array($algowooindexer, 'deactivate_plugin')); |