=== HD SofT AI Summary ===
Contributors: hdsoft
Tags: ai, summary, openrouter, content, automation
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 8.0
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automatically generate AI-powered summaries for your WordPress posts using OpenRouter API integration.

== Description ==

HD SofT AI Summary is a powerful WordPress plugin that automatically generates intelligent summaries for your blog posts using advanced AI models through the OpenRouter API. Save time and improve your content's accessibility with professionally crafted summaries.

= Key Features =

**Free Version:**
* **Manual Summary Generation** - Generate summaries using the "Generate Summary" button in post editor
* **OpenRouter API Integration** - Access to multiple AI models including GPT-3.5, GPT-4, Claude, and more
* **Narrative Style Summaries** - 2-3 sentence narrative summaries in content language
* **Manual Override** - Edit summaries manually when needed, with protection against auto-overwriting
* **Flexible Display Options** - Show summaries before content, after content, or use shortcodes for custom placement
* **Smart Content Detection** - Hash-based system detects content changes
* **REST API Support** - Full REST API for developers and integrations
* **Responsive Design** - Mobile-friendly summary display with customizable styling

**Pro Version Features:**
* **Automatic Summary Generation** - Summaries are generated automatically when you publish or update posts
* **Multiple Prompt Styles** - Choose from Narrative, Structured Bullets, or Executive Brief styles
* **Custom Summary Titles** - Set default title for summaries (used in AI prompts)
* **Enhanced Automation** - Auto-generate on save for streamlined workflow

= How It Works =

1. **Install and Configure** - Add your OpenRouter API key in the settings
2. **Choose Your Model** - Select from various AI models based on your needs and budget
3. **Generate Summaries** - Free: Use "Generate Summary" button in post editor. Pro: Automatic generation on save/publish
4. **Customize Display** - Choose where and how summaries appear on your site
5. **Manual Control** - Edit summaries manually when you need specific content

= OpenRouter Integration =

This plugin uses the OpenRouter API to access multiple AI models:
- OpenAI GPT-3.5 Turbo (Recommended for most users)
- OpenAI GPT-4 (Premium quality)
- Anthropic Claude models
- Meta Llama models
- And many more

You'll need an OpenRouter API key (free tier available) to use this plugin.

= Developer Features =

* **REST API for Integrations** - Authenticated endpoints for generating, retrieving, and managing summaries (requires WordPress user permissions)
* **WordPress Hooks** - Basic customization hooks (init, settings updates, supported post types filter)
* **Template Functions** - Static functions for theme developers to display summaries
* **Shortcode Support** - `[hdsoft_ai_summary]` shortcode with customizable attributes

= Privacy & Security =

* API keys are stored securely with autoload=false
* Content is sent to OpenRouter API only for summary generation
* No personal data is stored by third-party services
* Full control over when and how content is processed

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/hdsoft-ai-summary/` or install through WordPress admin
2. Activate the plugin through the 'Plugins' screen in WordPress
3. Go to Settings > AI Summary to configure the plugin
4. Get your free OpenRouter API key from https://openrouter.ai/
5. Enter your API key and configure your preferences
6. Test the connection and start generating summaries!

== Frequently Asked Questions ==

= Do I need an OpenRouter account? =

Yes, you need an OpenRouter API key to generate summaries. OpenRouter offers a free tier to get started, and you only pay for what you use.

= Which AI models are supported? =

The plugin supports all models available through OpenRouter, including GPT-3.5, GPT-4, Claude, Llama, and many others. You can choose the model that best fits your needs and budget.

= Will summaries be regenerated if I edit my posts? =

The plugin uses a smart hash-based system to detect content changes. In the Pro version, summaries are automatically regenerated when post content changes (if auto-generation is enabled). In the Free version, you need to manually regenerate summaries using the "Generate Summary" button. Manual edits are always protected from being overwritten.

= Can I customize where summaries appear? =

Yes! You can choose to display summaries before content, after content, or use the `[hdsoft_ai_summary]` shortcode for custom placement. You can also use summaries as post excerpts.

= Is there a way to edit summaries manually? =

Absolutely! You can edit any summary manually through the post editor meta box. Manual edits are protected and won't be overwritten by automatic regeneration.

= Does this work with custom post types? =

By default, the plugin works with standard posts. Developers can extend support to custom post types using the `hdsoft_ai_summary_supported_post_types` filter.

= What happens to my summaries if I deactivate the plugin? =

Your summaries are stored as post meta and will remain in your database. If you reactivate the plugin, all summaries will still be available.

== Screenshots ==

1. Settings page with OpenRouter API configuration
2. Post editor meta box for manual summary editing
3. Summary displayed on the frontend
4. Connection test and model selection

== Changelog ==

= 1.0.0 =
* Initial release
* OpenRouter API integration
* Automatic summary generation
* Manual editing capabilities
* REST API endpoints
* Shortcode support
* Responsive frontend display
* WordPress 6.0+ compatibility

== Upgrade Notice ==

= 1.0.0 =
Initial release of HD SofT AI Summary plugin.

== Privacy Notice ==

This plugin may send post content to OpenRouter API for AI summary generation. The data transmission occurs only when:
- Auto-generation is enabled and you publish/update a post
- You manually generate a summary using the "Generate Summary" button
- You test the API connection in settings

**Data Handling:**
- Post titles and content are sent to OpenRouter for processing
- No personal data or user information is transmitted
- API keys are stored locally and never shared with plugin developers
- Generated summaries are stored in your WordPress database
- You can disable auto-generation at any time

**Third-Party Service:**
This plugin integrates with OpenRouter (https://openrouter.ai/), which provides access to various AI models. Please review OpenRouter's privacy policy and terms of service for information about how they handle data.

**Your Control:**
- You can disable automatic summary generation
- You can delete summaries at any time
- API communication only occurs when explicitly triggered
- No background or scheduled data transmission

**Freemius SDK:**
This plugin uses the Freemius SDK to collect non-sensitive diagnostic data only after your explicit opt-in. You can opt out at any time from the plugin's settings. For more information, see the Freemius privacy policy: https://freemius.com/privacy/

== Developer Documentation ==

= REST API Endpoints =

Base URL: `/wp-json/hdsoft-ai-summary/v1/`

**Authentication Required:** All endpoints require WordPress user authentication with appropriate permissions.

* `POST /generate` - Generate summary for a post
  - Requires: `edit_posts` capability and `edit_post` permission for specific post
  - Parameters: `post_id` (required), `force_regenerate` (optional, boolean)

* `GET /summary/{post_id}` - Retrieve existing summary
  - Requires: Post must be publicly readable OR user has edit permissions

* `DELETE /summary/{post_id}` - Delete post summary
  - Requires: `edit_posts` capability and `edit_post` permission

* `POST /test-connection` - Test OpenRouter API connection
  - Requires: `manage_options` capability (admin only)

= Template Functions =

Use these static functions in your theme templates:

```php
// Display formatted summary HTML
HDSofT\AISummary\Frontend::get_summary( $post_id, $echo );

// Check if post has summary
if ( HDSofT\AISummary\Frontend::has_summary( $post_id ) ) {
    // Post has summary
}

// Get raw summary text only
$summary_text = HDSofT\AISummary\Frontend::get_summary_text( $post_id );
```

= WordPress Hooks =

**Action Hooks:**
* `hdsoft_ai_summary_init` - Fired when plugin is initialized
* `hdsoft_ai_summary_settings_updated` - Fired when settings are saved
* `hdsoft_ai_summary_fs_loaded` - Fired when Freemius SDK is loaded

**Filter Hooks:**
* `hdsoft_ai_summary_supported_post_types` - Modify supported post types (default: `['post']`)

Example:
```php
add_filter( 'hdsoft_ai_summary_supported_post_types', function( $post_types ) {
    $post_types[] = 'custom_post_type';
    return $post_types;
});
```

= Shortcode Attributes =

`[hdsoft_ai_summary post_id="123" class="my-summary" wrapper="div"]`

* `post_id` - Specific post ID (default: current post)
* `class` - CSS class name (default: hdsoft-ai-summary)  
* `wrapper` - HTML wrapper element: div, section, aside, p (default: div)

== Support ==

For support, feature requests, or bug reports, please visit our website at https://hdsoft.fi/ or contact us through the plugin support forum.

== Credits ==

Developed by HD SofT - Professional WordPress development services.
