PluginProbe
BotWriter – AI Writer & SEO Content Generator / trunk
BotWriter – AI Writer & SEO Content Generator vtrunk
3.4.10 3.4.9 3.4.8 3.4.7 3.4.6 3.4.4 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 3.3.0 3.2.8 trunk 1.3.0 1.3.1 1.3.2 1.3.3 All 51 releases
botwriter / includes / settings / stability.php

stability.php in BotWriter – AI Writer & SEO Content Generator trunk, at includes/settings/stability.php

226 lines 11.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Stability AI Image Provider Settings
4 *
5 * @package BotWriter
6 */
7
8 if (!defined('ABSPATH')) {
9 exit;
10 }
11
12 /**
13 * Get Stability AI models configuration
14 */
15 function botwriter_get_stability_models() {
16 if (function_exists('botwriter_get_provider_image_models')) {
17 $catalog_models = botwriter_get_provider_image_models('stability');
18 if (!empty($catalog_models)) {
19 return $catalog_models;
20 }
21 }
22
23 return [
24 'Stable Diffusion 3.5' => [
25 'sd3.5-large-turbo' => 'SD 3.5 Large Turbo (fast)',
26 'sd3.5-large' => 'SD 3.5 Large (highest quality)',
27 'sd3.5-medium' => 'SD 3.5 Medium (balanced)',
28 'sd3.5-flash' => 'SD 3.5 Flash (lowest cost)',
29 ],
30 'Premium' => [
31 'core' => 'Stable Image Core',
32 'ultra' => 'Stable Image Ultra',
33 ],
34 ];
35 }
36
37 /**
38 * Get Stability AI provider info
39 */
40 function botwriter_get_stability_info() {
41 return [
42 'name' => 'Stability AI',
43 'description' => __('Creators of Stable Diffusion, the most popular open-source image model. Credit-based pricing with excellent quality.', 'botwriter'),
44 'website' => 'https://stability.ai',
45 'api_url' => 'https://platform.stability.ai/account/keys',
46 'docs_url' => 'https://platform.stability.ai/docs/getting-started',
47 'pricing_url' => 'https://platform.stability.ai/pricing',
48 'free_credits' => __('25 FREE credits on signup (no credit card required!)', 'botwriter'),
49 'pricing_summary' => [
50 'SD 3.5 Large' => '6.5 credits (~$0.065/image)',
51 'SD 3.5 Large Turbo' => '4 credits (~$0.04/image)',
52 'SD 3.5 Medium' => '3.5 credits (~$0.035/image)',
53 'Stable Image Core' => '3 credits (~$0.03/image)',
54 'Creative Upscaler' => '60 credits (~$0.60/upscale)',
55 ],
56 'features' => [
57 __('25 free credits to start!', 'botwriter'),
58 __('Creators of Stable Diffusion', 'botwriter'),
59 __('Excellent image quality', 'botwriter'),
60 __('Image editing tools (inpaint, outpaint)', 'botwriter'),
61 __('Upscaling (up to 4K)', 'botwriter'),
62 __('Background removal', 'botwriter'),
63 __('3D and audio generation too', 'botwriter'),
64 ],
65 'pros' => [
66 __('Free credits to start', 'botwriter'),
67 __('Pioneer in AI imagery', 'botwriter'),
68 __('Many editing tools', 'botwriter'),
69 __('Predictable credit pricing', 'botwriter'),
70 ],
71 'cons' => [
72 __('Credit system can be confusing', 'botwriter'),
73 __('Credits expire after 1 year', 'botwriter'),
74 ],
75 ];
76 }
77
78 /**
79 * Render Stability AI settings tab content
80 */
81 function botwriter_render_stability_settings($settings, $is_active) {
82 $info = botwriter_get_stability_info();
83 $models = botwriter_get_stability_models();
84 ?>
85 <div class="provider-config-section">
86 <div class="provider-config-card">
87 <h4><?php esc_html_e('API Configuration', 'botwriter'); ?></h4>
88 <div class="form-row">
89 <label><?php esc_html_e('API Key:', 'botwriter'); ?></label>
90 <div class="api-key-wrapper">
91 <input type="password" name="botwriter_stability_api_key" class="form-control api-key-input"
92 value="<?php echo esc_attr(botwriter_decrypt_api_key(get_option('botwriter_stability_api_key'))); ?>"
93 placeholder="sk-...">
94 <button type="button" class="button toggle-api-key"><?php esc_html_e('Show', 'botwriter'); ?></button>
95 <button type="button" class="button button-secondary test-api-key" data-provider="stability">
96 <span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e('Test API Key', 'botwriter'); ?>
97 </button>
98 <span class="test-api-result"></span>
99 </div>
100 <p class="description"><?php esc_html_e('Your Stability API key starts with "sk-"', 'botwriter'); ?></p>
101 <?php botwriter_api_key_transmission_notice(); ?>
102 </div>
103 <div class="form-row">
104 <label><?php esc_html_e('Model:', 'botwriter'); ?></label>
105 <select name="botwriter_stability_model" class="form-select" style="width: 100%; max-width: 400px;">
106 <?php foreach ($models as $group => $group_models): ?>
107 <optgroup label="<?php echo esc_attr($group); ?>">
108 <?php foreach ($group_models as $id => $name): ?>
109 <option value="<?php echo esc_attr($id); ?>" <?php selected($settings['botwriter_stability_model'], $id); ?>><?php echo esc_html($name); ?></option>
110 <?php endforeach; ?>
111 </optgroup>
112 <?php endforeach; ?>
113 </select>
114 </div>
115 </div>
116
117 <div class="provider-info-card highlight-free">
118 <h4><span class="dashicons dashicons-info-outline"></span> <?php esc_html_e('How to Get Your API Key', 'botwriter'); ?></h4>
119 <div class="free-banner">
120 <span class="dashicons dashicons-awards"></span>
121 <strong><?php esc_html_e('🎁 25 FREE credits on signup!', 'botwriter'); ?></strong>
122 </div>
123 <ol class="setup-steps">
124 <li><?php esc_html_e('Go to', 'botwriter'); ?> <a href="https://platform.stability.ai/" target="_blank">platform.stability.ai</a> <?php esc_html_e('and create an account', 'botwriter'); ?></li>
125 <li><?php esc_html_e('Navigate to', 'botwriter'); ?> <a href="https://platform.stability.ai/account/keys" target="_blank"><?php esc_html_e('Account → API Keys', 'botwriter'); ?></a></li>
126 <li><?php esc_html_e('Click "Create API Key"', 'botwriter'); ?></li>
127 <li><?php esc_html_e('Copy the key and paste it above', 'botwriter'); ?></li>
128 </ol>
129 <div class="info-tip success">
130 <span class="dashicons dashicons-yes-alt"></span>
131 <p><?php esc_html_e('You get 25 free credits immediately - no credit card needed! That\'s about 6-8 high-quality images.', 'botwriter'); ?></p>
132 </div>
133 </div>
134
135 <div class="provider-pricing-card">
136 <h4><span class="dashicons dashicons-money-alt"></span> <?php esc_html_e('Pricing Overview', 'botwriter'); ?></h4>
137
138 <div class="pricing-highlight free-highlight">
139 <span class="free-credits-badge large"><?php esc_html_e('🎁 25 FREE Credits', 'botwriter'); ?></span>
140 <p><?php echo esc_html($info['free_credits']); ?></p>
141 </div>
142
143 <div class="credits-explanation">
144 <p><strong><?php esc_html_e('How credits work:', 'botwriter'); ?></strong> <?php esc_html_e('1 credit = $0.01. Buy credits in bundles starting at $10.', 'botwriter'); ?></p>
145 </div>
146
147 <table class="pricing-table">
148 <thead>
149 <tr>
150 <th><?php esc_html_e('Model', 'botwriter'); ?></th>
151 <th><?php esc_html_e('Credits / Est. Cost', 'botwriter'); ?></th>
152 </tr>
153 </thead>
154 <tbody>
155 <?php foreach ($info['pricing_summary'] as $model => $price): ?>
156 <tr>
157 <td><code><?php echo esc_html($model); ?></code></td>
158 <td><?php echo esc_html($price); ?></td>
159 </tr>
160 <?php endforeach; ?>
161 </tbody>
162 </table>
163
164 <p class="pricing-note">
165 <a href="<?php echo esc_url($info['pricing_url']); ?>" target="_blank" class="button button-secondary">
166 <span class="dashicons dashicons-external"></span> <?php esc_html_e('View Full Pricing', 'botwriter'); ?>
167 </a>
168 <a href="https://platform.stability.ai/account/credits" target="_blank" class="button button-secondary">
169 <span class="dashicons dashicons-money-alt"></span> <?php esc_html_e('Buy Credits', 'botwriter'); ?>
170 </a>
171 </p>
172 </div>
173
174 <div class="provider-features-card">
175 <h4><span class="dashicons dashicons-star-filled"></span> <?php esc_html_e('Features & Benefits', 'botwriter'); ?></h4>
176 <ul class="features-list">
177 <?php foreach ($info['features'] as $feature): ?>
178 <li><span class="dashicons dashicons-yes-alt"></span> <?php echo esc_html($feature); ?></li>
179 <?php endforeach; ?>
180 </ul>
181
182 <div class="pros-cons">
183 <div class="pros">
184 <h5><?php esc_html_e('Pros', 'botwriter'); ?></h5>
185 <ul>
186 <?php foreach ($info['pros'] as $pro): ?>
187 <li><span class="dashicons dashicons-plus-alt2"></span> <?php echo esc_html($pro); ?></li>
188 <?php endforeach; ?>
189 </ul>
190 </div>
191 <div class="cons">
192 <h5><?php esc_html_e('Cons', 'botwriter'); ?></h5>
193 <ul>
194 <?php foreach ($info['cons'] as $con): ?>
195 <li><span class="dashicons dashicons-minus"></span> <?php echo esc_html($con); ?></li>
196 <?php endforeach; ?>
197 </ul>
198 </div>
199 </div>
200 </div>
201
202 <div class="provider-links-card">
203 <h4><span class="dashicons dashicons-admin-links"></span> <?php esc_html_e('Useful Links', 'botwriter'); ?></h4>
204 <div class="links-grid">
205 <a href="<?php echo esc_url($info['api_url']); ?>" target="_blank" class="link-item">
206 <span class="dashicons dashicons-admin-network"></span>
207 <?php esc_html_e('Get API Key', 'botwriter'); ?>
208 </a>
209 <a href="<?php echo esc_url($info['docs_url']); ?>" target="_blank" class="link-item">
210 <span class="dashicons dashicons-book"></span>
211 <?php esc_html_e('Documentation', 'botwriter'); ?>
212 </a>
213 <a href="<?php echo esc_url($info['pricing_url']); ?>" target="_blank" class="link-item">
214 <span class="dashicons dashicons-money-alt"></span>
215 <?php esc_html_e('Pricing', 'botwriter'); ?>
216 </a>
217 <a href="https://stabilityai.instatus.com/" target="_blank" class="link-item">
218 <span class="dashicons dashicons-heart"></span>
219 <?php esc_html_e('Status', 'botwriter'); ?>
220 </a>
221 </div>
222 </div>
223 </div>
224 <?php
225 }
226