Plugin Directory

Changeset 3771549


Ignore:
Timestamp:
10/28/2026 08:20:04 PM (3 days ago)
Author:
szbtechs
Message:

Release 1.2.4

Location:
szbtechs-ai-blog-writer
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • szbtechs-ai-blog-writer/tags/1.2.4/includes/class-admin.php

    r3770993 r3771549  
    7373                $history    = WBBA_Queue::history();
    7474                // Extensions that supply their own AI provider report readiness here.
    75                 $core_ready = ( 'wordpress' === $settings['ai_source'] && WBBA_Provider_WordPress_AI::available() ) || trim( (string) $settings['groq_api_key'] ) !== '';
     75                $core_ready = ( 'groq' !== $settings['ai_source'] && WBBA_Provider_WordPress_AI::ready() ) || trim( (string) $settings['groq_api_key'] ) !== '';
    7676                $has_key    = (bool) wbba_apply_filters( 'wbba_ai_ready', $core_ready, $settings );
    7777
    … …  
    335335                                                <th>Write articles with</th>
    336336                                                <td>
    337                                                         <label><input type="radio" name="wbba[ai_source]" value="wordpress" <?php checked( $s['ai_source'], 'wordpress' ); ?> <?php disabled( ! WBBA_Provider_WordPress_AI::available() ); ?> /> WordPress AI (recommended) — the AI provider connected in WordPress itself (WordPress 7.0+)</label><br />
    338                                                         <label><input type="radio" name="wbba[ai_source]" value="groq" <?php checked( $s['ai_source'], 'groq' ); ?> /> Groq — with your own API key (below), for sites without WordPress AI</label>
    339                                                         <?php if ( ! WBBA_Provider_WordPress_AI::available() ) : ?>
    340                                                                 <p class="description">WordPress AI is not available on this site (needs WordPress 7.0+ with an AI provider connected), so Groq is used.</p>
    341                                                         <?php endif; ?>
     337                                                        <?php $wbba_wp_ai_ready = WBBA_Provider_WordPress_AI::ready(); ?>
     338                                                        <label><input type="radio" name="wbba[ai_source]" value="auto" <?php checked( $s['ai_source'], 'auto' ); ?> /> Automatic (recommended) — WordPress AI when a provider is connected, otherwise Groq</label><br />
     339                                                        <label><input type="radio" name="wbba[ai_source]" value="wordpress" <?php checked( $s['ai_source'], 'wordpress' ); ?> <?php disabled( ! WBBA_Provider_WordPress_AI::available() ); ?> /> WordPress AI — the AI provider connected in WordPress itself (WordPress 7.0+)</label><br />
     340                                                        <label><input type="radio" name="wbba[ai_source]" value="groq" <?php checked( $s['ai_source'], 'groq' ); ?> /> Groq — with your own API key (below)</label>
     341                                                        <p class="description">
     342                                                                <?php if ( $wbba_wp_ai_ready ) : ?>
     343                                                                        WordPress AI: ready — a connected provider can write text.
     344                                                                <?php elseif ( WBBA_Provider_WordPress_AI::available() ) : ?>
     345                                                                        WordPress AI: no provider that can write text is connected yet (connect one under <a href="<?php echo esc_url( admin_url( 'options-general.php' ) ); ?>">Settings → AI</a>). Until then Groq is used<?php echo trim( (string) $s['groq_api_key'] ) === '' ? ' — add a Groq API key below' : ''; ?>.
     346                                                                <?php else : ?>
     347                                                                        WordPress AI is not available on this site (it needs WordPress 7.0+), so Groq is used.
     348                                                                <?php endif; ?>
     349                                                        </p>
    342350                                                </td>
    343351                                        </tr>
    … …  
    645653                wbba_do_action( 'wbba_settings_saved', $clean );
    646654                delete_option( 'wbba_setup_pending' );
     655                delete_transient( 'wbba_wp_ai_ready' ); // Re-check WordPress AI on the next page load.
    647656                $this->redirect( 'wbba-settings', 'saved' );
    648657        }
    … …  
    659668                $clean['groq_api_key']      = isset( $posted['groq_api_key'] ) ? sanitize_text_field( trim( (string) $posted['groq_api_key'] ) ) : '';
    660669                $clean['groq_model']        = isset( $posted['groq_model'] ) ? sanitize_text_field( $posted['groq_model'] ) : WBBA_Settings::DEFAULT_GROQ_MODEL;
    661                 $clean['ai_source']         = ( isset( $posted['ai_source'] ) && 'wordpress' === $posted['ai_source'] ) ? 'wordpress' : 'groq';
     670                $clean['ai_source']         = isset( $posted['ai_source'] ) && in_array( $posted['ai_source'], array( 'auto', 'wordpress', 'groq' ), true ) ? $posted['ai_source'] : 'auto';
    662671                $clean['min_words']         = isset( $posted['min_words'] ) ? max( 600, min( 3000, (int) $posted['min_words'] ) ) : 1000;
    663672                $clean['max_words']         = isset( $posted['max_words'] ) ? max( 800, min( 4000, (int) $posted['max_words'] ) ) : 1200;
  • szbtechs-ai-blog-writer/tags/1.2.4/includes/class-llm.php

    r3770993 r3771549  
    115115        }
    116116
     117        /**
     118         * True when the AI Client exists AND a connected provider can generate text.
     119         * Cached for ten minutes: connecting a provider in Settings → AI takes effect shortly after.
     120         */
     121        public static function ready() {
     122                static $ready = null;
     123                if ( null !== $ready ) {
     124                        return $ready;
     125                }
     126                if ( ! self::available() ) {
     127                        return $ready = false;
     128                }
     129                $cached = get_transient( 'wbba_wp_ai_ready' );
     130                if ( false !== $cached ) {
     131                        return $ready = ( 'yes' === $cached );
     132                }
     133                try {
     134                        $ready = (bool) wp_ai_client_prompt( 'ping' )->is_supported_for_text_generation();
     135                } catch ( Throwable $e ) {
     136                        $ready = false;
     137                }
     138                set_transient( 'wbba_wp_ai_ready', $ready ? 'yes' : 'no', 10 * MINUTE_IN_SECONDS );
     139                return $ready;
     140        }
     141
    117142        public function chat( array $messages, array $opts = array() ) {
    118143                if ( ! self::available() ) {
    … …  
    192217                        return $provider;
    193218                }
    194                 if ( 'wordpress' === WBBA_Settings::get( 'ai_source', 'groq' ) && WBBA_Provider_WordPress_AI::available() ) {
     219                if ( self::uses_wordpress_ai() ) {
    195220                        return new WBBA_Provider_WordPress_AI();
    196221                }
    … …  
    201226                $groq->sleeper     = $this->sleeper;
    202227                return $groq;
     228        }
     229
     230        /**
     231         * Which AI writes the articles:
     232         *  - auto (default): WordPress AI when a text-capable provider is connected, otherwise Groq;
     233         *  - wordpress: WordPress AI, but Groq when no provider can write text and a Groq key is set;
     234         *  - groq: always Groq.
     235         */
     236        public static function uses_wordpress_ai() {
     237                $source = (string) WBBA_Settings::get( 'ai_source', 'auto' );
     238                if ( 'groq' === $source ) {
     239                        return false;
     240                }
     241                if ( WBBA_Provider_WordPress_AI::ready() ) {
     242                        return true;
     243                }
     244                // Not ready: keep WordPress AI only when it was chosen explicitly and there is no Groq
     245                // key to fall back to, so the run log explains what to connect.
     246                return 'wordpress' === $source && '' === trim( (string) WBBA_Settings::get( 'groq_api_key', '' ) ) && WBBA_Provider_WordPress_AI::available();
    203247        }
    204248
  • szbtechs-ai-blog-writer/tags/1.2.4/includes/class-settings.php

    r3770993 r3771549  
    2525        protected static function core_defaults() {
    2626                return array(
    27                         // AI source: wordpress (the WordPress 7+ AI Client, preferred when the
    28                         // site has it) | groq (your own Groq key, for sites without it).
    29                         'ai_source'         => function_exists( 'wp_ai_client_prompt' ) ? 'wordpress' : 'groq',
     27                        // AI source: auto (WordPress AI when a text-capable provider is connected,
     28                        // otherwise Groq) | wordpress (WordPress 7+ AI Client) | groq (your own key).
     29                        'ai_source'         => 'auto',
    3030
    3131                        // Groq key — https://console.groq.com.
  • szbtechs-ai-blog-writer/tags/1.2.4/readme.txt

    r3771518 r3771549  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.2.3
     7Stable tag: 1.2.4
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    3535This plugin connects to the following third-party services. Nothing is sent until you press **Run now**.
    3636
    37 * **WordPress AI Client** — used when "WordPress AI" is the selected AI provider (the default on WordPress 7.0+); the prompts below go to whichever AI provider you connected in WordPress (Settings → AI), under that provider's terms.
    38 * **Groq API** (`api.groq.com`) — used only when "Groq" is the selected AI provider; writes topics, keywords (fallback) and articles. Sent: your API key, the selected product's name, categories, price and description, and the generated prompts. [Terms](https://groq.com/terms-of-use/) · [Privacy](https://groq.com/privacy-policy/)
     37* **WordPress AI Client** — used when "WordPress AI" is selected, or with the default "Automatic" setting when a provider that can write text is connected in WordPress 7.0+; the prompts below go to whichever AI provider you connected in WordPress (Settings → AI), under that provider's terms.
     38* **Groq API** (`api.groq.com`) — used when "Groq" is selected, or with "Automatic" when WordPress AI has no text provider; writes topics, keywords (fallback) and articles. Sent: your API key, the selected product's name, categories, price and description, and the generated prompts. [Terms](https://groq.com/terms-of-use/) · [Privacy](https://groq.com/privacy-policy/)
    3939* **Google Autocomplete** (`suggestqueries.google.com`) — keyword suggestions. Sent: short search phrases derived from the product and topic, plus your country/language codes. [Terms](https://policies.google.com/terms) · [Privacy](https://policies.google.com/privacy)
    4040* **Cited websites** — each external link in a generated article receives one HEAD/GET request to check it is not broken. Sent: a standard HTTP request with no personal data.
    … …  
    6969== Changelog ==
    7070
     71= 1.2.4 =
     72* New "Automatic" AI provider setting (the default): uses WordPress AI when a provider that can write text is connected, otherwise your Groq key.
     73* Fix: runs no longer fail with "No AI provider connected in WordPress supports text generation" when WordPress AI has no provider but a Groq key is set.
     74* The settings page shows whether WordPress AI is ready.
     75
    7176= 1.2.3 =
    7277* Fix: "Save settings", "Publish" and "New image" could stay on "Saving…" without submitting in Chrome and other browsers.
  • szbtechs-ai-blog-writer/tags/1.2.4/szbtechs-ai-blog-writer.php

    r3771518 r3771549  
    44 * Plugin URI:        https://szbtechs.com/products/ai-blog-writer/
    55 * Description:       AI blog pipeline for WooCommerce stores — product selection, local keyword research, SEO article writing with internal/external linking, product images, and a review queue.
    6  * Version:           1.2.3
     6 * Version:           1.2.4
    77 * Author:            SZBTechs
    88 * Author URI:        https://szbtechs.com
    … …  
    3838}
    3939
    40 define( 'WBBA_VERSION', '1.2.3' );
     40define( 'WBBA_VERSION', '1.2.4' );
    4141define( 'WBBA_PLUGIN_FILE', __FILE__ );
    4242define( 'WBBA_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
  • szbtechs-ai-blog-writer/tags/1.2.4/uninstall.php

    r3770993 r3771549  
    2222}
    2323wp_clear_scheduled_hook( 'wbba_daily_run' );
     24delete_transient( 'wbba_wp_ai_ready' );
  • szbtechs-ai-blog-writer/trunk/includes/class-admin.php

    r3770993 r3771549  
    7373                $history    = WBBA_Queue::history();
    7474                // Extensions that supply their own AI provider report readiness here.
    75                 $core_ready = ( 'wordpress' === $settings['ai_source'] && WBBA_Provider_WordPress_AI::available() ) || trim( (string) $settings['groq_api_key'] ) !== '';
     75                $core_ready = ( 'groq' !== $settings['ai_source'] && WBBA_Provider_WordPress_AI::ready() ) || trim( (string) $settings['groq_api_key'] ) !== '';
    7676                $has_key    = (bool) wbba_apply_filters( 'wbba_ai_ready', $core_ready, $settings );
    7777
    … …  
    335335                                                <th>Write articles with</th>
    336336                                                <td>
    337                                                         <label><input type="radio" name="wbba[ai_source]" value="wordpress" <?php checked( $s['ai_source'], 'wordpress' ); ?> <?php disabled( ! WBBA_Provider_WordPress_AI::available() ); ?> /> WordPress AI (recommended) — the AI provider connected in WordPress itself (WordPress 7.0+)</label><br />
    338                                                         <label><input type="radio" name="wbba[ai_source]" value="groq" <?php checked( $s['ai_source'], 'groq' ); ?> /> Groq — with your own API key (below), for sites without WordPress AI</label>
    339                                                         <?php if ( ! WBBA_Provider_WordPress_AI::available() ) : ?>
    340                                                                 <p class="description">WordPress AI is not available on this site (needs WordPress 7.0+ with an AI provider connected), so Groq is used.</p>
    341                                                         <?php endif; ?>
     337                                                        <?php $wbba_wp_ai_ready = WBBA_Provider_WordPress_AI::ready(); ?>
     338                                                        <label><input type="radio" name="wbba[ai_source]" value="auto" <?php checked( $s['ai_source'], 'auto' ); ?> /> Automatic (recommended) — WordPress AI when a provider is connected, otherwise Groq</label><br />
     339                                                        <label><input type="radio" name="wbba[ai_source]" value="wordpress" <?php checked( $s['ai_source'], 'wordpress' ); ?> <?php disabled( ! WBBA_Provider_WordPress_AI::available() ); ?> /> WordPress AI — the AI provider connected in WordPress itself (WordPress 7.0+)</label><br />
     340                                                        <label><input type="radio" name="wbba[ai_source]" value="groq" <?php checked( $s['ai_source'], 'groq' ); ?> /> Groq — with your own API key (below)</label>
     341                                                        <p class="description">
     342                                                                <?php if ( $wbba_wp_ai_ready ) : ?>
     343                                                                        WordPress AI: ready — a connected provider can write text.
     344                                                                <?php elseif ( WBBA_Provider_WordPress_AI::available() ) : ?>
     345                                                                        WordPress AI: no provider that can write text is connected yet (connect one under <a href="<?php echo esc_url( admin_url( 'options-general.php' ) ); ?>">Settings → AI</a>). Until then Groq is used<?php echo trim( (string) $s['groq_api_key'] ) === '' ? ' — add a Groq API key below' : ''; ?>.
     346                                                                <?php else : ?>
     347                                                                        WordPress AI is not available on this site (it needs WordPress 7.0+), so Groq is used.
     348                                                                <?php endif; ?>
     349                                                        </p>
    342350                                                </td>
    343351                                        </tr>
    … …  
    645653                wbba_do_action( 'wbba_settings_saved', $clean );
    646654                delete_option( 'wbba_setup_pending' );
     655                delete_transient( 'wbba_wp_ai_ready' ); // Re-check WordPress AI on the next page load.
    647656                $this->redirect( 'wbba-settings', 'saved' );
    648657        }
    … …  
    659668                $clean['groq_api_key']      = isset( $posted['groq_api_key'] ) ? sanitize_text_field( trim( (string) $posted['groq_api_key'] ) ) : '';
    660669                $clean['groq_model']        = isset( $posted['groq_model'] ) ? sanitize_text_field( $posted['groq_model'] ) : WBBA_Settings::DEFAULT_GROQ_MODEL;
    661                 $clean['ai_source']         = ( isset( $posted['ai_source'] ) && 'wordpress' === $posted['ai_source'] ) ? 'wordpress' : 'groq';
     670                $clean['ai_source']         = isset( $posted['ai_source'] ) && in_array( $posted['ai_source'], array( 'auto', 'wordpress', 'groq' ), true ) ? $posted['ai_source'] : 'auto';
    662671                $clean['min_words']         = isset( $posted['min_words'] ) ? max( 600, min( 3000, (int) $posted['min_words'] ) ) : 1000;
    663672                $clean['max_words']         = isset( $posted['max_words'] ) ? max( 800, min( 4000, (int) $posted['max_words'] ) ) : 1200;
  • szbtechs-ai-blog-writer/trunk/includes/class-llm.php

    r3770993 r3771549  
    115115        }
    116116
     117        /**
     118         * True when the AI Client exists AND a connected provider can generate text.
     119         * Cached for ten minutes: connecting a provider in Settings → AI takes effect shortly after.
     120         */
     121        public static function ready() {
     122                static $ready = null;
     123                if ( null !== $ready ) {
     124                        return $ready;
     125                }
     126                if ( ! self::available() ) {
     127                        return $ready = false;
     128                }
     129                $cached = get_transient( 'wbba_wp_ai_ready' );
     130                if ( false !== $cached ) {
     131                        return $ready = ( 'yes' === $cached );
     132                }
     133                try {
     134                        $ready = (bool) wp_ai_client_prompt( 'ping' )->is_supported_for_text_generation();
     135                } catch ( Throwable $e ) {
     136                        $ready = false;
     137                }
     138                set_transient( 'wbba_wp_ai_ready', $ready ? 'yes' : 'no', 10 * MINUTE_IN_SECONDS );
     139                return $ready;
     140        }
     141
    117142        public function chat( array $messages, array $opts = array() ) {
    118143                if ( ! self::available() ) {
    … …  
    192217                        return $provider;
    193218                }
    194                 if ( 'wordpress' === WBBA_Settings::get( 'ai_source', 'groq' ) && WBBA_Provider_WordPress_AI::available() ) {
     219                if ( self::uses_wordpress_ai() ) {
    195220                        return new WBBA_Provider_WordPress_AI();
    196221                }
    … …  
    201226                $groq->sleeper     = $this->sleeper;
    202227                return $groq;
     228        }
     229
     230        /**
     231         * Which AI writes the articles:
     232         *  - auto (default): WordPress AI when a text-capable provider is connected, otherwise Groq;
     233         *  - wordpress: WordPress AI, but Groq when no provider can write text and a Groq key is set;
     234         *  - groq: always Groq.
     235         */
     236        public static function uses_wordpress_ai() {
     237                $source = (string) WBBA_Settings::get( 'ai_source', 'auto' );
     238                if ( 'groq' === $source ) {
     239                        return false;
     240                }
     241                if ( WBBA_Provider_WordPress_AI::ready() ) {
     242                        return true;
     243                }
     244                // Not ready: keep WordPress AI only when it was chosen explicitly and there is no Groq
     245                // key to fall back to, so the run log explains what to connect.
     246                return 'wordpress' === $source && '' === trim( (string) WBBA_Settings::get( 'groq_api_key', '' ) ) && WBBA_Provider_WordPress_AI::available();
    203247        }
    204248
  • szbtechs-ai-blog-writer/trunk/includes/class-settings.php

    r3770993 r3771549  
    2525        protected static function core_defaults() {
    2626                return array(
    27                         // AI source: wordpress (the WordPress 7+ AI Client, preferred when the
    28                         // site has it) | groq (your own Groq key, for sites without it).
    29                         'ai_source'         => function_exists( 'wp_ai_client_prompt' ) ? 'wordpress' : 'groq',
     27                        // AI source: auto (WordPress AI when a text-capable provider is connected,
     28                        // otherwise Groq) | wordpress (WordPress 7+ AI Client) | groq (your own key).
     29                        'ai_source'         => 'auto',
    3030
    3131                        // Groq key — https://console.groq.com.
  • szbtechs-ai-blog-writer/trunk/readme.txt

    r3771518 r3771549  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.2.3
     7Stable tag: 1.2.4
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    3535This plugin connects to the following third-party services. Nothing is sent until you press **Run now**.
    3636
    37 * **WordPress AI Client** — used when "WordPress AI" is the selected AI provider (the default on WordPress 7.0+); the prompts below go to whichever AI provider you connected in WordPress (Settings → AI), under that provider's terms.
    38 * **Groq API** (`api.groq.com`) — used only when "Groq" is the selected AI provider; writes topics, keywords (fallback) and articles. Sent: your API key, the selected product's name, categories, price and description, and the generated prompts. [Terms](https://groq.com/terms-of-use/) · [Privacy](https://groq.com/privacy-policy/)
     37* **WordPress AI Client** — used when "WordPress AI" is selected, or with the default "Automatic" setting when a provider that can write text is connected in WordPress 7.0+; the prompts below go to whichever AI provider you connected in WordPress (Settings → AI), under that provider's terms.
     38* **Groq API** (`api.groq.com`) — used when "Groq" is selected, or with "Automatic" when WordPress AI has no text provider; writes topics, keywords (fallback) and articles. Sent: your API key, the selected product's name, categories, price and description, and the generated prompts. [Terms](https://groq.com/terms-of-use/) · [Privacy](https://groq.com/privacy-policy/)
    3939* **Google Autocomplete** (`suggestqueries.google.com`) — keyword suggestions. Sent: short search phrases derived from the product and topic, plus your country/language codes. [Terms](https://policies.google.com/terms) · [Privacy](https://policies.google.com/privacy)
    4040* **Cited websites** — each external link in a generated article receives one HEAD/GET request to check it is not broken. Sent: a standard HTTP request with no personal data.
    … …  
    6969== Changelog ==
    7070
     71= 1.2.4 =
     72* New "Automatic" AI provider setting (the default): uses WordPress AI when a provider that can write text is connected, otherwise your Groq key.
     73* Fix: runs no longer fail with "No AI provider connected in WordPress supports text generation" when WordPress AI has no provider but a Groq key is set.
     74* The settings page shows whether WordPress AI is ready.
     75
    7176= 1.2.3 =
    7277* Fix: "Save settings", "Publish" and "New image" could stay on "Saving…" without submitting in Chrome and other browsers.
  • szbtechs-ai-blog-writer/trunk/szbtechs-ai-blog-writer.php

    r3771518 r3771549  
    44 * Plugin URI:        https://szbtechs.com/products/ai-blog-writer/
    55 * Description:       AI blog pipeline for WooCommerce stores — product selection, local keyword research, SEO article writing with internal/external linking, product images, and a review queue.
    6  * Version:           1.2.3
     6 * Version:           1.2.4
    77 * Author:            SZBTechs
    88 * Author URI:        https://szbtechs.com
    … …  
    3838}
    3939
    40 define( 'WBBA_VERSION', '1.2.3' );
     40define( 'WBBA_VERSION', '1.2.4' );
    4141define( 'WBBA_PLUGIN_FILE', __FILE__ );
    4242define( 'WBBA_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
  • szbtechs-ai-blog-writer/trunk/uninstall.php

    r3770993 r3771549  
    2222}
    2323wp_clear_scheduled_hook( 'wbba_daily_run' );
     24delete_transient( 'wbba_wp_ai_ready' );
Note: See TracChangeset for help on using the changeset viewer.