| 1 |
<?php |
| 2 |
/** |
| 3 |
* Default Templates for BotWriter |
| 4 |
* |
| 5 |
* This file contains the default templates that are inserted into the database |
| 6 |
* when the plugin is activated. These templates provide various content styles |
| 7 |
* optimized for different purposes. |
| 8 |
* |
| 9 |
* @package BotWriter |
| 10 |
*/ |
| 11 |
|
| 12 |
if (!defined('ABSPATH')) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* Get all default templates to be inserted on plugin activation |
| 18 |
* |
| 19 |
* @return array Array of template data |
| 20 |
*/ |
| 21 |
function botwriter_get_default_templates() { |
| 22 |
return array( |
| 23 |
// Template 1: Default (Basic) |
| 24 |
array( |
| 25 |
'name' => 'Default Template', |
| 26 |
'is_default' => 1, |
| 27 |
'content' => 'Write an article for a blog, follow these instructions: |
| 28 |
|
| 29 |
-The article must be HTML, with proper opening and closing H2-H4 tags for headings, and <p> for paragraphs. |
| 30 |
-The length should be approximately {{post_length}} words. |
| 31 |
-The article language must be: {{post_language}}. |
| 32 |
-Narrative style: {{writer_style}} |
| 33 |
-The topic must be related to some of the following keywords: {{prompt_or_keywords}} |
| 34 |
|
| 35 |
-IMPORTANT: Do not title or label the last paragraph with Conclusion, Final Thoughts, Summary, or any similar term. The last paragraph should integrate naturally into the article, without any heading or subheading. It should subtly close the article by reinforcing the main message or idea, offering a final reflection, or leaving the reader with a powerful takeaway, but without explicitly indicating it is the end.', |
| 36 |
), |
| 37 |
|
| 38 |
// Template 2: SEO Optimized Article |
| 39 |
array( |
| 40 |
'name' => 'SEO Optimized Article', |
| 41 |
'is_default' => 0, |
| 42 |
'content' => 'Write an SEO-optimized blog article following these guidelines: |
| 43 |
|
| 44 |
-Format: HTML with H2-H4 headings and <p> paragraphs. Do NOT use H1. |
| 45 |
-Length: Approximately {{post_length}} words. |
| 46 |
-Language: {{post_language}} |
| 47 |
-Writing style: {{writer_style}} |
| 48 |
-Target keywords: {{prompt_or_keywords}} |
| 49 |
|
| 50 |
SEO Requirements: |
| 51 |
-Include the primary keyword naturally in the first 100 words. |
| 52 |
-Use semantic variations and related terms throughout the content. |
| 53 |
-Structure with clear H2 subheadings that include relevant keywords. |
| 54 |
-Write short paragraphs (2-4 sentences) for better readability. |
| 55 |
-Include a compelling hook in the introduction to reduce bounce rate. |
| 56 |
-Add transitional phrases between sections for better flow. |
| 57 |
|
| 58 |
-IMPORTANT: End the article naturally without using words like "Conclusion", "Summary", "Final Thoughts", or "In conclusion". The last paragraph should reinforce the main message while leaving the reader with actionable value.', |
| 59 |
), |
| 60 |
|
| 61 |
// Template 3: Listicle / List Article |
| 62 |
array( |
| 63 |
'name' => 'Listicle (List Article)', |
| 64 |
'is_default' => 0, |
| 65 |
'content' => 'Write a listicle-style blog article with the following specifications: |
| 66 |
|
| 67 |
-Format: HTML with numbered H2 headings for each list item, and <p> paragraphs for descriptions. |
| 68 |
-Length: Approximately {{post_length}} words. |
| 69 |
-Language: {{post_language}} |
| 70 |
-Writing style: {{writer_style}} |
| 71 |
-Topic keywords: {{prompt_or_keywords}} |
| 72 |
|
| 73 |
Structure: |
| 74 |
-Start with a brief introduction (2-3 paragraphs) explaining what the reader will learn. |
| 75 |
-Each list item should have: a clear H2 heading with number, detailed explanation (2-4 paragraphs), and practical tips or examples. |
| 76 |
-Use bullet points or sub-lists within items when appropriate. |
| 77 |
-Make each item scannable and valuable on its own. |
| 78 |
|
| 79 |
-IMPORTANT: Do not end with a "Conclusion" section. Instead, finish with the last list item and optionally add a brief closing thought that feels natural, not like a summary.', |
| 80 |
), |
| 81 |
|
| 82 |
// Template 4: How-To Guide |
| 83 |
array( |
| 84 |
'name' => 'How-To Guide', |
| 85 |
'is_default' => 0, |
| 86 |
'content' => 'Write a comprehensive how-to guide following these instructions: |
| 87 |
|
| 88 |
-Format: HTML with H2-H3 headings for steps and sections, <p> paragraphs, and bullet/numbered lists where helpful. |
| 89 |
-Length: Approximately {{post_length}} words. |
| 90 |
-Language: {{post_language}} |
| 91 |
-Writing style: {{writer_style}} |
| 92 |
-Topic: {{prompt_or_keywords}} |
| 93 |
|
| 94 |
Structure: |
| 95 |
-Introduction: Explain what the reader will accomplish and why it matters. |
| 96 |
-Prerequisites or requirements section (if applicable). |
| 97 |
-Step-by-step instructions with clear H2 headings for each major step. |
| 98 |
-Include practical tips, warnings, or pro-tips in each step. |
| 99 |
-Add examples or use cases to illustrate key points. |
| 100 |
|
| 101 |
Writing Guidelines: |
| 102 |
-Use action verbs at the beginning of each step. |
| 103 |
-Be specific and avoid vague instructions. |
| 104 |
-Anticipate common mistakes and address them. |
| 105 |
-Write for beginners unless specified otherwise. |
| 106 |
|
| 107 |
-IMPORTANT: End with the final step or a brief "next steps" suggestion. Avoid formal conclusion sections with labels like "Conclusion" or "Summary".', |
| 108 |
), |
| 109 |
|
| 110 |
// Template 5: Product Review |
| 111 |
array( |
| 112 |
'name' => 'Product Review', |
| 113 |
'is_default' => 0, |
| 114 |
'content' => 'Write a detailed and balanced product review article: |
| 115 |
|
| 116 |
-Format: HTML with H2-H3 headings and <p> paragraphs. |
| 117 |
-Length: Approximately {{post_length}} words. |
| 118 |
-Language: {{post_language}} |
| 119 |
-Writing style: {{writer_style}} |
| 120 |
-Product/Topic: {{prompt_or_keywords}} |
| 121 |
|
| 122 |
Review Structure: |
| 123 |
-Introduction: Brief overview of what the product/service is and who it\'s for. |
| 124 |
-Key Features section: List and explain the main features with H3 subheadings. |
| 125 |
-Pros and Cons: Honest assessment of advantages and disadvantages. |
| 126 |
-User Experience: Describe how it feels to use the product. |
| 127 |
-Comparison: Brief comparison with alternatives (if relevant). |
| 128 |
-Who Should Buy This: Target audience recommendations. |
| 129 |
-Value for Money: Assessment of pricing vs. features. |
| 130 |
|
| 131 |
Guidelines: |
| 132 |
-Be objective and balanced - mention both positives and negatives. |
| 133 |
-Use specific examples and details, not generic statements. |
| 134 |
-Include practical scenarios where the product excels or falls short. |
| 135 |
|
| 136 |
-IMPORTANT: End with a clear recommendation without using "Conclusion" or "Final Verdict" as a heading. Just state your honest opinion naturally.', |
| 137 |
), |
| 138 |
|
| 139 |
// Template 6: Comparison Article |
| 140 |
array( |
| 141 |
'name' => 'Comparison Article', |
| 142 |
'is_default' => 0, |
| 143 |
'content' => 'Write a comprehensive comparison article: |
| 144 |
|
| 145 |
-Format: HTML with H2-H3 headings and <p> paragraphs. |
| 146 |
-Length: Approximately {{post_length}} words. |
| 147 |
-Language: {{post_language}} |
| 148 |
-Writing style: {{writer_style}} |
| 149 |
-Comparison topic: {{prompt_or_keywords}} |
| 150 |
|
| 151 |
Article Structure: |
| 152 |
-Introduction: Briefly introduce what\'s being compared and why the comparison matters. |
| 153 |
-Quick Overview: Brief summary of each option. |
| 154 |
-Detailed Comparison Sections (use H2 for each criterion): |
| 155 |
* Feature comparison |
| 156 |
* Pricing comparison |
| 157 |
* Ease of use |
| 158 |
* Performance |
| 159 |
* Best use cases for each |
| 160 |
-Comparison summary (can be a simple list or brief paragraphs). |
| 161 |
|
| 162 |
Guidelines: |
| 163 |
-Be fair and objective to all options. |
| 164 |
-Use specific data and examples when possible. |
| 165 |
-Help readers understand which option fits their specific needs. |
| 166 |
-Avoid declaring an absolute winner - focus on "best for X scenario". |
| 167 |
|
| 168 |
-IMPORTANT: End by helping the reader make a decision based on their needs, without a formal "Conclusion" heading.', |
| 169 |
), |
| 170 |
|
| 171 |
// Template 7: News/Trends Article |
| 172 |
array( |
| 173 |
'name' => 'News & Trends Article', |
| 174 |
'is_default' => 0, |
| 175 |
'content' => 'Write a news or trends article with journalistic quality: |
| 176 |
|
| 177 |
-Format: HTML with H2 headings and <p> paragraphs. |
| 178 |
-Length: Approximately {{post_length}} words. |
| 179 |
-Language: {{post_language}} |
| 180 |
-Writing style: {{writer_style}} |
| 181 |
-Topic: {{prompt_or_keywords}} |
| 182 |
|
| 183 |
Article Structure: |
| 184 |
-Lead paragraph: Answer Who, What, When, Where, Why in the first paragraph. |
| 185 |
-Context section: Background information the reader needs to understand the news. |
| 186 |
-Main body: Detailed coverage of the topic with multiple angles. |
| 187 |
-Expert perspectives or data points to support the story. |
| 188 |
-Implications: What this means for readers or the industry. |
| 189 |
|
| 190 |
Guidelines: |
| 191 |
-Use inverted pyramid structure (most important info first). |
| 192 |
-Keep paragraphs short (1-3 sentences for news style). |
| 193 |
-Cite sources or data when making claims. |
| 194 |
-Maintain objectivity - present facts, not opinions. |
| 195 |
-Use active voice and strong verbs. |
| 196 |
|
| 197 |
-IMPORTANT: End with forward-looking implications or what to watch next. No formal conclusion section needed.', |
| 198 |
), |
| 199 |
|
| 200 |
// Template 8: Beginner's Guide |
| 201 |
array( |
| 202 |
'name' => 'Beginner\'s Guide', |
| 203 |
'is_default' => 0, |
| 204 |
'content' => 'Write a comprehensive beginner\'s guide: |
| 205 |
|
| 206 |
-Format: HTML with H2-H3 headings, <p> paragraphs, and lists where helpful. |
| 207 |
-Length: Approximately {{post_length}} words. |
| 208 |
-Language: {{post_language}} |
| 209 |
-Writing style: {{writer_style}} |
| 210 |
-Topic: {{prompt_or_keywords}} |
| 211 |
|
| 212 |
Structure for Beginners: |
| 213 |
-Introduction: What this guide covers and what they\'ll learn. |
| 214 |
-"What is [Topic]?" section: Clear definition and basic explanation. |
| 215 |
-"Why does it matter?" section: Benefits and importance. |
| 216 |
-Core concepts: Break down fundamental ideas (one H2 per concept). |
| 217 |
-Getting started: First steps for beginners. |
| 218 |
-Common mistakes to avoid. |
| 219 |
-Resources or next steps for further learning. |
| 220 |
|
| 221 |
Writing Guidelines: |
| 222 |
-Avoid jargon or explain technical terms when first used. |
| 223 |
-Use analogies and real-world examples to explain concepts. |
| 224 |
-Assume zero prior knowledge. |
| 225 |
-Build concepts progressively from simple to complex. |
| 226 |
-Be encouraging and supportive in tone. |
| 227 |
|
| 228 |
-IMPORTANT: End with encouragement and a simple first action the reader can take. Avoid formal conclusion headings.', |
| 229 |
), |
| 230 |
|
| 231 |
// Template 9: Expert Deep Dive |
| 232 |
array( |
| 233 |
'name' => 'Expert Deep Dive', |
| 234 |
'is_default' => 0, |
| 235 |
'content' => 'Write an in-depth expert-level article: |
| 236 |
|
| 237 |
-Format: HTML with H2-H4 headings for detailed sections, <p> paragraphs, and technical lists. |
| 238 |
-Length: Approximately {{post_length}} words. |
| 239 |
-Language: {{post_language}} |
| 240 |
-Writing style: {{writer_style}} |
| 241 |
-Topic: {{prompt_or_keywords}} |
| 242 |
|
| 243 |
Expert Content Structure: |
| 244 |
-Introduction: State the advanced topic and what makes this analysis unique. |
| 245 |
-Background context: Brief recap for readers who need it. |
| 246 |
-Core analysis sections (H2 for each major point): |
| 247 |
* Detailed technical explanations |
| 248 |
* Data, research, or case studies |
| 249 |
* Nuanced perspectives and edge cases |
| 250 |
-Practical applications and advanced strategies. |
| 251 |
-Future implications or emerging trends. |
| 252 |
|
| 253 |
Guidelines: |
| 254 |
-Write for an audience with existing knowledge of the subject. |
| 255 |
-Use industry terminology appropriately. |
| 256 |
-Support claims with data, research, or expert references. |
| 257 |
-Explore nuances and edge cases. |
| 258 |
-Provide original insights, not just rehashed information. |
| 259 |
-Include actionable advanced tips. |
| 260 |
|
| 261 |
-IMPORTANT: End with thought-provoking insights or predictions. Skip generic conclusion headings.', |
| 262 |
), |
| 263 |
|
| 264 |
// Template 10: Storytelling/Narrative |
| 265 |
array( |
| 266 |
'name' => 'Storytelling Article', |
| 267 |
'is_default' => 0, |
| 268 |
'content' => 'Write an engaging narrative-style article: |
| 269 |
|
| 270 |
-Format: HTML with H2 headings for sections and <p> paragraphs. |
| 271 |
-Length: Approximately {{post_length}} words. |
| 272 |
-Language: {{post_language}} |
| 273 |
-Writing style: {{writer_style}} |
| 274 |
-Topic: {{prompt_or_keywords}} |
| 275 |
|
| 276 |
Narrative Structure: |
| 277 |
-Hook: Start with a compelling story, question, or surprising fact. |
| 278 |
-Setup: Introduce the context and characters/subjects involved. |
| 279 |
-Rising action: Build tension or curiosity through the narrative. |
| 280 |
-Key insights: Weave educational content into the story naturally. |
| 281 |
-Resolution: Bring the narrative to a satisfying point. |
| 282 |
-Takeaway: What the reader should remember or do. |
| 283 |
|
| 284 |
Storytelling Guidelines: |
| 285 |
-Use vivid descriptions and sensory details. |
| 286 |
-Include dialogue or quotes when appropriate. |
| 287 |
-Create emotional connection with the reader. |
| 288 |
-Balance story with valuable information. |
| 289 |
-Use scene-setting to transport the reader. |
| 290 |
-Show, don\'t tell - use examples instead of abstract statements. |
| 291 |
|
| 292 |
-IMPORTANT: End with the story\'s natural resolution or a powerful final image. No labeled conclusion needed.', |
| 293 |
), |
| 294 |
|
| 295 |
// Template 11: Custom Prompt (Empty) |
| 296 |
array( |
| 297 |
'name' => 'Custom Prompt (Empty)', |
| 298 |
'is_default' => 0, |
| 299 |
'content' => '{{prompt_or_keywords}}', |
| 300 |
), |
| 301 |
); |
| 302 |
} |
| 303 |
|
| 304 |
/** |
| 305 |
* Insert all default templates into the database |
| 306 |
* Called on plugin activation |
| 307 |
*/ |
| 308 |
function botwriter_insert_all_default_templates() { |
| 309 |
global $wpdb; |
| 310 |
$table_name = $wpdb->prefix . 'botwriter_templates'; |
| 311 |
|
| 312 |
// Check if any templates exist |
| 313 |
$existing_count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name"); |
| 314 |
if ($existing_count > 0) { |
| 315 |
return; // Templates already exist, don't overwrite |
| 316 |
} |
| 317 |
|
| 318 |
$templates = botwriter_get_default_templates(); |
| 319 |
|
| 320 |
foreach ($templates as $template) { |
| 321 |
$wpdb->insert( |
| 322 |
$table_name, |
| 323 |
array( |
| 324 |
'name' => $template['name'], |
| 325 |
'content' => $template['content'], |
| 326 |
'is_default' => $template['is_default'], |
| 327 |
) |
| 328 |
); |
| 329 |
} |
| 330 |
} |
| 331 |
|
| 332 |
/** |
| 333 |
* Reset templates to default (delete all and re-insert defaults) |
| 334 |
* Use with caution - this will delete user-created templates |
| 335 |
*/ |
| 336 |
function botwriter_reset_templates_to_default() { |
| 337 |
global $wpdb; |
| 338 |
$table_name = $wpdb->prefix . 'botwriter_templates'; |
| 339 |
|
| 340 |
// Delete all existing templates |
| 341 |
$wpdb->query("TRUNCATE TABLE $table_name"); |
| 342 |
|
| 343 |
// Insert defaults |
| 344 |
botwriter_insert_all_default_templates(); |
| 345 |
} |
| 346 |
|
| 347 |
/** |
| 348 |
* Get a specific default template by name |
| 349 |
* Useful for restoring individual templates |
| 350 |
* |
| 351 |
* @param string $name Template name |
| 352 |
* @return array|null Template data or null if not found |
| 353 |
*/ |
| 354 |
function botwriter_get_default_template_by_name($name) { |
| 355 |
$templates = botwriter_get_default_templates(); |
| 356 |
|
| 357 |
foreach ($templates as $template) { |
| 358 |
if ($template['name'] === $name) { |
| 359 |
return $template; |
| 360 |
} |
| 361 |
} |
| 362 |
|
| 363 |
return null; |
| 364 |
} |
| 365 |
|