You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/plugins/hwp-previews/explanation/core-concepts/index.md
+98-1Lines changed: 98 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,4 +3,101 @@ title: "Core Concepts"
3
3
description: "Deep dive explanations of the HWP Previews plugin's core concepts, architecture, and systems."
4
4
---
5
5
6
-
@TODO
6
+
## Overview
7
+
8
+
This article provides an in-depth exploration of the fundamental concepts that power the HWP Previews plugin, covering the template-based URL system that enables framework-agnostic preview generation, the parameter registry that makes URLs dynamic and context-aware, the flexible post type configuration system, solutions for WordPress hierarchical content challenges, and the different preview modes available to content creators.
9
+
10
+
## Core Architectural Concepts
11
+
12
+
### 1. Preview URL Templates with Dynamic Parameters
13
+
14
+
At the heart of HWP Previews is the concept of URL templates. Instead of hardcoding preview URLs, administrators define templates using placeholder tokens that get dynamically replaced with actual post data.
This template approach ensures framework agnosticity, whether you're using Next.js with `/api/preview?slug={slug}`, a custom React app with `/preview/{ID}`, or any other front-end architecture. The system generates context-rich URLs that can pass any information your front-end needs to handle previews intelligently, from basic post data to complex hierarchical relationships.
27
+
28
+
#### The Parameter Registry System
29
+
30
+
HWP Previews maintains a parameter registry, a centralized collection of available dynamic parameters. Out of the box, it provides:
31
+
32
+
-`{ID}` – Post ID
33
+
-`{author_ID}` – Post author's user ID
34
+
-`{status}` – Post status (draft, pending, etc.)
35
+
-`{slug}` – Post slug
36
+
-`{parent_ID}` – Parent post ID (for hierarchical types)
37
+
-`{type}` – Post type slug
38
+
-`{template}` – Template filename
39
+
40
+
This registry is extensible through WordPress filters, allowing developers to add custom parameters (e.g., `{category}`, `{custom_field}`, or `{locale}` for multilingual sites).
41
+
42
+
### 2. Post Type-Specific Configuration
43
+
44
+
WordPress sites often have diverse content types (posts, pages, custom post types) each potentially requiring different preview handling. To address this challenge, HWP Previews provides per-post-type configuration.
45
+
46
+
For each public post type, you can independently configure:
47
+
- Whether previews are enabled at all
48
+
- The preview URL template
49
+
- Whether to display previews in an iframe within the editor
50
+
- Whether to allow non-published posts as parents (for hierarchical types)
51
+
52
+
### 3. Hierarchical Post Types and Parent Status
53
+
54
+
WordPress supports hierarchical post types (like pages) where posts can have parent-child relationships. By default, WordPress only allows published posts to be parents. This creates a workflow problem: when building a site, you often want to establish page hierarchies while everything is still in draft.
55
+
56
+
HWP Previews solves this with the "Allow All Statuses as Parent" option. When enabled for a post type, draft, pending, or private posts can serve as parents.
57
+
58
+
### 4. Iframe vs. New Tab Preview Modes
59
+
60
+
HWP Previews offers two preview rendering modes, each suited to different workflows:
61
+
62
+
#### Iframe Mode
63
+
When enabled, previews load directly within the WordPress editor in a sandboxed `<iframe>`. This provides an integrated experience, so you can see your changes alongside the preview, similar to the WordPress theme customizer.
64
+
65
+
#### New Tab Mode
66
+
When disabled, clicking "Preview" opens the preview URL in a new browser tab.
67
+
68
+
### 5. Faust Integration
69
+
70
+
When Faust.js is detected, HWP Previews automatically configures itself to work seamlessly with Faust's preview system. This provides Faust users with an upgrade path that maintains their existing workflows while gaining access to additional features like iframe mode, custom parameters, and per-post-type control.
71
+
72
+
The integration removes potential conflicts by disabling Faust's native preview handling and pre-configuring preview URLs to match Faust's expected structure. This **compatibility without compromise** approach minimizes adoption barriers for users with existing Faust investments.
73
+
74
+
## The Hook System and Extensibility
75
+
76
+
HWP Previews provides a comprehensive system of WordPress actions and filters for extending functionality.
Copy file name to clipboardExpand all lines: docs/plugins/hwp-previews/how-to/configure-previews/index.md
+111-1Lines changed: 111 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,4 +3,114 @@ title: "Configure Previews"
3
3
description: "Learn how to configure preview functionality using the HWP Previews plugin in your headless WordPress application."
4
4
---
5
5
6
-
@TODO
6
+
## Overview
7
+
8
+
This guide shows you how to configure preview URLs for your headless WordPress site using HWP Previews. You'll set up preview links that redirect from WordPress to your front-end application with the necessary context data.
9
+
10
+
> [!TIP]
11
+
> Want to see HWP Previews in action first? Check out the working examples in the `examples/` directory that demonstrate integration with WP GraphQL and REST API. You can run them locally using `wp-env` to test the plugin functionality before configuring your own setup.
12
+
13
+
## Prerequisites
14
+
15
+
- HWP Previews plugin installed and activated
16
+
- A running front-end application with a preview endpoint
17
+
18
+
## 1. Access the settings page
19
+
20
+
1. Log into your WordPress admin dashboard
21
+
2. Navigate to **Settings > HWP Previews**
22
+
23
+

24
+
25
+
You'll see tabs for each public post type on your site (Posts, Pages, and any custom post types).
26
+
27
+
## 2. Configure a post type
28
+
29
+
### a. Enable previews for the post type
30
+
31
+
1. Click on the tab for the post type you want to configure (e.g., "Posts")
32
+
2. Check the "Enable HWP Previews" box
33
+
34
+
> [!NOTE]
35
+
> If you have Faust.js installed, this option will be enabled by default for all post types.
36
+
37
+
### b. Set the preview URL template
38
+
39
+
In the "Preview URL Template" field, enter your front-end preview endpoint URL with dynamic parameters:
-`{parent_ID}` - Parent post ID (for hierarchical types)
52
+
-`{type}` - Post type slug
53
+
-`{template}` - Template filename
54
+
55
+
The parameters sidebar shows descriptions for each available parameter.
56
+
57
+

58
+
59
+
### c. Choose the preview mode
60
+
61
+
Select how you want previews to display:
62
+
63
+
-**Iframe mode**: Check "Load Previews in Iframe" to display previews within the WordPress editor
64
+
-**New tab mode**: Leave unchecked to open previews in a new browser tab
65
+
66
+
For iframe mode to work, your front-end must not set restrictive `X-Frame-Options` headers.
67
+
68
+
### d. Optional: Configure hierarchical post types (Pages only)
69
+
70
+
For hierarchical post types like Pages, you can allow draft posts to be parents by checking "Allow All Statuses as Parent" and saving changes, which lets you build page hierarchies before publishing content.
71
+
72
+

73
+
74
+
## 3. Save your settings
75
+
76
+
Click the "Save Changes" button at the bottom of the page.
77
+
78
+
## 4. Test the preview
79
+
80
+
1. Open any post of the configured type in the editor
81
+
2. Make a change to the content
82
+
3. Click the "Preview" button
83
+
84
+
If configured correctly:
85
+
-**Iframe mode**: The preview loads within the editor
86
+
-**New tab mode**: A new tab opens with your front-end preview URL
87
+
88
+
The URL will include the dynamic parameters you specified, for example:
3. Removes Faust.js's native preview link filter to prevent conflicts
31
+
4. Disables Faust's redirect functionality for preview URLs
32
+
5. Shows an admin notice on the settings page confirming the integration
33
+
34
+
The `{FAUST_FRONTEND_URI}` is automatically pulled from your Faust.js settings. If not configured, it defaults to `http://localhost:3000`.
35
+
36
+
### Authentication
37
+
HWP Previews handles preview URL generation, but authentication remains the responsibility of your Faust front-end application. Continue using [Faust.js authentication](https://faustjs.org/docs/how-to/authentication/) to access draft content in previews.
38
+
39
+
## 2. Verify the integration
40
+
41
+
1. Go to **Settings > HWP Previews**
42
+
2. Check any post type tab (Posts, Pages, etc.)
43
+
3. Verify that:
44
+
- "Enable HWP Previews" is checked
45
+
- The Preview URL Template contains your Faust front-end URL
46
+
47
+

48
+
49
+
## 3. Test previews
50
+
51
+
1. Open any post in the WordPress editor
52
+
2. Click the "Preview" button
53
+
3. You should be redirected to your Faust front-end preview endpoint
0 commit comments