=== AffCoupon - Coupons and Deals for Affiliate Sites ===
Contributors: couponthemes
Tags: coupon, coupons, deal, deals, affiliate
Requires at least: 5.7
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.3.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Display affiliate coupons and deals beautifully. Generate more affiliate sales with click-to-copy coupon codes, deals, and image coupons.

== Description ==

**Promote affiliate coupons and deals on your WordPress site. Present coupons and deals the right way, protect affiliate sales, and generate more revenue.**

[__Live Demo__](https://couponthemes.net/plugins/affcoupon)

AffCoupon - Coupons and Deals for Affiliate Sites is a coupon plugin that lets you add coupons and deals to your posts and pages with a simple and beautiful shortcode. You can also show coupons and deals on your sidebar or any widget area using the included widget.

You can create three types of coupon:

* Coupon
* Deal
* Image

The coupon shortcode supports **click-to-copy coupon codes**. When a user clicks the coupon code, the code is copied to the clipboard and a link opens in a new tab - you can use your affiliate link here, so every copy becomes a tracked click.

The Deal shortcode looks the same as the Coupon type. Instead of a coupon code, it shows a customizable button (for example "Get This Deal" or "Get Deal"). When users click the button, your affiliate link opens in a new tab - nothing is copied.

Both types display a discount amount or text on the left so users instantly know what the offer is about. Below the discount, the coupon type is shown (coupon code or deal).

Both the coupon code and the deal button display a tooltip with text you control. The expiration date or text appears on the right; expired coupons display a customizable expired message, and never-expiring coupons can show your own text.

You can customize the date format of the expiration date. Make sure to update the expiration date of your existing coupons after changing the format, otherwise the previous format will still be shown.

You can also show only the coupon code (without the full coupon details) by selecting the shortcode type from the shortcode inserter.

Image coupons are just images - upload a coupon image and give users the option to print it.

= Key Features =

* Very lightweight, loads fast.
* Responsive and attractive shortcode.
* Live preview of the coupon as you create it.
* Insert shortcode directly from the post editor.
* Click-to-copy functionality.
* Voting system for individual coupons.
* Social share buttons for individual coupons.
* Widget to show coupons and deals on widget areas.
* Easy to use settings.
* Coupon categories to categorize your coupons.
* Expiration system to show coupon expiration.
* Stylesheets and scripts loaded conditionally for better performance.
* AMP support for all coupon shortcodes.

= Included Advanced Features =

* Hide Coupons.
* Coupon expiration countdown.
* Coupon Templates.
* Show Specific Coupons.
* Show Coupons of a specific Category.
* Show Coupons of a specific Vendor.
* Coupons Archive Page.

== Installation ==

1. Upload the `affcoupon` folder to the `/wp-content/plugins/` directory, or install the plugin through the WordPress Plugins screen directly.
2. Activate the plugin through the **Plugins** screen in WordPress.
3. A new **Coupons** menu (with a scissor icon) appears in your admin dashboard.

== Frequently Asked Questions ==

= How do I add a coupon to a post? =

After installing the plugin, go to **Coupons -> Add New Coupon** and create your coupon. Then open any post or page in the editor and click the **Add Coupon** button next to the **Add Media** button. A window pops up with a list of all your added coupons - pick the coupon you want, choose the shortcode type, and click **Insert Coupon Shortcode**. The shortcode is inserted with the corresponding ID; save the post and you're done.

= What sections appear under the Coupons menu? =

* **Coupons** - the list of all coupons you have added (with type, code, description, link, category, shortcode, and expiration).
* **Add New Coupon** - where you create new coupons.
* **Coupon Categories** - manage and create categories.
* **Settings** - general plugin settings.

= Does AffCoupon work with AMP? =

Yes - AMP support is included for all coupon shortcodes.

= Can I use AffCoupon in widget areas? =

Yes. The plugin ships with a widget that displays coupons and deals in any widget area.

= Where can I find the shortcode for a coupon? =

You can copy the shortcode from the **Coupons** list page, or insert it directly from the post editor using the **Add Coupon** button.

== Naming and Prefixes ==

All identifiers introduced by this plugin use one of AffCoupon's owned prefixes:

* `affcoupon_` / `AFFCOUPON_` - PHP constants, globals, the plugin slug, and the text domain.
* `WPAF_` - class names.
* `wpaf_` - function names, plugin source file names, PHP hook/action names, option keys, post type and taxonomy slugs, AJAX action names, script and style handles, nonces, and CSS class names.

The legacy `[aff-coupon]` shortcode tag is preserved only so that existing posts that use `[aff-coupon ...]` continue to render. It is *not* the plugin's text domain.

== Source Code and Build Tools ==

Every JavaScript file authored by this plugin is shipped unminified and human-readable: `assets/js/main.js` (frontend) and `assets/admin/js/admin.js` (admin). There is no compiled or bundled plugin JavaScript.

The only minification applied is to the plugin's CSS. Each minified stylesheet has its unminified source committed alongside it in the package:

* `assets/css/dist/style.min.css` -> source `assets/css/style.css`
* `assets/admin/css/dist/admin.min.css` -> source `assets/admin/css/admin.css`
* `assets/admin/css/dist/jquery-ui.min.css` -> source `assets/admin/css/jquery-ui.css`
* `assets/admin/css/dist/welcome.min.css` -> source `assets/admin/css/welcome.css`

When `SCRIPT_DEBUG` is enabled, the unminified sources are loaded directly. See `assets/README.md` for the full asset inventory.

== Third-Party Libraries ==

This plugin bundles the following third-party JavaScript add-ons. These are *not* present in WordPress core and are loaded with `wp_enqueue_script()` as dependencies of WordPress's bundled jQuery (`array( 'jquery' )`):

* "The Final Countdown" - a countdown add-on for jQuery, by Edson Hilios (MIT License). File: `assets/js/jquery.countdown.min.js`. Attribution and full MIT text: `assets/js/jquery.countdown.LICENSE.txt`. This is a jQuery add-on, *not* a copy of jQuery itself.
* jQuery UI Timepicker add-on (MIT License) by Trent Richardson. File: `assets/admin/js/jquery-ui-timepicker.js`. Attribution: `assets/admin/js/jquery-ui-timepicker.LICENSE.txt`. Depends on the jQuery UI bundled with WordPress core.

All other JavaScript and CSS in the plugin is original work by the plugin author.

== Changelog ==

= 1.3.1 =
* Changed: Every feature is now available unconditionally, with no license, plan, activation, or "valid user" checks anywhere in the plugin. The internal plan/license helper and all feature gates have been removed so the plugin is fully functional out of the box, in line with the WordPress.org plugin directory guidelines.
* Removed: "Upgrade to Pro", "Get License Key", and "Purchase License Key" promotional links, the unused upgrade page, and the related admin notices.

= 1.3 =
* Fixed: The `[affcoupon_btn]` coupon-code button rendered twice due to a duplicated render hook; it now renders once.
* Fixed: The hidden-coupon popup is now moved to the page body before it opens, so it stays centered on themes whose layout uses CSS transforms (previously it could appear off to one side).
* Fixed: The "Copy code" button now works on current WordPress (which bundles clipboard.js v2). Copying is handled by a single built-in routine that uses the modern Clipboard API with a fallback, and shows a "Copied" confirmation on every coupon template.
* Performance: Frontend CSS/JS now load only on pages that actually render coupons (coupon archive, coupon/vendor taxonomy, the coupon widget, or posts that use an AffCoupon shortcode) instead of site-wide.
* Security: Inline coupon styles are now passed through an output-escaping function (`wp_strip_all_tags()`) when added via `wp_add_inline_style()`.
* Security: The admin "restored to revision" notice no longer reads the unverified `revision` request value; the revision title is derived from the post's own revisions.
* Security: The CSV/XML import AJAX handler verifies its nonce and `current_user_can()` capability before any request data is processed.
* Security: Coupon meta-box fields are now run through a context-appropriate core sanitizer at the point each value is read from the request.
* Security: Admin asset loading now identifies plugin screens by their admin hook suffix and AJAX render-mode by the active hook, rather than reading request variables.
* Security: The CSV/XML import form now carries a nonce that is verified before any submitted values are read back into the page.

= 1.2 =
* Fixed: Settings saved on the Settings page were not being read by frontend templates due to an internal prefix mismatch. All settings now apply correctly on the frontend.
* Fixed: Frontend coupon-submission form now uses an explicit nonce + capability check on the server side.
* Fixed: Per-term taxonomy image option name is now properly prefixed (`affcoupon_taxonomy_term_*`).
* Fixed: Google Fonts on the welcome page now load via `wp_enqueue_style()` instead of a raw `<link>` tag.
* Security: Sanitized inputs on the CSV/XML import preview form to prevent stored XSS.
* Removed: The arbitrary "Custom CSS" textarea, per WordPress.org plugin directory guidelines (use the Customizer "Additional CSS" panel instead).
* Internal: Aligned the plugin text domain with the plugin slug (`affcoupon`). Renamed all internal `wpcd_*` identifiers to AffCoupon-owned prefixes.
* Internal: Documented bundled third-party libraries and the webpack build pipeline in this readme.

= 1.1 =
* Minor bug fixes.
* Update modal made responsive.
* More mobile-friendly responsive layout.
* Updated functions for faster coupon loading.

= 1.0 =
*Release Date: September 1, 2023*

* Initial release.
* Hide Coupons.
* Coupon expiration countdown.
* Coupon Templates.
* Show Specific Coupons.
* Show Coupons of a specific Category.
* Show Coupons of a specific Vendor.
* Coupons Archive Page.
* Frontend Coupon Submission.

Full changelog: **[AffCoupon Changelog](https://couponthemes.net/)**

== Upgrade Notice ==

= 1.3.1 =
All features are now fully available with no license or activation checks, per WordPress.org guidelines. Recommended for all users.

= 1.3 =
Performance and security update: plugin assets now load only where coupons appear, and several admin/AJAX inputs are sanitized and escaped more strictly. Recommended for all users.

= 1.2 =
Important update. Fixes a long-standing bug where Settings page values were not being applied on the frontend, hardens the frontend coupon-submission form, and meets the current WordPress.org plugin directory guidelines. Recommended for all users.
