Skip to content

Improve loading and configuration for front page and editor styles - #128

Open
girishpanchal30 wants to merge 5 commits into
developmentfrom
bugfix/theme-compatibility
Open

girishpanchal30 wants to merge 5 commits into
developmentfrom
bugfix/theme-compatibility

Conversation

@girishpanchal30

Copy link
Copy Markdown

Summary

Improved block pattern registration by deferring property initialization to ensure translations and filters are applied correctly, and updated the front-page-hero pattern title for clarity. Strengthened welcome notice security by returning a 403 response for missing or invalid nonces, refined AJAX dismissal and button state handling, and fixed plugin detection using WP_PLUGIN_DIR. Updated editor style loading to use the enqueue_block_assets hook with an admin-context check to prevent unnecessary front-end asset loading. Added comprehensive tests covering block pattern registration, welcome notice behavior, security checks, plugin detection, and editor asset loading.

Closes #118
Closes #119
Closes #120
Closes #121
Closes #122

@pirate-bot

Copy link
Copy Markdown
Contributor

Plugin build for ac05e27 is ready 🛎️!

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes requested

The welcome-notice fixes work, but the design-pack dismissal and the Otter activation flow still hide their notice after a rejected request.

Questions for the author

  • Does enqueue_block_assets run with is_admin() true in every supported editor context from WordPress 5.5 to 6.4? Source shows it on the block editor screen at 5.5 and 6.4 only.

  • inc/Admin.php:104-112 — correctness The dismissal fix covers only the welcome notice. The design-pack notice keeps the same failure. With an expired or missing nonce, its dismiss handler returns silently. WordPress then answers 200 with 0. DesignPackNotice.js:49-60 ignores the response and hides the notice. The notice returns on the next page load. Answer a bad nonce with an error status, as remove_welcome_notice() now does. Hide the notice only after a success response. Add PHPUnit cases for this handler with invalid and missing nonces that expect 403 and no saved option.

  • assets/js/src/welcome-notice.js:31-43 — correctness The Otter button can report success when nothing was activated. activatePlugin() resolves { success: false } on failure, for example after the nonce expires. This code ignores that result and posts the reference request. The reference handler (inc/Admin.php:219-226) also returns 200 on a bad nonce. The notice then shows "Done" and hides, but Otter is not active. Check the result of the install, activation and reference requests. Show "Done" and hide the notice only when all of them succeed. Make the reference handler answer a bad nonce with an error status, and add a PHPUnit case for it.

Validation details
  • Files reviewed: 9/9 changed files.
  • PHPUnit at HEAD on WordPress 7.1.5 and PHP 7.4: set -e; T=/var/www/html/wp-content/themes; rm -rf $T/fork-head $T/fork-base; mkdir -p $T/fork-head $T/fork-base git -C /… printed OK (19 tests, 60 assertions) (run R6).
  • The added tests on the base tree: T=/var/www/html/wp-content/themes; F='(Test_Block_Patterns|Test_Editor_Assets|Test_Welcome_Notice)::'; cd $T/fork-base &… printed Tests: 16, Assertions: 39, Errors: 1, Failures: 10. (run R9)
  • With an empty fork-en_US.mo and debug logging, the HEAD requests left `set -o pipefail; cd /var/www/html; cat > /workspace/checks/C11/setup-mu.sh <<'EOF'
    #!/bin/bash

C11 fixture setup/teard…printedno debug.log(run R39). The base tree loggedset -o pipefail; cd /var/www/html; cat > /workspace/checks/C11/setup-mu.sh <<'EOF'

#!/bin/bash

C11 fixture setup/teard…printedfork-domain notices: 9` (run R39).

  • Security pass found no new trust-boundary gap in the nonce change.
Untested areas
  • The editor console warning and editor canvas styling were not checked in a browser.
  • The textdomain notice was not checked on admin-ajax, cron or customizer requests.
  • WordPress 5.6 to 6.3 hook behavior was not read.

🤖 Automated review · run code-review-agent_6b12a6d5703517.75048605.


🤖 Review agent — review posted ✅ on ac05e273 · changes requested · 3 findings · 58 min

Run code-review-agent_6b12a6d5703517.75048605 · trail

Comment on lines +65 to +71
public function test_active_otter_hides_the_welcome_notice() {
update_option( 'active_plugins', array( 'otter-blocks/otter-blocks.php' ) );
ob_start();
( new Fork\Admin() )->render_welcome_notice();

$this->assertSame( '', ob_get_clean() );
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tests test_active_otter_hides_the_welcome_notice exercises no line this change touches. It passes on the base tree. With Otter active, render_welcome_notice() returns before get_otter_status() runs. Delete this case, or replace it with a case that fails without the change.

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.

2 participants