@@ -9,14 +9,14 @@ |
||
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'); |
@@ -18,26 +18,26 @@ |
||
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')); |
@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | /** |
12 | 12 | * Abort if this file is called directly |
13 | 13 | */ |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
18 | -if ( ! class_exists( 'Algolia_Verify_Nonces' ) ) { |
|
18 | +if ( ! class_exists('Algolia_Verify_Nonces')) { |
|
19 | 19 | /** |
20 | 20 | * Verify submitted nonces |
21 | 21 | */ |
@@ -29,12 +29,12 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * Filter incoming nonces and values |
31 | 31 | */ |
32 | - $settings_nonce = filter_input( INPUT_POST, 'algolia_woo_indexer_admin_api_nonce_name', FILTER_DEFAULT ); |
|
32 | + $settings_nonce = filter_input(INPUT_POST, 'algolia_woo_indexer_admin_api_nonce_name', FILTER_DEFAULT); |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Return 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 |
||
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 | } |
@@ -22,7 +22,7 @@ discard block |
||
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 | /** |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public static function setup_settings_sections() { |
79 | 79 | /** |
80 | - * Setup arguments for settings sections and fields |
|
81 | - * |
|
82 | - * @see https://developer.wordpress.org/reference/functions/register_setting/ |
|
83 | - */ |
|
80 | + * Setup arguments for settings sections and fields |
|
81 | + * |
|
82 | + * @see https://developer.wordpress.org/reference/functions/register_setting/ |
|
83 | + */ |
|
84 | 84 | if ( is_admin() ) { |
85 | 85 | $arguments = array( |
86 | 86 | 'type' => 'string', |
@@ -486,8 +486,8 @@ discard block |
||
486 | 486 | ); |
487 | 487 | |
488 | 488 | /** |
489 | - * Setup arguments for sending only a single product |
|
490 | - */ |
|
489 | + * Setup arguments for sending only a single product |
|
490 | + */ |
|
491 | 491 | if ( isset( $id ) && '' !== $id ) { |
492 | 492 | $arguments = array( |
493 | 493 | 'status' => 'publish', |
@@ -631,8 +631,8 @@ discard block |
||
631 | 631 | */ |
632 | 632 | public static function algolia_woo_indexer_settings() { |
633 | 633 | /** |
634 | - * Verify that the user can access the settings page |
|
635 | - */ |
|
634 | + * Verify that the user can access the settings page |
|
635 | + */ |
|
636 | 636 | if ( ! current_user_can( 'manage_options' ) ) { |
637 | 637 | wp_die( esc_html__( 'Action not allowed.', 'algolia_woo_indexer_settings' ) ); |
638 | 638 | } |
@@ -14,24 +14,24 @@ 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 | -if ( ! class_exists( 'Algolia_Woo_Indexer' ) ) { |
|
34 | +if ( ! class_exists('Algolia_Woo_Indexer')) { |
|
35 | 35 | /** |
36 | 36 | * Algolia WooIndexer main class |
37 | 37 | */ |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @see https://developer.wordpress.org/reference/functions/register_setting/ |
83 | 83 | */ |
84 | - if ( is_admin() ) { |
|
84 | + if (is_admin()) { |
|
85 | 85 | $arguments = array( |
86 | 86 | 'type' => 'string', |
87 | 87 | 'sanitize_callback' => 'settings_fields_validate_options', |
88 | 88 | 'default' => null, |
89 | 89 | ); |
90 | - register_setting( 'algolia_woo_options', 'algolia_woo_options', $arguments ); |
|
90 | + register_setting('algolia_woo_options', 'algolia_woo_options', $arguments); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Make sure we reference the instance of the current class by using self::get_instance() |
@@ -100,42 +100,42 @@ discard block |
||
100 | 100 | */ |
101 | 101 | add_settings_section( |
102 | 102 | 'algolia_woo_indexer_main', |
103 | - esc_html__( 'Algolia Woo Plugin Settings', 'algolia-woo-indexer' ), |
|
104 | - array( $algowooindexer, 'algolia_woo_indexer_section_text' ), |
|
103 | + esc_html__('Algolia Woo Plugin Settings', 'algolia-woo-indexer'), |
|
104 | + array($algowooindexer, 'algolia_woo_indexer_section_text'), |
|
105 | 105 | 'algolia_woo_indexer' |
106 | 106 | ); |
107 | 107 | add_settings_field( |
108 | 108 | 'algolia_woo_indexer_application_id', |
109 | - esc_html__( 'Application ID', 'algolia-woo-indexer' ), |
|
110 | - array( $algowooindexer, 'algolia_woo_indexer_application_id_output' ), |
|
109 | + esc_html__('Application ID', 'algolia-woo-indexer'), |
|
110 | + array($algowooindexer, 'algolia_woo_indexer_application_id_output'), |
|
111 | 111 | 'algolia_woo_indexer', |
112 | 112 | 'algolia_woo_indexer_main' |
113 | 113 | ); |
114 | 114 | add_settings_field( |
115 | 115 | 'algolia_woo_indexer_admin_api_key', |
116 | - esc_html__( 'Admin API Key', 'algolia-woo-indexer' ), |
|
117 | - array( $algowooindexer, 'algolia_woo_indexer_admin_api_key_output' ), |
|
116 | + esc_html__('Admin API Key', 'algolia-woo-indexer'), |
|
117 | + array($algowooindexer, 'algolia_woo_indexer_admin_api_key_output'), |
|
118 | 118 | 'algolia_woo_indexer', |
119 | 119 | 'algolia_woo_indexer_main' |
120 | 120 | ); |
121 | 121 | add_settings_field( |
122 | 122 | 'algolia_woo_indexer_index_name', |
123 | - esc_html__( 'Index name (will be created if not existing)', 'algolia-woo-indexer' ), |
|
124 | - array( $algowooindexer, 'algolia_woo_indexer_index_name_output' ), |
|
123 | + esc_html__('Index name (will be created if not existing)', 'algolia-woo-indexer'), |
|
124 | + array($algowooindexer, 'algolia_woo_indexer_index_name_output'), |
|
125 | 125 | 'algolia_woo_indexer', |
126 | 126 | 'algolia_woo_indexer_main' |
127 | 127 | ); |
128 | 128 | add_settings_field( |
129 | 129 | 'algolia_woo_indexer_index_in_stock', |
130 | - esc_html__( 'Only index products in stock', 'algolia-woo-indexer' ), |
|
131 | - array( $algowooindexer, 'algolia_woo_indexer_index_in_stock_output' ), |
|
130 | + esc_html__('Only index products in stock', 'algolia-woo-indexer'), |
|
131 | + array($algowooindexer, 'algolia_woo_indexer_index_in_stock_output'), |
|
132 | 132 | 'algolia_woo_indexer', |
133 | 133 | 'algolia_woo_indexer_main' |
134 | 134 | ); |
135 | 135 | add_settings_field( |
136 | 136 | 'algolia_woo_indexer_automatically_send_new_products', |
137 | - esc_html__( 'Automatically index new products', 'algolia-woo-indexer' ), |
|
138 | - array( $algowooindexer, 'algolia_woo_indexer_automatically_send_new_products_output' ), |
|
137 | + esc_html__('Automatically index new products', 'algolia-woo-indexer'), |
|
138 | + array($algowooindexer, 'algolia_woo_indexer_automatically_send_new_products_output'), |
|
139 | 139 | 'algolia_woo_indexer', |
140 | 140 | 'algolia_woo_indexer_main' |
141 | 141 | ); |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | * @return void |
151 | 151 | */ |
152 | 152 | public static function algolia_woo_indexer_admin_api_key_output() { |
153 | - $api_key = get_option( ALGOWOO_DB_OPTION . '_admin_api_key' ); |
|
153 | + $api_key = get_option(ALGOWOO_DB_OPTION . '_admin_api_key'); |
|
154 | 154 | $api_key = is_string($api_key) ? $api_key : "change me"; |
155 | 155 | |
156 | - wp_nonce_field( 'algolia_woo_indexer_admin_api_nonce_action', 'algolia_woo_indexer_admin_api_nonce_name' ); |
|
156 | + wp_nonce_field('algolia_woo_indexer_admin_api_nonce_action', 'algolia_woo_indexer_admin_api_nonce_name'); |
|
157 | 157 | |
158 | 158 | echo "<input id='algolia_woo_indexer_admin_api_key' name='algolia_woo_indexer_admin_api_key[key]' |
159 | - type='text' value='" . esc_attr( $api_key ) . "' />"; |
|
159 | + type='text' value='" . esc_attr($api_key) . "' />"; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | * @return void |
166 | 166 | */ |
167 | 167 | public static function algolia_woo_indexer_application_id_output() { |
168 | - $application_id = get_option( ALGOWOO_DB_OPTION . '_application_id' ); |
|
168 | + $application_id = get_option(ALGOWOO_DB_OPTION . '_application_id'); |
|
169 | 169 | |
170 | 170 | echo "<input id='algolia_woo_indexer_application_id' name='algolia_woo_indexer_application_id[id]' |
171 | - type='text' value='" . esc_attr( $application_id ) . "' />"; |
|
171 | + type='text' value='" . esc_attr($application_id) . "' />"; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | * @return void |
178 | 178 | */ |
179 | 179 | public static function algolia_woo_indexer_index_name_output() { |
180 | - $index_name = get_option( ALGOWOO_DB_OPTION . '_index_name' ); |
|
180 | + $index_name = get_option(ALGOWOO_DB_OPTION . '_index_name'); |
|
181 | 181 | |
182 | 182 | echo "<input id='algolia_woo_indexer_index_name' name='algolia_woo_indexer_index_name[name]' |
183 | - type='text' value='" . esc_attr( $index_name ) . "' />"; |
|
183 | + type='text' value='" . esc_attr($index_name) . "' />"; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | * Sanitization is not really needed as the variable is not directly echoed |
194 | 194 | * But I have still done it to be 100% safe |
195 | 195 | */ |
196 | - $index_in_stock = get_option( ALGOWOO_DB_OPTION . '_index_in_stock' ); |
|
197 | - $index_in_stock = ( ! empty( $index_in_stock ) ) ? 1 : 0; |
|
196 | + $index_in_stock = get_option(ALGOWOO_DB_OPTION . '_index_in_stock'); |
|
197 | + $index_in_stock = ( ! empty($index_in_stock)) ? 1 : 0; |
|
198 | 198 | ?> |
199 | 199 | <input id="algolia_woo_indexer_index_in_stock" name="algolia_woo_indexer_index_in_stock[checked]" |
200 | - type="checkbox" <?php checked( 1, $index_in_stock ); ?> /> |
|
200 | + type="checkbox" <?php checked(1, $index_in_stock); ?> /> |
|
201 | 201 | <?php |
202 | 202 | } |
203 | 203 | |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | * Sanitization is not really needed as the variable is not directly echoed |
212 | 212 | * But I have still done it to be 100% safe |
213 | 213 | */ |
214 | - $automatically_send_new_products = get_option( ALGOWOO_DB_OPTION . '_automatically_send_new_products' ); |
|
215 | - $automatically_send_new_products = ( ! empty( $automatically_send_new_products ) ) ? 1 : 0; |
|
214 | + $automatically_send_new_products = get_option(ALGOWOO_DB_OPTION . '_automatically_send_new_products'); |
|
215 | + $automatically_send_new_products = ( ! empty($automatically_send_new_products)) ? 1 : 0; |
|
216 | 216 | ?> |
217 | 217 | <input id="algolia_woo_indexer_automatically_send_new_products" name="algolia_woo_indexer_automatically_send_new_products[checked]" |
218 | - type="checkbox" <?php checked( 1, $automatically_send_new_products ); ?> /> |
|
218 | + type="checkbox" <?php checked(1, $automatically_send_new_products); ?> /> |
|
219 | 219 | <?php |
220 | 220 | } |
221 | 221 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @return void |
226 | 226 | */ |
227 | 227 | public static function algolia_woo_indexer_section_text() { |
228 | - echo esc_html__( 'Enter your settings here', 'algolia-woo-indexer' ); |
|
228 | + echo esc_html__('Enter your settings here', 'algolia-woo-indexer'); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public static function maybe_send_products() { |
237 | 237 | |
238 | - if ( true === Algolia_Verify_Nonces::verify_send_products_nonce() ) { |
|
238 | + if (true === Algolia_Verify_Nonces::verify_send_products_nonce()) { |
|
239 | 239 | self::send_products_to_algolia(); |
240 | 240 | return; |
241 | 241 | } |
@@ -251,19 +251,19 @@ discard block |
||
251 | 251 | /** |
252 | 252 | * Fetch the option to see if we are going to automatically send new products |
253 | 253 | */ |
254 | - $automatically_send_new_products = get_option( ALGOWOO_DB_OPTION . '_automatically_send_new_products' ); |
|
254 | + $automatically_send_new_products = get_option(ALGOWOO_DB_OPTION . '_automatically_send_new_products'); |
|
255 | 255 | |
256 | 256 | /** |
257 | 257 | * Check that we have the minimum versions required and all of the required PHP extensions |
258 | 258 | */ |
259 | 259 | Algolia_Check_Requirements::check_unmet_requirements(); |
260 | 260 | |
261 | - if ( ! Algolia_Check_Requirements::algolia_wp_version_check() || ! Algolia_Check_Requirements::algolia_php_version_check() ) { |
|
261 | + if ( ! Algolia_Check_Requirements::algolia_wp_version_check() || ! Algolia_Check_Requirements::algolia_php_version_check()) { |
|
262 | 262 | add_action( |
263 | 263 | 'admin_notices', |
264 | - function () { |
|
264 | + function() { |
|
265 | 265 | echo '<div class="error notice"> |
266 | - <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> |
|
266 | + <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> |
|
267 | 267 | </div>'; |
268 | 268 | } |
269 | 269 | ); |
@@ -274,33 +274,33 @@ discard block |
||
274 | 274 | /** |
275 | 275 | * Setup translations |
276 | 276 | */ |
277 | - add_action( 'plugins_loaded', array( $ob_class, 'load_textdomain' ) ); |
|
277 | + add_action('plugins_loaded', array($ob_class, 'load_textdomain')); |
|
278 | 278 | |
279 | 279 | /** |
280 | 280 | * Add actions to setup admin menu |
281 | 281 | */ |
282 | - if ( is_admin() ) { |
|
283 | - add_action( 'admin_menu', array( $ob_class, 'admin_menu' ) ); |
|
284 | - add_action( 'admin_init', array( $ob_class, 'setup_settings_sections' ) ); |
|
285 | - add_action( 'admin_init', array( $ob_class, 'update_settings_options' ) ); |
|
286 | - add_action( 'admin_init', array( $ob_class, 'maybe_send_products' ) ); |
|
282 | + if (is_admin()) { |
|
283 | + add_action('admin_menu', array($ob_class, 'admin_menu')); |
|
284 | + add_action('admin_init', array($ob_class, 'setup_settings_sections')); |
|
285 | + add_action('admin_init', array($ob_class, 'update_settings_options')); |
|
286 | + add_action('admin_init', array($ob_class, 'maybe_send_products')); |
|
287 | 287 | |
288 | 288 | /** |
289 | 289 | * Register hook to automatically send new products if the option is set |
290 | 290 | */ |
291 | 291 | |
292 | - if ( '1' === $automatically_send_new_products ) { |
|
293 | - add_action( 'save_post', array( $ob_class, 'send_new_product_to_algolia' ), 10, 3 ); |
|
292 | + if ('1' === $automatically_send_new_products) { |
|
293 | + add_action('save_post', array($ob_class, 'send_new_product_to_algolia'), 10, 3); |
|
294 | 294 | } |
295 | 295 | |
296 | - self::$plugin_url = admin_url( 'options-general.php?page=algolia-woo-indexer-settings' ); |
|
296 | + self::$plugin_url = admin_url('options-general.php?page=algolia-woo-indexer-settings'); |
|
297 | 297 | |
298 | - if ( ! is_plugin_active('woocommerce/woocommerce.php') ) { |
|
298 | + if ( ! is_plugin_active('woocommerce/woocommerce.php')) { |
|
299 | 299 | add_action( |
300 | 300 | 'admin_notices', |
301 | - function () { |
|
301 | + function() { |
|
302 | 302 | echo '<div class="error notice"> |
303 | - <p>' . esc_html__( 'WooCommerce plugin must be enabled for Algolia Woo Indexer to work.', 'algolia-woo-indexer' ) . '</p> |
|
303 | + <p>' . esc_html__('WooCommerce plugin must be enabled for Algolia Woo Indexer to work.', 'algolia-woo-indexer') . '</p> |
|
304 | 304 | </div>'; |
305 | 305 | } |
306 | 306 | ); |
@@ -316,12 +316,12 @@ discard block |
||
316 | 316 | * |
317 | 317 | * @return void |
318 | 318 | */ |
319 | - public static function send_new_product_to_algolia( $post_id, $post ) { |
|
319 | + public static function send_new_product_to_algolia($post_id, $post) { |
|
320 | 320 | |
321 | - if ( 'publish' !== $post->post_status || 'product' !== $post->post_type ) { |
|
321 | + if ('publish' !== $post->post_status || 'product' !== $post->post_type) { |
|
322 | 322 | return; |
323 | 323 | } |
324 | - self::send_products_to_algolia( $post_id ); |
|
324 | + self::send_products_to_algolia($post_id); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | /** |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | /** |
338 | 338 | * Do not proceed if we are going to send products |
339 | 339 | */ |
340 | - if ( true === Algolia_Verify_Nonces::verify_send_products_nonce() ) { |
|
340 | + if (true === Algolia_Verify_Nonces::verify_send_products_nonce()) { |
|
341 | 341 | return; |
342 | 342 | } |
343 | 343 | |
@@ -346,26 +346,26 @@ discard block |
||
346 | 346 | * |
347 | 347 | * @see https://www.php.net/manual/en/function.filter-input.php |
348 | 348 | */ |
349 | - $post_application_id = filter_input( INPUT_POST, 'algolia_woo_indexer_application_id', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
350 | - $post_api_key = filter_input( INPUT_POST, 'algolia_woo_indexer_admin_api_key', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
351 | - $post_index_name = filter_input( INPUT_POST, 'algolia_woo_indexer_index_name', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
352 | - $index_in_stock = filter_input( INPUT_POST, 'algolia_woo_indexer_index_in_stock', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
353 | - $automatically_send_new_products = filter_input( INPUT_POST, 'algolia_woo_indexer_automatically_send_new_products', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
349 | + $post_application_id = filter_input(INPUT_POST, 'algolia_woo_indexer_application_id', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
350 | + $post_api_key = filter_input(INPUT_POST, 'algolia_woo_indexer_admin_api_key', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
351 | + $post_index_name = filter_input(INPUT_POST, 'algolia_woo_indexer_index_name', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
352 | + $index_in_stock = filter_input(INPUT_POST, 'algolia_woo_indexer_index_in_stock', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
353 | + $automatically_send_new_products = filter_input(INPUT_POST, 'algolia_woo_indexer_automatically_send_new_products', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
354 | 354 | |
355 | 355 | /** |
356 | 356 | * Properly sanitize text fields before updating data |
357 | 357 | * |
358 | 358 | * @see https://developer.wordpress.org/reference/functions/sanitize_text_field/ |
359 | 359 | */ |
360 | - $filtered_application_id = sanitize_text_field( $post_application_id['id'] ); |
|
361 | - $filtered_api_key = sanitize_text_field( $post_api_key['key'] ); |
|
362 | - $filtered_index_name = sanitize_text_field( $post_index_name['name'] ); |
|
360 | + $filtered_application_id = sanitize_text_field($post_application_id['id']); |
|
361 | + $filtered_api_key = sanitize_text_field($post_api_key['key']); |
|
362 | + $filtered_index_name = sanitize_text_field($post_index_name['name']); |
|
363 | 363 | |
364 | 364 | /** |
365 | 365 | * Sanitizing by setting the value to either 1 or 0 |
366 | 366 | */ |
367 | - $filtered_index_in_stock = ( ! empty( $index_in_stock ) ) ? 1 : 0; |
|
368 | - $filtered_automatically_send_new_products = ( ! empty( $automatically_send_new_products ) ) ? 1 : 0; |
|
367 | + $filtered_index_in_stock = ( ! empty($index_in_stock)) ? 1 : 0; |
|
368 | + $filtered_automatically_send_new_products = ( ! empty($automatically_send_new_products)) ? 1 : 0; |
|
369 | 369 | |
370 | 370 | /** |
371 | 371 | * Values have been filtered and sanitized |
@@ -373,35 +373,35 @@ discard block |
||
373 | 373 | * |
374 | 374 | * @see https://developer.wordpress.org/reference/functions/update_option/ |
375 | 375 | */ |
376 | - if ( isset( $filtered_application_id ) && ( ! empty( $filtered_application_id ) ) ) { |
|
376 | + if (isset($filtered_application_id) && ( ! empty($filtered_application_id))) { |
|
377 | 377 | update_option( |
378 | 378 | ALGOWOO_DB_OPTION . '_application_id', |
379 | 379 | $filtered_application_id |
380 | 380 | ); |
381 | 381 | } |
382 | 382 | |
383 | - if ( isset( $filtered_api_key ) && ( ! empty( $filtered_api_key ) ) ) { |
|
383 | + if (isset($filtered_api_key) && ( ! empty($filtered_api_key))) { |
|
384 | 384 | update_option( |
385 | 385 | ALGOWOO_DB_OPTION . '_admin_api_key', |
386 | 386 | $filtered_api_key |
387 | 387 | ); |
388 | 388 | } |
389 | 389 | |
390 | - if ( isset( $filtered_index_name ) && ( ! empty( $filtered_index_name ) ) ) { |
|
390 | + if (isset($filtered_index_name) && ( ! empty($filtered_index_name))) { |
|
391 | 391 | update_option( |
392 | 392 | ALGOWOO_DB_OPTION . '_index_name', |
393 | 393 | $filtered_index_name |
394 | 394 | ); |
395 | 395 | } |
396 | 396 | |
397 | - if ( isset( $filtered_index_in_stock ) && ( ! empty( $filtered_index_in_stock ) ) ) { |
|
397 | + if (isset($filtered_index_in_stock) && ( ! empty($filtered_index_in_stock))) { |
|
398 | 398 | update_option( |
399 | 399 | ALGOWOO_DB_OPTION . '_index_in_stock', |
400 | 400 | $filtered_index_in_stock |
401 | 401 | ); |
402 | 402 | } |
403 | 403 | |
404 | - if ( isset( $filtered_automatically_send_new_products ) && ( ! empty( $filtered_automatically_send_new_products ) ) ) { |
|
404 | + if (isset($filtered_automatically_send_new_products) && ( ! empty($filtered_automatically_send_new_products))) { |
|
405 | 405 | update_option( |
406 | 406 | ALGOWOO_DB_OPTION . '_automatically_send_new_products', |
407 | 407 | $filtered_automatically_send_new_products |
@@ -415,33 +415,33 @@ discard block |
||
415 | 415 | * @param Int $id Product to send to Algolia if we send only a single product |
416 | 416 | * @return void |
417 | 417 | */ |
418 | - public static function send_products_to_algolia( $id = '' ) { |
|
418 | + public static function send_products_to_algolia($id = '') { |
|
419 | 419 | /** |
420 | 420 | * Remove classes from plugin URL and autoload Algolia with Composer |
421 | 421 | */ |
422 | 422 | |
423 | - $base_plugin_directory = str_replace( 'classes', '', dirname( __FILE__ ) ); |
|
423 | + $base_plugin_directory = str_replace('classes', '', dirname(__FILE__)); |
|
424 | 424 | require_once $base_plugin_directory . '/vendor/autoload.php'; |
425 | 425 | |
426 | 426 | /** |
427 | 427 | * Fetch the required variables from the Settings API |
428 | 428 | */ |
429 | 429 | |
430 | - $algolia_application_id = get_option( ALGOWOO_DB_OPTION . '_application_id' ); |
|
431 | - $algolia_api_key = get_option( ALGOWOO_DB_OPTION . '_admin_api_key' ); |
|
432 | - $algolia_index_name = get_option( ALGOWOO_DB_OPTION . '_index_name' ); |
|
430 | + $algolia_application_id = get_option(ALGOWOO_DB_OPTION . '_application_id'); |
|
431 | + $algolia_api_key = get_option(ALGOWOO_DB_OPTION . '_admin_api_key'); |
|
432 | + $algolia_index_name = get_option(ALGOWOO_DB_OPTION . '_index_name'); |
|
433 | 433 | |
434 | - $index_in_stock = get_option( ALGOWOO_DB_OPTION . '_index_in_stock' ); |
|
434 | + $index_in_stock = get_option(ALGOWOO_DB_OPTION . '_index_in_stock'); |
|
435 | 435 | |
436 | 436 | /** |
437 | 437 | * Display admin notice and return if not all values have been set |
438 | 438 | */ |
439 | - if ( empty( $algolia_application_id ) || empty( $algolia_api_key || empty( $algolia_index_name ) ) ) { |
|
439 | + if (empty($algolia_application_id) || empty($algolia_api_key || empty($algolia_index_name))) { |
|
440 | 440 | add_action( |
441 | 441 | 'admin_notices', |
442 | - function () { |
|
442 | + function() { |
|
443 | 443 | echo '<div class="error notice"> |
444 | - <p>' . esc_html__( 'All settings need to be set for the plugin to work.', 'algolia-woo-indexer' ) . '</p> |
|
444 | + <p>' . esc_html__('All settings need to be set for the plugin to work.', 'algolia-woo-indexer') . '</p> |
|
445 | 445 | </div>'; |
446 | 446 | } |
447 | 447 | ); |
@@ -451,19 +451,19 @@ discard block |
||
451 | 451 | /** |
452 | 452 | * Initiate the Algolia client |
453 | 453 | */ |
454 | - self::$algolia = \Algolia\AlgoliaSearch\SearchClient::create( $algolia_application_id, $algolia_api_key ); |
|
454 | + self::$algolia = \Algolia\AlgoliaSearch\SearchClient::create($algolia_application_id, $algolia_api_key); |
|
455 | 455 | |
456 | 456 | /** |
457 | 457 | * Check if we can connect, if not, handle the exception, display an error and then return |
458 | 458 | */ |
459 | 459 | try { |
460 | 460 | self::$algolia->listApiKeys(); |
461 | - } catch ( \Algolia\AlgoliaSearch\Exceptions\UnreachableException $error ) { |
|
461 | + } catch (\Algolia\AlgoliaSearch\Exceptions\UnreachableException $error) { |
|
462 | 462 | add_action( |
463 | 463 | 'admin_notices', |
464 | - function () { |
|
464 | + function() { |
|
465 | 465 | echo '<div class="error notice"> |
466 | - <p>' . esc_html__( 'An error has been encountered. Please check your application ID and API key. ', 'algolia-woo-indexer' ) . '</p> |
|
466 | + <p>' . esc_html__('An error has been encountered. Please check your application ID and API key. ', 'algolia-woo-indexer') . '</p> |
|
467 | 467 | </div>'; |
468 | 468 | } |
469 | 469 | ); |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | /** |
474 | 474 | * Initialize the search index and set the name to the option from the database |
475 | 475 | */ |
476 | - $index = self::$algolia->initIndex( $algolia_index_name ); |
|
476 | + $index = self::$algolia->initIndex($algolia_index_name); |
|
477 | 477 | |
478 | 478 | /** |
479 | 479 | * Setup arguments for sending all products to Algolia |
@@ -489,10 +489,10 @@ discard block |
||
489 | 489 | /** |
490 | 490 | * Setup arguments for sending only a single product |
491 | 491 | */ |
492 | - if ( isset( $id ) && '' !== $id ) { |
|
492 | + if (isset($id) && '' !== $id) { |
|
493 | 493 | $arguments = array( |
494 | 494 | 'status' => 'publish', |
495 | - 'include' => array( $id ), |
|
495 | + 'include' => array($id), |
|
496 | 496 | 'paginate' => false, |
497 | 497 | ); |
498 | 498 | } |
@@ -502,17 +502,17 @@ discard block |
||
502 | 502 | * |
503 | 503 | * @see https://docs.woocommerce.com/wc-apidocs/function-wc_get_products.html |
504 | 504 | */ |
505 | - $products = /** @scrutinizer ignore-call */ wc_get_products( $arguments ); |
|
505 | + $products = /** @scrutinizer ignore-call */ wc_get_products($arguments); |
|
506 | 506 | |
507 | - if ( $products ) { |
|
507 | + if ($products) { |
|
508 | 508 | $records = array(); |
509 | 509 | $record = array(); |
510 | 510 | |
511 | - foreach ( $products as $product ) { |
|
511 | + foreach ($products as $product) { |
|
512 | 512 | /** |
513 | 513 | * Check if product is in stock if $index_in_stock is set to 1 |
514 | 514 | */ |
515 | - if ( '1' === $index_in_stock && $product->is_in_stock() ) { |
|
515 | + if ('1' === $index_in_stock && $product->is_in_stock()) { |
|
516 | 516 | /** |
517 | 517 | * Extract image from $product->get_image() |
518 | 518 | */ |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | /** |
535 | 535 | * Do not check if product is in stock if $index_in_stock is set to 0 |
536 | 536 | */ |
537 | - if ( '0' === $index_in_stock ) { |
|
537 | + if ('0' === $index_in_stock) { |
|
538 | 538 | /** |
539 | 539 | * Extract image from $product->get_image() |
540 | 540 | */ |
@@ -562,14 +562,14 @@ discard block |
||
562 | 562 | * Send the information to Algolia and save the result |
563 | 563 | * If result is NullResponse, print an error message |
564 | 564 | */ |
565 | - $result = $index->saveObjects( $records ); |
|
565 | + $result = $index->saveObjects($records); |
|
566 | 566 | |
567 | - if ( 'Algolia\AlgoliaSearch\Response\NullResponse' === get_class( $result ) ) { |
|
567 | + if ('Algolia\AlgoliaSearch\Response\NullResponse' === get_class($result)) { |
|
568 | 568 | add_action( |
569 | 569 | 'admin_notices', |
570 | - function () { |
|
570 | + function() { |
|
571 | 571 | echo '<div class="error notice is-dismissible"> |
572 | - <p>' . esc_html__( 'No response from the server. Please check your settings and try again ', 'algolia-woo-indexer' ) . '</p> |
|
572 | + <p>' . esc_html__('No response from the server. Please check your settings and try again ', 'algolia-woo-indexer') . '</p> |
|
573 | 573 | </div>'; |
574 | 574 | } |
575 | 575 | ); |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | * Display success message |
581 | 581 | */ |
582 | 582 | echo '<div class="notice notice-success is-dismissible"> |
583 | - <p>' . esc_html__( 'Product(s) sent to Algolia.', 'algolia-woo-indexer' ) . '</p> |
|
583 | + <p>' . esc_html__('Product(s) sent to Algolia.', 'algolia-woo-indexer') . '</p> |
|
584 | 584 | </div>'; |
585 | 585 | } |
586 | 586 | |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * @param string $input Settings text data |
591 | 591 | * @return array |
592 | 592 | */ |
593 | - public static function settings_fields_validate_options( $input ) { |
|
593 | + public static function settings_fields_validate_options($input) { |
|
594 | 594 | $valid = array(); |
595 | 595 | $valid['name'] = preg_replace( |
596 | 596 | '/[^a-zA-Z\s]/', |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | * @return void |
607 | 607 | */ |
608 | 608 | public static function load_textdomain() { |
609 | - load_plugin_textdomain( 'algolia-woo-indexer', false, basename( dirname( __FILE__ ) ) . '/languages/' ); |
|
609 | + load_plugin_textdomain('algolia-woo-indexer', false, basename(dirname(__FILE__)) . '/languages/'); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | /** |
@@ -617,11 +617,11 @@ discard block |
||
617 | 617 | public static function admin_menu() { |
618 | 618 | add_submenu_page( |
619 | 619 | 'options-general.php', |
620 | - esc_html__( 'Algolia Woo Indexer Settings', 'algolia-woo-indexer' ), |
|
621 | - esc_html__( 'Algolia Woo Indexer Settings', 'algolia-woo-indexer' ), |
|
620 | + esc_html__('Algolia Woo Indexer Settings', 'algolia-woo-indexer'), |
|
621 | + esc_html__('Algolia Woo Indexer Settings', 'algolia-woo-indexer'), |
|
622 | 622 | 'manage_options', |
623 | 623 | 'algolia-woo-indexer-settings', |
624 | - array( get_called_class(), 'algolia_woo_indexer_settings' ) |
|
624 | + array(get_called_class(), 'algolia_woo_indexer_settings') |
|
625 | 625 | ); |
626 | 626 | } |
627 | 627 | |
@@ -634,23 +634,23 @@ discard block |
||
634 | 634 | /** |
635 | 635 | * Verify that the user can access the settings page |
636 | 636 | */ |
637 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
638 | - wp_die( esc_html__( 'Action not allowed.', 'algolia_woo_indexer_settings' ) ); |
|
637 | + if ( ! current_user_can('manage_options')) { |
|
638 | + wp_die(esc_html__('Action not allowed.', 'algolia_woo_indexer_settings')); |
|
639 | 639 | } |
640 | 640 | ?> |
641 | 641 | <div class="wrap"> |
642 | - <h1><?php esc_html__( 'Algolia Woo Indexer Settings', 'algolia-woo-indexer' ); ?></h1> |
|
643 | - <form action="<?php echo esc_url( self::$plugin_url ); ?>" method="POST"> |
|
642 | + <h1><?php esc_html__('Algolia Woo Indexer Settings', 'algolia-woo-indexer'); ?></h1> |
|
643 | + <form action="<?php echo esc_url(self::$plugin_url); ?>" method="POST"> |
|
644 | 644 | <?php |
645 | - settings_fields( 'algolia_woo_options' ); |
|
646 | - do_settings_sections( 'algolia_woo_indexer' ); |
|
647 | - submit_button( '', 'primary wide' ); |
|
645 | + settings_fields('algolia_woo_options'); |
|
646 | + do_settings_sections('algolia_woo_indexer'); |
|
647 | + submit_button('', 'primary wide'); |
|
648 | 648 | ?> |
649 | 649 | </form> |
650 | - <form action="<?php echo esc_url( self::$plugin_url ); ?>" method="POST"> |
|
651 | - <?php wp_nonce_field( 'send_products_to_algolia_nonce_action', 'send_products_to_algolia_nonce_name' ); ?> |
|
650 | + <form action="<?php echo esc_url(self::$plugin_url); ?>" method="POST"> |
|
651 | + <?php wp_nonce_field('send_products_to_algolia_nonce_action', 'send_products_to_algolia_nonce_name'); ?> |
|
652 | 652 | <input type="hidden" name="send_products_to_algolia" id="send_products_to_algolia" value="true" /> |
653 | - <?php submit_button( esc_html__( 'Send products to Algolia', 'algolia_woo_indexer_settings' ), 'primary wide', '', false ); ?> |
|
653 | + <?php submit_button(esc_html__('Send products to Algolia', 'algolia_woo_indexer_settings'), 'primary wide', '', false); ?> |
|
654 | 654 | </form> |
655 | 655 | </div> |
656 | 656 | <?php |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | * @return object |
663 | 663 | */ |
664 | 664 | public static function get_instance() { |
665 | - if ( ! self::$instance ) { |
|
665 | + if ( ! self::$instance) { |
|
666 | 666 | self::$instance = new Algolia_Woo_Indexer(); |
667 | 667 | } |
668 | 668 | return self::$instance; |
@@ -678,47 +678,47 @@ discard block |
||
678 | 678 | /** |
679 | 679 | * Set default values for options if not already set |
680 | 680 | */ |
681 | - $index_in_stock = get_option( ALGOWOO_DB_OPTION . '_index_in_stock' ); |
|
682 | - $automatically_send_new_products = get_option( ALGOWOO_DB_OPTION . '_automatically_send_new_products' ); |
|
683 | - $algolia_application_id = get_option( ALGOWOO_DB_OPTION . '_application_id' ); |
|
684 | - $algolia_api_key = get_option( ALGOWOO_DB_OPTION . '_admin_api_key' ); |
|
685 | - $algolia_index_name = get_option( ALGOWOO_DB_OPTION . '_index_name' ); |
|
681 | + $index_in_stock = get_option(ALGOWOO_DB_OPTION . '_index_in_stock'); |
|
682 | + $automatically_send_new_products = get_option(ALGOWOO_DB_OPTION . '_automatically_send_new_products'); |
|
683 | + $algolia_application_id = get_option(ALGOWOO_DB_OPTION . '_application_id'); |
|
684 | + $algolia_api_key = get_option(ALGOWOO_DB_OPTION . '_admin_api_key'); |
|
685 | + $algolia_index_name = get_option(ALGOWOO_DB_OPTION . '_index_name'); |
|
686 | 686 | |
687 | - if ( empty( $index_in_stock ) ) { |
|
687 | + if (empty($index_in_stock)) { |
|
688 | 688 | add_option( |
689 | 689 | ALGOWOO_DB_OPTION . '_index_in_stock', |
690 | 690 | '0' |
691 | 691 | ); |
692 | 692 | } |
693 | 693 | |
694 | - if ( empty( $automatically_send_new_products ) ) { |
|
694 | + if (empty($automatically_send_new_products)) { |
|
695 | 695 | add_option( |
696 | 696 | ALGOWOO_DB_OPTION . '_automatically_send_new_products', |
697 | 697 | '0' |
698 | 698 | ); |
699 | 699 | } |
700 | 700 | |
701 | - if ( empty( $algolia_application_id ) ) { |
|
701 | + if (empty($algolia_application_id)) { |
|
702 | 702 | add_option( |
703 | 703 | ALGOWOO_DB_OPTION . '_application_id', |
704 | 704 | 'Change me' |
705 | 705 | ); |
706 | 706 | } |
707 | 707 | |
708 | - if ( empty( $algolia_api_key ) ) { |
|
708 | + if (empty($algolia_api_key)) { |
|
709 | 709 | add_option( |
710 | 710 | ALGOWOO_DB_OPTION . '_admin_api_key', |
711 | 711 | 'Change me' |
712 | 712 | ); |
713 | 713 | } |
714 | 714 | |
715 | - if ( empty( $algolia_index_name ) ) { |
|
715 | + if (empty($algolia_index_name)) { |
|
716 | 716 | add_option( |
717 | 717 | ALGOWOO_DB_OPTION . '_index_name', |
718 | 718 | 'Change me' |
719 | 719 | ); |
720 | 720 | } |
721 | - set_transient( self::PLUGIN_TRANSIENT, true ); |
|
721 | + set_transient(self::PLUGIN_TRANSIENT, true); |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | /** |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | * @return void |
728 | 728 | */ |
729 | 729 | public static function deactivate_plugin() { |
730 | - delete_transient( self::PLUGIN_TRANSIENT, true ); |
|
730 | + delete_transient(self::PLUGIN_TRANSIENT, true); |
|
731 | 731 | } |
732 | 732 | } |
733 | 733 | } |
@@ -18,64 +18,64 @@ |
||
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 | } |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Abort if this file is called directly |
19 | 19 | */ |
20 | -if (! defined('ABSPATH')) { |
|
20 | +if ( ! defined('ABSPATH')) { |
|
21 | 21 | exit; |
22 | 22 | } |
23 | 23 | |
24 | -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 |
||
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>'; |