=== SmartWoo – AI Product Description & Image Optimizer ===
Contributors: mdsuzonmia
Tags: woocommerce, ai, products, seo, images
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 1.0.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

SmartWoo is an API-first WooCommerce product content and image optimization client.

== Description ==

SmartWoo connects WordPress only to the centralized SmartWoo REST API. WordPress never stores AI-provider keys and never calls OpenAI, Gemini, Anthropic, or image providers directly. The SmartWoo API remains authoritative for accounts, subscriptions, entitlements, credits, usage, models, generation, images, history, and jobs.

Generated content is previewed in the WooCommerce product editor. The optimizer includes dedicated featured-image and coordinated product-gallery generators with selectable batch import. A user with the manage_woocommerce capability must explicitly apply content or import an image. Existing content is not silently overwritten.

== Installation ==

1. Install and activate WooCommerce.
2. Copy the smartwoo-ai-product-description-image-optimizer directory to wp-content/plugins/.
3. Activate SmartWoo.
4. Open SmartWoo > Account. If needed, follow the free-trial registration link to create an account and one-time API token.
5. Paste the token into SmartWoo > Account and select Verify and connect.
6. Open a WooCommerce product and use the SmartWoo AI Optimizer panel.

== SmartWoo API requirement ==

The API uses Bearer token authentication and JSON responses with a success boolean plus data or error fields. Production sites connect to:

https://smartwoo.codervex.com/api/v1/

This hosted endpoint is the plugin default. Developers may override SMARTWOO_API_BASE_URL or SMARTWOO_API_VERSION before plugins load, or use the smartwoo_api_base_url and smartwoo_api_endpoints filters. Endpoint paths are centralized in SmartWoo_API_Client::endpoints(). Non-local connections require HTTPS.

== Current endpoint map ==

The included defaults match the hosted SmartWoo API for account, usage, models, product generation, and image generation. Future features, bulk jobs, and history paths are also centralized and fail safely when the server has not exposed them yet.

== Authentication and local data ==

The API token is verified before storage and encrypted at rest using Sodium when available, otherwise AES-256-GCM derived from WordPress authentication salts. It is never localized into JavaScript, rendered in HTML, or written to logs.

WordPress stores only the encrypted credential, UI defaults, short-lived transients, last-applied product metadata, and optional job identifiers. It does not duplicate the SmartWoo SaaS database.

== Development ==

WP_DEBUG and WP_DEBUG_LOG may be enabled for local work. SmartWoo logging is separately disabled by default. Enable it under SmartWoo > Settings; logs contain endpoint, status, duration, request ID, and normalized codes, with credential-like fields redacted.

Language and tone values are populated from the API features response when available. Local values are preferences only and cannot bypass API authorization or plan restrictions.

== Troubleshooting ==

= WooCommerce warning =

Activate WooCommerce. Product-specific features stay disabled without it and WordPress remains operational.

= API unavailable =

Check SMARTWOO_API_BASE_URL, confirm the API health route, and ensure Apache can reach the API. Production endpoints must use HTTPS. Existing WooCommerce content is left intact on every API failure.

= 401 or expired token =

Open SmartWoo > Account, disconnect the local credential, and connect with a current SmartWoo token.

= 403, 429, or limit exceeded =

The SmartWoo API is authoritative. Review the live account and usage pages; local settings cannot unlock server features or credits.

= Bulk endpoint unavailable =

The v1 UI uses asynchronous SmartWoo API jobs. Configure the bulk and job entries through smartwoo_api_endpoints after those routes are deployed on the SmartWoo API.

== Security ==

All admin mutations require manage_woocommerce, an authenticated WordPress session, and a nonce. Inputs are validated and sanitized, output is escaped, remote images are size and MIME checked, non-local API HTTP is rejected, and generated product content is applied only after an explicit action.

== External service ==

This plugin connects to the SmartWoo API at `https://smartwoo.codervex.com/api/v1` to authenticate SmartWoo accounts, retrieve subscription entitlements and usage, and generate product content or images.

When an administrator connects an account, the supplied SmartWoo API token is sent for verification. When account, usage, or settings screens are opened, the plugin sends the stored bearer token and a one-way site identifier to retrieve account data. When an administrator explicitly starts generation, relevant WooCommerce product details, generation instructions, selected language and tone, and AI routing preferences are sent to the service. Generated images are downloaded only after an administrator explicitly chooses an import action.

The SmartWoo API may route generation to its configured AI providers. WordPress does not store provider credentials or contact those providers directly.

SmartWoo service terms: https://smartwoo.ai/terms

SmartWoo privacy policy: https://smartwoo.ai/privacy-policy

== Uninstall ==

Configuration is preserved by default. Enable "Delete SmartWoo local data on uninstall" before uninstalling to remove plugin-owned local options, caches, and SmartWoo product metadata. The plugin never deletes SaaS account data.

== Changelog ==

= 1.0.3 =
* Fixed product gallery generation so the requested count returns separate image files instead of a combined collage.

= 1.0.2 =
* Updated the production SmartWoo API endpoint to https://smartwoo.codervex.com/api/v1.
* Updated the API connection documentation for the hosted service.

= 1.0.1 =
* Added a dedicated Monthly AI Reports admin menu and live current-month summary.
* Removed AI Translation, FAQ Generator, and AI Chat Assistant from the core plugin.
* Added optional maximum character and word limits for product titles, short descriptions, and full descriptions.
* Added live visible-text counts and over-limit warnings in generated previews.
* Kept optimizer action-button icons and labels aligned on one line.
* Added dedicated featured product image and multi-image gallery generators.
* Added selectable gallery batch import, duplicate protection, safe partial-failure handling, and automatic attachment alt text.
* Redesigned the product AI Optimizer with tool tabs, target-audience guidance, clearer previews, character counts, and account context.

= 1.0.0 =
* Initial API-first release.
