Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use plugin slug for generator tag #1103

Merged
merged 4 commits into from Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion load.php
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
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' );
1 change: 1 addition & 0 deletions plugins/dominant-color-images/readme.txt
Expand Up @@ -52,6 +52,7 @@ Contributions are always welcome! Learn more about how to get involved in the [C
= 1.1.0 =

* Rename plugin to "Image Placeholders". ([1101](https://github.com/WordPress/performance/pull/1101))
* Use plugin slug for generator tag. ([1103](https://github.com/WordPress/performance/pull/1103))
* Bump minimum required WP version to 6.4. ([1062](https://github.com/WordPress/performance/pull/1062))
* Update tested WordPress version to 6.5. ([1027](https://github.com/WordPress/performance/pull/1027))

Expand Down
3 changes: 2 additions & 1 deletion plugins/embed-optimizer/hooks.php
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' );
1 change: 1 addition & 0 deletions plugins/embed-optimizer/readme.txt
Expand Up @@ -51,6 +51,7 @@ The [plugin source code](https://github.com/WordPress/performance/tree/trunk/plu

= 0.1.1 =

* Use plugin slug for generator tag. ([1103](https://github.com/WordPress/performance/pull/1103))
* Bump minimum required WP version to 6.4. ([1076](https://github.com/WordPress/performance/pull/1076))

= 0.1.0 =
Expand Down
3 changes: 2 additions & 1 deletion plugins/optimization-detective/helper.php
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";
}
4 changes: 2 additions & 2 deletions plugins/optimization-detective/load.php
Expand Up @@ -5,7 +5,7 @@
* Description: Uses real user metrics to improve heuristics WordPress applies on the frontend to improve image loading priority.
* Requires at least: 6.4
* Requires PHP: 7.0
* Version: 0.1.0
* Version: 0.1.1
* Author: WordPress Performance Team
* Author URI: https://make.wordpress.org/performance/
* License: GPLv2 or later
Expand Down Expand Up @@ -43,7 +43,7 @@
);
}

define( 'OPTIMIZATION_DETECTIVE_VERSION', '0.1.0' );
define( 'OPTIMIZATION_DETECTIVE_VERSION', '0.1.1' );

require_once __DIR__ . '/helper.php';

Expand Down
6 changes: 5 additions & 1 deletion plugins/optimization-detective/readme.txt
Expand Up @@ -4,7 +4,7 @@ Contributors: wordpressdotorg
Requires at least: 6.4
Tested up to: 6.5
Requires PHP: 7.0
Stable tag: 0.1.0
Stable tag: 0.1.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Tags: performance, images
Expand Down Expand Up @@ -137,6 +137,10 @@ The [plugin source code](https://github.com/WordPress/performance/tree/trunk/plu

== Changelog ==

= 0.1.1 =

* Use plugin slug for generator tag. ([1103](https://github.com/WordPress/performance/pull/1103))
felixarntz marked this conversation as resolved.
Show resolved Hide resolved

= 0.1.0 =

* Initial release.
3 changes: 2 additions & 1 deletion plugins/speculation-rules/hooks.php
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
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
1 change: 1 addition & 0 deletions plugins/webp-uploads/readme.txt
Expand Up @@ -64,6 +64,7 @@ By default, the Modern Image Formats plugin will only generate WebP versions of

* Add link to WebP settings to plugins table. ([1036](https://github.com/WordPress/performance/pull/1036))
* Rename plugin to "Modern Image Formats". ([1101](https://github.com/WordPress/performance/pull/1101))
* Use plugin slug for generator tag. ([1103](https://github.com/WordPress/performance/pull/1103))
* Bump minimum required WP version to 6.4. ([1062](https://github.com/WordPress/performance/pull/1062))
* Update tested WordPress version to 6.5. ([1027](https://github.com/WordPress/performance/pull/1027))

Expand Down
4 changes: 2 additions & 2 deletions tests/load-tests.php
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
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
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
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