" \ * -d '{ * "count": 1, * "context": "Minimalist and professional icon for the website example.com. ..." * }' * * @return int|WP_Error Attachment ID on success, WP_Error on failure */ function contai_generate_and_set_site_icon_from_openai() { $host = sanitize_text_field(wp_parse_url(home_url(), PHP_URL_HOST)); $theme = sanitize_text_field(get_option('contai_site_theme', 'general')); $context = "Minimalist and professional logo for the website $host. " . "The logo must include the domain name '$host' in a modern, elegant font. " . "Add a simple plant-related icon such as a $theme next to the text. " . "The logo must have a transparent background, no white margins or extra spacing " . "— cropped tightly to the content. Typography and icon should look balanced and clean."; $service = ContaiImageGenerationService::create(); $filename = "icon-$host.png"; $attachment_id = $service->generateAndSideload($context, $filename); if (is_wp_error($attachment_id)) { return $attachment_id; } update_option('site_icon', $attachment_id); return $attachment_id; }