' . esc_html(__('AI Webmaster Studio Operator has been disabled.', 'ai-webmaster-studio')) . '

'; } else { $confirmed = AIWEST_Security::post_text('aiwest_operator_confirm') === 'yes'; $scope = AIWEST_Security::post_key('aiwest_technical_operator_scope', 'draft_only'); if (!$confirmed) { $notice = '

' . esc_html(__('To enable the AI operator, confirm explicit administrator consent.', 'ai-webmaster-studio')) . '

'; } elseif (class_exists('AIWEST_Technical_Operator')) { $operator_result = AIWEST_Technical_Operator::enable($scope); if (is_wp_error($operator_result)) { $notice = '

' . esc_html($operator_result->get_error_message()) . '

'; } else { $notice = '

' . esc_html(__('AI Webmaster Studio Operator has been configured.', 'ai-webmaster-studio')) . '

'; } } } } if (AIWEST_Security::is_post_request() && AIWEST_Security::post_bool('aiwest_save_settings')) { check_admin_referer('aiwest_settings_action'); $model_mode = AIWEST_Security::post_text('aiwest_openai_model_choice'); $custom_model = AIWEST_Security::post_text('aiwest_openai_model_custom'); $text_model = $model_mode === '__custom__' ? $custom_model : $model_mode; $original = AIWEST_Security::post_text('aiwest_openai_model_original',AIWEST_Text_Models::get()); $model_result = AIWEST_Text_Models::set($text_model ?: $original,$original); if (is_wp_error($model_result)) { $notice = '

'.esc_html($model_result->get_error_message()).'

'; } else { $previous_interface_locale=AIWEST_Languages::locale(); AIWEST_Languages::save(); if ($previous_interface_locale!==AIWEST_Languages::locale()) { // Admin navigation is rendered before this callback; refresh it in the new locale. wp_add_inline_script('aiwest-text-model','window.location.replace('.wp_json_encode(admin_url('admin.php?page=aiwest-settings')).');'); } $new_key = trim(AIWEST_Security::post_text('aiwest_openai_api_key')); if ($new_key !== '') update_option('aiwest_openai_api_key',sanitize_text_field($new_key)); $image_model_choice = AIWEST_Security::post_text('aiwest_openai_image_model_choice'); $custom_image_model = AIWEST_Security::post_text('aiwest_openai_image_model_custom'); $image_model = $image_model_choice === '__custom__' && $custom_image_model ? $custom_image_model : $image_model_choice; if (!$image_model) { $image_model = AIWEST_Security::post_text('aiwest_openai_image_model', get_option('aiwest_openai_image_model', 'gpt-image-1')); } update_option('aiwest_openai_image_model', $image_model); update_option('aiwest_auto_publish_posts', AIWEST_Security::post_bool('aiwest_auto_publish_posts') ? 'yes' : 'no'); update_option('aiwest_auto_taxonomy', AIWEST_Security::post_bool('aiwest_auto_taxonomy') ? 'yes' : 'no'); $auto_images_ai = AIWEST_Security::post_bool('aiwest_auto_images_enabled') ? 'yes' : 'no'; $auto_images_library = AIWEST_Security::post_bool('aiwest_auto_images_library_enabled') ? 'yes' : 'no'; // Only one automatic featured-image source should be active at a time. // Media Library wins as the safer/no-API-cost option when both checkboxes are submitted. if ($auto_images_library === 'yes') { $auto_images_ai = 'no'; } update_option('aiwest_auto_images_enabled', $auto_images_ai); update_option('aiwest_auto_images_library_enabled', $auto_images_library); update_option('aiwest_auto_content_refresh', 'no'); update_option('aiwest_image_style', AIWEST_Security::post_textarea('aiwest_image_style')); update_option('aiwest_google_maps_api_key', AIWEST_Security::post_text('aiwest_google_maps_api_key', get_option('aiwest_google_maps_api_key', ''))); if (class_exists('AIWEST_Social_Media')) { $social_links = AIWEST_Security::post_array('aiwest_social_links'); $social_enabled = AIWEST_Security::post_array('aiwest_social_enabled_platforms'); update_option('aiwest_social_links', AIWEST_Social_Media::sanitize_links($social_links), false); update_option('aiwest_social_enabled_platforms', AIWEST_Social_Media::sanitize_enabled_platforms($social_enabled), false); update_option('aiwest_social_footer_enabled', AIWEST_Security::post_bool('aiwest_social_footer_enabled') ? 'yes' : 'no', false); update_option('aiwest_social_footer_label', AIWEST_Security::post_text('aiwest_social_footer_label', 'Find us on social media'), false); } $default_status = AIWEST_Security::post_key('aiwest_site_builder_default_status', 'draft'); if (!in_array($default_status, ['draft', 'publish'], true)) $default_status = 'draft'; update_option('aiwest_site_builder_default_status', $default_status); $notice = '

' . esc_html(__('AI Webmaster Studio settings have been saved.', 'ai-webmaster-studio')) . '

'; if (AIWEST_Security::post_bool('aiwest_test_openai_api')) { if (!class_exists('AIWEST_OpenAI')) { $test_payload = [ 'ok' => false, 'time' => current_time('mysql'), 'message' => __('The OpenAI module is not available.', 'ai-webmaster-studio'), ]; update_option('aiwest_openai_last_test', $test_payload, false); $notice .= '

' . esc_html($test_payload['message']) . '

'; } else { $test = AIWEST_OpenAI::test_models_endpoint(); if (is_wp_error($test)) { $test_payload = [ 'ok' => false, 'time' => current_time('mysql'), 'message' => $test->get_error_message(), ]; update_option('aiwest_openai_last_test', $test_payload, false); $notice .= '

' . esc_html(__('OpenAI API test failed:', 'ai-webmaster-studio')) . ' ' . esc_html($test_payload['message']) . '

'; } else { $count = absint($test['count'] ?? 0); $test_payload = [ 'ok' => true, 'time' => current_time('mysql'), 'model_count' => $count, 'message' => sprintf( /* translators: %d: Number of models returned by the OpenAI models endpoint. */ __('OpenAI API connection works. The models endpoint returned %d models.', 'ai-webmaster-studio'), $count ), ]; update_option('aiwest_openai_last_test', $test_payload, false); $notice .= '

' . esc_html(__('OpenAI API test completed successfully.', 'ai-webmaster-studio')) . ' ' . esc_html($test_payload['message']) . '

'; } } } } } $key = get_option('aiwest_openai_api_key', ''); $masked_key = $key ? substr($key, 0, 7) . '...' . substr($key, -4) : ''; $current_model = AIWEST_Text_Models::get(); $text_choice = in_array($current_model, $text_models, true) ? $current_model : '__custom__'; $text_custom = $text_choice === '__custom__' ? $current_model : ''; $current_image_model = get_option('aiwest_openai_image_model', 'gpt-image-1'); $image_choice = in_array($current_image_model, $image_models, true) ? $current_image_model : '__custom__'; $image_custom = $image_choice === '__custom__' ? $current_image_model : ''; $openai_last_test = get_option('aiwest_openai_last_test', []); $openai_last_test = is_array($openai_last_test) ? $openai_last_test : []; $auto_library_images_enabled = get_option('aiwest_auto_images_library_enabled', 'no') === 'yes'; ?>

display_name . ' (#' . intval($operator_user->ID) . ')') : esc_html(__('Not created yet', 'ai-webmaster-studio')); ?>
user_email) : esc_html(__('It will be created during configuration.', 'ai-webmaster-studio')); ?>

' . esc_html($masked_key) . '' : '' . esc_html(__('No key', 'ai-webmaster-studio')) . ''; ?>

—


$platform): ?>

AI Webmaster Studio → .

[aiwest_directory_map]. [aiwest_company_map]