Repository navigation
Improve loading and configuration for front page and editor styles - #128
girishpanchal30 wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
🟡 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_assetsrun withis_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—correctnessThe 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 with0.DesignPackNotice.js:49-60ignores the response and hides the notice. The notice returns on the next page load. Answer a bad nonce with an error status, asremove_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—correctnessThe 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 /…printedOK (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 &…printedTests: 16, Assertions: 39, Errors: 1, Failures: 10.(run R9) - With an empty
fork-en_US.moand 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
| 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() ); | ||
| } |
There was a problem hiding this comment.
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.
Summary
Improved block pattern registration by deferring property initialization to ensure translations and filters are applied correctly, and updated the
front-page-heropattern 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 usingWP_PLUGIN_DIR. Updated editor style loading to use theenqueue_block_assetshook 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