Skip to content

Commit 0f580ff

Browse files
committed
Merge remote-tracking branch 'origin/main' into chore-update-examples-iteration-1
2 parents 63b7396 + e8fb779 commit 0f580ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+13665
-69
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"pnpm": {
1010
"overrides": {
1111
"@babel/runtime": "7.27.0",
12-
"webpack-dev-server@<=5.2.0": ">=5.2.1"
12+
"webpack-dev-server@<=5.2.0": ">=5.2.1",
13+
"on-headers@<1.1.0": ">=1.1.0",
14+
"form-data@>=4.0.0 <4.0.4": ">=4.0.4"
1315
}
1416
},
1517
"scripts": {

plugins/composer-packages.json

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
{
22
"packages": {
33
"wpengine/hwp-previews": {
4+
"0.0.8": {
5+
"name": "wpengine/hwp-previews",
6+
"version": "0.0.8",
7+
"type": "wordpress-plugin",
8+
"description": "A WordPress plugin for headless previews.",
9+
"homepage": "https://github.com/wpengine/hwptoolkit",
10+
"license": "GPL-2.0",
11+
"authors": [
12+
{
13+
"name": "WP Engine Headless OSS Development Team",
14+
"email": "[email protected]",
15+
"homepage": "https://wpengine.com/"
16+
}
17+
],
18+
"support": {
19+
"issues": "https://github.com/wpengine/hwptoolkit/issues",
20+
"email": "[email protected]"
21+
},
22+
"dist": {
23+
"url": "https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fhwp-previews-wordpress-plugin-0.0.8/hwp-previews.zip",
24+
"type": "zip"
25+
},
26+
"require": {
27+
"composer/installers": "~1.0 || ~2.0"
28+
}
29+
},
430
"0.0.7": {
531
"name": "wpengine/hwp-previews",
632
"version": "0.0.7",
@@ -106,7 +132,61 @@
106132
}
107133
}
108134
},
135+
"wpengine/wpgraphql-debug-extensions": {
136+
"0.0.1": {
137+
"name": "wpengine/wpgraphql-debug-extensions",
138+
"version": "0.0.1",
139+
"type": "wordpress-plugin",
140+
"description": "A WordPress plugin for wpgraphql debug extensions.",
141+
"homepage": "https://github.com/wpengine/hwptoolkit",
142+
"license": "GPL-2.0",
143+
"authors": [
144+
{
145+
"name": "WP Engine Headless OSS Development Team",
146+
"email": "[email protected]",
147+
"homepage": "https://wpengine.com/"
148+
}
149+
],
150+
"support": {
151+
"issues": "https://github.com/wpengine/hwptoolkit/issues",
152+
"email": "[email protected]"
153+
},
154+
"dist": {
155+
"url": "https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-debug-extensions-plugin-0.0.1/wpgraphql-debug-extensions.zip",
156+
"type": "zip"
157+
},
158+
"require": {
159+
"composer/installers": "~1.0 || ~2.0"
160+
}
161+
}
162+
},
109163
"wpengine/wp-graphql-webhooks": {
164+
"0.0.4": {
165+
"name": "wpengine/wp-graphql-webhooks",
166+
"version": "0.0.4",
167+
"type": "wordpress-plugin",
168+
"description": "Headless webhooks for WPGraphQL",
169+
"homepage": "https://github.com/wpengine/hwptoolkit",
170+
"license": "GPL-2.0",
171+
"authors": [
172+
{
173+
"name": "WP Engine Headless OSS Development Team",
174+
"email": "[email protected]",
175+
"homepage": "https://wpengine.com/"
176+
}
177+
],
178+
"support": {
179+
"issues": "https://github.com/wpengine/hwptoolkit/issues",
180+
"email": "[email protected]"
181+
},
182+
"dist": {
183+
"url": "https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.4/wp-graphql-webhooks.zip",
184+
"type": "zip"
185+
},
186+
"require": {
187+
"composer/installers": "~1.0 || ~2.0"
188+
}
189+
},
110190
"0.0.3": {
111191
"name": "wpengine/wp-graphql-webhooks",
112192
"version": "0.0.3",

plugins/hwp-previews/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# HWP Previews
22

3+
## 0.0.8
4+
5+
### Patch Changes
6+
7+
- [#333](https://github.com/wpengine/hwptoolkit/pull/333) [`cf0a040`](https://github.com/wpengine/hwptoolkit/commit/cf0a0405ae04e0355745a81bf53b3c9065f10739) Thanks [@ahuseyn](https://github.com/ahuseyn)! - 1. Disables Faust front-end redirects for preview url's to solve the iframe conflict. 2. Introduced methods in Faust_Integration to replace Faust-generated preview URLs with the site’s home URL as needed.
8+
39
## 0.0.7
410

511
### Patch Changes

plugins/hwp-previews/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "wordpress-plugin",
44
"description": "A WordPress plugin for headless previews.",
55
"license": "GPL-2.0",
6-
"version": "0.0.7",
6+
"version": "0.0.8",
77
"authors": [
88
{
99
"name": "WP Engine Headless OSS Development Team",

plugins/hwp-previews/hwp-previews.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Author: WPEngine Headless OSS Team
88
* Author URI: https://github.com/wpengine
99
* Update URI: https://github.com/wpengine/hwptoolkit
10-
* Version: 0.0.7
10+
* Version: 0.0.8
1111
* Text Domain: hwp-previews
1212
* Domain Path: /languages
1313
* Requires at least: 6.0
@@ -67,7 +67,7 @@ function hwp_previews_init(): void {
6767
*/
6868
function hwp_previews_constants(): void {
6969
if ( ! defined( 'HWP_PREVIEWS_VERSION' ) ) {
70-
define( 'HWP_PREVIEWS_VERSION', '0.0.7' );
70+
define( 'HWP_PREVIEWS_VERSION', '0.0.8' );
7171
}
7272

7373
if ( ! defined( 'HWP_PREVIEWS_PLUGIN_DIR' ) ) {

plugins/hwp-previews/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wpengine/hwp-previews-wordpress-plugin",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"private": true,
55
"description": "Headless Previews solution for WordPress: fully configurable preview URLs via the settings page.",
66
"scripts": {

plugins/hwp-previews/readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: GraphQL, Headless, Previews, WPGraphQL, React, Rest
44
Requires at least: 6.0
55
Tested up to: 6.8.1
66
Requires PHP: 7.4
7-
Stable tag: 0.0.7
7+
Stable tag: 0.0.8
88
License: GPL-2.0
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html
1010

plugins/hwp-previews/src/Hooks/Preview_Hooks.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace HWP\Previews\Hooks;
66

77
use HWP\Previews\Admin\Settings\Fields\Settings_Field_Collection;
8+
use HWP\Previews\Integration\Faust_Integration;
89
use HWP\Previews\Preview\Parameter\Preview_Parameter_Registry;
910
use HWP\Previews\Preview\Post\Post_Editor_Service;
1011
use HWP\Previews\Preview\Post\Post_Preview_Service;
@@ -226,6 +227,13 @@ public function update_preview_post_link( string $preview_link, WP_Post $post ):
226227

227228
// If the iframe option is enabled, we need to resolve preview on the template redirect level.
228229
if ( $post_type_service->is_iframe() ) {
230+
$faust_helper = new Faust_Integration();
231+
232+
// If Faust post & category rewrites enabled, we should revert the preview link rewrites.
233+
if ( $faust_helper->is_faust_rewrites_enabled() ) {
234+
return $faust_helper->replace_faust_preview_rewrite( $preview_link );
235+
}
236+
229237
return $preview_link;
230238
}
231239

plugins/hwp-previews/src/Integration/Faust_Integration.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,41 @@ public function register_faust_admin_notice(): void {
181181
}, 10, 0 );
182182
}
183183

184+
/**
185+
* Check if Faust rewrites are enabled.
186+
*/
187+
public function is_faust_rewrites_enabled(): bool {
188+
if ( $this->get_faust_enabled() && function_exists( '\WPE\FaustWP\Settings\is_rewrites_enabled' ) ) {
189+
return (bool) \WPE\FaustWP\Settings\is_rewrites_enabled();
190+
}
191+
192+
return false;
193+
}
194+
195+
/**
196+
* Replace Faust preview rewrites with the home URL.
197+
*
198+
* @param string $url The URL to be rewritten.
199+
*/
200+
public function replace_faust_preview_rewrite($url): string {
201+
if ( ! function_exists( '\WPE\FaustWP\Settings\faustwp_get_setting' ) ) {
202+
return $url;
203+
}
204+
205+
$frontend_uri = \WPE\FaustWP\Settings\faustwp_get_setting( 'frontend_uri' );
206+
207+
// Return the URL as is if frontend uri is empty.
208+
if ( ! $frontend_uri ) {
209+
return $url;
210+
}
211+
212+
$frontend_uri = trailingslashit( $frontend_uri );
213+
$home_url = trailingslashit( get_home_url() );
214+
215+
216+
return str_replace( $frontend_uri, $home_url, $url );
217+
}
218+
184219
/**
185220
* Dismiss the Faust admin notice.
186221
*/
@@ -202,9 +237,26 @@ protected function configure_faust(): void {
202237
// Remove FaustWP post preview link filter to avoid conflicts with our custom preview link generation.
203238
remove_filter( 'preview_post_link', 'WPE\FaustWP\Replacement\post_preview_link', 1000 );
204239

240+
// Prevent Faust from redirecting preview URLs to the frontend in iframe mode.
241+
$this->disable_faust_redirects();
242+
205243
$this->display_faust_admin_notice();
206244
}
207245

246+
/**
247+
* Disable Faust's redirect functionality for preview URLs.
248+
*/
249+
protected function disable_faust_redirects(): void {
250+
add_action( 'template_redirect', static function (): void {
251+
// Only run for preview URLs (e.g., ?p=ID&preview=true).
252+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce verification not required for disabling front-end redirects.
253+
if ( isset( $_GET['preview'] ) && 'true' === $_GET['preview'] ) {
254+
// Remove Faust's redirect callback.
255+
remove_action( 'template_redirect', 'WPE\FaustWP\Deny_Public_Access\deny_public_access', 99 );
256+
}
257+
}, 10, 0 );
258+
}
259+
208260
/**
209261
* If Faust is enabled, show an admin notice about the migration on the settings page.
210262
*/

plugins/wp-graphql-webhooks/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# @wpengine/wpgraphql-webhooks-wordpress-plugin
22

3+
## 0.0.4
4+
5+
### Patch Changes
6+
7+
- [#336](https://github.com/wpengine/hwptoolkit/pull/336) [`cff50ab`](https://github.com/wpengine/hwptoolkit/commit/cff50abcdaccecbefe4969312df14f94d11663d7) Thanks [@josephfusco](https://github.com/josephfusco)! - fix: security improvements for webhooks plugin
8+
9+
- Enhanced input validation and sanitization
10+
- Improved output escaping
11+
- Strengthened authorization checks
12+
- Added additional security hardening measures
13+
314
## 0.0.3
415

516
### Patch Changes

0 commit comments

Comments
 (0)