Changeset 3771549
- Timestamp:
- 10/28/2026 08:20:04 PM (3 days ago)
- Location:
- szbtechs-ai-blog-writer
- Files:
-
- 12 edited
- 1 copied
-
tags/1.2.4 (copied) (copied from szbtechs-ai-blog-writer/trunk )
-
tags/1.2.4/includes/class-admin.php (modified) (4 diffs)
-
tags/1.2.4/includes/class-llm.php (modified) (3 diffs)
-
tags/1.2.4/includes/class-settings.php (modified) (1 diff)
-
tags/1.2.4/readme.txt (modified) (3 diffs)
-
tags/1.2.4/szbtechs-ai-blog-writer.php (modified) (2 diffs)
-
tags/1.2.4/uninstall.php (modified) (1 diff)
-
trunk/includes/class-admin.php (modified) (4 diffs)
-
trunk/includes/class-llm.php (modified) (3 diffs)
-
trunk/includes/class-settings.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/szbtechs-ai-blog-writer.php (modified) (2 diffs)
-
trunk/uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
szbtechs-ai-blog-writer/tags/1.2.4/includes/class-admin.php
r3770993 r3771549 73 73 $history = WBBA_Queue::history(); 74 74 // 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'] ) !== ''; 76 76 $has_key = (bool) wbba_apply_filters( 'wbba_ai_ready', $core_ready, $settings ); 77 77 … … 335 335 <th>Write articles with</th> 336 336 <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> 342 350 </td> 343 351 </tr> … … 645 653 wbba_do_action( 'wbba_settings_saved', $clean ); 646 654 delete_option( 'wbba_setup_pending' ); 655 delete_transient( 'wbba_wp_ai_ready' ); // Re-check WordPress AI on the next page load. 647 656 $this->redirect( 'wbba-settings', 'saved' ); 648 657 } … … 659 668 $clean['groq_api_key'] = isset( $posted['groq_api_key'] ) ? sanitize_text_field( trim( (string) $posted['groq_api_key'] ) ) : ''; 660 669 $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'; 662 671 $clean['min_words'] = isset( $posted['min_words'] ) ? max( 600, min( 3000, (int) $posted['min_words'] ) ) : 1000; 663 672 $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 115 115 } 116 116 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 117 142 public function chat( array $messages, array $opts = array() ) { 118 143 if ( ! self::available() ) { … … 192 217 return $provider; 193 218 } 194 if ( 'wordpress' === WBBA_Settings::get( 'ai_source', 'groq' ) && WBBA_Provider_WordPress_AI::available() ) {219 if ( self::uses_wordpress_ai() ) { 195 220 return new WBBA_Provider_WordPress_AI(); 196 221 } … … 201 226 $groq->sleeper = $this->sleeper; 202 227 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(); 203 247 } 204 248 -
szbtechs-ai-blog-writer/tags/1.2.4/includes/class-settings.php
r3770993 r3771549 25 25 protected static function core_defaults() { 26 26 return array( 27 // AI source: wordpress (the WordPress 7+ AI Client, preferred when the28 // 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', 30 30 31 31 // Groq key — https://console.groq.com. -
szbtechs-ai-blog-writer/tags/1.2.4/readme.txt
r3771518 r3771549 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 1.2. 37 Stable tag: 1.2.4 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 35 35 This plugin connects to the following third-party services. Nothing is sent until you press **Run now**. 36 36 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 AIprovider; 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/) 39 39 * **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) 40 40 * **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. … … 69 69 == Changelog == 70 70 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 71 76 = 1.2.3 = 72 77 * 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 4 4 * Plugin URI: https://szbtechs.com/products/ai-blog-writer/ 5 5 * 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. 36 * Version: 1.2.4 7 7 * Author: SZBTechs 8 8 * Author URI: https://szbtechs.com … … 38 38 } 39 39 40 define( 'WBBA_VERSION', '1.2. 3' );40 define( 'WBBA_VERSION', '1.2.4' ); 41 41 define( 'WBBA_PLUGIN_FILE', __FILE__ ); 42 42 define( 'WBBA_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); -
szbtechs-ai-blog-writer/tags/1.2.4/uninstall.php
r3770993 r3771549 22 22 } 23 23 wp_clear_scheduled_hook( 'wbba_daily_run' ); 24 delete_transient( 'wbba_wp_ai_ready' ); -
szbtechs-ai-blog-writer/trunk/includes/class-admin.php
r3770993 r3771549 73 73 $history = WBBA_Queue::history(); 74 74 // 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'] ) !== ''; 76 76 $has_key = (bool) wbba_apply_filters( 'wbba_ai_ready', $core_ready, $settings ); 77 77 … … 335 335 <th>Write articles with</th> 336 336 <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> 342 350 </td> 343 351 </tr> … … 645 653 wbba_do_action( 'wbba_settings_saved', $clean ); 646 654 delete_option( 'wbba_setup_pending' ); 655 delete_transient( 'wbba_wp_ai_ready' ); // Re-check WordPress AI on the next page load. 647 656 $this->redirect( 'wbba-settings', 'saved' ); 648 657 } … … 659 668 $clean['groq_api_key'] = isset( $posted['groq_api_key'] ) ? sanitize_text_field( trim( (string) $posted['groq_api_key'] ) ) : ''; 660 669 $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'; 662 671 $clean['min_words'] = isset( $posted['min_words'] ) ? max( 600, min( 3000, (int) $posted['min_words'] ) ) : 1000; 663 672 $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 115 115 } 116 116 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 117 142 public function chat( array $messages, array $opts = array() ) { 118 143 if ( ! self::available() ) { … … 192 217 return $provider; 193 218 } 194 if ( 'wordpress' === WBBA_Settings::get( 'ai_source', 'groq' ) && WBBA_Provider_WordPress_AI::available() ) {219 if ( self::uses_wordpress_ai() ) { 195 220 return new WBBA_Provider_WordPress_AI(); 196 221 } … … 201 226 $groq->sleeper = $this->sleeper; 202 227 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(); 203 247 } 204 248 -
szbtechs-ai-blog-writer/trunk/includes/class-settings.php
r3770993 r3771549 25 25 protected static function core_defaults() { 26 26 return array( 27 // AI source: wordpress (the WordPress 7+ AI Client, preferred when the28 // 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', 30 30 31 31 // Groq key — https://console.groq.com. -
szbtechs-ai-blog-writer/trunk/readme.txt
r3771518 r3771549 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 1.2. 37 Stable tag: 1.2.4 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 35 35 This plugin connects to the following third-party services. Nothing is sent until you press **Run now**. 36 36 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 AIprovider; 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/) 39 39 * **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) 40 40 * **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. … … 69 69 == Changelog == 70 70 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 71 76 = 1.2.3 = 72 77 * 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 4 4 * Plugin URI: https://szbtechs.com/products/ai-blog-writer/ 5 5 * 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. 36 * Version: 1.2.4 7 7 * Author: SZBTechs 8 8 * Author URI: https://szbtechs.com … … 38 38 } 39 39 40 define( 'WBBA_VERSION', '1.2. 3' );40 define( 'WBBA_VERSION', '1.2.4' ); 41 41 define( 'WBBA_PLUGIN_FILE', __FILE__ ); 42 42 define( 'WBBA_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); -
szbtechs-ai-blog-writer/trunk/uninstall.php
r3770993 r3771549 22 22 } 23 23 wp_clear_scheduled_hook( 'wbba_daily_run' ); 24 delete_transient( 'wbba_wp_ai_ready' );
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)