Skip to content

lite-site: skip module init when Newspack Lite Site plugin is active#4720

Merged
miguelpeixe merged 2 commits into
Automattic:trunkfrom
R1shabh-Gupta:fix/lite-site-conflict-standalone-plugin
May 13, 2026
Merged

lite-site: skip module init when Newspack Lite Site plugin is active#4720
miguelpeixe merged 2 commits into
Automattic:trunkfrom
R1shabh-Gupta:fix/lite-site-conflict-standalone-plugin

Conversation

@R1shabh-Gupta
Copy link
Copy Markdown
Contributor

Description

When the Newspack Lite Site plugin (code here) is active alongside newspack-plugin, both register identical WordPress identifiers and the same settings group (newspack_lite_site), option name (newspack_lite_site_settings), admin menu slug (newspack-lite-site), and rewrite rules. This causes:

  • Doubled settings forms on the Settings > Lite Site admin page and Lite Site → Settings & Appearance page
  • Duplicate sanitize callbacks stacked on sanitize_option_newspack_lite_site_settings.
  • Conflicting rewrite rules registered twice

The standalone plugin defines NEWSPACK_LITE_SITE_PLUGIN_FILE in its main file at load time. Guarding Lite_Site::init() with a check for that constant prevents the built-in module from initializing at all when the standalone plugin is active, eliminating all four collision points.

All Submissions:

Changes proposed in this Pull Request:

Wrap Lite_Site::init() in includes/lite-site/class-lite-site.php with a defined( 'NEWSPACK_LITE_SITE_PLUGIN_FILE' ) guard so the built-in lite-site module is a no-op when the Newspack Lite Site plugin is active.

How to test the changes in this Pull Request:

  1. Activate both newspack-plugin and the Newspack Lite Site plugin.
  2. Navigate to Lite Site → Settings & Appearance and confirm only one settings form is rendered.
  3. Save settings (e.g. toggle "Enable Lite Site", set a URL base) and confirm values persist correctly on reload with no fields stripped.
  4. Check the Settings menu and confirm no "Lite Site" entry appears there.
  5. Deactivate the standalone plugin and confirm the built-in Settings → Lite Site page is still fully functional (module initialises normally when NEWSPACK_LITE_SITE_PLUGIN_FILE is undefined).

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@R1shabh-Gupta R1shabh-Gupta marked this pull request as ready for review May 13, 2026 14:28
@R1shabh-Gupta R1shabh-Gupta requested a review from a team as a code owner May 13, 2026 14:28
Copy link
Copy Markdown
Member

@miguelpeixe miguelpeixe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @R1shabh-Gupta!

It's best to hook this under plugins_loaded to ensure the Lite Site plugin is loaded.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents the built-in Lite Site module inside newspack-plugin from initializing when the standalone Newspack Lite Site plugin is active, avoiding collisions on shared identifiers (settings group/option name, menu slug, and rewrite rules).

Changes:

  • Add an early defined( 'NEWSPACK_LITE_SITE_PLUGIN_FILE' ) guard inside Lite_Site::init() to no-op when the standalone plugin is present.
  • Switch module bootstrapping from an immediate Lite_Site::init(); call to a plugins_loaded hook so the constant check reliably reflects other loaded plugins.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@miguelpeixe miguelpeixe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for revising!

@miguelpeixe miguelpeixe merged commit a17cf24 into Automattic:trunk May 13, 2026
11 checks passed
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.

3 participants