diff --git a/includes/class-openclawp-setup-wizard.php b/includes/class-openclawp-setup-wizard.php index f17d6d1..13de93f 100644 --- a/includes/class-openclawp-setup-wizard.php +++ b/includes/class-openclawp-setup-wizard.php @@ -90,7 +90,8 @@ public static function maybe_render_welcome_notice(): void { } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only page check. $current_page = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( (string) $_GET['page'] ) ) : ''; - if ( self::PAGE_SLUG === $current_page ) { + $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; + if ( ! self::should_render_welcome_notice( $current_page, $screen ) ) { return; } @@ -108,6 +109,31 @@ public static function maybe_render_welcome_notice(): void { assertFalse( self::should_render_welcome_notice( 'openclawp-setup', null ) ); + } + + public function test_welcome_notice_can_be_hidden_by_filter_for_host_screen(): void { + $screen = (object) array( 'id' => 'toplevel_page_wp-inbox' ); + + $GLOBALS['openclawp_test_filters']['openclawp_show_setup_notice'] = static function ( bool $show, string $current_page, $passed_screen ) use ( $screen ): bool { + TestCase::assertTrue( $show ); + TestCase::assertSame( 'wp-inbox', $current_page ); + TestCase::assertSame( $screen, $passed_screen ); + return false; + }; + + $this->assertFalse( self::should_render_welcome_notice( 'wp-inbox', $screen ) ); + } + + private static function should_render_welcome_notice( string $current_page, $screen ): bool { + $method = new ReflectionMethod( OpenclaWP_Setup_Wizard::class, 'should_render_welcome_notice' ); + $method->setAccessible( true ); + + return (bool) $method->invoke( null, $current_page, $screen ); + } +}