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

Release for v1.0.2 #10

Merged
merged 55 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
3413a8e
Initial commit
jeawhanlee Oct 15, 2024
d8ec457
Added phpcs
jeawhanlee Oct 15, 2024
f92f8d5
Added lint config
jeawhanlee Oct 15, 2024
f402c43
Updated config file
jeawhanlee Oct 15, 2024
7742694
Added gitignore
jeawhanlee Oct 15, 2024
4cbcbc2
Fixed phpcs errors
jeawhanlee Oct 15, 2024
1bd7fcf
Ignore composer.lock
jeawhanlee Oct 15, 2024
1e10a4b
Added tests
jeawhanlee Oct 15, 2024
5553a85
Added patchwork config
jeawhanlee Oct 15, 2024
88ea2d3
Updated composer packages and script
jeawhanlee Oct 15, 2024
d53b905
Updated method
jeawhanlee Oct 15, 2024
a514056
Updated namespace
jeawhanlee Oct 15, 2024
14f6702
Updated namespace and methods
jeawhanlee Oct 15, 2024
a191bd0
Added test workflow
jeawhanlee Oct 15, 2024
e2f0d80
Remove test cache
jeawhanlee Oct 15, 2024
3672163
Ignore test cache
jeawhanlee Oct 15, 2024
d5af0e3
Updated README
jeawhanlee Oct 16, 2024
58cf829
Updated README
jeawhanlee Oct 16, 2024
d0002d4
Updated README
jeawhanlee Oct 16, 2024
4e9ae88
Updated README
jeawhanlee Oct 16, 2024
4b11dda
Updated test
jeawhanlee Oct 16, 2024
4bec6fe
Updated README
jeawhanlee Oct 17, 2024
d12ca1d
Updated namespace
jeawhanlee Oct 17, 2024
a23f4dc
Added phpstan
jeawhanlee Oct 17, 2024
f8454ab
Fixed phpstan errors
jeawhanlee Oct 17, 2024
ecf9f67
Updated composer.json
jeawhanlee Oct 17, 2024
ce0f113
Added phpstan config
jeawhanlee Oct 17, 2024
2c7bb56
Added workflow file for phpstan
jeawhanlee Oct 17, 2024
e25931f
Updated namespace
jeawhanlee Oct 17, 2024
276981e
use defined var
jeawhanlee Oct 17, 2024
a72f32d
Updated README
jeawhanlee Oct 17, 2024
7bf9c44
Updated tests
jeawhanlee Oct 18, 2024
193a534
Make wp rocket referrer dynamic
jeawhanlee Oct 21, 2024
9453a5f
Updated data
jeawhanlee Oct 21, 2024
e198429
Updated tests
jeawhanlee Oct 21, 2024
13ddeee
Added git attribute file
jeawhanlee Oct 21, 2024
d62f483
Fixed phpcs
jeawhanlee Oct 21, 2024
51bbb1f
Merge pull request #4 from wp-media/enhancement/3-update-wp-rocket-ge…
jeawhanlee Oct 21, 2024
05363d6
Fixed Conflicts
jeawhanlee Oct 21, 2024
0c8a7d4
:fixes: #6 change imagify plugin path
Khadreal Oct 25, 2024
22da91b
Fix install event for imagify
Khadreal Oct 25, 2024
2796bef
Fix imagify urls
Khadreal Oct 25, 2024
60a034d
Fix lint error
Khadreal Oct 25, 2024
f982832
fix test error
Khadreal Oct 25, 2024
bd4947f
fix conflict
Khadreal Oct 25, 2024
9e30348
Directly reference plugin array copy
jeawhanlee Oct 25, 2024
3de5d91
Updated test
jeawhanlee Oct 25, 2024
acb4ae0
Keep optimize category at the top even when containing main plugin
jeawhanlee Oct 25, 2024
dce7046
Added test
jeawhanlee Oct 25, 2024
749d4eb
phpcs fix
jeawhanlee Oct 25, 2024
8f58f0d
Updated README.md
jeawhanlee Oct 25, 2024
e664dde
Merge pull request #7 from wp-media/fix/imagify-plugin-path
jeawhanlee Oct 25, 2024
8856ca3
Merge branch 'develop' into fix/8-fix-error-warning-for-non-active-pl…
jeawhanlee Oct 25, 2024
806d2dc
Updated tests
jeawhanlee Oct 25, 2024
d50c8b8
Merge pull request #9 from wp-media/fix/8-fix-error-warning-for-non-a…
jeawhanlee Oct 25, 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class View {
}

public function display_page() {
$plugin_family = $this->plugin_family->get_filtered_plugins( 'imagify-plugin/imagify' );
$plugin_family = $this->plugin_family->get_filtered_plugins( 'imagify/imagify' );

$data = [
'plugin_family' => $plugin_family['uncategorized'],
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/PluginFamily.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function get_post_install_event(): array {
$allowed_plugin = [
'uk-cookie-consent',
'backwpup',
'imagify-plugin',
'imagify',
'seo-by-rank-math',
'wp-rocket',
];
Expand Down
14 changes: 8 additions & 6 deletions src/Model/PluginFamily.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PluginFamily {
* @var array
*/
protected $wp_rocket_referrer = [
'imagify-plugin' => 'imagify',
'imagify' => 'imagify',
'seo-by-rank-math' => '',
'backwpup' => '',
'uk-cookie-consent' => '',
Expand Down Expand Up @@ -60,7 +60,7 @@ public function filter_plugins_by_activation( array $plugins, string $main_plugi
* to re-add them back using array_merge to be displayed after
* plugins that are not installed or not activated.
*/
if ( is_plugin_active( $plugin_path ) ) {
if ( is_plugin_active( $plugin_path ) && $main_plugin . '.php' !== $plugin_path ) {
// set cta data of active plugins.
$plugins[ $cat ]['plugins'][ $plugin ]['cta'] = [
'text' => 'Activated',
Expand All @@ -71,16 +71,18 @@ public function filter_plugins_by_activation( array $plugins, string $main_plugi
$active_plugins[ $plugin ] = $plugins[ $cat ]['plugins'][ $plugin ];

// Remove active plugin from current category.
unset( $cat_data['plugins'][ $plugin ] );
$active_plugin = $plugins[ $cat ]['plugins'][ $plugin ];
unset( $plugins[ $cat ]['plugins'][ $plugin ] );

// Send active plugin to the end of array in current category.
$cat_data['plugins'][ $plugin ] = $plugins[ $cat ]['plugins'][ $plugin ];
$plugins[ $cat ]['plugins'][ $plugin ] = $active_plugin;

// Remove category with active plugin from current array.
$active_cat = $plugins[ $cat ];
unset( $plugins[ $cat ] );

// Send category with active plugins to the end of array.
$plugins[ $cat ] = $cat_data;
$plugins[ $cat ] = $active_cat;
continue;
}

Expand All @@ -92,7 +94,7 @@ public function filter_plugins_by_activation( array $plugins, string $main_plugi
'plugin_to_install' => rawurlencode( $plugin ),
];

if ( 'imagify-plugin' === $plugin_slug ) {
if ( 'imagify' === $plugin_slug ) {
$args = [
'action' => 'install_imagify_from_partner_' . $main_plugin_slug,
'_wpnonce' => wp_create_nonce( 'install_imagify_from_partner' ),
Expand Down
4 changes: 2 additions & 2 deletions src/Model/wp_media_plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'optimize_performance' => [
'title' => 'Optimize Performance',
'plugins' => [
'wp-rocket/wp-rocket' => [
'wp-rocket/wp-rocket' => [
'logo' => [
'file' => 'logo-wp-rocket.svg',
'width' => '50%',
Expand All @@ -16,7 +16,7 @@
'desc' => 'WP Rocket is the easiest way to make your WordPress website faster and boost your Google PageSpeed score. Get more traffic, better engagement, and higher conversions effortlessly.',
'link' => '',
],
'imagify-plugin/imagify' => [
'imagify/imagify' => [
'logo' => [
'file' => 'logo-imagify.svg',
'width' => '50%',
Expand Down
170 changes: 164 additions & 6 deletions tests/Fixtures/src/Model/PluginFamily/filterPluginsByActivation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'desc' => 'WP Rocket is the easiest way to make your WordPress website faster and boost your Google PageSpeed score. Get more traffic, better engagement, and higher conversions effortlessly.',
'link' => 'https://wp-rocket.me/?utm_source=imagify-coupon&utm_medium=plugin&utm_campaign=imagify',
],
'imagify-plugin/imagify' => [
'imagify/imagify' => [
'logo' => [
'file' => 'logo-imagify.svg',
'width' => '50%',
Expand Down Expand Up @@ -116,7 +116,7 @@
'optimize_performance' => [
'title' => 'Optimize Performance',
'plugins' => [
'imagify-plugin/imagify' => [
'imagify/imagify' => [
'logo' => [
'file' => 'logo-imagify.svg',
'width' => '50%',
Expand Down Expand Up @@ -202,7 +202,7 @@
'url' => 'http://example.org/wp-admin/admin-post.php?action=plugin_family_install_wp-rocket&_wpnonce=9a68f00b8d&plugin_to_install=wp-rocket%2Fwp-rocket'
],
],
'imagify-plugin/imagify' => [
'imagify/imagify' => [
'logo' => [
'file' => 'logo-imagify.svg',
'width' => '50%',
Expand Down Expand Up @@ -257,7 +257,7 @@
'url' => 'https://wp-rocket.me/?utm_source=-coupon&utm_medium=plugin&utm_campaign='
],
],
'imagify-plugin/imagify' => [
'imagify/imagify' => [
'logo' => [
'file' => 'logo-imagify.svg',
'width' => '50%',
Expand Down Expand Up @@ -298,6 +298,146 @@
],
];

$expectedWithSecondOrLastPluginActiveInCategory = [
'optimize_performance' => [
'title' => 'Optimize Performance',
'plugins' => [
'imagify/imagify' => [
'logo' => [
'file' => 'logo-imagify.svg',
'width' => '50%',
],
'title' => 'Speed Up Your Website With Lighter Images',
'desc' => 'Imagify is the easiest WordPress image optimizer. It automatically compresses images, converts them to WebP and AVIF formats, and lets you resize and optimize with just one click!',
'link' => 'https://imagify.io/',
'cta' => [
'text' => 'Install',
'url' => 'http://example.org/wp-admin/admin-post.php?action=install_imagify_from_partner_wp-rocket&_wpnonce=9a68f00b8d&_wp_http_referer=https%3A%2F%2Fexample.org%2Fwp-admin'
],
],
],
],
'boost_traffic' => [
'title' => 'Boost Traffic',
'plugins' => [
'seo-by-rank-math/rank-math' => [
'logo' => [
'file' => 'logo-rank-math.svg',
'width' => '60%',
],
'title' => 'The Swiss Army Knife of SEO Tools',
'desc' => 'Rank Math SEO is the Best WordPress SEO plugin with the features of many SEO and AI SEO tools in a single package to help multiply your SEO traffic.',
'link' => 'https://rankmath.com/wordpress/plugin/seo-suite/',
'cta' => [
'text' => 'Install',
'url' => 'http://example.org/wp-admin/admin-post.php?action=plugin_family_install_seo-by-rank-math&_wpnonce=9a68f00b8d&plugin_to_install=seo-by-rank-math%2Frank-math'
],
],
],
],
'protect_secure' => [
'title' => 'Protect & Secure',
'plugins' => [
'backwpup/backwpup' => [
'logo' => [
'file' => 'logo-backwpup.svg',
'width' => '60%',
],
'title' => 'The Easiest Way to Protect Your Website',
'desc' => 'BackWPup is the most comprehensive and user-friendly backup & restore plugin for WordPress. Easily schedule automatic backups, securely store and restore with just a few clicks!',
'link' => 'https://backwpup.com/',
'cta' => [
'text' => 'Install',
'url' => 'http://example.org/wp-admin/admin-post.php?action=plugin_family_install_backwpup&_wpnonce=9a68f00b8d&plugin_to_install=backwpup%2Fbackwpup'
],
],
'uk-cookie-consent/uk-cookie-consent' => [
'logo' => [
'file' => 'logo-termly.svg',
'width' => '50%',
],
'title' => 'GDPR/CCPA Cookie Consent Banner',
'desc' => 'One of the easiest, most comprehensive, and popular cookie consent plugins available. Google Gold Certified Partner to quickly comply with data privacy laws from around the world.',
'link' => 'https://termly.io/resources/articles/wordpress-cookies-guide/',
'cta' => [
'text' => 'Activated',
'url' => '#'
],
],
],
],
];

$expectedOptimizeCategoryAsFirstWhenContainingMainPlugin = [
'optimize_performance' => [
'title' => 'Optimize Performance',
'plugins' => [
'imagify/imagify' => [
'logo' => [
'file' => 'logo-imagify.svg',
'width' => '50%',
],
'title' => 'Speed Up Your Website With Lighter Images',
'desc' => 'Imagify is the easiest WordPress image optimizer. It automatically compresses images, converts them to WebP and AVIF formats, and lets you resize and optimize with just one click!',
'link' => 'https://imagify.io/',
'cta' => [
'text' => 'Install',
'url' => 'http://example.org/wp-admin/admin-post.php?action=install_imagify_from_partner_wp-rocket&_wpnonce=9a68f00b8d&_wp_http_referer=https%3A%2F%2Fexample.org%2Fwp-admin'
],
],
],
],
'boost_traffic' => [
'title' => 'Boost Traffic',
'plugins' => [
'seo-by-rank-math/rank-math' => [
'logo' => [
'file' => 'logo-rank-math.svg',
'width' => '60%',
],
'title' => 'The Swiss Army Knife of SEO Tools',
'desc' => 'Rank Math SEO is the Best WordPress SEO plugin with the features of many SEO and AI SEO tools in a single package to help multiply your SEO traffic.',
'link' => 'https://rankmath.com/wordpress/plugin/seo-suite/',
'cta' => [
'text' => 'Install',
'url' => 'http://example.org/wp-admin/admin-post.php?action=plugin_family_install_seo-by-rank-math&_wpnonce=9a68f00b8d&plugin_to_install=seo-by-rank-math%2Frank-math'
],
],
],
],
'protect_secure' => [
'title' => 'Protect & Secure',
'plugins' => [
'backwpup/backwpup' => [
'logo' => [
'file' => 'logo-backwpup.svg',
'width' => '60%',
],
'title' => 'The Easiest Way to Protect Your Website',
'desc' => 'BackWPup is the most comprehensive and user-friendly backup & restore plugin for WordPress. Easily schedule automatic backups, securely store and restore with just a few clicks!',
'link' => 'https://backwpup.com/',
'cta' => [
'text' => 'Install',
'url' => 'http://example.org/wp-admin/admin-post.php?action=plugin_family_install_backwpup&_wpnonce=9a68f00b8d&plugin_to_install=backwpup%2Fbackwpup'
],
],
'uk-cookie-consent/uk-cookie-consent' => [
'logo' => [
'file' => 'logo-termly.svg',
'width' => '50%',
],
'title' => 'GDPR/CCPA Cookie Consent Banner',
'desc' => 'One of the easiest, most comprehensive, and popular cookie consent plugins available. Google Gold Certified Partner to quickly comply with data privacy laws from around the world.',
'link' => 'https://termly.io/resources/articles/wordpress-cookies-guide/',
'cta' => [
'text' => 'Install',
'url' => 'http://example.org/wp-admin/admin-post.php?action=plugin_family_install_uk-cookie-consent&_wpnonce=9a68f00b8d&plugin_to_install=uk-cookie-consent%2Fuk-cookie-consent'
],
],
],
],
];

return [
'testShouldReturnEmptyArrayIfEmptyArrayParsed' => [
'config' => [
Expand All @@ -312,14 +452,14 @@
'plugins' => $plugins,
'main_plugin' => 'wp-rocket/wp-rocket',
'order' => 'categorized',
'active_plugin' => 'imagify-plugin/imagify.php',
'active_plugin' => 'imagify/imagify.php',
],
'expected' => $expectedActivePluginAsTheLastElement,
],
'testShouldReturnCategoryWithActivePluginAsTheLastElement' => [
'config' => [
'plugins' => $plugins,
'main_plugin' => 'imagify-plugin/imagify',
'main_plugin' => 'imagify/imagify',
'order' => 'uncategorized',
'active_plugin' => 'seo-by-rank-math/rank-math.php',
],
Expand All @@ -344,4 +484,22 @@
],
'expected' => $expectedUniqueInstallLinkForImagify,
],
'testShouldReturnAsExpectedWithSecondOrLastPluginActiveInCategory' => [
'config' => [
'plugins' => $plugins,
'main_plugin' => 'wp-rocket/wp-rocket',
'order' => 'categorized',
'active_plugin' => 'uk-cookie-consent/uk-cookie-consent.php',
],
'expected' => $expectedWithSecondOrLastPluginActiveInCategory,
],
'testShouldStillReturnOptimizeCategoryAsFirstWhenContainingMainPlugin' => [
'config' => [
'plugins' => $plugins,
'main_plugin' => 'wp-rocket/wp-rocket',
'order' => 'categorized',
'active_plugin' => 'wp-rocket/wp-rocket.php',
],
'expected' => $expectedOptimizeCategoryAsFirstWhenContainingMainPlugin,
]
];
Loading