@@ -14,27 +14,27 @@ 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 | |
28 | 28 | /** |
29 | 29 | * Define the plugin version and the database table name |
30 | 30 | */ |
31 | -define( 'ALGOWOO_DB_OPTION', '_algolia_woo_indexer' ); |
|
32 | -define( 'ALGOWOO_CURRENT_DB_VERSION', '0.3' ); |
|
31 | +define('ALGOWOO_DB_OPTION', '_algolia_woo_indexer'); |
|
32 | +define('ALGOWOO_CURRENT_DB_VERSION', '0.3'); |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Define application constants |
36 | 36 | */ |
37 | -define( 'CHANGE_ME', 'change me' ); |
|
37 | +define('CHANGE_ME', 'change me'); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Database table names |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | define('ALGOLIA_APPLICATION_ID', '_application_id'); |
45 | 45 | define('ALGOLIA_API_KEY', '_admin_api_key'); |
46 | 46 | |
47 | -if (! class_exists('Algolia_Woo_Indexer')) { |
|
47 | +if ( ! class_exists('Algolia_Woo_Indexer')) { |
|
48 | 48 | /** |
49 | 49 | * Algolia WooIndexer main class |
50 | 50 | */ |
@@ -116,34 +116,34 @@ discard block |
||
116 | 116 | add_settings_section( |
117 | 117 | 'algolia_woo_indexer_main', |
118 | 118 | esc_html__('Algolia Woo Plugin Settings', 'algolia-woo-indexer'), |
119 | - array( $algowooindexer, 'algolia_woo_indexer_section_text' ), |
|
119 | + array($algowooindexer, 'algolia_woo_indexer_section_text'), |
|
120 | 120 | 'algolia_woo_indexer' |
121 | 121 | ); |
122 | 122 | add_settings_field( |
123 | 123 | 'algolia_woo_indexer_application_id', |
124 | 124 | esc_html__('Application ID', 'algolia-woo-indexer'), |
125 | - array( $algowooindexer, 'algolia_woo_indexer_application_id_output' ), |
|
125 | + array($algowooindexer, 'algolia_woo_indexer_application_id_output'), |
|
126 | 126 | 'algolia_woo_indexer', |
127 | 127 | 'algolia_woo_indexer_main' |
128 | 128 | ); |
129 | 129 | add_settings_field( |
130 | 130 | 'algolia_woo_indexer_admin_api_key', |
131 | 131 | esc_html__('Admin API Key', 'algolia-woo-indexer'), |
132 | - array( $algowooindexer, 'algolia_woo_indexer_admin_api_key_output' ), |
|
132 | + array($algowooindexer, 'algolia_woo_indexer_admin_api_key_output'), |
|
133 | 133 | 'algolia_woo_indexer', |
134 | 134 | 'algolia_woo_indexer_main' |
135 | 135 | ); |
136 | 136 | add_settings_field( |
137 | 137 | 'algolia_woo_indexer_index_name', |
138 | 138 | esc_html__('Index name (will be created if not existing)', 'algolia-woo-indexer'), |
139 | - array( $algowooindexer, 'algolia_woo_indexer_index_name_output' ), |
|
139 | + array($algowooindexer, 'algolia_woo_indexer_index_name_output'), |
|
140 | 140 | 'algolia_woo_indexer', |
141 | 141 | 'algolia_woo_indexer_main' |
142 | 142 | ); |
143 | 143 | add_settings_field( |
144 | 144 | 'algolia_woo_indexer_automatically_send_new_products', |
145 | 145 | esc_html__('Automatically index new products', 'algolia-woo-indexer'), |
146 | - array( $algowooindexer, 'algolia_woo_indexer_automatically_send_new_products_output' ), |
|
146 | + array($algowooindexer, 'algolia_woo_indexer_automatically_send_new_products_output'), |
|
147 | 147 | 'algolia_woo_indexer', |
148 | 148 | 'algolia_woo_indexer_main' |
149 | 149 | ); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * But I have still done it to be 100% safe |
209 | 209 | */ |
210 | 210 | $automatically_send_new_products = get_option(ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS); |
211 | - $automatically_send_new_products = (! empty($automatically_send_new_products)) ? 1 : 0; ?> |
|
211 | + $automatically_send_new_products = ( ! empty($automatically_send_new_products)) ? 1 : 0; ?> |
|
212 | 212 | <input id="algolia_woo_indexer_automatically_send_new_products" name="algolia_woo_indexer_automatically_send_new_products[checked]" |
213 | 213 | type="checkbox" <?php checked(1, $automatically_send_new_products); ?> /> |
214 | 214 | <?php |
@@ -254,10 +254,10 @@ discard block |
||
254 | 254 | */ |
255 | 255 | Algolia_Check_Requirements::check_unmet_requirements(); |
256 | 256 | |
257 | - if (! Algolia_Check_Requirements::algolia_wp_version_check() || ! Algolia_Check_Requirements::algolia_php_version_check()) { |
|
257 | + if ( ! Algolia_Check_Requirements::algolia_wp_version_check() || ! Algolia_Check_Requirements::algolia_php_version_check()) { |
|
258 | 258 | add_action( |
259 | 259 | 'admin_notices', |
260 | - function () { |
|
260 | + function() { |
|
261 | 261 | echo '<div class="error notice"> |
262 | 262 | <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> |
263 | 263 | </div>'; |
@@ -270,31 +270,31 @@ discard block |
||
270 | 270 | /** |
271 | 271 | * Setup translations |
272 | 272 | */ |
273 | - add_action('plugins_loaded', array( $ob_class, 'load_textdomain' )); |
|
273 | + add_action('plugins_loaded', array($ob_class, 'load_textdomain')); |
|
274 | 274 | |
275 | 275 | /** |
276 | 276 | * Add actions to setup admin menu |
277 | 277 | */ |
278 | 278 | if (is_admin()) { |
279 | - add_action('admin_menu', array( $ob_class, 'admin_menu' )); |
|
280 | - add_action('admin_init', array( $ob_class, 'setup_settings_sections' )); |
|
281 | - add_action('admin_init', array( $ob_class, 'update_settings_options' )); |
|
282 | - add_action('admin_init', array( $ob_class, 'maybe_send_products' )); |
|
279 | + add_action('admin_menu', array($ob_class, 'admin_menu')); |
|
280 | + add_action('admin_init', array($ob_class, 'setup_settings_sections')); |
|
281 | + add_action('admin_init', array($ob_class, 'update_settings_options')); |
|
282 | + add_action('admin_init', array($ob_class, 'maybe_send_products')); |
|
283 | 283 | |
284 | 284 | /** |
285 | 285 | * Register hook to automatically send new products if the option is set |
286 | 286 | */ |
287 | 287 | |
288 | 288 | if ('1' === $automatically_send_new_products) { |
289 | - add_action('save_post', array( $ob_class, 'send_new_product_to_algolia' ), 10, 3); |
|
289 | + add_action('save_post', array($ob_class, 'send_new_product_to_algolia'), 10, 3); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | self::$plugin_url = admin_url('options-general.php?page=algolia-woo-indexer-settings'); |
293 | 293 | |
294 | - if (! is_plugin_active('woocommerce/woocommerce.php')) { |
|
294 | + if ( ! is_plugin_active('woocommerce/woocommerce.php')) { |
|
295 | 295 | add_action( |
296 | 296 | 'admin_notices', |
297 | - function () { |
|
297 | + function() { |
|
298 | 298 | echo '<div class="error notice"> |
299 | 299 | <p>' . esc_html__('WooCommerce plugin must be enabled for Algolia Woo Indexer to work.', 'algolia-woo-indexer') . '</p> |
300 | 300 | </div>'; |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | /** |
360 | 360 | * Sanitizing by setting the value to either 1 or 0 |
361 | 361 | */ |
362 | - $filtered_automatically_send_new_products = (! empty($automatically_send_new_products)) ? 1 : 0; |
|
362 | + $filtered_automatically_send_new_products = ( ! empty($automatically_send_new_products)) ? 1 : 0; |
|
363 | 363 | |
364 | 364 | /** |
365 | 365 | * Values have been filtered and sanitized |
@@ -367,28 +367,28 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @see https://developer.wordpress.org/reference/functions/update_option/ |
369 | 369 | */ |
370 | - if (isset($filtered_application_id) && (! empty($filtered_application_id))) { |
|
370 | + if (isset($filtered_application_id) && ( ! empty($filtered_application_id))) { |
|
371 | 371 | update_option( |
372 | 372 | ALGOWOO_DB_OPTION . ALGOLIA_APPLICATION_ID, |
373 | 373 | $filtered_application_id |
374 | 374 | ); |
375 | 375 | } |
376 | 376 | |
377 | - if (isset($filtered_api_key) && (! empty($filtered_api_key))) { |
|
377 | + if (isset($filtered_api_key) && ( ! empty($filtered_api_key))) { |
|
378 | 378 | update_option( |
379 | 379 | ALGOWOO_DB_OPTION . ALGOLIA_API_KEY, |
380 | 380 | $filtered_api_key |
381 | 381 | ); |
382 | 382 | } |
383 | 383 | |
384 | - if (isset($filtered_index_name) && (! empty($filtered_index_name))) { |
|
384 | + if (isset($filtered_index_name) && ( ! empty($filtered_index_name))) { |
|
385 | 385 | update_option( |
386 | 386 | ALGOWOO_DB_OPTION . INDEX_NAME, |
387 | 387 | $filtered_index_name |
388 | 388 | ); |
389 | 389 | } |
390 | 390 | |
391 | - if (isset($filtered_automatically_send_new_products) && (! empty($filtered_automatically_send_new_products))) { |
|
391 | + if (isset($filtered_automatically_send_new_products) && ( ! empty($filtered_automatically_send_new_products))) { |
|
392 | 392 | update_option( |
393 | 393 | ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS, |
394 | 394 | $filtered_automatically_send_new_products |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | if (empty($algolia_application_id) || empty($algolia_api_key || empty($algolia_index_name))) { |
426 | 426 | add_action( |
427 | 427 | 'admin_notices', |
428 | - function () { |
|
428 | + function() { |
|
429 | 429 | echo '<div class="error notice"> |
430 | 430 | <p>' . esc_html__('All settings need to be set for the plugin to work.', 'algolia-woo-indexer') . '</p> |
431 | 431 | </div>'; |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | } catch (\Algolia\AlgoliaSearch\Exceptions\UnreachableException $error) { |
448 | 448 | add_action( |
449 | 449 | 'admin_notices', |
450 | - function () { |
|
450 | + function() { |
|
451 | 451 | echo '<div class="error notice"> |
452 | 452 | <p>' . esc_html__('An error has been encountered. Please check your application ID and API key. ', 'algolia-woo-indexer') . '</p> |
453 | 453 | </div>'; |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | if (isset($id) && '' !== $id) { |
479 | 479 | $arguments = array( |
480 | 480 | 'status' => 'publish', |
481 | - 'include' => array( $id ), |
|
481 | + 'include' => array($id), |
|
482 | 482 | 'paginate' => false, |
483 | 483 | ); |
484 | 484 | } |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | */ |
491 | 491 | $products = /** @scrutinizer ignore-call */ wc_get_products($arguments); |
492 | 492 | |
493 | - if (! $products) { |
|
493 | + if ( ! $products) { |
|
494 | 494 | return; |
495 | 495 | } |
496 | 496 | $records = array(); |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | if ('Algolia\AlgoliaSearch\Response\NullResponse' === get_class($result)) { |
527 | 527 | add_action( |
528 | 528 | 'admin_notices', |
529 | - function () { |
|
529 | + function() { |
|
530 | 530 | echo '<div class="error notice is-dismissible"> |
531 | 531 | <p>' . esc_html__('No response from the server. Please check your settings and try again ', 'algolia-woo-indexer') . '</p> |
532 | 532 | </div>'; |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | esc_html__('Algolia Woo Indexer Settings', 'algolia-woo-indexer'), |
584 | 584 | 'manage_options', |
585 | 585 | 'algolia-woo-indexer-settings', |
586 | - array( get_called_class(), 'algolia_woo_indexer_settings' ) |
|
586 | + array(get_called_class(), 'algolia_woo_indexer_settings') |
|
587 | 587 | ); |
588 | 588 | } |
589 | 589 | |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | /** |
598 | 598 | * Verify that the user can access the settings page |
599 | 599 | */ |
600 | - if (! current_user_can('manage_options')) { |
|
600 | + if ( ! current_user_can('manage_options')) { |
|
601 | 601 | wp_die(esc_html__('Action not allowed.', 'algolia_woo_indexer_settings')); |
602 | 602 | } ?> |
603 | 603 | <div class="wrap"> |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | */ |
625 | 625 | public static function get_instance() |
626 | 626 | { |
627 | - if (! self::$instance) { |
|
627 | + if ( ! self::$instance) { |
|
628 | 628 | self::$instance = new Algolia_Woo_Indexer(); |
629 | 629 | } |
630 | 630 | return self::$instance; |