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 / google.php

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

194 lines 9.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Google (Gemini) Provider Settings
4 *
5 * @package BotWriter
6 */
7
8 if (!defined('ABSPATH')) {
9 exit;
10 }
11
12 /**
13 * Get Google provider info
14 */
15 function botwriter_get_google_info() {
16 return [
17 'name' => 'Google AI (Gemini)',
18 'description' => __('Google\'s most capable AI models. Excellent multimodal capabilities and generous free tier.', 'botwriter'),
19 'website' => 'https://ai.google.dev',
20 'api_url' => 'https://aistudio.google.com/apikey',
21 'docs_url' => 'https://ai.google.dev/gemini-api/docs',
22 'pricing_url' => 'https://ai.google.dev/pricing',
23 'free_credits' => __('FREE TIER: Unlimited free usage with rate limits (no credit card required!)', 'botwriter'),
24 'pricing_summary' => [
25 'gemini-3.5-flash' => __('Production model (see official pricing page)', 'botwriter'),
26 'gemini-3.1-flash-lite' => __('Low-cost fallback model (see official pricing page)', 'botwriter'),
27 'gemini-2.5-pro' => 'FREE or $1.25/1M input, $10/1M output',
28 ],
29 'features' => [
30 __('Generous FREE tier - no credit card required!', 'botwriter'),
31 __('1 million token context window', 'botwriter'),
32 __('Native multimodal (text, images, video, audio)', 'botwriter'),
33 __('Google Search grounding included', 'botwriter'),
34 __('Excellent for reasoning and coding', 'botwriter'),
35 __('Built-in image generation (Imagen)', 'botwriter'),
36 ],
37 'pros' => [
38 __('Best free tier in the industry', 'botwriter'),
39 __('No credit card for free tier', 'botwriter'),
40 __('Massive context window', 'botwriter'),
41 __('Fast inference speed', 'botwriter'),
42 ],
43 'cons' => [
44 __('Free tier has rate limits', 'botwriter'),
45 __('Some features paid-only', 'botwriter'),
46 ],
47 ];
48 }
49
50 /**
51 * Render Google settings tab content
52 */
53 function botwriter_render_google_settings($settings, $is_active) {
54 $info = botwriter_get_google_info();
55 ?>
56 <div class="provider-config-section">
57 <div class="provider-config-card">
58 <h4><?php esc_html_e('API Configuration', 'botwriter'); ?></h4>
59 <div class="form-row">
60 <label><?php esc_html_e('API Key:', 'botwriter'); ?></label>
61 <div class="api-key-wrapper">
62 <input type="password" name="botwriter_google_api_key" class="form-control api-key-input"
63 value="<?php echo esc_attr(botwriter_decrypt_api_key(get_option('botwriter_google_api_key'))); ?>"
64 placeholder="AIza...">
65 <button type="button" class="button toggle-api-key"><?php esc_html_e('Show', 'botwriter'); ?></button>
66 <button type="button" class="button button-secondary test-api-key" data-provider="google">
67 <span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e('Test API Key & Update Models', 'botwriter'); ?>
68 </button>
69 <span class="test-api-result"></span>
70 </div>
71 <p class="description"><?php esc_html_e('Your Google AI API key starts with "AIza"', 'botwriter'); ?></p>
72 <?php botwriter_api_key_transmission_notice(); ?>
73 </div>
74 <div class="form-row">
75 <label><?php esc_html_e('Model:', 'botwriter'); ?></label>
76 <div class="model-select-wrapper">
77 <?php botwriter_render_model_select('google', 'botwriter_google_model', $settings['botwriter_google_model']); ?>
78 <button type="button" class="button button-secondary test-model" data-provider="google">
79 <span class="dashicons dashicons-controls-play"></span> <?php esc_html_e('Test Model', 'botwriter'); ?>
80 </button>
81 <span class="test-model-result"></span>
82 </div>
83 </div>
84 </div>
85
86 <div class="provider-info-card highlight-free">
87 <h4><span class="dashicons dashicons-info-outline"></span> <?php esc_html_e('How to Get Your API Key', 'botwriter'); ?></h4>
88 <div class="free-banner">
89 <span class="dashicons dashicons-awards"></span>
90 <strong><?php esc_html_e('100% FREE to start - No credit card required!', 'botwriter'); ?></strong>
91 </div>
92 <ol class="setup-steps">
93 <li><?php esc_html_e('Go to', 'botwriter'); ?> <a href="https://aistudio.google.com/" target="_blank">Google AI Studio</a> <?php esc_html_e('and sign in with your Google account', 'botwriter'); ?></li>
94 <li><?php esc_html_e('Click', 'botwriter'); ?> <a href="https://aistudio.google.com/apikey" target="_blank"><?php esc_html_e('"Get API Key"', 'botwriter'); ?></a></li>
95 <li><?php esc_html_e('Click "Create API Key"', 'botwriter'); ?></li>
96 <li><?php esc_html_e('Copy the key and paste it above', 'botwriter'); ?></li>
97 </ol>
98 <div class="info-tip success">
99 <span class="dashicons dashicons-yes-alt"></span>
100 <p><?php esc_html_e('That\'s it! No billing setup needed for the free tier. Start using immediately!', 'botwriter'); ?></p>
101 </div>
102 </div>
103
104 <div class="provider-pricing-card">
105 <h4><span class="dashicons dashicons-money-alt"></span> <?php esc_html_e('Pricing Overview', 'botwriter'); ?></h4>
106
107 <div class="pricing-highlight free-highlight">
108 <span class="free-credits-badge large"><?php esc_html_e('🎉 FREE TIER', 'botwriter'); ?></span>
109 <p><?php echo esc_html($info['free_credits']); ?></p>
110 </div>
111
112 <table class="pricing-table">
113 <thead>
114 <tr>
115 <th><?php esc_html_e('Model', 'botwriter'); ?></th>
116 <th><?php esc_html_e('Cost', 'botwriter'); ?></th>
117 </tr>
118 </thead>
119 <tbody>
120 <?php foreach ($info['pricing_summary'] as $model => $price): ?>
121 <tr>
122 <td><code><?php echo esc_html($model); ?></code></td>
123 <td><?php echo esc_html($price); ?></td>
124 </tr>
125 <?php endforeach; ?>
126 </tbody>
127 </table>
128
129 <div class="cost-saving-tip">
130 <span class="dashicons dashicons-saved"></span>
131 <strong><?php esc_html_e('Free Tier Limits:', 'botwriter'); ?></strong>
132 <?php esc_html_e('15 RPM (requests/min), 1M TPM (tokens/min), 1,500 RPD (requests/day).', 'botwriter'); ?>
133 </div>
134
135 <p class="pricing-note">
136 <a href="<?php echo esc_url($info['pricing_url']); ?>" target="_blank" class="button button-secondary">
137 <span class="dashicons dashicons-external"></span> <?php esc_html_e('View Full Pricing', 'botwriter'); ?>
138 </a>
139 </p>
140 </div>
141
142 <div class="provider-features-card">
143 <h4><span class="dashicons dashicons-star-filled"></span> <?php esc_html_e('Features & Benefits', 'botwriter'); ?></h4>
144 <ul class="features-list">
145 <?php foreach ($info['features'] as $feature): ?>
146 <li><span class="dashicons dashicons-yes-alt"></span> <?php echo esc_html($feature); ?></li>
147 <?php endforeach; ?>
148 </ul>
149
150 <div class="pros-cons">
151 <div class="pros">
152 <h5><?php esc_html_e('Pros', 'botwriter'); ?></h5>
153 <ul>
154 <?php foreach ($info['pros'] as $pro): ?>
155 <li><span class="dashicons dashicons-plus-alt2"></span> <?php echo esc_html($pro); ?></li>
156 <?php endforeach; ?>
157 </ul>
158 </div>
159 <div class="cons">
160 <h5><?php esc_html_e('Cons', 'botwriter'); ?></h5>
161 <ul>
162 <?php foreach ($info['cons'] as $con): ?>
163 <li><span class="dashicons dashicons-minus"></span> <?php echo esc_html($con); ?></li>
164 <?php endforeach; ?>
165 </ul>
166 </div>
167 </div>
168 </div>
169
170 <div class="provider-links-card">
171 <h4><span class="dashicons dashicons-admin-links"></span> <?php esc_html_e('Useful Links', 'botwriter'); ?></h4>
172 <div class="links-grid">
173 <a href="<?php echo esc_url($info['api_url']); ?>" target="_blank" class="link-item">
174 <span class="dashicons dashicons-admin-network"></span>
175 <?php esc_html_e('Get API Key', 'botwriter'); ?>
176 </a>
177 <a href="<?php echo esc_url($info['docs_url']); ?>" target="_blank" class="link-item">
178 <span class="dashicons dashicons-book"></span>
179 <?php esc_html_e('Documentation', 'botwriter'); ?>
180 </a>
181 <a href="<?php echo esc_url($info['pricing_url']); ?>" target="_blank" class="link-item">
182 <span class="dashicons dashicons-money-alt"></span>
183 <?php esc_html_e('Pricing', 'botwriter'); ?>
184 </a>
185 <a href="https://aistudio.google.com/" target="_blank" class="link-item">
186 <span class="dashicons dashicons-welcome-widgets-menus"></span>
187 <?php esc_html_e('AI Studio', 'botwriter'); ?>
188 </a>
189 </div>
190 </div>
191 </div>
192 <?php
193 }
194