Add Google Analytics and Search Console integration

- Implemented Groq_AI_Google_Analytics_Data_Client for fetching GA4 data.
- Created Groq_AI_Google_Search_Console_Client for retrieving Search Console data.
- Added Google OAuth client for authentication with Google APIs.
- Enhanced Groq_AI_Settings_Manager to include Google OAuth settings.
- Introduced term context building methods in Groq_AI_Google_Context_Builder.
- Developed JavaScript functionality for term generation in the admin interface.
- Added methods for generating term prompts and handling responses.
- Improved error handling and response parsing for Google API interactions.
This commit is contained in:
2026-01-16 17:48:34 +00:00
parent 985f7dfbcd
commit 95f7983e70
10 changed files with 2089 additions and 3 deletions

View File

@@ -35,6 +35,15 @@ class Groq_AI_Settings_Manager {
'groq_api_key' => '',
'openai_api_key' => '',
'google_api_key' => '',
'google_oauth_client_id' => '',
'google_oauth_client_secret' => '',
'google_oauth_refresh_token' => '',
'google_oauth_connected_email' => '',
'google_oauth_connected_at' => 0,
'google_enable_gsc' => true,
'google_enable_ga' => true,
'google_gsc_site_url' => '',
'google_ga4_property_id' => '',
'context_fields' => $this->get_default_context_fields(),
'modules' => $this->get_default_modules_settings(),
'image_context_mode' => 'url',
@@ -81,6 +90,15 @@ class Groq_AI_Settings_Manager {
'groq_api_key' => '',
'openai_api_key' => '',
'google_api_key' => '',
'google_oauth_client_id' => '',
'google_oauth_client_secret' => '',
'google_oauth_refresh_token' => '',
'google_oauth_connected_email' => '',
'google_oauth_connected_at' => 0,
'google_enable_gsc' => true,
'google_enable_ga' => true,
'google_gsc_site_url' => '',
'google_ga4_property_id' => '',
'context_fields' => $this->get_default_context_fields(),
'modules' => $this->get_default_modules_settings(),
'image_context_mode' => 'url',
@@ -127,6 +145,15 @@ class Groq_AI_Settings_Manager {
'groq_api_key' => sanitize_text_field( $input['groq_api_key'] ),
'openai_api_key' => sanitize_text_field( $input['openai_api_key'] ),
'google_api_key' => sanitize_text_field( $input['google_api_key'] ),
'google_oauth_client_id' => sanitize_text_field( $input['google_oauth_client_id'] ),
'google_oauth_client_secret' => sanitize_text_field( $input['google_oauth_client_secret'] ),
'google_oauth_refresh_token' => sanitize_text_field( $input['google_oauth_refresh_token'] ),
'google_oauth_connected_email' => sanitize_text_field( $input['google_oauth_connected_email'] ),
'google_oauth_connected_at' => absint( $input['google_oauth_connected_at'] ),
'google_enable_gsc' => ! empty( $raw_input['google_enable_gsc'] ),
'google_enable_ga' => ! empty( $raw_input['google_enable_ga'] ),
'google_gsc_site_url' => esc_url_raw( (string) $input['google_gsc_site_url'] ),
'google_ga4_property_id' => sanitize_text_field( (string) $input['google_ga4_property_id'] ),
'response_format_compat' => ! empty( $raw_input['response_format_compat'] ),
'image_context_mode' => $image_mode,
'image_context_limit' => $image_limit,