=== Connect for Mobilox ===
Contributors: naiches
Tags: mobilox, hexon, vehicles, inventory, sync
Requires at least: 7.0
Tested up to: 7.0
Requires PHP: 8.4
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Sync your Mobilox/Hexon vehicle inventory to WordPress — real-time incremental sync and bulk XML import.

== Description ==

Connect for Mobilox syncs your vehicle inventory from the Mobilox/Hexon dealer management system to your WordPress site. Vehicles are stored as a configurable post type with full data available to your theme.

**Features:**

* Real-time sync — vehicles are added, updated, and removed automatically via the DV incremental XML feed.
* Configurable post type — sync to the built-in "Vehicle" post type or any existing custom post type in your theme.
* Full data storage — every field Mobilox sends is stored in a custom table as JSON, accessible via template helpers.
* Image management — diff-based: only new images are downloaded, unchanged images keep their attachment IDs, removed images are cleaned up.
* Endpoint security — protect your sync endpoint with a secret token or HTTP Basic Auth.
* Status dashboard — see synced vehicle count, errors, last sync time, and a full activity log.
* Read-only meta box — view all vehicle data grouped by category on the post editor.

**For theme developers:**

Access vehicle data in your templates:

    $vehicle = mobilox_get_vehicle();
    echo $vehicle->{'general.make.name'};
    echo $vehicle->{'powertrain.engine.power.pk'} . ' pk';

Or field by field:

    echo mobilox_get_field( 'body.colour.name_nl' );

== Installation ==

1. Upload the plugin to `/wp-content/plugins/` or install via Plugins → Add New.
2. Activate the plugin.
3. Go to **Mobilox → Settings** and select a post type.
4. Copy the endpoint URL from the **Mobilox → Dashboard** page into your DV management tool.
5. Vehicles will sync automatically as Mobilox pushes updates.

== Frequently Asked Questions ==

= Which post type should I choose? =

If your theme already has a vehicle/occasion post type, select that. Otherwise, use the built-in "Mobilox Vehicle" type. You can change this at any time — existing vehicles will continue to work.

= How do I access vehicle data in my theme? =

Use `mobilox_get_vehicle( $post_id )` to get the full data object, or `mobilox_get_field( 'field.name' )` for a single field. Field names match the Mobilox XML element names (e.g. `general.make.name`, `powertrain.engine.power.pk`).

= Is the sync endpoint secure? =

By default, the endpoint is open (for easy setup). Go to Settings to add a secret token or HTTP Basic Auth credentials.

== Screenshots ==

1. The Mobilox dashboard — vehicle count, sync status, endpoint URL, and activity log.
2. Settings — post type selector, endpoint security, and log retention.

== Changelog ==

= 1.1.0 =
* Complete rewrite — OOP architecture with namespaced classes.
* Custom database table for vehicle data (no postmeta bloat).
* Configurable post type — sync to any existing CPT or the built-in one.
* XML-only sync (v2.23+ compatible) — dropped legacy POST field support.
* Diff-based image handling — only downloads new/changed images.
* Secured REST endpoint with token and HTTP Basic Auth.
* Admin dashboard with stats, activity log, and endpoint URL.
* Read-only meta box showing all vehicle data grouped by category.
* Template helper functions for theme developers.
* Full uninstall cleanup (tables, posts, attachments, options).

= 1.0.0 =
* Initial version.
