Skip to content

Conversation

n7studios
Copy link
Contributor

Summary

The Plugin may display an admin notice in the WordPress dashboard when:

  • Member Content is enabled on a Page, Post, or Custom Post Type, and
  • a third-party caching plugin requires manual configuration to ensure proper functionality.

Previously, the query used to check whether Member Content was enabled ran on every admin request, making it inefficient for sites with a large number of posts (for example, this reported case with 450,000 pages).

This PR improves performance by:

  • Optimizing the SQL query, resulting in approximately 60% faster execution, using a raw SQL query in favour of WP_Query, which resulted in unnecessary joins
  • Running the query only when a Page, Post, or Custom Post Type is created, updated, or deleted, and caching the result for reuse (vs. the current behaviour of running this on every admin UI request)

Before:
before1

before2

After:
after1

after2

Testing

  • Renamed RestrictContentIPInRangeTest to RestrictContentTest
  • Added integration tests to RestrictContentTest to confirm cached result is correctly set depending on existence of Member Content
  • Existing integration tests with caching plugins will pass, confirming admin notices correctly display, which now use this cached result

Checklist

@n7studios n7studios self-assigned this Oct 7, 2025
@n7studios n7studios added the bug label Oct 7, 2025
Copy link

WordPress Playground

🚀 Your PR has been built and is ready for testing in WordPress Playground!

Click here to test your changes in WordPress Playground

@n7studios n7studios requested review from a team, corydhmiller and noelherrick and removed request for a team October 10, 2025 12:23
@n7studios n7studios marked this pull request as ready for review October 10, 2025 12:23
Copy link

WordPress Playground

🚀 Your PR has been built and is ready for testing in WordPress Playground!

Click here to test your changes in WordPress Playground

@n7studios n7studios merged commit 2d82880 into main Oct 11, 2025
524 of 560 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants