=== WC Korkmaz Contract – Contracts for WooCommerce ===
Contributors: yemliha24
Donate link: https://yemlihakorkmaz.com
Tags: woocommerce, contract, agreement, pdf, checkout
Requires at least: 6.0
Requires PHP: 7.4
Tested up to: 6.9.1
Stable tag: 2.4.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automatically builds, displays, and emails legally compliant contracts (PDF) on the WooCommerce checkout page.

== Description ==
This plugin lets you create distance sales contracts, pre-information forms, and fully custom legal contracts for WooCommerce. It automatically fills the contracts at checkout and emails them as PDF attachments after order confirmation.

* Fully compatible with WooCommerce’s new **block-based** checkout.
* Add and edit legal contracts from the WordPress admin.
* Insert any order/customer/store data into any part of your contract via placeholders.
* Automatically generate contracts on the checkout page.
* Automatically send contracts in **PDF** format upon order confirmation.
* View past contracts on both admin and customer order pages.
* Store emailed PDFs under the WordPress **uploads** directory and serve customer downloads through protected links.

https://www.youtube.com/watch?v=wKfnfilEIk4

== Installation ==
1. Download the plugin here or install it from **Plugins → Add New** in your WordPress dashboard.
2. (Manual) Upload and extract the archive into `/wp-content/plugins/`.
3. Go to **Plugins → Installed Plugins** and click **Activate**.
4. A new **Contracts** menu will appear in the admin — add your contracts there.

== Frequently Asked Questions ==

= Is it completely free to use? =
Yes. The plugin is completely free to use. No charges apply.

= I don’t want PDFs to be sent via email. Can I disable this? =
Yes. There is a setting on the plugin’s settings page to disable PDF email attachments.

= How are stored contract PDFs protected on Apache and Nginx? =
The plugin writes an Apache `.htaccess` rule into the contract PDF folder and serves customer/admin downloads through protected WordPress URLs. Nginx does not read `.htaccess`, so the settings screen includes a direct-access security check and a copyable Nginx `location` rule for your server block.

= How can I disable the ID/Tax number fields? =
Use the option on the plugin’s settings page to hide or disable those fields.

= I need more support. What should I do? =
Please email: yemlihakorkmaz@hotmail.com

== Screenshots ==
1. Contracts – Admin menu
2. Settings section
3. Options section
4. First contract edit screen
5. Second contract edit screen
6. Placeholder insertion in contract editor
7. Using placeholders anywhere in the text
8. Checkout – Contract display and confirmation
9. Checkout – Viewing contracts in a modal
10. Thank-you page – Contract display
11. My Account → Orders – Contract view
12. Mapping checkout field IDs for placeholders

== Localization ==
This plugin is translation-ready. Source strings are in **en_US** (English – United States).
Contribute translations here:
https://translate.wordpress.org/projects/wp-plugins/wc-korkmaz-contract/

== External Services ==
* **yemlihakorkmaz.com/sozlesmeornek.txt** — used to fetch the default contract template.
  Data sent: none (HTTP GET). Privacy: https://yemlihakorkmaz.com/privacy

This external request is used only when contract templates are empty and the plugin needs a sample template.

== Changelog ==

= 2.4.2 =
* Security: Contract PDFs are now served through protected download URLs instead of direct public uploads links.
* Security: Added an admin PDF storage security check with Apache and Nginx server-rule guidance.
* Security: Checkout AJAX, contract template saving, and PDF downloads now include nonce checks.
* Security: Contract snapshots are generated server-side from order data, while legacy meta keys remain compatible.
* Compatibility: Block checkout now sends and validates contract approval on the Store API side.
* Compatibility: Block checkout contract approval now migrates to the default terms area before the place order button.
* Compatibility: Classic shortcode checkout now has stronger contract field fallbacks and clearer approval validation.
* Admin: Fields mapping screen now offers selectable checkout fields plus manual custom selectors.
* Privacy: Removed the checkout-time external IP lookup from the block integration.
* PDF: Restricted Dompdf remote fetching to same-site hosts by default and strengthened PDF filename generation.
* Admin: Restricted plugin assets to plugin admin screens and fixed the email status value mismatch.
* Release: Updated the stable tag to match the plugin version.

= 2.3.8 =
* Fix: Block checkout entegrasyonu korunurken `register_block_type_from_metadata()` frontend'de query sonrasi zamana alinarak `is_feed was called incorrectly` notice'i engellendi.
* Fix: Block checkout'ta sozlesme blogu gorunurlugu korunur.

= 2.3.7 =
* Fix: Block checkout'ta sozlesme blogunun gorunmemesine neden olan entegrasyon zamanlamasi duzeltildi.
* Compatibility: Block checkout auto-insert ozelligi korunarak frontend render kaydi geri uyumlu hale getirildi.

= 2.3.6 =
* New: Block tabanli checkout sayfasinda `irem/ozel-sozlesmeler` blogu yoksa otomatik olarak checkout icerigine eklenir.
* Compatibility: Klasik checkout (`[woocommerce_checkout]`) kullanan sayfalarda herhangi bir otomatik icerik degisikligi yapilmaz.

= 2.3.5 =
* Fix: Aktivasyon sonrası görülen `Function is_feed was called incorrectly` notice'ı için blok entegrasyon kaydı frontend'de query sonrası zamana alındı.
* Fix: Blok editör stili erken enqueue edilmek yerine güvenli şekilde register edilir.

= 2.3.4 =
* New: Logging açıkken admin ayarlar ekranında log çıktısı (son kayıtlar) gösterilir.
* Fix: Erken aşamada conditional tag çağrılarına karşı checkout context kontrolü güçlendirildi (`is_feed` notice önlendi).
* Update: Log ayarı açık/kapalı davranışı korunarak yeni log görünümü eklendi.

= 2.3.3 =
* New: Admin panelde "Enable plugin logging" ayarı eklendi.
* Update: Plugin logları varsayılan olarak kapalı; yalnızca ayar açıldığında yazılır.
* Performance: Gereksiz checkout log yazımı kapatılarak disk I/O azaltıldı.

= 2.3.2 =
* PDF: `render_shortcodes()` içinde `the_content` fallback kaldırıldı; tema/eklenti kaynaklı harici içerik enjeksiyonu engellendi.
* Stabilite: PDF boyutu ve render yükü düşürülerek checkout sırasında timeout/504 riskleri azaltıldı.

= 2.3.1 =
* Checkout: `[satin_alinan_urunler]` sipariş özeti artık DOM yerine sunucu tarafında oluşturuluyor (ürün, adet, toplam).
* Modal: Daha sağlam Tingle modal altyapısına geçildi ve arayüz yenilendi.
* Cache: CSS/JS dosyaları için otomatik sürümleme (filemtime) eklendi.

= 2.3.0 =
* Güvenlik: PDF klasörüne otomatik .htaccess ve index.php eklenerek dizin listeleme ve arama motoru indekslemesi engellendi.
* PDF içeriği: `[satin_alinan_urunler]` ve `[sepettoplami]` sipariş verilerinden (ürün, varyasyon meta, toplam) dolduruluyor; Checkout DOM’una bağlılık kaldırıldı.
* Kısa kodlar: Sözleşme metninde üçüncü parti kısa kodlar `do_shortcode` + `the_content` filtresiyle işleniyor; modal ve PDF’te çalışıyor.
* UX: Checkout sözleşme JS’inde son anda yapılan değişiklikler form gönderiminde yakalanıyor; gereksiz döngüler engelleniyor.

= 2.2.1 =
* Fix: Updated `checkout-contracts.js` to improve reliability on checkout updates.

= 2.2.0 =
*New: Added Turkish (tr_TR) translation (.po/.mo and JS JSON).
*New: Implemented wp_set_script_translations() for block/JS translation loading.
*Fix: Minor stability and text improvements.

= 2.1.5 =
* Fixed an language function.

= 2.1.4 =
* Fixed an admin-page function.

= 2.1.3 =
* Fixed PHP version handling.

= 2.1.2 =
* Fixed various issues.

= 2.1.1 =
* Fixed various issues.

= 2.1.0 =
* Tested with WordPress 6.8.
* Added nonce verification to all POST handlers.
* Replaced direct filesystem calls with the WP_Filesystem API.
* Minor security and code-quality improvements.

= 2.0.9 =
* Fixed a JavaScript issue.

= 2.0.8 =
* Fixed a JavaScript issue.

= 2.0.7 =
* Fixed a JavaScript issue.

= 2.0.6 =
* Fixed mail attachments.

= 2.0.5 =
* Fixed a PDF URL error.

= 2.0.4 =
* Fixed HTML errors.
* Resolved errors during PDF creation.
* Fixed an issue preventing contracts from being attached to emails.

= 2.0.3 =
* Modernized the settings-page UI.
* Added a settings link on the Plugins screen.
* General bug fixes.

= 2.0.2 =
* General bug fixes.

= 2.0.1 =
* General bug fixes.

= 2.0 =
* Added support for WooCommerce’s new block-based checkout.
* Resolved errors during PDF creation.
* Fixed issues occurring during email PDF delivery.
* Security updates and code optimizations.

= 1.3.3 =
* Fixed an HTML tag error during PDF creation.

= 1.3.2 =
* Added a settings option to control contract sending conditions.
* Fixed a filename issue related to HPOS updates.

= 1.3.1 =
* Added separate placeholders for first name, last name, tax office, tax number, and company name.
* Fixed an issue with a single placeholder replacement.
* Fixed an escape-character display issue in the modal.

= 1.3 =
* Updated for WordPress 6.3.2 compatibility.
* Resolved JavaScript issues.
* Added individual/corporate option for ID and tax office fields.

= 1.2 =
* Updated for WordPress 3.6 compatibility.
* Fixed an input issue with payment-method info.
* Added default field information alongside the fields.

= 1.1.3 =
* Fixed an issue where contracts were not emailed upon order completion.
* Fixed modal-related issues.
* Fixed a regression introduced in 1.1.2.

= 1.1.2 =
* Added an “Fields” admin section for defining which checkout fields feed the placeholders.
* Fixed potential modal issues.
* General improvements.

= 1.1.1 =
* Fixed a contract URL issue in multisite setups.

= 1.1 =
* Fixed several issues from the latest update.

= 1.0.9 =
* Improved language-selection options in the plugin.

= 1.0.8 =
* Replaced Bootstrap and jquery.modal with HystModal to resolve compatibility issues.

= 1.0.7 =
* Removed unnecessary code.

= 1.0.6 =
* Removed Bootstrap and Tingle libraries.
* Fixed city/district selection error.
* Fixed an ID-number related issue.

= 1.0.5 =
* Fixed an error caused by JavaScript.

= 1.0.4 =
* Fixed incorrect contract URLs shown on the Thank-you page.

= 1.0.3 =
* Added a special placeholder for product-related tables.
* Corrected incorrect placeholders.
* Adjusted emailed filenames to match contract titles.

= 1.0.2 =
* Fixed errors when disabling features on the settings page.
* General bug fixes.

= 1.0.1 =
* Added an option to toggle ID/Tax numbers.
* Removed the print button.
* Fixed modal slowdowns on the checkout page.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==
= 1.0.0 =
Please back up your contracts before installing or uninstalling the plugin.
