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 `