Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use plugin slugs in generator tags.
  • Loading branch information
felixarntz committed Mar 29, 2024
commit 88599d4f97445cccf20018dff1e6601a145b1fce
3 changes: 2 additions & 1 deletion load.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ function perflab_get_generator_content() {
}

return sprintf(
'Performance Lab %1$s; plugins: %2$s',
// Use the plugin slug as it is immutable.
'performance-lab %1$s; plugins: %2$s',
PERFLAB_VERSION,
implode( ', ', $active_plugins )
);
Expand Down
3 changes: 2 additions & 1 deletion plugins/dominant-color-images/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ function dominant_color_add_inline_style() {
* @since 1.0.0
*/
function dominant_color_render_generator() {
echo '<meta name="generator" content="Image Placeholders ' . esc_attr( DOMINANT_COLOR_IMAGES_VERSION ) . '">' . "\n";
// Use the plugin slug as it is immutable.
echo '<meta name="generator" content="dominant-color-images ' . esc_attr( DOMINANT_COLOR_IMAGES_VERSION ) . '">' . "\n";
}
add_action( 'wp_head', 'dominant_color_render_generator' );
3 changes: 2 additions & 1 deletion plugins/embed-optimizer/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ function embed_optimizer_trigger_error( string $function_name, string $message,
* @since 0.1.0
*/
function embed_optimizer_render_generator() {
echo '<meta name="generator" content="Embed Optimizer ' . esc_attr( EMBED_OPTIMIZER_VERSION ) . '">' . "\n";
// Use the plugin slug as it is immutable.
echo '<meta name="generator" content="embed-optimizer ' . esc_attr( EMBED_OPTIMIZER_VERSION ) . '">' . "\n";
}
add_action( 'wp_head', 'embed_optimizer_render_generator' );
3 changes: 2 additions & 1 deletion plugins/optimization-detective/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
* @since 0.1.0
*/
function od_render_generator_meta_tag() {
echo '<meta name="generator" content="Optimization Detective ' . esc_attr( OPTIMIZATION_DETECTIVE_VERSION ) . '">' . "\n";
// Use the plugin slug as it is immutable.
echo '<meta name="generator" content="optimization-detective ' . esc_attr( OPTIMIZATION_DETECTIVE_VERSION ) . '">' . "\n";
}
3 changes: 2 additions & 1 deletion plugins/speculation-rules/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function plsr_print_speculation_rules() {
* @since 1.1.0
*/
function plsr_render_generator_meta_tag() {
echo '<meta name="generator" content="Speculative Loading ' . esc_attr( SPECULATION_RULES_VERSION ) . '">' . "\n";
// Use the plugin slug as it is immutable.
echo '<meta name="generator" content="speculation-rules ' . esc_attr( SPECULATION_RULES_VERSION ) . '">' . "\n";
Copy link
Member

Choose a reason for hiding this comment

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

probably want to bump the plugin version as well, otherwise users won't get this update.

Copy link
Member Author

Choose a reason for hiding this comment

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

@adamsilverstein That version is already bumped (and not published), so this PR doesn't need to bump it again. :)

}
add_action( 'wp_head', 'plsr_render_generator_meta_tag' );
3 changes: 2 additions & 1 deletion plugins/webp-uploads/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,8 @@ function webp_uploads_modify_webp_quality( $quality, $mime_type ) {
* @since 1.0.0
*/
function webp_uploads_render_generator() {
echo '<meta name="generator" content="Modern Image Formats ' . esc_attr( WEBP_UPLOADS_VERSION ) . '">' . "\n";
// Use the plugin slug as it is immutable.
echo '<meta name="generator" content="webp-uploads ' . esc_attr( WEBP_UPLOADS_VERSION ) . '">' . "\n";
}
add_action( 'wp_head', 'webp_uploads_render_generator' );

Expand Down
4 changes: 2 additions & 2 deletions tests/load-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
class Load_Tests extends WP_UnitTestCase {

public function test_perflab_get_generator_content() {
$expected = 'Performance Lab ' . PERFLAB_VERSION . '; plugins: ';
$expected = 'performance-lab ' . PERFLAB_VERSION . '; plugins: ';
$content = perflab_get_generator_content();
$this->assertSame( $expected, $content );
}

public function test_perflab_render_generator() {
$expected = '<meta name="generator" content="Performance Lab ' . PERFLAB_VERSION . '; plugins: ">' . "\n";
$expected = '<meta name="generator" content="performance-lab ' . PERFLAB_VERSION . '; plugins: ">' . "\n";
$output = get_echo( 'perflab_render_generator' );
$this->assertSame( $expected, $output );

Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/embed-optimizer/embed-optimizer-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,6 @@ public function test_embed_optimizer_render_generator() {
$tag = get_echo( 'embed_optimizer_render_generator' );
$this->assertStringStartsWith( '<meta', $tag );
$this->assertStringContainsString( 'generator', $tag );
$this->assertStringContainsString( EMBED_OPTIMIZER_VERSION, $tag );
$this->assertStringContainsString( 'embed-optimizer ' . EMBED_OPTIMIZER_VERSION, $tag );
}
}
2 changes: 1 addition & 1 deletion tests/plugins/optimization-detective/helper-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public function test_od_render_generator_meta_tag() {
$tag = get_echo( 'od_render_generator_meta_tag' );
$this->assertStringStartsWith( '<meta', $tag );
$this->assertStringContainsString( 'generator', $tag );
$this->assertStringContainsString( 'Optimization Detective ' . OPTIMIZATION_DETECTIVE_VERSION, $tag );
$this->assertStringContainsString( 'optimization-detective ' . OPTIMIZATION_DETECTIVE_VERSION, $tag );
}
}
14 changes: 14 additions & 0 deletions tests/plugins/speculation-rules/speculation-rules-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ public function data_provider_to_test_print_speculation_rules(): array {
);
}

/**
* Test printing the meta generator tag.
*
* @covers ::plsr_render_generator_meta_tag
*/
public function test_plsr_render_generator_meta_tag() {
$this->assertSame( 10, has_action( 'wp_head', 'plsr_render_generator_meta_tag' ) );

$tag = get_echo( 'plsr_render_generator_meta_tag' );
$this->assertStringStartsWith( '<meta', $tag );
$this->assertStringContainsString( 'generator', $tag );
$this->assertStringContainsString( 'speculation-rules ' . SPECULATION_RULES_VERSION, $tag );
}

/**
* @dataProvider data_provider_to_test_print_speculation_rules
* @covers ::plsr_print_speculation_rules
Expand Down