Skip to content

Add Public Post Preview compatibility shim to RSA#345

Closed
benlk wants to merge 3 commits into
developfrom
feat/344-integrate-with-public-post-preview
Closed

Add Public Post Preview compatibility shim to RSA#345
benlk wants to merge 3 commits into
developfrom
feat/344-integrate-with-public-post-preview

Conversation

@benlk
Copy link
Copy Markdown

@benlk benlk commented Mar 7, 2025

Description of the Change

This substantially integrates the shim wp-plugin-ppp-rsa-compat.php into Restricted Site Access.

The shim reimplements significant portions of Public Post Preview's functionality, because the methods in PPP used to verify whether the preview link is valid are set to private access.

I'm filing this PR against RSA, but if this feature is better implemented in PPP, I have a corresponding PR against PPP here: ocean90/public-post-preview#184

Resolves #344

How to test the Change

  1. Enable PPP and RSA on the same site.
  2. Create a draft post.
  3. Verify that the draft post is visible to logged-in users, and blocked for logged-out users.
  4. Enable PPP for the post.
  5. Verify that the draft post is visible to both logged-in users and logged-out users.
  6. Disable PPP for the post.
  7. Verify that the draft post is visible to logged-in users, and blocked for logged-out users.

Changelog Entry

Added - Compatibility with Public Post Preview to allow logged-out users to view preview links.

Credits

Props @benlk

Checklist:

@benlk
Copy link
Copy Markdown
Author

benlk commented Mar 7, 2025

This PR is a draft because, while the shim has been tested on live sites, I have not tested this specific PR's code in any environment. There's a PHPCS fail, and tests and docs are needed before this is ready for merge.

However, this PR should be sufficient to determine whether this PR or ocean90/public-post-preview#184 is preferred.

@jeffpaul jeffpaul requested review from a team and peterwilsoncc and removed request for a team March 7, 2025 18:22
@jeffpaul
Copy link
Copy Markdown
Member

Bumping this to @10up/open-source-practice for input on preferred approach

@dkotter
Copy link
Copy Markdown
Collaborator

dkotter commented Apr 25, 2025

Bumping this to @10up/open-source-practice for input on preferred approach

Looking at the code here, seems we're copying a lot of functionality from Public Post Preview so I think the ideal outcome here is getting a fix within that plugin instead of here.

That said, we obviously have more control of RSA so if we think we have a better chance of getting this fix here, we can proceed with this.

@peterwilsoncc
Copy link
Copy Markdown
Contributor

peterwilsoncc commented Apr 27, 2025

@jeffpaul @dkotter I added some notes on the issue to discuss what user expectations are when installing both RSA and PPP. tl;dr: do they wish to allow full access to preview posts via ppp or do they wish to only allow the restricted users to preview posts via ppp?

#344 (comment)

@jeffpaul
Copy link
Copy Markdown
Member

do they wish to allow full access to preview posts via ppp or do they wish to only allow the restricted users to preview posts via ppp?

My initial reaction here is restricted to only those who have access via RSA, to default towards the more secure/restricted approach.

@peterwilsoncc
Copy link
Copy Markdown
Contributor

My initial reaction here is restricted to only those who have access via RSA, to default towards the more secure/restricted approach.

This is my strong inclination too.

@benlk Do you have bandwidth to repurpose this PR to provide documentation as to how to add a filter to allow ppp links through and add any hooks to the existing code base that are required to achieve this?

@jeffpaul jeffpaul modified the milestones: 7.6.0, 7.7.0 Oct 23, 2025
@benlk
Copy link
Copy Markdown
Author

benlk commented Nov 6, 2025

@peterwilsoncc I don't have bandwidth to add more than a short comment pointing at this PR, or at a gist version of the shim, describing them as reference implementations.

add any hooks to the existing code base that are required to achieve this

The restricted_site_access_is_restricted hook is sufficient. The main issue is that, unless ocean90/public-post-preview#184 is merged, any developer seeking to recreate the functionality that this PR provides will have to independently re-implement the code that PPP uses to determine if a given request is a valid PPP link.

@jeffpaul regarding

My initial reaction here is restricted to only those who have access via RSA, to default towards the more secure/restricted approach.

That approach is already satisfied by the combination of RSA and PPP, without this shim. Without this shim, PPP parses requests after RSA checks whether the user can view the whole site. People who can't pass RSA don't see the PPP link.

This shim moves parsing of requests for PPP-validity to before RSA checks the request, and bypasses RSA for PPP-validated requests.

@peterwilsoncc
Copy link
Copy Markdown
Contributor

Without this shim, PPP parses requests after RSA checks whether the user can view the whole site. People who can't pass RSA don't see the PPP link.

This shim moves parsing of requests for PPP-validity to before RSA checks the request, and bypasses RSA for PPP-validated requests.

I remain of the view that this is the correct default behaviour and that site owners wishing to use PPP to allow all to access an RSA protected site should use the filter.

I'm going to close this pull request off and document on the issue that a snippet would be helpful for users wishing to do the reverse.

@jeffpaul jeffpaul removed this from the 7.7.0 milestone Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate with Public Posts Preview

4 participants