=== DM Mobile Location ===
Contributors: dependentmedia
Tags: location, food truck, mobile, map, gps
Requires at least: 5.0
Tested up to: 6.4
Requires PHP: 7.4
Stable tag: 2.2.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Track and display your food truck location. Update via iPhone app, display on your website with an interactive map.

== Description ==

DM Mobile Location allows you to update your business location from your iPhone and display it on your WordPress website. Perfect for food trucks, mobile vendors, pop-up shops, and any business that moves!

**Key Features:**

* Update location from your iPhone with one tap
* Interactive map display on your website
* Automatic address lookup
* "Get Directions" button for customers
* Multiple location support (for fleets)
* Customizable map styles and markers
* Secure API with rate limiting

== Installation ==

= Step 1: Install the Plugin =

1. Download the `dm-mobile-location.zip` file
2. In WordPress admin, go to **Plugins → Add New**
3. Click **Upload Plugin** at the top
4. Choose the zip file and click **Install Now**
5. Click **Activate Plugin**

= Step 2: Get Your API Key =

1. Go to **Mobile Location** in the WordPress admin sidebar
2. Click **Security** in the submenu
3. Your API key is displayed on this page
4. **Copy the API key** — you'll need it for the iPhone app

= Step 3: Add the Map to Your Website =

1. Edit the page where you want the map to appear
2. Add this shortcode: `[dm_mobile_location]`
3. Save/publish the page

Until you set a location from the iPhone app, visitors will see "Location coming soon!"

= Step 4: Install the iPhone App =

See the iPhone app README for detailed instructions on building and installing the companion app.

== Using the Plugin ==

= Admin Menu =

After activation, you'll see **Mobile Location** in your WordPress admin sidebar with three pages:

**Locations**
- View all saved locations
- See current coordinates, address, and last update time
- Set which location is "Primary" (shown by default)
- Delete locations

**Map Settings**
- Customize marker color and icon style
- Choose from 6 map tile styles
- Configure popup appearance
- Enable/disable address, time, and directions display

**Security**
- View and regenerate API key
- Configure rate limiting
- Set IP whitelist for API access
- View security log of authentication attempts

= Shortcode Options =

Basic usage:
`[dm_mobile_location]`

Show all locations on one map:
`[dm_mobile_location show="all"]`

Show a specific location by ID:
`[dm_mobile_location id="loc_abc123"]`

Custom dimensions and zoom:
`[dm_mobile_location width="100%" height="500px" zoom="14"]`

Custom message when no location is set:
`[dm_mobile_location no_location_message="Check back soon for our location!"]`

= Map Styles =

Choose from these map styles in **Map Settings**:

* **OpenStreetMap** (Default) - Classic street map
* **CartoDB Positron** - Light, minimal style
* **CartoDB Dark Matter** - Dark theme
* **CartoDB Voyager** - Colorful, detailed
* **Esri World Street** - Detailed street map
* **Esri Satellite** - Aerial imagery

= Marker Icons =

* **Default Pin** - Standard map marker
* **Food Truck** - Truck silhouette icon
* **Restaurant** - Fork and knife icon
* **Star** - Star shape
* **Custom** - Upload your own image (32x32px PNG recommended)

== Security Features ==

= API Key =

- API key is required for all location updates
- Keys are stored securely using password hashing
- Regenerate your key immediately if compromised

= Rate Limiting =

Prevents abuse by limiting API requests per IP address:
- Default: 60 requests per hour
- Customize in Security settings

= IP Whitelist =

Optionally restrict API access to specific IP addresses:
1. Go to **Mobile Location → Security**
2. Enter allowed IPs (one per line)
3. Leave empty to allow all IPs

= HTTPS Requirement =

Enable "Require HTTPS" to reject API requests over insecure connections.

= Security Log =

Monitor all authentication attempts:
- ✓ Successful authentications
- ✗ Invalid API key attempts
- ⚠ Rate limit exceeded
- ✗ IP blocked attempts

== API Reference ==

= Endpoints =

Base URL: `https://yoursite.com/wp-json/dm-mobile-location/v1/`

**GET /location**
Returns the primary location (public, no authentication required)

**GET /locations**
Returns all locations (public)

**GET /location/{id}**
Returns a specific location by ID (public)

**POST /location**
Create or update a location (requires API key)

**POST /location/{id}**
Update a specific location (requires API key)

**DELETE /location/{id}**
Delete a location (requires API key)

= Authentication =

Include your API key in the request header:
`X-API-Key: dm_your_api_key_here`

= Example: Get Current Location =

`curl "https://yoursite.com/wp-json/dm-mobile-location/v1/location"`

Response:
`{
  "success": true,
  "data": {
    "id": "loc_abc123",
    "lat": 37.7749,
    "lng": -122.4194,
    "label": "Parked at Main & 5th",
    "address": "123 Main St, San Francisco, CA",
    "updated": "2026-02-03T14:30:00+00:00",
    "is_primary": true
  }
}`

= Example: Update Location =

`curl -X POST "https://yoursite.com/wp-json/dm-mobile-location/v1/location" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: dm_your_api_key_here" \
  -d '{
    "lat": 37.7749,
    "lng": -122.4194,
    "label": "Lunch spot today!",
    "address": "123 Main St, San Francisco, CA"
  }'`

== Frequently Asked Questions ==

= Do I need the iPhone app? =

The iPhone app is the easiest way to update your location, but you can also use the API directly with any HTTP client or custom app.

= Can I have multiple food trucks? =

Yes! The plugin supports multiple locations. Each truck can update its own location using the same API key, or you can create different location IDs for each truck.

= Does this work with other map plugins? =

This plugin uses Leaflet.js for maps and doesn't conflict with other map plugins. However, only one map library should be loaded per page for best performance.

= How often can I update my location? =

As often as you like! Rate limiting applies to API requests (default 60/hour), but normal usage won't hit this limit.

= Does the map auto-refresh? =

Currently, visitors need to refresh the page to see updated locations. Real-time updates may be added in a future version.

= Can I customize the popup design? =

Yes! Use the Custom CSS field in Map Settings to style the popup. The popup has the class `.dm-popup`.

== Screenshots ==

1. Main Locations page showing API configuration and location list
2. Map Settings page with marker and style options
3. Security page with rate limiting and IP whitelist
4. Frontend map display with popup and directions button
5. iPhone app main screen with map and controls
6. iPhone app settings screen

== Changelog ==

= 2.2.0 =
* iPhone app: Added Auto-Update feature for continuous background location tracking
* iPhone app: Configurable update intervals (1, 5, 15, 30 minutes, or 1 hour)
* iPhone app: Background location indicator shows when auto-update is active
* Updated support links and documentation

= 2.1.2 =
* Added support contact section to Setup Guide
* Updated plugin links to official help center and support email
* Support: support@dependentmedia.com
* Help Center: https://dependentmedia.com/dm-mobile-location-help-center/

= 2.1.1 =
* Added Setup Guide page in WordPress admin
* Comprehensive documentation including quick start, iPhone app setup, shortcode reference, API reference, and troubleshooting
* All documentation now accessible from Mobile Location → Setup Guide

= 2.1.0 =
* Added "Get Directions" button to map popup
* Directions link opens Google Maps with navigation
* Works on mobile (opens native maps app) and desktop
* New setting to enable/disable directions in Map Settings

= 2.0.0 =
* Major update: Multiple locations support
* Security: Rate limiting, IP whitelist, HTTPS enforcement
* Security: API key hashing, security event logging
* Customization: 6 map styles, marker colors, custom icons
* Customization: Popup styling (colors, show/hide elements)
* New admin menu with separate pages
* Migration support for v1.x data

= 1.0.2 =
* Added address field support
* Address displayed in map popup and admin

= 1.0.1 =
* Added shortcode with Leaflet map display

= 1.0.0 =
* Initial release

== Upgrade Notice ==

= 2.1.1 =
Adds comprehensive Setup Guide documentation inside WordPress admin.

= 2.1.0 =
Adds "Get Directions" button to help customers navigate to your location.

= 2.0.0 =
Major update with multiple locations, enhanced security, and customization options. Your existing location and API key will be migrated automatically.
