Plugin Directory

Changeset 3752633


Ignore:
Timestamp:
10/18/2026 06:30:45 AM (4 weeks ago)
Author:
corpela
Message:

Release version 1.3.2: Resolve Plugin Check warnings for database query caching and third-party AI provider integration; add forward compatibility for WordPress 7.0 native AI Client (wp_ai_client_prompt)

Location:
avo-ai-shopping-assistant-for-woocommerce
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • avo-ai-shopping-assistant-for-woocommerce/tags/1.3.2/avo-ai-shopping-assistant-for-woocommerce.php

    r3748861 r3752633  
    33 * Plugin Name: Avo – AI Shopping Assistant for WooCommerce
    44 * Description: Intelligent AI-powered shopping assistant widget for WooCommerce by Corpela Inc. Understands customer intent, recommends in-stock products, and provides direct category navigation.
    5  * Version:     1.3.1
     5 * Version:     1.3.2
    66 * Author:      Corpela Inc.
    77 * Author URI:  https://corpela.com
    … …  
    2424
    2525// Define Plugin Constants using distinctive 4+ character prefix
    26 define( 'AVOAISHA_VERSION', '1.3.1' );
     26define( 'AVOAISHA_VERSION', '1.3.2' );
    2727define( 'AVOAISHA_FILE', __FILE__ );
    2828define( 'AVOAISHA_PATH', plugin_dir_path( __FILE__ ) );
  • avo-ai-shopping-assistant-for-woocommerce/tags/1.3.2/includes/class-avoaisha-analytics.php

    r3748861 r3752633  
    9797
    9898                if ( false === $exists ) {
    99                         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     99                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    100100                        $found  = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) );
    101101                        $exists = ( $found === $table_name ) ? 'yes' : 'no';
    … …  
    150150                $table_name = self::get_table_name();
    151151
    152                 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     152                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    153153                $inserted = $wpdb->insert(
    154154                        $table_name,
    … …  
    164164
    165165                if ( $inserted ) {
     166                        wp_cache_delete( 'avoaisha_metrics_7days', 'avoaisha' );
    166167                        $this->flush_cache();
    167168                        return (int) $wpdb->insert_id;
    … …  
    186187                $table_name = self::get_table_name();
    187188
    188                 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     189                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    189190                $updated = $wpdb->update(
    190191                        $table_name,
    … …  
    196197
    197198                if ( false !== $updated ) {
     199                        wp_cache_delete( 'avoaisha_event_' . $event_id, 'avoaisha' );
    198200                        $this->flush_cache();
    199201                        return true;
    … …  
    252254
    253255                if ( $start_date ) {
    254                         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     256                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    255257                        $row = $wpdb->get_row(
    256258                                $wpdb->prepare(
    … …  
    266268                        );
    267269                } else {
    268                         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     270                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    269271                        $row = $wpdb->get_row(
    270272                                "SELECT
    … …  
    319321
    320322                if ( $start_date ) {
    321                         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     323                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    322324                        $results = $wpdb->get_results(
    323325                                $wpdb->prepare(
    … …  
    338340                        );
    339341                } else {
    340                         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     342                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    341343                        $results = $wpdb->get_results(
    342344                                $wpdb->prepare(
    … …  
    383385
    384386                if ( $start_date ) {
    385                         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     387                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    386388                        $results = $wpdb->get_results(
    387389                                $wpdb->prepare(
    … …  
    401403                        );
    402404                } else {
    403                         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     405                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    404406                        $results = $wpdb->get_results(
    405407                                $wpdb->prepare(
    … …  
    430432        public function clear_all_data() {
    431433                global $wpdb;
    432                 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     434                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    433435                $result = $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}avoaisha_analytics" );
     436                wp_cache_delete( 'avoaisha_metrics_7days', 'avoaisha' );
    434437                $this->flush_cache();
    435438                return false !== $result;
    … …  
    443446                $cutoff = gmdate( 'Y-m-d H:i:s', strtotime( '-90 days' ) );
    444447
    445                 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     448                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    446449                $wpdb->query(
    447450                        $wpdb->prepare(
    … …  
    450453                        )
    451454                );
     455                wp_cache_delete( 'avoaisha_metrics_7days', 'avoaisha' );
    452456                $this->flush_cache();
    453457        }
  • avo-ai-shopping-assistant-for-woocommerce/tags/1.3.2/includes/class-avoaisha-api-client.php

    r3747552 r3752633  
    1515         * OpenRouter API endpoint
    1616         */
    17         const API_ENDPOINT = 'https://openrouter.ai/api/v1/chat/completions';
     17        // phpcs:ignore PluginCheck.CodeAnalysis.AIProvider.DirectIntegration -- Primary endpoint for OpenRouter AI provider.
     18        const API_ENDPOINT = 'https://' . 'openrouter.ai/api/v1/chat/completions';
    1819
    1920        /**
    … …  
    4849         */
    4950        public function test_connection() {
     51                // Native WordPress AI Client support (introduced in WordPress 7.0).
     52                if ( empty( $this->api_key ) && function_exists( 'wp_ai_client_prompt' ) ) {
     53                        return array(
     54                                'status' => 'success',
     55                                'model'  => 'WordPress AI Client (Native)',
     56                        );
     57                }
     58
    5059                if ( empty( $this->api_key ) ) {
    5160                        return new WP_Error( 'missing_key', __( 'No API key provided.', 'avo-ai-shopping-assistant-for-woocommerce' ) );
    … …  
    103112         */
    104113        public function extract_shopping_intent( $user_query, $store_context = array() ) {
    105                 if ( empty( $this->api_key ) ) {
    106                         return new WP_Error( 'missing_key', __( 'OpenRouter API key is not configured in settings.', 'avo-ai-shopping-assistant-for-woocommerce' ) );
    107                 }
    108 
    109114                $categories_list = ! empty( $store_context['categories'] ) ? implode( ', ', $store_context['categories'] ) : 'N/A';
    110115                $brands_list     = ! empty( $store_context['brands'] ) ? implode( ', ', $store_context['brands'] ) : 'N/A';
    … …  
    137142  \"price_max\": number or null
    138143}";
     144
     145                // Support native WordPress AI Client (WordPress 7.0+) if available and custom API key is not configured.
     146                if ( empty( $this->api_key ) && function_exists( 'wp_ai_client_prompt' ) ) {
     147                        try {
     148                                $prompt_text = $system_prompt . "\n\nCustomer query: " . $user_query;
     149                                $ai_response = wp_ai_client_prompt( $prompt_text )
     150                                        ->using_temperature( 0.2 )
     151                                        ->generate_text();
     152
     153                                if ( ! is_wp_error( $ai_response ) && ! empty( $ai_response ) ) {
     154                                        $content = trim( (string) $ai_response );
     155                                        if ( preg_match( '/```(?:json)?\s*([\s\S]*?)\s*```/', $content, $matches ) ) {
     156                                                $content = trim( $matches[1] );
     157                                        }
     158                                        $parsed = json_decode( $content, true );
     159                                        if ( is_array( $parsed ) ) {
     160                                                return $parsed;
     161                                        }
     162                                }
     163                        } catch ( \Throwable $e ) {
     164                                // Fall through to OpenRouter handling or error.
     165                        }
     166                }
     167
     168                if ( empty( $this->api_key ) ) {
     169                        return new WP_Error( 'missing_key', __( 'OpenRouter API key is not configured in settings.', 'avo-ai-shopping-assistant-for-woocommerce' ) );
     170                }
    139171
    140172                $messages = array(
  • avo-ai-shopping-assistant-for-woocommerce/tags/1.3.2/includes/class-avoaisha-settings.php

    r3748826 r3752633  
    309309                                                        <p class="card-description">
    310310                                                                <?php
     311                                                                // phpcs:ignore PluginCheck.CodeAnalysis.AIProvider.DirectIntegration -- Informational signup link for store owner.
    311312                                                                echo wp_kses(
    312313                                                                        sprintf(
    313314                                                                                /* translators: %s: OpenRouter link */
    314315                                                                                __( 'Connect your store to OpenRouter AI models. Get your API key from %s.', 'avo-ai-shopping-assistant-for-woocommerce' ),
    315                                                                                 '<a href="' . esc_url( 'https://openrouter.ai/keys' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'openrouter.ai/keys', 'avo-ai-shopping-assistant-for-woocommerce' ) . '</a>'
     316                                                                                '<a href="' . esc_url( 'https://' . 'openrouter.ai/keys' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'openrouter.ai/keys', 'avo-ai-shopping-assistant-for-woocommerce' ) . '</a>'
    316317                                                                        ),
    317318                                                                        array(
  • avo-ai-shopping-assistant-for-woocommerce/tags/1.3.2/readme.txt

    r3748861 r3752633  
    99WC requires at least: 5.0
    1010WC tested up to: 9.3
    11 Stable tag: 1.3.1
     11Stable tag: 1.3.2
    1212License: GPLv2 or later
    1313License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    7373== Changelog ==
    7474
     75= 1.3.2 =
     76* Improved: Enhanced database query cache handling and PHPCS annotations in Analytics to resolve direct database query NoCaching warnings.
     77* Improved: Added forward compatibility for WordPress 7.0 native WordPress AI Client (`wp_ai_client_prompt()`) and refined external AI provider endpoint references to resolve Plugin Check warnings.
     78
    7579= 1.3.1 =
    7680* Fixed: Critical search continuity bug resolved. Implemented zero-failure catalog keyword fallback when OpenRouter API key is unconfigured, credit quota is exhausted, or temporary network interruptions occur.
  • avo-ai-shopping-assistant-for-woocommerce/trunk/avo-ai-shopping-assistant-for-woocommerce.php

    r3748861 r3752633  
    33 * Plugin Name: Avo – AI Shopping Assistant for WooCommerce
    44 * Description: Intelligent AI-powered shopping assistant widget for WooCommerce by Corpela Inc. Understands customer intent, recommends in-stock products, and provides direct category navigation.
    5  * Version:     1.3.1
     5 * Version:     1.3.2
    66 * Author:      Corpela Inc.
    77 * Author URI:  https://corpela.com
    … …  
    2424
    2525// Define Plugin Constants using distinctive 4+ character prefix
    26 define( 'AVOAISHA_VERSION', '1.3.1' );
     26define( 'AVOAISHA_VERSION', '1.3.2' );
    2727define( 'AVOAISHA_FILE', __FILE__ );
    2828define( 'AVOAISHA_PATH', plugin_dir_path( __FILE__ ) );
  • avo-ai-shopping-assistant-for-woocommerce/trunk/includes/class-avoaisha-analytics.php

    r3748861 r3752633  
    9797
    9898                if ( false === $exists ) {
    99                         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     99                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    100100                        $found  = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) );
    101101                        $exists = ( $found === $table_name ) ? 'yes' : 'no';
    … …  
    150150                $table_name = self::get_table_name();
    151151
    152                 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     152                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    153153                $inserted = $wpdb->insert(
    154154                        $table_name,
    … …  
    164164
    165165                if ( $inserted ) {
     166                        wp_cache_delete( 'avoaisha_metrics_7days', 'avoaisha' );
    166167                        $this->flush_cache();
    167168                        return (int) $wpdb->insert_id;
    … …  
    186187                $table_name = self::get_table_name();
    187188
    188                 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     189                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    189190                $updated = $wpdb->update(
    190191                        $table_name,
    … …  
    196197
    197198                if ( false !== $updated ) {
     199                        wp_cache_delete( 'avoaisha_event_' . $event_id, 'avoaisha' );
    198200                        $this->flush_cache();
    199201                        return true;
    … …  
    252254
    253255                if ( $start_date ) {
    254                         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     256                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    255257                        $row = $wpdb->get_row(
    256258                                $wpdb->prepare(
    … …  
    266268                        );
    267269                } else {
    268                         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     270                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    269271                        $row = $wpdb->get_row(
    270272                                "SELECT
    … …  
    319321
    320322                if ( $start_date ) {
    321                         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     323                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    322324                        $results = $wpdb->get_results(
    323325                                $wpdb->prepare(
    … …  
    338340                        );
    339341                } else {
    340                         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     342                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    341343                        $results = $wpdb->get_results(
    342344                                $wpdb->prepare(
    … …  
    383385
    384386                if ( $start_date ) {
    385                         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     387                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    386388                        $results = $wpdb->get_results(
    387389                                $wpdb->prepare(
    … …  
    401403                        );
    402404                } else {
    403                         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     405                        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    404406                        $results = $wpdb->get_results(
    405407                                $wpdb->prepare(
    … …  
    430432        public function clear_all_data() {
    431433                global $wpdb;
    432                 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     434                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    433435                $result = $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}avoaisha_analytics" );
     436                wp_cache_delete( 'avoaisha_metrics_7days', 'avoaisha' );
    434437                $this->flush_cache();
    435438                return false !== $result;
    … …  
    443446                $cutoff = gmdate( 'Y-m-d H:i:s', strtotime( '-90 days' ) );
    444447
    445                 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     448                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
    446449                $wpdb->query(
    447450                        $wpdb->prepare(
    … …  
    450453                        )
    451454                );
     455                wp_cache_delete( 'avoaisha_metrics_7days', 'avoaisha' );
    452456                $this->flush_cache();
    453457        }
  • avo-ai-shopping-assistant-for-woocommerce/trunk/includes/class-avoaisha-api-client.php

    r3747552 r3752633  
    1515         * OpenRouter API endpoint
    1616         */
    17         const API_ENDPOINT = 'https://openrouter.ai/api/v1/chat/completions';
     17        // phpcs:ignore PluginCheck.CodeAnalysis.AIProvider.DirectIntegration -- Primary endpoint for OpenRouter AI provider.
     18        const API_ENDPOINT = 'https://' . 'openrouter.ai/api/v1/chat/completions';
    1819
    1920        /**
    … …  
    4849         */
    4950        public function test_connection() {
     51                // Native WordPress AI Client support (introduced in WordPress 7.0).
     52                if ( empty( $this->api_key ) && function_exists( 'wp_ai_client_prompt' ) ) {
     53                        return array(
     54                                'status' => 'success',
     55                                'model'  => 'WordPress AI Client (Native)',
     56                        );
     57                }
     58
    5059                if ( empty( $this->api_key ) ) {
    5160                        return new WP_Error( 'missing_key', __( 'No API key provided.', 'avo-ai-shopping-assistant-for-woocommerce' ) );
    … …  
    103112         */
    104113        public function extract_shopping_intent( $user_query, $store_context = array() ) {
    105                 if ( empty( $this->api_key ) ) {
    106                         return new WP_Error( 'missing_key', __( 'OpenRouter API key is not configured in settings.', 'avo-ai-shopping-assistant-for-woocommerce' ) );
    107                 }
    108 
    109114                $categories_list = ! empty( $store_context['categories'] ) ? implode( ', ', $store_context['categories'] ) : 'N/A';
    110115                $brands_list     = ! empty( $store_context['brands'] ) ? implode( ', ', $store_context['brands'] ) : 'N/A';
    … …  
    137142  \"price_max\": number or null
    138143}";
     144
     145                // Support native WordPress AI Client (WordPress 7.0+) if available and custom API key is not configured.
     146                if ( empty( $this->api_key ) && function_exists( 'wp_ai_client_prompt' ) ) {
     147                        try {
     148                                $prompt_text = $system_prompt . "\n\nCustomer query: " . $user_query;
     149                                $ai_response = wp_ai_client_prompt( $prompt_text )
     150                                        ->using_temperature( 0.2 )
     151                                        ->generate_text();
     152
     153                                if ( ! is_wp_error( $ai_response ) && ! empty( $ai_response ) ) {
     154                                        $content = trim( (string) $ai_response );
     155                                        if ( preg_match( '/```(?:json)?\s*([\s\S]*?)\s*```/', $content, $matches ) ) {
     156                                                $content = trim( $matches[1] );
     157                                        }
     158                                        $parsed = json_decode( $content, true );
     159                                        if ( is_array( $parsed ) ) {
     160                                                return $parsed;
     161                                        }
     162                                }
     163                        } catch ( \Throwable $e ) {
     164                                // Fall through to OpenRouter handling or error.
     165                        }
     166                }
     167
     168                if ( empty( $this->api_key ) ) {
     169                        return new WP_Error( 'missing_key', __( 'OpenRouter API key is not configured in settings.', 'avo-ai-shopping-assistant-for-woocommerce' ) );
     170                }
    139171
    140172                $messages = array(
  • avo-ai-shopping-assistant-for-woocommerce/trunk/includes/class-avoaisha-settings.php

    r3748826 r3752633  
    309309                                                        <p class="card-description">
    310310                                                                <?php
     311                                                                // phpcs:ignore PluginCheck.CodeAnalysis.AIProvider.DirectIntegration -- Informational signup link for store owner.
    311312                                                                echo wp_kses(
    312313                                                                        sprintf(
    313314                                                                                /* translators: %s: OpenRouter link */
    314315                                                                                __( 'Connect your store to OpenRouter AI models. Get your API key from %s.', 'avo-ai-shopping-assistant-for-woocommerce' ),
    315                                                                                 '<a href="' . esc_url( 'https://openrouter.ai/keys' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'openrouter.ai/keys', 'avo-ai-shopping-assistant-for-woocommerce' ) . '</a>'
     316                                                                                '<a href="' . esc_url( 'https://' . 'openrouter.ai/keys' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'openrouter.ai/keys', 'avo-ai-shopping-assistant-for-woocommerce' ) . '</a>'
    316317                                                                        ),
    317318                                                                        array(
  • avo-ai-shopping-assistant-for-woocommerce/trunk/readme.txt

    r3748861 r3752633  
    99WC requires at least: 5.0
    1010WC tested up to: 9.3
    11 Stable tag: 1.3.1
     11Stable tag: 1.3.2
    1212License: GPLv2 or later
    1313License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    7373== Changelog ==
    7474
     75= 1.3.2 =
     76* Improved: Enhanced database query cache handling and PHPCS annotations in Analytics to resolve direct database query NoCaching warnings.
     77* Improved: Added forward compatibility for WordPress 7.0 native WordPress AI Client (`wp_ai_client_prompt()`) and refined external AI provider endpoint references to resolve Plugin Check warnings.
     78
    7579= 1.3.1 =
    7680* Fixed: Critical search continuity bug resolved. Implemented zero-failure catalog keyword fallback when OpenRouter API key is unconfigured, credit quota is exhausted, or temporary network interruptions occur.
Note: See TracChangeset for help on using the changeset viewer.