function chatgpt_seo_title_generate() { check_ajax_referer('chatgpt_seo_title_nonce', 'nonce'); $attachment_id = intval($_POST['attachment_id']); $attachment = get_post($attachment_id); if (!$attachment) { wp_send_json_error(array('message' => 'Attachment not found.')); } $parent_post_id = $attachment->post_parent; $parent_post = get_post($parent_post_id); if (!$parent_post) { wp_send_json_error(array('message' => 'Parent post not found.')); } $parent_post_title = sanitize_text_field($parent_post->post_title); $media_post_title = sanitize_text_field($attachment->post_title); if (!$parent_post_title || !$media_post_title) { wp_send_json_error(array('message' => 'No titles found.')); } // Remove unwanted keywords from the parent post title using regular expressions $unwanted_keywords = array('PNG', 'Transparent', 'Images'); // Add other keywords to exclude here foreach ($unwanted_keywords as $keyword) { $parent_post_title = preg_replace('/\b' . preg_quote($keyword, '/') . '\b/i', '', $parent_post_title); } // Remove extra spaces $parent_post_title = trim(preg_replace('/\s+/', ' ', $parent_post_title)); // Combine both titles $combined_title = $parent_post_title . ' - ' . $media_post_title; $api_key = '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'; $model = 'gpt-4o-mini'; $messages = array(array('role' => 'user', 'content' => "Generate an SEO title based on the following combined title: \"$combined_title\". The title should be clear, concise, and optimized for search engines, under 50-55 characters, and free of special characters, Quotation marks. Avoid adding words like guide, overview, solutions, Character, emblem, Meaning, Explained. Generate the title with minimal stop words, focusing on essential keywords and clarity.")); $temperature = 0.7; $max_tokens = 400; $response = wp_remote_post('https://api.openai.com/v1/chat/completions', array( 'body' => json_encode(array( 'model' => $model, 'messages' => $messages, 'temperature' => $temperature, 'max_tokens' => $max_tokens, )), 'headers' => array( 'Authorization' => 'Bearer ' . $api_key, 'Content-Type' => 'application/json', ), )); if (is_wp_error($response)) { wp_send_json_error(array('message' => $response->get_error_message())); } $body = wp_remote_retrieve_body($response); $data = json_decode($body, true); if (isset($data['choices'][0]['message']['content'])) { $seo_title = sanitize_text_field($data['choices'][0]['message']['content']); // Define variations to append $variations = array('PNG', 'HD PNG', 'Clipart PNG', 'Clipart HD PNG', 'Free PNG'); $seo_titles_with_variations = array(); // Generate SEO titles with each variation foreach ($variations as $variation) { $seo_titles_with_variations[] = $seo_title . ' ' . $variation; } // Select the most appropriate variation or save all variations $final_seo_title = $seo_titles_with_variations[0]; // Example: use the first variation // Update media post title wp_update_post(array( 'ID' => $attachment_id, 'post_title' => $final_seo_title )); // Update alt tag by appending the parent post title $current_alt_text = get_post_meta($attachment_id, '_wp_attachment_image_alt', true); $new_alt_text = $current_alt_text . ', ' . $parent_post_title . ' ' . $variations[0]; update_post_meta($attachment_id, '_wp_attachment_image_alt', sanitize_text_field($new_alt_text)); wp_send_json_success(array('seo_title' => $final_seo_title)); } else { wp_send_json_error(array('message' => 'No content received from the API.')); } } Debris PNG Cutout | PNG All
Home » Debris PNG Transparent Images

Advertisements


Debris PNG Cutout

Debris PNG Cutout


Download PNG File

Download Debris PNG Cutout which is available for personal use. You can also check out the similar PNG images from below gallery.

DMCA: Report

Advertisements

Debris PNG Pic
Debris PNG Picture
Debris PNG
Debris Transparent
Debris No Background
Debris PNG File
Debris PNG Image HD
Debris PNG Photo