@@ -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 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | define('ALGOLIA_APP_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 | */ |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } catch (\Algolia\AlgoliaSearch\Exceptions\UnreachableException $error) { |
73 | 73 | add_action( |
74 | 74 | 'admin_notices', |
75 | - function () { |
|
75 | + function() { |
|
76 | 76 | echo '<div class="error notice"> |
77 | 77 | <p>' . esc_html__('An error has been encountered. Please check your application ID and API key. ', 'algolia-woo-indexer') . '</p> |
78 | 78 | </div>'; |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | $sale_price = 0; |
94 | 94 | $regular_price = 0; |
95 | 95 | if ($product->is_type('simple')) { |
96 | - $sale_price = $product->get_sale_price(); |
|
97 | - $regular_price = $product->get_regular_price(); |
|
96 | + $sale_price = $product->get_sale_price(); |
|
97 | + $regular_price = $product->get_regular_price(); |
|
98 | 98 | } elseif ($product->is_type('variable')) { |
99 | - $sale_price = $product->get_variation_sale_price('min', true); |
|
100 | - $regular_price = $product->get_variation_regular_price('max', true); |
|
99 | + $sale_price = $product->get_variation_sale_price('min', true); |
|
100 | + $regular_price = $product->get_variation_regular_price('max', true); |
|
101 | 101 | } |
102 | 102 | return array( |
103 | 103 | 'sale_price' => $sale_price, |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $algolia_api_key = is_string($algolia_api_key) ? $algolia_api_key : CHANGE_ME; |
132 | 132 | |
133 | 133 | $algolia_index_name = get_option(ALGOWOO_DB_OPTION . INDEX_NAME); |
134 | - $algolia_index_name = is_string($algolia_index_name) ? $algolia_index_name : CHANGE_ME; |
|
134 | + $algolia_index_name = is_string($algolia_index_name) ? $algolia_index_name : CHANGE_ME; |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Display admin notice and return if not all values have been set |
@@ -15,18 +15,18 @@ 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 | |
29 | -if (! class_exists('Algolia_Woo_Indexer')) { |
|
29 | +if ( ! class_exists('Algolia_Woo_Indexer')) { |
|
30 | 30 | /** |
31 | 31 | * Algolia WooIndexer main class |
32 | 32 | */ |
@@ -92,34 +92,34 @@ discard block |
||
92 | 92 | add_settings_section( |
93 | 93 | 'algolia_woo_indexer_main', |
94 | 94 | esc_html__('Algolia Woo Plugin Settings', 'algolia-woo-indexer'), |
95 | - array( $algowooindexer, 'algolia_woo_indexer_section_text' ), |
|
95 | + array($algowooindexer, 'algolia_woo_indexer_section_text'), |
|
96 | 96 | 'algolia_woo_indexer' |
97 | 97 | ); |
98 | 98 | add_settings_field( |
99 | 99 | 'algolia_woo_indexer_application_id', |
100 | 100 | esc_html__('Application ID', 'algolia-woo-indexer'), |
101 | - array( $algowooindexer, 'algolia_woo_indexer_application_id_output' ), |
|
101 | + array($algowooindexer, 'algolia_woo_indexer_application_id_output'), |
|
102 | 102 | 'algolia_woo_indexer', |
103 | 103 | 'algolia_woo_indexer_main' |
104 | 104 | ); |
105 | 105 | add_settings_field( |
106 | 106 | 'algolia_woo_indexer_admin_api_key', |
107 | 107 | esc_html__('Admin API Key', 'algolia-woo-indexer'), |
108 | - array( $algowooindexer, 'algolia_woo_indexer_admin_api_key_output' ), |
|
108 | + array($algowooindexer, 'algolia_woo_indexer_admin_api_key_output'), |
|
109 | 109 | 'algolia_woo_indexer', |
110 | 110 | 'algolia_woo_indexer_main' |
111 | 111 | ); |
112 | 112 | add_settings_field( |
113 | 113 | 'algolia_woo_indexer_index_name', |
114 | 114 | esc_html__('Index name (will be created if not existing)', 'algolia-woo-indexer'), |
115 | - array( $algowooindexer, 'algolia_woo_indexer_index_name_output' ), |
|
115 | + array($algowooindexer, 'algolia_woo_indexer_index_name_output'), |
|
116 | 116 | 'algolia_woo_indexer', |
117 | 117 | 'algolia_woo_indexer_main' |
118 | 118 | ); |
119 | 119 | add_settings_field( |
120 | 120 | 'algolia_woo_indexer_automatically_send_new_products', |
121 | 121 | esc_html__('Automatically index new products', 'algolia-woo-indexer'), |
122 | - array( $algowooindexer, 'algolia_woo_indexer_automatically_send_new_products_output' ), |
|
122 | + array($algowooindexer, 'algolia_woo_indexer_automatically_send_new_products_output'), |
|
123 | 123 | 'algolia_woo_indexer', |
124 | 124 | 'algolia_woo_indexer_main' |
125 | 125 | ); |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * But I have still done it to be 100% safe |
185 | 185 | */ |
186 | 186 | $auto_send_new_products = get_option(ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS); |
187 | - $auto_send_new_products = (! empty($auto_send_new_products)) ? 1 : 0; ?> |
|
187 | + $auto_send_new_products = ( ! empty($auto_send_new_products)) ? 1 : 0; ?> |
|
188 | 188 | <input id="algolia_woo_indexer_automatically_send_new_products" name="algolia_woo_indexer_automatically_send_new_products[checked]" |
189 | 189 | type="checkbox" <?php checked(1, $auto_send_new_products); ?> /> |
190 | 190 | <?php |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | */ |
231 | 231 | Algolia_Check_Requirements::check_unmet_requirements(); |
232 | 232 | |
233 | - if (! Algolia_Check_Requirements::algolia_wp_version_check() || ! Algolia_Check_Requirements::algolia_php_version_check()) { |
|
233 | + if ( ! Algolia_Check_Requirements::algolia_wp_version_check() || ! Algolia_Check_Requirements::algolia_php_version_check()) { |
|
234 | 234 | add_action( |
235 | 235 | 'admin_notices', |
236 | - function () { |
|
236 | + function() { |
|
237 | 237 | echo '<div class="error notice"> |
238 | 238 | <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> |
239 | 239 | </div>'; |
@@ -246,31 +246,31 @@ discard block |
||
246 | 246 | /** |
247 | 247 | * Setup translations |
248 | 248 | */ |
249 | - add_action('plugins_loaded', array( $ob_class, 'load_textdomain' )); |
|
249 | + add_action('plugins_loaded', array($ob_class, 'load_textdomain')); |
|
250 | 250 | |
251 | 251 | /** |
252 | 252 | * Add actions to setup admin menu |
253 | 253 | */ |
254 | 254 | if (is_admin()) { |
255 | - add_action('admin_menu', array( $ob_class, 'admin_menu' )); |
|
256 | - add_action('admin_init', array( $ob_class, 'setup_settings_sections' )); |
|
257 | - add_action('admin_init', array( $ob_class, 'update_settings_options' )); |
|
258 | - add_action('admin_init', array( $ob_class, 'maybe_send_products' )); |
|
255 | + add_action('admin_menu', array($ob_class, 'admin_menu')); |
|
256 | + add_action('admin_init', array($ob_class, 'setup_settings_sections')); |
|
257 | + add_action('admin_init', array($ob_class, 'update_settings_options')); |
|
258 | + add_action('admin_init', array($ob_class, 'maybe_send_products')); |
|
259 | 259 | |
260 | 260 | /** |
261 | 261 | * Register hook to automatically send new products if the option is set |
262 | 262 | */ |
263 | 263 | |
264 | 264 | if ('1' === $auto_send_new_products) { |
265 | - add_action('save_post', array( $ob_class, 'send_new_product_to_algolia' ), 10, 3); |
|
265 | + add_action('save_post', array($ob_class, 'send_new_product_to_algolia'), 10, 3); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | self::$plugin_url = admin_url('options-general.php?page=algolia-woo-indexer-settings'); |
269 | 269 | |
270 | - if (! is_plugin_active('woocommerce/woocommerce.php')) { |
|
270 | + if ( ! is_plugin_active('woocommerce/woocommerce.php')) { |
|
271 | 271 | add_action( |
272 | 272 | 'admin_notices', |
273 | - function () { |
|
273 | + function() { |
|
274 | 274 | echo '<div class="error notice"> |
275 | 275 | <p>' . esc_html__('WooCommerce plugin must be enabled for Algolia Woo Indexer to work.', 'algolia-woo-indexer') . '</p> |
276 | 276 | </div>'; |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | /** |
336 | 336 | * Sanitizing by setting the value to either 1 or 0 |
337 | 337 | */ |
338 | - $filtered_new_products = (! empty($auto_send_new_products)) ? 1 : 0; |
|
338 | + $filtered_new_products = ( ! empty($auto_send_new_products)) ? 1 : 0; |
|
339 | 339 | |
340 | 340 | /** |
341 | 341 | * Values have been filtered and sanitized |
@@ -343,28 +343,28 @@ discard block |
||
343 | 343 | * |
344 | 344 | * @see https://developer.wordpress.org/reference/functions/update_option/ |
345 | 345 | */ |
346 | - if (isset($filtered_application_id) && (! empty($filtered_application_id))) { |
|
346 | + if (isset($filtered_application_id) && ( ! empty($filtered_application_id))) { |
|
347 | 347 | update_option( |
348 | 348 | ALGOWOO_DB_OPTION . ALGOLIA_APP_ID, |
349 | 349 | $filtered_application_id |
350 | 350 | ); |
351 | 351 | } |
352 | 352 | |
353 | - if (isset($filtered_api_key) && (! empty($filtered_api_key))) { |
|
353 | + if (isset($filtered_api_key) && ( ! empty($filtered_api_key))) { |
|
354 | 354 | update_option( |
355 | 355 | ALGOWOO_DB_OPTION . ALGOLIA_API_KEY, |
356 | 356 | $filtered_api_key |
357 | 357 | ); |
358 | 358 | } |
359 | 359 | |
360 | - if (isset($filtered_index_name) && (! empty($filtered_index_name))) { |
|
360 | + if (isset($filtered_index_name) && ( ! empty($filtered_index_name))) { |
|
361 | 361 | update_option( |
362 | 362 | ALGOWOO_DB_OPTION . INDEX_NAME, |
363 | 363 | $filtered_index_name |
364 | 364 | ); |
365 | 365 | } |
366 | 366 | |
367 | - if (isset($filtered_new_products) && (! empty($filtered_new_products))) { |
|
367 | + if (isset($filtered_new_products) && ( ! empty($filtered_new_products))) { |
|
368 | 368 | update_option( |
369 | 369 | ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS, |
370 | 370 | $filtered_new_products |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | esc_html__('Algolia Woo Indexer Settings', 'algolia-woo-indexer'), |
413 | 413 | 'manage_options', |
414 | 414 | 'algolia-woo-indexer-settings', |
415 | - array( get_called_class(), 'algolia_woo_indexer_settings' ) |
|
415 | + array(get_called_class(), 'algolia_woo_indexer_settings') |
|
416 | 416 | ); |
417 | 417 | } |
418 | 418 | |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | /** |
427 | 427 | * Verify that the user can access the settings page |
428 | 428 | */ |
429 | - if (! current_user_can('manage_options')) { |
|
429 | + if ( ! current_user_can('manage_options')) { |
|
430 | 430 | wp_die(esc_html__('Action not allowed.', 'algolia_woo_indexer_settings')); |
431 | 431 | } ?> |
432 | 432 | <div class="wrap"> |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | */ |
454 | 454 | public static function get_instance() |
455 | 455 | { |
456 | - if (! self::$instance) { |
|
456 | + if ( ! self::$instance) { |
|
457 | 457 | self::$instance = new Algolia_Woo_Indexer(); |
458 | 458 | } |
459 | 459 | return self::$instance; |