base_url . '/generateRandomDocId'; return $this->sendGetRequest($url); } public function generateRandomKey() { $url = $this->base_url . '/generateRandomKey'; return $this->sendGetRequest($url); } public function maskdown($text) { // Check if text is null or empty if ($text === null || $text === '') { return ''; } $Parsedown = new Parsedown(); $cleaned_text = $this->removeImageTags($text); // Ensure cleaned text is not null if ($cleaned_text === null || $cleaned_text === '') { return ''; } $html = $Parsedown->text($cleaned_text); return $html ?: ''; } public function removeImageTags($inputString) { // Handle null or non-string input if ($inputString === null) { return ''; } // Convert to string if not already if (!is_string($inputString)) { $inputString = (string) $inputString; } if(!empty($inputString)){ $pattern = '/\[Image[^\]]*\]/'; $replacement = ''; $outputString = preg_replace($pattern, $replacement, $inputString); return $outputString ?: ''; }else{ return ''; } } public function bardrewrite($question, $lang = 'Vietnamese',$toneOfVoice='') { $url = $this->base_url . '/bardrewrite'; $data = ['question' => $question, 'lang' => $lang,'toneOfVoice'=>$toneOfVoice]; $response = $this->sendPostRequestFull($url, $data); // Check if API returned error code if (isset($response['code']) && $response['code'] != '200' && $response['code'] != 200) { // Return full response with error code and message return $response; } // If successful, return masked result if (isset($response['result']) && $response['result'] !== false) { return $this->maskdown($response['result']); } return $response; } public function bardcontentfull($question, $lang = 'Vietnamese') { $url = $this->base_url . '/bardcontentfull'; $data = ['question' => $question, 'lang' => $lang]; return $this->maskdown($this->sendPostRequest($url, $data)); } public function bardcontent($question, $lang = 'Vietnamese') { $url = $this->base_url . '/bardcontent'; $data = ['question' => $question, 'lang' => $lang]; $response = $this->sendPostRequestFull($url, $data); // Check if API returned error code if (isset($response['code']) && $response['code'] != '200' && $response['code'] != 200) { // Return full response with error code and message return $response; } // If successful, return masked result if (isset($response['result']) && $response['result'] !== false) { return $this->maskdown($response['result']); } return $response; } public function bardcontentRaw($question, $lang = 'Vietnamese') { $url = $this->base_url . '/bardcontent'; $data = ['question' => $question, 'lang' => $lang]; return $this->sendPostRequest($url, $data); } public function bardcontentmore($question, $lang = 'Vietnamese'){ $url = $this->base_url . '/bardcontentmore'; $data = ['question' => $question, 'lang' => $lang]; $response = $this->sendPostRequestFull($url, $data); // Check if API returned error code if (isset($response['code']) && $response['code'] != '200' && $response['code'] != 200) { // Return full response with error code and message return $response; } // If successful, return masked result if (isset($response['result']) && $response['result'] !== false) { return $this->maskdown($response['result']); } return $response; } /** // Tạo prompt cho bài viết hoàn chỉnh $prompt = $this->generateFullArticlePrompt($keywords, $lang, $chapters, $words); // Sử dụng API bardcontentmore hiện có $url = $this->base_url . '/bardcontentmore'; $data = [ 'question' => $prompt, 'lang' => $lang ]; $result = $this->sendPostRequest($url, $data); // Xử lý kết quả để tạo cấu trúc bài viết return $this->processFullArticleResult($result, $keywords, $chapters, $words); } /** * Tạo prompt cho bài viết hoàn chỉnh */ private function generateFullArticlePrompt($keywords, $lang, $chapters, $words) { $wordsPerChapter = round($words / $chapters); $prompt = "Viết một bài viết hoàn chỉnh về chủ đề: {$keywords}\n\n"; $prompt .= "Yêu cầu:\n"; $prompt .= "- Tạo {$chapters} chapters với cấu trúc logic\n"; $prompt .= "- Mỗi chapter khoảng {$wordsPerChapter} từ\n"; $prompt .= "- Tổng cộng khoảng {$words} từ\n"; $prompt .= "- Bao gồm introduction và conclusion\n"; $prompt .= "- Sử dụng HTML formatting (h2, p, ul, li, strong, em)\n"; $prompt .= "- Viết bằng {$lang}\n"; $prompt .= "- Tối ưu SEO\n"; $prompt .= "- Nội dung chất lượng cao và hữu ích\n\n"; $prompt .= "Cấu trúc bài viết:\n"; $prompt .= "1. Introduction (giới thiệu chủ đề)\n"; for ($i = 1; $i <= $chapters; $i++) { $prompt .= ($i + 1) . ". Chapter {$i} (nội dung chính)\n"; } $prompt .= ($chapters + 2) . ". Conclusion (kết luận)\n\n"; $prompt .= "Hãy viết bài viết hoàn chỉnh với đầy đủ các phần trên."; return $prompt; } /** * Xử lý kết quả để tạo cấu trúc bài viết */ private function processFullArticleResult($result, $keywords, $chapters, $words) { // Tạo title từ keywords $title = $this->generateTitleFromKeywords($keywords); // Tạo tags từ keywords $tags = $this->generateTagsFromKeywords($keywords); return [ 'title' => $title, 'article' => $result, 'tags' => $tags, 'keywords' => $keywords, 'chapters' => $chapters, 'words' => $words ]; } /** * Tạo title từ keywords */ /** * Tạo tags từ keywords */ public function gentitle($question, $lang = 'Vietnamese') { $url = $this->base_url . '/gentitle'; $data = ['question' => $question, 'lang' => $lang]; return $this->sendPostRequest($url, $data); } /** * Generate ideas/titles for blog posts * @param string $lang Language for generation * @param int $count Number of ideas to generate (default: 10) * @return array Array of idea objects with 'title' property */ public function generateIdeas($lang = 'Vietnamese', $count = 10) { // Try to use dedicated API endpoint if available $url = $this->base_url . '/generateIdeas'; $data = ['lang' => $lang, 'count' => $count]; try { $result = $this->sendPostRequest($url, $data); // Check if result is valid if ($result === null || $result === false) { return $this->generateIdeasFallback($lang, $count); } // If result is array, return as is if (is_array($result)) { // Ensure each item has 'title' property $ideas = array_map(function($item) { if (is_string($item)) { return ['title' => $item]; } elseif (is_array($item) && isset($item['title'])) { return $item; } elseif (is_array($item) && isset($item[0])) { return ['title' => $item[0]]; } return ['title' => is_string($item) ? $item : '']; }, $result); if (!empty($ideas)) { return array_slice($ideas, 0, $count); } } // If result is string, try to parse it as JSON or split by newlines if (is_string($result) && !empty($result)) { $decoded = json_decode($result, true); if (is_array($decoded)) { $ideas = array_map(function($item) { return ['title' => is_array($item) ? ($item['title'] ?? $item[0] ?? '') : $item]; }, $decoded); if (!empty($ideas)) { return array_slice($ideas, 0, $count); } } // Split by newlines if it's a text string $lines = array_filter(array_map('trim', explode("\n", $result))); if (!empty($lines)) { $ideas = array_map(function($line) { // Remove numbering (1., 2., etc.) $line = preg_replace('/^\d+[\.\)]\s*/', '', $line); $line = trim($line); return ['title' => $line]; }, array_slice($lines, 0, $count)); if (!empty($ideas)) { return $ideas; } } } } catch (Exception $e) { // Fallback: use bardcontentmore to generate ideas if (defined('WP_DEBUG') && WP_DEBUG) { error_log('BardGenContent::generateIdeas() API error: ' . $e->getMessage()); } } catch (Error $e) { // Fallback: use bardcontentmore to generate ideas if (defined('WP_DEBUG') && WP_DEBUG) { error_log('BardGenContent::generateIdeas() Fatal error: ' . $e->getMessage()); } } // Fallback if API doesn't work return $this->generateIdeasFallback($lang, $count); } /** * Fallback method to generate ideas using bardcontentmore */ private function generateIdeasFallback($lang = 'Vietnamese', $count = 10) { $prompt = "Hãy tạo danh sách {$count} ý tưởng tiêu đề bài viết blog hấp dẫn và SEO-friendly. "; $prompt .= "Mỗi tiêu đề nên ngắn gọn, hấp dẫn và dễ hiểu. "; $prompt .= "Trả về danh sách dạng:\n"; $prompt .= "1. Tiêu đề 1\n"; $prompt .= "2. Tiêu đề 2\n"; $prompt .= "...\n"; $prompt .= "Viết bằng {$lang}"; try { $result = $this->bardcontentmore($prompt, $lang); if (!empty($result)) { // Parse the result to extract titles $lines = array_filter(array_map('trim', explode("\n", strip_tags($result)))); $ideas = []; foreach ($lines as $line) { // Remove numbering and bullet points $line = preg_replace('/^[\d\-\*\•\◦]\s*/', '', $line); $line = preg_replace('/^\d+[\.\)]\s*/', '', $line); $line = trim($line); if (!empty($line) && strlen($line) > 10) { $ideas[] = ['title' => $line]; if (count($ideas) >= $count) { break; } } } if (!empty($ideas)) { return $ideas; } } } catch (Exception $e) { // Continue to default fallback } // Default fallback: return some generic ideas $defaultIdeas = [ ['title' => 'Cách bắt đầu với ' . $lang], ['title' => 'Hướng dẫn chi tiết về ' . $lang], ['title' => 'Tips và tricks cho ' . $lang], ['title' => 'Những điều cần biết về ' . $lang], ['title' => 'Best practices cho ' . $lang], ]; return array_slice($defaultIdeas, 0, min($count, count($defaultIdeas))); } public function searchimg($question) { $url = $this->base_url . '/searchimg'; $data = ['question' => $question]; return $this->sendPostRequest($url, $data); } private function sendGetRequest($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); return $response; } private function sendPostRequest($url, $data) { $data['info'] = rendersetting::aiautotool_getdata(); $data['domain'] = get_option('home'); // Debug log: URL and request data if (defined('WP_DEBUG') && WP_DEBUG) { error_log('=== BardGenContent::sendPostRequest() DEBUG START ==='); error_log('API URL: ' . $url); error_log('Request Data: ' . json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); } $json_data = json_encode($data); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); $response = curl_exec($ch); $curl_error = curl_error($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); // Debug log: Response info if (defined('WP_DEBUG') && WP_DEBUG) { error_log('HTTP Status Code: ' . $http_code); error_log('Response Length: ' . (is_string($response) ? strlen($response) : 'N/A')); if ($response !== false && strlen($response) > 0) { // Log first 500 chars of response for debugging (truncate if too long) $response_preview = strlen($response) > 500 ? substr($response, 0, 500) . '...' : $response; error_log('Response Preview: ' . $response_preview); } } // Check for curl errors if ($response === false || !empty($curl_error)) { if (defined('WP_DEBUG') && WP_DEBUG) { error_log('BardGenContent::sendPostRequest() curl error: ' . $curl_error); error_log('=== BardGenContent::sendPostRequest() DEBUG END (ERROR) ==='); } return null; } // Check HTTP status code if ($http_code !== 200) { if (defined('WP_DEBUG') && WP_DEBUG) { error_log('BardGenContent::sendPostRequest() HTTP error: ' . $http_code); error_log('Response Body: ' . (is_string($response) ? substr($response, 0, 500) : 'N/A')); error_log('=== BardGenContent::sendPostRequest() DEBUG END (HTTP ERROR) ==='); } return null; } // Decode JSON response $decoded = json_decode($response); // Check if decode was successful and response has result property if ($decoded === null || json_last_error() !== JSON_ERROR_NONE) { if (defined('WP_DEBUG') && WP_DEBUG) { error_log('BardGenContent::sendPostRequest() JSON decode error: ' . json_last_error_msg()); error_log('Raw Response: ' . (is_string($response) ? substr($response, 0, 500) : 'N/A')); error_log('=== BardGenContent::sendPostRequest() DEBUG END (JSON ERROR) ==='); } return null; } // Debug log: Decoded response structure if (defined('WP_DEBUG') && WP_DEBUG) { error_log('Decoded Response Keys: ' . (is_object($decoded) ? implode(', ', array_keys((array)$decoded)) : 'N/A')); } // Check if result property exists if (!isset($decoded->result)) { if (defined('WP_DEBUG') && WP_DEBUG) { error_log('BardGenContent::sendPostRequest() missing result property'); error_log('Available properties: ' . (is_object($decoded) ? implode(', ', array_keys((array)$decoded)) : 'N/A')); error_log('Full Decoded Response: ' . json_encode($decoded, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); error_log('=== BardGenContent::sendPostRequest() DEBUG END (NO RESULT) ==='); } return null; } // Debug log: Success if (defined('WP_DEBUG') && WP_DEBUG) { $result_preview = is_string($decoded->result) ? (strlen($decoded->result) > 200 ? substr($decoded->result, 0, 200) . '...' : $decoded->result) : 'N/A'; error_log('Result Length: ' . (is_string($decoded->result) ? strlen($decoded->result) : 'N/A')); error_log('Result Preview: ' . $result_preview); error_log('=== BardGenContent::sendPostRequest() DEBUG END (SUCCESS) ==='); } return $decoded->result; } /** * Send POST request and return full response including code and msg */ private function sendPostRequestFull($url, $data) { $data['info'] = rendersetting::aiautotool_getdata(); $data['domain'] = get_option('home'); // Debug log: URL and request data if (defined('WP_DEBUG') && WP_DEBUG) { error_log('=== BardGenContent::sendPostRequestFull() DEBUG START ==='); error_log('API URL: ' . $url); error_log('Request Data: ' . json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); } $json_data = json_encode($data); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); $response = curl_exec($ch); $curl_error = curl_error($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); // Debug log: Response info if (defined('WP_DEBUG') && WP_DEBUG) { error_log('HTTP Status Code: ' . $http_code); error_log('Response Length: ' . (is_string($response) ? strlen($response) : 'N/A')); if ($response !== false && strlen($response) > 0) { $response_preview = strlen($response) > 500 ? substr($response, 0, 500) . '...' : $response; error_log('Response Preview: ' . $response_preview); } } // Check for curl errors if ($response === false || !empty($curl_error)) { if (defined('WP_DEBUG') && WP_DEBUG) { error_log('BardGenContent::sendPostRequestFull() curl error: ' . $curl_error); error_log('=== BardGenContent::sendPostRequestFull() DEBUG END (ERROR) ==='); } return array( 'code' => '500', 'msg' => 'Network error: ' . $curl_error, 'result' => false ); } // Check HTTP status code if ($http_code !== 200) { if (defined('WP_DEBUG') && WP_DEBUG) { error_log('BardGenContent::sendPostRequestFull() HTTP error: ' . $http_code); error_log('Response Body: ' . (is_string($response) ? substr($response, 0, 500) : 'N/A')); error_log('=== BardGenContent::sendPostRequestFull() DEBUG END (HTTP ERROR) ==='); } return array( 'code' => '500', 'msg' => 'HTTP error: ' . $http_code, 'result' => false ); } // Decode JSON response $decoded = json_decode($response, true); // Use true to get associative array // Check if decode was successful if ($decoded === null || json_last_error() !== JSON_ERROR_NONE) { if (defined('WP_DEBUG') && WP_DEBUG) { error_log('BardGenContent::sendPostRequestFull() JSON decode error: ' . json_last_error_msg()); error_log('Raw Response: ' . (is_string($response) ? substr($response, 0, 500) : 'N/A')); error_log('=== BardGenContent::sendPostRequestFull() DEBUG END (JSON ERROR) ==='); } return array( 'code' => '500', 'msg' => 'Invalid response from server', 'result' => false ); } // Debug log: Decoded response structure if (defined('WP_DEBUG') && WP_DEBUG) { error_log('Decoded Response Keys: ' . (is_array($decoded) ? implode(', ', array_keys($decoded)) : 'N/A')); error_log('Response Code: ' . (isset($decoded['code']) ? $decoded['code'] : 'N/A')); error_log('Response Message: ' . (isset($decoded['msg']) ? $decoded['msg'] : 'N/A')); error_log('=== BardGenContent::sendPostRequestFull() DEBUG END ==='); } // Decode HTML entities in result if it's a string $decoded_result = isset($decoded['result']) ? $decoded['result'] : false; if (is_string($decoded_result) && !empty($decoded_result)) { // Decode HTML entities (like < to <, > to >, etc.) $decoded_result = html_entity_decode($decoded_result, ENT_QUOTES | ENT_HTML5, 'UTF-8'); } // Return full response array with code, msg, and result $result = array( 'code' => isset($decoded['code']) ? $decoded['code'] : '200', 'msg' => isset($decoded['msg']) ? $decoded['msg'] : 'Success', 'result' => $decoded_result ); return $result; } /** try { // Bước 1: Tạo cấu trúc bài viết $structure = $this->generateArticleStructure($keywords, $lang, $chapters); // Bước 2: Tạo introduction $introduction = $this->generateIntroduction($keywords, $lang); // Bước 3: Tạo từng chapter $chapterContent = []; for ($i = 1; $i <= $chapters; $i++) { $chapterPrompt = $structure['chapters'][$i - 1]; $chapterContent[] = $this->generateChapter($chapterPrompt, $lang, $i); } // Bước 4: Tạo conclusion $conclusion = $this->generateConclusion($keywords, $lang); // Bước 5: Ghép tất cả lại $fullArticle = $this->assembleFullArticle($introduction, $chapterContent, $conclusion); // Bước 6: Tạo title và tags $title = $this->generateTitleFromKeywords($keywords); $tags = $this->generateTagsFromKeywords($keywords); return [ 'title' => $title, 'article' => $fullArticle, 'tags' => $tags, 'keywords' => $keywords, 'chapters' => $chapters, 'words' => $words, 'structure' => $structure ]; } catch (Exception $e) { // Fallback về method đơn giản nếu có lỗi return $this->writefullarticle($keywords, $lang, $chapters, $words); } } /** * Tạo cấu trúc bài viết */ private function generateArticleStructure($keywords, $lang, $chapters) { $prompt = "Tạo cấu trúc chi tiết cho bài viết về: {$keywords}\n\n"; $prompt .= "Yêu cầu:\n"; $prompt .= "- Tạo {$chapters} chapters với tiêu đề cụ thể\n"; $prompt .= "- Mỗi chapter cần có prompt để viết nội dung\n"; $prompt .= "- Cấu trúc logic và mạch lạc\n"; $prompt .= "- Viết bằng {$lang}\n\n"; $prompt .= "Format trả về JSON:\n"; $prompt .= '{"title": "Tiêu đề bài viết", "subtitle": "Phụ đề", "chapters": [{"title": "Tiêu đề chapter 1", "prompt": "Prompt để viết chapter 1"}, ...]}'; $url = $this->base_url . '/bardcontentmore'; $data = ['question' => $prompt, 'lang' => $lang]; $result = $this->sendPostRequest($url, $data); // Parse JSON result $structure = json_decode($result, true); if (!$structure) { // Fallback structure $structure = [ 'title' => ucfirst($keywords), 'subtitle' => 'Hướng dẫn chi tiết', 'chapters' => [] ]; for ($i = 1; $i <= $chapters; $i++) { $structure['chapters'][] = [ 'title' => "Chapter {$i}", 'prompt' => "Viết nội dung cho chapter {$i} về {$keywords}" ]; } } return $structure; } /** * Tạo introduction */ private function generateIntroduction($keywords, $lang) { $prompt = "Viết phần giới thiệu (introduction) cho bài viết về: {$keywords}\n\n"; $prompt .= "Yêu cầu:\n"; $prompt .= "- Khoảng 100-150 từ\n"; $prompt .= "- Giới thiệu chủ đề một cách hấp dẫn\n"; $prompt .= "- Sử dụng HTML formatting\n"; $prompt .= "- Viết bằng {$lang}\n"; $prompt .= "- Không cần tiêu đề 'Introduction'"; $url = $this->base_url . '/bardcontentmore'; $data = ['question' => $prompt, 'lang' => $lang]; return $this->sendPostRequest($url, $data); } /** * Tạo chapter */ private function generateChapter($chapterPrompt, $lang, $chapterNumber) { $prompt = "Viết nội dung cho chapter {$chapterNumber}:\n\n"; $prompt .= "Tiêu đề: {$chapterPrompt['title']}\n"; $prompt .= "Prompt: {$chapterPrompt['prompt']}\n\n"; $prompt .= "Yêu cầu:\n"; $prompt .= "- Khoảng 300-400 từ\n"; $prompt .= "- Sử dụng HTML formatting (h2, p, ul, li, strong, em)\n"; $prompt .= "- Viết bằng {$lang}\n"; $prompt .= "- Nội dung chất lượng cao và hữu ích"; $url = $this->base_url . '/bardcontentmore'; $data = ['question' => $prompt, 'lang' => $lang]; return $this->sendPostRequest($url, $data); } /** * Tạo conclusion */ private function generateConclusion($keywords, $lang) { $prompt = "Viết phần kết luận (conclusion) cho bài viết về: {$keywords}\n\n"; $prompt .= "Yêu cầu:\n"; $prompt .= "- Khoảng 100-150 từ\n"; $prompt .= "- Tóm tắt những điểm chính\n"; $prompt .= "- Đưa ra kết luận hoặc gợi ý\n"; $prompt .= "- Sử dụng HTML formatting\n"; $prompt .= "- Viết bằng {$lang}\n"; $prompt .= "- Không cần tiêu đề 'Conclusion'"; $url = $this->base_url . '/bardcontentmore'; $data = ['question' => $prompt, 'lang' => $lang]; return $this->sendPostRequest($url, $data); } /** * Ghép bài viết hoàn chỉnh */ private function assembleFullArticle($introduction, $chapterContent, $conclusion) { $article = ''; // Thêm introduction $article .= $introduction . "\n\n"; // Thêm từng chapter foreach ($chapterContent as $index => $content) { $article .= $content . "\n\n"; } // Thêm conclusion $article .= $conclusion; return $article; } /** // Tạo prompt tối ưu cho bài viết hoàn chỉnh $prompt = $this->createOptimizedPrompt($keywords, $lang, $chapters, $words); // Sử dụng API bardcontentmore hiện có $url = $this->base_url . '/bardcontentmore'; $data = [ 'question' => $prompt, 'lang' => $lang ]; $result = $this->sendPostRequest($url, $data); // Xử lý kết quả return $this->processSimpleResult($result, $keywords, $chapters, $words); } /** * Tạo prompt tối ưu cho bài viết hoàn chỉnh */ private function createOptimizedPrompt($keywords, $lang, $chapters, $words) { $wordsPerChapter = round($words / $chapters); $prompt = "Viết một bài viết hoàn chỉnh và chuyên nghiệp về chủ đề: {$keywords}\n\n"; $prompt .= "YÊU CẦU CHI TIẾT:\n"; $prompt .= "1. Cấu trúc bài viết:\n"; $prompt .= " - Phần giới thiệu (Introduction) - khoảng 150 từ\n"; $prompt .= " - {$chapters} chapters chính - mỗi chapter khoảng {$wordsPerChapter} từ\n"; $prompt .= " - Phần kết luận (Conclusion) - khoảng 150 từ\n"; $prompt .= " - Tổng cộng khoảng {$words} từ\n\n"; $prompt .= "2. Format và style:\n"; $prompt .= " - Sử dụng HTML tags:
cho đoạn văn\n";
$prompt .= " - Sử dụng và cho nhấn mạnh\n";
$prompt .= " - Sử dụng và
', '
'], $content);
return $content;
}
/**
* Write Full Article with Real Progress Tracking
* @param string $keywords - Keywords chính của bài viết
* @param string $lang - Ngôn ngữ
* @param int $chapters - Số lượng chapters (mặc định 5)
* @param int $words - Số từ tối đa (mặc định 2000)
* @return array - Mảng chứa title, article content, tags và progress info
*/
/**
* Generate basic article - final fallback
*/
/**
* Analyze keywords and topic
*/
/**
* Create article structure
*/
/**
* Generate article content
*/
/**
* Finalize article
*/
/**
* Update progress - Store in WordPress transient
*/
}