Skip to content

Commit

Permalink
Merge pull request #1598 from WordPress/add/wwo-meta-generator
Browse files Browse the repository at this point in the history
Add Web Worker Offloading meta generator
  • Loading branch information
westonruter authored Oct 16, 2024
2 parents 865fc21 + f4090ec commit b7e9c5d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions plugins/web-worker-offloading/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,16 @@ function plwwo_filter_inline_script_attributes( $attributes ): array {
return $attributes;
}
add_filter( 'wp_inline_script_attributes', 'plwwo_filter_inline_script_attributes' );

/**
* Displays the HTML generator meta tag for the Web Worker Offloading plugin.
*
* See {@see 'wp_head'}.
*
* @since n.e.x.t
*/
function plwwo_render_generator_meta_tag(): void {
// Use the plugin slug as it is immutable.
echo '<meta name="generator" content="web-worker-offloading ' . esc_attr( WEB_WORKER_OFFLOADING_VERSION ) . '">' . "\n";
}
add_action( 'wp_head', 'plwwo_render_generator_meta_tag' );
12 changes: 12 additions & 0 deletions plugins/web-worker-offloading/tests/test-web-worker-offloading.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,18 @@ private function replace_placeholders( string $template ): string {
);
}

/**
* Test printing the meta generator tag.
*
* @covers ::plwwo_render_generator_meta_tag
*/
public function test_plwwo_render_generator_meta_tag(): void {
$tag = get_echo( 'plwwo_render_generator_meta_tag' );
$this->assertStringStartsWith( '<meta', $tag );
$this->assertStringContainsString( 'generator', $tag );
$this->assertStringContainsString( 'web-worker-offloading ' . WEB_WORKER_OFFLOADING_VERSION, $tag );
}

/**
* Reset WP_Scripts and WP_Styles.
*/
Expand Down

0 comments on commit b7e9c5d

Please sign in to comment.