Changeset 2931821
- Timestamp:
- 06/28/2023 12:13:11 PM (3 years ago)
- Location:
- nuclia-search-for-wp/trunk
- Files:
-
- 3 deleted
- 5 edited
-
README.txt (modified) (2 diffs)
-
includes/admin/class-nuclia-admin-page-settings.php (modified) (7 diffs)
-
includes/admin/js/reindex-button.js (modified) (1 diff)
-
includes/nuclia-searchbox-shortcode.php (modified) (1 diff)
-
languages/wp-search-with-nuclia-fr_FR.mo (deleted)
-
languages/wp-search-with-nuclia-fr_FR.po (deleted)
-
languages/wp-search-with-nuclia.pot (deleted)
-
nuclia.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
nuclia-search-for-wp/trunk/README.txt
r2931719 r2931821 5 5 Tested up to: 6.2.2 6 6 Requires PHP: 7.2 7 Stable tag: 1.1. 07 Stable tag: 1.1.1 8 8 License: GNU General Public License v2.0, MIT License 9 9 … … 67 67 == Changelog == 68 68 69 = 1.1.1 = 70 * Fix : Error notices when saving credentials 71 69 72 = 1.1.0 = 70 73 * Enhancement: Added a button for each post types in the settings page to index all unindexed posts ( or attachment ) -
nuclia-search-for-wp/trunk/includes/admin/class-nuclia-admin-page-settings.php
r2931719 r2931821 217 217 $setting = $settings->get_token(); 218 218 ?> 219 <input type="password" name="nuclia_token" class="regular-text" value="<?php echo esc_attr( $setting ); ?>" />219 <input type="password" name="nuclia_token" class="regular-text" value="<?php echo esc_attr( $setting ); ?>" autocomplete="new-password" /> 220 220 <p class="description" id="home-description"> 221 221 <?php esc_html_e( 'Your Nuclia Service Access token with Contributor access (kept private).', 'klx-nuclia-search-for-wp' ); ?> … … 233 233 $setting = $settings->get_kbid(); 234 234 ?> 235 <input type="text" name="nuclia_kbid" class="regular-text" value="<?php echo esc_attr( $setting ); ?>" />235 <input type="text" name="nuclia_kbid" class="regular-text" value="<?php echo esc_attr( $setting ); ?>" autocomplete="off" /> 236 236 <p class="description" id="home-description"> 237 237 <?php esc_html_e( 'Your Nuclia Knowledge box UID (must be public).', 'klx-nuclia-search-for-wp' ); ?> … … 370 370 return $count; 371 371 } 372 373 374 /** 375 * Sanitize zone.372 373 374 /** 375 * Sanitize Knowledge box UID. 376 376 * 377 377 * @since 1.0.0 … … 381 381 * @return string 382 382 */ 383 public function sanitize_ zone( $value ) {383 public function sanitize_kbid( $value ) { 384 384 385 385 $value = sanitize_text_field( $value ); 386 387 if ( empty( $value ) ) { 388 add_settings_error( 389 'nuclia_settings', 390 'empty', 391 esc_html__( 'Zone should not be empty.', 'klx-nuclia-search-for-wp' ) 392 ); 393 394 } 395 396 return $value; 397 } 398 399 /** 400 * Sanitize Service Access token. 401 * 402 * @since 1.0.0 403 * 404 * @param string $value The value to sanitize. 405 * 406 * @return string 407 */ 408 public function sanitize_token( $value ) { 409 410 $value = sanitize_text_field( $value ); 411 412 if ( empty( $value ) ) { 413 add_settings_error( 414 'nuclia_settings', 415 'empty', 416 esc_html__( 'Service Access token should not be empty.', 'klx-nuclia-search-for-wp' ) 417 ); 418 } 419 420 return $value; 421 } 422 423 /** 424 * Sanitize Knowledge box UID. 425 * 426 * @since 1.0.0 427 * 428 * @param string $value The value to sanitize. 429 * 430 * @return string 431 */ 432 public function sanitize_kbid( $value ) { 433 434 $value = sanitize_text_field( $value ); 386 387 $settings = $this->plugin->get_settings(); 435 388 436 389 if ( empty( $value ) ) { … … 440 393 esc_html__( 'Knowledge box UID should not be empty.', 'klx-nuclia-search-for-wp' ) 441 394 ); 395 $settings->set_api_is_reachable( false ); 442 396 return $value; 443 397 } 444 398 445 $settings = $this->plugin->get_settings();446 399 447 400 $valid_credentials = true; 448 401 try { 449 $this->is_valid_credentials( $settings->get_zone(), $ settings->get_kbid());402 $this->is_valid_credentials( $settings->get_zone(), $value ); 450 403 } catch ( Exception $exception ) { 451 404 $valid_credentials = false; … … 467 420 ); 468 421 $settings->set_api_is_reachable( false ); 422 }; 423 424 return $value; 425 } 426 427 /** 428 * Sanitize zone. 429 * 430 * @since 1.0.0 431 * 432 * @param string $value The value to sanitize. 433 * 434 * @return string 435 */ 436 public function sanitize_zone( $value ) { 437 438 $value = sanitize_text_field( $value ); 439 440 if ( empty( $value ) ) { 441 add_settings_error( 442 'nuclia_settings', 443 'empty', 444 esc_html__( 'Zone should not be empty.', 'klx-nuclia-search-for-wp' ) 445 ); 446 $settings = $this->plugin->get_settings(); 447 $settings->set_api_is_reachable( false ); 448 } 449 450 return $value; 451 } 452 453 /** 454 * Sanitize Service Access token. 455 * 456 * @since 1.0.0 457 * 458 * @param string $value The value to sanitize. 459 * 460 * @return string 461 */ 462 public function sanitize_token( $value ) { 463 464 $value = sanitize_text_field( $value ); 465 466 $settings = $this->plugin->get_settings(); 467 468 if ( empty( $value ) ) { 469 add_settings_error( 470 'nuclia_settings', 471 'empty', 472 esc_html__( 'Service Access token should not be empty.', 'klx-nuclia-search-for-wp' ) 473 ); 474 $settings->set_api_is_reachable( false ); 475 return $value; 476 } 477 478 479 if ( ! $this->is_valid_token( $settings->get_zone(), $settings->get_kbid(), $value ) ) { 480 add_settings_error( 481 'nuclia_settings', 482 'wrong_token', 483 esc_html__( 484 'It looks like your token is wrong.', 485 'klx-nuclia-search-for-wp' 486 ) 487 ); 488 $settings->set_api_is_reachable( false ); 469 489 } else { 470 if ( ! $this->is_valid_token( $settings->get_zone(), $settings->get_kbid(), $settings->get_token() ) ) { 471 add_settings_error( 472 'nuclia_settings', 473 'wrong_token', 474 esc_html__( 475 'It looks like your token is wrong.', 476 'klx-nuclia-search-for-wp' 477 ) 478 ); 479 $settings->set_api_is_reachable( false ); 480 } else { 481 add_settings_error( 482 'nuclia_settings', 483 'connection_success', 484 esc_html__( 'We succesfully managed to connect to the Nuclia servers with the provided information.', 'klx-nuclia-search-for-wp' ), 485 'updated' 486 ); 487 $settings->set_api_is_reachable( true ); 488 } 490 add_settings_error( 491 'nuclia_settings', 492 'connection_success', 493 esc_html__( 'We succesfully managed to connect to the Nuclia servers with the provided information.', 'klx-nuclia-search-for-wp' ), 494 'updated' 495 ); 496 $settings->set_api_is_reachable( true ); 489 497 } 490 498 491 499 return $value; 492 500 } … … 555 563 $response_code = wp_remote_retrieve_response_code( $response ); 556 564 if( $response_code === 200 ) { 557 return ;565 return true; 558 566 } elseif( $response_code === 422 ) { 559 567 throw new Exception( -
nuclia-search-for-wp/trunk/includes/admin/js/reindex-button.js
r2931724 r2931821 1 1 (function($) { 2 2 3 3 $( 4 4 function() { -
nuclia-search-for-wp/trunk/includes/nuclia-searchbox-shortcode.php
r2931719 r2931821 22 22 'features' => 'navigateToLink' 23 23 ), $atts)); 24 nuclia_log( 'shortcode atts : '.$zone.' - '.$kbid.' - '.$features ); 24 25 25 // we need zone and kbid to display searchbox 26 26 if ( empty($zone) || empty($kbid) ) : -
nuclia-search-for-wp/trunk/nuclia.php
r2931719 r2931821 4 4 * Plugin URI: https://github.com/kalyx/nuclia-search-for-wp 5 5 * Description: Integrate the powerful Nuclia search service with WordPress 6 * Version: 1.1. 06 * Version: 1.1.1 7 7 * Requires at least: 5.6 8 8 * Requires PHP: 7.2
Note: See TracChangeset
for help on using the changeset viewer.