From edaf46a9b2322e6681902c7baec1f1a5be9f171b Mon Sep 17 00:00:00 2001 From: corsacca Date: Thu, 13 Nov 2025 15:53:03 +0100 Subject: [PATCH] Allow setting which AI features are enabled for the whole multi-site. --- includes/tab-ai.php | 78 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/includes/tab-ai.php b/includes/tab-ai.php index d73c922..43641c2 100644 --- a/includes/tab-ai.php +++ b/includes/tab-ai.php @@ -34,14 +34,17 @@ public function content(){ } public function process_post() { - // Process Chat Model Form + // Verify nonces $ai_chat_nonce_verified = isset( $_POST['ai_chat_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['ai_chat_nonce'] ) ), 'ai_chat' ); $ai_transcript_nonce_verified = isset( $_POST['ai_transcript_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['ai_transcript_nonce'] ) ), 'ai_transcript' ); - if ( !$ai_chat_nonce_verified && !$ai_transcript_nonce_verified ) { + $ai_features_nonce_verified = isset( $_POST['ai_features_nonce'] ) + && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['ai_features_nonce'] ) ), 'ai_features' ); + + if ( !$ai_chat_nonce_verified && !$ai_transcript_nonce_verified && !$ai_features_nonce_verified ) { return [ 'is_update' => false, 'updated' => false @@ -97,6 +100,28 @@ public function process_post() { ]; } + // Process Enabled Features Form + if ( $ai_features_nonce_verified ) { + $post_vars = dt_recursive_sanitize_array( $_POST ); + + // Get all modules + $modules = Disciple_Tools_AI_API::list_modules(); + + // Build network module states array + $network_module_states = []; + foreach ( $modules as $module ) { + $network_module_states[ $module['id'] ] = isset( $post_vars[ $module['id'] ] ) ? 1 : 0; + } + + // Save network-level module states + update_site_option( 'DT_AI_network_modules', $network_module_states ); + + return [ + 'is_update' => true, + 'updated' => true + ]; + } + return false; } @@ -303,6 +328,55 @@ public function list_keys( $processed ){
+ + +
+ + + + + + + + + + + + + + + + + + +
Network Default Enabled Features
+ +
+ +
+ > +
+ + + +
+
+