Skip to content

Commit

Permalink
Merge pull request #1103 from WordPress/update/slugs-in-generator-tags
Browse files Browse the repository at this point in the history
Use plugin slug for generator tag
  • Loading branch information
felixarntz authored Apr 1, 2024
2 parents 82bd7fc + 08e31f7 commit eb0b0f4
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 14 deletions.
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' );
1 change: 1 addition & 0 deletions plugins/dominant-color-images/readme.txt
Original file line number Diff line number Diff line change
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
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' );
1 change: 1 addition & 0 deletions plugins/embed-optimizer/readme.txt
Original file line number Diff line number Diff line change
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
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";
}
4 changes: 2 additions & 2 deletions plugins/optimization-detective/load.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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))

= 0.1.0 =

* Initial release.
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";
}
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
1 change: 1 addition & 0 deletions plugins/webp-uploads/readme.txt
Original file line number Diff line number Diff line change
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
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
12 changes: 12 additions & 0 deletions tests/plugins/dominant-color-images/dominant-color-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,16 @@ public function provider_get_hex_color() {
),
);
}

/**
* Test printing the meta generator tag.
*
* @covers ::dominant_color_render_generator
*/
public function test_dominant_color_render_generator() {
$tag = get_echo( 'dominant_color_render_generator' );
$this->assertStringStartsWith( '<meta', $tag );
$this->assertStringContainsString( 'generator', $tag );
$this->assertStringContainsString( 'dominant-color-images ' . DOMINANT_COLOR_IMAGES_VERSION, $tag );
}
}
8 changes: 6 additions & 2 deletions tests/plugins/embed-optimizer/embed-optimizer-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

class Embed_Optimizer_Helper_Tests extends WP_UnitTestCase {

public function test_hooks() {
$this->assertSame( 10, has_filter( 'embed_oembed_html', 'embed_optimizer_filter_oembed_html' ) );
$this->assertSame( 10, has_action( 'wp_head', 'embed_optimizer_render_generator' ) );
}

/**
* Test that the oEmbed HTML is filtered.
*
Expand Down Expand Up @@ -163,10 +168,9 @@ function ( array $attrs, string $javascript ) {
* @covers ::embed_optimizer_render_generator
*/
public function test_embed_optimizer_render_generator() {
$this->assertSame( 10, has_action( 'wp_head', '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 );
}
}
17 changes: 17 additions & 0 deletions tests/plugins/speculation-rules/speculation-rules-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public function tear_down() {
parent::tear_down();
}

public function test_hooks() {
$this->assertSame( 10, has_action( 'wp_footer', 'plsr_print_speculation_rules' ) );
$this->assertSame( 10, has_action( 'wp_head', 'plsr_render_generator_meta_tag' ) );
}

public function data_provider_to_test_print_speculation_rules(): array {
return array(
'xhtml' => array(
Expand Down Expand Up @@ -56,4 +61,16 @@ public function test_plsr_print_speculation_rules_without_html5_support( bool $h
$this->assertStringContainsString( '/* <![CDATA[ */', wp_get_inline_script_tag( '/*...*/' ) );
}
}

/**
* Test printing the meta generator tag.
*
* @covers ::plsr_render_generator_meta_tag
*/
public function test_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 );
}
}
12 changes: 12 additions & 0 deletions tests/plugins/webp-uploads/load-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,18 @@ public function it_should_return_correct_quality_for_mime_types() {
$this->assertSame( 80, webp_uploads_modify_webp_quality( 80, 'image/jpeg' ), 'JPEG image quality should return default quality provided from WP filter wp_editor_set_quality.' );
}

/**
* Test printing the meta generator tag.
*
* @covers ::webp_uploads_render_generator
*/
public function test_webp_uploads_render_generator() {
$tag = get_echo( 'webp_uploads_render_generator' );
$this->assertStringStartsWith( '<meta', $tag );
$this->assertStringContainsString( 'generator', $tag );
$this->assertStringContainsString( 'webp-uploads ' . WEBP_UPLOADS_VERSION, $tag );
}

/**
* Runs (empty) hooks to satisfy webp_uploads_in_frontend_body() conditions.
*/
Expand Down

0 comments on commit eb0b0f4

Please sign in to comment.