PluginProbe
BotWriter – AI Writer & SEO Content Generator / 3.2.8
BotWriter – AI Writer & SEO Content Generator v3.2.8
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 / openai.php

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

178 lines 8.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * OpenAI Provider Settings
4 *
5 * @package BotWriter
6 */
7
8 if (!defined('ABSPATH')) {
9 exit;
10 }
11
12 /**
13 * Get OpenAI provider info
14 */
15 function botwriter_get_openai_info() {
16 return [
17 'name' => 'OpenAI',
18 'description' => __('The creators of ChatGPT. Industry leader in AI with the most advanced models for text generation.', 'botwriter'),
19 'website' => 'https://openai.com',
20 'api_url' => 'https://platform.openai.com/api-keys',
21 'docs_url' => 'https://platform.openai.com/docs',
22 'pricing_url' => 'https://openai.com/api/pricing/',
23 'free_credits' => __('$5 free credits for new accounts (limited time offers may vary)', 'botwriter'),
24 'pricing_summary' => [
25 'gpt-5-mini' => '$0.25/1M input, $2.00/1M output',
26 'gpt-5-nano' => '$0.05/1M input, $0.40/1M output',
27 'gpt-4o' => '~$5/1M input, $15/1M output',
28 'gpt-4o-mini' => '~$0.15/1M input, $0.60/1M output',
29 ],
30 'features' => [
31 __('Industry-leading models for complex tasks', 'botwriter'),
32 __('Excellent for coding and creative writing', 'botwriter'),
33 __('Image generation with DALL-E (same API key)', 'botwriter'),
34 __('Extensive documentation and community', 'botwriter'),
35 ],
36 'pros' => [
37 __('Best overall quality', 'botwriter'),
38 __('Most features and tools', 'botwriter'),
39 __('Great documentation', 'botwriter'),
40 ],
41 'cons' => [
42 __('Higher cost than alternatives', 'botwriter'),
43 __('Rate limits on free tier', 'botwriter'),
44 ],
45 ];
46 }
47
48 /**
49 * Render OpenAI settings tab content
50 */
51 function botwriter_render_openai_settings($settings, $is_active) {
52 $info = botwriter_get_openai_info();
53 ?>
54 <div class="provider-config-section">
55 <div class="provider-config-card">
56 <h4><?php esc_html_e('API Configuration', 'botwriter'); ?></h4>
57 <div class="form-row">
58 <label><?php esc_html_e('API Key:', 'botwriter'); ?></label>
59 <div class="api-key-wrapper">
60 <input type="password" name="botwriter_openai_api_key" class="form-control api-key-input"
61 value="<?php echo esc_attr(botwriter_decrypt_api_key(get_option('botwriter_openai_api_key'))); ?>"
62 placeholder="sk-...">
63 <button type="button" class="button toggle-api-key"><?php esc_html_e('Show', 'botwriter'); ?></button>
64 <button type="button" class="button button-secondary test-api-key" data-provider="openai">
65 <span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e('Test API Key & Update Models', 'botwriter'); ?>
66 </button>
67 <span class="test-api-result"></span>
68 </div>
69 <p class="description"><?php esc_html_e('Your OpenAI API key starts with "sk-"', 'botwriter'); ?></p>
70 </div>
71 <div class="form-row">
72 <label><?php esc_html_e('Model:', 'botwriter'); ?></label>
73 <div class="model-select-wrapper">
74 <?php botwriter_render_model_select('openai', 'botwriter_openai_model', $settings['botwriter_openai_model']); ?>
75 <button type="button" class="button button-secondary test-model" data-provider="openai">
76 <span class="dashicons dashicons-controls-play"></span> <?php esc_html_e('Test Model', 'botwriter'); ?>
77 </button>
78 <span class="test-model-result"></span>
79 </div>
80 </div>
81 </div>
82
83 <div class="provider-info-card">
84 <h4><span class="dashicons dashicons-info-outline"></span> <?php esc_html_e('How to Get Your API Key', 'botwriter'); ?></h4>
85 <ol class="setup-steps">
86 <li><?php esc_html_e('Go to', 'botwriter'); ?> <a href="https://platform.openai.com/signup" target="_blank">platform.openai.com</a> <?php esc_html_e('and create an account', 'botwriter'); ?></li>
87 <li><?php esc_html_e('Navigate to', 'botwriter'); ?> <a href="https://platform.openai.com/api-keys" target="_blank"><?php esc_html_e('API Keys', 'botwriter'); ?></a></li>
88 <li><?php esc_html_e('Click "Create new secret key"', 'botwriter'); ?></li>
89 <li><?php esc_html_e('Copy the key (it starts with "sk-") and paste it above', 'botwriter'); ?></li>
90 <li><?php esc_html_e('Add billing information in', 'botwriter'); ?> <a href="https://platform.openai.com/account/billing" target="_blank"><?php esc_html_e('Billing settings', 'botwriter'); ?></a></li>
91 </ol>
92 </div>
93
94 <div class="provider-pricing-card">
95 <h4><span class="dashicons dashicons-money-alt"></span> <?php esc_html_e('Pricing Overview', 'botwriter'); ?></h4>
96
97 <div class="pricing-highlight">
98 <span class="free-credits-badge"><?php esc_html_e('Free Credits', 'botwriter'); ?></span>
99 <p><?php echo esc_html($info['free_credits']); ?></p>
100 </div>
101
102 <table class="pricing-table">
103 <thead>
104 <tr>
105 <th><?php esc_html_e('Model', 'botwriter'); ?></th>
106 <th><?php esc_html_e('Cost (per 1M tokens)', 'botwriter'); ?></th>
107 </tr>
108 </thead>
109 <tbody>
110 <?php foreach ($info['pricing_summary'] as $model => $price): ?>
111 <tr>
112 <td><code><?php echo esc_html($model); ?></code></td>
113 <td><?php echo esc_html($price); ?></td>
114 </tr>
115 <?php endforeach; ?>
116 </tbody>
117 </table>
118
119 <p class="pricing-note">
120 <a href="<?php echo esc_url($info['pricing_url']); ?>" target="_blank" class="button button-secondary">
121 <span class="dashicons dashicons-external"></span> <?php esc_html_e('View Full Pricing', 'botwriter'); ?>
122 </a>
123 </p>
124 </div>
125
126 <div class="provider-features-card">
127 <h4><span class="dashicons dashicons-star-filled"></span> <?php esc_html_e('Features & Benefits', 'botwriter'); ?></h4>
128 <ul class="features-list">
129 <?php foreach ($info['features'] as $feature): ?>
130 <li><span class="dashicons dashicons-yes-alt"></span> <?php echo esc_html($feature); ?></li>
131 <?php endforeach; ?>
132 </ul>
133
134 <div class="pros-cons">
135 <div class="pros">
136 <h5><?php esc_html_e('Pros', 'botwriter'); ?></h5>
137 <ul>
138 <?php foreach ($info['pros'] as $pro): ?>
139 <li><span class="dashicons dashicons-plus-alt2"></span> <?php echo esc_html($pro); ?></li>
140 <?php endforeach; ?>
141 </ul>
142 </div>
143 <div class="cons">
144 <h5><?php esc_html_e('Cons', 'botwriter'); ?></h5>
145 <ul>
146 <?php foreach ($info['cons'] as $con): ?>
147 <li><span class="dashicons dashicons-minus"></span> <?php echo esc_html($con); ?></li>
148 <?php endforeach; ?>
149 </ul>
150 </div>
151 </div>
152 </div>
153
154 <div class="provider-links-card">
155 <h4><span class="dashicons dashicons-admin-links"></span> <?php esc_html_e('Useful Links', 'botwriter'); ?></h4>
156 <div class="links-grid">
157 <a href="<?php echo esc_url($info['api_url']); ?>" target="_blank" class="link-item">
158 <span class="dashicons dashicons-admin-network"></span>
159 <?php esc_html_e('Get API Key', 'botwriter'); ?>
160 </a>
161 <a href="<?php echo esc_url($info['docs_url']); ?>" target="_blank" class="link-item">
162 <span class="dashicons dashicons-book"></span>
163 <?php esc_html_e('Documentation', 'botwriter'); ?>
164 </a>
165 <a href="<?php echo esc_url($info['pricing_url']); ?>" target="_blank" class="link-item">
166 <span class="dashicons dashicons-money-alt"></span>
167 <?php esc_html_e('Pricing', 'botwriter'); ?>
168 </a>
169 <a href="https://status.openai.com/" target="_blank" class="link-item">
170 <span class="dashicons dashicons-heart"></span>
171 <?php esc_html_e('API Status', 'botwriter'); ?>
172 </a>
173 </div>
174 </div>
175 </div>
176 <?php
177 }
178