From 788f0a9e9477a50828b8bde06166d1742a06fd08 Mon Sep 17 00:00:00 2001 From: ahuseyn Date: Wed, 18 Jun 2025 15:26:24 +0200 Subject: [PATCH 1/3] docs: add docs box to wp-admin --- .../hwp-previews/assets/css/hwp-previews.css | 15 +++++++++++++++ plugins/hwp-previews/assets/icons/doc.svg | 3 +++ .../Settings/Templates/settings-page-main.php | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 plugins/hwp-previews/assets/icons/doc.svg diff --git a/plugins/hwp-previews/assets/css/hwp-previews.css b/plugins/hwp-previews/assets/css/hwp-previews.css index e84eb182..0fbb51b7 100644 --- a/plugins/hwp-previews/assets/css/hwp-previews.css +++ b/plugins/hwp-previews/assets/css/hwp-previews.css @@ -56,3 +56,18 @@ visibility: visible; opacity: 1; } + +.hwp-previews-docs ul li { + list-style-type: none; + margin-left: 30px; + padding-bottom: 16px; +} + +.hwp-previews-docs ul li:before { + content: url(../icons/doc.svg); + height: 1em; + margin-left: -29px; + margin-top: -2px; + position: absolute; + width: 0.5em; +} diff --git a/plugins/hwp-previews/assets/icons/doc.svg b/plugins/hwp-previews/assets/icons/doc.svg new file mode 100644 index 00000000..2bc45f26 --- /dev/null +++ b/plugins/hwp-previews/assets/icons/doc.svg @@ -0,0 +1,3 @@ + + + diff --git a/plugins/hwp-previews/src/Admin/Settings/Templates/settings-page-main.php b/plugins/hwp-previews/src/Admin/Settings/Templates/settings-page-main.php index ab59c525..450a996c 100644 --- a/plugins/hwp-previews/src/Admin/Settings/Templates/settings-page-main.php +++ b/plugins/hwp-previews/src/Admin/Settings/Templates/settings-page-main.php @@ -2,6 +2,8 @@ declare(strict_types=1); +use HWP\Previews\Integration\Faust_Integration; + $hwp_previews_tabs_config = (array) get_query_var( 'hwp_previews_main_page_config' ); $hwp_previews_current_tab = (string) ( $hwp_previews_tabs_config['current_tab'] ?? '' ); $hwp_previews_tabs = (array) ( $hwp_previews_tabs_config['tabs'] ?? [] ); @@ -55,6 +57,23 @@ + +
+

+
+ +
    +
  • +
  • + +
  • + +
  • +
+

+

HWP Toolkit on GitHub

+
+
From 4e93ed6f340694f1589d8ae3b27c9f2442c3cee1 Mon Sep 17 00:00:00 2001 From: ahuseyn Date: Wed, 18 Jun 2025 15:26:35 +0200 Subject: [PATCH 2/3] docs: add Faust usage info and update readme --- plugins/hwp-previews/ACTIONS_AND_FILTERS.md | 2 +- plugins/hwp-previews/README.md | 107 +++++++++++++------- 2 files changed, 73 insertions(+), 36 deletions(-) diff --git a/plugins/hwp-previews/ACTIONS_AND_FILTERS.md b/plugins/hwp-previews/ACTIONS_AND_FILTERS.md index 4318bb03..ac6f3b3b 100644 --- a/plugins/hwp-previews/ACTIONS_AND_FILTERS.md +++ b/plugins/hwp-previews/ACTIONS_AND_FILTERS.md @@ -32,7 +32,7 @@ Modify which post types appear in the settings UI: ```php // Removes attachment post type from the settings page configuration. -add_filter( 'hwp_previews_filter_post_type_setting', 'hwp_previews_filter_post_type_setting_callback' ); +add_filter( 'hwp_previews_filter_available_post_types', 'hwp_previews_filter_post_type_setting_callback' ); function hwp_previews_filter_post_type_setting_callback( $post_types ) { if ( isset( $post_types['attachment'] ) ) { unset( $post_types['attachment'] ); diff --git a/plugins/hwp-previews/README.md b/plugins/hwp-previews/README.md index 5a4ff21c..ff727373 100644 --- a/plugins/hwp-previews/README.md +++ b/plugins/hwp-previews/README.md @@ -11,11 +11,14 @@ ## Table of Contents -* [Overview](#overview) -* [Features](#features) -* [Configuration](#configuration) -* [Hooks & Extensibility](#hooks--extensibility) -* [Integration](#integration) +- [Overview](#overview) +- [Features](#features) +- [Getting Started](#getting-started) +- [Configuration](#configuration) +- [Front-End Integration](#front-end-integration) +- [Using With Faust.js](#using-with-faustjs) +- [Extending the Functionality](#extending-the-functionality) +- [Testing](#testing) ## Overview @@ -27,51 +30,62 @@ With HWP Previews, you can define dynamic URL templates, enforce unique slugs fo ## Features -* **Enable/Disable Previews**: Turn preview functionality on or off for each public post type (including custom types). -* **Custom URL Templates**: Define preview URLs using placeholder tokens for dynamic content. Default tokens include: +- **Enable/Disable Previews**: Turn preview functionality on or off for each public post type (including custom types). +- **Custom URL Templates**: Define preview URLs using placeholder tokens for dynamic content. +- **Parent Status**: Allow posts of **all** statuses to be used as parent within hierarchical post types. +- **Highly Customizable**: Extend core behavior with a comprehensive set of actions and filters. - * `{ID}` – Post ID - * `{author_ID}` – Post author’s user ID - * `{status}` – Post status slug - * `{slug}` – Post slug - * `{parent_ID}` – Parent post ID (hierarchical types) - * `{type}` – Post type slug - * `{template}` – Template filename +--- + +## Getting Started + +This guide will help you set up your first headless preview link for the "Posts" post type. -* **Unique Post Slugs**: Force unique slugs for all post statuses in the post status config. -* **Parent Status**: Allow posts of **all** statuses to be used as parent within hierarchical post types. -* **Default Post Statuses Config**: `publish`, `future`, `draft`, `pending`, `private`, `auto-draft` (modifiable via core hook). -* **Parameter Registry**: Register, unregister, or customize URL tokens through the `hwp_previews_core` action. -* **Iframe Template for Previews**: Allows enable previews in the iframe on the WP Admin side. User can override the iframe preview template via `hwp_previews_template_path` filter. +1. **Activate the Plugin:** Ensure "HWP Previews" is installed and activated. +2. **Navigate to Settings:** Go to **Settings > HWP Previews** in your WordPress admin dashboard. +3. **Enable for Posts:** On the "Posts" tab check the "Enable HWP Previews" box. If you have Faust installed this option will be enabled by default. Find more information about Faust integration below. +4. **Set the Preview URL:** In the "Preview URL Template" field for Posts, enter the URL for your front-end application's preview endpoint. Use parameters to add dynamic information that you want to access. +5. **Save and Test:** Save changes and go to any post, make a change, and click the "Preview" button. You should be redirected to the URL you just configured. --- +## Configuration -## Actions & Filters +HWP Previews configuration located at **Settings > HWP Previews** page in your WP Admin. The settings are organized by post type. -See the [Actions & Filters documentation](ACTIONS_AND_FILTERS.md) for a comprehensive list of available hooks and how to use them. +### Settings -## Configuration +For each public post type, you can configure: -### Default Post Types Config: -All public post types are enabled by default on the settings page. It is filterable via `hwp_previews_filter_post_type_setting` filter hook. +- **Enable HWP Previews:** This is the master switch for the post type. If disabled, WordPress will revert to its default preview behavior for these posts. +- **Allow All Statuses as Parent:** This option is only available for Pages type. By default, WordPress only allows published posts to be parents. Enable this to build parent-child relationships using draft or pending posts. +- **Load Previews in Iframe:** When enabled, the preview will be displayed directly within the WordPress editor in a sandboxed `