| 1 |
<?php |
| 2 |
/** |
| 3 |
* Site Identity Prompts Class |
| 4 |
* |
| 5 |
* Handles site identity optimization AI prompts. |
| 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 |
* Site Identity Prompts Class |
| 24 |
* |
| 25 |
* Centralized site identity prompt building for consistent AI optimization across all providers. |
| 26 |
* Handles site name, description, tagline, and meta description optimization. |
| 27 |
* |
| 28 |
* @since 1.0.0 |
| 29 |
*/ |
| 30 |
class Site_Identity_Prompts { |
| 31 |
|
| 32 |
/** |
| 33 |
* Build site identity optimization prompt |
| 34 |
* |
| 35 |
* @since 1.0.0 |
| 36 |
* |
| 37 |
* @param array $site_data Site data to optimize |
| 38 |
* @param string $business_type Business type |
| 39 |
* @param string $target_audience Target audience |
| 40 |
* @param string $tone Desired tone |
| 41 |
* @param string $provider AI provider |
| 42 |
* @return string Formatted prompt |
| 43 |
*/ |
| 44 |
public function build_site_identity_prompt(array $site_data, string $business_type, string $target_audience, string $tone, string $provider = 'openai'): string { |
| 45 |
$current_name = $site_data['site_name'] ?? ''; |
| 46 |
$current_description = $site_data['site_description'] ?? ''; |
| 47 |
$current_tagline = $site_data['tagline'] ?? ''; |
| 48 |
$current_meta_description = $site_data['default_meta_description'] ?? ''; |
| 49 |
|
| 50 |
// Provider-specific introduction |
| 51 |
$intro = ''; |
| 52 |
switch ($provider) { |
| 53 |
case 'claude': |
| 54 |
$intro = "As an expert SEO consultant, analyze and optimize this site identity for SEO and user engagement:"; |
| 55 |
break; |
| 56 |
case 'openai': |
| 57 |
default: |
| 58 |
$intro = "Analyze and optimize this site identity for SEO and user engagement:"; |
| 59 |
break; |
| 60 |
} |
| 61 |
|
| 62 |
return "{$intro} |
| 63 |
|
| 64 |
Current Site Information: |
| 65 |
- Site Name: \"{$current_name}\" |
| 66 |
- Site Description: \"{$current_description}\" |
| 67 |
- Tagline: \"{$current_tagline}\" |
| 68 |
- Default Meta Description: \"{$current_meta_description}\" |
| 69 |
|
| 70 |
Business Context: |
| 71 |
- Business Type: {$business_type} |
| 72 |
- Target Audience: {$target_audience} |
| 73 |
- Desired Tone: {$tone} |
| 74 |
|
| 75 |
Please provide optimization recommendations in this exact JSON format: |
| 76 |
{ |
| 77 |
\"optimized_data\": { |
| 78 |
\"site_name\": \"optimized site name (if improvement needed)\", |
| 79 |
\"site_description\": \"optimized description (150-160 chars, SEO-friendly)\", |
| 80 |
\"tagline\": \"optimized tagline (concise, memorable)\", |
| 81 |
\"default_meta_description\": \"optimized default meta description (150-160 chars, SEO-friendly)\" |
| 82 |
}, |
| 83 |
\"analysis\": \"Brief analysis of current identity and optimization rationale\", |
| 84 |
\"suggestions\": [ |
| 85 |
\"Specific actionable suggestion 1\", |
| 86 |
\"Specific actionable suggestion 2\", |
| 87 |
\"Specific actionable suggestion 3\" |
| 88 |
], |
| 89 |
\"score\": 85 |
| 90 |
} |
| 91 |
|
| 92 |
Focus on: |
| 93 |
1. SEO optimization (keywords, length, clarity) |
| 94 |
2. Brand consistency and memorability |
| 95 |
3. Target audience appeal |
| 96 |
4. Search engine visibility |
| 97 |
5. User engagement potential |
| 98 |
|
| 99 |
Only suggest changes if they provide clear improvements. If current content is already well-optimized, indicate so in the analysis."; |
| 100 |
} |
| 101 |
} |
| 102 |
|