Passed
Branch master (6d02eb)
by Daniel
03:14 queued 01:22
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.
algolia-woo-indexer.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,26 +18,26 @@
 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
 $algowooindexer = \Algowoo\Algolia_Woo_Indexer::get_instance();
41 41
 
42
-register_activation_hook( __FILE__, array( $algowooindexer, 'activate_plugin' ) );
43
-register_deactivation_hook( __FILE__, array( $algowooindexer, 'deactivate_plugin' ) );
42
+register_activation_hook(__FILE__, array($algowooindexer, 'activate_plugin'));
43
+register_deactivation_hook(__FILE__, array($algowooindexer, 'deactivate_plugin'));
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 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -18,64 +18,64 @@
 block discarded – undo
18 18
  * Abort if this file is called directly
19 19
  */
20 20
 if (! defined('ABSPATH')) {
21
-    exit;
21
+	exit;
22 22
 }
23 23
 
24 24
 if (! class_exists('Algolia_Check_Requirements')) {
25
-    /**
26
-     * Check requirements for Algolia plugin
27
-     */
28
-    class Algolia_Check_Requirements
29
-    {
25
+	/**
26
+	 * Check requirements for Algolia plugin
27
+	 */
28
+	class Algolia_Check_Requirements
29
+	{
30 30
 
31
-        /**
32
-         * Check for required PHP version.
33
-         *
34
-         * @return bool
35
-         */
36
-        public static function algolia_php_version_check()
37
-        {
38
-            if (version_compare(PHP_VERSION, ALGOLIA_MIN_PHP_VERSION, '<')) {
39
-                return false;
40
-            }
41
-            return true;
42
-        }
31
+		/**
32
+		 * Check for required PHP version.
33
+		 *
34
+		 * @return bool
35
+		 */
36
+		public static function algolia_php_version_check()
37
+		{
38
+			if (version_compare(PHP_VERSION, ALGOLIA_MIN_PHP_VERSION, '<')) {
39
+				return false;
40
+			}
41
+			return true;
42
+		}
43 43
 
44
-        /**
45
-         * Check for required WordPress version.
46
-         *
47
-         * @return bool
48
-         */
49
-        public static function algolia_wp_version_check()
50
-        {
51
-            if (version_compare($GLOBALS['wp_version'], ALGOLIA_MIN_WP_VERSION, '<')) {
52
-                return false;
53
-            }
54
-            return true;
55
-        }
44
+		/**
45
+		 * Check for required WordPress version.
46
+		 *
47
+		 * @return bool
48
+		 */
49
+		public static function algolia_wp_version_check()
50
+		{
51
+			if (version_compare($GLOBALS['wp_version'], ALGOLIA_MIN_WP_VERSION, '<')) {
52
+				return false;
53
+			}
54
+			return true;
55
+		}
56 56
 
57
-        /**
58
-         * Check that we have all of the required PHP extensions installed
59
-         *
60
-         * @return void
61
-         */
62
-        public static function check_unmet_requirements()
63
-        {
64
-            if (! extension_loaded('mbstring')) {
65
-                echo '<div class="error notice">
57
+		/**
58
+		 * Check that we have all of the required PHP extensions installed
59
+		 *
60
+		 * @return void
61
+		 */
62
+		public static function check_unmet_requirements()
63
+		{
64
+			if (! extension_loaded('mbstring')) {
65
+				echo '<div class="error notice">
66 66
 					  <p>' . esc_html__('Algolia Woo Indexer requires the "mbstring" PHP extension to be enabled. Please contact your hosting provider.', 'algolia-woo-indexer') . '</p>
67 67
 				  </div>';
68
-            } elseif (! function_exists('mb_ereg_replace')) {
69
-                echo '<div class="error notice">
68
+			} elseif (! function_exists('mb_ereg_replace')) {
69
+				echo '<div class="error notice">
70 70
 					  <p>' . esc_html__('Algolia Woo Indexer needs "mbregex" NOT to be disabled. Please contact your hosting provider.', 'algolia-woo-indexer') . '</p>
71 71
 				  </div>';
72
-            }
73
-            if (! extension_loaded('curl')) {
74
-                echo '<div class="error notice">
72
+			}
73
+			if (! extension_loaded('curl')) {
74
+				echo '<div class="error notice">
75 75
 					  <p>' . esc_html__('Algolia Woo Indexer requires the "cURL" PHP extension to be enabled. Please contact your hosting provider.', 'algolia-woo-indexer') . '</p>
76 76
 				  </div>';
77
-                return;
78
-            }
79
-        }
77
+				return;
78
+			}
79
+		}
80 80
 	}
81 81
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 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
      */
@@ -61,16 +61,16 @@  discard block
 block discarded – undo
61 61
          */
62 62
         public static function check_unmet_requirements()
63 63
         {
64
-            if (! extension_loaded('mbstring')) {
64
+            if ( ! extension_loaded('mbstring')) {
65 65
                 echo '<div class="error notice">
66 66
 					  <p>' . esc_html__('Algolia Woo Indexer requires the "mbstring" PHP extension to be enabled. Please contact your hosting provider.', 'algolia-woo-indexer') . '</p>
67 67
 				  </div>';
68
-            } elseif (! function_exists('mb_ereg_replace')) {
68
+            } elseif ( ! function_exists('mb_ereg_replace')) {
69 69
                 echo '<div class="error notice">
70 70
 					  <p>' . esc_html__('Algolia Woo Indexer needs "mbregex" NOT to be disabled. Please contact your hosting provider.', 'algolia-woo-indexer') . '</p>
71 71
 				  </div>';
72 72
             }
73
-            if (! extension_loaded('curl')) {
73
+            if ( ! extension_loaded('curl')) {
74 74
                 echo '<div class="error notice">
75 75
 					  <p>' . esc_html__('Algolia Woo Indexer requires the "cURL" PHP extension to be enabled. Please contact your hosting provider.', 'algolia-woo-indexer') . '</p>
76 76
 				  </div>';
Please login to merge, or discard this patch.
classes/class-algolia-woo-indexer.php 2 patches
Indentation   +594 added lines, -594 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  * Include plugin file if function is_plugin_active does not exist
23 23
  */
24 24
 if (! function_exists('is_plugin_active')) {
25
-    require_once(ABSPATH . '/wp-admin/includes/plugin.php');
25
+	require_once(ABSPATH . '/wp-admin/includes/plugin.php');
26 26
 }
27 27
 
28 28
 /**
@@ -45,356 +45,356 @@  discard block
 block discarded – undo
45 45
 define('ALGOLIA_API_KEY', '_admin_api_key');
46 46
 
47 47
 if (! class_exists('Algolia_Woo_Indexer')) {
48
-    /**
49
-     * Algolia WooIndexer main class
50
-     */
51
-    class Algolia_Woo_Indexer
52
-    {
53
-        const PLUGIN_NAME      = 'Algolia Woo Indexer';
54
-        const PLUGIN_TRANSIENT = 'algowoo-plugin-notice';
55
-
56
-        /**
57
-         * Class instance
58
-         *
59
-         * @var object
60
-         */
61
-        private static $instance;
62
-
63
-        /**
64
-         * The plugin URL
65
-         *
66
-         * @var string
67
-         */
68
-        private static $plugin_url = '';
69
-
70
-        /**
71
-         * The Algolia instance
72
-         *
73
-         * @var \Algolia\AlgoliaSearch\SearchClient
74
-         */
75
-        private static $algolia = null;
76
-
77
-        /**
78
-         * Class constructor
79
-         *
80
-         * @return void
81
-         */
82
-        public function __construct()
83
-        {
84
-            $this->init();
85
-        }
86
-
87
-        /**
88
-         * Setup sections and fields to store and retrieve values from Settings API
89
-         *
90
-         * @return void
91
-         */
92
-        public static function setup_settings_sections()
93
-        {
94
-            /**
95
-            * Setup arguments for settings sections and fields
96
-            *
97
-            * @see https://developer.wordpress.org/reference/functions/register_setting/
98
-            */
99
-            if (is_admin()) {
100
-                $arguments = array(
101
-                    'type'              => 'string',
102
-                    'sanitize_callback' => 'settings_fields_validate_options',
103
-                    'default'           => null,
104
-                );
105
-                register_setting('algolia_woo_options', 'algolia_woo_options', $arguments);
106
-
107
-                /**
108
-                 * Make sure we reference the instance of the current class by using self::get_instance()
109
-                 * This way we can setup the correct callback function for add_settings_section and add_settings_field
110
-                 */
111
-                $algowooindexer = self::get_instance();
112
-
113
-                /**
114
-                 * Add our necessary settings sections and fields
115
-                 */
116
-                add_settings_section(
117
-                    'algolia_woo_indexer_main',
118
-                    esc_html__('Algolia Woo Plugin Settings', 'algolia-woo-indexer'),
119
-                    array( $algowooindexer, 'algolia_woo_indexer_section_text' ),
120
-                    'algolia_woo_indexer'
121
-                );
122
-                add_settings_field(
123
-                    'algolia_woo_indexer_application_id',
124
-                    esc_html__('Application ID', 'algolia-woo-indexer'),
125
-                    array( $algowooindexer, 'algolia_woo_indexer_application_id_output' ),
126
-                    'algolia_woo_indexer',
127
-                    'algolia_woo_indexer_main'
128
-                );
129
-                add_settings_field(
130
-                    'algolia_woo_indexer_admin_api_key',
131
-                    esc_html__('Admin API Key', 'algolia-woo-indexer'),
132
-                    array( $algowooindexer, 'algolia_woo_indexer_admin_api_key_output' ),
133
-                    'algolia_woo_indexer',
134
-                    'algolia_woo_indexer_main'
135
-                );
136
-                add_settings_field(
137
-                    'algolia_woo_indexer_index_name',
138
-                    esc_html__('Index name (will be created if not existing)', 'algolia-woo-indexer'),
139
-                    array( $algowooindexer, 'algolia_woo_indexer_index_name_output' ),
140
-                    'algolia_woo_indexer',
141
-                    'algolia_woo_indexer_main'
142
-                );
143
-                add_settings_field(
144
-                    'algolia_woo_indexer_automatically_send_new_products',
145
-                    esc_html__('Automatically index new products', 'algolia-woo-indexer'),
146
-                    array( $algowooindexer, 'algolia_woo_indexer_automatically_send_new_products_output' ),
147
-                    'algolia_woo_indexer',
148
-                    'algolia_woo_indexer_main'
149
-                );
150
-            }
151
-        }
152
-
153
-        /**
154
-         * Output for admin API key field
155
-         *
156
-         * @see https://developer.wordpress.org/reference/functions/wp_nonce_field/
157
-         *
158
-         * @return void
159
-         */
160
-        public static function algolia_woo_indexer_admin_api_key_output()
161
-        {
162
-            $api_key = get_option(ALGOWOO_DB_OPTION . ALGOLIA_API_KEY);
163
-            $api_key = is_string($api_key) ? $api_key : CHANGE_ME;
164
-
165
-            wp_nonce_field('algolia_woo_indexer_admin_api_nonce_action', 'algolia_woo_indexer_admin_api_nonce_name');
166
-
167
-            echo "<input id='algolia_woo_indexer_admin_api_key' name='algolia_woo_indexer_admin_api_key[key]'
48
+	/**
49
+	 * Algolia WooIndexer main class
50
+	 */
51
+	class Algolia_Woo_Indexer
52
+	{
53
+		const PLUGIN_NAME      = 'Algolia Woo Indexer';
54
+		const PLUGIN_TRANSIENT = 'algowoo-plugin-notice';
55
+
56
+		/**
57
+		 * Class instance
58
+		 *
59
+		 * @var object
60
+		 */
61
+		private static $instance;
62
+
63
+		/**
64
+		 * The plugin URL
65
+		 *
66
+		 * @var string
67
+		 */
68
+		private static $plugin_url = '';
69
+
70
+		/**
71
+		 * The Algolia instance
72
+		 *
73
+		 * @var \Algolia\AlgoliaSearch\SearchClient
74
+		 */
75
+		private static $algolia = null;
76
+
77
+		/**
78
+		 * Class constructor
79
+		 *
80
+		 * @return void
81
+		 */
82
+		public function __construct()
83
+		{
84
+			$this->init();
85
+		}
86
+
87
+		/**
88
+		 * Setup sections and fields to store and retrieve values from Settings API
89
+		 *
90
+		 * @return void
91
+		 */
92
+		public static function setup_settings_sections()
93
+		{
94
+			/**
95
+			 * Setup arguments for settings sections and fields
96
+			 *
97
+			 * @see https://developer.wordpress.org/reference/functions/register_setting/
98
+			 */
99
+			if (is_admin()) {
100
+				$arguments = array(
101
+					'type'              => 'string',
102
+					'sanitize_callback' => 'settings_fields_validate_options',
103
+					'default'           => null,
104
+				);
105
+				register_setting('algolia_woo_options', 'algolia_woo_options', $arguments);
106
+
107
+				/**
108
+				 * Make sure we reference the instance of the current class by using self::get_instance()
109
+				 * This way we can setup the correct callback function for add_settings_section and add_settings_field
110
+				 */
111
+				$algowooindexer = self::get_instance();
112
+
113
+				/**
114
+				 * Add our necessary settings sections and fields
115
+				 */
116
+				add_settings_section(
117
+					'algolia_woo_indexer_main',
118
+					esc_html__('Algolia Woo Plugin Settings', 'algolia-woo-indexer'),
119
+					array( $algowooindexer, 'algolia_woo_indexer_section_text' ),
120
+					'algolia_woo_indexer'
121
+				);
122
+				add_settings_field(
123
+					'algolia_woo_indexer_application_id',
124
+					esc_html__('Application ID', 'algolia-woo-indexer'),
125
+					array( $algowooindexer, 'algolia_woo_indexer_application_id_output' ),
126
+					'algolia_woo_indexer',
127
+					'algolia_woo_indexer_main'
128
+				);
129
+				add_settings_field(
130
+					'algolia_woo_indexer_admin_api_key',
131
+					esc_html__('Admin API Key', 'algolia-woo-indexer'),
132
+					array( $algowooindexer, 'algolia_woo_indexer_admin_api_key_output' ),
133
+					'algolia_woo_indexer',
134
+					'algolia_woo_indexer_main'
135
+				);
136
+				add_settings_field(
137
+					'algolia_woo_indexer_index_name',
138
+					esc_html__('Index name (will be created if not existing)', 'algolia-woo-indexer'),
139
+					array( $algowooindexer, 'algolia_woo_indexer_index_name_output' ),
140
+					'algolia_woo_indexer',
141
+					'algolia_woo_indexer_main'
142
+				);
143
+				add_settings_field(
144
+					'algolia_woo_indexer_automatically_send_new_products',
145
+					esc_html__('Automatically index new products', 'algolia-woo-indexer'),
146
+					array( $algowooindexer, 'algolia_woo_indexer_automatically_send_new_products_output' ),
147
+					'algolia_woo_indexer',
148
+					'algolia_woo_indexer_main'
149
+				);
150
+			}
151
+		}
152
+
153
+		/**
154
+		 * Output for admin API key field
155
+		 *
156
+		 * @see https://developer.wordpress.org/reference/functions/wp_nonce_field/
157
+		 *
158
+		 * @return void
159
+		 */
160
+		public static function algolia_woo_indexer_admin_api_key_output()
161
+		{
162
+			$api_key = get_option(ALGOWOO_DB_OPTION . ALGOLIA_API_KEY);
163
+			$api_key = is_string($api_key) ? $api_key : CHANGE_ME;
164
+
165
+			wp_nonce_field('algolia_woo_indexer_admin_api_nonce_action', 'algolia_woo_indexer_admin_api_nonce_name');
166
+
167
+			echo "<input id='algolia_woo_indexer_admin_api_key' name='algolia_woo_indexer_admin_api_key[key]'
168 168
 				type='text' value='" . esc_attr($api_key) . "' />";
169
-        }
170
-
171
-        /**
172
-         * Output for application ID field
173
-         *
174
-         * @return void
175
-         */
176
-        public static function algolia_woo_indexer_application_id_output()
177
-        {
178
-            $application_id = get_option(ALGOWOO_DB_OPTION . ALGOLIA_APPLICATION_ID);
179
-            $application_id = is_string($application_id) ? $application_id : CHANGE_ME;
180
-
181
-            echo "<input id='algolia_woo_indexer_application_id' name='algolia_woo_indexer_application_id[id]'
169
+		}
170
+
171
+		/**
172
+		 * Output for application ID field
173
+		 *
174
+		 * @return void
175
+		 */
176
+		public static function algolia_woo_indexer_application_id_output()
177
+		{
178
+			$application_id = get_option(ALGOWOO_DB_OPTION . ALGOLIA_APPLICATION_ID);
179
+			$application_id = is_string($application_id) ? $application_id : CHANGE_ME;
180
+
181
+			echo "<input id='algolia_woo_indexer_application_id' name='algolia_woo_indexer_application_id[id]'
182 182
 				type='text' value='" . esc_attr($application_id) . "' />";
183
-        }
184
-
185
-        /**
186
-         * Output for index name field
187
-         *
188
-         * @return void
189
-         */
190
-        public static function algolia_woo_indexer_index_name_output()
191
-        {
192
-            $index_name = get_option(ALGOWOO_DB_OPTION . INDEX_NAME);
193
-            $index_name = is_string($index_name) ? $index_name : CHANGE_ME;
194
-
195
-            echo "<input id='algolia_woo_indexer_index_name' name='algolia_woo_indexer_index_name[name]'
183
+		}
184
+
185
+		/**
186
+		 * Output for index name field
187
+		 *
188
+		 * @return void
189
+		 */
190
+		public static function algolia_woo_indexer_index_name_output()
191
+		{
192
+			$index_name = get_option(ALGOWOO_DB_OPTION . INDEX_NAME);
193
+			$index_name = is_string($index_name) ? $index_name : CHANGE_ME;
194
+
195
+			echo "<input id='algolia_woo_indexer_index_name' name='algolia_woo_indexer_index_name[name]'
196 196
 				type='text' value='" . esc_attr($index_name) . "' />";
197
-        }
197
+		}
198 198
         
199
-        /**
200
-         * Output for checkbox to check if we automatically send new products to Algolia
201
-         *
202
-         * @return void
203
-         */
204
-        public static function algolia_woo_indexer_automatically_send_new_products_output()
205
-        {
206
-            /**
207
-             * Sanitization is not really needed as the variable is not directly echoed
208
-             * But I have still done it to be 100% safe
209
-             */
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; ?>
199
+		/**
200
+		 * Output for checkbox to check if we automatically send new products to Algolia
201
+		 *
202
+		 * @return void
203
+		 */
204
+		public static function algolia_woo_indexer_automatically_send_new_products_output()
205
+		{
206
+			/**
207
+			 * Sanitization is not really needed as the variable is not directly echoed
208
+			 * But I have still done it to be 100% safe
209
+			 */
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; ?>
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
215
-        }
216
-
217
-        /**
218
-         * Section text for plugin settings section text
219
-         *
220
-         * @return void
221
-         */
222
-        public static function algolia_woo_indexer_section_text()
223
-        {
224
-            echo esc_html__('Enter your settings here', 'algolia-woo-indexer');
225
-        }
226
-
227
-        /**
228
-         * Check if we are going to send products by verifying send products nonce
229
-         *
230
-         * @return void
231
-         */
232
-        public static function maybe_send_products()
233
-        {
234
-            if (true === Algolia_Verify_Nonces::verify_send_products_nonce()) {
235
-                self::send_products_to_algolia();
236
-            }
237
-        }
238
-
239
-        /**
240
-         * Initialize class, setup settings sections and fields
241
-         *
242
-         * @return void
243
-         */
244
-        public static function init()
245
-        {
246
-
247
-            /**
248
-             * Fetch the option to see if we are going to automatically send new products
249
-             */
250
-            $automatically_send_new_products = get_option(ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS);
251
-
252
-            /**
253
-             * Check that we have the minimum versions required and all of the required PHP extensions
254
-             */
255
-            Algolia_Check_Requirements::check_unmet_requirements();
256
-
257
-            if (! Algolia_Check_Requirements::algolia_wp_version_check() || ! Algolia_Check_Requirements::algolia_php_version_check()) {
258
-                add_action(
259
-                    'admin_notices',
260
-                    function () {
261
-                        echo '<div class="error notice">
215
+		}
216
+
217
+		/**
218
+		 * Section text for plugin settings section text
219
+		 *
220
+		 * @return void
221
+		 */
222
+		public static function algolia_woo_indexer_section_text()
223
+		{
224
+			echo esc_html__('Enter your settings here', 'algolia-woo-indexer');
225
+		}
226
+
227
+		/**
228
+		 * Check if we are going to send products by verifying send products nonce
229
+		 *
230
+		 * @return void
231
+		 */
232
+		public static function maybe_send_products()
233
+		{
234
+			if (true === Algolia_Verify_Nonces::verify_send_products_nonce()) {
235
+				self::send_products_to_algolia();
236
+			}
237
+		}
238
+
239
+		/**
240
+		 * Initialize class, setup settings sections and fields
241
+		 *
242
+		 * @return void
243
+		 */
244
+		public static function init()
245
+		{
246
+
247
+			/**
248
+			 * Fetch the option to see if we are going to automatically send new products
249
+			 */
250
+			$automatically_send_new_products = get_option(ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS);
251
+
252
+			/**
253
+			 * Check that we have the minimum versions required and all of the required PHP extensions
254
+			 */
255
+			Algolia_Check_Requirements::check_unmet_requirements();
256
+
257
+			if (! Algolia_Check_Requirements::algolia_wp_version_check() || ! Algolia_Check_Requirements::algolia_php_version_check()) {
258
+				add_action(
259
+					'admin_notices',
260
+					function () {
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>';
264
-                    }
265
-                );
266
-            }
267
-
268
-            $ob_class = get_called_class();
269
-
270
-            /**
271
-             * Setup translations
272
-             */
273
-            add_action('plugins_loaded', array( $ob_class, 'load_textdomain' ));
274
-
275
-            /**
276
-             * Add actions to setup admin menu
277
-             */
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' ));
283
-
284
-                /**
285
-                 * Register hook to automatically send new products if the option is set
286
-                 */
287
-
288
-                if ('1' === $automatically_send_new_products) {
289
-                    add_action('save_post', array( $ob_class, 'send_new_product_to_algolia' ), 10, 3);
290
-                }
291
-
292
-                self::$plugin_url = admin_url('options-general.php?page=algolia-woo-indexer-settings');
293
-
294
-                if (! is_plugin_active('woocommerce/woocommerce.php')) {
295
-                    add_action(
296
-                        'admin_notices',
297
-                        function () {
298
-                            echo '<div class="error notice">
264
+					}
265
+				);
266
+			}
267
+
268
+			$ob_class = get_called_class();
269
+
270
+			/**
271
+			 * Setup translations
272
+			 */
273
+			add_action('plugins_loaded', array( $ob_class, 'load_textdomain' ));
274
+
275
+			/**
276
+			 * Add actions to setup admin menu
277
+			 */
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' ));
283
+
284
+				/**
285
+				 * Register hook to automatically send new products if the option is set
286
+				 */
287
+
288
+				if ('1' === $automatically_send_new_products) {
289
+					add_action('save_post', array( $ob_class, 'send_new_product_to_algolia' ), 10, 3);
290
+				}
291
+
292
+				self::$plugin_url = admin_url('options-general.php?page=algolia-woo-indexer-settings');
293
+
294
+				if (! is_plugin_active('woocommerce/woocommerce.php')) {
295
+					add_action(
296
+						'admin_notices',
297
+						function () {
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>';
301
-                        }
302
-                    );
303
-                }
304
-            }
305
-        }
306
-
307
-        /**
308
-         * Send a single product to Algolia once a new product has been published
309
-         *
310
-         * @param int   $post_id ID of the product.
311
-         * @param array $post Post array.
312
-         *
313
-         * @return void
314
-         */
315
-        public static function send_new_product_to_algolia($post_id, $post)
316
-        {
317
-            if ('publish' !== $post->post_status || 'product' !== $post->post_type) {
318
-                return;
319
-            }
320
-            self::send_products_to_algolia($post_id);
321
-        }
322
-
323
-        /**
324
-         * Verify nonces before we update options and settings
325
-         * Also retrieve the value from the send_products_to_algolia hidden field to check if we are sending products to Algolia
326
-         *
327
-         * @return void
328
-         */
329
-        public static function update_settings_options()
330
-        {
331
-            Algolia_Verify_Nonces::verify_settings_nonce();
332
-
333
-            /**
334
-             * Do not proceed if we are going to send products
335
-             */
336
-            if (true === Algolia_Verify_Nonces::verify_send_products_nonce()) {
337
-                return;
338
-            }
339
-
340
-            /**
341
-             * Filter the application id, api key, index name and verify that the input is an array
342
-             *
343
-             * @see https://www.php.net/manual/en/function.filter-input.php
344
-             */
345
-            $post_application_id             = filter_input(INPUT_POST, 'algolia_woo_indexer_application_id', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
346
-            $post_api_key                    = filter_input(INPUT_POST, 'algolia_woo_indexer_admin_api_key', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
347
-            $post_index_name                 = filter_input(INPUT_POST, 'algolia_woo_indexer_index_name', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
348
-            $automatically_send_new_products = filter_input(INPUT_POST, 'algolia_woo_indexer_automatically_send_new_products', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
349
-
350
-            /**
351
-             * Properly sanitize text fields before updating data
352
-             *
353
-             * @see https://developer.wordpress.org/reference/functions/sanitize_text_field/
354
-             */
355
-            $filtered_application_id = sanitize_text_field($post_application_id['id']);
356
-            $filtered_api_key        = sanitize_text_field($post_api_key['key']);
357
-            $filtered_index_name     = sanitize_text_field($post_index_name['name']);
358
-
359
-            /**
360
-             * Sanitizing by setting the value to either 1 or 0
361
-             */
362
-            $filtered_automatically_send_new_products = (! empty($automatically_send_new_products)) ? 1 : 0;
363
-
364
-            /**
365
-             * Values have been filtered and sanitized
366
-             * Check if set and not empty and update the database
367
-             *
368
-             * @see https://developer.wordpress.org/reference/functions/update_option/
369
-             */
370
-            if (isset($filtered_application_id) && (! empty($filtered_application_id))) {
371
-                update_option(
372
-                    ALGOWOO_DB_OPTION . ALGOLIA_APPLICATION_ID,
373
-                    $filtered_application_id
374
-                );
375
-            }
376
-
377
-            if (isset($filtered_api_key) && (! empty($filtered_api_key))) {
378
-                update_option(
379
-                    ALGOWOO_DB_OPTION . ALGOLIA_API_KEY,
380
-                    $filtered_api_key
381
-                );
382
-            }
383
-
384
-            if (isset($filtered_index_name) && (! empty($filtered_index_name))) {
385
-                update_option(
386
-                    ALGOWOO_DB_OPTION . INDEX_NAME,
387
-                    $filtered_index_name
388
-                );
389
-            }
390
-
391
-            if (isset($filtered_automatically_send_new_products) && (! empty($filtered_automatically_send_new_products))) {
392
-                update_option(
393
-                    ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS,
394
-                    $filtered_automatically_send_new_products
395
-                );
396
-            }
397
-        }
301
+						}
302
+					);
303
+				}
304
+			}
305
+		}
306
+
307
+		/**
308
+		 * Send a single product to Algolia once a new product has been published
309
+		 *
310
+		 * @param int   $post_id ID of the product.
311
+		 * @param array $post Post array.
312
+		 *
313
+		 * @return void
314
+		 */
315
+		public static function send_new_product_to_algolia($post_id, $post)
316
+		{
317
+			if ('publish' !== $post->post_status || 'product' !== $post->post_type) {
318
+				return;
319
+			}
320
+			self::send_products_to_algolia($post_id);
321
+		}
322
+
323
+		/**
324
+		 * Verify nonces before we update options and settings
325
+		 * Also retrieve the value from the send_products_to_algolia hidden field to check if we are sending products to Algolia
326
+		 *
327
+		 * @return void
328
+		 */
329
+		public static function update_settings_options()
330
+		{
331
+			Algolia_Verify_Nonces::verify_settings_nonce();
332
+
333
+			/**
334
+			 * Do not proceed if we are going to send products
335
+			 */
336
+			if (true === Algolia_Verify_Nonces::verify_send_products_nonce()) {
337
+				return;
338
+			}
339
+
340
+			/**
341
+			 * Filter the application id, api key, index name and verify that the input is an array
342
+			 *
343
+			 * @see https://www.php.net/manual/en/function.filter-input.php
344
+			 */
345
+			$post_application_id             = filter_input(INPUT_POST, 'algolia_woo_indexer_application_id', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
346
+			$post_api_key                    = filter_input(INPUT_POST, 'algolia_woo_indexer_admin_api_key', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
347
+			$post_index_name                 = filter_input(INPUT_POST, 'algolia_woo_indexer_index_name', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
348
+			$automatically_send_new_products = filter_input(INPUT_POST, 'algolia_woo_indexer_automatically_send_new_products', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
349
+
350
+			/**
351
+			 * Properly sanitize text fields before updating data
352
+			 *
353
+			 * @see https://developer.wordpress.org/reference/functions/sanitize_text_field/
354
+			 */
355
+			$filtered_application_id = sanitize_text_field($post_application_id['id']);
356
+			$filtered_api_key        = sanitize_text_field($post_api_key['key']);
357
+			$filtered_index_name     = sanitize_text_field($post_index_name['name']);
358
+
359
+			/**
360
+			 * Sanitizing by setting the value to either 1 or 0
361
+			 */
362
+			$filtered_automatically_send_new_products = (! empty($automatically_send_new_products)) ? 1 : 0;
363
+
364
+			/**
365
+			 * Values have been filtered and sanitized
366
+			 * Check if set and not empty and update the database
367
+			 *
368
+			 * @see https://developer.wordpress.org/reference/functions/update_option/
369
+			 */
370
+			if (isset($filtered_application_id) && (! empty($filtered_application_id))) {
371
+				update_option(
372
+					ALGOWOO_DB_OPTION . ALGOLIA_APPLICATION_ID,
373
+					$filtered_application_id
374
+				);
375
+			}
376
+
377
+			if (isset($filtered_api_key) && (! empty($filtered_api_key))) {
378
+				update_option(
379
+					ALGOWOO_DB_OPTION . ALGOLIA_API_KEY,
380
+					$filtered_api_key
381
+				);
382
+			}
383
+
384
+			if (isset($filtered_index_name) && (! empty($filtered_index_name))) {
385
+				update_option(
386
+					ALGOWOO_DB_OPTION . INDEX_NAME,
387
+					$filtered_index_name
388
+				);
389
+			}
390
+
391
+			if (isset($filtered_automatically_send_new_products) && (! empty($filtered_automatically_send_new_products))) {
392
+				update_option(
393
+					ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS,
394
+					$filtered_automatically_send_new_products
395
+				);
396
+			}
397
+		}
398 398
 
399 399
 		/**
400 400
 		 * Check if values are empty and display error notice if not all values have been set
@@ -407,224 +407,224 @@  discard block
 block discarded – undo
407 407
 		public static function check_algolia_input_values($algolia_application_id, $algolia_api_key, $algolia_index_name )
408 408
 		{	
409 409
 			if (empty($algolia_application_id) || empty($algolia_api_key || empty($algolia_index_name))) {
410
-                add_action(
411
-                    'admin_notices',
412
-                    function () {
413
-                        echo '<div class="error notice">
410
+				add_action(
411
+					'admin_notices',
412
+					function () {
413
+						echo '<div class="error notice">
414 414
 							  <p>' . esc_html__('All settings need to be set for the plugin to work.', 'algolia-woo-indexer') . '</p>
415 415
 							</div>';
416
-                    }
417
-                );
418
-                return;
419
-            }
420
-        }
416
+					}
417
+				);
418
+				return;
419
+			}
420
+		}
421 421
 
422 422
 		/**
423 423
 		 * Check if we can connect to Algolia, if not, handle the exception, display an error and then return
424 424
 		 */
425 425
 		public static function can_connect_to_algolia() {
426
-            try {
427
-                self::$algolia->listApiKeys();
428
-            } catch (\Algolia\AlgoliaSearch\Exceptions\UnreachableException $error) {
429
-                add_action(
430
-                    'admin_notices',
431
-                    function () {
432
-                        echo '<div class="error notice">
426
+			try {
427
+				self::$algolia->listApiKeys();
428
+			} catch (\Algolia\AlgoliaSearch\Exceptions\UnreachableException $error) {
429
+				add_action(
430
+					'admin_notices',
431
+					function () {
432
+						echo '<div class="error notice">
433 433
 							  <p>' . esc_html__('An error has been encountered. Please check your application ID and API key. ', 'algolia-woo-indexer') . '</p>
434 434
 							</div>';
435
-                    }
436
-                );
437
-                return;
438
-            }
435
+					}
436
+				);
437
+				return;
438
+			}
439 439
 		}
440 440
 
441
-        /**
442
-         * Send WooCommerce products to Algolia
443
-         *
444
-         * @param Int $id Product to send to Algolia if we send only a single product
445
-         * @return void
446
-         */
447
-        public static function send_products_to_algolia($id = '')
448
-        {
449
-            /**
450
-             * Remove classes from plugin URL and autoload Algolia with Composer
451
-             */
452
-
453
-            $base_plugin_directory = str_replace('classes', '', dirname(__FILE__));
454
-            require_once $base_plugin_directory . '/vendor/autoload.php';
455
-
456
-            /**
457
-             * Fetch the required variables from the Settings API
458
-             */
459
-
460
-            $algolia_application_id = get_option(ALGOWOO_DB_OPTION . ALGOLIA_APPLICATION_ID);
441
+		/**
442
+		 * Send WooCommerce products to Algolia
443
+		 *
444
+		 * @param Int $id Product to send to Algolia if we send only a single product
445
+		 * @return void
446
+		 */
447
+		public static function send_products_to_algolia($id = '')
448
+		{
449
+			/**
450
+			 * Remove classes from plugin URL and autoload Algolia with Composer
451
+			 */
452
+
453
+			$base_plugin_directory = str_replace('classes', '', dirname(__FILE__));
454
+			require_once $base_plugin_directory . '/vendor/autoload.php';
455
+
456
+			/**
457
+			 * Fetch the required variables from the Settings API
458
+			 */
459
+
460
+			$algolia_application_id = get_option(ALGOWOO_DB_OPTION . ALGOLIA_APPLICATION_ID);
461 461
 			$algolia_application_id = is_string($algolia_application_id) ? $algolia_application_id : CHANGE_ME;
462 462
 
463
-            $algolia_api_key        = get_option(ALGOWOO_DB_OPTION . ALGOLIA_API_KEY);
463
+			$algolia_api_key        = get_option(ALGOWOO_DB_OPTION . ALGOLIA_API_KEY);
464 464
 			$algolia_api_key		= is_string($algolia_api_key) ?$algolia_api_key : CHANGE_ME;
465 465
 
466
-            $algolia_index_name     = get_option(ALGOWOO_DB_OPTION . INDEX_NAME);
466
+			$algolia_index_name     = get_option(ALGOWOO_DB_OPTION . INDEX_NAME);
467 467
 			$algolia_index_name		= is_string($algolia_index_name) ? $algolia_index_name : CHANGE_ME;
468 468
 
469 469
 			/**
470
-             * Display admin notice and return if not all values have been set
471
-             */
470
+			 * Display admin notice and return if not all values have been set
471
+			 */
472 472
 
473 473
 			self::check_algolia_input_values($algolia_application_id, $algolia_api_key, $algolia_index_name);
474 474
 
475
-            /**
476
-             * Initiate the Algolia client
477
-             */
478
-            self::$algolia = \Algolia\AlgoliaSearch\SearchClient::create($algolia_application_id, $algolia_api_key);
475
+			/**
476
+			 * Initiate the Algolia client
477
+			 */
478
+			self::$algolia = \Algolia\AlgoliaSearch\SearchClient::create($algolia_application_id, $algolia_api_key);
479 479
 
480 480
 			/**
481
-             * Check if we can connect, if not, handle the exception, display an error and then return
482
-             */
481
+			 * Check if we can connect, if not, handle the exception, display an error and then return
482
+			 */
483 483
 			self::can_connect_to_algolia();
484 484
 			
485 485
 			/**
486
-             * Initialize the search index and set the name to the option from the database
487
-             */
488
-            $index = self::$algolia->initIndex($algolia_index_name);
489
-
490
-            /**
491
-             * Setup arguments for sending all products to Algolia
492
-             *
493
-             * Limit => -1 means we send all products
494
-             */
495
-            $arguments = array(
496
-                'status'   => 'publish',
497
-                'limit'    => -1,
498
-                'paginate' => false,
499
-            );
500
-
501
-            /**
502
-            * Setup arguments for sending only a single product
503
-            */
504
-            if (isset($id) && '' !== $id) {
505
-                $arguments = array(
506
-                    'status'   => 'publish',
507
-                    'include'  => array( $id ),
508
-                    'paginate' => false,
509
-                );
510
-            }
511
-
512
-            /**
513
-             * Fetch all products from WooCommerce
514
-             *
515
-             * @see https://docs.woocommerce.com/wc-apidocs/function-wc_get_products.html
516
-             */
517
-            $products = /** @scrutinizer ignore-call */ wc_get_products($arguments);
518
-
519
-            if ( empty( $products ) ) {
520
-                return;
521
-            }
522
-            $records = array();
523
-            $record  = array();
524
-
525
-            foreach ($products as $product) {
526
-                /**
527
-                 * Extract image from $product->get_image()
528
-                 */
529
-                preg_match('/<img(.*)src(.*)=(.*)"(.*)"/U', $product->get_image(), $result);
530
-                $product_image = array_pop($result);
531
-                /**
532
-                 * Build the record array using the information from the WooCommerce product
533
-                 */
534
-                $record['objectID']          = $product->get_id();
535
-                $record['product_name']      = $product->get_name();
536
-                $record['product_image']     = $product_image;
537
-                $record['short_description'] = $product->get_short_description();
538
-                $record['regular_price']     = $product->get_regular_price();
539
-                $record['sale_price']        = $product->get_sale_price();
540
-                $record['on_sale']           = $product->is_on_sale();
541
-
542
-                $records[] = $record;
543
-            }
544
-            wp_reset_postdata();
545
-
546
-            /**
547
-             * Send the information to Algolia and save the result
548
-             * If result is NullResponse, print an error message
549
-             */
550
-            $result = $index->saveObjects($records);
551
-
552
-            if ('Algolia\AlgoliaSearch\Response\NullResponse' === get_class($result)) {
486
+			 * Initialize the search index and set the name to the option from the database
487
+			 */
488
+			$index = self::$algolia->initIndex($algolia_index_name);
489
+
490
+			/**
491
+			 * Setup arguments for sending all products to Algolia
492
+			 *
493
+			 * Limit => -1 means we send all products
494
+			 */
495
+			$arguments = array(
496
+				'status'   => 'publish',
497
+				'limit'    => -1,
498
+				'paginate' => false,
499
+			);
500
+
501
+			/**
502
+			 * Setup arguments for sending only a single product
503
+			 */
504
+			if (isset($id) && '' !== $id) {
505
+				$arguments = array(
506
+					'status'   => 'publish',
507
+					'include'  => array( $id ),
508
+					'paginate' => false,
509
+				);
510
+			}
511
+
512
+			/**
513
+			 * Fetch all products from WooCommerce
514
+			 *
515
+			 * @see https://docs.woocommerce.com/wc-apidocs/function-wc_get_products.html
516
+			 */
517
+			$products = /** @scrutinizer ignore-call */ wc_get_products($arguments);
518
+
519
+			if ( empty( $products ) ) {
520
+				return;
521
+			}
522
+			$records = array();
523
+			$record  = array();
524
+
525
+			foreach ($products as $product) {
526
+				/**
527
+				 * Extract image from $product->get_image()
528
+				 */
529
+				preg_match('/<img(.*)src(.*)=(.*)"(.*)"/U', $product->get_image(), $result);
530
+				$product_image = array_pop($result);
531
+				/**
532
+				 * Build the record array using the information from the WooCommerce product
533
+				 */
534
+				$record['objectID']          = $product->get_id();
535
+				$record['product_name']      = $product->get_name();
536
+				$record['product_image']     = $product_image;
537
+				$record['short_description'] = $product->get_short_description();
538
+				$record['regular_price']     = $product->get_regular_price();
539
+				$record['sale_price']        = $product->get_sale_price();
540
+				$record['on_sale']           = $product->is_on_sale();
541
+
542
+				$records[] = $record;
543
+			}
544
+			wp_reset_postdata();
545
+
546
+			/**
547
+			 * Send the information to Algolia and save the result
548
+			 * If result is NullResponse, print an error message
549
+			 */
550
+			$result = $index->saveObjects($records);
551
+
552
+			if ('Algolia\AlgoliaSearch\Response\NullResponse' === get_class($result)) {
553 553
 				wp_die(esc_html__('No response from the server. Please check your settings and try again', 'algolia_woo_indexer_settings'));    
554
-            }
554
+			}
555 555
 
556
-            /**
557
-             * Display success message
558
-             */
559
-            echo '<div class="notice notice-success is-dismissible">
556
+			/**
557
+			 * Display success message
558
+			 */
559
+			echo '<div class="notice notice-success is-dismissible">
560 560
 					 	<p>' . esc_html__('Product(s) sent to Algolia.', 'algolia-woo-indexer') . '</p>
561 561
 				  		</div>';
562
-        }
563
-
564
-        /**
565
-         * Sanitize input in settings fields and filter through regex to accept only a-z and A-Z
566
-         *
567
-         * @param string $input Settings text data
568
-         * @return array
569
-         */
570
-        public static function settings_fields_validate_options($input)
571
-        {
572
-            $valid         = array();
573
-            $valid['name'] = preg_replace(
574
-                '/[^a-zA-Z\s]/',
575
-                '',
576
-                $input['name']
577
-            );
578
-            return $valid;
579
-        }
580
-
581
-        /**
582
-         * Load text domain for translations
583
-         *
584
-         * @return void
585
-         */
586
-        public static function load_textdomain()
587
-        {
588
-            load_plugin_textdomain('algolia-woo-indexer', false, basename(dirname(__FILE__)) . '/languages/');
589
-        }
590
-
591
-        /**
592
-         * Add the new menu to settings section so that we can configure the plugin
593
-         *
594
-         * @return void
595
-         */
596
-        public static function admin_menu()
597
-        {
598
-            add_submenu_page(
599
-                'options-general.php',
600
-                esc_html__('Algolia Woo Indexer Settings', 'algolia-woo-indexer'),
601
-                esc_html__('Algolia Woo Indexer Settings', 'algolia-woo-indexer'),
602
-                'manage_options',
603
-                'algolia-woo-indexer-settings',
604
-                array( get_called_class(), 'algolia_woo_indexer_settings' )
605
-            );
606
-        }
607
-
608
-        /**
609
-         * Display settings and allow user to modify them
610
-         *
611
-         * @return void
612
-         */
613
-        public static function algolia_woo_indexer_settings()
614
-        {
615
-            /**
616
-            * Verify that the user can access the settings page
617
-            */
618
-            if (! current_user_can('manage_options')) {
619
-                wp_die(esc_html__('Action not allowed.', 'algolia_woo_indexer_settings'));
620
-            } ?>
562
+		}
563
+
564
+		/**
565
+		 * Sanitize input in settings fields and filter through regex to accept only a-z and A-Z
566
+		 *
567
+		 * @param string $input Settings text data
568
+		 * @return array
569
+		 */
570
+		public static function settings_fields_validate_options($input)
571
+		{
572
+			$valid         = array();
573
+			$valid['name'] = preg_replace(
574
+				'/[^a-zA-Z\s]/',
575
+				'',
576
+				$input['name']
577
+			);
578
+			return $valid;
579
+		}
580
+
581
+		/**
582
+		 * Load text domain for translations
583
+		 *
584
+		 * @return void
585
+		 */
586
+		public static function load_textdomain()
587
+		{
588
+			load_plugin_textdomain('algolia-woo-indexer', false, basename(dirname(__FILE__)) . '/languages/');
589
+		}
590
+
591
+		/**
592
+		 * Add the new menu to settings section so that we can configure the plugin
593
+		 *
594
+		 * @return void
595
+		 */
596
+		public static function admin_menu()
597
+		{
598
+			add_submenu_page(
599
+				'options-general.php',
600
+				esc_html__('Algolia Woo Indexer Settings', 'algolia-woo-indexer'),
601
+				esc_html__('Algolia Woo Indexer Settings', 'algolia-woo-indexer'),
602
+				'manage_options',
603
+				'algolia-woo-indexer-settings',
604
+				array( get_called_class(), 'algolia_woo_indexer_settings' )
605
+			);
606
+		}
607
+
608
+		/**
609
+		 * Display settings and allow user to modify them
610
+		 *
611
+		 * @return void
612
+		 */
613
+		public static function algolia_woo_indexer_settings()
614
+		{
615
+			/**
616
+			 * Verify that the user can access the settings page
617
+			 */
618
+			if (! current_user_can('manage_options')) {
619
+				wp_die(esc_html__('Action not allowed.', 'algolia_woo_indexer_settings'));
620
+			} ?>
621 621
 			<div class="wrap">
622 622
 				<h1><?php esc_html__('Algolia Woo Indexer Settings', 'algolia-woo-indexer'); ?></h1>
623 623
 				<form action="<?php echo esc_url(self::$plugin_url); ?>" method="POST">
624 624
 			<?php
625
-            settings_fields('algolia_woo_options');
626
-            do_settings_sections('algolia_woo_indexer');
627
-            submit_button('', 'primary wide'); ?>
625
+			settings_fields('algolia_woo_options');
626
+			do_settings_sections('algolia_woo_indexer');
627
+			submit_button('', 'primary wide'); ?>
628 628
 				</form>
629 629
 				<form action="<?php echo esc_url(self::$plugin_url); ?>" method="POST">
630 630
 					<?php wp_nonce_field('send_products_to_algolia_nonce_action', 'send_products_to_algolia_nonce_name'); ?>
@@ -633,75 +633,75 @@  discard block
 block discarded – undo
633 633
 				</form>
634 634
 			</div>
635 635
 			<?php
636
-        }
637
-
638
-        /**
639
-         * Get active object instance
640
-         *
641
-         * @return object
642
-         */
643
-        public static function get_instance()
644
-        {
645
-            if (! self::$instance) {
646
-                self::$instance = new Algolia_Woo_Indexer();
647
-            }
648
-            return self::$instance;
649
-        }
650
-
651
-        /**
652
-         * The actions to execute when the plugin is activated.
653
-         *
654
-         * @return void
655
-         */
656
-        public static function activate_plugin()
657
-        {
658
-
659
-            /**
660
-             * Set default values for options if not already set
661
-             */
662
-            $automatically_send_new_products = get_option(ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS);
663
-            $algolia_application_id          = get_option(ALGOWOO_DB_OPTION . ALGOLIA_APPLICATION_ID);
664
-            $algolia_api_key                 = get_option(ALGOWOO_DB_OPTION . ALGOLIA_API_KEY);
665
-            $algolia_index_name              = get_option(ALGOWOO_DB_OPTION . INDEX_NAME);
636
+		}
637
+
638
+		/**
639
+		 * Get active object instance
640
+		 *
641
+		 * @return object
642
+		 */
643
+		public static function get_instance()
644
+		{
645
+			if (! self::$instance) {
646
+				self::$instance = new Algolia_Woo_Indexer();
647
+			}
648
+			return self::$instance;
649
+		}
650
+
651
+		/**
652
+		 * The actions to execute when the plugin is activated.
653
+		 *
654
+		 * @return void
655
+		 */
656
+		public static function activate_plugin()
657
+		{
658
+
659
+			/**
660
+			 * Set default values for options if not already set
661
+			 */
662
+			$automatically_send_new_products = get_option(ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS);
663
+			$algolia_application_id          = get_option(ALGOWOO_DB_OPTION . ALGOLIA_APPLICATION_ID);
664
+			$algolia_api_key                 = get_option(ALGOWOO_DB_OPTION . ALGOLIA_API_KEY);
665
+			$algolia_index_name              = get_option(ALGOWOO_DB_OPTION . INDEX_NAME);
666 666
             
667
-            if (empty($automatically_send_new_products)) {
668
-                add_option(
669
-                    ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS,
670
-                    '0'
671
-                );
672
-            }
673
-
674
-            if (empty($algolia_application_id)) {
675
-                add_option(
676
-                    ALGOWOO_DB_OPTION . ALGOLIA_APPLICATION_ID,
677
-                    'Change me'
678
-                );
679
-            }
680
-
681
-            if (empty($algolia_api_key)) {
682
-                add_option(
683
-                    ALGOWOO_DB_OPTION . ALGOLIA_API_KEY,
684
-                    'Change me'
685
-                );
686
-            }
687
-
688
-            if (empty($algolia_index_name)) {
689
-                add_option(
690
-                    ALGOWOO_DB_OPTION . INDEX_NAME,
691
-                    'Change me'
692
-                );
693
-            }
694
-            set_transient(self::PLUGIN_TRANSIENT, true);
695
-        }
696
-
697
-        /**
698
-         * The actions to execute when the plugin is deactivated.
699
-         *
700
-         * @return void
701
-         */
702
-        public static function deactivate_plugin()
703
-        {
704
-            delete_transient(self::PLUGIN_TRANSIENT);
705
-        }
706
-    }
667
+			if (empty($automatically_send_new_products)) {
668
+				add_option(
669
+					ALGOWOO_DB_OPTION . AUTOMATICALLY_SEND_NEW_PRODUCTS,
670
+					'0'
671
+				);
672
+			}
673
+
674
+			if (empty($algolia_application_id)) {
675
+				add_option(
676
+					ALGOWOO_DB_OPTION . ALGOLIA_APPLICATION_ID,
677
+					'Change me'
678
+				);
679
+			}
680
+
681
+			if (empty($algolia_api_key)) {
682
+				add_option(
683
+					ALGOWOO_DB_OPTION . ALGOLIA_API_KEY,
684
+					'Change me'
685
+				);
686
+			}
687
+
688
+			if (empty($algolia_index_name)) {
689
+				add_option(
690
+					ALGOWOO_DB_OPTION . INDEX_NAME,
691
+					'Change me'
692
+				);
693
+			}
694
+			set_transient(self::PLUGIN_TRANSIENT, true);
695
+		}
696
+
697
+		/**
698
+		 * The actions to execute when the plugin is deactivated.
699
+		 *
700
+		 * @return void
701
+		 */
702
+		public static function deactivate_plugin()
703
+		{
704
+			delete_transient(self::PLUGIN_TRANSIENT);
705
+		}
706
+	}
707 707
 }
708 708
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -14,27 +14,27 @@  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
 
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
 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_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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
@@ -404,12 +404,12 @@  discard block
 block discarded – undo
404 404
 		 * 	@param string $algolia_index_name Algolia index name.
405 405
 		 * 
406 406
 		 */
407
-		public static function check_algolia_input_values($algolia_application_id, $algolia_api_key, $algolia_index_name )
407
+		public static function check_algolia_input_values($algolia_application_id, $algolia_api_key, $algolia_index_name)
408 408
 		{	
409 409
 			if (empty($algolia_application_id) || empty($algolia_api_key || empty($algolia_index_name))) {
410 410
                 add_action(
411 411
                     'admin_notices',
412
-                    function () {
412
+                    function() {
413 413
                         echo '<div class="error notice">
414 414
 							  <p>' . esc_html__('All settings need to be set for the plugin to work.', 'algolia-woo-indexer') . '</p>
415 415
 							</div>';
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
             } catch (\Algolia\AlgoliaSearch\Exceptions\UnreachableException $error) {
429 429
                 add_action(
430 430
                     'admin_notices',
431
-                    function () {
431
+                    function() {
432 432
                         echo '<div class="error notice">
433 433
 							  <p>' . esc_html__('An error has been encountered. Please check your application ID and API key. ', 'algolia-woo-indexer') . '</p>
434 434
 							</div>';
@@ -461,10 +461,10 @@  discard block
 block discarded – undo
461 461
 			$algolia_application_id = is_string($algolia_application_id) ? $algolia_application_id : CHANGE_ME;
462 462
 
463 463
             $algolia_api_key        = get_option(ALGOWOO_DB_OPTION . ALGOLIA_API_KEY);
464
-			$algolia_api_key		= is_string($algolia_api_key) ?$algolia_api_key : CHANGE_ME;
464
+			$algolia_api_key = is_string($algolia_api_key) ? $algolia_api_key : CHANGE_ME;
465 465
 
466 466
             $algolia_index_name     = get_option(ALGOWOO_DB_OPTION . INDEX_NAME);
467
-			$algolia_index_name		= is_string($algolia_index_name) ? $algolia_index_name : CHANGE_ME;
467
+			$algolia_index_name = is_string($algolia_index_name) ? $algolia_index_name : CHANGE_ME;
468 468
 
469 469
 			/**
470 470
              * Display admin notice and return if not all values have been set
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
             if (isset($id) && '' !== $id) {
505 505
                 $arguments = array(
506 506
                     'status'   => 'publish',
507
-                    'include'  => array( $id ),
507
+                    'include'  => array($id),
508 508
                     'paginate' => false,
509 509
                 );
510 510
             }
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
              */
517 517
             $products = /** @scrutinizer ignore-call */ wc_get_products($arguments);
518 518
 
519
-            if ( empty( $products ) ) {
519
+            if (empty($products)) {
520 520
                 return;
521 521
             }
522 522
             $records = array();
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
                 esc_html__('Algolia Woo Indexer Settings', 'algolia-woo-indexer'),
602 602
                 'manage_options',
603 603
                 'algolia-woo-indexer-settings',
604
-                array( get_called_class(), 'algolia_woo_indexer_settings' )
604
+                array(get_called_class(), 'algolia_woo_indexer_settings')
605 605
             );
606 606
         }
607 607
 
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
             /**
616 616
             * Verify that the user can access the settings page
617 617
             */
618
-            if (! current_user_can('manage_options')) {
618
+            if ( ! current_user_can('manage_options')) {
619 619
                 wp_die(esc_html__('Action not allowed.', 'algolia_woo_indexer_settings'));
620 620
             } ?>
621 621
 			<div class="wrap">
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
          */
643 643
         public static function get_instance()
644 644
         {
645
-            if (! self::$instance) {
645
+            if ( ! self::$instance) {
646 646
                 self::$instance = new Algolia_Woo_Indexer();
647 647
             }
648 648
             return self::$instance;
Please login to merge, or discard this patch.