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

Move published modules to standalone plugins #1011

Merged
merged 40 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1a92839
Move dominant-color-images from modules to plugins
thelovekesh Feb 23, 2024
c6d2db3
Move webp-uploads from modules to plugins
thelovekesh Feb 23, 2024
0b693dd
Rename webp-uploads main plugin file from load.php to webp-uploads.php
thelovekesh Feb 23, 2024
7525f28
Rename dominant-color-images main plugin file from load.php to domina…
thelovekesh Feb 23, 2024
9b1b9cc
Update dominant-color-images plugin header and plugin files docblocks
thelovekesh Feb 23, 2024
b6a17b0
Update webp-uploads plugin header and plugin files docblocks
thelovekesh Feb 23, 2024
e2f55e1
Move test cases for dominant-color-images plugin to plugins tests dir…
thelovekesh Feb 23, 2024
218dea7
Move test cases for webp-uploads plugin to plugins tests directory
thelovekesh Feb 23, 2024
9c33cf2
Add testsuite entry for dominant-color-images and webp-uplaods
thelovekesh Feb 23, 2024
c9ba298
Update test files docblocks for dominant-color-images and webp-uplaods
thelovekesh Feb 23, 2024
d9be6b8
Add tests workflow entry for dominant-color-images and webp-uplaods
thelovekesh Feb 23, 2024
0acc681
Move webp-uploads tests helpers to correct directory
thelovekesh Feb 23, 2024
feb5294
Update plugins array
thelovekesh Feb 23, 2024
0c3f725
Revert to single quotes
thelovekesh Feb 23, 2024
187ad34
Update CODEOWNERS
thelovekesh Feb 23, 2024
c2bc5f2
Update text domain for dominant-color-images
thelovekesh Feb 24, 2024
a003f3d
Update text domain for webp-uploads
thelovekesh Feb 24, 2024
df6cbc1
Update `@package` tag for webp-uploads tests helpers
thelovekesh Feb 24, 2024
941c2ef
Remove .gitattributes from standalone plugins
thelovekesh Feb 24, 2024
7f5243b
Update auto-enabled modules
thelovekesh Feb 25, 2024
6b725e2
Remove dominant-color-images from legacy modules list
thelovekesh Feb 25, 2024
49c3aab
Remove dominant-color-images and webp-uploads from modules list which…
thelovekesh Feb 25, 2024
5de0cab
Revert "Update auto-enabled modules"
thelovekesh Feb 26, 2024
5b0ac00
Update plugin URI
thelovekesh Feb 26, 2024
e05b468
Move dominant-color-images from modules to plugins
thelovekesh Feb 26, 2024
f62248e
Update dominant-color-images plugin test data images path
thelovekesh Feb 26, 2024
f404d1a
Update CODEOWNERS for dominant-color-images testdata
thelovekesh Feb 26, 2024
ada4cd9
Revert standalone main plugin file names to load.php
thelovekesh Feb 26, 2024
be74ffe
Add PHPCS config for dominant-color-images
thelovekesh Feb 28, 2024
f8a92c1
Add PHPCS config for webp-uploads
thelovekesh Feb 28, 2024
7d4c30e
Add composer scripts for standalone plugins
thelovekesh Feb 28, 2024
66ebdf9
Fix plugin URI for `dominant-color-images`
thelovekesh Feb 28, 2024
d40df1c
Fix plugin URI for `webp-uploads`
thelovekesh Feb 28, 2024
b0dfc9e
Revert safeguard to block direct access to file
thelovekesh Feb 28, 2024
8174b3f
Remove modules
thelovekesh Feb 28, 2024
83d3ef1
Update testsuites order alphabetically
thelovekesh Mar 5, 2024
70d60dc
Fix lines spacing in CODEOWNERS
thelovekesh Mar 5, 2024
58f6a85
Add safeguard to bail early if plugins version is already defined
thelovekesh Mar 5, 2024
7bd5f3f
Move test helpers to data directory
thelovekesh Mar 5, 2024
369ee8c
Merge branch 'trunk' into move/modules-to-plugins
felixarntz Mar 5, 2024
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
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
thelovekesh marked this conversation as resolved.
Show resolved Hide resolved

# 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
Loading