=== Content Performance Analyzer ===
Contributors: wajahatmubashir
Tags: analytics, seo, content, performance, ai
Requires at least: 6.2
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Content Performance Analyzer: The all-in-one plugin for SEO, analytics, and AI-powered content improvement.

== Description ==

Content Performance Analyzer is a powerful WordPress plugin that combines Google Analytics 4 (GA4) and Google Search Console data to provide actionable insights about your website's content performance. Using progressive AI-powered analysis with intelligent timeout handling, it efficiently processes hundreds of URLs and provides specific recommendations to improve SEO, user engagement, and conversions.

= Key Features =

* **Progressive Content Analysis**: Analyzes all pages incrementally in background batches without timeouts
* **Smart Waiting Banner**: Shows realistic time estimates with auto-refresh during analysis
* **Priority-Based Processing**: Flagged pages processed first for faster AI suggestions
* **Intelligent AI Timing**: AI waits for complete content data ensuring optimal recommendations
* **Plugin Page Integration**: Direct Settings and View Insights links on WordPress plugins page
* **Automated Data Collection**: Daily automatic collection of GA4 and Search Console data
* **AI-Powered Recommendations**: OpenAI integration provides specific, actionable suggestions
* **Performance Flagging**: Automatically identifies pages with decay, SEO issues, or conversion problems
* **Dynamic Batch Processing**: Analyze hundreds of URLs efficiently with 6-12 page batches
* **Real-Time Progress Tracking**: Live status updates with detailed progress information
* **Keyword Analysis**: Shows primary keywords and suggests optimization opportunities
* **Custom URL Upload**: Target specific pages with .txt upload
* **Comprehensive Dashboard**: Clean, sortable interface showing all key metrics

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/content-performance-analyzer/`
2. Activate the plugin through the 'Plugins' screen in WordPress
3. Click "Settings" link directly from the plugin page, or go to Content Insights > Settings
4. Follow the setup instructions to connect your Google APIs and OpenAI
5. Visit Content Insights dashboard to start analysis - realistic time estimates will be shown

== Changelog ==

= 1.0.0 =
* Progressive content analysis - analyzes all pages without artificial limits
* Smart waiting banner with realistic time estimates and auto-refresh
* Priority-based processing - flagged pages analyzed first for faster AI suggestions
* Intelligent AI timing - AI waits for complete content data for optimal recommendations
* Plugin page integration - direct Settings and View Insights links
* 3x performance improvement - reduced from 15.5s to ~3s average per page
* Dynamic batch sizing (6-12 pages) based on priorities and system performance
* Dynamic timeout prediction with 75-second safety buffer prevents all timeouts
* Real-time progress tracking with detailed status updates
* Enhanced user experience with transparent progress communication

= Previous Version =
* Complete rewrite with modular architecture
* Added automatic keyword analysis and optimization suggestions
* Implemented AI suggestion expiry system
* Enhanced dashboard with better UX
* Batch URL upload and retry/rescan features
* WordPress coding standards compliance

== External Services ==

This plugin connects to external services to collect analytics data and generate AI-powered recommendations. Below is a complete disclosure of all external APIs used:

= 1. Google Analytics 4 (GA4) =

**What it does:** Retrieves traffic and engagement metrics for your website's content pages.

**Data sent:** Your GA4 Property ID, date ranges, and requested URL paths/metrics for the authenticated Google Analytics property. Authentication is performed using your Google Service Account credentials.

**When:** When you manually trigger data collection, when scheduled daily automatic refresh runs, or when you upload URLs for analysis.

**Service URLs:**
* https://analyticsreporting.googleapis.com/
* https://www.googleapis.com/auth/analytics.readonly

**Terms of Service:** https://marketingplatform.google.com/about/analytics/terms/

**Privacy Policy:** https://policies.google.com/privacy

= 2. Google Search Console =

**What it does:** Retrieves search performance data (clicks, impressions, CTR, average position) for your verified website.

**Data sent:** Your verified site URL, date ranges, and performance data queries. Authentication is performed using your Google Service Account credentials.

**When:** When you manually trigger data collection, when scheduled daily automatic refresh runs, or when you upload URLs for analysis.

**Service URLs:**
* https://www.googleapis.com/webmasters/v3/
* https://www.googleapis.com/auth/webmasters.readonly

**Terms of Service:** https://support.google.com/webmasters/answer/4559176

**Privacy Policy:** https://policies.google.com/privacy

= 3. Google PageSpeed Insights (Optional) =

**What it does:** Fetches performance scores, Core Web Vitals, and diagnostic information for specific URLs.

**Data sent:** The URL being analyzed, your API key, and analysis strategy (mobile/desktop). The URL is sent to Google's servers for performance testing.

**When:** Only when you manually enable PageSpeed Insights in settings and trigger analysis. This service is completely optional.

**Service URL:**
* https://www.googleapis.com/pagespeedonline/v5/runPagespeed

**Terms of Service:** https://developers.google.com/terms

**Privacy Policy:** https://policies.google.com/privacy

= 4. OpenAI API (or Groq API) =

**What it does:** Generates AI-powered content improvement recommendations based on your page performance data.

**Data sent:** Page URLs, performance metrics (traffic, rankings, bounce rates), content analysis results (headings, word count, links), and performance issues. No actual page content or user data is sent.

**When:** Only when you manually trigger AI analysis for flagged pages. You control when AI suggestions are generated.

**Service URLs:**
* OpenAI: https://api.openai.com/v1/chat/completions (default)
* Groq: https://api.groq.com/openai/v1/chat/completions (alternative)

**OpenAI Terms:** https://openai.com/policies/terms-of-use

**OpenAI Privacy:** https://openai.com/policies/privacy-policy

**Groq Terms:** https://groq.com/terms/

**Groq Privacy:** https://groq.com/privacy-policy/

= Important Notes =

* All API communications use secure HTTPS connections
* You must provide your own API credentials (Google Service Account, OpenAI/Groq API key)
* No data is sent without your explicit configuration and action
* You can disable any optional service (e.g., PageSpeed Insights, AI analysis)
* No user data or personal information is transmitted to these services
* Only aggregated performance metrics and content structure information is shared

== Frequently Asked Questions ==

= How long does analysis take for large sites? =
With v1.0.0 optimizations, AI suggestions appear in 6-40 minutes for 200 URLs (vs. previous 1.67 hours). The smart waiting banner shows realistic time estimates and auto-refreshes progress.

= Does this plugin slow down my site? =
No, all heavy processing is done asynchronously in the background using WordPress cron. The progressive analysis system prevents any performance impact on your site.

= Will the analysis timeout on shared hosting? =
No, the intelligent timeout management with dynamic prediction and 75-second safety buffer prevents all timeouts. Background processing continues automatically even if you close the browser.

= Can I use this on multisite? =
Yes, the plugin is multisite compatible.

= Is my data safe? =
All analysis is performed locally or via secure API. No data is shared with third parties except the APIs you connect.

= How do I access the plugin settings after activation? =
After activation, you'll see "View Insights" and "Settings" links directly on the WordPress plugins page, or navigate to Content Insights in your admin menu.
