| 1 |
<?php |
| 2 |
/** |
| 3 |
* Homepage Prompts Class |
| 4 |
* |
| 5 |
* Handles homepage-related AI prompts including meta content and hero section optimization. |
| 6 |
* Preserves exact functionality from original OpenAI and Claude client implementations. |
| 7 |
* |
| 8 |
* @package ThinkRank |
| 9 |
* @subpackage AI\Prompts |
| 10 |
* @since 1.0.0 |
| 11 |
*/ |
| 12 |
|
| 13 |
declare(strict_types=1); |
| 14 |
|
| 15 |
namespace ThinkRank\AI\Prompts; |
| 16 |
|
| 17 |
// Prevent direct access |
| 18 |
if (!defined('ABSPATH')) { |
| 19 |
exit; |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Homepage Prompts Class |
| 24 |
* |
| 25 |
* Centralized homepage prompt building for consistent AI optimization across all providers. |
| 26 |
* Handles homepage meta content and hero section optimization. |
| 27 |
* |
| 28 |
* @since 1.0.0 |
| 29 |
*/ |
| 30 |
class Homepage_Prompts { |
| 31 |
|
| 32 |
/** |
| 33 |
* Build homepage meta optimization prompt |
| 34 |
* |
| 35 |
* @since 1.0.0 |
| 36 |
* |
| 37 |
* @param array $content_data Meta content data |
| 38 |
* @param string $business_type Business type |
| 39 |
* @param string $target_audience Target audience |
| 40 |
* @param string $tone Content tone |
| 41 |
* @param array $context Additional context information |
| 42 |
* @param string $provider AI provider |
| 43 |
* @return string Optimization prompt |
| 44 |
*/ |
| 45 |
public function build_homepage_meta_prompt(array $content_data, string $business_type, string $target_audience, string $tone, array $context = [], string $provider = 'openai'): string { |
| 46 |
$current_title = $content_data['title'] ?? ''; |
| 47 |
$current_meta_description = $content_data['meta_description'] ?? ''; |
| 48 |
|
| 49 |
// Extract context information |
| 50 |
$site_name = $context['site_name'] ?? 'the website'; |
| 51 |
$site_url = $context['site_url'] ?? ''; |
| 52 |
$hero_title = $context['hero_title'] ?? ''; |
| 53 |
$hero_subtitle = $context['hero_subtitle'] ?? ''; |
| 54 |
|
| 55 |
$context_info = ''; |
| 56 |
if (!empty($site_name) && $site_name !== 'the website') { |
| 57 |
$context_info .= "- Website Name: {$site_name}\n"; |
| 58 |
} |
| 59 |
if (!empty($hero_title)) { |
| 60 |
$context_info .= "- Hero Title: {$hero_title}\n"; |
| 61 |
} |
| 62 |
if (!empty($hero_subtitle)) { |
| 63 |
$context_info .= "- Hero Subtitle: {$hero_subtitle}\n"; |
| 64 |
} |
| 65 |
|
| 66 |
return "As an expert SEO consultant, analyze and optimize this homepage meta content for SEO and user engagement: |
| 67 |
|
| 68 |
Current Meta Information: |
| 69 |
- Title: \"{$current_title}\" |
| 70 |
- Meta Description: \"{$current_meta_description}\" |
| 71 |
|
| 72 |
Website Context: |
| 73 |
{$context_info} |
| 74 |
Business Context: |
| 75 |
- Business Type: {$business_type} |
| 76 |
- Target Audience: {$target_audience} |
| 77 |
- Desired Tone: {$tone} |
| 78 |
|
| 79 |
Please provide optimization recommendations in this exact JSON format: |
| 80 |
{ |
| 81 |
\"optimized_data\": { |
| 82 |
\"title\": \"optimized title (50-60 chars, SEO-friendly)\", |
| 83 |
\"meta_description\": \"optimized meta description (150-160 chars, SEO-friendly)\" |
| 84 |
}, |
| 85 |
\"analysis\": \"Brief analysis of current meta content and optimization rationale\", |
| 86 |
\"suggestions\": [ |
| 87 |
\"Specific actionable suggestion 1\", |
| 88 |
\"Specific actionable suggestion 2\", |
| 89 |
\"Specific actionable suggestion 3\" |
| 90 |
], |
| 91 |
\"score\": 85 |
| 92 |
} |
| 93 |
|
| 94 |
Focus on: |
| 95 |
1. SEO optimization (keywords, length, clarity) |
| 96 |
2. Click-through rate optimization |
| 97 |
3. Target audience appeal |
| 98 |
4. Search engine visibility |
| 99 |
5. User engagement potential |
| 100 |
|
| 101 |
Only suggest changes if they provide clear improvements. If current content is already well-optimized, indicate so in the analysis."; |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Build homepage hero optimization prompt |
| 106 |
* |
| 107 |
* @since 1.0.0 |
| 108 |
* |
| 109 |
* @param array $hero_data Hero content data |
| 110 |
* @param string $business_type Business type |
| 111 |
* @param string $target_audience Target audience |
| 112 |
* @param string $tone Content tone |
| 113 |
* @param array $context Additional context information |
| 114 |
* @param string $provider AI provider |
| 115 |
* @return string Optimization prompt |
| 116 |
*/ |
| 117 |
public function build_homepage_hero_prompt(array $hero_data, string $business_type, string $target_audience, string $tone, array $context = [], string $provider = 'openai'): string { |
| 118 |
$current_title = $hero_data['hero_title'] ?? ''; |
| 119 |
$current_subtitle = $hero_data['hero_subtitle'] ?? ''; |
| 120 |
$current_cta_text = $hero_data['hero_cta_text'] ?? ''; |
| 121 |
$current_cta_url = $hero_data['hero_cta_url'] ?? ''; |
| 122 |
|
| 123 |
// Extract context information |
| 124 |
$site_name = $context['site_name'] ?? 'the website'; |
| 125 |
$site_url = $context['site_url'] ?? ''; |
| 126 |
$homepage_title = $context['homepage_title'] ?? ''; |
| 127 |
$homepage_meta_description = $context['homepage_meta_description'] ?? ''; |
| 128 |
|
| 129 |
$context_info = ''; |
| 130 |
if (!empty($site_name) && $site_name !== 'the website') { |
| 131 |
$context_info .= "- Website Name: {$site_name}\n"; |
| 132 |
} |
| 133 |
if (!empty($homepage_title)) { |
| 134 |
$context_info .= "- Homepage Title: {$homepage_title}\n"; |
| 135 |
} |
| 136 |
if (!empty($homepage_meta_description)) { |
| 137 |
$context_info .= "- Homepage Description: {$homepage_meta_description}\n"; |
| 138 |
} |
| 139 |
|
| 140 |
return "As an expert conversion optimization specialist, analyze and optimize this homepage hero section for conversions and engagement: |
| 141 |
|
| 142 |
Current Hero Section: |
| 143 |
- Hero Title: \"{$current_title}\" |
| 144 |
- Hero Subtitle: \"{$current_subtitle}\" |
| 145 |
- CTA Text: \"{$current_cta_text}\" |
| 146 |
- CTA URL: \"{$current_cta_url}\" |
| 147 |
|
| 148 |
Website Context: |
| 149 |
{$context_info} |
| 150 |
Business Context: |
| 151 |
- Business Type: {$business_type} |
| 152 |
- Target Audience: {$target_audience} |
| 153 |
- Desired Tone: {$tone} |
| 154 |
|
| 155 |
Please provide optimization recommendations in this exact JSON format: |
| 156 |
{ |
| 157 |
\"optimized_data\": { |
| 158 |
\"hero_title\": \"optimized hero title (compelling, clear value proposition)\", |
| 159 |
\"hero_subtitle\": \"optimized hero subtitle (supporting details, benefits)\", |
| 160 |
\"hero_cta_text\": \"optimized CTA text (action-oriented, compelling)\" |
| 161 |
}, |
| 162 |
\"analysis\": \"Brief analysis of current hero section and optimization rationale\", |
| 163 |
\"suggestions\": [ |
| 164 |
\"Specific actionable suggestion 1\", |
| 165 |
\"Specific actionable suggestion 2\", |
| 166 |
\"Specific actionable suggestion 3\" |
| 167 |
], |
| 168 |
\"score\": 85 |
| 169 |
} |
| 170 |
|
| 171 |
Focus on: |
| 172 |
1. Conversion optimization (clear value proposition, compelling CTA text) |
| 173 |
2. User engagement and clarity |
| 174 |
3. Target audience appeal |
| 175 |
4. Brand consistency |
| 176 |
5. Action-oriented messaging |
| 177 |
|
| 178 |
Note: Do not generate or suggest URLs. Focus only on optimizing the text content. |
| 179 |
|
| 180 |
Only suggest changes if they provide clear improvements. If current content is already well-optimized, indicate so in the analysis."; |
| 181 |
} |
| 182 |
} |
| 183 |
|