=== Tenant Referral Program ===
Contributors: offertown
Tags: referral, affiliate, marketing, tracking, widget
Requires at least: 5.0
Tested up to: 6.4
Requires PHP: 7.4
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A comprehensive referral program plugin that allows users to sign up and track referrals through widgets and signup forms.

== Description ==

The Tenant Referral Program plugin provides a complete solution for managing referral programs on your WordPress site. It includes:

* **Referral Widget**: Display an iframe widget for your referral program
* **Signup Form**: Allow users to register and automatically track referral conversions
* **API Integration**: Seamlessly integrates with your referral tracking system
* **Cookie Tracking**: Automatically tracks referral codes through cookies
* **Admin Settings**: Easy-to-use settings panel for configuration

== Installation ==

= Setup Steps =

1. **Install Offertown Plugin**
   - Upload the plugin files to `/wp-content/plugins/tenant-referral-program` directory
   - Activate the plugin through the 'Plugins' screen in WordPress

2. **Configure Plugin Settings**
   - Go to Settings → Offertown in WordPress admin
   - Enter your API credentials:
     * API Key: Your tenant-specific API key from Offertown dashboard
     * API Base URL: https://offertown.net (auto-filled)
   - Click "Save Settings" to verify the connection

3. **Add Shortcodes**
   The plugin automatically detects your tenant ID from the API key and connects to production.

== Frequently Asked Questions ==

= What shortcodes are available? =

* `[tenant_referral_widget]` - Displays the referral program widget iframe
* `[tenant_referral_signup]` - Displays the referral signup form

= How do I configure the plugin? =

Go to Settings → Offertown in your WordPress admin to configure the API key and verify connection status.

= Is this compatible with my existing referral system? =

Yes, the plugin is designed to integrate with external referral tracking systems via API calls.

= How does authentication work? =

The plugin uses API key authentication to securely communicate with the Offertown platform. No additional authentication plugins are required.

= How do I get my API key? =

1. Log into your Offertown admin panel at https://offertown.net
2. Navigate to Settings -> API Keys
3. Create a new WordPress Plugin key
4. Copy the key and paste it in the plugin settings

== Screenshots ==

1. Admin settings page
2. Referral widget display
3. System status information

== Changelog ==

= 1.1.0 =
* Added customizable agreement text field in plugin settings
* Added customizable Terms & Conditions URL field in plugin settings
* Removed marketing communications checkbox from signup form
* Enhanced form flexibility - admins can now customize legal agreement text and link
* Improved user experience with configurable consent options
* Updated plugin version for better semantic versioning

= 1.0.10 =
* HOTFIX: Fixed critical function redeclaration error with trp_debug_log() causing fatal PHP errors
* Removed duplicate function declaration that was preventing plugin activation
* This is an urgent bugfix for users experiencing "Cannot redeclare trp_debug_log()" errors

= 1.0.9 =
* Fixed Cloudflare integration issues with asset loading and script ordering
* Implemented conditional asset loading to prevent unnecessary CSS/JS on non-referral pages
* Added development mode toggle for cache-busting control in testing environments
* Enhanced HTTPS URL validation with port preservation for development environments
* Fixed shortcode documentation consistency - both [tenant_referral_signup] and [tenant_referral_signup_form] now work
* Improved WordPress superglobal sanitization with proper wp_unslash() usage
* Implemented secure debug logging that respects debug mode settings and redacts sensitive data
* Enhanced widget content inspection to prevent false positives in conditional loading
* Added Cloudflare Rocket Loader compatibility with data-cfasync="false" attribute
* Fixed development mode setting integration across all asset loading logic
* Improved URL conversion to preserve query parameters and fragments during HTTPS enforcement
* Enhanced admin inline styles with dedicated handles for guaranteed output
* Added comprehensive debug flag support for both WP_DEBUG and development mode settings

= 1.0.8 =
* Updated CSS to use theme-aware custom properties for better integration with main platform
* Added support for light/dark mode theme inheritance
* Improved visual consistency with amber-minimal design system
* Enhanced border radius, shadows, and color variables to match parent theme

= 1.0.7 =
* Fixed timeout issues during referral signup - increased API timeout from 15 to 30 seconds
* Improved email notification system to prevent blocking API responses
* Fixed "cURL error 28: Operation timed out" error during referral registration
* Enhanced reliability of referral tracking API calls from WordPress

= 1.0.6 =
* Removed JWT authentication requirement - plugin now uses API key authentication only
* Simplified installation process - no longer requires JWT plugin or wp-config.php modifications
* Updated documentation to reflect authentication changes

= 1.0.5 =
* Updated default API base URL to production environment (offertown.net)
* Updated plugin metadata and branding
* Improved default configuration for new installations

= 1.0.4 =
* CRITICAL FIX: Moved AJAX handler registration to constructor to ensure handlers are always available
* Fixed "Action not found" error that was causing 400 Bad Request responses
* Reduced API timeout from 15 to 5 seconds to prevent form submission timeouts
* Improved form submission reliability and error handling

= 1.0.3 =
* CRITICAL FIX: Removed duplicate nonce field that was causing 400 Bad Request errors on form submission
* Fixed WordPress AJAX handler nonce verification issues
* Improved form submission reliability

= 1.0.2 =
* Fixed form detection logic to properly initialize on referral signup pages
* Fixed nonce verification in PHP handler to check both possible field names
* Improved error handling and debugging capabilities
* Enhanced referral code field handling with fallback support

= 1.0.1 =
* Initial release
* Referral widget integration
* Signup form with referral tracking
* API integration for conversion tracking
* Cookie-based referral code persistence

= 1.0.0 =
* Initial release
* Referral widget shortcode
* Admin settings panel
* API client integration
* Cookie tracking support
* Backward compatibility with existing shortcodes

== Upgrade Notice ==

= 1.1.0 =
New features: Customizable agreement text and Terms URL in settings. Marketing checkbox removed from signup form. Update to get these new configuration options.

= 1.0.2 =
Critical bug fixes for form submission and referral tracking. Update immediately to resolve 400 Bad Request errors.

= 1.0.1 =
Added signup form functionality and enhanced tracking capabilities.

= 1.0.0 =
Initial release of the Tenant Referral Program plugin. 