=== CodePros Email Template Builder ===
Contributors: codeprosai
Tags: email templates, woocommerce emails, email builder, wordpress emails, transactional email
Requires at least: 6.3
Tested up to: 7.0
Stable tag: 1.0.0
Requires PHP: 7.4
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Design beautiful, branded email templates and assign them to WordPress and WooCommerce email hooks — no coding required.

== Description ==

**CodePros Email Template Builder** replaces the default plain-text WordPress and WooCommerce emails with pixel-perfect, brand-consistent HTML templates built in a visual drag-and-drop editor.

Stop sending ugly default emails. With CodePros Email Template Builder you design once, assign to a hook, and every triggered email looks exactly the way you want — automatically.

= Free Features =

* **Visual drag-and-drop builder** — build email layouts with heading, text, button, image, divider, spacer, columns, table, social links, HTML code, footer, and WooCommerce address/order-items blocks
* **Social links block** — add platform icons (Facebook, Twitter/X, Instagram, LinkedIn, YouTube, Pinterest, TikTok, GitHub, WhatsApp, Telegram) with circular or square shape
* **Template management** — create, edit, duplicate, and delete templates from a clean list view
* **WordPress core email hooks** — assign templates to built-in WP emails: new user notification, password reset, admin new user, email change, and password change
* **Dynamic variables** — insert `{{variable}}` tokens (first name, site name, login URL, and more) that resolve automatically at send time
* **Live preview** — preview rendered templates directly in the admin before assigning
* **Send test email** — send a test message to any address to verify layout in a real inbox
* **CSS inlining** — inline all CSS automatically for maximum email client compatibility
* **Custom From name & email** — override the default WordPress sender details per template or globally
* **Duplicate templates** — clone any template as a starting point for a new design
* **WooCommerce Emails** — assign templates to all 16+ WooCommerce transactional hooks (new order, order status changes, invoice, password reset, and more). Includes per-email active/inactive toggle so you can revert to the default WC email instantly without deleting your template
* **WooCommerce order items table** — render a full order summary inside your template using `{{order_items_table}}` or `{{order_items_table_with_images}}`

= Pro Features =

Upgrade to **CodePros Email Template Builder Pro** to unlock:

* **Custom Hooks** — register your own PHP action/filter hooks, define custom `{{variables}}` passed from your code, assign templates directly in the UI, and get a copy-ready PHP snippet for your theme or plugin
* **Reusable Blocks** — create saved block sections and insert them into any template with a single click; update once to reflect the change everywhere
* **WooCommerce Products block** — drop a live product grid (recent or featured) directly into any email template; configurable columns, count, image, price, and call-to-action button
* **WordPress Posts block** — embed a recent-posts grid with thumbnail, title, excerpt, date, and read-more button — ideal for newsletters and digest emails

= How It Works =

1. Go to **Email Templates** in the WordPress admin sidebar.
2. Click **Add Template** and build your layout in the visual editor.
3. Use `{{variable}}` tokens to personalise the content dynamically.
4. Click **Preview** or **Send Test** to verify it looks right.
5. Go to **WooCommerce Emails** or the assignment panel to map the template to an email hook.
6. Done — every email fired on that hook now uses your template.

= Variable Tokens =

The following tokens are available in templates and resolve at send time:

**WordPress core:** `{{site_name}}`, `{{site_url}}`, `{{first_name}}`, `{{last_name}}`, `{{user_email}}`, `{{user_login}}`, `{{reset_link}}`, `{{login_url}}`

**WooCommerce email:** `{{order_id}}`, `{{order_total}}`, `{{order_date}}`, `{{billing_first_name}}`, `{{billing_last_name}}`, `{{billing_email}}`, `{{shipping_address}}`, `{{payment_method}}`, `{{order_items_table}}`, `{{order_items_table_with_images}}`

**Custom Hooks (Pro):** any variables you define when registering a custom hook

== Installation ==

1. Upload the `codepros-email-template-builder` folder to `/wp-content/plugins/`.
2. Activate the plugin through the **Plugins** screen in WordPress.
3. Navigate to **Email Templates** in the admin sidebar to start building.
4. *(Pro)* Go to the **License** tab, enter your license key, and click **Activate**.

= Minimum Requirements =

* WordPress 6.3 or higher
* PHP 7.4 or higher
* WooCommerce 7.0+ (optional, required for WooCommerce email features)


== Frequently Asked Questions ==

= Will this replace my existing WooCommerce emails? =

Only for hooks you explicitly assign a template to. Any hook without an active template assignment continues to use the default WC email unchanged.

= Can I use this without WooCommerce? =

Yes. The core template builder and WordPress core email hooks are fully available without WooCommerce. WooCommerce-specific features (WC Emails tab) appear only when WC is installed and active.

= What happens if I deactivate the plugin? =

All email hooks immediately revert to the WordPress or WooCommerce defaults. Your templates are stored in the database and will be restored when you reactivate.

= Can I use custom fonts? =

You can add any web-safe font via the text block font-family setting, or embed a Google Fonts `@import` in a custom HTML block. Note that many email clients do not support web fonts and will fall back to the specified fallback font.

= Does the builder support responsive email layouts? =

Yes. The email shell wraps all content in a 600px max-width table-based layout that stacks correctly on mobile clients.

= Where are templates stored? =

Templates are stored in a dedicated `wp_eta_templates` database table, not as post meta, keeping your `wp_posts` table clean.

= How do I trigger a custom hook from PHP? (Pro) =

After registering a custom hook in the Custom Hooks tab, copy the provided PHP snippet and add it to your theme or plugin. When that code runs, CodePros Email Template Builder intercepts the action and sends the assigned template with the variables you passed.

== Screenshots ==

1. Template list — manage all your email templates in one place
2. WooCommerce Emails tab — assign and toggle templates per WC email
3. Custom Hooks tab — register and manage custom PHP email hooks (Pro)
4. Reusable Blocks tab — create saved sections for reuse across templates (Pro)
5. Settings page — global From name/email and CSS inlining options
6. Drag-and-drop email builder with block palette

== External Services ==

This plugin connects to the **CodePros AI Licensing API** (https://api.wp-plugins.codepros.ai)
when a Pro license key is entered and activated. The following data is transmitted:

* Your WordPress site name
* Your WordPress site URL
* Your license key

This data is used solely to validate your Pro license. No data is collected or transmitted
on free (unlicensed) installations.

Service privacy policy: https://codepros.ai/privacy-policy
Service terms of use:   https://codepros.ai/terms

== Source Code & Build Process ==

The compiled and minified JavaScript files in the `build/` directory are generated from the human-readable source files located in the `src/` directory, which is included in this plugin package.

= Build Tools =

* **Node.js** (16 or higher) and **npm**
* **@wordpress/scripts** `^27.9.0` — provides the webpack configuration optimised for WordPress block development

= Dependencies =

* `@tanstack/react-query` `^5.0.0` — server-state management for REST API calls
* `bootstrap-icons` `^1.13.1` — icon set used in the admin UI

= Steps to Regenerate Compiled Files =

1. Ensure Node.js 16+ and npm are installed.
2. From the plugin root directory, install dependencies:
   `npm install`
3. Build production assets (output goes to `build/`):
   `npm run build`
4. For development (watch mode with source maps):
   `npm run start`

= Third-Party PHP Libraries =

* **tijsverkoyen/css-to-inline-styles** — CSS inlining; source: https://github.com/tijsverkoyen/CssToInlineStyles (MIT License)
* **WordPress Coding Standards (WPCS)** — used for PHP linting only; not shipped with the plugin

== Changelog ==

= 1.0.0 =
* Initial release
* Visual drag-and-drop email builder with 8 block types
* Social links block with 10 platform icons (circular/square shape)
* WordPress core email hook assignments (5 hooks)
* Dynamic `{{variable}}` token resolution
* Live preview and send-test functionality
* CSS inlining via tijsverkoyen/css-to-inline-styles
* Template CRUD with duplication
* WooCommerce Emails integration with active/inactive toggle (16+ hooks, free)
* WooCommerce Products block — live product grid rendered at send time (Pro)
* WordPress Posts block — recent-posts grid rendered at send time (Pro)
* Custom Hooks with variable definitions and PHP code snippet (Pro)
* Reusable Blocks (Pro)
* CodePros AI license system with 12-hour validation cache

== Upgrade Notice ==

= 1.0.0 =
Initial release — no upgrade steps required.
