=== Dropndot AI Content for Custom Fields ===
Contributors: dropndot
Tags: ai, custom-fields, openai, gemini, content-generation
Requires at least: 7.0
Tested up to: 7.1
Stable tag: 1.0.0
Requires PHP: 7.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Smart AI content generation for WordPress custom fields with automatic token management and no cutoffs.

== Description ==

Dropndot AI Content for Custom Fields is a powerful WordPress plugin that brings AI-powered content generation directly to your custom fields. Generate high-quality content for any custom field with a single click, using the WordPress AI Client and whichever AI provider you have connected (OpenAI, Google Gemini, Anthropic, and others).

= Key Features =

* **Smart Field Detection**: Automatically detects all custom fields (ACF, Meta Box, Pods, standard WordPress fields, Yoast SEO, Rank Math)
* **One-Click Generation**: Generate content for any field with a single click
* **Intelligent Content Detection**: Automatically detects appropriate content type based on field name
* **Custom Prompts with Limits**: Set custom AI prompts for each field with explicit character/word limits
* **Precise Length Control**: Dedicated character and word limit fields ensure AI respects your requirements
* **Complete Sentence Truncation**: Smart truncation at sentence boundaries, never cuts off mid-word
* **Advanced Internal Linker**: AI-powered keyword extraction and smart post matching for internal linking
* **AI Chat Assistant**: Chat with AI about your article content for suggestions and improvements
* **Preview & Edit**: Review AI-generated content before saving
* **WordPress AI Client**: Uses the core AI Client so credentials live in Settings → Connectors, not in this plugin
* **Optimized Token Usage**: Intelligent content truncation to prevent token limit errors
* **User Access Control**: Granular user permissions
* **Format Support**: Plain text, WYSIWYG, JSON, lists, and paragraphs
* **Professional UI**: Clean, modern WordPress admin interface

= How It Works =

1. Install and activate the plugin
2. Connect an AI provider under **Settings → Connectors** (install an official AI provider plugin if WordPress asks you to)
3. Select which custom fields to enable
4. Set character/word limits for each field (optional)
5. Optionally set custom prompts for each field
6. Generate content with one click while editing posts

= Supported Field Types =

* Advanced Custom Fields (ACF)
* Meta Box
* Pods
* Standard WordPress custom fields
* Yoast SEO fields
* Rank Math fields
* WYSIWYG/rich text fields
* Plain text fields
* JSON fields

= Use Cases =

* Generate SEO meta descriptions (with precise character limits)
* Create article summaries
* Generate FAQs and quiz questions
* Create internal link suggestions
* Generate subtitles and taglines
* Chat with AI about content improvements
* Generate social media snippets with character limits

= Character & Word Limits =

The plugin now features explicit character and word limit fields:

* **Character Limits**: Perfect for meta descriptions, Twitter posts, etc.
* **Word Limits**: Ideal for summaries, excerpts, and article sections
* **Smart Enforcement**: AI is instructed to respect limits during generation
* **Safety Net**: Intelligent post-processing ensures limits are never exceeded
* **Complete Sentences**: Truncation always happens at sentence boundaries
* **Per-Field Control**: Set different limits for each custom field

= Token Optimization =

The plugin includes advanced token management:

* **Adaptive Content Truncation**: Sends less article content when generating short outputs
* **Concise System Messages**: Optimized AI instructions to save tokens
* **Dynamic Limits**: Adjusts content based on character/word requirements
* **Prevents Errors**: Never exceeds API token limits

== External services ==

This plugin uses the WordPress AI Client (WordPress 7.0+) to generate content. No request is ever made until a site administrator connects an AI provider under Settings → Connectors and a permitted user actively triggers a feature. This plugin does not store AI provider API keys. The plugin does not collect analytics and does not track visitors or site users.

The destination of each request is whichever AI provider the site owner has connected (for example OpenAI, Google, or Anthropic). Official provider plugins register with the Connectors screen and send the request from your server.

= WordPress AI Client / connected providers =

Used to generate custom field content, internal link suggestions and chat replies.

What is sent: the post title and post content of the entry being edited (truncated to a maximum of 15,000 characters), the custom prompt configured for the field, the chat messages you type, the recent chat history of the current conversation, and your WordPress display name so the assistant can address you by name.

When it is sent: only when a logged-in, permitted user clicks a "Generate" button, requests internal links, or sends a chat message.

Provider terms depend on which connector you enable. Common examples:

* OpenAI terms: https://openai.com/policies/terms-of-use/
* OpenAI privacy: https://openai.com/policies/privacy-policy/
* Google Gemini terms: https://ai.google.dev/gemini-api/terms
* Google privacy: https://policies.google.com/privacy
* Anthropic terms: https://www.anthropic.com/legal/terms
* Anthropic privacy: https://www.anthropic.com/legal/privacy

= Upstash Search (optional) =

Used only for the internal linking feature, and only when "Use Upstash for Search" is enabled in the Internal Links settings and an Upstash REST URL and token are configured. When it is disabled, the plugin uses the built-in WordPress search instead and contacts no external search service.

What is sent: search queries derived from the keywords of the post being edited, sent to the Upstash Search REST endpoint you configure, together with your Upstash REST token.

When it is sent: only when a user generates internal link suggestions while the option is enabled.

Terms of service: https://upstash.com/trust/terms.pdf
Privacy policy: https://upstash.com/trust/privacy.pdf

== Installation ==

1. Upload the `dropndot-ai-content-custom-fields` folder to your `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Go to **Settings → Connectors** to add an AI provider, then **Settings → Dropndot AI Content for Custom Fields** to choose fields and prompts
4. Select which custom fields to enable
5. Set character/word limits for fields that need them
6. Start generating content!

== Frequently Asked Questions ==

= Do I need to pay for the API? =

Yes. You connect your own AI provider under Settings → Connectors (OpenAI, Google, Anthropic, or another registered provider). Costs depend on that provider's pricing. This plugin does not add its own usage fees.

= How do character limits work? =

Simply enter a number in the "Char Limit" field (e.g., 140 for meta descriptions). The AI will generate content within that limit, and a safety net ensures it never exceeds the limit. Truncation happens at sentence boundaries for natural-looking content.

= Can I set both character and word limits? =

Yes, but typically you'd use one or the other. If both are set, the AI will respect whichever limit is more restrictive. For SEO meta descriptions, use character limits. For article summaries, word limits work better.

= What if I don't set any limits? =

That's fine! The plugin will generate content based on your custom prompt instructions. Limits are optional and only needed when you have specific requirements (like SEO meta descriptions).

= Does it work with Advanced Custom Fields (ACF)? =

Yes! It works perfectly with ACF, Meta Box, Pods, and standard WordPress custom fields. It also supports Yoast SEO and Rank Math fields.

= Can I use it on custom post types? =

Yes! The plugin works on all public post types. You can control access through user permissions.

= How does the internal links feature work? =

The AI analyzes your post content, extracts relevant keywords, and matches them with other posts in your database. You can review and approve links before they're applied to your content.

= Can I customize the AI prompts? =

Yes! Each field can have its own custom prompt. You can specify instructions, tone, format requirements, and any other details. The character/word limits are set in separate fields for precision.

= What happens if I get a "Token limit reached" error? =

The plugin includes automatic token optimization. It adaptively reduces article content when generating short outputs (like meta descriptions) to prevent token errors.

= Does the chat feature remember conversation history? =

Yes! The chat maintains conversation context throughout your session, allowing for follow-up questions and deeper analysis.

= Can I use both OpenAI and Gemini? =

Connect one or more providers in Settings → Connectors. In this plugin you can prefer OpenAI or Gemini; if that family is not connected, the WordPress AI Client falls back to any compatible model.

= How do I control who can use AI features? =

Go to Settings → Dropndot AI Content for Custom Fields → User Access tab. Administrators always have access. You can grant access to specific users or roles.

== Screenshots ==

1. Settings page with WordPress AI Client / Connectors status
2. Custom fields selection interface with character/word limits
3. Content generation modal with preview
4. Internal links suggestion interface
5. AI chat assistant
6. Quick prompts configuration
7. Professional table layout with proper spacing

== Changelog ==

= 1.0.0 =
* Initial release
* Custom field AI generation through the WordPress AI Client
* Character and word limits with sentence-boundary truncation
* Internal links feature
* AI chat assistant
* Custom prompts support
* User access control
* SEO field support (Yoast SEO, Rank Math)
* WYSIWYG formatting support
* Quick prompts feature

== Upgrade Notice ==

= 1.0.0 =
Initial release of Dropndot AI Content for Custom Fields.

== Support ==

For support, please visit the plugin website or contact the developer.

Author: Dropndot Solutions
Author URI: https://dropndot.com

== Technical Details ==

= System Requirements =
* WordPress 7.0 or higher
* PHP 7.4 or higher
* An AI provider connected in Settings → Connectors
* cURL extension enabled

= Token Management =
The plugin uses intelligent token management:
* Short outputs (< 200 chars): Uses ~5K article content
* Medium outputs (200-500 chars): Uses ~10K article content
* Long outputs (no limits): Uses up to 50K article content
* Adaptive based on custom prompt length

= API Limits =
* Output token budgets are requested through the WordPress AI Client
* Automatic continuation for incomplete responses
* Smart content truncation to prevent input token errors

= Privacy =
* AI provider API keys are not stored by this plugin; they are managed in Settings → Connectors
* Post content and prompts are sent to the AI provider you connect - see the "External services" section for exactly what is sent and when
* Data handling on the provider side is governed by that provider's own terms and privacy policy
* The plugin itself does not track users and sends no analytics
* All communication uses HTTPS

== Credits ==

Developed by Dropndot Solutions
Copyright (C) 2026 Dropndot Solutions
