Skip to content

Commit ac38e32

Browse files
Web Worker Offloading: Add sunset notice in plugin row
This notice informs users that the plugin is proposed for being sunset and encourages them to share INP metrics in the support forum. Co-authored-by: gemini-cli <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent ea98672 commit ac38e32

3 files changed

Lines changed: 60 additions & 0 deletions

File tree

plugins/web-worker-offloading/helper.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,33 @@ function plwwo_render_generator_meta_tag(): void {
198198
// Use the plugin slug as it is immutable.
199199
echo '<meta name="generator" content="web-worker-offloading ' . esc_attr( WEB_WORKER_OFFLOADING_VERSION ) . '">' . "\n";
200200
}
201+
202+
/**
203+
* Displays a sunset warning notice for the plugin in the plugin row meta.
204+
*
205+
* @since n.e.x.t
206+
* @access private
207+
*
208+
* @param string $plugin_file Path to the plugin file relative to the plugins directory.
209+
*/
210+
function plwwo_render_sunset_notice( string $plugin_file ): void {
211+
if ( 'web-worker-offloading/load.php' !== $plugin_file ) {
212+
return;
213+
}
214+
215+
$message = sprintf(
216+
/* translators: 1: GitHub issue URL. 2: Support forum URL. */
217+
__( 'The Web Worker Offloading plugin is proposed for being sunset. Please refer to the <a href="%1$s" target="_blank" rel="noopener">GitHub issue</a> for more information. If you have metrics showing how this plugin specifically improved your Interaction to Next Paint (INP), please share them in the <a href="%2$s" target="_blank" rel="noopener">support forum</a> as this could provide a reason to keep the plugin.', 'web-worker-offloading' ),
218+
esc_url( 'https://github.com/WordPress/performance/issues/2284' ),
219+
esc_url( 'https://wordpress.org/support/plugin/web-worker-offloading/' )
220+
);
221+
?>
222+
<div class="notice inline notice-warning notice-alt">
223+
<p>
224+
<?php
225+
echo wp_kses_post( $message );
226+
?>
227+
</p>
228+
</div>
229+
<?php
230+
}

plugins/web-worker-offloading/hooks.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
add_filter( 'script_loader_tag', 'plwwo_update_script_type', 10, 2 );
1616
add_filter( 'wp_inline_script_attributes', 'plwwo_filter_inline_script_attributes' );
1717
add_action( 'wp_head', 'plwwo_render_generator_meta_tag' );
18+
add_action( 'after_plugin_row_meta', 'plwwo_render_sunset_notice' );
1819
// @codeCoverageIgnoreEnd

plugins/web-worker-offloading/tests/test-web-worker-offloading.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,4 +396,33 @@ public function test_plwwo_load_third_party_integrations(): void {
396396
$this->assertFalse( function_exists( 'plwwo_rank_math_configure' ) );
397397
$this->assertFalse( function_exists( 'plwwo_woocommerce_configure' ) );
398398
}
399+
400+
/**
401+
* Test the sunset notice hook.
402+
*
403+
* @covers ::plwwo_render_sunset_notice
404+
*/
405+
public function test_plwwo_render_sunset_notice_hook(): void {
406+
$this->assertEquals( 10, has_action( 'after_plugin_row_meta', 'plwwo_render_sunset_notice' ) );
407+
}
408+
409+
/**
410+
* Test rendering the sunset notice.
411+
*
412+
* @covers ::plwwo_render_sunset_notice
413+
*/
414+
public function test_plwwo_render_sunset_notice_rendering(): void {
415+
$plugin_file = 'web-worker-offloading/load.php';
416+
417+
$output = get_echo( 'plwwo_render_sunset_notice', array( $plugin_file ) );
418+
419+
$this->assertStringContainsString( 'notice-warning', $output );
420+
$this->assertStringContainsString( 'The Web Worker Offloading plugin is proposed for being sunset.', $output );
421+
$this->assertStringContainsString( 'Interaction to Next Paint (INP)', $output );
422+
$this->assertStringContainsString( 'https://wordpress.org/support/plugin/web-worker-offloading/', $output );
423+
424+
// Test with different plugin file.
425+
$output = get_echo( 'plwwo_render_sunset_notice', array( 'other-plugin/load.php' ) );
426+
$this->assertEmpty( $output );
427+
}
399428
}

0 commit comments

Comments
 (0)