From df30824934e28a98ffc27647232008bbc2a29a3e Mon Sep 17 00:00:00 2001 From: Michael Lee <38788055+jeawhanlee@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:18:44 +0100 Subject: [PATCH 1/7] Release for v1.0.1 (#5) * Initial commit * Added phpcs * Added lint config * Updated config file * Added gitignore * Fixed phpcs errors * Ignore composer.lock * Added tests * Added patchwork config * Updated composer packages and script * Updated method * Updated namespace * Updated namespace and methods * Added test workflow * Remove test cache * Ignore test cache * Updated README * Updated README * Updated README * Updated README * Updated test * Updated README * Updated namespace * Added phpstan * Fixed phpstan errors * Updated composer.json * Added phpstan config * Added workflow file for phpstan * Updated namespace * use defined var * Updated README * Updated tests * Make wp rocket referrer dynamic * Updated data * Updated tests * Added git attribute file * Fixed phpcs --- .gitattributes | 9 +++++++++ src/Model/PluginFamily.php | 20 ++++++++++++++++++- src/Model/wp_media_plugins.php | 2 +- .../filterPluginsByActivation.php | 6 +++--- 4 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2649aa9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +.github export-ignore +tests export-ignore +.gitattributes export-ignore +.gitignore export-ignore +patchwork.json export-ignore +phpcs.xml export-ignore +phpstan.neon.dist export-ignore +README.md export-ignore + diff --git a/src/Model/PluginFamily.php b/src/Model/PluginFamily.php index d63bee7..b3e616d 100644 --- a/src/Model/PluginFamily.php +++ b/src/Model/PluginFamily.php @@ -6,6 +6,19 @@ * Handles the data to be passed to the frontend. */ class PluginFamily { + + /** + * An array of referrers for wp rocket. + * + * @var array + */ + protected $wp_rocket_referrer = [ + 'imagify-plugin' => 'imagify', + 'seo-by-rank-math' => '', + 'backwpup' => '', + 'uk-cookie-consent' => '', + ]; + /** * Get filtered plugins. * @@ -40,6 +53,7 @@ public function filter_plugins_by_activation( array $plugins, string $main_plugi $plugin_path = $plugin . '.php'; $plugin_slug = dirname( $plugin ); $main_plugin_slug = dirname( $main_plugin ); + $wpr_referrer = 'wp-rocket' !== $main_plugin_slug ? $this->wp_rocket_referrer[ $main_plugin_slug ] : ''; /** * Check for activated plugins and pop them out of the array @@ -96,10 +110,14 @@ public function filter_plugins_by_activation( array $plugins, string $main_plugi // Create unique CTA data for WP Rocket. if ( 'wp-rocket/wp-rocket' === $plugin ) { + $url = 'https://wp-rocket.me/?utm_source=' . $wpr_referrer . '-coupon&utm_medium=plugin&utm_campaign=' . $wpr_referrer; + $plugins[ $cat ]['plugins'][ $plugin ]['cta'] = [ 'text' => 'Get it Now', - 'url' => 'https://wp-rocket.me/?utm_source=imagify-coupon&utm_medium=plugin&utm_campaign=imagify', + 'url' => $url, ]; + + $plugins[ $cat ]['plugins'][ $plugin ]['link'] = $url; } // Set activation text. diff --git a/src/Model/wp_media_plugins.php b/src/Model/wp_media_plugins.php index 46bf8ef..0432334 100644 --- a/src/Model/wp_media_plugins.php +++ b/src/Model/wp_media_plugins.php @@ -14,7 +14,7 @@ ], 'title' => 'Speed Up Your Website, Instantly', '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', + 'link' => '', ], 'imagify-plugin/imagify' => [ 'logo' => [ diff --git a/tests/Fixtures/src/Model/PluginFamily/filterPluginsByActivation.php b/tests/Fixtures/src/Model/PluginFamily/filterPluginsByActivation.php index a2253d7..f37df58 100644 --- a/tests/Fixtures/src/Model/PluginFamily/filterPluginsByActivation.php +++ b/tests/Fixtures/src/Model/PluginFamily/filterPluginsByActivation.php @@ -196,7 +196,7 @@ ], 'title' => 'Speed Up Your Website, Instantly', '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', + 'link' => 'https://wp-rocket.me/?utm_source=-coupon&utm_medium=plugin&utm_campaign=', 'cta' => [ 'text' => 'Activate', 'url' => 'http://example.org/wp-admin/admin-post.php?action=plugin_family_install_wp-rocket&_wpnonce=9a68f00b8d&plugin_to_install=wp-rocket%2Fwp-rocket' @@ -251,10 +251,10 @@ ], 'title' => 'Speed Up Your Website, Instantly', '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', + 'link' => 'https://wp-rocket.me/?utm_source=-coupon&utm_medium=plugin&utm_campaign=', 'cta' => [ 'text' => 'Get it Now', - 'url' => 'https://wp-rocket.me/?utm_source=imagify-coupon&utm_medium=plugin&utm_campaign=imagify' + 'url' => 'https://wp-rocket.me/?utm_source=-coupon&utm_medium=plugin&utm_campaign=' ], ], 'imagify-plugin/imagify' => [ From 0c8a7d4c7d248bac6e2fc7ea49be3e421f8b4684 Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Fri, 25 Oct 2024 07:03:43 +0100 Subject: [PATCH 2/7] :fixes: #6 change imagify plugin path --- src/Model/wp_media_plugins.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/wp_media_plugins.php b/src/Model/wp_media_plugins.php index 0432334..6036432 100644 --- a/src/Model/wp_media_plugins.php +++ b/src/Model/wp_media_plugins.php @@ -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%', From 22da91b90dab963cd8c4efb083c501d962b2083d Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Fri, 25 Oct 2024 07:23:51 +0100 Subject: [PATCH 3/7] Fix install event for imagify --- src/Controller/PluginFamily.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/PluginFamily.php b/src/Controller/PluginFamily.php index 26aad5b..eb08d67 100644 --- a/src/Controller/PluginFamily.php +++ b/src/Controller/PluginFamily.php @@ -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', ]; From 2796befc077c18d6ba8fb7cfccec1d84e1cbf2eb Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Fri, 25 Oct 2024 08:15:44 +0100 Subject: [PATCH 4/7] Fix imagify urls --- src/Model/PluginFamily.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/PluginFamily.php b/src/Model/PluginFamily.php index b3e616d..7c57795 100644 --- a/src/Model/PluginFamily.php +++ b/src/Model/PluginFamily.php @@ -92,7 +92,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' ), From 60a034d8a6baa3819a60c07b878ca8b0975f536d Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Fri, 25 Oct 2024 08:19:59 +0100 Subject: [PATCH 5/7] Fix lint error --- src/Model/wp_media_plugins.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Model/wp_media_plugins.php b/src/Model/wp_media_plugins.php index 6036432..e1a1e29 100644 --- a/src/Model/wp_media_plugins.php +++ b/src/Model/wp_media_plugins.php @@ -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%', @@ -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/imagify' => [ + 'imagify/imagify' => [ 'logo' => [ 'file' => 'logo-imagify.svg', 'width' => '50%', From f982832a607e17fe6e014c470bb3cfb0e5ac0e5e Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Fri, 25 Oct 2024 09:47:51 +0100 Subject: [PATCH 6/7] fix test error --- src/Model/PluginFamily.php | 2 +- .../Model/PluginFamily/filterPluginsByActivation.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Model/PluginFamily.php b/src/Model/PluginFamily.php index 7c57795..ef75280 100644 --- a/src/Model/PluginFamily.php +++ b/src/Model/PluginFamily.php @@ -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' => '', diff --git a/tests/Fixtures/src/Model/PluginFamily/filterPluginsByActivation.php b/tests/Fixtures/src/Model/PluginFamily/filterPluginsByActivation.php index f37df58..14ca685 100644 --- a/tests/Fixtures/src/Model/PluginFamily/filterPluginsByActivation.php +++ b/tests/Fixtures/src/Model/PluginFamily/filterPluginsByActivation.php @@ -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%', @@ -116,7 +116,7 @@ 'optimize_performance' => [ 'title' => 'Optimize Performance', 'plugins' => [ - 'imagify-plugin/imagify' => [ + 'imagify/imagify' => [ 'logo' => [ 'file' => 'logo-imagify.svg', 'width' => '50%', @@ -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%', @@ -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%', @@ -312,14 +312,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', ], From 8f58f0d201f9b5a02370c65ec0c5cb0797a1ef97 Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Fri, 25 Oct 2024 12:44:48 +0100 Subject: [PATCH 7/7] Updated README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3afd066..0fa3e28 100644 --- a/README.md +++ b/README.md @@ -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'],