Skip to content

Commit

Permalink
Merge pull request #1011 from WordPress/move/modules-to-plugins
Browse files Browse the repository at this point in the history
Move published modules to standalone plugins
  • Loading branch information
felixarntz authored Mar 5, 2024
2 parents 646116b + 369ee8c commit b5cc801
Show file tree
Hide file tree
Showing 67 changed files with 232 additions and 237 deletions.
18 changes: 8 additions & 10 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
/tests/modules/object-cache @tillkruss @spacedmonkey
/tests/testdata/modules/object-cache @tillkruss @spacedmonkey

# Module: WebP Uploads
/modules/images/webp-uploads @adamsilverstein @felixarntz
/tests/modules/images/webp-uploads @adamsilverstein @felixarntz
/tests/testdata/modules/images/webp-uploads @adamsilverstein @felixarntz

# Module: WebP Support Health Check
/modules/images/webp-support @adamsilverstein
/tests/modules/images/webp-support @adamsilverstein
Expand All @@ -49,15 +44,18 @@
/tests/modules/js-and-css/audit-enqueued-assets @manuelRod
/tests/testdata/modules/js-and-css/audit-enqueued-assets @manuelRod

# Module: Dominant Color Images
/modules/images/dominant-color-images @pbearne @spacedmonkey
/tests/modules/images/dominant-color-images @pbearne @spacedmonkey
/tests/testdata/modules/images/dominant-color-images @pbearne @spacedmonkey

# Plugin: Auto-sizes for Lazy-Loaded Images
/plugins/auto-sizes @joemcgill
/tests/plugins/auto-sizes @joemcgill

# Plugin: Speculation Rules
/plugins/speculation-rules @felixarntz
/tests/plugins/speculation-rules @felixarntz

# Plugin: WebP Uploads
/plugins/webp-uploads @adamsilverstein @felixarntz
/tests/plugins/webp-uploads @adamsilverstein @felixarntz

# Plugin: Dominant Color Images
/plugins/dominant-color-images @pbearne @spacedmonkey
/tests/plugins/dominant-color-images @pbearne @spacedmonkey
24 changes: 18 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@
"format": "build-cs/vendor/bin/phpcbf --report-summary --report-source",
"lint": "build-cs/vendor/bin/phpcs",
"lint:all": [
"@lint",
"@lint:auto-sizes",
"@lint:speculation-rules"
"@lint",
"@lint:auto-sizes",
"@lint:dominant-color-images",
"@lint:speculation-rules",
"@lint:webp-uploads"
],
"lint:auto-sizes": "@lint -- ./plugins/auto-sizes --standard=./plugins/auto-sizes/phpcs.xml.dist",
"lint:dominant-color-images": "@lint -- ./plugins/dominant-color-images --standard=./plugins/dominant-color-images/phpcs.xml.dist",
"lint:speculation-rules": "@lint -- ./plugins/speculation-rules --standard=./plugins/speculation-rules/phpcs.xml.dist",
"lint:webp-uploads": "@lint -- ./plugins/webp-uploads --standard=./plugins/webp-uploads/phpcs.xml.dist",
"test": "phpunit --verbose --testsuite performance-lab",
"test-multisite": "phpunit -c tests/multisite.xml --verbose --testsuite performance-lab",
"test:all": [
Expand All @@ -45,16 +49,24 @@
],
"test:plugins": [
"@test:auto-sizes",
"@test:speculation-rules"
"@test:dominant-color-images",
"@test:speculation-rules",
"@test:webp-uploads"
],
"test-multisite:plugins": [
"@test-multisite:auto-sizes",
"@test-multisite:speculation-rules"
"@test-multisite:dominant-color-images",
"@test-multisite:speculation-rules",
"@test-multisite:webp-uploads"
],
"test:auto-sizes": "phpunit --verbose --testsuite auto-sizes",
"test-multisite:auto-sizes": "phpunit -c tests/multisite.xml --verbose --testsuite auto-sizes",
"test:dominant-color-images": "phpunit --verbose --testsuite dominant-color-images",
"test-multisite:dominant-color-images": "phpunit -c tests/multisite.xml --verbose --testsuite dominant-color-images",
"test:speculation-rules": "phpunit --verbose --testsuite speculation-rules",
"test-multisite:speculation-rules": "phpunit -c tests/multisite.xml --verbose --testsuite speculation-rules"
"test-multisite:speculation-rules": "phpunit -c tests/multisite.xml --verbose --testsuite speculation-rules",
"test:webp-uploads": "phpunit --verbose --testsuite webp-uploads",
"test-multisite:webp-uploads": "phpunit -c tests/multisite.xml --verbose --testsuite webp-uploads"
},
"config": {
"allow-plugins": {
Expand Down
6 changes: 1 addition & 5 deletions load.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ function perflab_get_module_settings() {
'site-health/audit-autoloaded-options' => 'database/audit-autoloaded-options',
'site-health/audit-enqueued-assets' => 'js-and-css/audit-enqueued-assets',
'site-health/webp-support' => 'images/webp-support',
'images/dominant-color' => 'images/dominant-color-images',
);

foreach ( $legacy_module_slugs as $legacy_slug => $current_slug ) {
Expand Down Expand Up @@ -323,10 +322,7 @@ function perflab_get_standalone_plugin_version_constants( $source = 'plugins' )
* This list includes all modules which are also available as standalone plugins,
* as `$module_dir => $version_constant` pairs.
*/
return array(
'images/dominant-color-images' => 'DOMINANT_COLOR_IMAGES_VERSION',
'images/webp-uploads' => 'WEBP_UPLOADS_VERSION',
);
return array();
}

/*
Expand Down
3 changes: 0 additions & 3 deletions modules/images/dominant-color-images/.gitattributes

This file was deleted.

24 changes: 0 additions & 24 deletions modules/images/dominant-color-images/load.php

This file was deleted.

3 changes: 0 additions & 3 deletions modules/images/webp-uploads/.gitattributes

This file was deleted.

15 changes: 0 additions & 15 deletions modules/images/webp-uploads/can-load.php

This file was deleted.

41 changes: 0 additions & 41 deletions modules/images/webp-uploads/load.php

This file was deleted.

6 changes: 6 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@
<testsuite name="auto-sizes">
<directory suffix=".php">./tests/plugins/auto-sizes</directory>
</testsuite>
<testsuite name="dominant-color-images">
<directory suffix=".php">./tests/plugins/dominant-color-images</directory>
</testsuite>
<testsuite name="speculation-rules">
<directory suffix=".php">./tests/plugins/speculation-rules</directory>
</testsuite>
<testsuite name="webp-uploads">
<directory suffix=".php">./tests/plugins/webp-uploads</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
Expand Down
15 changes: 4 additions & 11 deletions plugins.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
{
"modules": {
"images/dominant-color-images": {
"slug": "dominant-color-images",
"version": "1.0.1"
},
"images/webp-uploads": {
"slug": "webp-uploads",
"version": "1.0.5"
}
},
"modules": {},
"plugins": [
"auto-sizes",
"speculation-rules"
"dominant-color-images",
"speculation-rules",
"webp-uploads"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
* WordPress Image Editor Class for Image Manipulation through GD
* with dominant color detection
*
* @package performance-lab
* @group dominant-color-images
* @package dominant-color-images
*
* @since 1.2.0
* @since 1.0.0
*/

/**
* WordPress Image Editor Class for Image Manipulation through GD
* with dominant color detection.
*
* @since 1.2.0
* @since 1.0.0
*
* @see WP_Image_Editor
*/
Expand All @@ -22,14 +21,14 @@ class Dominant_Color_Image_Editor_GD extends WP_Image_Editor_GD {
/**
* Get dominant color from a file.
*
* @since 1.2.0
* @since 1.0.0
*
* @return string|WP_Error Dominant hex color string, or an error on failure.
*/
public function get_dominant_color() {

if ( ! $this->image ) {
return new WP_Error( 'image_editor_dominant_color_error_no_image', __( 'Dominant color detection no image found.', 'performance-lab' ) );
return new WP_Error( 'image_editor_dominant_color_error_no_image', __( 'Dominant color detection no image found.', 'dominant-color-images' ) );
}
// The logic here is resize the image to 1x1 pixel, then get the color of that pixel.
$shorted_image = imagecreatetruecolor( 1, 1 );
Expand All @@ -41,7 +40,7 @@ public function get_dominant_color() {
$b = $rgb & 0xFF;
$hex = dominant_color_rgb_to_hex( $r, $g, $b );
if ( ! $hex ) {
return new WP_Error( 'image_editor_dominant_color_error', __( 'Dominant color detection failed.', 'performance-lab' ) );
return new WP_Error( 'image_editor_dominant_color_error', __( 'Dominant color detection failed.', 'dominant-color-images' ) );
}

return $hex;
Expand All @@ -52,14 +51,14 @@ public function get_dominant_color() {
* Looks for transparent pixels in the image.
* If there are none, it returns false.
*
* @since 1.2.0
* @since 1.0.0
*
* @return bool|WP_Error True or false based on whether there are transparent pixels, or an error on failure.
*/
public function has_transparency() {

if ( ! $this->image ) {
return new WP_Error( 'image_editor_has_transparency_error_no_image', __( 'Transparency detection no image found.', 'performance-lab' ) );
return new WP_Error( 'image_editor_has_transparency_error_no_image', __( 'Transparency detection no image found.', 'dominant-color-images' ) );
}

// Walk through the pixels and look transparent pixels.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
* WordPress Image Editor Class for Image Manipulation through Imagick
* with dominant color detection
*
* @package performance-lab
* @group dominant-color-images
* @package dominant-color-images
*
* @since 1.2.0
* @since 1.0.0
*/

/**
* WordPress Image Editor Class for Image Manipulation through Imagick
* with dominant color detection.
*
* @since 1.2.0
* @since 1.0.0
*
* @see WP_Image_Editor
*/
Expand All @@ -22,14 +21,14 @@ class Dominant_Color_Image_Editor_Imagick extends WP_Image_Editor_Imagick {
/**
* Get dominant color from a file.
*
* @since 1.2.0
* @since 1.0.0
*
* @return string|WP_Error Dominant hex color string, or an error on failure.
*/
public function get_dominant_color() {

if ( ! $this->image ) {
return new WP_Error( 'image_editor_dominant_color_error_no_image', __( 'Dominant color detection no image found.', 'performance-lab' ) );
return new WP_Error( 'image_editor_dominant_color_error_no_image', __( 'Dominant color detection no image found.', 'dominant-color-images' ) );
}

try {
Expand All @@ -40,28 +39,28 @@ public function get_dominant_color() {
$color = $pixel->getColor();
$hex = dominant_color_rgb_to_hex( $color['r'], $color['g'], $color['b'] );
if ( ! $hex ) {
return new WP_Error( 'image_editor_dominant_color_error', __( 'Dominant color detection failed.', 'performance-lab' ) );
return new WP_Error( 'image_editor_dominant_color_error', __( 'Dominant color detection failed.', 'dominant-color-images' ) );
}

return $hex;
} catch ( Exception $e ) {
/* translators: %s is the error message. */
return new WP_Error( 'image_editor_dominant_color_error', sprintf( __( 'Dominant color detection failed: %s', 'performance-lab' ), $e->getMessage() ) );
return new WP_Error( 'image_editor_dominant_color_error', sprintf( __( 'Dominant color detection failed: %s', 'dominant-color-images' ), $e->getMessage() ) );
}
}

/**
* Looks for transparent pixels in the image.
* If there are none, it returns false.
*
* @since 1.2.0
* @since 1.0.0
*
* @return bool|WP_Error True or false based on whether there are transparent pixels, or an error on failure.
*/
public function has_transparency() {

if ( ! $this->image ) {
return new WP_Error( 'image_editor_has_transparency_error_no_image', __( 'Transparency detection no image found.', 'performance-lab' ) );
return new WP_Error( 'image_editor_has_transparency_error_no_image', __( 'Transparency detection no image found.', 'dominant-color-images' ) );
}

try {
Expand Down Expand Up @@ -93,7 +92,7 @@ public function has_transparency() {

} catch ( Exception $e ) {
/* translators: %s is the error message */
return new WP_Error( 'image_editor_has_transparency_error', sprintf( __( 'Transparency detection failed: %s', 'performance-lab' ), $e->getMessage() ) );
return new WP_Error( 'image_editor_has_transparency_error', sprintf( __( 'Transparency detection failed: %s', 'dominant-color-images' ), $e->getMessage() ) );
}
}
}
Loading

0 comments on commit b5cc801

Please sign in to comment.