Skip to content

Fix: Update WP Rocket promotional link and UTMs#1023

Open
faisalahammad wants to merge 1 commit intowp-media:developfrom
faisalahammad:fix/issue-1008-update-wpr-banner-link
Open

Fix: Update WP Rocket promotional link and UTMs#1023
faisalahammad wants to merge 1 commit intowp-media:developfrom
faisalahammad:fix/issue-1008-update-wpr-banner-link

Conversation

@faisalahammad
Copy link
Copy Markdown

@faisalahammad faisalahammad commented Feb 27, 2026

Summary

Updates WP Rocket promotion links to correctly track Imagify users with the requested UTM parameters.

Fixes #1008

Problem

The WP Rocket promotional banners and Our Plugins page linked to the default WP Rocket URL with outdated UTM campaigns (imagify-coupon). Users need to be redirected to a targeted landing page (wp-rocket-for-imagify-users/) with updated tracking parameters.

Solution

Updated the generated base URL and the UTM parameter array in imagify_get_wp_rocket_url(). Similarly, updated the dynamic URL assembled for WP Rocket in the PluginFamily component while maintaining existing variable interpolations.

Changes

inc/functions/admin.php

Before:

function imagify_get_wp_rocket_url( $path = false, $query = [] ) {
	$wprocket_url = 'https://wp-rocket.me/';
// ...
	// Query args.
	$query = array_merge(
		[
			'utm_source'   => 'imagify-coupon',
			'utm_medium'   => 'plugin',
			'utm_campaign' => 'imagify',
		],

After:

function imagify_get_wp_rocket_url( $path = false, $query = [] ) {
	$wprocket_url = 'https://wp-rocket.me/wp-rocket-for-imagify-users/';
// ...
	// Query args.
	$query = array_merge(
		[
			'utm_source'   => 'imagify',
			'utm_medium'   => 'partners',
			'utm_campaign' => 'imagify-benefits',
		],

Why this works:
Updating the base URL string directly routes users to the new landing page, and changing the default query array variables preserves existing URL generation logic while strictly satisfying the new UTM tracking requests.

classes/Dependencies/WPMedia/PluginFamily/Model/PluginFamily.php

Before:

				if ( 'wp-rocket/wp-rocket' === $plugin ) {
					$url = 'https://wp-rocket.me/?utm_source=' . $wpr_referrer . '-coupon&utm_medium=plugin&utm_campaign=' . $wpr_referrer;

After:

				if ( 'wp-rocket/wp-rocket' === $plugin ) {
					$url = 'https://wp-rocket.me/wp-rocket-for-imagify-users/?utm_campaign=' . $wpr_referrer . '-benefits&utm_source=' . $wpr_referrer . '&utm_medium=partners';

Why this works:
Modifying the hardcoded URL respects the dynamic $wpr_referrer variable logic previously established, allowing tracking parameters to scale gracefully via existing references.

Testing

Manual Testing

Test Case 1: WP Rocket URL verification

  • Steps:
    1. Build the zip, install in WordPress Admin.
    2. Check the WP Rocket ad banner link on the Settings page.
    3. Navigate to Tools > Our Plugins and check the "Get it Now" link.
  • Result: Banners seamlessly link to https://wp-rocket.me/wp-rocket-for-imagify-users/?utm_campaign=imagify-benefits&utm_source=imagify&utm_medium=partners as expected.

Automated Tests

$ composer test-unit
PHPUnit 9.6.34 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.5.3
Configuration: Tests/Unit/phpunit.xml.dist

........................                                          24 / 24 (100%)

OK, but incomplete, skipped, or risky tests!
Tests: 24, Assertions: 59, Risky: 5.

Build Artifact

For manual verification, I've attached a build of the plugin with these changes:

imagify-fix-issue-1008.zip

Installation: WordPress Admin > Plugins > Add New > Upload Plugin

Screenshot

image

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Imagify’s WP Rocket promotional destinations to point to the new “Imagify users” landing page and to use the requested UTM tracking values.

Changes:

  • Updated imagify_get_wp_rocket_url() base URL and default UTM parameters.
  • Updated WP Rocket CTA link generation in the PluginFamily model to use the new landing page and UTMs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
inc/functions/admin.php Switches WP Rocket base URL to the new landing page and updates default UTM parameters used by admin banners/views.
classes/Dependencies/WPMedia/PluginFamily/Model/PluginFamily.php Updates the “Our Plugins” WP Rocket CTA URL to target the new landing page with updated UTMs.
Comments suppressed due to low confidence (1)

inc/functions/admin.php:230

  • imagify_get_wp_rocket_url() appends the locale segment after the base URL. With the new base including wp-rocket-for-imagify-users/, non-English URLs become .../wp-rocket-for-imagify-users/fr/ instead of the existing pattern used elsewhere in this helper (https://wp-rocket.me/fr/...). This likely breaks localized landing pages; consider keeping the base as https://wp-rocket.me/, appending the locale first (when needed), then appending wp-rocket-for-imagify-users/ (and any optional $path).
	$wprocket_url = 'https://wp-rocket.me/wp-rocket-for-imagify-users/';

	// Current lang.
	$lang = imagify_get_current_lang_in( [ 'de', 'es', 'fr', 'it' ] );

	if ( 'en' !== $lang ) {
		$wprocket_url .= $lang . '/';
	}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// 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;
$url = 'https://wp-rocket.me/wp-rocket-for-imagify-users/?utm_campaign=' . $wpr_referrer . '-benefits&utm_source=' . $wpr_referrer . '&utm_medium=partners';
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WP Rocket CTA URL is assembled via manual string concatenation with interpolated values. To avoid malformed query strings and ensure proper URL encoding, build this URL with add_query_arg() (or similar) and encode $wpr_referrer before using it in query values.

Suggested change
$url = 'https://wp-rocket.me/wp-rocket-for-imagify-users/?utm_campaign=' . $wpr_referrer . '-benefits&utm_source=' . $wpr_referrer . '&utm_medium=partners';
$encoded_wpr_referrer = rawurlencode( $wpr_referrer );
$url = add_query_arg(
[
'utm_campaign' => $encoded_wpr_referrer . '-benefits',
'utm_source' => $encoded_wpr_referrer,
'utm_medium' => 'partners',
],
'https://wp-rocket.me/wp-rocket-for-imagify-users/'
);

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@remyperona remyperona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the merge conflicts, and follow the suggestion from the review

faisalahammad added a commit to faisalahammad/imagify-plugin that referenced this pull request Apr 28, 2026
Replace manual string concatenation with WordPress's add_query_arg()
and rawurlencode() to ensure proper URL encoding and avoid malformed
query strings as recommended by code review.

Addresses: wp-media#1023 (comment)
@faisalahammad
Copy link
Copy Markdown
Author

faisalahammad commented Apr 28, 2026

Thank you, @remyperona for the review feedback! I have applied the suggested change in the latest commit (5d155f92).

The WP Rocket CTA URL in PluginFamily.php is now built using rawurlencode() + add_query_arg() instead of manual string concatenation, which properly encodes the $wpr_referrer value and prevents any risk of malformed query strings.

All 24 unit tests continue to pass.

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 28, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@remyperona
Copy link
Copy Markdown
Contributor

Changes are ok, but you still have merge conflicts to fix with the main develop branch

@remyperona remyperona added this to the 2.2.8 milestone Apr 28, 2026
@faisalahammad faisalahammad force-pushed the fix/issue-1008-update-wpr-banner-link branch from 5d155f9 to 499345e Compare April 29, 2026 05:33
@faisalahammad
Copy link
Copy Markdown
Author

Hi @remyperona, thanks for the follow-up! I've rebased the branch onto the latest develop to resolve the merge conflicts.

What happened:

  • The develop branch had 3 new commits since our branch diverged, including PR Replace Mozart by Strauss #1016 (Replace Mozart by Strauss), which changed the dependency tooling and deleted classes/Dependencies/WPMedia/PluginFamily/Model/PluginFamily.php from git tracking (Strauss now generates it in vendor/ at build time, which is gitignored).
  • Our branch previously included a change to that file (the add_query_arg() improvement suggested by Copilot). Since develop no longer tracks that file in git, I dropped that part of the change during the rebase.
  • The inc/functions/admin.php changes (base URL + UTM parameters) are cleanly applied on top of the current develop HEAD.

Current state:

The branch should now be conflict-free and ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get WPR link in banner needs to be updated

3 participants