Plugin Directory

Changeset 2931821


Ignore:
Timestamp:
06/28/2023 12:13:11 PM (3 years ago)
Author:
kalyx
Message:

init v1.1.1

Location:
nuclia-search-for-wp/trunk
Files:
3 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • nuclia-search-for-wp/trunk/README.txt

    r2931719 r2931821  
    55Tested up to: 6.2.2
    66Requires PHP: 7.2
    7 Stable tag: 1.1.0
     7Stable tag: 1.1.1
    88License: GNU General Public License v2.0, MIT License
    99
     
    6767== Changelog ==
    6868
     69= 1.1.1 =
     70* Fix : Error notices when saving credentials
     71
    6972= 1.1.0 =
    7073* 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  
    217217        $setting       = $settings->get_token();
    218218        ?>
    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" />
    220220<p class="description" id="home-description">
    221221  <?php esc_html_e( 'Your Nuclia Service Access token with Contributor access (kept private).', 'klx-nuclia-search-for-wp' ); ?>
     
    233233        $setting       = $settings->get_kbid();
    234234        ?>
    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" />
    236236<p class="description" id="home-description">
    237237  <?php esc_html_e( 'Your Nuclia Knowledge box UID (must be public).', 'klx-nuclia-search-for-wp' ); ?>
     
    370370        return $count;
    371371    }
    372    
    373        
    374     /**
    375      * Sanitize zone.
     372
     373
     374    /**
     375     * Sanitize Knowledge box UID.
    376376     *
    377377     * @since  1.0.0
     
    381381     * @return string
    382382     */
    383     public function sanitize_zone( $value ) {
     383    public function sanitize_kbid( $value ) {
    384384
    385385        $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();
    435388
    436389        if ( empty( $value ) ) {
     
    440393                esc_html__( 'Knowledge box UID should not be empty.', 'klx-nuclia-search-for-wp' )
    441394            );
     395            $settings->set_api_is_reachable( false );
    442396            return $value;
    443397        }
    444398
    445         $settings = $this->plugin->get_settings();
    446399
    447400        $valid_credentials = true;
    448401        try {
    449             $this->is_valid_credentials( $settings->get_zone(), $settings->get_kbid() );
     402            $this->is_valid_credentials( $settings->get_zone(), $value );
    450403        } catch ( Exception $exception ) {
    451404            $valid_credentials = false;
     
    467420            );
    468421            $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 );
    469489        } 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 );
    489497        }
    490 
     498       
    491499        return $value;
    492500    }
     
    555563        $response_code  = wp_remote_retrieve_response_code( $response );
    556564        if( $response_code === 200 ) {
    557             return;
     565            return true;
    558566        } elseif( $response_code === 422 ) {
    559567            throw new Exception(
  • nuclia-search-for-wp/trunk/includes/admin/js/reindex-button.js

    r2931724 r2931821  
    11(function($) {
    2 
     2   
    33    $(
    44        function() {
  • nuclia-search-for-wp/trunk/includes/nuclia-searchbox-shortcode.php

    r2931719 r2931821  
    2222        'features' => 'navigateToLink'
    2323    ), $atts));
    24     nuclia_log( 'shortcode atts : '.$zone.' - '.$kbid.' - '.$features );
     24
    2525    // we need zone and kbid to display searchbox
    2626    if ( empty($zone) || empty($kbid) ) :
  • nuclia-search-for-wp/trunk/nuclia.php

    r2931719 r2931821  
    44 * Plugin URI:        https://github.com/kalyx/nuclia-search-for-wp
    55 * Description:       Integrate the powerful Nuclia search service with WordPress
    6  * Version:           1.1.0
     6 * Version:           1.1.1
    77 * Requires at least: 5.6
    88 * Requires PHP:      7.2
Note: See TracChangeset for help on using the changeset viewer.