Skip to content

Prevent maintenance mode from changing front page setting - #565

Open
poonam279 wants to merge 2 commits into
masterfrom
fix/564-preserve-show-on-front
Open

poonam279 wants to merge 2 commits into
masterfrom
fix/564-preserve-show-on-front

Conversation

@poonam279

@poonam279 poonam279 commented Sep 17, 2026

Copy link
Copy Markdown

Summary

  • record the initial show_on_front value once before maintenance mode changes it
  • preserve that initial value across repeated active requests
  • restore and remove the saved value when maintenance mode is disabled or the plugin is deactivated
  • clean up the temporary option on uninstall
  • add regression coverage for both disable and deactivation lifecycles

Testing

  • PHP lint and PHPCS
  • PHPStan
  • PHPUnit on PHP 7.2 with WordPress 6.4
  • PHPUnit on PHP 7.4 with WordPress latest
  • git diff --check

Fixes #564

@pirate-bot

pirate-bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Plugin build for 1d0856e is ready 🛎️!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new override ignores existing bot and system-request bypass rules, potentially serving maintenance content to exempt requests.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Prevents maintenance mode from permanently modifying WordPress’s front-page setting.

Changes:

  • Replaces persisted show_on_front changes with a request-time filter.
  • Adds regression coverage for visitor/admin option behavior.
File summaries
File Description
includes/classes/wp-maintenance-mode.php Adds conditional front-page override.
tests/page-state-test.php Tests preservation of Reading settings.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

add_filter(
'pre_option_show_on_front',
function ( $value ) {
if ( ( ! $this->check_user_role() && ! $this->check_exclude() ) && isset( $this->plugin_settings['design']['page_id'] ) && get_option( 'wpmm_new_look' ) ) {
Comment thread tests/page-state-test.php
wp_set_current_user( 0 );
$this->boot_plugin( $this->make_settings( 1, $page_id ) );

$this->assertSame( 'page', get_option( 'show_on_front' ) );

Copilot AI commented Sep 17, 2026

Copy link
Copy Markdown

One or more custom setup steps configured for this repository failed during this Copilot code review run:

Start the WordPress environment via wp-env

Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review.

Note

You can configure setup steps for Copilot code review separately from Copilot cloud agent with a copilot-code-review.yml file. Read the docs for details.

@selul

selul commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

I think is better to store the initial value in a new option and use that on deactivation.

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.

Activating LightStart corrupts show_on_front option, breaking front-page.php template loading

4 participants