# Edocman Lite – Frontend Page Creation Guide (English)

This guide explains how to create public-facing pages for Edocman Lite using WordPress shortcodes.

---

## Available Shortcodes

| Shortcode | Description |
|---|---|
| `[edocman_lite_categories]` | Display the list of document categories |
| `[edocman_lite_documents]` | Display documents (optionally filtered by category) |
| `[edocman_lite_document]` | Display the detail view of a single document |
| `[edocman_lite_upload_document]` | Frontend upload form (logged-in users only) |
| `[edocman_lite_my_documents]` | List of documents uploaded by the logged-in user |

---

## 1. Categories List Page

**Purpose:** Show all top-level document categories. Clicking a category takes the visitor to the documents in that category.

**Steps:**
1. Create a new WordPress Page (e.g. "Document Categories").
2. Add the shortcode to the page body:

   ```
   [edocman_lite_categories]
   ```

3. Publish the page.

**Shortcode parameters:**

| Parameter | Default | Description |
|---|---|---|
| `parent_id` | `0` | Show categories under this parent (0 = top-level) |
| `show_description` | `1` | Show category description (1 = yes, 0 = no) |
| `show_image` | `1` | Show category thumbnail (1 = yes, 0 = no) |

**Example – show sub-categories of category #5:**
```
[edocman_lite_categories parent_id="5"]
```

---

## 2. Category Detail / Documents in a Category

**Purpose:** Display the list of documents belonging to a specific category.

You can use either of the following methods:

### Method A – Using the category list page (automatic)

When a visitor clicks a category on the Categories List page, the URL automatically adds `?cat_id=X` and the same page displays the documents for that category.

### Method B – Dedicated page per category

Create a page with the following shortcode, replacing `5` with the actual category ID:

```
[edocman_lite_documents category_id="5"]
```

**Shortcode parameters:**

| Parameter | Default | Description |
|---|---|---|
| `category_id` | `0` | Filter documents by category (0 = all) |
| `limit` | `10` | Maximum number of documents to display |
| `show_description` | `1` | Show document description (1 = yes, 0 = no) |

---

## 3. Documents List Page

**Purpose:** Show all published documents regardless of category.

1. Create a new WordPress Page (e.g. "All Documents").
2. Add the shortcode:

   ```
   [edocman_lite_documents]
   ```

3. Publish the page.

---

## 4. Document Detail Page

**Purpose:** Show the full details of a single document, including title, description, file size, download button, and view button.

**Automatic navigation:** When a visitor clicks a document title on the Documents List page, the URL adds `?doc_id=X` and the same page renders the document detail view automatically.

**Dedicated detail page:** If you want a separate detail page, create a page and add:

```
[edocman_lite_document]
```

The shortcode reads the `doc_id` query parameter from the URL to determine which document to display.

---

## 5. Upload Document Page (requires login)

**Purpose:** Allow registered users to upload their own documents for review.

1. Create a new WordPress Page (e.g. "Upload Document").
2. Add the shortcode:

   ```
   [edocman_lite_upload_document]
   ```

3. Publish the page.

Visitors who are **not logged in** will see a message asking them to login. Logged-in users will see an upload form with:
- Title (required)
- Category selector
- Description
- File picker

Uploaded documents are saved with `published = 0` (pending review). An administrator can then publish them from the Documents admin page.

---

## 6. My Documents Page (requires login)

**Purpose:** Show each registered user a list of the documents they have uploaded, with the ability to delete them.

1. Create a new WordPress Page (e.g. "My Documents").
2. Add the shortcode:

   ```
   [edocman_lite_my_documents]
   ```

3. Publish the page.

---

## Recommended Page Structure

A typical site structure using all shortcodes:

```
Home
├── Document Categories    → [edocman_lite_categories]
│   └── (clicking a category shows documents via ?cat_id=X)
│       └── (clicking a document shows details via ?doc_id=X)
├── All Documents          → [edocman_lite_documents]
├── Upload Document        → [edocman_lite_upload_document]
└── My Documents           → [edocman_lite_my_documents]
```

---

## Version Update Detection

Edocman Lite checks WordPress.org for a newer version once every 12 hours. If a newer version is found, a notice is displayed on the **Configuration** admin page (Edocman Lite → Configuration) with a link to download the update.

The mechanism:
1. The plugin calls `https://api.wordpress.org/plugins/info/1.0/edocman-lite.json`.
2. The response (including the latest version number) is cached in a WordPress transient named `edocman_lite_version_info` for 12 hours to avoid excessive HTTP requests.
3. The cached version number is compared against the current `EDOCMAN_LITE_VERSION` constant.
4. If the remote version is higher, an update notice is shown.
