@@ -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 | } |
@@ -14,14 +14,14 @@ discard block |
||
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 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | define('ATTRIBUTES_LIST_INTERPOLATE', '_attributes_list_interpolate'); |
77 | 77 | |
78 | 78 | |
79 | -if (!class_exists('Algolia_Send_Products')) { |
|
79 | +if ( ! class_exists('Algolia_Send_Products')) { |
|
80 | 80 | /** |
81 | 81 | * Algolia WooIndexer main class |
82 | 82 | */ |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | } catch (\Algolia\AlgoliaSearch\Exceptions\UnreachableException $error) { |
104 | 104 | add_action( |
105 | 105 | 'admin_notices', |
106 | - function () { |
|
106 | + function() { |
|
107 | 107 | echo '<div class="error notice"> |
108 | 108 | <p>' . esc_html__('An error has been encountered. Please check your application ID and API key. ', 'algolia-woo-indexer') . '</p> |
109 | 109 | </div>'; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | /** |
140 | 140 | * only if enabled or validation skipped and not empty |
141 | 141 | */ |
142 | - if ((!self::is_basic_field_enabled($field) && !$skip_basic_field_validation) || empty($value)) { |
|
142 | + if (( ! self::is_basic_field_enabled($field) && ! $skip_basic_field_validation) || empty($value)) { |
|
143 | 143 | return $record; |
144 | 144 | } |
145 | 145 | |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | $sale_price = 0; |
159 | 159 | $regular_price = 0; |
160 | 160 | if ($product->is_type('simple')) { |
161 | - $sale_price = $product->get_sale_price(); |
|
162 | - $regular_price = $product->get_regular_price(); |
|
161 | + $sale_price = $product->get_sale_price(); |
|
162 | + $regular_price = $product->get_regular_price(); |
|
163 | 163 | } elseif ($product->is_type('variable')) { |
164 | - $sale_price = $product->get_variation_sale_price('min', true); |
|
165 | - $regular_price = $product->get_variation_regular_price('max', true); |
|
164 | + $sale_price = $product->get_variation_sale_price('min', true); |
|
165 | + $regular_price = $product->get_variation_regular_price('max', true); |
|
166 | 166 | } |
167 | 167 | return array( |
168 | 168 | 'sale_price' => $sale_price, |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | $setting_ids_interpolate = get_option(ALGOWOO_DB_OPTION . ATTRIBUTES_LIST_INTERPOLATE); |
256 | 256 | $setting_ids_interpolate = explode(",", $setting_ids_interpolate); |
257 | 257 | |
258 | - if (!$rawAttributes) { |
|
258 | + if ( ! $rawAttributes) { |
|
259 | 259 | return false; |
260 | 260 | } |
261 | 261 | |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | */ |
274 | 274 | $visibility = $attribute["visible"]; |
275 | 275 | if ( |
276 | - ($setting_visibility === "visible" && $visibility === false) || |
|
277 | - ($setting_visibility === "hidden" && $visibility === true) |
|
276 | + ($setting_visibility === "visible" && $visibility === false) || |
|
277 | + ($setting_visibility === "hidden" && $visibility === true) |
|
278 | 278 | ) { |
279 | 279 | continue; |
280 | 280 | } |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | */ |
285 | 285 | $variation = $attribute["variation"]; |
286 | 286 | if ( |
287 | - ($setting_variation === "used" && $variation === false) || |
|
288 | - ($setting_variation === "notused" && $variation === true) |
|
287 | + ($setting_variation === "used" && $variation === false) || |
|
288 | + ($setting_variation === "notused" && $variation === true) |
|
289 | 289 | ) { |
290 | 290 | continue; |
291 | 291 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * ensure that taxonomy is whitelisted |
295 | 295 | */ |
296 | 296 | $id = $attribute->get_id(); |
297 | - if (!in_array($id, $setting_ids)) { |
|
297 | + if ( ! in_array($id, $setting_ids)) { |
|
298 | 298 | continue; |
299 | 299 | } |
300 | 300 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | /** |
322 | 322 | * normal mixed content case |
323 | 323 | */ |
324 | - if (!in_array($id, $setting_ids_interpolate)) { |
|
324 | + if ( ! in_array($id, $setting_ids_interpolate)) { |
|
325 | 325 | foreach ($terms as $term) { |
326 | 326 | $single_term = esc_html($term->name); |
327 | 327 | array_push($tax_terms, $single_term); |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | $algolia_api_key = is_string($algolia_api_key) ? $algolia_api_key : CHANGE_ME; |
360 | 360 | |
361 | 361 | $algolia_index_name = get_option(ALGOWOO_DB_OPTION . INDEX_NAME); |
362 | - $algolia_index_name = is_string($algolia_index_name) ? $algolia_index_name : CHANGE_ME; |
|
362 | + $algolia_index_name = is_string($algolia_index_name) ? $algolia_index_name : CHANGE_ME; |
|
363 | 363 | |
364 | 364 | /** |
365 | 365 | * Display admin notice and return if not all values have been set |
@@ -16,18 +16,18 @@ discard block |
||
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 | */ |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * But I have still done it to be 100% safe |
255 | 255 | */ |
256 | 256 | $auto_send = get_option(ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS); |
257 | - $auto_send = (!empty($auto_send)) ? 1 : 0; ?> |
|
257 | + $auto_send = ( ! empty($auto_send)) ? 1 : 0; ?> |
|
258 | 258 | <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); ?> /> |
259 | 259 | <?php |
260 | 260 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | public static function algolia_woo_indexer_field_output() |
268 | 268 | { |
269 | 269 | $value = get_option(ALGOWOO_DB_OPTION . BASIC_FIELD_PREFIX . $args["name"]); |
270 | - $isChecked = (!empty($value)) ? 1 : 0; |
|
270 | + $isChecked = ( ! empty($value)) ? 1 : 0; |
|
271 | 271 | ?> |
272 | 272 | <input id="<?php echo $args["label_for"] ?>" name="<?php echo $args["label_for"] ?>[checked]" type="checkbox" <?php checked(1, $isChecked); ?> /> |
273 | 273 | <?php |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | public static function algolia_woo_indexer_attributes_enabled_output() |
282 | 282 | { |
283 | 283 | $value = get_option(ALGOWOO_DB_OPTION . ATTRIBUTES_ENABLED); |
284 | - $isChecked = (!empty($value)) ? 1 : 0; |
|
284 | + $isChecked = ( ! empty($value)) ? 1 : 0; |
|
285 | 285 | ?> |
286 | 286 | <input id="algolia_woo_indexer_attributes_enabled" name="algolia_woo_indexer_attributes_enabled[checked]" type="checkbox" <?php checked(1, $isChecked); ?> /> |
287 | 287 | <?php |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | { |
357 | 357 | $attribute_taxonomies = wc_get_attribute_taxonomies(); |
358 | 358 | |
359 | - if (!$attribute_taxonomies) { |
|
359 | + if ( ! $attribute_taxonomies) { |
|
360 | 360 | echo esc_html__('You don\'t have any attributes defined yet. Go to WooCommerce and add some to use this feature.', 'algolia-woo-indexer'); |
361 | 361 | return; |
362 | 362 | } |
@@ -441,10 +441,10 @@ discard block |
||
441 | 441 | */ |
442 | 442 | Algolia_Check_Requirements::check_unmet_requirements(); |
443 | 443 | |
444 | - if (!Algolia_Check_Requirements::algolia_wp_version_check() || !Algolia_Check_Requirements::algolia_php_version_check()) { |
|
444 | + if ( ! Algolia_Check_Requirements::algolia_wp_version_check() || ! Algolia_Check_Requirements::algolia_php_version_check()) { |
|
445 | 445 | add_action( |
446 | 446 | 'admin_notices', |
447 | - function () { |
|
447 | + function() { |
|
448 | 448 | echo '<div class="error notice"> |
449 | 449 | <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> |
450 | 450 | </div>'; |
@@ -478,10 +478,10 @@ discard block |
||
478 | 478 | |
479 | 479 | self::$plugin_url = admin_url('options-general.php?page=algolia-woo-indexer-settings'); |
480 | 480 | |
481 | - if (!is_plugin_active('woocommerce/woocommerce.php')) { |
|
481 | + if ( ! is_plugin_active('woocommerce/woocommerce.php')) { |
|
482 | 482 | add_action( |
483 | 483 | 'admin_notices', |
484 | - function () { |
|
484 | + function() { |
|
485 | 485 | echo '<div class="error notice"> |
486 | 486 | <p>' . esc_html__('WooCommerce plugin must be enabled for Algolia Woo Indexer to work.', 'algolia-woo-indexer') . '</p> |
487 | 487 | </div>'; |
@@ -552,8 +552,8 @@ discard block |
||
552 | 552 | $filtered_app_id = sanitize_text_field($post_application_id['id']); |
553 | 553 | $filtered_api_key = sanitize_text_field($post_api_key['key']); |
554 | 554 | $filtered_index_name = sanitize_text_field($post_index_name['name']); |
555 | - $filtered_attributes_visibility = sanitize_text_field($attributes_visibility['value']); |
|
556 | - $filtered_attributes_variation = sanitize_text_field($attributes_variation['value']); |
|
555 | + $filtered_attributes_visibility = sanitize_text_field($attributes_visibility['value']); |
|
556 | + $filtered_attributes_variation = sanitize_text_field($attributes_variation['value']); |
|
557 | 557 | |
558 | 558 | /** |
559 | 559 | * sanitize select list of id's by getting integers and them implode seperated with comma |
@@ -573,8 +573,8 @@ discard block |
||
573 | 573 | /** |
574 | 574 | * Sanitizing by setting the value to either 1 or 0 |
575 | 575 | */ |
576 | - $filtered_product = (!empty($auto_send)) ? 1 : 0; |
|
577 | - $filtered_attributes_enabled = (!empty($attributes_enabled)) ? 1 : 0; |
|
576 | + $filtered_product = ( ! empty($auto_send)) ? 1 : 0; |
|
577 | + $filtered_attributes_enabled = ( ! empty($attributes_enabled)) ? 1 : 0; |
|
578 | 578 | |
579 | 579 | /** |
580 | 580 | * Filter the data fields checkboxes and verify that the input is an array and assign it to an associative array |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | $filtered_fields = array(); |
585 | 585 | foreach (BASIC_FIELDS as $field) { |
586 | 586 | $raw_field = filter_input(INPUT_POST, 'algolia_woo_indexer_field_' . $field, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
587 | - $filtered_field = (!empty($raw_field)) ? 1 : 0; |
|
587 | + $filtered_field = ( ! empty($raw_field)) ? 1 : 0; |
|
588 | 588 | $filtered_fields[$field] = $filtered_field; |
589 | 589 | } |
590 | 590 | |
@@ -594,21 +594,21 @@ discard block |
||
594 | 594 | * |
595 | 595 | * @see https://developer.wordpress.org/reference/functions/update_option/ |
596 | 596 | */ |
597 | - if (isset($filtered_app_id) && (!empty($filtered_app_id))) { |
|
597 | + if (isset($filtered_app_id) && ( ! empty($filtered_app_id))) { |
|
598 | 598 | update_option( |
599 | 599 | ALGOWOO_DB_OPTION . ALGOLIA_APP_ID, |
600 | 600 | $filtered_app_id |
601 | 601 | ); |
602 | 602 | } |
603 | 603 | |
604 | - if (isset($filtered_api_key) && (!empty($filtered_api_key))) { |
|
604 | + if (isset($filtered_api_key) && ( ! empty($filtered_api_key))) { |
|
605 | 605 | update_option( |
606 | 606 | ALGOWOO_DB_OPTION . ALGOLIA_API_KEY, |
607 | 607 | $filtered_api_key |
608 | 608 | ); |
609 | 609 | } |
610 | 610 | |
611 | - if (isset($filtered_index_name) && (!empty($filtered_index_name))) { |
|
611 | + if (isset($filtered_index_name) && ( ! empty($filtered_index_name))) { |
|
612 | 612 | update_option( |
613 | 613 | ALGOWOO_DB_OPTION . INDEX_NAME, |
614 | 614 | $filtered_index_name |
@@ -629,35 +629,35 @@ discard block |
||
629 | 629 | ); |
630 | 630 | } |
631 | 631 | |
632 | - if (isset($filtered_attributes_visibility) && (!empty($filtered_attributes_visibility))) { |
|
632 | + if (isset($filtered_attributes_visibility) && ( ! empty($filtered_attributes_visibility))) { |
|
633 | 633 | update_option( |
634 | 634 | ALGOWOO_DB_OPTION . ATTRIBUTES_VISIBILITY, |
635 | 635 | $filtered_attributes_visibility |
636 | 636 | ); |
637 | 637 | } |
638 | 638 | |
639 | - if (isset($filtered_attributes_variation) && (!empty($filtered_attributes_variation))) { |
|
639 | + if (isset($filtered_attributes_variation) && ( ! empty($filtered_attributes_variation))) { |
|
640 | 640 | update_option( |
641 | 641 | ALGOWOO_DB_OPTION . ATTRIBUTES_VARIATION, |
642 | 642 | $filtered_attributes_variation |
643 | 643 | ); |
644 | 644 | } |
645 | 645 | |
646 | - if (isset($filtered_attributes_list) && (!empty($filtered_attributes_list))) { |
|
646 | + if (isset($filtered_attributes_list) && ( ! empty($filtered_attributes_list))) { |
|
647 | 647 | update_option( |
648 | 648 | ALGOWOO_DB_OPTION . ATTRIBUTES_LIST, |
649 | 649 | $filtered_attributes_list |
650 | 650 | ); |
651 | 651 | } |
652 | 652 | |
653 | - if (isset($clean_attributes_list_interp) && (!empty($clean_attributes_list_interp))) { |
|
653 | + if (isset($clean_attributes_list_interp) && ( ! empty($clean_attributes_list_interp))) { |
|
654 | 654 | update_option( |
655 | 655 | ALGOWOO_DB_OPTION . ATTRIBUTES_LIST_INTERPOLATE, |
656 | 656 | $clean_attributes_list_interp |
657 | 657 | ); |
658 | 658 | } |
659 | 659 | |
660 | - if (isset($filtered_fields) && (!empty($filtered_fields))) { |
|
660 | + if (isset($filtered_fields) && ( ! empty($filtered_fields))) { |
|
661 | 661 | foreach ($filtered_fields as $key => $value) { |
662 | 662 | update_option( |
663 | 663 | ALGOWOO_DB_OPTION . BASIC_FIELD_PREFIX . $key, |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | /** |
722 | 722 | * Verify that the user can access the settings page |
723 | 723 | */ |
724 | - if (!current_user_can('manage_options')) { |
|
724 | + if ( ! current_user_can('manage_options')) { |
|
725 | 725 | wp_die(esc_html__('Action not allowed.', 'algolia_woo_indexer_settings')); |
726 | 726 | } ?> |
727 | 727 | <div class="wrap"> |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | */ |
749 | 749 | public static function get_instance() |
750 | 750 | { |
751 | - if (!self::$instance) { |
|
751 | + if ( ! self::$instance) { |
|
752 | 752 | self::$instance = new Algolia_Woo_Indexer(); |
753 | 753 | } |
754 | 754 | return self::$instance; |