__('Missing permission.','ai-webmaster-studio')],403); check_ajax_referer('aiwest_text_model','nonce'); $operation=AIWEST_Security::post_key('operation','read'); if ($operation==='set') { $result=self::set(AIWEST_Security::post_text('model'),AIWEST_Security::post_text('original')); if (is_wp_error($result)) wp_send_json_error(['message'=>$result->get_error_message(),'model'=>self::get()],409); } wp_send_json_success(['model'=>self::get()]); } public static function assets() { $page=AIWEST_Security::get_key('page'); if (!current_user_can('manage_options') || !in_array($page,['aiwest-chat','aiwest-settings'],true)) return; wp_enqueue_script('aiwest-text-model',AIWEST_URL.'assets/text-model.js',[],AIWEST_VERSION,true); wp_localize_script('aiwest-text-model','AIWESTTextModel',[ 'url'=>admin_url('admin-ajax.php'),'nonce'=>wp_create_nonce('aiwest_text_model'),'model'=>self::get(), 'saving'=>__('Saving the global model…','ai-webmaster-studio'), 'saved'=>__('Global model saved. Settings and AI Chat now use the same model.','ai-webmaster-studio'), 'changed'=>__('The global model was updated in another tab.','ai-webmaster-studio'), 'error'=>__('The model could not be saved. Reload and try again.','ai-webmaster-studio'), ]); } public static function chat_control() { $current=self::get(); echo '
'.esc_html__('Changing this selection updates Text model in Settings and all subsequent text tasks. It does not change the image model. Luna is economical; Sol balances quality and cost; Astra is intended for demanding work. Model access depends on your API project.','ai-webmaster-studio').'