=== SAVP Boost for Leyka ===
Contributors: studioavp
Tags: leyka, donations, utm, analytics, fundraising
Requires at least: 6.4
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Requires Plugins: leyka

Additional tools for the Leyka donation plugin: UTM tracking, form improvements and campaign controls. Requires Leyka 3.20+.

== Description ==

**SAVP Boost for Leyka** is an all-in-one add-on for the [Leyka](https://wordpress.org/plugins/leyka/) donation plugin. It combines three powerful modules into a single plugin, replacing the need for separate add-ons.

= UTM Tracker =

Track the source of every donation with full UTM attribution support.

* Captures UTM parameters (source, medium, campaign) from donor URLs and cookies
* First touch and last touch attribution models
* Donations table with filters by source, medium, campaign, status and date range
* Analytics dashboard: top traffic sources, top campaigns, first→last touch paths
* Pagination (25 records per page) and CSV export
* UTM link generator with history

= Toolkit =

Improve your Leyka donation forms with useful UI additions.

* Newsletter subscription checkbox — adds a customizable opt-in checkbox to donation forms, assigns a donor tag on successful donation
* Recurring payment consent checkbox — adds a mandatory consent checkbox for recurring donations, blocks form submission until checked, assigns a donor tag

= Close Campaign (Закрыть сбор) =

Give your team control over donation campaigns directly from the frontend.

* Toggle button on donation forms to open or close a campaign with one click
* Configurable minimum amount threshold and auto-toggle threshold
* Activation and deactivation statistics
* Customizable button appearance (colors, icon, border)

= Unified Event Log =

All three modules write to a single shared event log.

* Color-coded badges for modules and log levels (ERROR / INFO / DEBUG)
* Filter by module and log level
* Search by message
* Download log file
* Auto-rotation with configurable retention period (default: 30 days)

= Module Controls =

Each module can be enabled or disabled independently from the main Settings page.

== Installation ==

1. Make sure the [Leyka](https://wordpress.org/plugins/leyka/) plugin (version 3.20 or higher) is installed and active.
2. Upload the `savp-boost-for-leyka` folder to `/wp-content/plugins/`.
3. Activate the plugin through the **Plugins** menu in WordPress.
4. Go to **Leyka Boost → Settings** to configure each module.

**Note:** If you were previously using the separate leyka-utm-tracker, leyka-toolkit, or leyka-close-campaign plugins, deactivate and delete them before activating SAVP Boost for Leyka. Your existing data will be preserved.

== Frequently Asked Questions ==

= What plugins are required? =

SAVP Boost for Leyka requires the [Leyka](https://wordpress.org/plugins/leyka/) donation plugin version 3.20 or higher to be installed and active.

= Will I lose data if I switch from the separate add-ons? =

No. SAVP Boost for Leyka uses the same database table and option keys as the original separate plugins (leyka-utm-tracker, leyka-toolkit, leyka-close-campaign). Your existing UTM data, settings, and statistics will be available immediately after activation.

= Can I use only some modules? =

Yes. Each module (UTM Tracker, Toolkit, Close Campaign) can be enabled or disabled independently from **Leyka Boost → Settings**.

= Where are log files stored? =

Log files are stored in `wp-content/uploads/savp-boost-for-leyka/logs/`. The directory is protected from direct access via `.htaccess`. Log filenames include a random hash for additional security.

= Does it work with multisite? =

The plugin uses `wp_upload_dir()` for log file paths, which is multisite-compatible. Full multisite support has not been explicitly tested — use with caution on multisite installations.

= Is it compatible with the latest WordPress? =

Yes. SAVP Boost for Leyka has been tested up to WordPress 7.0.

= How do I export UTM data? =

Go to **Leyka Boost → UTM Tracker**, apply any filters you need, and click the **Export CSV** button. The export respects active filters.

= How does the Close Campaign toggle work? =

When enabled, a toggle button appears on donation forms on the frontend. Clicking it opens or closes the campaign. The toggle is visible only to users with the appropriate permissions (configurable in settings).

= What happens to my log files when I uninstall the plugin? =

When the plugin is deleted through the WordPress admin, all plugin options, the UTM tracker database table, and the log directory are removed. This behavior can be reviewed in `uninstall.php`.

== Screenshots ==

1. Main Settings page — manage modules and logging preferences
2. UTM Tracker — donation statistics with source analytics and filters
3. Toolkit — newsletter subscription and recurring payment consent settings

== Changelog ==

= 1.0.5 =
* UTM Tracker (analytics, link generator with history, settings and CSV export) is now available to users with the Editor role, not just Administrator. Editor is not granted `manage_options` or any other elevated capability; access uses the standard `edit_pages` capability that Administrator and Editor already share.
* Toolkit, Close Campaign, the shared event log and plugin-wide settings remain Administrator-only.

= 1.0.4 =
* Fixed Close Campaign spamming ERROR log entries for campaigns without a target amount: absence of a target is a normal Leyka campaign state, not a plugin error.
* The Close Campaign toggle script (and its background AJAX call) is no longer added to the page at all for campaigns without a target amount, since the goal-completion check does not apply to them.
* The `savpblf_close_get_sums` AJAX endpoint still handles a missing/non-positive target safely, but now logs it at DEBUG level instead of ERROR.

= 1.0.3.1 =
* Fixed UTM Tracker journal pagination: page 2+ links are now a GET form with submit buttons instead of `<a href>` links, so the page number no longer needs to survive as an `&`/`&#038;`-containing query string inside HTML markup.
* Pagination controls now visually match the plugin's event log pagination (compact WP-core buttons, right-aligned, active/disabled states).

= 1.0.3 =
* Fixed the Close Campaign toggle to always reflect the campaign's current collected amount, using Leyka's total_funded data.
* The toggle's state now updates via a background AJAX request instead of relying on the cached page, so full-page caching plugins (e.g. WP Rocket) no longer show a stale amount.

= 1.0.2 =
* Fixed recurring consent donor tag assignment after a donation transitions to funded.
* Added support for Leyka's leyka_donation_funded_status_changed hook.
* Improved compatibility with Leyka separated donation storage.
* Uses Leyka donation meta API for recurring consent with fallback for older postmeta data.

= 1.0.1 =
* Hardened SQL queries with wpdb->prepare() for consistency.
* Removed unused SAVPBLF_CLOSE_LOGS_URL constant and get_log_url() method.
* Replaced deprecated current_time('timestamp') with time().
* Added rate-limiting for frontend AJAX statistics endpoint.

= 1.0.0 =
* Initial release.
* UTM Tracker: donation UTM tracking with first/last touch attribution, analytics, CSV export and link generator.
* Toolkit: newsletter subscription checkbox and recurring payment consent checkbox for donation forms.
* Close Campaign: frontend toggle button to open/close donation campaigns with statistics.
* Unified event log with module filtering, level badges, search and auto-rotation.
* Russian and English localization included.

== Upgrade Notice ==

= 1.0.5 =
UTM Tracker (analytics, generator, CSV export, settings) is now accessible to Editor users, not only Administrator.

= 1.0.3 =
Fixes the Close Campaign toggle showing an outdated collected amount on sites using full-page caching (e.g. WP Rocket).

= 1.0.2 =
Fixes recurring consent donor tag assignment and improves separated donation storage compatibility.

= 1.0.1 =
Security audit polish: hardening, cleanup and consistency improvements without feature changes.

= 1.0.0 =
Initial release.
