@@ -231,6 +231,9 @@ public function render(): void {
231
231
}
232
232
233
233
$ attributes = [ 'data-text-domain ' => $ this ->text_domain ];
234
+
235
+ $ buy_now_link = $ this ->get_buy_now_link_with_utms ();
236
+
234
237
if ( self ::STATUS_INACTIVE === $ this ->get_status () ) {
235
238
$ plugin = $ this ->get_plugin ();
236
239
$ plugin_basename = $ plugin ['path ' ] ?? '' ;
@@ -243,20 +246,19 @@ public function render(): void {
243
246
$ caps = 'install_plugins ' ;
244
247
$ attributes ['data-action ' ] = 'install ' ;
245
248
$ button_text = __ ( 'Install & Activate ' , 'gk-gravityview ' );
246
- $ button_href = $ this -> buy_now_link ;
249
+ $ button_href = $ buy_now_link ;
247
250
} else {
248
251
$ caps = 'read ' ;
249
252
$ button_text = __ ( 'Buy Now ' , 'gk-gravityview ' );
250
- $ button_href = $ this -> buy_now_link ;
253
+ $ button_href = $ buy_now_link ;
251
254
}
252
255
253
- $ params = compact ( 'caps ' , 'button_href ' , 'button_text ' , 'attributes ' );
256
+ $ params = compact ( 'caps ' , 'button_href ' , 'button_text ' , 'attributes ' , ' buy_now_link ' );
254
257
$ params = array_merge ( $ params , [
255
258
'type ' => (string ) $ this ->type ,
256
259
'icon ' => (string ) $ this ->icon ,
257
260
'title ' => (string ) $ this ->title ,
258
261
'description ' => (string ) $ this ->description ,
259
- 'buy_now_link ' => (string ) $ this ->buy_now_link ,
260
262
] );
261
263
262
264
// Render the template in a scoped function.
@@ -265,4 +267,20 @@ public function render(): void {
265
267
require GRAVITYVIEW_DIR . 'includes/admin/metaboxes/views/placeholder.php ' ;
266
268
} )();
267
269
}
270
+
271
+ /**
272
+ * Returns the Buy Now link with UTM parameters added.
273
+ *
274
+ * @since TODO
275
+ *
276
+ * @return string The buy now link.
277
+ */
278
+ private function get_buy_now_link_with_utms (): string {
279
+ return add_query_arg ( [
280
+ 'utm_source ' => 'plugin ' ,
281
+ 'utm_medium ' => 'buy_now ' ,
282
+ 'utm_campaign ' => 'placeholders ' ,
283
+ 'utm_term ' => $ this ->text_domain ,
284
+ ], $ this ->buy_now_link );
285
+ }
268
286
}
0 commit comments