@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public static function setup_settings_sections() { |
| 72 | 72 | /** |
| 73 | - * Setup arguments for settings sections and fields |
|
| 74 | - * |
|
| 75 | - * @see https://developer.wordpress.org/reference/functions/register_setting/ |
|
| 76 | - */ |
|
| 73 | + * Setup arguments for settings sections and fields |
|
| 74 | + * |
|
| 75 | + * @see https://developer.wordpress.org/reference/functions/register_setting/ |
|
| 76 | + */ |
|
| 77 | 77 | if ( is_admin() ) { |
| 78 | 78 | $arguments = array( |
| 79 | 79 | 'type' => 'string', |
@@ -480,8 +480,8 @@ discard block |
||
| 480 | 480 | ); |
| 481 | 481 | |
| 482 | 482 | /** |
| 483 | - * Setup arguments for sending only a single product |
|
| 484 | - */ |
|
| 483 | + * Setup arguments for sending only a single product |
|
| 484 | + */ |
|
| 485 | 485 | if ( isset( $id ) && '' !== $id ) { |
| 486 | 486 | $arguments = array( |
| 487 | 487 | 'status' => 'publish', |
@@ -625,8 +625,8 @@ discard block |
||
| 625 | 625 | */ |
| 626 | 626 | public static function algolia_woo_indexer_settings() { |
| 627 | 627 | /** |
| 628 | - * Verify that the user can access the settings page |
|
| 629 | - */ |
|
| 628 | + * Verify that the user can access the settings page |
|
| 629 | + */ |
|
| 630 | 630 | if ( ! current_user_can( 'manage_options' ) ) { |
| 631 | 631 | wp_die( esc_html__( 'Action not allowed.', 'algolia_woo_indexer_settings' ) ); |
| 632 | 632 | } |
@@ -14,17 +14,17 @@ 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 | * Define the plugin version and the database table name |
| 23 | 23 | */ |
| 24 | -define( 'ALGOWOO_DB_OPTION', '_algolia_woo_indexer' ); |
|
| 25 | -define( 'ALGOWOO_CURRENT_DB_VERSION', '0.3' ); |
|
| 24 | +define('ALGOWOO_DB_OPTION', '_algolia_woo_indexer'); |
|
| 25 | +define('ALGOWOO_CURRENT_DB_VERSION', '0.3'); |
|
| 26 | 26 | |
| 27 | -if ( ! class_exists( 'Algolia_Woo_Indexer' ) ) { |
|
| 27 | +if ( ! class_exists('Algolia_Woo_Indexer')) { |
|
| 28 | 28 | /** |
| 29 | 29 | * Algolia WooIndexer main class |
| 30 | 30 | */ |
@@ -74,13 +74,13 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @see https://developer.wordpress.org/reference/functions/register_setting/ |
| 76 | 76 | */ |
| 77 | - if ( is_admin() ) { |
|
| 77 | + if (is_admin()) { |
|
| 78 | 78 | $arguments = array( |
| 79 | 79 | 'type' => 'string', |
| 80 | 80 | 'sanitize_callback' => 'settings_fields_validate_options', |
| 81 | 81 | 'default' => null, |
| 82 | 82 | ); |
| 83 | - register_setting( 'algolia_woo_options', 'algolia_woo_options', $arguments ); |
|
| 83 | + register_setting('algolia_woo_options', 'algolia_woo_options', $arguments); |
|
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * Make sure we reference the instance of the current class by using self::get_instance() |
@@ -93,42 +93,42 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | add_settings_section( |
| 95 | 95 | 'algolia_woo_indexer_main', |
| 96 | - esc_html__( 'Algolia Woo Plugin Settings', 'algolia-woo-indexer' ), |
|
| 97 | - array( $algowooindexer, 'algolia_woo_indexer_section_text' ), |
|
| 96 | + esc_html__('Algolia Woo Plugin Settings', 'algolia-woo-indexer'), |
|
| 97 | + array($algowooindexer, 'algolia_woo_indexer_section_text'), |
|
| 98 | 98 | 'algolia_woo_indexer' |
| 99 | 99 | ); |
| 100 | 100 | add_settings_field( |
| 101 | 101 | 'algolia_woo_indexer_application_id', |
| 102 | - esc_html__( 'Application ID', 'algolia-woo-indexer' ), |
|
| 103 | - array( $algowooindexer, 'algolia_woo_indexer_application_id_output' ), |
|
| 102 | + esc_html__('Application ID', 'algolia-woo-indexer'), |
|
| 103 | + array($algowooindexer, 'algolia_woo_indexer_application_id_output'), |
|
| 104 | 104 | 'algolia_woo_indexer', |
| 105 | 105 | 'algolia_woo_indexer_main' |
| 106 | 106 | ); |
| 107 | 107 | add_settings_field( |
| 108 | 108 | 'algolia_woo_indexer_admin_api_key', |
| 109 | - esc_html__( 'Admin API Key', 'algolia-woo-indexer' ), |
|
| 110 | - array( $algowooindexer, 'algolia_woo_indexer_admin_api_key_output' ), |
|
| 109 | + esc_html__('Admin API Key', 'algolia-woo-indexer'), |
|
| 110 | + array($algowooindexer, 'algolia_woo_indexer_admin_api_key_output'), |
|
| 111 | 111 | 'algolia_woo_indexer', |
| 112 | 112 | 'algolia_woo_indexer_main' |
| 113 | 113 | ); |
| 114 | 114 | add_settings_field( |
| 115 | 115 | 'algolia_woo_indexer_index_name', |
| 116 | - esc_html__( 'Index name (will be created if not existing)', 'algolia-woo-indexer' ), |
|
| 117 | - array( $algowooindexer, 'algolia_woo_indexer_index_name_output' ), |
|
| 116 | + esc_html__('Index name (will be created if not existing)', 'algolia-woo-indexer'), |
|
| 117 | + array($algowooindexer, 'algolia_woo_indexer_index_name_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_in_stock', |
| 123 | - esc_html__( 'Only index products in stock', 'algolia-woo-indexer' ), |
|
| 124 | - array( $algowooindexer, 'algolia_woo_indexer_index_in_stock_output' ), |
|
| 123 | + esc_html__('Only index products in stock', 'algolia-woo-indexer'), |
|
| 124 | + array($algowooindexer, 'algolia_woo_indexer_index_in_stock_output'), |
|
| 125 | 125 | 'algolia_woo_indexer', |
| 126 | 126 | 'algolia_woo_indexer_main' |
| 127 | 127 | ); |
| 128 | 128 | add_settings_field( |
| 129 | 129 | 'algolia_woo_indexer_automatically_send_new_products', |
| 130 | - esc_html__( 'Automatically index new products', 'algolia-woo-indexer' ), |
|
| 131 | - array( $algowooindexer, 'algolia_woo_indexer_automatically_send_new_products_output' ), |
|
| 130 | + esc_html__('Automatically index new products', 'algolia-woo-indexer'), |
|
| 131 | + array($algowooindexer, 'algolia_woo_indexer_automatically_send_new_products_output'), |
|
| 132 | 132 | 'algolia_woo_indexer', |
| 133 | 133 | 'algolia_woo_indexer_main' |
| 134 | 134 | ); |
@@ -143,12 +143,12 @@ discard block |
||
| 143 | 143 | * @return void |
| 144 | 144 | */ |
| 145 | 145 | public static function algolia_woo_indexer_admin_api_key_output() { |
| 146 | - $api_key = get_option( ALGOWOO_DB_OPTION . '_admin_api_key' ); |
|
| 146 | + $api_key = get_option(ALGOWOO_DB_OPTION . '_admin_api_key'); |
|
| 147 | 147 | |
| 148 | - wp_nonce_field( 'algolia_woo_indexer_admin_api_nonce_action', 'algolia_woo_indexer_admin_api_nonce_name' ); |
|
| 148 | + wp_nonce_field('algolia_woo_indexer_admin_api_nonce_action', 'algolia_woo_indexer_admin_api_nonce_name'); |
|
| 149 | 149 | |
| 150 | 150 | echo "<input id='algolia_woo_indexer_admin_api_key' name='algolia_woo_indexer_admin_api_key[key]' |
| 151 | - type='text' value='" . esc_attr( $api_key ) . "' />"; |
|
| 151 | + type='text' value='" . esc_attr($api_key) . "' />"; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -157,10 +157,10 @@ discard block |
||
| 157 | 157 | * @return void |
| 158 | 158 | */ |
| 159 | 159 | public static function algolia_woo_indexer_application_id_output() { |
| 160 | - $application_id = get_option( ALGOWOO_DB_OPTION . '_application_id' ); |
|
| 160 | + $application_id = get_option(ALGOWOO_DB_OPTION . '_application_id'); |
|
| 161 | 161 | |
| 162 | 162 | echo "<input id='algolia_woo_indexer_application_id' name='algolia_woo_indexer_application_id[id]' |
| 163 | - type='text' value='" . esc_attr( $application_id ) . "' />"; |
|
| 163 | + type='text' value='" . esc_attr($application_id) . "' />"; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
@@ -169,10 +169,10 @@ discard block |
||
| 169 | 169 | * @return void |
| 170 | 170 | */ |
| 171 | 171 | public static function algolia_woo_indexer_index_name_output() { |
| 172 | - $index_name = get_option( ALGOWOO_DB_OPTION . '_index_name' ); |
|
| 172 | + $index_name = get_option(ALGOWOO_DB_OPTION . '_index_name'); |
|
| 173 | 173 | |
| 174 | 174 | echo "<input id='algolia_woo_indexer_index_name' name='algolia_woo_indexer_index_name[name]' |
| 175 | - type='text' value='" . esc_attr( $index_name ) . "' />"; |
|
| 175 | + type='text' value='" . esc_attr($index_name) . "' />"; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -185,11 +185,11 @@ discard block |
||
| 185 | 185 | * Sanitization is not really needed as the variable is not directly echoed |
| 186 | 186 | * But I have still done it to be 100% safe |
| 187 | 187 | */ |
| 188 | - $index_in_stock = get_option( ALGOWOO_DB_OPTION . '_index_in_stock' ); |
|
| 189 | - $index_in_stock = ( ! empty( $index_in_stock ) ) ? 1 : 0; |
|
| 188 | + $index_in_stock = get_option(ALGOWOO_DB_OPTION . '_index_in_stock'); |
|
| 189 | + $index_in_stock = ( ! empty($index_in_stock)) ? 1 : 0; |
|
| 190 | 190 | ?> |
| 191 | 191 | <input id="algolia_woo_indexer_index_in_stock" name="algolia_woo_indexer_index_in_stock[checked]" |
| 192 | - type="checkbox" <?php checked( 1, $index_in_stock ); ?> /> |
|
| 192 | + type="checkbox" <?php checked(1, $index_in_stock); ?> /> |
|
| 193 | 193 | <?php |
| 194 | 194 | } |
| 195 | 195 | |
@@ -203,11 +203,11 @@ discard block |
||
| 203 | 203 | * Sanitization is not really needed as the variable is not directly echoed |
| 204 | 204 | * But I have still done it to be 100% safe |
| 205 | 205 | */ |
| 206 | - $automatically_send_new_products = get_option( ALGOWOO_DB_OPTION . '_automatically_send_new_products' ); |
|
| 207 | - $automatically_send_new_products = ( ! empty( $automatically_send_new_products ) ) ? 1 : 0; |
|
| 206 | + $automatically_send_new_products = get_option(ALGOWOO_DB_OPTION . '_automatically_send_new_products'); |
|
| 207 | + $automatically_send_new_products = ( ! empty($automatically_send_new_products)) ? 1 : 0; |
|
| 208 | 208 | ?> |
| 209 | 209 | <input id="algolia_woo_indexer_automatically_send_new_products" name="algolia_woo_indexer_automatically_send_new_products[checked]" |
| 210 | - type="checkbox" <?php checked( 1, $automatically_send_new_products ); ?> /> |
|
| 210 | + type="checkbox" <?php checked(1, $automatically_send_new_products); ?> /> |
|
| 211 | 211 | <?php |
| 212 | 212 | } |
| 213 | 213 | |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * @return void |
| 218 | 218 | */ |
| 219 | 219 | public static function algolia_woo_indexer_section_text() { |
| 220 | - echo esc_html__( 'Enter your settings here', 'algolia-woo-indexer' ); |
|
| 220 | + echo esc_html__('Enter your settings here', 'algolia-woo-indexer'); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | public static function maybe_send_products() { |
| 229 | 229 | |
| 230 | - if ( true === Algolia_Verify_Nonces::verify_send_products_nonce() ) { |
|
| 230 | + if (true === Algolia_Verify_Nonces::verify_send_products_nonce()) { |
|
| 231 | 231 | self::send_products_to_algolia(); |
| 232 | 232 | return; |
| 233 | 233 | } |
@@ -243,19 +243,19 @@ discard block |
||
| 243 | 243 | /** |
| 244 | 244 | * Fetch the option to see if we are going to automatically send new products |
| 245 | 245 | */ |
| 246 | - $automatically_send_new_products = get_option( ALGOWOO_DB_OPTION . '_automatically_send_new_products' ); |
|
| 246 | + $automatically_send_new_products = get_option(ALGOWOO_DB_OPTION . '_automatically_send_new_products'); |
|
| 247 | 247 | |
| 248 | 248 | /** |
| 249 | 249 | * Check that we have the minimum versions required and all of the required PHP extensions |
| 250 | 250 | */ |
| 251 | 251 | Algolia_Check_Requirements::check_unmet_requirements(); |
| 252 | 252 | |
| 253 | - if ( ! Algolia_Check_Requirements::algolia_wp_version_check() || ! Algolia_Check_Requirements::algolia_php_version_check() ) { |
|
| 253 | + if ( ! Algolia_Check_Requirements::algolia_wp_version_check() || ! Algolia_Check_Requirements::algolia_php_version_check()) { |
|
| 254 | 254 | add_action( |
| 255 | 255 | 'admin_notices', |
| 256 | - function () { |
|
| 256 | + function() { |
|
| 257 | 257 | echo '<div class="error notice"> |
| 258 | - <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> |
|
| 258 | + <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> |
|
| 259 | 259 | </div>'; |
| 260 | 260 | } |
| 261 | 261 | ); |
@@ -266,33 +266,33 @@ discard block |
||
| 266 | 266 | /** |
| 267 | 267 | * Setup translations |
| 268 | 268 | */ |
| 269 | - add_action( 'plugins_loaded', array( $ob_class, 'load_textdomain' ) ); |
|
| 269 | + add_action('plugins_loaded', array($ob_class, 'load_textdomain')); |
|
| 270 | 270 | |
| 271 | 271 | /** |
| 272 | 272 | * Add actions to setup admin menu |
| 273 | 273 | */ |
| 274 | - if ( is_admin() ) { |
|
| 275 | - add_action( 'admin_menu', array( $ob_class, 'admin_menu' ) ); |
|
| 276 | - add_action( 'admin_init', array( $ob_class, 'setup_settings_sections' ) ); |
|
| 277 | - add_action( 'admin_init', array( $ob_class, 'update_settings_options' ) ); |
|
| 278 | - add_action( 'admin_init', array( $ob_class, 'maybe_send_products' ) ); |
|
| 274 | + if (is_admin()) { |
|
| 275 | + add_action('admin_menu', array($ob_class, 'admin_menu')); |
|
| 276 | + add_action('admin_init', array($ob_class, 'setup_settings_sections')); |
|
| 277 | + add_action('admin_init', array($ob_class, 'update_settings_options')); |
|
| 278 | + add_action('admin_init', array($ob_class, 'maybe_send_products')); |
|
| 279 | 279 | |
| 280 | 280 | /** |
| 281 | 281 | * Register hook to automatically send new products if the option is set |
| 282 | 282 | */ |
| 283 | 283 | |
| 284 | - if ( '1' === $automatically_send_new_products ) { |
|
| 285 | - add_action( 'save_post', array( $ob_class, 'send_new_product_to_algolia' ), 10, 3 ); |
|
| 284 | + if ('1' === $automatically_send_new_products) { |
|
| 285 | + add_action('save_post', array($ob_class, 'send_new_product_to_algolia'), 10, 3); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - self::$plugin_url = admin_url( 'options-general.php?page=algolia-woo-indexer-settings' ); |
|
| 288 | + self::$plugin_url = admin_url('options-general.php?page=algolia-woo-indexer-settings'); |
|
| 289 | 289 | |
| 290 | - if ( ! Algolia_Check_Requirements::is_woocommerce_plugin_active() ) { |
|
| 290 | + if ( ! Algolia_Check_Requirements::is_woocommerce_plugin_active()) { |
|
| 291 | 291 | add_action( |
| 292 | 292 | 'admin_notices', |
| 293 | - function () { |
|
| 293 | + function() { |
|
| 294 | 294 | echo '<div class="error notice"> |
| 295 | - <p>' . esc_html__( 'WooCommerce plugin must be enabled for Algolia Woo Indexer to work.', 'algolia-woo-indexer' ) . '</p> |
|
| 295 | + <p>' . esc_html__('WooCommerce plugin must be enabled for Algolia Woo Indexer to work.', 'algolia-woo-indexer') . '</p> |
|
| 296 | 296 | </div>'; |
| 297 | 297 | } |
| 298 | 298 | ); |
@@ -309,12 +309,12 @@ discard block |
||
| 309 | 309 | * |
| 310 | 310 | * @return void |
| 311 | 311 | */ |
| 312 | - public static function send_new_product_to_algolia( $post_id, $post, $update ) { |
|
| 312 | + public static function send_new_product_to_algolia($post_id, $post, $update) { |
|
| 313 | 313 | |
| 314 | - if ( 'publish' !== $post->post_status || 'product' !== $post->post_type ) { |
|
| 314 | + if ('publish' !== $post->post_status || 'product' !== $post->post_type) { |
|
| 315 | 315 | return; |
| 316 | 316 | } |
| 317 | - self::send_products_to_algolia( $post_id ); |
|
| 317 | + self::send_products_to_algolia($post_id); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | /** |
| 331 | 331 | * Do not proceed if we are going to send products |
| 332 | 332 | */ |
| 333 | - if ( true === Algolia_Verify_Nonces::verify_send_products_nonce() ) { |
|
| 333 | + if (true === Algolia_Verify_Nonces::verify_send_products_nonce()) { |
|
| 334 | 334 | return; |
| 335 | 335 | } |
| 336 | 336 | |
@@ -339,26 +339,26 @@ discard block |
||
| 339 | 339 | * |
| 340 | 340 | * @see https://www.php.net/manual/en/function.filter-input.php |
| 341 | 341 | */ |
| 342 | - $post_application_id = filter_input( INPUT_POST, 'algolia_woo_indexer_application_id', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
| 343 | - $post_api_key = filter_input( INPUT_POST, 'algolia_woo_indexer_admin_api_key', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
| 344 | - $post_index_name = filter_input( INPUT_POST, 'algolia_woo_indexer_index_name', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
| 345 | - $index_in_stock = filter_input( INPUT_POST, 'algolia_woo_indexer_index_in_stock', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
| 346 | - $automatically_send_new_products = filter_input( INPUT_POST, 'algolia_woo_indexer_automatically_send_new_products', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
| 342 | + $post_application_id = filter_input(INPUT_POST, 'algolia_woo_indexer_application_id', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
| 343 | + $post_api_key = filter_input(INPUT_POST, 'algolia_woo_indexer_admin_api_key', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
| 344 | + $post_index_name = filter_input(INPUT_POST, 'algolia_woo_indexer_index_name', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
| 345 | + $index_in_stock = filter_input(INPUT_POST, 'algolia_woo_indexer_index_in_stock', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
| 346 | + $automatically_send_new_products = filter_input(INPUT_POST, 'algolia_woo_indexer_automatically_send_new_products', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
| 347 | 347 | |
| 348 | 348 | /** |
| 349 | 349 | * Properly sanitize text fields before updating data |
| 350 | 350 | * |
| 351 | 351 | * @see https://developer.wordpress.org/reference/functions/sanitize_text_field/ |
| 352 | 352 | */ |
| 353 | - $filtered_application_id = sanitize_text_field( $post_application_id['id'] ); |
|
| 354 | - $filtered_api_key = sanitize_text_field( $post_api_key['key'] ); |
|
| 355 | - $filtered_index_name = sanitize_text_field( $post_index_name['name'] ); |
|
| 353 | + $filtered_application_id = sanitize_text_field($post_application_id['id']); |
|
| 354 | + $filtered_api_key = sanitize_text_field($post_api_key['key']); |
|
| 355 | + $filtered_index_name = sanitize_text_field($post_index_name['name']); |
|
| 356 | 356 | |
| 357 | 357 | /** |
| 358 | 358 | * Sanitizing by setting the value to either 1 or 0 |
| 359 | 359 | */ |
| 360 | - $filtered_index_in_stock = ( ! empty( $index_in_stock ) ) ? 1 : 0; |
|
| 361 | - $filtered_automatically_send_new_products = ( ! empty( $automatically_send_new_products ) ) ? 1 : 0; |
|
| 360 | + $filtered_index_in_stock = ( ! empty($index_in_stock)) ? 1 : 0; |
|
| 361 | + $filtered_automatically_send_new_products = ( ! empty($automatically_send_new_products)) ? 1 : 0; |
|
| 362 | 362 | |
| 363 | 363 | /** |
| 364 | 364 | * Values have been filtered and sanitized |
@@ -366,35 +366,35 @@ discard block |
||
| 366 | 366 | * |
| 367 | 367 | * @see https://developer.wordpress.org/reference/functions/update_option/ |
| 368 | 368 | */ |
| 369 | - if ( isset( $filtered_application_id ) && ( ! empty( $filtered_application_id ) ) ) { |
|
| 369 | + if (isset($filtered_application_id) && ( ! empty($filtered_application_id))) { |
|
| 370 | 370 | update_option( |
| 371 | 371 | ALGOWOO_DB_OPTION . '_application_id', |
| 372 | 372 | $filtered_application_id |
| 373 | 373 | ); |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - if ( isset( $filtered_api_key ) && ( ! empty( $filtered_api_key ) ) ) { |
|
| 376 | + if (isset($filtered_api_key) && ( ! empty($filtered_api_key))) { |
|
| 377 | 377 | update_option( |
| 378 | 378 | ALGOWOO_DB_OPTION . '_admin_api_key', |
| 379 | 379 | $filtered_api_key |
| 380 | 380 | ); |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - if ( isset( $filtered_index_name ) && ( ! empty( $filtered_index_name ) ) ) { |
|
| 383 | + if (isset($filtered_index_name) && ( ! empty($filtered_index_name))) { |
|
| 384 | 384 | update_option( |
| 385 | 385 | ALGOWOO_DB_OPTION . '_index_name', |
| 386 | 386 | $filtered_index_name |
| 387 | 387 | ); |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - if ( isset( $filtered_index_in_stock ) && ( ! empty( $filtered_index_in_stock ) ) ) { |
|
| 390 | + if (isset($filtered_index_in_stock) && ( ! empty($filtered_index_in_stock))) { |
|
| 391 | 391 | update_option( |
| 392 | 392 | ALGOWOO_DB_OPTION . '_index_in_stock', |
| 393 | 393 | $filtered_index_in_stock |
| 394 | 394 | ); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - if ( isset( $filtered_automatically_send_new_products ) && ( ! empty( $filtered_automatically_send_new_products ) ) ) { |
|
| 397 | + if (isset($filtered_automatically_send_new_products) && ( ! empty($filtered_automatically_send_new_products))) { |
|
| 398 | 398 | update_option( |
| 399 | 399 | ALGOWOO_DB_OPTION . '_automatically_send_new_products', |
| 400 | 400 | $filtered_automatically_send_new_products |
@@ -408,33 +408,33 @@ discard block |
||
| 408 | 408 | * @param Int $id Product to send to Algolia if we send only a single product |
| 409 | 409 | * @return void |
| 410 | 410 | */ |
| 411 | - public static function send_products_to_algolia( $id = '' ) { |
|
| 411 | + public static function send_products_to_algolia($id = '') { |
|
| 412 | 412 | /** |
| 413 | 413 | * Remove classes from plugin URL and autoload Algolia with Composer |
| 414 | 414 | */ |
| 415 | 415 | |
| 416 | - $base_plugin_directory = str_replace( 'classes', '', dirname( __FILE__ ) ); |
|
| 416 | + $base_plugin_directory = str_replace('classes', '', dirname(__FILE__)); |
|
| 417 | 417 | require_once $base_plugin_directory . '/vendor/autoload.php'; |
| 418 | 418 | |
| 419 | 419 | /** |
| 420 | 420 | * Fetch the required variables from the Settings API |
| 421 | 421 | */ |
| 422 | 422 | |
| 423 | - $algolia_application_id = get_option( ALGOWOO_DB_OPTION . '_application_id' ); |
|
| 424 | - $algolia_api_key = get_option( ALGOWOO_DB_OPTION . '_admin_api_key' ); |
|
| 425 | - $algolia_index_name = get_option( ALGOWOO_DB_OPTION . '_index_name' ); |
|
| 423 | + $algolia_application_id = get_option(ALGOWOO_DB_OPTION . '_application_id'); |
|
| 424 | + $algolia_api_key = get_option(ALGOWOO_DB_OPTION . '_admin_api_key'); |
|
| 425 | + $algolia_index_name = get_option(ALGOWOO_DB_OPTION . '_index_name'); |
|
| 426 | 426 | |
| 427 | - $index_in_stock = get_option( ALGOWOO_DB_OPTION . '_index_in_stock' ); |
|
| 427 | + $index_in_stock = get_option(ALGOWOO_DB_OPTION . '_index_in_stock'); |
|
| 428 | 428 | |
| 429 | 429 | /** |
| 430 | 430 | * Display admin notice and return if not all values have been set |
| 431 | 431 | */ |
| 432 | - if ( empty( $algolia_application_id ) || empty( $algolia_api_key || empty( $algolia_index_name ) ) ) { |
|
| 432 | + if (empty($algolia_application_id) || empty($algolia_api_key || empty($algolia_index_name))) { |
|
| 433 | 433 | add_action( |
| 434 | 434 | 'admin_notices', |
| 435 | - function () { |
|
| 435 | + function() { |
|
| 436 | 436 | echo '<div class="error notice"> |
| 437 | - <p>' . esc_html__( 'All settings need to be set for the plugin to work.', 'algolia-woo-indexer' ) . '</p> |
|
| 437 | + <p>' . esc_html__('All settings need to be set for the plugin to work.', 'algolia-woo-indexer') . '</p> |
|
| 438 | 438 | </div>'; |
| 439 | 439 | } |
| 440 | 440 | ); |
@@ -444,19 +444,19 @@ discard block |
||
| 444 | 444 | /** |
| 445 | 445 | * Initiate the Algolia client |
| 446 | 446 | */ |
| 447 | - self::$algolia = \Algolia\AlgoliaSearch\SearchClient::create( $algolia_application_id, $algolia_api_key ); |
|
| 447 | + self::$algolia = \Algolia\AlgoliaSearch\SearchClient::create($algolia_application_id, $algolia_api_key); |
|
| 448 | 448 | |
| 449 | 449 | /** |
| 450 | 450 | * Check if we can connect, if not, handle the exception, display an error and then return |
| 451 | 451 | */ |
| 452 | 452 | try { |
| 453 | 453 | self::$algolia->listApiKeys(); |
| 454 | - } catch ( \Algolia\AlgoliaSearch\Exceptions\UnreachableException $error ) { |
|
| 454 | + } catch (\Algolia\AlgoliaSearch\Exceptions\UnreachableException $error) { |
|
| 455 | 455 | add_action( |
| 456 | 456 | 'admin_notices', |
| 457 | - function () { |
|
| 457 | + function() { |
|
| 458 | 458 | echo '<div class="error notice"> |
| 459 | - <p>' . esc_html__( 'An error has been encountered. Please check your application ID and API key. ', 'algolia-woo-indexer' ) . '</p> |
|
| 459 | + <p>' . esc_html__('An error has been encountered. Please check your application ID and API key. ', 'algolia-woo-indexer') . '</p> |
|
| 460 | 460 | </div>'; |
| 461 | 461 | } |
| 462 | 462 | ); |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | /** |
| 467 | 467 | * Initialize the search index and set the name to the option from the database |
| 468 | 468 | */ |
| 469 | - $index = self::$algolia->initIndex( $algolia_index_name ); |
|
| 469 | + $index = self::$algolia->initIndex($algolia_index_name); |
|
| 470 | 470 | |
| 471 | 471 | /** |
| 472 | 472 | * Setup arguments for sending all products to Algolia |
@@ -482,10 +482,10 @@ discard block |
||
| 482 | 482 | /** |
| 483 | 483 | * Setup arguments for sending only a single product |
| 484 | 484 | */ |
| 485 | - if ( isset( $id ) && '' !== $id ) { |
|
| 485 | + if (isset($id) && '' !== $id) { |
|
| 486 | 486 | $arguments = array( |
| 487 | 487 | 'status' => 'publish', |
| 488 | - 'include' => array( $id ), |
|
| 488 | + 'include' => array($id), |
|
| 489 | 489 | 'paginate' => false, |
| 490 | 490 | ); |
| 491 | 491 | } |
@@ -495,17 +495,17 @@ discard block |
||
| 495 | 495 | * |
| 496 | 496 | * @see https://docs.woocommerce.com/wc-apidocs/function-wc_get_products.html |
| 497 | 497 | */ |
| 498 | - $products = wc_get_products( $arguments ); |
|
| 498 | + $products = wc_get_products($arguments); |
|
| 499 | 499 | |
| 500 | - if ( $products ) { |
|
| 500 | + if ($products) { |
|
| 501 | 501 | $records = array(); |
| 502 | 502 | $record = array(); |
| 503 | 503 | |
| 504 | - foreach ( $products as $product ) { |
|
| 504 | + foreach ($products as $product) { |
|
| 505 | 505 | /** |
| 506 | 506 | * Check if product is in stock if $index_in_stock is set to 1 |
| 507 | 507 | */ |
| 508 | - if ( '1' === $index_in_stock && $product->is_in_stock() ) { |
|
| 508 | + if ('1' === $index_in_stock && $product->is_in_stock()) { |
|
| 509 | 509 | /** |
| 510 | 510 | * Extract image from $product->get_image() |
| 511 | 511 | */ |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | /** |
| 528 | 528 | * Do not check if product is in stock if $index_in_stock is set to 0 |
| 529 | 529 | */ |
| 530 | - if ( '0' === $index_in_stock ) { |
|
| 530 | + if ('0' === $index_in_stock) { |
|
| 531 | 531 | /** |
| 532 | 532 | * Extract image from $product->get_image() |
| 533 | 533 | */ |
@@ -555,14 +555,14 @@ discard block |
||
| 555 | 555 | * Send the information to Algolia and save the result |
| 556 | 556 | * If result is NullResponse, print an error message |
| 557 | 557 | */ |
| 558 | - $result = $index->saveObjects( $records ); |
|
| 558 | + $result = $index->saveObjects($records); |
|
| 559 | 559 | |
| 560 | - if ( 'Algolia\AlgoliaSearch\Response\NullResponse' === get_class( $result ) ) { |
|
| 560 | + if ('Algolia\AlgoliaSearch\Response\NullResponse' === get_class($result)) { |
|
| 561 | 561 | add_action( |
| 562 | 562 | 'admin_notices', |
| 563 | - function () { |
|
| 563 | + function() { |
|
| 564 | 564 | echo '<div class="error notice is-dismissible"> |
| 565 | - <p>' . esc_html__( 'No response from the server. Please check your settings and try again ', 'algolia-woo-indexer' ) . '</p> |
|
| 565 | + <p>' . esc_html__('No response from the server. Please check your settings and try again ', 'algolia-woo-indexer') . '</p> |
|
| 566 | 566 | </div>'; |
| 567 | 567 | } |
| 568 | 568 | ); |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | * Display success message |
| 574 | 574 | */ |
| 575 | 575 | echo '<div class="notice notice-success is-dismissible"> |
| 576 | - <p>' . esc_html__( 'Product(s) sent to Algolia.', 'algolia-woo-indexer' ) . '</p> |
|
| 576 | + <p>' . esc_html__('Product(s) sent to Algolia.', 'algolia-woo-indexer') . '</p> |
|
| 577 | 577 | </div>'; |
| 578 | 578 | } |
| 579 | 579 | |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | * @param string $input Settings text data |
| 584 | 584 | * @return array |
| 585 | 585 | */ |
| 586 | - public static function settings_fields_validate_options( $input ) { |
|
| 586 | + public static function settings_fields_validate_options($input) { |
|
| 587 | 587 | $valid = array(); |
| 588 | 588 | $valid['name'] = preg_replace( |
| 589 | 589 | '/[^a-zA-Z\s]/', |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | * @return void |
| 600 | 600 | */ |
| 601 | 601 | public static function load_textdomain() { |
| 602 | - load_plugin_textdomain( 'algolia-woo-indexer', false, basename( dirname( __FILE__ ) ) . '/languages/' ); |
|
| 602 | + load_plugin_textdomain('algolia-woo-indexer', false, basename(dirname(__FILE__)) . '/languages/'); |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | /** |
@@ -610,11 +610,11 @@ discard block |
||
| 610 | 610 | public static function admin_menu() { |
| 611 | 611 | add_submenu_page( |
| 612 | 612 | 'options-general.php', |
| 613 | - esc_html__( 'Algolia Woo Indexer Settings', 'algolia-woo-indexer' ), |
|
| 614 | - esc_html__( 'Algolia Woo Indexer Settings', 'algolia-woo-indexer' ), |
|
| 613 | + esc_html__('Algolia Woo Indexer Settings', 'algolia-woo-indexer'), |
|
| 614 | + esc_html__('Algolia Woo Indexer Settings', 'algolia-woo-indexer'), |
|
| 615 | 615 | 'manage_options', |
| 616 | 616 | 'algolia-woo-indexer-settings', |
| 617 | - array( get_called_class(), 'algolia_woo_indexer_settings' ) |
|
| 617 | + array(get_called_class(), 'algolia_woo_indexer_settings') |
|
| 618 | 618 | ); |
| 619 | 619 | } |
| 620 | 620 | |
@@ -627,23 +627,23 @@ discard block |
||
| 627 | 627 | /** |
| 628 | 628 | * Verify that the user can access the settings page |
| 629 | 629 | */ |
| 630 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 631 | - wp_die( esc_html__( 'Action not allowed.', 'algolia_woo_indexer_settings' ) ); |
|
| 630 | + if ( ! current_user_can('manage_options')) { |
|
| 631 | + wp_die(esc_html__('Action not allowed.', 'algolia_woo_indexer_settings')); |
|
| 632 | 632 | } |
| 633 | 633 | ?> |
| 634 | 634 | <div class="wrap"> |
| 635 | - <h1><?php esc_html__( 'Algolia Woo Indexer Settings', 'algolia-woo-indexer' ); ?></h1> |
|
| 636 | - <form action="<?php echo esc_url( self::$plugin_url ); ?>" method="POST"> |
|
| 635 | + <h1><?php esc_html__('Algolia Woo Indexer Settings', 'algolia-woo-indexer'); ?></h1> |
|
| 636 | + <form action="<?php echo esc_url(self::$plugin_url); ?>" method="POST"> |
|
| 637 | 637 | <?php |
| 638 | - settings_fields( 'algolia_woo_options' ); |
|
| 639 | - do_settings_sections( 'algolia_woo_indexer' ); |
|
| 640 | - submit_button( '', 'primary wide' ); |
|
| 638 | + settings_fields('algolia_woo_options'); |
|
| 639 | + do_settings_sections('algolia_woo_indexer'); |
|
| 640 | + submit_button('', 'primary wide'); |
|
| 641 | 641 | ?> |
| 642 | 642 | </form> |
| 643 | - <form action="<?php echo esc_url( self::$plugin_url ); ?>" method="POST"> |
|
| 644 | - <?php wp_nonce_field( 'send_products_to_algolia_nonce_action', 'send_products_to_algolia_nonce_name' ); ?> |
|
| 643 | + <form action="<?php echo esc_url(self::$plugin_url); ?>" method="POST"> |
|
| 644 | + <?php wp_nonce_field('send_products_to_algolia_nonce_action', 'send_products_to_algolia_nonce_name'); ?> |
|
| 645 | 645 | <input type="hidden" name="send_products_to_algolia" id="send_products_to_algolia" value="true" /> |
| 646 | - <?php submit_button( esc_html__( 'Send products to Algolia', 'algolia_woo_indexer_settings' ), 'primary wide', '', false ); ?> |
|
| 646 | + <?php submit_button(esc_html__('Send products to Algolia', 'algolia_woo_indexer_settings'), 'primary wide', '', false); ?> |
|
| 647 | 647 | </form> |
| 648 | 648 | </div> |
| 649 | 649 | <?php |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | * @return object |
| 656 | 656 | */ |
| 657 | 657 | public static function get_instance() { |
| 658 | - if ( ! self::$instance ) { |
|
| 658 | + if ( ! self::$instance) { |
|
| 659 | 659 | self::$instance = new Algolia_Woo_Indexer(); |
| 660 | 660 | } |
| 661 | 661 | return self::$instance; |
@@ -671,47 +671,47 @@ discard block |
||
| 671 | 671 | /** |
| 672 | 672 | * Set default values for options if not already set |
| 673 | 673 | */ |
| 674 | - $index_in_stock = get_option( ALGOWOO_DB_OPTION . '_index_in_stock' ); |
|
| 675 | - $automatically_send_new_products = get_option( ALGOWOO_DB_OPTION . '_automatically_send_new_products' ); |
|
| 676 | - $algolia_application_id = get_option( ALGOWOO_DB_OPTION . '_application_id' ); |
|
| 677 | - $algolia_api_key = get_option( ALGOWOO_DB_OPTION . '_admin_api_key' ); |
|
| 678 | - $algolia_index_name = get_option( ALGOWOO_DB_OPTION . '_index_name' ); |
|
| 674 | + $index_in_stock = get_option(ALGOWOO_DB_OPTION . '_index_in_stock'); |
|
| 675 | + $automatically_send_new_products = get_option(ALGOWOO_DB_OPTION . '_automatically_send_new_products'); |
|
| 676 | + $algolia_application_id = get_option(ALGOWOO_DB_OPTION . '_application_id'); |
|
| 677 | + $algolia_api_key = get_option(ALGOWOO_DB_OPTION . '_admin_api_key'); |
|
| 678 | + $algolia_index_name = get_option(ALGOWOO_DB_OPTION . '_index_name'); |
|
| 679 | 679 | |
| 680 | - if ( empty( $index_in_stock ) ) { |
|
| 680 | + if (empty($index_in_stock)) { |
|
| 681 | 681 | add_option( |
| 682 | 682 | ALGOWOO_DB_OPTION . '_index_in_stock', |
| 683 | 683 | '0' |
| 684 | 684 | ); |
| 685 | 685 | } |
| 686 | 686 | |
| 687 | - if ( empty( $automatically_send_new_products ) ) { |
|
| 687 | + if (empty($automatically_send_new_products)) { |
|
| 688 | 688 | add_option( |
| 689 | 689 | ALGOWOO_DB_OPTION . '_automatically_send_new_products', |
| 690 | 690 | '0' |
| 691 | 691 | ); |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | - if ( empty( $algolia_application_id ) ) { |
|
| 694 | + if (empty($algolia_application_id)) { |
|
| 695 | 695 | add_option( |
| 696 | 696 | ALGOWOO_DB_OPTION . '_application_id', |
| 697 | 697 | 'Change me' |
| 698 | 698 | ); |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - if ( empty( $algolia_api_key ) ) { |
|
| 701 | + if (empty($algolia_api_key)) { |
|
| 702 | 702 | add_option( |
| 703 | 703 | ALGOWOO_DB_OPTION . '_admin_api_key', |
| 704 | 704 | 'Change me' |
| 705 | 705 | ); |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | - if ( empty( $algolia_index_name ) ) { |
|
| 708 | + if (empty($algolia_index_name)) { |
|
| 709 | 709 | add_option( |
| 710 | 710 | ALGOWOO_DB_OPTION . '_index_name', |
| 711 | 711 | 'Change me' |
| 712 | 712 | ); |
| 713 | 713 | } |
| 714 | - set_transient( self::PLUGIN_TRANSIENT, true ); |
|
| 714 | + set_transient(self::PLUGIN_TRANSIENT, true); |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | /** |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | * @return void |
| 721 | 721 | */ |
| 722 | 722 | public static function deactivate_plugin() { |
| 723 | - delete_transient( self::PLUGIN_TRANSIENT, true ); |
|
| 723 | + delete_transient(self::PLUGIN_TRANSIENT, true); |
|
| 724 | 724 | } |
| 725 | 725 | } |
| 726 | 726 | } |
@@ -11,17 +11,17 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * Define minimum required versions of PHP and WordPress |
| 13 | 13 | */ |
| 14 | -define( 'ALGOLIA_MIN_PHP_VERSION', '7.2' ); |
|
| 15 | -define( 'ALGOLIA_MIN_WP_VERSION', '5.4' ); |
|
| 14 | +define('ALGOLIA_MIN_PHP_VERSION', '7.2'); |
|
| 15 | +define('ALGOLIA_MIN_WP_VERSION', '5.4'); |
|
| 16 | 16 | |
| 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 | */ |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | 35 | public static function algolia_php_version_check() { |
| 36 | - if ( version_compare( PHP_VERSION, ALGOLIA_MIN_PHP_VERSION, '<' ) ) { |
|
| 36 | + if (version_compare(PHP_VERSION, ALGOLIA_MIN_PHP_VERSION, '<')) { |
|
| 37 | 37 | return false; |
| 38 | 38 | } |
| 39 | 39 | return true; |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @return bool |
| 46 | 46 | */ |
| 47 | 47 | public static function algolia_wp_version_check() { |
| 48 | - if ( version_compare( $GLOBALS['wp_version'], ALGOLIA_MIN_WP_VERSION, '<' ) ) { |
|
| 48 | + if (version_compare($GLOBALS['wp_version'], ALGOLIA_MIN_WP_VERSION, '<')) { |
|
| 49 | 49 | return false; |
| 50 | 50 | } |
| 51 | 51 | return true; |
@@ -57,18 +57,18 @@ discard block |
||
| 57 | 57 | * @return void |
| 58 | 58 | */ |
| 59 | 59 | public static function check_unmet_requirements() { |
| 60 | - if ( ! extension_loaded( 'mbstring' ) ) { |
|
| 60 | + if ( ! extension_loaded('mbstring')) { |
|
| 61 | 61 | echo '<div class="error notice"> |
| 62 | - <p>' . esc_html__( 'Algolia Woo Indexer requires the "mbstring" PHP extension to be enabled. Please contact your hosting provider.', 'algolia-woo-indexer' ) . '</p> |
|
| 62 | + <p>' . esc_html__('Algolia Woo Indexer requires the "mbstring" PHP extension to be enabled. Please contact your hosting provider.', 'algolia-woo-indexer') . '</p> |
|
| 63 | 63 | </div>'; |
| 64 | - } elseif ( ! function_exists( 'mb_ereg_replace' ) ) { |
|
| 64 | + } elseif ( ! function_exists('mb_ereg_replace')) { |
|
| 65 | 65 | echo '<div class="error notice"> |
| 66 | - <p>' . esc_html__( 'Algolia Woo Indexer needs "mbregex" NOT to be disabled. Please contact your hosting provider.', 'algolia-woo-indexer' ) . '</p> |
|
| 66 | + <p>' . esc_html__('Algolia Woo Indexer needs "mbregex" NOT to be disabled. Please contact your hosting provider.', 'algolia-woo-indexer') . '</p> |
|
| 67 | 67 | </div>'; |
| 68 | 68 | } |
| 69 | - if ( ! extension_loaded( 'curl' ) ) { |
|
| 69 | + if ( ! extension_loaded('curl')) { |
|
| 70 | 70 | echo '<div class="error notice"> |
| 71 | - <p>' . esc_html__( 'Algolia Woo Indexer requires the "cURL" PHP extension to be enabled. Please contact your hosting provider.', 'algolia-woo-indexer' ) . '</p> |
|
| 71 | + <p>' . esc_html__('Algolia Woo Indexer requires the "cURL" PHP extension to be enabled. Please contact your hosting provider.', 'algolia-woo-indexer') . '</p> |
|
| 72 | 72 | </div>'; |
| 73 | 73 | return; |
| 74 | 74 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @return boolean |
| 81 | 81 | */ |
| 82 | 82 | public static function is_woocommerce_plugin_active() { |
| 83 | - return in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ); |
|
| 83 | + return in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')), true); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -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 ) && ! isset( $send_products_nonce ) ) { |
|
| 37 | + if ( ! isset($settings_nonce) && ! isset($send_products_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 | } |
@@ -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')); |
|