=== Nexu AI Content Writer ===
Contributors: nexuvibe
Tags: ai, content, generator, automation, gpt
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 3.2.37
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Powerful AI-powered automatic content generator with advanced features, intelligent scheduling, and support for multiple AI providers.

== Description ==

Nexu AI Content Writer is a comprehensive WordPress plugin that leverages the power of artificial intelligence to automatically generate high-quality, SEO-optimized content for your website.

= Key Features =

* **Site Analyzer** - Analyze your existing content to generate relevant title suggestions
* **Content Structure Builder** - Visual drag & drop builder to define your content structure
* **Multiple AI Providers** - Support for OpenAI, Claude, Gemini, Grok, and Mistral
* **Image Generation** - Create images with DALL-E, Stable Diffusion, and Midjourney
* **Customizable Prompts** - Edit and optimize AI prompts for your specific needs
* **Task Management** - Create, schedule, and monitor multiple content generation tasks
* **Background Processing** - Robust queue system with cron job support
* **Advanced Logging** - Comprehensive activity logs with filtering and export
* **Statistics Dashboard** - Track your content generation metrics
* **Multi-Language Support** - Fully translatable with i18n

= Supported AI Providers =

**Text Generation:**
* OpenAI (GPT-4, GPT-4 Turbo, GPT-3.5)
* Anthropic Claude (Opus, Sonnet, Haiku)
* Google Gemini
* xAI Grok
* Mistral AI

**Image Generation:**
* DALL-E (OpenAI)
* Stable Diffusion
* Midjourney

= Content Builder Elements =

* Headings (H1, H2, H3)
* Paragraphs (configurable word count)
* Images (with AI generation)
* Lists (ordered/unordered)
* Quotes
* Tables
* Code Blocks

= Background Processing =

The plugin includes a powerful background processing system that:
* Uses WordPress cron or server cron jobs
* Handles token limits intelligently
* Retries failed tasks automatically
* Provides real-time progress updates
* Supports graceful shutdown

= Professional Features =

* **Two-Phase Content Generation** - First creates outline, then generates detailed content
* **Chunk Processing** - Handles large content by splitting into manageable chunks
* **Contextual Images** - Generates images based on title and surrounding content
* **Auto-Bold Keywords** - Automatically highlights important keywords for SEO
* **Global Keywords** - Set site-wide keywords to include in all content
* **Post Type Support** - Works with posts, pages, products, and custom post types
* **Flexible Scheduling** - Immediate, scheduled, or recurring content generation
* **Progress Tracking** - Detailed progress with completion percentage and logs

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/nexu-ai-content-writer/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Navigate to 'AI Writer' in the admin menu
4. Configure your AI provider API keys in the 'API Settings' tab
5. Create a content builder in the 'Builder' tab
6. Start generating content!

= Server Cron Setup (Recommended) =

For optimal performance, set up a server cron job:

**DirectAdmin:**
`wget -q -O - https://yoursite.com/wp-cron.php >/dev/null 2>&1`

**cPanel:**
`php /path/to/your/site/wp-cron.php`

Schedule to run every 5 minutes: `*/5 * * * *`

== Frequently Asked Questions ==

= Do I need API keys? =

Yes, you need API keys from the AI providers you want to use. Get them from:
* OpenAI: platform.openai.com
* Claude: console.anthropic.com
* Gemini: makersuite.google.com
* Grok: console.x.ai
* Mistral: console.mistral.ai

= Is my API key secure? =

Yes, all API keys are encrypted before being stored in the database.

= Can I use this for WooCommerce products? =

Yes! The plugin supports all public post types including WooCommerce products.

= How many posts can I generate at once? =

You can generate as many posts as you want. The plugin uses a queue system to process them in the background.

= Can I customize the AI prompts? =

Yes! All prompts are fully editable in the Model Settings tab.

= Does it support multiple languages? =

Yes, the plugin is fully internationalized and can generate content in any language supported by the AI providers.

= What happens if content generation fails? =

Failed tasks are automatically retried up to 3 times. You can monitor all attempts in the logs.

== Screenshots ==

1. Main dashboard with beautiful UI
2. Site analyzer generating title suggestions
3. Visual content structure builder
4. API settings with connection testing
5. Task management with progress tracking
6. Background processing settings
7. Content generator with real-time progress
8. Statistics dashboard with charts
9. Activity logs with filtering

== Changelog ==

= 3.2.37 =
* Fixed: Removed duplicate event handler for Refresh button
* Added: "Updated: HH:MM:SS" indicator shows when tasks list was last refreshed
* This helps verify auto-refresh is working

= 3.2.36 =
* CRITICAL FIX: Style parameter was NOT being sent to image generator in content generation!
* Fixed: generate_featured_image() now sends style parameter
* Fixed: generate_image_for_section() now sends style parameter
* This was the root cause of bad images in content vs good images in Quick Image Generator

= 3.2.35 =
* Fixed: Content generation images now use same simple prompt format as Quick Image Generator
* Fixed: Removed duplicate style application (was applied twice before)
* Improved: Simplified build_smart_prompt() to just return clean title + "no text"
* Result: Content images should now be as good as Quick Image Generator

= 3.2.34 =
* Fixed: Image style now properly applied to all image generators (DALL-E, Gemini, Stable Diffusion, Midjourney)
* Added: Style modifiers appended to prompts (realistic, cartoon, illustration, 3D, pixel)
* Improved: BaseImageGenerator now has shared apply_style_to_prompt method

= 3.2.33 =
* Added: Default image prompt now pre-filled in task creation form
* Added: Reset to Default button for image prompt
* Improved: Image generation prompts are now simpler and more focused
* Fixed: Custom image prompt now auto-enables featured image generation
* Improved: Task-level image settings properly override global settings
* Added: Universal image prompt template for consistent results

= 3.2.32 =
* Fixed: Task cards now update properly when task completes (status based on counts)
* Added: Manual Refresh button for tasks list
* Improved: Auto-refresh interval reduced to 3 seconds
* Fixed: AJAX cache disabled to ensure fresh data
* Improved: Status calculation uses actual queue counts, not just DB status field

= 3.2.31 =
* NEW: Temperature (creativity) control per task
* NEW: Image Size override per task (Square, Landscape, Portrait)
* NEW: Image Style override per task (Realistic, Cartoon, Illustration, 3D, Pixel)
* NEW: Image Quality override per task (Standard, HD)
* Improved: All task settings properly cascade (element > task > global)
* Improved: Duplicate task now copies all advanced settings

= 3.2.30 =
* NEW: Custom prompts per task - override content and image generation instructions
* Added: Content Generation Instructions field in Advanced Settings
* Added: Image Generation Prompt field in Advanced Settings
* Improved: Task-level prompts merge with item-level prompts
* Improved: Duplicate task now copies custom prompts

= 3.2.29 =
* Fixed: Task cards now properly update to "Completed" status in real-time
* Improved: Status detection logic - checks all states (completed, failed, running, pending)
* Fixed: Progress bar and status badge sync correctly with queue status

= 3.2.28 =
* NEW: View Post button on completed tasks - direct link to generated content
* Added: Support for multiple posts per task with dropdown menu
* Improved: Quick access to edit generated posts from tasks list

= 3.2.27 =
* Removed: Success alert popup after task creation (less intrusive UX)
* Improved: Task creation now silently closes modal and refreshes list

= 3.2.26 =
* NEW: Completely redesigned image generation prompts for better quality
* NEW: Smart conceptual prompts that extract core meaning from titles
* NEW: DefaultPrompts class for centralized prompt management
* NEW: Default prompts now visible in settings with "Use This" button
* NEW: Toggle visibility - default prompt shown only when custom is empty
* Improved: Shorter, focused prompts produce cleaner images
* Improved: Better abstraction of concepts (no more literal interpretations)
* Improved: Reset button now clearly resets to factory defaults
* Fixed: Images no longer contain unrelated elements (like cheetah for speed plugin)

= 3.2.25 =
* Improved: Auto-refresh interval reduced from 10 to 5 seconds for faster updates
* Removed: All console.log debug statements from tasks-tab.php
* Fixed: Task cards now update in real-time without page refresh
* Improved: Cleaner code without emoji debug messages

= 3.2.24 =
* Improved: Task creation validation now shows specific missing field names
* Added: Visual highlight (red border) on empty required fields
* Added: Validation for at least one title requirement
* Better: User-friendly error messages listing all missing fields

= 3.2.23 =
* Removed: All console.log debug statements from builder JavaScript
* Improved: Cleaner production code without debug output
* Security: No sensitive data exposed in browser console

= 3.2.22 =
* Fixed: Cancel and Save buttons styling in builder element settings modal
* Added: Missing naicw-btn class to modal footer buttons

= 3.2.21 =
* Fixed: Builder element edit button error (undefined element ID)
* Improved: Elements loaded from database now get valid IDs assigned
* Changed: Default image size in Installer to Landscape (1792x1024)
* Changed: Default image style in Installer to Illustration
* Changed: Default image quality in Installer to HD

= 3.2.20 =
* Improved: Completely rewritten default image prompts for all 5 styles
* Added: Strong "NO TEXT" instructions in all default prompts
* Improved: Clean, minimalist, professional image generation
* Added: Style-specific optimized prompts (Realistic, Illustration, Cartoon, 3D, Pixel)
* Updated: Placeholder texts with helpful examples and tips
* Fixed: Images now generate without unwanted text/typography

= 3.2.19 =
* Fixed: Removed annoying "leave page" confirmation when switching between tabs
* Improved: Form change flag resets when navigating between plugin tabs

= 3.2.18 =
* Changed: Default image size from 1024x1024 to 1792x1024 (Landscape)
* Changed: Default image style from Realistic to Illustration
* Updated: All default values across settings, builder, and task runner

= 3.2.17 =
* Fixed: Dashicons display with !important to override inline styles
* Improved: Icons now properly display as block with explicit dimensions
* Added: Bottom margin to separate icon from text

= 3.2.16 =
* Fixed: Dashicons alignment in tasks grid - icons now centered above text
* Fixed: Loading state alignment - now properly centered in grid
* Improved: Both empty state and loading state span full width

= 3.2.15 =
* Fixed: Form grid top spacing - added margin-top 20px to all form grids
* Improved: First form grid has no top margin to avoid extra space

= 3.2.14 =
* Fixed: Empty state text alignment in tasks grid - now properly centered
* Improved: Empty state spans full width in grid layout

= 3.2.13 =
* Fixed: Form grid sections spacing in modal dialogs - added margin-bottom 20px
* Improved: Better visual separation between form sections

= 3.2.12 =
* Fixed: Input and select field vertical alignment in modal dialogs
* Changed: Using proper padding (0 12px) and line-height for text centering
* Improved: Textarea now has separate styling with proper padding

= 3.2.11 =
* Fixed: Restored original form styling in modal dialogs with proper background and borders
* Improved: Form fields now display in 2-column grid layout with consistent padding

= 3.2.10 =
* Fixed: Form field alignment in modal dialogs - changed to single column layout
* Removed: Background styling from modal form fields for cleaner appearance

= 3.2.9 =
* Fixed: Form padding in modal dialogs - added proper padding and background styling
* Improved: Modal form fields now have consistent card-like appearance

= 3.2.8 =
* Fixed: Form fields alignment in settings tabs (align-items: start)
* Improved: Form grid styling with card-like appearance for each field

= 3.2.7 =
* Added: Quick Image Generator remembers settings (Size, Style, Quality) via localStorage
* Improved: Settings persist between page visits

= 3.2.6 =
* Fixed: Header icon not visible (removed conflicting inline styles)

= 3.2.5 =
* Fixed: Select dropdown text vertical alignment
* Improved: Custom dropdown arrow for select fields
* Added: RTL support for select dropdowns

= 3.2.4 =
* Fixed: GPT Image models size compatibility (1536x1024 / 1024x1536 instead of 1792x1024 / 1024x1792)
* Added: Automatic size mapping for GPT Image models

= 3.2.3 =
* Improved: Better warning message for Grok limitations with detailed list
* Added: Note that xAI may take time to add aspect ratio features
* Added: Recommendation to use other providers for production

= 3.2.2 =
* Confirmed: Grok API has hard server-side limitation - always returns 720x960
* Changed: Size selector disabled for Grok provider (cannot be changed)
* Improved: Clearer warning message for Grok limitations
* Simplified: Grok prompt now only includes style (aspect ratio prompts ineffective)
* Tested: Community prompt engineering techniques - none work for aspect ratio

= 3.2.1 =
* Added: Warning message for Grok Aurora limitations in Quick Image page
* Note: Grok API returns fixed 720x960 (Portrait) images regardless of settings
* Improved: Simplified Grok prompt engineering for better results
* Improved: Only style is embedded in prompt (size cannot be changed via API)

= 3.2.0 =
* Fixed: Grok model name corrected to grok-2-image-1212 (grok-2-image doesn't exist)
* Fixed: Grok image generation now fully working
* Improved: Grok respects size, style, and quality via enhanced prompts
* Added: build_enhanced_prompt() method for Grok settings embedding
* Tested: Full integration with WordPress Media Library and WebP conversion

= 3.1.8 =
* Fixed: Grok image generation failing in Quick Image Generator
* Fixed: Removed unsupported parameters (size, quality, style) from Grok API requests
* Improved: Grok now uses URL response format for better compatibility

= 3.1.7 =
* Added: xAI Grok Aurora image generation support
* Added: Grok 2 Image models (grok-2-image, grok-2-image-1212)
* Added: GrokImageGenerator class for xAI API integration
* Improved: Image provider selection now includes Grok/Aurora

= 3.1.6 =
* Fixed: Base64 image saving issue with GPT Image models
* Fixed: WP_Filesystem initialization issue in AJAX context
* Improved: Using wp_tempnam() for reliable temp file creation
* Added: Better debug logging for image save operations

= 3.1.5 =
* Improved: Better error messages for GPT Image model failures
* Added: HTTP status code checking with specific error messages
* Added: Debug logging for API responses when WP_DEBUG is enabled
* Improved: Clearer guidance when organization verification is required (403 error)

= 3.1.4 =
* Fixed: GPT Image models (gpt-image-1.5, gpt-image-1) now working correctly
* Fixed: Base64 response handling for GPT Image models (they don't return URL)
* Added: save_base64_to_media_library method in BaseImageGenerator
* Improved: Better error messages for different response formats
* Improved: Extended timeout for GPT Image models (120 seconds)

= 3.1.3 =
* Added: Support for latest OpenAI GPT Image models (gpt-image-1.5, gpt-image-1, gpt-image-1-mini)
* Improved: Quality parameter mapping for new GPT Image models (Medium/High)
* Improved: Updated DALL-E model list

= 3.1.2 =
* Improved: Added detailed error prefixes to Gemini connection tests and generation
* Fixed: Potential caching issue in connection test handler
* Improved: Debugging information for Image AI providers

= 3.1.1 =
* Added: Support for Imagen 4.0 models (Standard, Ultra, Fast)
* Improved: Updated Gemini image generator defaults to Imagen 4.0
* Fixed: Compatibility with Google AI Studio API availability

= 3.1.0 =
* Improved: Enhanced Test Connection for Gemini to list available Imagen models
* Added: Support for imagen-3.0-fast-generate-001 model
* Fixed: Better debugging for Imagen model availability

= 3.0.10 =
* Fixed: Updated Google Imagen model to imagen-3.0-generate-002 (fixed "model not found" error)
* Added: Fallback for older Imagen models
* Improved: Better error handling for Gemini image generation

= 3.0.9 =
* Fixed: Quick Image Generator not working with Gemini/Imagen provider
* Added: Gemini support to Quick Image Generator
* Added: Model selection support for all image generators
* Fixed: stable-diffusion provider name mismatch
* Improved: Image generators now use selected model from settings

= 3.0.8 =
* Added: Real-time auto-refresh for task cards (every 10 seconds)
* Added: Live indicator showing real-time updates are active
* Added: Notifications when tasks complete or fail
* Added: Sound notification on task completion
* Improved: No more need to manually refresh page to see task status
* Improved: Silent refresh without loading spinner on auto-updates

= 3.0.7 =
* Fixed: Modal form field alignment issues
* Improved: Two-column grid layout in modal forms
* Improved: Better form styling in Create Task modal
* Added: Responsive design for modal forms on mobile

= 3.0.6 =
* Improved: Better error messages for API connection failures
* Added: Specific error messages for 401, 403, 429, 5xx errors
* Improved: Clearer guidance when API key is invalid

= 3.0.5 =
* Added: Real API connection testing for all providers
* Added: GeminiImageGenerator for Google Imagen support
* Fixed: Test Connection button now actually tests API connection
* Fixed: Welcome page redirect to correct tab

= 3.0.4 =
* Fixed: Welcome page "Start Setup" button redirecting to wrong tab
* Fixed: Changed redirect from tab=settings to tab=api-settings

= 3.0.3 =
* Added: Two-column layout for API Settings page
* Improved: Text and Image providers displayed side by side
* Improved: Better visual separation between provider types
* Fixed: Form layout - labels now display above inputs
* Improved: Responsive design for smaller screens

= 3.0.1 =
* Added: Google Imagen as image generation provider
* Added: Model selection dropdown for all text providers
* Added: OpenAI models: GPT-4o, GPT-4o-mini, O1-preview, O1-mini
* Added: Claude models: Claude 3.5 Sonnet, Claude 3.5 Haiku, Claude 3 Opus
* Added: Gemini models: Gemini 2.0 Flash, Gemini 1.5 Pro/Flash
* Added: Grok models: Grok 2, Grok Beta
* Added: Mistral models: Large, Small, Medium, Codestral, Pixtral, Ministral, Mixtral
* Added: Model selection dropdown for all image providers
* Improved: Dynamic model filtering based on selected provider
* Improved: API Settings page UI with model selection

= 3.0.0 =
* Added: Welcome page for first-time installation
* Added: Beautiful intro screen with feature highlights
* Added: Animated mascot image on welcome page
* Added: Quick start setup guide from welcome page
* Improved: Complete UI redesign with Indigo/Violet color scheme

= 2.9.9 =
* Updated: Admin UI design system to match Nexu Activity Log style
* Changed: Primary color from Orange to Indigo/Violet gradient (#6366f1 to #8b5cf6)
* Added: Outfit font family for modern typography
* Added: New animations and transitions for better UX
* Improved: Header banner design with icon animation
* Improved: Navigation rail with better hover and active states
* Improved: Form components with consistent styling
* Improved: Button styles with gradient support
* Improved: Progress bars with gradient background
* Improved: Quick Generators pages with updated color scheme
* Added: Additional CSS utility classes for badges, alerts, cards
* Fixed: RTL support improvements
* Enhanced: Responsive design for mobile devices

= 2.9.8 =
* Fixed: CRITICAL - Wrong image URL in content (PNG instead of WebP after conversion)
* Fixed: generate_image_for_section() returning wrong URL after WebP conversion
* Changed: Now directly uses URL from generator result instead of querying attachment ID again
* Improved: Image URL handling to ensure WebP URLs are used when conversion is enabled
* Added: Better logging for image generation with URL tracking
* Note: This fixes the issue where ai-generated-image-76.png was used instead of ai-generated-image-76.webp

= 2.9.7 =
* Fixed: "Create Task" submenu not redirecting to tasks tab properly
* Added: redirect_to_tasks_tab() method with proper wp_safe_redirect()
* Improved: "Create Content Task" menu now uses separate page slug with redirect
* Improved: Better menu navigation structure for quick access to task creation

= 2.9.6 =
* Fixed: CRITICAL - IMG elements in builder were not generating images at all
* Fixed: Images missing from generated content despite IMG elements in builder
* Added: Proper IMG/IMAGE type detection in Stage 3 content generation loop
* Added: Automatic image generation for IMG sections using generate_image_for_section()
* Added: HTML figure wrapper with proper WordPress block classes for generated images
* Added: ai-generated-image class to all programmatically generated images
* Improved: Image sections now skip text generation and call image API directly
* Improved: Better error logging for failed image generation attempts
* Note: This was a critical bug preventing ANY images from being generated via builder structure

= 2.9.5 =
* Fixed: "Unsaved changes" warning blocking navigation after creating tasks
* Fixed: Form change detection preventing tab switching
* Fixed: Statistics showing zeros for posts generated before version 2.9.4
* Added: "Sync Old Posts" button in Statistics tab to retroactively add metadata
* Added: AJAX handler for syncing old generated posts
* Added: Automatic detection of AI-generated posts via image markers
* Added: Informative notice when no statistics are found
* Added: Proper form reset after successful task creation
* Added: resetFormChanged() method in NAICWAdmin
* Improved: Modal close behavior now resets unsaved changes flag
* Improved: Better beforeunload event handling for modern browsers
* Improved: Statistics accuracy for legacy content

= 2.9.4 =
* Fixed: Statistics tab showing all zeros - now displays real data from generated content
* Added: Comprehensive StatsController for accurate statistics tracking
* Added: Post metadata tracking (_naicw_generated, _naicw_word_count, _naicw_text_provider, etc.)
* Added: Daily statistics tracking with date range filtering
* Added: AI provider usage breakdown
* Added: Post type distribution analytics
* Added: Recent generated content table with edit links
* Improved: Statistics now include all content generated through tasks
* Improved: Real-time charts with Chart.js integration
* Improved: Better date range filtering (default: last 30 days)
* Note: Token counting removed as requested

= 2.9.3 =
* Fixed: WebP images not appearing in media library when generated via TaskRunner
* Fixed: Image generators returning temporary URLs instead of permanent WordPress media library URLs
* Improved: All image generators now return correct attachment URL after WebP conversion
* Improved: StableDiffusionGenerator now supports WebP conversion
* Improved: Better URL handling for DallEGenerator and MidjourneyGenerator

= 2.9.2 =
* Fixed: Duplicate WebP images in media library (4x duplication issue)
* Fixed: Loop continuation when attachment creation fails
* Improved: Check for existing WebP files before conversion
* Improved: Check for already WebP format to avoid re-conversion
* Improved: Cleanup failed WebP files when conversion fails
* Improved: Better error handling and resource management

= 2.9.1 =
* Fixed: Division by zero error in WebP converter when source file not found
* Fixed: File size calculation after deleting original image
* Improved: Better error handling for missing files during conversion

= 2.9.0 =
* Added WebP image conversion system with automatic fallback
* Support for multiple conversion methods: GD Library, Imagick, cwebp, WordPress Editor
* New WebP Settings tab in admin panel
* Automatic quality optimization for generated images
* Option to delete original images after conversion
* Real-time conversion statistics
* Integration with all image generators (DALL-E, Stable Diffusion, etc.)
* Enhanced image optimization for better SEO and page speed
* Improved file size reduction (typically 30-80% smaller)

= 1.0.0 =
* Initial release
* Site analyzer with title suggestions
* Visual drag & drop content builder
* Support for 5 AI text providers
* Support for 3 image generators
* Task management system
* Background processing with cron
* Comprehensive logging system
* Statistics dashboard
* Fully translatable

== Upgrade Notice ==

= 2.9.0 =
Major update! WebP image optimization now available. Reduce image file sizes by 30-80% for better SEO and faster page loading. All settings configured automatically.

= 1.0.0 =
Initial release of Nexu AI Content Writer. Start generating amazing content with AI!

== Privacy Policy ==

This plugin sends content to third-party AI providers (OpenAI, Anthropic, Google, xAI, Mistral) based on your configuration. Please review their privacy policies:

* OpenAI: https://openai.com/privacy
* Anthropic: https://www.anthropic.com/privacy
* Google: https://policies.google.com/privacy
* xAI: https://x.ai/legal/privacy-policy
* Mistral: https://mistral.ai/terms/

Your API keys are encrypted and stored locally in your WordPress database.

== Credits ==

Developed by Nexuvibe Dev Group
Website: https://nexuvibe.co
Support: support@nexuvibe.co

== Third-Party Services ==

This plugin connects to the following third-party services:

* Chart.js (MIT License) - For statistics charts
* Sortable.js (MIT License) - For drag & drop functionality

Both are loaded from CDN for better performance.

