'warning', 'message' => __( 'Settings saved locally. Please select a category to sync with the API.', '1platform-content-ai' ), ), 30 ); wp_safe_redirect( wp_get_referer() ); exit; } $language_map = array( 'english' => 'en', 'spanish' => 'es', ); $lang_code = $language_map[ $site_language ] ?? 'en'; $website_provider = new ContaiWebsiteProvider(); $api_response = $website_provider->updateWebsite( array( 'category_id' => $site_category, 'lang' => $lang_code, ) ); if ( $api_response->isSuccess() ) { $api_message = $api_response->getMessage(); set_transient( 'contai_site_config_notice', array( 'type' => 'success', 'message' => ! empty( $api_message ) ? $api_message : __( 'Site configuration saved successfully!', '1platform-content-ai' ), ), 30 ); } else { $api_message = $api_response->getMessage(); set_transient( 'contai_site_config_notice', array( 'type' => 'error', 'message' => ! empty( $api_message ) ? sprintf( /* translators: %s: API error message */ __( 'Settings saved locally, but API sync failed: %s', '1platform-content-ai' ), $api_message ) : __( 'Settings saved locally, but API sync failed.', '1platform-content-ai' ), ), 30 ); } wp_safe_redirect( wp_get_referer() ); exit; } add_action( 'admin_post_contai_save_site_configuration', 'contai_handle_save_site_configuration' ); function contai_display_site_config_notice() { $notice = get_transient( 'contai_site_config_notice' ); if ( empty( $notice ) || ! is_array( $notice ) ) { return; } delete_transient( 'contai_site_config_notice' ); $type = in_array( $notice['type'], array( 'success', 'error', 'warning', 'info' ), true ) ? $notice['type'] : 'info'; $message = $notice['message'] ?? ''; if ( empty( $message ) ) { return; } $icons = array( 'success' => 'dashicons-yes-alt', 'error' => 'dashicons-dismiss', 'warning' => 'dashicons-warning', 'info' => 'dashicons-info', ); $icon = $icons[ $type ] ?? 'dashicons-info'; ?>