=== DomToRaj Integration ===
Contributors: domtoraj
Donate link: https://domtoraj.pl/
Tags: real estate, property listings, synchronization, domtoraj, agency
Requires at least: 5.8
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0.15
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Sync property listings from DomToRaj.pl with WordPress (custom post type, shortcodes, search UI).

== Description ==

This plugin connects your WordPress site to your DomToRaj.pl agency account.

* Imports listings as a custom post type (`domtoraj_property`, labeled “Nieruchomości” in the admin), with prefixed taxonomies for offer type and location. Public URLs use the `/nieruchomosci/…` rewrite base (singles and archive).
* **Automatic synchronization** (WP-Cron, hourly by default) plus manual sync from the admin screen.
* **Shortcodes** for a searchable list you can place on any page.
* Data is fetched from the official DomToRaj API (requires the **Business** plan on your DomToRaj account).

**DomToRaj requirements**

* An agency or developer account on [domtoraj.pl](https://domtoraj.pl).
* An active **Business** plan and valid **agency ID** and **API key** from the integration / API section in your account.

If the Business plan is not active, the API returns a permission error; the plugin shows the message in the admin and during sync.

== External services ==

This plugin connects to the external DomToRaj API service to download agency data and property listings required to display offers in WordPress.

Service provider: DomToRaj.pl
Service URL: https://domtoraj.pl/

Data sent and when:
* Agency ID (configured in plugin settings) is sent in the API endpoint path on each sync request.
* API key (configured in plugin settings) is sent in the `X-Api-Key` request header on each sync request.
* Requests are sent when the admin runs manual sync and during scheduled WP-Cron synchronization.

Terms of Service: https://domtoraj.pl/p/regulamin-dla-biur-nieruchomosci
Privacy Policy: https://domtoraj.pl/p/polityka-prywatnosci

== Installation ==

1. Install the plugin from the WordPress plugin directory (once published) or upload the `domtoraj-integration` folder to `wp-content/plugins/`.
2. Activate the plugin under **Plugins**.
3. Go to **DomToRaj → Settings**, enter your **agency ID** and **API key**, and save.
4. Run **Sync now** or wait for the scheduled sync.
5. Create a results page and add the shortcodes `[domtoraj_wyszukiwarka]` and `[domtoraj_lista_ofert]` (in that order) to the content.

== Frequently Asked Questions ==

= Where do I get the agency ID and API key? =

Log in to domtoraj.pl, open **Integration** / **API** in your agency settings, and copy the values into the plugin.

= Why does sync return HTTP 403? =

Usually: inactive **Business** plan, expired subscription, or wrong API key / agency ID. The API message is shown in the plugin admin.

= Does the plugin work with the free Start plan? =

No. WordPress listing sync requires the **Business** plan on DomToRaj.

= How do I show listings on the home page? =

Use `[domtoraj_lista_ofert]` with optional attributes, e.g. `[domtoraj_lista_ofert limit="6" typ_oferty="sprzedaz"]` (`typ_oferty` and `lokalizacja` are shortcode attribute names; they filter by term slug on the plugin taxonomies).

== Screenshots ==

1. Single listing page with photo gallery, key facts, description, map and agency contact.
2. Search form and latest listings on the home page (shortcodes in an Elementor layout).
3. Plugin settings: subscription status, statistics, manual sync and agency data from DomToRaj.

== Changelog ==

= 1.0.15 =
* WordPress.org guidelines: prefixed internal identifiers for the listings post type and taxonomies (`domtoraj_property`, `domtoraj_offer_type`, `domtoraj_location`); automatic one-time migration from older unprefixed keys; public rewrite base remains `/nieruchomosci/`.
* Permalink fix: rebuild rewrite rules on `init` (after CPT registration), not during `plugins_loaded` migration — avoids missing rules and 301/404 to the homepage after the CPT rename.

= 1.0.14 =
* Security and compliance update: stricter agency ID sanitization and documented external service links (terms and privacy policy).

= 1.0.13 =
* Minor fixes and API compatibility (including error messages from `message` / `error` fields).

= 1.0.0 =
* Initial release: CPT, taxonomies, sync, shortcodes, templates.

== Upgrade Notice ==

= 1.0.15 =
Update recommended: prefixed CPT/taxonomy identifiers, migration, and permalink rewrite flush fix. If URLs look wrong once, open Settings → Permalinks and click Save.

= 1.0.14 =
Recommended update with stricter settings sanitization and external services documentation.
